Sidebar

How can I create my own custom HL7, XML, CSV message model object.

0 votes
2.5K views
asked Jun 5, 2015 by gary-t-8719 (14,860 points)

1 Answer

+1 vote
In the following example a new HL7 message model object is created from the ORC segment groups (ORC, OBR, NTE, and DG1 segments respectively). This newly created object can then be modified using all of the “Message” object functions (e.g message.getNode, message.setNode, et cetera) by replacing message with new object name “orcGroup”.
Sample message:
 
MSH|^~\&|EHR|Test^E IM|Imaging|E IM |20120807170000||ORU^R01|1659978|P|2.3.1|||NE|NE
PID|1||80-TEST011|MR-000-002|Bassett^Don^C.||19470612|M||W|12155 SW Broadway^^Beaverton^OR^97005^USA||503-629-5541^^^dbassett@aol.com|503-692-8955|English|M|||543-34-5621|||N
PV1|1|O|^^^E IM||||kstarr
ORC|NW|71798-1|||||||20120608|||hwinston
OBR|1|71798-1||XR013^Xray-Ankle|||20120608||1||N|||||hwinston|||||||||||^^^^^R
NTE|1||Specify Right ankle
DG1|1|I9|V70.0^GENERAL MEDICAL EXAM^I9|GENERAL MEDICAL EXAM
ORC|NW|71798-2|||||||20120608|||hwinston
OBR|1|71798-2||US003^US-ABDOMEN|||20120608||1||N|||||hwinston|||||||||||^^^^^R
NTE|1||Patient should be fasting 24hrs prior to test
DG1|1|I9|V70.0^GENERAL MEDCICAL EXAM^I9|GENERAL MEDICAL EXAM
 
   // Get all of the ORC segment groups
var orcGroups = source.getAllNodes('ORC[group=!ORC]');
   // Loop through each group separately
for (var i=0 ; i < orcGroups.length ; i++) {
   // parse the group as an HL7 string (aka create a new HL7
   // message object out of just the ORC, OBR, NTE, and DG1
   // segments    
var orcGroup = qie.parseHL7String(orcGroups[i]);
   // perform relevant functions to the group using the new
   // object with all of the same built in functions that
   // are available to the message object. See Code Wizard
   // “Message”
   // for available functions.
orcGroup.setNode('ORC-1', i+1); // this line of code works becasue of the qie.parseHL7String(orcGroups[i]) function above.
   // put the newly modified segment group back into the message
message.addChild('/', 'ORC', orcGroup.toString());
}
 
The previouse example illistrates creating a new HL7 message model object. However the concept is the same for all message model types using the QIE System Function -> Parse String -> opitons of Parse CSV, Parse HL7, Parse JSON, and Parse XML.
answered Jun 5, 2015 by gary-t-8719 (14,860 points)
edited Jun 5, 2015 by gary-t-8719
...