Announcement

Collapse

Mirth Connect 3.12.0 Released!

Mirth Connect 3.12.0 is now available as an appliance update and on our GitHub page. This release includes database performance improvements, improves visual HL7 representation, message pruning, keystore handling, PDF generation, community contributions, and fixes several security vulnerabilities. This release also contains many improvements to commercial extensions. See the release notes for the list of fixes and updates.

Download | See What's New | Upgrade Guide | Release Notes

For discussion on this release, see this thread.
See more
See less

Creating OBX segments dynamically

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Creating OBX segments dynamically

    Hello everyone!

    I'm trying to create dynamically an unknown number of OBX. The number are going to be based on the number of rows from the result set on my SQL statement.

    I did this...

    ================================================== ===========================
    var data = msg['OBX DATA FROM DB'];
    var obx = tmp['OBX'];
    var i = 0;

    while (i < data.length)
    {
    if (msg['glucose'] > 0)
    {
    tmp['OBX'][i] = obx;
    tmp['OBX'][i]['OBX.1']['OBX.1.1'] = i;
    tmp['OBX'][i]['OBX.2']['OBX.2.1'] = 'NM';
    tmp['OBX'][i]['OBX.3']['OBX.3.1'] = '302789003';
    tmp['OBX'][i]['OBX.3']['OBX.3.2'] = 'Glucose'
    tmp['OBX'][i]['OBX.3']['OBX.3.3'] = 'SNOMED-CT';
    tmp['OBX'][i]['OBX.4']['OBX.4.1'] = '';
    tmp['OBX'][i]['OBX.5']['OBX.5.1'] = msg['glucose'].toString();
    tmp['OBX'][i]['OBX.6']['OBX.6.1'] = '258813002';
    tmp['OBX'][i]['OBX.6']['OBX.6.2'] = 'mmol/L';
    tmp['OBX'][i]['OBX.6']['OBX.6.3'] = 'SNOMED-CT';
    tmp['OBX'][i]['OBX.7']['OBX.7.1'] = '3-6';
    tmp['OBX'][i]['OBX.8']['OBX.8.1'] = '';
    tmp['OBX'][i]['OBX.9']['OBX.9.1'] = '';
    tmp['OBX'][i]['OBX.10']['OBX.10.1'] = '';
    tmp['OBX'][i]['OBX.11']['OBX.11.1'] = 'F';
    tmp['OBX'][i]['OBX.12']['OBX.12.1'] = '';
    tmp['OBX'][i]['OBX.13']['OBX.13.1'] = '';
    tmp['OBX'][i]['OBX.14']['OBX.14.1'] = msg['screeningdate'].toString();
    tmp['OBX'][i]['OBX.15']['OBX.15.1'] = '';
    tmp['OBX'][i]['OBX.16']['OBX.16.1'] = '';
    tmp['OBX'][i]['OBX.17']['OBX.17.1'] = '';
    }
    if (msg['height'] > 0)
    {
    tmp['OBX'][i] = obx;
    tmp['OBX'][i]['OBX.1']['OBX.1.1'] = i;
    tmp['OBX'][i]['OBX.2']['OBX.2.1'] = 'NM';
    tmp['OBX'][i]['OBX.3']['OBX.3.1'] = '50373000';
    tmp['OBX'][i]['OBX.3']['OBX.3.2'] = 'Normal height';
    tmp['OBX'][i]['OBX.3']['OBX.3.3'] = 'SNOMED-CT';
    tmp['OBX'][i]['OBX.4']['OBX.4.1'] = '';
    tmp['OBX'][i]['OBX.5']['OBX.5.1'] = msg['height'].toString();
    tmp['OBX'][i]['OBX.6']['OBX.6.1'] = '258672001';
    tmp['OBX'][i]['OBX.6']['OBX.6.2'] = 'cm';
    tmp['OBX'][i]['OBX.6']['OBX.6.3'] = 'SNOMED-CT';
    tmp['OBX'][i]['OBX.7']['OBX.7.1'] = '0-200';
    tmp['OBX'][i]['OBX.8']['OBX.8.1'] = '';
    tmp['OBX'][i]['OBX.9']['OBX.9.1'] = '';
    tmp['OBX'][i]['OBX.10']['OBX.10.1'] = '';
    tmp['OBX'][i]['OBX.11']['OBX.11.1'] = 'F';
    tmp['OBX'][i]['OBX.12']['OBX.12.1'] = '';
    tmp['OBX'][i]['OBX.13']['OBX.13.1'] = '';
    tmp['OBX'][i]['OBX.14']['OBX.14.1'] = msg['screeningdate'].toString();
    tmp['OBX'][i]['OBX.15']['OBX.15.1'] = '';
    tmp['OBX'][i]['OBX.16']['OBX.16.1'] = '';
    tmp['OBX'][i]['OBX.17']['OBX.17.1'] = '';
    }
    if (msg['weight'] > 0)
    {
    tmp['OBX'][i] = obx;
    tmp['OBX'][i]['OBX.1']['OBX.1.1'] = i;
    tmp['OBX'][i]['OBX.2']['OBX.2.1'] = 'NM';
    tmp['OBX'][i]['OBX.3']['OBX.3.1'] = '27113001';
    tmp['OBX'][i]['OBX.3']['OBX.3.2'] = 'Body weigh';
    tmp['OBX'][i]['OBX.3']['OBX.3.3'] = 'SNOMED-CT';
    tmp['OBX'][i]['OBX.4']['OBX.4.1'] = '';
    tmp['OBX'][i]['OBX.5']['OBX.5.1'] = msg['weight'].toString();
    tmp['OBX'][i]['OBX.6']['OBX.6.1'] = '258683005';
    tmp['OBX'][i]['OBX.6']['OBX.6.2'] = 'kg';
    tmp['OBX'][i]['OBX.6']['OBX.6.3'] = 'SNOMED-CT';
    tmp['OBX'][i]['OBX.7']['OBX.7.1'] = '0-300';
    tmp['OBX'][i]['OBX.8']['OBX.8.1'] = '';
    tmp['OBX'][i]['OBX.9']['OBX.9.1'] = '';
    tmp['OBX'][i]['OBX.10']['OBX.10.1'] = '';
    tmp['OBX'][i]['OBX.11']['OBX.11.1'] = 'F';
    tmp['OBX'][i]['OBX.12']['OBX.12.1'] = '';
    tmp['OBX'][i]['OBX.13']['OBX.13.1'] = '';
    tmp['OBX'][i]['OBX.14']['OBX.14.1'] = msg['screeningdate'].toString();
    tmp['OBX'][i]['OBX.15']['OBX.15.1'] = '';
    tmp['OBX'][i]['OBX.16']['OBX.16.1'] = '';
    tmp['OBX'][i]['OBX.17']['OBX.17.1'] = '';
    }
    if (msg['heartrate'] > 0)
    {
    tmp['OBX'][i] = obx;
    tmp['OBX'][i]['OBX.1']['OBX.1.1'] = i;
    tmp['OBX'][i]['OBX.2']['OBX.2.1'] = 'NM';
    tmp['OBX'][i]['OBX.3']['OBX.3.1'] = '364075005';
    tmp['OBX'][i]['OBX.3']['OBX.3.2'] = 'Heart rate';
    tmp['OBX'][i]['OBX.3']['OBX.3.3'] = 'SNOMED-CT';
    tmp['OBX'][i]['OBX.4']['OBX.4.1'] = '';
    tmp['OBX'][i]['OBX.5']['OBX.5.1'] = msg['heartrate'].toString();
    tmp['OBX'][i]['OBX.6']['OBX.6.1'] = '258983007';
    tmp['OBX'][i]['OBX.6']['OBX.6.2'] = 'bpm';
    tmp['OBX'][i]['OBX.6']['OBX.6.3'] = 'SNOMED-CT';
    tmp['OBX'][i]['OBX.7']['OBX.7.1'] = '50-100';
    tmp['OBX'][i]['OBX.8']['OBX.8.1'] = '';
    tmp['OBX'][i]['OBX.9']['OBX.9.1'] = '';
    tmp['OBX'][i]['OBX.10']['OBX.10.1'] = '';
    tmp['OBX'][i]['OBX.11']['OBX.11.1'] = 'F';
    tmp['OBX'][i]['OBX.12']['OBX.12.1'] = '';
    tmp['OBX'][i]['OBX.13']['OBX.13.1'] = '';
    tmp['OBX'][i]['OBX.14']['OBX.14.1'] = msg['screeningdate'].toString();
    tmp['OBX'][i]['OBX.15']['OBX.15.1'] = '';
    tmp['OBX'][i]['OBX.16']['OBX.16.1'] = '';
    tmp['OBX'][i]['OBX.17']['OBX.17.1'] = '';
    }
    if (msg['pulseoximetry'] > 0)
    {
    tmp['OBX'][i] = obx;
    tmp['OBX'][i]['OBX.1']['OBX.1.1'] = i;
    tmp['OBX'][i]['OBX.2']['OBX.2.1'] = 'NM';
    tmp['OBX'][i]['OBX.3']['OBX.3.1'] = '252465000';
    tmp['OBX'][i]['OBX.3']['OBX.3.2'] = 'Pulse oximetry';
    tmp['OBX'][i]['OBX.3']['OBX.3.3'] = 'SNOMED-CT';
    tmp['OBX'][i]['OBX.4']['OBX.4.1'] = '';
    tmp['OBX'][i]['OBX.5']['OBX.5.1'] = msg['pulseoximetry'].toString();
    tmp['OBX'][i]['OBX.6']['OBX.6.1'] = '118582008';
    tmp['OBX'][i]['OBX.6']['OBX.6.2'] = '%';
    tmp['OBX'][i]['OBX.6']['OBX.6.3'] = 'SNOMED-CT';
    tmp['OBX'][i]['OBX.7']['OBX.7.1'] = '94-100';
    tmp['OBX'][i]['OBX.8']['OBX.8.1'] = '';
    tmp['OBX'][i]['OBX.9']['OBX.9.1'] = '';
    tmp['OBX'][i]['OBX.10']['OBX.10.1'] = '';
    tmp['OBX'][i]['OBX.11']['OBX.11.1'] = 'F';
    tmp['OBX'][i]['OBX.12']['OBX.12.1'] = '';
    tmp['OBX'][i]['OBX.13']['OBX.13.1'] = '';
    tmp['OBX'][i]['OBX.14']['OBX.14.1'] = msg['screeningdate'].toString();
    tmp['OBX'][i]['OBX.15']['OBX.15.1'] = '';
    tmp['OBX'][i]['OBX.16']['OBX.16.1'] = '';
    tmp['OBX'][i]['OBX.17']['OBX.17.1'] = '';
    }
    if (msg['diastolic'] > 0)
    {
    tmp['OBX'][i] = obx;
    tmp['OBX'][i]['OBX.1']['OBX.1.1'] = i;
    tmp['OBX'][i]['OBX.2']['OBX.2.1'] = 'NM';
    tmp['OBX'][i]['OBX.3']['OBX.3.1'] = '271650006';
    tmp['OBX'][i]['OBX.3']['OBX.3.2'] = 'Diastolic blood pressure';
    tmp['OBX'][i]['OBX.3']['OBX.3.3'] = 'SNOMED-CT';
    tmp['OBX'][i]['OBX.4']['OBX.4.1'] = '';
    tmp['OBX'][i]['OBX.5']['OBX.5.1'] = msg['diastolic'].toString();
    tmp['OBX'][i]['OBX.6']['OBX.6.1'] = '259018001';
    tmp['OBX'][i]['OBX.6']['OBX.6.2'] = 'mmHg';
    tmp['OBX'][i]['OBX.6']['OBX.6.3'] = 'SNOMED-CT';
    tmp['OBX'][i]['OBX.7']['OBX.7.1'] = '0-90';
    tmp['OBX'][i]['OBX.8']['OBX.8.1'] = '';
    tmp['OBX'][i]['OBX.9']['OBX.9.1'] = '';
    tmp['OBX'][i]['OBX.10']['OBX.10.1'] = '';
    tmp['OBX'][i]['OBX.11']['OBX.11.1'] = 'F';
    tmp['OBX'][i]['OBX.12']['OBX.12.1'] = '';
    tmp['OBX'][i]['OBX.13']['OBX.13.1'] = '';
    tmp['OBX'][i]['OBX.14']['OBX.14.1'] = msg['screeningdate'].toString();
    tmp['OBX'][i]['OBX.15']['OBX.15.1'] = '';
    tmp['OBX'][i]['OBX.16']['OBX.16.1'] = '';
    tmp['OBX'][i]['OBX.17']['OBX.17.1'] = '';
    }
    if (msg['systolic'] > 0)
    {
    tmp['OBX'][i] = obx;
    tmp['OBX'][i]['OBX.1']['OBX.1.1'] = i;
    tmp['OBX'][i]['OBX.2']['OBX.2.1'] = 'NM';
    tmp['OBX'][i]['OBX.3']['OBX.3.1'] = '271649006';
    tmp['OBX'][i]['OBX.3']['OBX.3.2'] = 'Systolic blood pressure';
    tmp['OBX'][i]['OBX.3']['OBX.3.3'] = 'SNOMED-CT';
    tmp['OBX'][i]['OBX.4']['OBX.4.1'] = '';
    tmp['OBX'][i]['OBX.5']['OBX.5.1'] = msg['systolic'].toString();
    tmp['OBX'][i]['OBX.6']['OBX.6.1'] = '259018001';
    tmp['OBX'][i]['OBX.6']['OBX.6.2'] = 'mmHg';
    tmp['OBX'][i]['OBX.6']['OBX.6.3'] = 'SNOMED-CT';
    tmp['OBX'][i]['OBX.7']['OBX.7.1'] = '100-140';
    tmp['OBX'][i]['OBX.8']['OBX.8.1'] = '';
    tmp['OBX'][i]['OBX.9']['OBX.9.1'] = '';
    tmp['OBX'][i]['OBX.10']['OBX.10.1'] = '';
    tmp['OBX'][i]['OBX.11']['OBX.11.1'] = 'F';
    tmp['OBX'][i]['OBX.12']['OBX.12.1'] = '';
    tmp['OBX'][i]['OBX.13']['OBX.13.1'] = '';
    tmp['OBX'][i]['OBX.14']['OBX.14.1'] = msg['screeningdate'].toString();
    tmp['OBX'][i]['OBX.15']['OBX.15.1'] = '';
    tmp['OBX'][i]['OBX.16']['OBX.16.1'] = '';
    tmp['OBX'][i]['OBX.17']['OBX.17.1'] = '';
    }
    if (msg['fev1'] > 0)
    {
    tmp['OBX'][i] = obx;
    tmp['OBX'][i]['OBX.1']['OBX.1.1'] = i;
    tmp['OBX'][i]['OBX.2']['OBX.2.1'] = 'NM';
    tmp['OBX'][i]['OBX.3']['OBX.3.1'] = '251930006';
    tmp['OBX'][i]['OBX.3']['OBX.3.2'] = 'FEV1';
    tmp['OBX'][i]['OBX.3']['OBX.3.3'] = 'SNOMED-CT';
    tmp['OBX'][i]['OBX.4']['OBX.4.1'] = '';
    tmp['OBX'][i]['OBX.5']['OBX.5.1'] = msg['fev1'].toString();
    tmp['OBX'][i]['OBX.6']['OBX.6.1'] = '258995007';
    tmp['OBX'][i]['OBX.6']['OBX.6.2'] = 'L/s';
    tmp['OBX'][i]['OBX.6']['OBX.6.3'] = 'SNOMED-CT';
    tmp['OBX'][i]['OBX.7']['OBX.7.1'] = '0-5';
    tmp['OBX'][i]['OBX.8']['OBX.8.1'] = '';
    tmp['OBX'][i]['OBX.9']['OBX.9.1'] = '';
    tmp['OBX'][i]['OBX.10']['OBX.10.1'] = '';
    tmp['OBX'][i]['OBX.11']['OBX.11.1'] = 'F';
    tmp['OBX'][i]['OBX.12']['OBX.12.1'] = '';
    tmp['OBX'][i]['OBX.13']['OBX.13.1'] = '';
    tmp['OBX'][i]['OBX.14']['OBX.14.1'] = msg['screeningdate'].toString();
    tmp['OBX'][i]['OBX.15']['OBX.15.1'] = '';
    tmp['OBX'][i]['OBX.16']['OBX.16.1'] = '';
    tmp['OBX'][i]['OBX.17']['OBX.17.1'] = '';
    }
    if (msg['fvc'] > 0)
    {
    tmp['OBX'][i] = obx;
    tmp['OBX'][i]['OBX.1']['OBX.1.1'] = i;
    tmp['OBX'][i]['OBX.2']['OBX.2.1'] = 'NM';
    tmp['OBX'][i]['OBX.3']['OBX.3.1'] = '50834005';
    tmp['OBX'][i]['OBX.3']['OBX.3.2'] = 'FVC';
    tmp['OBX'][i]['OBX.3']['OBX.3.3'] = 'SNOMED-CT';
    tmp['OBX'][i]['OBX.4']['OBX.4.1'] = '';
    tmp['OBX'][i]['OBX.5']['OBX.5.1'] = msg['fvc'].toString();
    tmp['OBX'][i]['OBX.6']['OBX.6.1'] = '258770004';
    tmp['OBX'][i]['OBX.6']['OBX.6.2'] = 'L';
    tmp['OBX'][i]['OBX.6']['OBX.6.3'] = 'SNOMED-CT';
    tmp['OBX'][i]['OBX.7']['OBX.7.1'] = '4-7';
    tmp['OBX'][i]['OBX.8']['OBX.8.1'] = '';
    tmp['OBX'][i]['OBX.9']['OBX.9.1'] = '';
    tmp['OBX'][i]['OBX.10']['OBX.10.1'] = '';
    tmp['OBX'][i]['OBX.11']['OBX.11.1'] = 'F';
    tmp['OBX'][i]['OBX.12']['OBX.12.1'] = '';
    tmp['OBX'][i]['OBX.13']['OBX.13.1'] = '';
    tmp['OBX'][i]['OBX.14']['OBX.14.1'] = msg['screeningdate'].toString();
    tmp['OBX'][i]['OBX.15']['OBX.15.1'] = '';
    tmp['OBX'][i]['OBX.16']['OBX.16.1'] = '';
    tmp['OBX'][i]['OBX.17']['OBX.17.1'] = '';
    }
    if (msg['pef'] > 0)
    {
    tmp['OBX'][i] = obx;
    tmp['OBX'][i]['OBX.1']['OBX.1.1'] = i;
    tmp['OBX'][i]['OBX.2']['OBX.2.1'] = 'NM';
    tmp['OBX'][i]['OBX.3']['OBX.3.1'] = '18491006';
    tmp['OBX'][i]['OBX.3']['OBX.3.2'] = 'PEF';
    tmp['OBX'][i]['OBX.3']['OBX.3.3'] = 'SNOMED-CT';
    tmp['OBX'][i]['OBX.4']['OBX.4.1'] = '';
    tmp['OBX'][i]['OBX.5']['OBX.5.1'] = msg['pef'].toString();
    tmp['OBX'][i]['OBX.6']['OBX.6.1'] = '258995007';
    tmp['OBX'][i]['OBX.6']['OBX.6.2'] = 'L/s';
    tmp['OBX'][i]['OBX.6']['OBX.6.3'] = 'SNOMED-CT';
    tmp['OBX'][i]['OBX.7']['OBX.7.1'] = '10-30';
    tmp['OBX'][i]['OBX.8']['OBX.8.1'] = '';
    tmp['OBX'][i]['OBX.9']['OBX.9.1'] = '';
    tmp['OBX'][i]['OBX.10']['OBX.10.1'] = '';
    tmp['OBX'][i]['OBX.11']['OBX.11.1'] = 'F';
    tmp['OBX'][i]['OBX.12']['OBX.12.1'] = '';
    tmp['OBX'][i]['OBX.13']['OBX.13.1'] = '';
    tmp['OBX'][i]['OBX.14']['OBX.14.1'] = msg['screeningdate'].toString();
    tmp['OBX'][i]['OBX.15']['OBX.15.1'] = '';
    tmp['OBX'][i]['OBX.16']['OBX.16.1'] = '';
    tmp['OBX'][i]['OBX.17']['OBX.17.1'] = '';
    }
    if (msg['temperature'] > 0)
    {
    tmp['OBX'][i] = obx;
    tmp['OBX'][i]['OBX.1']['OBX.1.1'] = i;
    tmp['OBX'][i]['OBX.2']['OBX.2.1'] = 'NM';
    tmp['OBX'][i]['OBX.3']['OBX.3.1'] = '386725007';
    tmp['OBX'][i]['OBX.3']['OBX.3.2'] = 'Body temperature';
    tmp['OBX'][i]['OBX.3']['OBX.3.3'] = 'SNOMED-CT';
    tmp['OBX'][i]['OBX.4']['OBX.4.1'] = '';
    tmp['OBX'][i]['OBX.5']['OBX.5.1'] = msg['temperature'].toString();
    tmp['OBX'][i]['OBX.6']['OBX.6.1'] = '258710007';
    tmp['OBX'][i]['OBX.6']['OBX.6.2'] = 'degC';
    tmp['OBX'][i]['OBX.6']['OBX.6.3'] = 'SNOMED-CT';
    tmp['OBX'][i]['OBX.7']['OBX.7.1'] = '36.0-37.4';
    tmp['OBX'][i]['OBX.8']['OBX.8.1'] = '';
    tmp['OBX'][i]['OBX.9']['OBX.9.1'] = '';
    tmp['OBX'][i]['OBX.10']['OBX.10.1'] = '';
    tmp['OBX'][i]['OBX.11']['OBX.11.1'] = 'F';
    tmp['OBX'][i]['OBX.12']['OBX.12.1'] = '';
    tmp['OBX'][i]['OBX.13']['OBX.13.1'] = '';
    tmp['OBX'][i]['OBX.14']['OBX.14.1'] = msg['screeningdate'].toString();
    tmp['OBX'][i]['OBX.15']['OBX.15.1'] = '';
    tmp['OBX'][i]['OBX.16']['OBX.16.1'] = '';
    tmp['OBX'][i]['OBX.17']['OBX.17.1'] = '';
    }

    i++;
    }
    ================================================== ===========================

    the OBX are not even being created in my ORU message.

    What should I do to add dynamically OBX segments as much as I need?
    How to retrieve the value from my SELECT statement?

    It doesn't matter how many lines I've got in my result set, I want to create just one ORU messsage.

    Thanks in advance!

    Alexander

    Post edited by: Alexander, at: 05/01/2008 19:13
Working...
X