Question
Lionel Woods · Sep 27

Splitting HL7 message into several

I am trying to split a HL7 message (RDE O11) into several messages depending on how many RXC segments there are in the message (Two RXC segments would need to two separate HL7 messages)

I have seen a couple of posts regarding this but am struggling with my BP using ObjectScript, the idea is to take the receiving message and split this before passing it onto another BP

Here is my code so far 

 

Class BDROWA.Transform.OVMO Extends Ens.BusinessProcess [ ClassType = persistent ]


{ Method OnRequest(pRequest As EnsLib.HL7.Message, Output pResponse As Ens.Response) As %Status


{ Set RXCCount = pRequest.GetValueAt("RXCgrp(*).RXC")
For i=1:1:RXCCount
{
Set tMsg = ##class(EnsLib.HL7.Message).%New()
Set tMsg.DocType = pRequest.DocType
Set tMSgCtrl = pRequest.GetValueAt("MSH:10")_"."_i
Do tMsg.SetValueAt(pRequest.GetValueAt("MSH"),"MSH")
Do tMsg.SetValueAt(tMSgCtrl,"MSH:10")
Do tMSg.SetValueAt(pRequest.GetValueAt("PID"),"PID")
Do tMSg.SetValueAt(pRequest.GetValueAt("PV1"),"PV1")
Do tMSg.SetValueAt(pRequest.GetValueAt("ORC"),"ORC")
Do tMSg.SetValueAt(pRequest.GetValueAt("RXE"),"RXE")
Do tMSg.SetValueAt(pRequest.GetValueAt("RXR"),"RXR")
Do tMSg.SetValueAt(pRequest.GetValueAt("PV1"),"PV1")
Do tMSg.SetValueAt(pRequest.GetValueAt("RXCgrp("_i_").RXC"),"RXCgrp(1).RXC")
Do tMSg.SetValueAt(pRequest.GetValueAt("ZRX"),"ZRX")
Set tSC = tMsg.%Save()

Set tSC1 =..SendRequestAsync("Process.BDROWARouter",tMsg)

}
Return tSC
Return tSC1
}

}

Product version: IRIS 2021.1
0
0 90
Discussion (2)2
Log in or sign up to continue

Hi Lionel,

There shouldn't be a need to use %Save() after you've built the HL7 message as you're not saving it to any custom persistent class, plus, the HL7 message will be stored into the EnsLib.HL7.Message class any way.

Once you've created your new HL7 message you can leave out the %Save() and just use; Set tSC=..SendRequestAsync("Process.BDROWARouter",tMsg,0) - the 0 indicating you don't want a response back (assuming that's how you want it set up). Then you can Quit tSC.

If you are anticipating more changes to the custom HL7 you're building it might be good to call a class method for that to split the code up a bit, I've done something similar on my BD integration where I'm sending multiple ZRA's from one RDE message depending on whether or not it's a diluent. I've removed some ..SendRequestAsync lines as it is a multi-site dispensing integration I did for BD, not sure if you're doing the same. Hope this helps.

If $ISOBJECT(pRequest.FindSegment("RXC"))
{
    $$$LOGINFO("Mixture order. Drug information will be taken from the RXC segment, but only if there's an 'A' present in RXC:1.")
    
    Set RXCCount=pRequest.GetValueAt("RXCgrp(*)")
    For i=1:1:RXCCount
    {
        If (pRequest.GetValueAt("RXCgrp("_i_").RXC:1")="A") && ((pRequest.GetValueAt("RXCgrp("_i_").RXC:2.1")'="") && (pRequest.GetValueAt("RXCgrp("_i_").RXC:3")'=""))
        {
            Set RXCBarcode=pRequest.GetValueAt("RXCgrp("_i_").RXC:2.1")
            Set RXCQuantity=pRequest.GetValueAt("RXCgrp("_i_").RXC:3")
            Set tSC=..BuildZRARequestMsg(pRequest,$GET(DispensingSite),MsgType,"",1,RXCQuantity,RXCBarcode,.ZRAMsg)
            
            If tSC
            {
                If $GET(ZRAMsg)'=""
                {
                    If DispensingSite="ORC" Set tSC=..SendRequestAsync("BD Rowa ORC",ZRAMsg,1,"OrderSent")
                }
            }
        }
    }
}

Sample segments (modified)...

RXC|A|00000000001^Med1^ADS|28|Tab^tablet|30|mg^mg|^VALNI XL
RXC|A|00000000011^Med2^ADS|28|Tab^tablet|60|mg^mg|^VALNI XL

Trace showing the split...

Jordan

Hey Lionel.

I did write an article about this a little while ago which I hope can walk you through what you're looking to achieve, with the difference being to pivot from using the ORCGrp counts like I had, and instead using RXCgrp and then setting the transform to have a source and target class of RDE O11.

If you do ty to follow this approach, I'm more than happy to answer any questions you have.