use of ca.uhn.hl7v2.model.v26.message.ADT_AXX in project streamsx.health by IBMStreams.
the class AdtToModelMapper method messageToModel.
@SuppressWarnings("unchecked")
public <T> Iterable<T> messageToModel(Message message) {
ArrayList<ADTEvent> adtEvents = new ArrayList<ADTEvent>();
if (message instanceof ADT_AXX) {
ADT_AXX superMsg = (ADT_AXX) message;
MessageInfo msg = new MessageInfo();
Patient patient = new Patient();
try {
MSH header = superMsg.getMSH();
msg.setSendingApp(header.getSendingApplication().encode());
msg.setSendingFacility(header.getSendingFacility().encode());
msg.setReceivingApp(header.getReceivingApplication().encode());
msg.setReceivingFacility(header.getReceivingFacility().encode());
msg.setMessageTs(header.getDateTimeOfMessage().encode());
msg.setMessageType(header.getMessageType().encode());
PID pid = superMsg.getPID();
patient.setId(pid.getPatientID().encode());
XPN[] patientNames = pid.getPatientName();
for (XPN name : patientNames) {
if (patient.getName().equals(IInjestServicesConstants.EMPTYSTR)) {
patient.setName(getPatientFullName(name));
} else {
patient.addAlternateName(getPatientFullName(name));
}
}
patient.setGender(pid.getAdministrativeSex().encode());
patient.setDateOfBirth(pid.getDateTimeOfBirth().encode());
CX[] ids = pid.getAlternatePatientIDPID();
if (ids.length > 0) {
for (CX cx : ids) {
patient.addAlternativeId(cx.encode());
}
}
EventDetails evt = new EventDetails();
EVN evn = superMsg.getEVN();
evt.setEventType(evn.getEventTypeCode().encode());
evt.setEventTs(evn.getEvn6_EventOccurred().encode());
evt.setRecordTs(evn.getEvn2_RecordedDateTime().encode());
PV1 pv1 = superMsg.getPV1();
PatientVisit patientVisit = new PatientVisit();
patientVisit.setPatientClass(pv1.getPatientClass().encode());
patientVisit.setLocation(pv1.getAssignedPatientLocation().encode());
patientVisit.setPriorLocation(pv1.getPriorPatientLocation().encode());
patientVisit.setVisitNumber(pv1.getVisitNumber().encode());
patient.setStatus(pv1.getBedStatus().encode());
XCN[] doctors = pv1.getAttendingDoctor();
for (XCN xcn : doctors) {
String id = xcn.getIDNumber().encode();
String name = xcn.getFamilyName().encode() + " " + xcn.getGivenName().encode();
Clinician clinician = new Clinician();
clinician.setId(id);
clinician.setName(name);
patientVisit.addAttendingDoctor(clinician);
}
doctors = pv1.getConsultingDoctor();
for (XCN xcn : doctors) {
String id = xcn.getIDNumber().encode();
String name = xcn.getFamilyName().encode() + " " + xcn.getGivenName().encode();
Clinician clinician = new Clinician();
clinician.setId(id);
clinician.setName(name);
patientVisit.addConsultingDoctor(clinician);
}
ADTEvent adtEvent = new ADTEvent();
adtEvent.setEvt(evt);
adtEvent.setPatient(patient);
adtEvent.setMsg(msg);
adtEvent.setPv(patientVisit);
adtEvents.add(adtEvent);
} catch (HL7Exception e) {
TRACE.error("Unable to parse HL7 message", e);
}
}
return (Iterable<T>) adtEvents;
}
use of ca.uhn.hl7v2.model.v26.message.ADT_AXX in project streamsx.health by IBMStreams.
the class HapiMessageHandler method processMessage.
@Override
public Message processMessage(Message theMessage, Map<String, Object> arg1) throws ReceivingApplicationException, HL7Exception {
server.messageArrived(theMessage);
Message ack;
try {
// Always use the default parser to generate an ack
// HAPI seems to get into trouble if the ADT_AXX superstructure
// is used.
// Internally, when it tries to generate an ack message
// the super structure setting in the model class factory causes the ADT_AXX message
// to get created instead of the ACK getting created. This is to override the model
// class factory so that the proper class can be generated.
theMessage.setParser(ackParser);
ack = theMessage.generateACK();
return ack;
} catch (IOException e) {
TRACE.log(TraceLevel.ERROR, "Unable to generate ack message", e);
}
return theMessage;
}
Aggregations