Using BP to create multiple messages from a single HL7

Primary tabs

Hi all.

I'm currently working with a system needing results from a lab system, and they can only accept a single OBR per R01 message.

The R01s from the source have multiple OBRs, so I need to be able to send a message per OBR.

I found a similar post where the example was using a BPL, however there's some additional trickery processing that I already have working within an ObjectScript Business Process and would like to avoid trying to recreate in a BPL.

Any sample code will be greatly received smiley

  • + 1
  • 1
  • 108
  • 2
  • 1


I've done something similar with COS, but in my case it was the ORC group that was repeating:

Class HICG.Process.MultiORC Extends Ens.BusinessProcess [ ClassType = persistent ]
Property TargetConfigNames As %String(MAXLEN = 1000);
Parameter SETTINGS = "TargetConfigNames:Basic:selector?multiSelect=1&context={Ens.ContextSearch/ProductionItems?targets=1&productionName=@productionId}";
Method OnRequest(pRequest As EnsLib.HL7.Message, Output pResponse As Ens.Response) As %Status
    Set tORCcnt = pRequest.GetValueAt("PIDgrpgrp(1).ORCgrp(*)")
    For i=1:1:tORCcnt
        Set tMsg = ##class(EnsLib.HL7.Message).%New()
        Set tMsg.DocType = pRequest.DocType
        // Keep MSH:10 unique
        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("PIDgrpgrp(1).PIDgrp.PID"),"PIDgrpgrp(1).PIDgrp.PID")
        Do tMsg.SetValueAt(pRequest.GetValueAt("PIDgrpgrp(1).PIDgrp.PV1grp.PV1"),"PIDgrpgrp(1).PIDgrp.PV1grp.PV1")
        Do tMsg.SetValueAt(pRequest.GetValueAt("PIDgrpgrp(1).ORCgrp("_i_").ORC"),"PIDgrpgrp(1).ORCgrp(1).ORC")
        Do tMsg.SetValueAt(pRequest.GetValueAt("PIDgrpgrp(1).ORCgrp("_i_").OBR"),"PIDgrpgrp(1).ORCgrp(1).OBR")
        Set tOBXcnt = pRequest.GetValueAt("PIDgrpgrp(1).ORCgrp("_i_").OBXgrp(*)")
        For j=1:1:tOBXcnt
            Do tMsg.SetValueAt(pRequest.GetValueAt("PIDgrpgrp(1).ORCgrp("_i_").OBXgrp("_j_").OBX"),"PIDgrpgrp(1).ORCgrp(1).OBXgrp("_j_").OBX")
        Set tSC = tMsg.%Save()
        For iTarget=1:1:$L(..TargetConfigNames, ",")
            Set tTarget=$ZStrip($P(..TargetConfigNames,",",iTarget),"<>W")
            Set tSC1 = ..SendRequestAsync(tTarget,tMsg)
            Set:$$$ISERR(tSC1) tSC=$$$ADDSC(tSC,tSC1)
    Return tSC


I think this would be much easier with BPL/DTL. Why not have your ObjectScript Business Process do its thing, then hand the result to a BPL to loop over OBRs and break it into multiple messages? Or put the BPL first, if your 'trickery' should happen to each generated message individually.


Hi Steve.

The main reason is that I'm trying to reduce the footprint within our Ensemble/interoperability production. However, I'm not too proud to rule it out if I am stuck for other options.