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

Multiple XML segments from HL7

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

  • Multiple XML segments from HL7

    I am trying to convert an HL7 ADT message into XML that I can then use to update our practice management system via API.
    The XML should look like (this is a subset)
    Code:
    <Patients>
      <PatientRecord>
    	<HL7>
    	<MessageType>ADT</MessageType>
    	<TriggerEvent>A04</TriggerEvent>
    	</HL7>
    	<Key>
    	  <KeyData> 
              <Field>"USER2"</Field>
              <Data>1234</Data>
              </KeyData>
    	</Key>
        <Patient>
          <BILLUNIQUE>6</BILLUNIQUE>
          <LAST>Sawyer</LAST>
          <FIRST>Michelle</FIRST>
        </Patient>
        <Bill>
          <BILLUNIQUE>6</BILLUNIQUE>
          <LAST>Adams</LAST>
          <FIRST>Tom</FIRST>
          <SALUTE>Mr.</SALUTE>
        </Bill>
    	<Insureds>
    	<Insured>
    	  <ID>1</ID>
    	  <CO_NAME>AETNA Life Ins Company</CO_NAME>
    	</Insured>
    	<Insured>
    	  <ID>2</ID>
    	  <CO_NAME>Blue Cross Blue Shield</CO_NAME>
    	</Insured>
       </Insureds>
      </PatientRecord>
    </Patients>
    I am trying to add on the <Insureds> and <Insured> sections based on the IN1 segments.
    Relevant code in the transform is
    Code:
    var counter = 0;
    var First = true;
    for each (insurance in msg..IN1){
      if(First) {tmp['PatientRecord']['Insureds']=<Insureds></Insureds>;
                 First = false;
        }; 
    tmp['PatientRecord']['Insureds']['Insured'][counter]=<Insured><ID></ID>
    <PATUNIQUE></PATUNIQUE><INS_REL></INS_REL><CO_NAME></CO_NAME><CO_STRT></CO_STRT><CO_CITY></CO_CITY>
    <CO_STATE></CO_STATE><CO_ZIP></CO_ZIP><CO_PHONE></CO_PHONE><CO_ATTN></CO_ATTN><INS_LAST></INS_LAST>
    <INS_FIRST></INS_FIRST><INS_STRT></INS_STRT><INS_CITY></INS_CITY><INS_STAT></INS_STAT><INS_ZIP></INS_ZIP>
    <INS_NUM></INS_NUM><INS_GRP></INS_GRP><INS_GPNM></INS_GPNM><INS_DOB></INS_DOB><INS_SEX></INS_SEX>
    <INS_EMP></INS_EMP><EFFECTIVE></EFFECTIVE>
    <EXPIRE></EXPIRE><IGRPUNIQUE></IGRPUNIQUE></Insured>;
    tmp['PatientRecord']['Insureds']['Insured'][counter]['ID'] = insurance['IN1.22']['IN1.22.1'].toString();
    tmp['PatientRecord']['Insureds']['Insured'][counter]['CO_NAME']=insurance['IN1.4'].toString();
        counter++;
    }
    The error I get is
    TypeError: Cannot set property "ID" of undefined to ""

    I'm thinking that I am not adding to the outgoing tmp properly, but haven't been able to find an answer in the forum or looking through the E4XML docs...yet.
    Tried names of segments in double quotes. Tried names of segments in XML() function in quotes.

  • #2
    Same problem!

    Originally posted by dugjohnson View Post
    I am trying to convert an HL7 ADT message into XML that I can then use to update our practice management system via API.
    The XML should look like (this is a subset)
    Code:
    <Patients>
      <PatientRecord>
    	<HL7>
    	<MessageType>ADT</MessageType>
    	<TriggerEvent>A04</TriggerEvent>
    	</HL7>
    	<Key>
    	  <KeyData> 
              <Field>"USER2"</Field>
              <Data>1234</Data>
              </KeyData>
    	</Key>
        <Patient>
          <BILLUNIQUE>6</BILLUNIQUE>
          <LAST>Sawyer</LAST>
          <FIRST>Michelle</FIRST>
        </Patient>
        <Bill>
          <BILLUNIQUE>6</BILLUNIQUE>
          <LAST>Adams</LAST>
          <FIRST>Tom</FIRST>
          <SALUTE>Mr.</SALUTE>
        </Bill>
    	<Insureds>
    	<Insured>
    	  <ID>1</ID>
    	  <CO_NAME>AETNA Life Ins Company</CO_NAME>
    	</Insured>
    	<Insured>
    	  <ID>2</ID>
    	  <CO_NAME>Blue Cross Blue Shield</CO_NAME>
    	</Insured>
       </Insureds>
      </PatientRecord>
    </Patients>
    I am trying to add on the <Insureds> and <Insured> sections based on the IN1 segments.
    Relevant code in the transform is
    Code:
    var counter = 0;
    var First = true;
    for each (insurance in msg..IN1){
      if(First) {tmp['PatientRecord']['Insureds']=<Insureds></Insureds>;
                 First = false;
        }; 
    tmp['PatientRecord']['Insureds']['Insured'][counter]=<Insured><ID></ID>
    <PATUNIQUE></PATUNIQUE><INS_REL></INS_REL><CO_NAME></CO_NAME><CO_STRT></CO_STRT><CO_CITY></CO_CITY>
    <CO_STATE></CO_STATE><CO_ZIP></CO_ZIP><CO_PHONE></CO_PHONE><CO_ATTN></CO_ATTN><INS_LAST></INS_LAST>
    <INS_FIRST></INS_FIRST><INS_STRT></INS_STRT><INS_CITY></INS_CITY><INS_STAT></INS_STAT><INS_ZIP></INS_ZIP>
    <INS_NUM></INS_NUM><INS_GRP></INS_GRP><INS_GPNM></INS_GPNM><INS_DOB></INS_DOB><INS_SEX></INS_SEX>
    <INS_EMP></INS_EMP><EFFECTIVE></EFFECTIVE>
    <EXPIRE></EXPIRE><IGRPUNIQUE></IGRPUNIQUE></Insured>;
    tmp['PatientRecord']['Insureds']['Insured'][counter]['ID'] = insurance['IN1.22']['IN1.22.1'].toString();
    tmp['PatientRecord']['Insureds']['Insured'][counter]['CO_NAME']=insurance['IN1.4'].toString();
        counter++;
    }
    The error I get is
    TypeError: Cannot set property "ID" of undefined to ""

    I'm thinking that I am not adding to the outgoing tmp properly, but haven't been able to find an answer in the forum or looking through the E4XML docs...yet.
    Tried names of segments in double quotes. Tried names of segments in XML() function in quotes.
    I have the same problem, can anyone help with the answer, but XML TO XML?

    Comment

    Working...
    X