Page 1 of 1

Message creation question

Posted: Fri Dec 14, 2012 2:56 pm
by JerryB123
Hello,

I am trying out DelphiHL7 to create HL7 messages. I do not see any examples of using multiple parameters, so I do not know if I need to explicitly create other objects or if they are created automatically or if there is some other mechanism that needs to be invoked.

Do you have an example of creating a complete TdiORU_R01_26 message with multiple reading results? (BP: 120/80@75, Temperature: 98.6°F, SpO2: 98%) That would be very helpful in showing me how to use DelphiHL7 components to create messages that I need.

Thank you.
Jerry

Re: Message creation question

Posted: Fri Dec 14, 2012 5:57 pm
by admin
Hi,
Please check this link : http://www.delphihl7.com/?action=sample
The following codes are taken from that page.

First example is "Parsing Message" ORU_R01 for V 2.2

Code: Select all


uses diHL722, diHL7DT22, diHL7Grp22;

procedure TForm1.diMessageParseClick(Sender: TObject);
var
    msg : TdiORU_R01_22;
    Patient : TdiPN_22;
    observation : TdiORU_R01_PATIENT_RESULT_ORDER_OBSERVATION_OBSERVATION_22;
    MsgStr : AnsiString;
    i : integer;
begin

    MsgStr :=
    'MSH|^~\&|ABL735^ABL735 Operating Theatres|ABL735^ABL735 Operating Theatres|||'+
    '20010516135518||ORU^R01|20010516135518|P^not present|2.2' + #13 +
    'PID|1|||F87248654|Doe^John|||U' + #13 +
    'OBR|1||6^Sample #||||||||O||||Arterial^' + #13 +
    'NTE|1|L|443' + #13 +
    'OBX|1|ST|^pH^M||7.600|||N|||F|||20010503151400||' + #13 +
    'OBX|2|ST|^pO2^M||127|mmHg||N|||F|||||' + #13 +
    'OBX|3|ST|^pCO2^M||20.4|mmHg||N|||F|||||' + #13 +
    'OBX|4|ST|^Cl-^M||73|mmol/L||N|||F|||||' + #13 +
    'OBX|5|ST|^K+^M||5.5|mmol/L||N|||F|||||' + #13 +
    'OBX|6|ST|^Na+^M||125|mmol/L||N|||F|||||' + #13 +
    'OBX|7|ST|^Glu^M||11.3|mmol/L||N|||F|||||' + #13 +
    'OBX|8|ST|^Lac^M||10.0|mmol/L||N|||F|||||' + #13 +
    'OBX|9|ST|^Ca++^M||0.36|mmol/L||N|||F|||||' + #13 +
    'OBX|10|ST|^tHb^M||17.3|g/dL||N|||F|||||' + #13 +
    'NTE|1|L|314' + #13 +
    'OBX|11|ST|^sO2^M||.....|%||N|||F|||||' + #13 +
    'NTE|1|L|314' + #13 +
    'OBX|12|ST|^O2Hb^M||-58.4|%||<|||F|||||' + #13 +
    'NTE|1|L|314^94' + #13 +
    'OBX|13|ST|^COHb^M||110.4|%||>|||F|||||' + #13 +
    'NTE|1|L|314^93' + #13 +
    'OBX|14|ST|^MetHb^M||-6.5|%||<|||F|||||' + #13 +
    'NTE|1|L|314^94' + #13 +
    'OBX|15|ST|^tBil^M||.....|micromol/L||<|||F|||||' + #13 +
    'NTE|1|L|314^94' + #13 +
    'OBX|16|ST|^T^I||37.0|Cel|||||F|||||' + #13 +
    'OBX|17|ST|^FIO2^D||21.0|%|||||F|||||' + #13 +
    'OBX|18|ST|^pH(T)^M||7.600|||N|||F|||||' + #13 +
    'OBX|19|ST|^pCO2(T)^M||20.4|mmHg||N|||F|||||' + #13 +
    'OBX|20|ST|^SBE^C||-1.5|mmol/L|||||F|||||' + #13 +
    'OBX|21|ST|^pO2(T)^M||127|mmHg||N|||F|||||';

    msg := TdiORU_R01_22.Create;    
    msg.AsString := MsgStr; //Parse message
	    	
    Patient:=msg.PATIENT_RESULT[0].PATIENT.PID.PatientName;
    // Shows John
    ShowMessage( Patient.GivenName.AsString );
    
    Memo1.Lines.Add( 'OBSERVATIONRepCount : ' + IntToStr( msg.PATIENT_RESULT[0].ORDER_OBSERVATION[0].OBSERVATIONRepCount) );
	
    for i := 0 to msg.PATIENT_RESULT[0].ORDER_OBSERVATION[0].OBSERVATIONRepCount-1 do
    begin
       observation := msg.PATIENT_RESULT[0].ORDER_OBSERVATION[0].OBSERVATION[i];
       Memo1.Lines.Append(observation.OBX.ObservationIdentifier.Text.AsString+#9#9+
	                      TdiST_22(observation.OBX.ObservationValue).AsString);     
    end;

    {
    OBSERVATIONRepCount : 21
	
    pH		7.600
    pO2		127
    pCO2		20.4
    Cl-		73
    K+		5.5
    Na+		125
    Glu		11.3
    Lac		10.0
    Ca++		0.36
    tHb		17.3
    sO2		.....
    O2Hb		-58.4
    COHb		110.4
    MetHb		-6.5
    tBil		.....
    T		37.0
    FIO2		21.0
    pH(T)		7.600
    pCO2(T)		20.4
    SBE		-1.5
    pO2(T)		127	
    }	

    FreeAndNil(msg);
end;
For create a message :
You can create HL7 message using AsString property or XML message using AsXML property

Code: Select all




procedure TForm1.bGenerateXMLMsg(Sender: TObject);
var
    msg : TdiORU_R01_24;
    msh : TdiMSH_24;
    pid: TdiPID_24;
    obr: TdiOBR_24;
    obx: TdiOBX_24;
    sn : TdiSN_24;
begin
    msg:=TdiORU_R01_24.Create;

    //MSH
    msh:= msg.MSH;
    msh.SendingApplication.NamespaceID.AsString:='GHH LAB';
    msh.SendingFacility.NamespaceID.AsString:='ELAB-3';
    msh.ReceivingApplication.NamespaceID.AsString:='GHH OE';
    msh.ReceivingFacility.NamespaceID.AsString:='BLDG4';
    msh.DateTimeOfMessage.TimeOfAnEvent.AsString:='200202150930';
    msh.MessageControlID.AsString:='CNTRL-3456';
    
    //PID
    pid:=msg.PATIENT_RESULT[0].PATIENT.PID;
    pid.PatientIdentifierList[0].ID.AsString:='555-44-4444';
    pid.PatientName[0].Familyname.Surname.AsString:='EVERYWOMAN';
    pid.PatientName[0].Givenname.AsString:='EVE';
    pid.PatientName[0].Secondandfurthergivennamesorinitialsthereof.AsString:='E';
    pid.PatientName[0].Nametypecode.AsString:='L';
    pid.MothersMaidenName[0].Familyname.Surname.AsString:='JONES';
    pid.DateTimeOfBirth.TimeOfAnEvent.AsString:='196203520';
    pid.AdministrativeSex.AsString:='F';
    pid.PatientAddress[0].Streetaddress.Streetormailingaddress.AsString:='153 FERNWOOD DR.';
    pid.PatientAddress[0].City.AsString:='STATESVILLE';
    pid.PatientAddress[0].Stateorprovince.AsString:='OH';
    pid.PatientAddress[0].Ziporpostalcode.AsString:='35292';
    pid.PhoneNumberHome[0].Telephonenumber.AsString:='(206)3345232';
    pid.PhoneNumberBusiness[0].Telephonenumber.AsString:='(206)752-121';
    pid.PatientAccountNumber.ID.AsString:='AC555444444';
    pid.DriversLicenseNumberPatient.Driverslicensenumber.AsString:='67-A4335';
    pid.DriversLicenseNumberPatient.Issuingstate_province_country.AsString:='OH';
    pid.DriversLicenseNumberPatient.Expirationdate.AsString:='20030520';

    // OBR
    obr:=msg.PATIENT_RESULT[0].ORDER_OBSERVATION[0].OBR;
    obr.SetIDOBR.AsString:='1';
    obr.PlacerOrderNumber.Entityidentifier.AsString:='845439';
    obr.PlacerOrderNumber.NamespaceID.AsString:='GHH OE';
    obr.FillerOrderNumber.Entityidentifier.AsString:='1045813';
    obr.FillerOrderNumber.NamespaceID.AsString:='GHH LAB';
    obr.UniversalServiceIdentifier.Identifier.AsString:='1554-5';
    obr.UniversalServiceIdentifier.Text.AsString:='GLUCOSE';
    obr.UniversalServiceIdentifier.Nameofcodingsystem.AsString:='LN';
    obr.ObservationDateTime.TimeOfAnEvent.AsString:='200202150730';
    obr.OrderingProvider[0].IDnumber.AsString:='555-55-5555';
    obr.OrderingProvider[0].Familyname.Surname.AsString:='PRIMARY';
    obr.OrderingProvider[0].Givenname.AsString:='PATRICIA P';
    obr.OrderingProvider[0].Degree.AsString:='MD';
    obr.OrderingProvider[0].Assigningauthority.NamespaceID.AsString:='LEVEL SEVEN HEALTHCARE, INC.';
    obr.ResultStatus.AsString:='F';
    obr.PrincipalResultInterpreter.OPName.IDNumber.AsString:='444-44-4444';
    obr.PrincipalResultInterpreter.OPName.FamilyName.AsString:='HIPPOCRATES';
    obr.PrincipalResultInterpreter.OPName.GivenName.AsString:='HOWARD H';
    obr.PrincipalResultInterpreter.OPName.Degree.AsString:='MD';

    // OBX
    obx:=msg.PATIENT_RESULT[0].ORDER_OBSERVATION[0].OBSERVATION[0].OBX;
    obx.SetIDOBX.AsString:='1';
    obx.ValueType.AsString:='SN';
    obx.ObservationIdentifier.Identifier.AsString:='1554-5';
    obx.ObservationIdentifier.Text.AsString:='GLUCOSE POST 12H CFST';
    obx.ObservationIdentifier.Nameofcodingsystem.AsString:='LN';

    sn:=TdiSN_24.Create;
    sn.Num1.AsString:='182';
    obx.ObservationValue[0]:= sn;
    obx.Units.Identifier.AsString:= 'mg/dl';
    obx.ReferencesRange.AsString:='70-105';
    obx.AbnormalFlags.AsString:='H';
    obx.ObservationResultStatus.AsString:='F';
    
    // XML format
    Memo1.Lines.Text:=msg.AsXML;
   
    // HL7 format
    //Memo1.Lines.Text:=msg.AsString;

    FreeAndNil(msg);

end;

please note the following selected section

Code: Select all

    sn:=TdiSN_24.Create;
    sn.Num1.AsString:='182';
    obx.ObservationValue[0]:= sn;
    obx.Units.Identifier.AsString:= 'mg/dl';
    obx.ReferencesRange.AsString:='70-105';
    obx.AbnormalFlags.AsString:='H';
    obx.ObservationResultStatus.AsString:='F';
For executable + source code please see attachment.

Best regards.