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
{ 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
}
}