web stats
Multiple XML segments from HL7 - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 07-01-2008, 01:45 PM
dugjohnson dugjohnson is offline
OBX.2 Kenobi
 
Join Date: Jan 2007
Posts: 52
dugjohnson
Default 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.
Reply With Quote
  #2  
Old 01-04-2017, 06:37 AM
arber arber is offline
What's HL7?
 
Join Date: Dec 2016
Posts: 1
arber is on a distinguished road
Default Same problem!

Quote:
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?
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple DG1 Segments into a database mrslatezb Support 3 02-24-2016 06:14 PM
Receive multiple OBX segments nilesh Support 16 02-07-2013 02:24 PM
Multiple IN1 Segments with Optional IN2 Segments bdilworth Support 4 07-29-2008 11:24 AM
Multiple insurance segments dfelton Support 5 10-17-2007 06:32 AM
Mapping Multiple Segments Datawalke Development 1 07-18-2007 05:37 PM


All times are GMT -8. The time now is 03:53 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2020, vBulletin Solutions, Inc.
Mirth Corporation