I am new to Nhapi and using it to parse the HL7 message .
The issue i am facing is i am parsing the ADT^A03 message but always i get the PV1 segment as null.
I am attaching the Sample Message and my Code .
Sample Message :
MSH|^~\&|MMM|MMM|||201412081017||ADT^A03|2014342370374441||2.3
EVN|A03|201412081017|201412080001||73540
PID|1||000000004449^^^PHS^MR|491662^^^MMM|||19500225|F||1||||||D|CAT|78599180^^M10^MMM^PN|
PD1||1|||||NNN|||||
NK1|0001|NONE AS PER PT^NONE AS PER PT^^^^^L|19||||JUCON||||||||||||||||||||||||||||||
NK1|0002|NONE^^^^^^L|||||PTEMP|||UNEMPLOYED|||||||||||||||||||||||||||
PV1|1|O||R|||001211^RAM SHYAM|001211^RAM SHYAM||SDO||||OU|||001211^RAM SHYAM|U||H^20141208||||||||||||||||AHR|||PNKN|||||201412080625|201412081015
PV2||||||||201412080001|||||||N|||||1||||OD|||||||||||||
GT1|0001||SHYAM^RAM|||||19500225|F|P|01|00000000||||NONE|||||||||||||||||||||||||||||||||||NONE||||
IN1||00000000|^NONE^^^^^^^^L||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||(000)2584-33695|||||||NONE^L||
Code :
PipeParser parser = new PipeParser();
IMessage messageParsed = parser.Parse(message);
ADT_A03 a03 = messageParsed as ADT_A03;
PV1Segment pv1Segment = new PV1Segment();
pv1Segment.Set_Id_PV1_1_1 = a03.PV1.SetIDPatientVisit.Value;
pv1Segment.Patient_Class_2_1 = a03.PV1.PatientClass.Value;
pv1Segment.Assigned_Patient_Location_3_1 = a03.PV1.AssignedPatientLocation.PointOfCare.Value;
pv1Segment.Admission_Type_4_1 = a03.PV1.AdmissionType.Value;
pv1Segment.Pre_Admit_Number_5_1 = a03.PV1.PreadmitNumber.ID.Value;
pv1Segment.Prior_Patient_Location_6_1 = a03.PV1.PriorPatientLocation.PointOfCare.Value;
pv1Segment.Attending_Doctor_Id_7_1 = a03.PV1.AttendingDoctor.IDNumber.Value;
pv1Segment.Attending_Doctor_Name_7_2 = a03.PV1.AttendingDoctor.FamilyName.Value;
pv1Segment.Referring_Doctor_Id_8_1 = a03.PV1.ReferringDoctor.IDNumber.Value;
pv1Segment.Referring_Doctor_Name_8_2 = a03.PV1.ReferringDoctor.FamilyName.Value;
Your basic problem here is that you are trying to parse a HL7 2.3 message that doesn't conform to the HL7 2.3 specification for ADT A03 events.
Namely, NK1, GT1 and IN1 segments are not defined in the standard for the ADT A03 event in HL7 version 2.3.
If you remove the problem segments, the message will parse against the 2.3 specification using your code like so:
var parser = new PipeParser();
var messageParsed = parser.Parse(message);
var a03 = messageParsed as ADT_A03;
var setId = a03.PV1.SetIDPatientVisit.Value;
var patientClass = a03.PV1.PatientClass.Value;
var AssignedPatientLocation = a03.PV1.AssignedPatientLocation.PointOfCare.Value;
var Admission_Type = a03.PV1.AdmissionType.Value;
var Pre_Admit_Number = a03.PV1.PreadmitNumber.ID.Value;
var Prior_Patient_Location = a03.PV1.PriorPatientLocation.PointOfCare.Value;
var Attending_Doctor_Id = a03.PV1.AttendingDoctor.IDNumber.Value;
var Attending_Doctor_Name = a03.PV1.AttendingDoctor.FamilyName.Value;
var Referring_Doctor_Id = a03.PV1.ReferringDoctor.IDNumber.Value;
var Referring_Doctor_Name = a03.PV1.ReferringDoctor.FamilyName.Value;
NHapi's model parsing is modelled tightly against the HL7 standards, so you if give it non-standard data like the message you have shown above, it won't handle it gracefully. (aborting parsing of subsequent segments like in this case).