Announcement

Collapse
No announcement yet.

Source transformer-missing data when indexing a repeating field

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

  • Source transformer-missing data when indexing a repeating field

    Given a field value with repeating values is in OBR.28:
    Code:
    //mangled for readability:
    DOCX^LastNameX^Dr^FirstName X~
    CLINICA^Clinic A Name^~
    DOCY^LastNameY^Dr^FirstName Y|
    Notice that the clinic does NOT have a prefix (like "Dr." or a first name), and the OBR.28.3 and .4 are missing.

    In a source transformer, I am trying to loop through each provider:

    Code:
    while (msg[OBR][OBR.28][providerCount] != null) 
    	{
    		// Get the provider details
    		var mnemonic = msg[OBR][OBR.28][OBR.28.1'][providerCount];		
    		var lastName  = msg[OBR][OBR.28][OBR.28.2'][providerCount];
    		var prefix  = msg[OBR][OBR.28][OBR.28.3'][providerCount];
    		var firstName  = msg[OBR][OBR.28][OBR.28.4'][providerCount]; //
    		
    		//recreate the entire provider based on some custom rules:
    		//[ID]^[FAMILYNAME]^[FIRSTNAME]^^^[PREFIX]^^^[IDTYPE]^^^^[NAMESPACE]
            thisProvider = RebuildProviderSequence(mnemonic,lastName,firstName, prefix); //more processing here; not relevant to this problem.
    		newObx28 += thisProvider + "~";
    	}
    	
    //remove the last tilde.
    //reset our OBR28 to be formatted to our new standard.	
    obr['OBR.28'] = 		newObx28;
    The problem is that the clinic, the provider in the middle, is inheriting the FirstName of the next provider. So ClinicA's first name is "FirstName Y". When it comes time to evaluate FirstName for the last provider - the value is Undefined!

    The good news is that this algorithm works when all field separators are present.

    Do you have any suggestions to help avoid the swapping of FirstNames when the middle provider does NOT have the field included in the HL7?
    Last edited by Philoushka; 08-04-2009, 12:17 PM.

  • #2
    Classic off-by-one error.

    Provider count is probably 1-indexed. So 3 providers is expressed as 3.

    The index for msg[OBR][OBR.28][OBR.28.1'] is 0-indexed. So the 3rd provider would be index 2.

    Try this:
    Code:
    while (msg[OBR][OBR.28][providerCount] != null) 
    	{
    		// Get the provider details
    		var mnemonic = msg[OBR][OBR.28][OBR.28.1'][providerCount-1];		
    		var lastName  = msg[OBR][OBR.28][OBR.28.2'][providerCount-1];
    		var prefix  = msg[OBR][OBR.28][OBR.28.3'][providerCount-1];
    		var firstName  = msg[OBR][OBR.28][OBR.28.4'][providerCount-1]; //
    		
    		//recreate the entire provider based on some custom rules:
    		//[ID]^[FAMILYNAME]^[FIRSTNAME]^^^[PREFIX]^^^[IDTYPE]^^^^[NAMESPACE]
            thisProvider = RebuildProviderSequence(mnemonic,lastName,firstName, prefix); //more processing here; not relevant to this problem.
    		newObx28 += thisProvider + "~";
    	}
    	
    //remove the last tilde.
    //reset our OBR28 to be formatted to our new standard.	
    obr['OBR.28'] = 		newObx28;
    Jon Bartels

    Zen is hiring!!!!
    http://consultzen.com/careers/
    Talented healthcare IT professionals wanted. Engineers to sales to management.
    Good benefits, great working environment, genuinely interesting work.

    Comment


    • #3
      Thanks J. Fortunately for me, I am starting my counter providerCount with value zero. The great thing is that this algorithm works when all fields are present. So everything works well when that middle provider has its separator:

      Code:
      //mangled for readability:
      DOCX^LastNameX^Dr^FirstName X~
      CLINICA^Clinic A Name^^~
      DOCY^LastNameY^Dr^FirstName Y|

      Comment


      • #4
        Try changing the counter (providerCount) position to get the node you want:

        Code:
        var mnemonic = msg['OBR']['OBR.28'][providerCount]['OBR.28.1'];		
        var lastName  = msg['OBR']['OBR.28'][providerCount]['OBR.28.2'];
        var prefix  = msg['OBR']['OBR.28'][providerCount]['OBR.28.3'];
        var firstName  = msg['OBR']['OBR.28'][providerCount]['OBR.28.4']

        Comment

        Working...
        X