Announcement

Collapse
No announcement yet.

Error reading multiple OBX

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

  • Error reading multiple OBX

    I'm sure this is a total newbie question, but I can't figure out what I'm doing wrong.

    I'm reading a message with multiple OBX segments like this:

    MSH|^~\&|MGRM-HL7|MGRM|MGRM_APP|MGRM_FAC|200612121023||ORU^R01|7 10|D|2.3
    PID||123456789||||||F||||||||||1|
    ORC|RE|REFID-PSGT-222|11-111111||F||||200608181348|||^Smith^James^|||||||
    OBR|1|REFID-PSGT-222|11-111111|V7000^PhenoSense GT|||200610121135|||||||200610131135||^Smith^James ^||||||200608181348|||F||||||||||||||||||||
    OBX|1|ST|PSGTFile^PhenoSense GT Report Filename||REFID-PSGT-222_11-111111-PSGT_F.PDF||||||F|||||||
    OBX|2|ST|PSFile^PhenoSense HIV Report Filename||||||||X|||||||
    OBX|3|ST|GSFile^GeneSeq HIV Report Filename||REFID-PSGT-222_11-111111-1G0-1_F.PDF||||||F|||||||
    OBX|4|ST|RCVal^RC Value||0.13%||||||F|||||||
    OBX|5|ST|RCLow^RC Low||0.08%||||||F|||||||
    OBX|6|ST|RCHigh^RC High||0.21%||||||F|||||||
    OBX|7|ST|3TC-PSGT^Lamivudine Net Assessment||||||||X|||||||
    OBX|8|ST|ABC-PSGT^Abacavir Net Assessment||||||||X|||||||
    OBX|9|ST|AMP-PSGT^Fosamprenavir Net Assessment||||||||X|||||||

    As a test in my transformer, I'm just trying to read the OBX line numbers into a variable:

    Code:
    var test
    
    for (obx in msg..OBX){
    	test += obx['OBX.1']['OBX.1.1'].toString() + ',';
    }
    ...which results in the error, "Cannot read property "OBX.1.1" from undefined"

    Can someone point me in the right direction?

    Thanks!

  • #2
    Re:Error reading multiple OBX

    Repeating OBX segments with null data
    http://www.mirthproject.org/index.ph...d=3040&catid=2

    Post edited by: nshaik, at: 08/02/2007 12:06

    Comment


    • #3
      Re:Error reading multiple OBX

      Thanks, nshaik! It works with this code:

      Code:
      var obxi = 0;
      var test
      
      while (msg['OBX']['OBX.1']['OBX.1.1'][obxi] != null) {
      	test += msg['OBX'][obxi]['OBX.1']['OBX.1.1'].toString() + ',';
      obxi++;
      }

      But I'm still not clear why the "for" construct doesn't work. It fails with the same error even if I test for null.


      Code:
      var test
      
      for (obx in msg..OBX){
      	if(obx['OBX.1']['OBX.1.1'] != null){
      		test += obx['OBX.1']['OBX.1.1'].toString() + ',';
      	}
      }

      Comment


      • #4
        Re:Error reading multiple OBX

        I'm guessing that you should be using a 'for each' loop rather than a plain for?



        skrugg wrote:
        Thanks, nshaik! It works with this code:

        Code:
        var obxi = 0;
        var test
        
        while (msg['OBX']['OBX.1']['OBX.1.1'][obxi] != null) {
        	test += msg['OBX'][obxi]['OBX.1']['OBX.1.1'].toString() + ',';
        obxi++;
        }

        But I'm still not clear why the "for" construct doesn't work. It fails with the same error even if I test for null.


        Code:
        var test
        
        for (obx in msg..OBX){
        	if(obx['OBX.1']['OBX.1.1'] != null){
        		test += obx['OBX.1']['OBX.1.1'].toString() + ',';
        	}
        }

        Comment

        Working...
        X