How to programatically create an HL7 message in a business service and transmit it using a business operation

165 views
Skip to first unread message

cjoh...@gmail.com

unread,
Jan 27, 2014, 11:11:53 AM1/27/14
to Ensemble-in...@googlegroups.com
Hey all,

I have a global containing a list of IDs that I want to generate simple HL7 messages based on to inactivate the items. I am doing this by making a custom business service since there are certain tasks that I only need performed once (e.g. compare one file to an older file to find the items that have been inactivated).

The HL7 message needed to inactivate an item will be very simple--most of the fields will be blank. I was wondering how I can compose the HL7 message in code. Also, the business process that I have currently populates HL7 messages based on a record map. These HL7 messages will already be in HL7 format. Is there a way to send them via the current business process I have, or should I create another one? If I do, how do I programatically send the ad-hoc HL7 inactivation messages via this business process?

I would appreciate any advice that anyone can provide.

Thanks.

Dom

unread,
Feb 14, 2014, 6:38:07 AM2/14/14
to Ensemble-in...@googlegroups.com

Its quite simple to create an HL7 message via code and add values to fields. See example below where I create a new HL7 message and set some fields and take other feilds from another message. make sure you set the DocType else Ensemble will not know how to validate the message. "HL7" object is the new HL7 messageand "Message" object is the existing HL7 message.
 
Set Message=##class(EnsLib.HL7.Message).%OpenId(Source.MessageObjectID)
Set HL7=##class(EnsLib.HL7.Message).%New()
; Build a simple ADT_A01 from the source message so we can data transform it
Set HL7.DocType="2.3:ADT_A01"
;Segment copies
Set tSC=HL7.SetValueAt(Message.GetValueAt("MSH"),"MSH")
Set tSC=HL7.SetValueAt(Message.GetValueAt("EVN"),"EVN")
Set tSC=HL7.SetValueAt(Message.GetValueAt("PID"),"PID")
Set tSC=HL7.SetValueAt(Message.GetValueAt("PD1"),"PD1")
Set tSC=HL7.SetValueAt(Message.GetValueAt("NK1"),"NK1")
Set tSC=HL7.SetValueAt("PV1|","PV1")
; MSH changes
Set tSC=HL7.SetValueAt("SYMPHONYDAD","MSH:3")
Set tSC=HL7.SetValueAt("RW3","MSH:4")
Set tSC=HL7.SetValueAt("CLINICOM","MSH:5")
Set tSC=HL7.SetValueAt("","MSH:6")
Set tSC=HL7.SetValueAt("","MSH:7")
Set tSC=HL7.SetValueAt(xStamp,"MSH:7.1")
Set tSC=HL7.SetValueAt("ADT^A31","MSH:9")
Set tSC=HL7.SetValueAt(xControl,"MSH:10")
Set tSC=HL7.SetValueAt("P","MSH:11")
Set tSC=HL7.SetValueAt("2.4","MSH:12")
Set tSC=HL7.SetValueAt("NE","MSH:15")
Set tSC=HL7.SetValueAt("AL","MSH:16")
Set tSC=HL7.SetValueAt("","MSH:18")
; EVN changes
Set tSC=HL7.SetValueAt("A28","EVN:1")
; PID changes
Set tSC=HL7.SetValueAt("","PID:2")
Set tSC=HL7.SetValueAt(xid,"PID:3")
Set tSC=HL7.SetValueAt("","PID:4")
Set tSC=HL7.SetValueAt(Source.DOB,"PID:7.1")
Reply all
Reply to author
Forward
0 new messages