Adding missing PID data to message using Q21

Primary tabs


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:





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


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





QPD|Q21^Get Patient||5903615^^






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^^^^^^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|


  • 0
  • 0
  • 57
  • 0
  • 2


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