Jordan is an Avid Commentator
2 published comments for 2022
User bio
404 bio not found
Member since Oct 16, 2020
Replies:

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

Hi Ciaran,

Might be your best bet to construct a message from scratch and start appending segments in the order you wish, for example, loop through the PIDgrp appending the segments you want to your newly constructed message and then loop through ORCgrp NTE's and append each segment.

You can loop through and append by using code such as:

If ORMIn.GetValueAt("ORCgrp(1).NTE(1)")'=""
{
        Set NTECount=ORMIn.GetValueAt("ORCgrp(1).NTE(*)")
        For i=1:1:NTECount
        {
                Set tSC=ORMOut.AppendSegment(ORMIn.GetSegmentAt("ORCgrp(1).NTE("_i_")"))
         }
}

Hi Jeffrey,

I was able to loop through the specific NTE segments with the following code:

Set NTEGroup=MsgIn.GetValueAt("ORCgrp(1).OBRuniongrp.NTE(*)")
Set i=1
While i<=NTEGroup
{
    Set NTESeg=MsgIn.GetValueAt("ORCgrp(1).OBRuniongrp.NTE("_i_")")
    $$$TRACE(NTESegIndex)
    Set i=i+1
}

The trouble I have now is moving these NTE's to the end of the message beneath the SPM segment without it disrupting anything else. I am attempting to do this by first of all getting the segment index and then removing the segment referenced (commented out below). I am then getting the full segment string and importing that as a segment to then append them to the outbound message.

Set NTEGroup=MsgIn.GetValueAt("ORCgrp(1).OBRuniongrp.NTE(*)")
Set i=1
While i<=NTEGroup
 {
    Set NTESegIndex=MsgIn.GetSegmentIndex("ORCgrp(1).OBRuniongrp.NTE("_i_")")
    ;Set tSC=MsgOut.RemoveSegmentAt(NTESegIndex)
    Set NTEStr=MsgIn.GetValueAt("ORCgrp(1).OBRuniongrp.NTE("_i_")")
    Set NTE=##class(EnsLib.HL7.Segment).ImportFromString(NTEStr,.tSC,MsgIn.Separators)
    Set tSC=MsgOut.AppendSegment(NTE)
    Set i=i+1
 }

If I remove the RemoveSegmentAt() line, the segments are appending without any issues. Once I start using the RemoveSegmentAt() line, they still append but it causes some issues with other segments by removing the SPM segment and not removing all the NTE's expectedly.

Without RemoveSegmentAt()

NTE|1||Transfusion indications->Hgb <= 9 g/dL with chronic transfusion therapy
NTE|2||Has consent been obtained?->Yes
SPM|1|||Environment^Environmental sample||||||||||||||||Y
NTE|1||Transfusion indications->Hgb <= 9 g/dL with chronic transfusion therapy
NTE|2||Has consent been obtained?->Yes

With RemoveSegmentAt()

NTE|2||Has consent been obtained?->Yes
NTE|1||Transfusion indications->Hgb <= 9 g/dL with chronic transfusion therapy
NTE|2||Has consent been obtained?->Yes

Is there another recommended way of doing this?

Thanks!

Edit - I've been able to achieve this by creating a new message and building it from scratch and only looping through and grabbing the segments I need.

Followers:
Jordan has no followers yet.
Following:
Jordan has not followed anybody yet.
Global Masters badges:
Jordan has no Global Masters badges yet.