* accessors for ADT^A01's segments.
*
* HAPI provides several versions of the ADT_A01 class, each in a different package (note
* the import statement above) corresponding to the HL7 version for the message.
*/
ADT_A01 adtMsg = (ADT_A01)hapiMsg;
MSH msh = adtMsg.getMSH();
// Retrieve some data from the MSH segment
String msgType = msh.getMessageType().getMessageType().getValue();
String msgTrigger = msh.getMessageType().getTriggerEvent().getValue();
// Prints "ADT A01"
System.out.println(msgType + " " + msgTrigger);
/*
* Now let's retrieve the patient's name from the parsed message.
*
* PN is an HL7 data type consisting of several components, such as
* family name, given name, etc.
*/
PN patientName = adtMsg.getPID().getPatientName();
// Prints "SMITH"
String familyName = patientName.getFamilyName().getValue();
System.out.println(familyName);