Question
· Nov 4, 2019

Adding missing PID data to message using Q21

Hi,

I’m working on a project to add specific PID data to an ORU_R01 message by querying our patient system and adding it to the ORU. Here is what I have 
managed to do thus far:
 
-    Received ORU_R01 message
-    Created Q21 message using the PID data included in the ORU message and sent to patient system to query.
-    Received a K21 message with the required PID data
 
I’m stuck at this point now. I want to add a specific piece of the K21 PID data (highlighted below) to the original 
ORU_R01 PID and was hoping you would be able to assist. 
 

I am doing this using Studio. I want to avoid using a BPL. Could anyone help?


Here are me messages:

 

ORU

MSH|^~\&|WINPATH|TDL|NWL|NWL|201910211049||ORU^R01|1021104919F000103|P|2.3

PID||^^NHS|5903615^^HOSP||ZZZTWINKLETEST^MARIA||19630214|F|||^16A EATON RISE^LONDON^^W5 2ER

PV1|||JACK^JACK'S PLACE^^^^^^^NWIP||||||ELK^Mr J Elkabir

ORC|RE|63162|19F000103||CM||||201910211049

OBR|1|63162|19F000103|ESR^ESR^WinPath||201910211044|201910151150||||||testing  Infection risk: N - No known risk||SST^SST|||||||201910211049||HAEM

OBX|1|NM|ESR^Erythrocyte sedimentation rate^Winpath||50|mm/hr|1-20|H|||F

 

    

 Q21

 MSH|^~\&|TIE|R1K|iCS|EHT|201910211049||QBP^Q21|1021104919F000103|P|2.3

QPD|Q21^Get Patient||5903615^^

RCP||10^RD  

 


K21

MSH|^~\&|iCS|EHT|TIE|R1K|20191023144325||RSP^K21|1021104919F000103|P|2.4|||AL|NE|

MSA|AA|1021104919F000103|

QAK||OK|Q21^Get Patient|1|

QPD|Q21^Get Patient||5903615^^

PID|1|5903615^^^PAS^PAS|09002120^^^INT^INT~5903615^^^5^5||ZZZTWINKLETEST^Maria^Patient04^^Miss^^L||20030214000000|F|||16A EATON             RISE^LONDON^^^W1  9ER^^H^07W||020 8222 3232^PRN^PH^^~^NET^Internet^scarey.stearwood@nhs.net^^^^^Y~07775                                                                 101115^PRN^CP^^^^^^~020 8963 1111^WPN^PH^^||^^^^|S|UNK|||||L|||||||||||||PDIAB^20191017^|

PD1|1||QUEENS WALK PRACTICE^SURG^E85057^020 89973041^E85057^|G8746405^BIHOREAU^S^^^DR^QUEENS WALK PRACTICE^6 QUEENS                     WALK^EALING^LONDON^W5  1TP^07W|

QRI||||

Discussion (3)2
Log in or sign up to continue

After you receive the K21 response you could get the patient identifier that you need by looping through all the identifiers that are included in the K21 PID:3(X).1  field and extract the id that you want only if the PID:3(x).4 has a specific value.

Then you could create clone of the ORU message and you can set the value of the PID using the identifier extracted from the K21 response.

 

For example:

If your business process is receiving the ORU message then an example OnRequest method could be like the following one:

 

Method OnRequest(pRequest As EnsLib.HL7.Message, Output pResponse As Ens.Response) As %Status
{
                SET sc=$$$OK
                //assumes that you have created the Q21 here…
                SET sc=..SendRequestSync("PASSystem", Q21msg,.K21Resp)
                IF sc
                {                                             
                                For i=1:1:K21Resp.GetValueAt("PIDgrp.PID:3(*)")
                                {                                             
                                                IF K21Resp.GetValueAt("PIDgrp.PID:3("_i_").4.1")="5"
                                                {
                                                                SET PatID=K21Resp.GetValueAt("PIDgrp.PID:3("_i_").1")
                                                }                                             
                                }
                                SET newORU=pRequest.%ConstructClone()
                                IF $GET(PatID)'="" SET sc=newORU.SetValueAt(PatID,"PIDgrpgrp(1).PIDgrp.PID:3(1).1")
                                //now here you can set the pResponse to be the newORU or you can send it to another Business Host.
                                SET sc=..SendRequestSync("DestinationOfTheFinalORU", newORU ,. newORUResp)
                                SET pResponse=newORUResp
                }
                Quit sc
}

You can do like this as well in case you want to use DTL only ..

<transform sourceClass='EnsLib.HL7.Message' targetClass='EnsLib.HL7.Message' sourceDocType='2.3.1:ADT_A01' targetDocType='2.3.1:ADT_A01' create='copy' language='objectscript' >
<assign value='$extract(source.{MSH:Receivingfacility},1)' property='target.{MSH:Receivingfacility}' action='set' />
</transform>
}
 

I am using MSH:6 but you can use anything here.

In case you need to use any use written function you can create a class extending  "Ens.Util.FunctionSet."

Any class method we write in the class will be added in your DTL method option .