Announcement

Collapse
No announcement yet.

NTE to OBX Pairing and Conversion

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

  • NTE to OBX Pairing and Conversion

    Hello! Recently just learned how to start iterating but I am now facing a problem. This is part of the file I'm working on:

    OBR|1|LB00869554|19060935|URINES^URINALYSIS|R|2019 1015000300||||||||20191015000300||00^N/A||OPD^OPD||||20191015001745||||||OPD^OPD
    OBX|1|ST|UMACE^Physical Examination||""||||||F
    OBX|2|ST|UCOLOR^ Color||Yellow|||N|||F|||20191015001740|CTRLAB^CENT RAL LAB|JMDELACRUZ^Jessica May E. Dela Cruz PRC 0078638
    OBX|3|ST|UAPP^ Appearance||Slightly Turbid|||N|||F|||20191015001740|CTRLAB^CENTRAL LAB|JMDELACRUZ^Jessica May E. Dela Cruz PRC 0078638
    OBX|4|ST|UPH^ Reaction / pH||5.0|||N|||F|||20191015001740|CTRLAB^CENTRAL LAB|JMDELACRUZ^Jessica May E. Dela Cruz PRC 0078638
    OBX|5|ST|USG^ Specific Gravity||1.015|||N|||F|||20191015001740|CTRLAB^CEN TRAL LAB|JMDELACRUZ^Jessica May E. Dela Cruz PRC 0078638
    OBX|6|ST|UPRO^ Protein||Negative|||N|||F|||20191015001740|CTRLAB^ CENTRAL LAB|JMDELACRUZ^Jessica May E. Dela Cruz PRC 0078638
    OBX|7|ST|USU^ Sugar||Negative|||N|||F|||20191015001740|CTRLAB^CE NTRAL LAB|JMDELACRUZ^Jessica May E. Dela Cruz PRC 0078638
    OBX|8|ST|HUMICH^Microscopic||""||||||F
    OBX|9|ST|FPC^ Pus Cells||0-1|/HPF||N|||F|||20191015001740|CTRLAB^CENTRAL LAB|JMDELACRUZ^Jessica May E. Dela Cruz PRC 0078638
    OBX|10|ST|SMRBC^ RBC||4-6|/HPF||N|||F|||20191015001740|CTRLAB^CENTRAL LAB|JMDELACRUZ^Jessica May E. Dela Cruz PRC 0078638
    NTE|1||\.br\RBC Morphology: 15% Normocytic, 85% Dysmorphic
    OBX|11|ST|UYC^ Yeast Cells||!|/HPF||N|||D|||20191015001740|CTRLAB^CENTRAL LAB|JMDELACRUZ^Jessica May E. Dela Cruz PRC 0078638

    I need to do some mapping and use an outbound template as so:
    MSH|^~\&|||||||^|||2.5
    PID|||||^^|||
    PV1|||||||||||||||||||||||||||||||||||||||||||||
    ORC||||||||||^^^||^^^^|||||||||||
    OBR||||^||||||||||||^^^||||||||||||||||&&&^^|&&&^^ |&&&^^|&&&^^||||||||||||||||^^|^^|^^|^^|^^|^^|^^|| ||

    Currently, I map OBX using the following javascript:
    var i = 0;

    for each (seg in msg..OBX)
    {
    var obx = createSegment('OBX', tmp, i);
    obx['OBX.1']['OBX.1.1'] = seg['OBX.1']['OBX.1.1'].toString();
    obx['OBX.2']['OBX.2.1'] = seg['OBX.2']['OBX.2.1'].toString();
    obx['OBX.3']['OBX.3.1'] = seg['OBX.3']['OBX.3.1'].toString();
    obx['OBX.3']['OBX.3.2'] = seg['OBX.3']['OBX.3.2'].toString();
    obx['OBX.5']['OBX.5.1'] = seg['OBX.5']['OBX.5.1'].toString();
    obx['OBX.6']['OBX.6.1'] = seg['OBX.6']['OBX.6.1'].toString();
    obx['OBX.7']['OBX.7.1'] = seg['OBX.7']['OBX.7.1'].toString();
    obx['OBX.11']['OBX.11.1'] = seg['OBX.11']['OBX.11.1'].toString();
    obx['OBX.19']['OBX.19.1'] = msg['OBR']['OBR.22']['OBR.22.1'].toString();
    i++;
    }

    I am now tasked with converting NTE segments into OBX segments, with the conditions that:
    NTE-1 will continue the OBX-1 numbering
    NTE-3 will become OBX-5
    Succeeding OBX-1 will continue the numbering scheme

    For the given sample, it should become
    OBR|1|LB00869554|19060935|URINES^URINALYSIS|R|2019 1015000300||||||||20191015000300||00^N/A||OPD^OPD||||20191015001745||||||OPD^OPD
    OBX|1|ST|UMACE^Physical Examination||""||||||F
    OBX|2|ST|UCOLOR^ Color||Yellow|||N|||F|||20191015001740|CTRLAB^CENT RAL LAB|JMDELACRUZ^Jessica May E. Dela Cruz PRC 0078638
    OBX|3|ST|UAPP^ Appearance||Slightly Turbid|||N|||F|||20191015001740|CTRLAB^CENTRAL LAB|JMDELACRUZ^Jessica May E. Dela Cruz PRC 0078638
    OBX|4|ST|UPH^ Reaction / pH||5.0|||N|||F|||20191015001740|CTRLAB^CENTRAL LAB|JMDELACRUZ^Jessica May E. Dela Cruz PRC 0078638
    OBX|5|ST|USG^ Specific Gravity||1.015|||N|||F|||20191015001740|CTRLAB^CEN TRAL LAB|JMDELACRUZ^Jessica May E. Dela Cruz PRC 0078638
    OBX|6|ST|UPRO^ Protein||Negative|||N|||F|||20191015001740|CTRLAB^ CENTRAL LAB|JMDELACRUZ^Jessica May E. Dela Cruz PRC 0078638
    OBX|7|ST|USU^ Sugar||Negative|||N|||F|||20191015001740|CTRLAB^CE NTRAL LAB|JMDELACRUZ^Jessica May E. Dela Cruz PRC 0078638
    OBX|8|ST|HUMICH^Microscopic||""||||||F
    OBX|9|ST|FPC^ Pus Cells||0-1|/HPF||N|||F|||20191015001740|CTRLAB^CENTRAL LAB|JMDELACRUZ^Jessica May E. Dela Cruz PRC 0078638
    OBX|10|ST|SMRBC^ RBC||4-6|/HPF||N|||F|||20191015001740|CTRLAB^CENTRAL LAB|JMDELACRUZ^Jessica May E. Dela Cruz PRC 0078638
    OBX|11||||\.br\RBC Morphology: 15% Normocytic, 85% Dysmorphic
    OBX|12|ST|UYC^ Yeast Cells||!|/HPF||N|||D|||20191015001740|CTRLAB^CENTRAL LAB|JMDELACRUZ^Jessica May E. Dela Cruz PRC 0078638

    Messages I receive may have any number of OBX and NTE lines. Any help or hints towards a good solution are very much appreciated. Thanks!
    Last edited by Golfmachine; 11-18-2019, 09:48 PM.

  • #2
    If anyone is interested, I got this to work but I needed both transformers. In source:

    var i = 0;

    for each(seg in msg.children()){
    if(seg.name() == "OBX"){
    var obx = createSegment('OBX', tmp, i);
    obx['OBX.1']['OBX.1.1'] = seg['OBX.1']['OBX.1.1'].toString();
    obx['OBX.2']['OBX.2.1'] = seg['OBX.2']['OBX.2.1'].toString();
    obx['OBX.3']['OBX.3.1'] = seg['OBX.3']['OBX.3.1'].toString();
    obx['OBX.3']['OBX.3.2'] = seg['OBX.3']['OBX.3.2'].toString();
    obx['OBX.5']['OBX.5.1'] = seg['OBX.5']['OBX.5.1'].toString();
    obx['OBX.6']['OBX.6.1'] = seg['OBX.6']['OBX.6.1'].toString();
    obx['OBX.7']['OBX.7.1'] = seg['OBX.7']['OBX.7.1'].toString();
    obx['OBX.11']['OBX.11.1'] = seg['OBX.11']['OBX.11.1'].toString();
    obx['OBX.19']['OBX.19.1'] = msg['OBR']['OBR.22']['OBR.22.1'].toString();
    i++;
    }
    if(seg.name() == "NTE") {
    var obx = createSegment('OBX', tmp, i);
    obx['OBX.2']['OBX.2.1'] = "ST";
    obx['OBX.3']['OBX.3.1'] = "NOTES";
    obx['OBX.3']['OBX.3.2'] = "Comment";
    obx['OBX.5']['OBX.5.1'] = seg['NTE.3']['NTE.3.1'].toString();
    obx['OBX.19']['OBX.19.1'] = msg['OBR']['OBR.22']['OBR.22.1'].toString();
    i++;
    }
    }

    In destination:
    var i = 0;

    for each (seg in msg..OBX)
    {
    seg['OBX.1']['OBX.1.1'] = i+1;
    i++;
    }

    Comment


    • #3
      Add this to the bottom of your source transformer, and you shouldn't need the destination. You need to iterate over tmp instead of msg since that's where you want to do your renumbering.
      Code:
      for (var i = 0; i < tmp.OBX.length(); i++) {
          tmp['OBX'][i]['OBX.1']['OBX.1.1'] = i+1;
      }
      Last edited by agermano; 11-20-2019, 07:20 AM.

      Comment

      Working...
      X