I am trying to parse HL7 Message version 2.8 using HAPI. Before that am able to get value from each segment like MSH, EVN, PID, PV1. But now am getting value only from MSH seg other segments(EVN,PId,PV1) comes NULL. Please have look my code & give me solutions for that.
public class ADTService {
AWSCredentials awsCredentials = null;
AmazonDynamoDBClient amazonDynamoDBClient = null;
public Reply sendADTMessage() throws HL7Exception {
Reply reply = new Reply();
PatientInfo patientInfo = new PatientInfo();
byte[] valueDecoded= Base64.decode("TVNIfF5+XFwmfFNtYXJ0fDgwMDB8fEZ8MjAxMzA3MzExMzIyNTl8fEFEVF5BMDF8NDM0MzQzfFB8Mi44fHx8QUx8TkUKRVZOfFAwM3wyMDEzMDczMTEzMjI1OXx8T3x8MjAxMzA3MzExMzIyNTkKUElEfDF8UjQzNTQzNXxSNDM1NDM1fHxCQVRJU1RFXkFOVE9JTkVefHwxOTI1MDIyODAwMDAwMHxNfHx8fHx8fHx8fHw0MzgyNjEzMDcKUFYxfDF8SXxVLTAxXjQwN15BfHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHwyMDEwMTAwNTAwMDAwMA==");
String decodedADT = new String(valueDecoded);
System.out.println("Decoded value is " + decodedADT);
HapiContext context = new DefaultHapiContext();
context.setValidationContext(new NoValidation());
try {
Parser p = context.getGenericParser();
Message hapiMsg = p.parse(decodedADT);
System.out.println("Decoded value 1 is " + hapiMsg);
ADT_A01 adtMsg = (ADT_A01)hapiMsg;
MSH msh = adtMsg.getMSH();
PID pid = adtMsg.getPID();
EVN event = adtMsg.getEVN();
PV1 pv1 = adtMsg.getPV1();
System.out.println("MSH sending application "+msh.getSendingApplication().getNamespaceID().getValue());
System.out.println("MSH sending facility "+msh.getSendingFacility().getNamespaceID().getValue());
System.out.println("MSH receiving application "+msh.getReceivingApplication().getNamespaceID().getValue());
System.out.println("MSH receiving facility "+msh.getReceivingFacility().getNamespaceID().getValue());
System.out.println("MSH datetime of message "+msh.getDateTimeOfMessage().getValue());
System.out.println("MSH message control id "+msh.getMessageControlID().getValue());
System.out.println("MSH ADT Event "+msh.getMessageType().getMessageCode().getValue()+"-"+msh.getMessageType().getTriggerEvent().getValue());
System.out.println();
System.out.println("EVN recorded datetime "+event.getRecordedDateTime().getValue());
System.out.println();
System.out.println("PID patient id "+pid.getPatientIdentifierList(0).getIDNumber().getValue());
System.out.println("PID patient id "+pid.getPatientID().getValue());
System.out.println("PID last name "+pid.getPatientName(0).getFamilyName().getFn1_Surname().getValue());
System.out.println("PID first name "+pid.getPatientName(0).getGivenName().getValue());
System.out.println("PID dob "+pid.getDateTimeOfBirth().getValue());
System.out.println("PID gender "+pid.getAdministrativeSex().getIdentifier().getValue());
System.out.println();
System.out.println("PV1 admit datetime "+pv1.getAdmitDateTime().getValue());
System.out.println("PV1 bed status "+pv1.getBedStatus().getValueSetOID());
System.out.println("PV1 assigned patient location bed "+pv1.getAssignedPatientLocation().getBed().getNamespaceID().getValue());
System.out.println("PV1 assigned patient location room "+pv1.getAssignedPatientLocation().getRoom().getNamespaceID().getValue());
System.out.println("PV1 assigned patient location floor "+pv1.getAssignedPatientLocation().getFloor().getNamespaceID().getValue());
System.out.println("PV1 assigned patient location building "+pv1.getAssignedPatientLocation().getBuilding().getNamespaceID().getValue());
System.out.println("PV1 prior patient location bed "+pv1.getPriorPatientLocation().getBed().getNamespaceID().getValue());
System.out.println("PV1 prior patient location room "+pv1.getPriorPatientLocation().getRoom().getNamespaceID().getValue());
System.out.println("PV1 prior patient location fllor "+pv1.getPriorPatientLocation().getFloor().getNamespaceID().getValue());
System.out.println("PV1 prior patient location building "+pv1.getPriorPatientLocation().getBuilding().getNamespaceID().getValue());
System.out.println("PV1 discharge datetime "+pv1.getDischargeDateTime().getValue());
patientInfo.setSendingApplication(msh.getSendingApplication().getNamespaceID().getValue());
patientInfo.setSendingFacility(msh.getSendingFacility().getNamespaceID().getValue());
patientInfo.setPatientId(pid.getPatientIdentifierList(0).getIDNumber().getValue());
patientInfo.setGivenName(pid.getPatientName(0).getGivenName().getValue());
patientInfo.setAdministrativeSex(pid.getAdministrativeSex().getIdentifier().getValue());
} catch (Exception e) {
e.getStackTrace();
} finally{
try {
context.close();
} catch (IOException e) {
context = null;
e.printStackTrace();
}
}
patientInfo.setPatientDetails(decodedADT);
ADTService adtService = new ADTService();
adtService.savePatientDetails(patientInfo);
//System.out.println(ADTMessage.Contents);
reply = SubProcess();
return reply;
}