Sidebar

How do I split a DFT message with multiple FT1 segments into one DFT per FT1

+1 vote
729 views
asked Jan 26, 2016 by marcus-r-8406 (160 points)
edited Jan 26, 2016 by marcus-r-8406

CB can only accept 1 FT1 segment per DFT message.  So we are needing to create one message per FT1 segment.  How would I go about doing this?

How would I split this message into four DFT messages:

MSH|^~\&|LinkLogic-2847|TEST000^MHS|PracticeMgr|MHS|20150903172205||DFT^P03|1756920101108260|P|2.3.1|||NE|NE
EVN|P03|20150903172205
PID|1||98-2847001||TEST^CHRISTINA||20040319|F||||||||U||||||U
PV1|1|O|^^^MHS||||acardino
FT1|1|||20150903|20150903170513|DP|CPT-90700|Daptacel Intramuscular Suspension 10-15-||1||||||^^^SOUTH|||Z23^^I10||01234||26-1|01234|CPT-90700
FT1|2|||20150903|20150903170513|DP|CPT-90632|Vaqta Intramuscular Suspension 50 UNIT/M||1||||||^^^SOUTH|||Z23^^I10||01234||26-3|01234|CPT-90632
FT1|3|||20150903|20150903170513|DP|CPT-90472|Addl Vx - Ix admin via ID IM or jet inje||1||||||^^^SOUTH|||Z23^^I10||01234||26-4|01234|CPT-90472
FT1|4|||20150903|20150903171659|DP|CPT-90702|DT||1||||||^^^SOUTH|||I10^^I10^401.1^^I9||01234||26-5|01234|CPT-90702
 

1 Answer

0 votes
 
Best answer

This can be accomplished with a custom mapping using the code below.

 

// Get headers to use on all new messages

var headers = message.getNode('MSH[group=!FT1]');

//Retrieve the FT1 Segments

var ft1Groups = message.getAllNodes('FT1[group=!FT1]');

//Loop Through Each one

for (var i=0 ; i < ft1Groups.length ; i++) {

   //Set newMessage to the headers and the individual FT1 Segment

   var newMessage = qie.parseHL7String(headers + ft1Groups[i]);

   //Reset FT1-1 to "1"

   newMessage.setNode('FT1-1', '1');

   //  Ensure we have a unique id in MSH-10 (message ID)

   //  so the messages don't error out in the receiving system

   newMessage.setNode('MSH-10', newMessage.getNode('MSH-10') + '-' + i);

   // Send the new message through to the remaining nodes

   qie.spawnNewMessage(newMessage);

}

//Discard original message as it is no longer needed.

message.discard();

After this mapping function, you will need to create a new mapping node for any additional mapping functions. Most cases you will not use source.getNode after a spawn. Use message.getNode in mappings that follow the spawn.

answered Jan 26, 2016 by brandon-w-8204 (33,270 points)
edited Feb 9, 2017 by michael-h-5027
...