use of ca.uhn.hl7v2.model.v26.segment.PID in project camel by apache.
the class HL7ValidateTest method createADT01Message.
private static Message createADT01Message() throws Exception {
ADT_A01 adt = new ADT_A01();
adt.initQuickstart("ADT", "A01", "P");
// Populate the PID Segment
PID pid = adt.getPID();
pid.getPatientName(0).getFamilyName().getSurname().setValue("Doe");
pid.getPatientName(0).getGivenName().setValue("John");
pid.getPhoneNumberBusiness(0).getPhoneNumber().setValue("333123456");
pid.getPatientIdentifierList(0).getID().setValue("123456");
return adt;
}
use of ca.uhn.hl7v2.model.v26.segment.PID in project camel by apache.
the class HL7ValidateTest method createRouteBuilder.
protected RouteBuilder createRouteBuilder() throws Exception {
HapiContext hapiContext = new DefaultHapiContext();
hapiContext.setValidationContext(new NoValidation());
Parser p = new GenericParser(hapiContext);
hl7 = new HL7DataFormat();
hl7.setParser(p);
/*
* Let's start by adding a validation rule to the default validation
* that disallows PID-2 to be empty.
*/
ValidationRuleBuilder builder = new ValidationRuleBuilder() {
private static final long serialVersionUID = 1L;
@Override
protected void configure() {
forVersion(Version.V24).message("ADT", "*").terser("PID-2", not(empty()));
}
};
ValidationContext customValidationContext = ValidationContextFactory.fromBuilder(builder);
HapiContext customContext = new DefaultHapiContext(customValidationContext);
final Parser customParser = new GenericParser(customContext);
return new RouteBuilder() {
public void configure() throws Exception {
from("direct:unmarshalFailed").unmarshal().hl7().to("mock:unmarshal");
from("direct:unmarshalOk").unmarshal().hl7(false).to("mock:unmarshal");
from("direct:unmarshalOkCustom").unmarshal(hl7).to("mock:unmarshal");
from("direct:start1").marshal().hl7(customParser).to("mock:end");
from("direct:start2").marshal().hl7(true).to("mock:end");
}
};
}
use of ca.uhn.hl7v2.model.v26.segment.PID 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.segment.PID in project camel by apache.
the class AckExpressionTest method createADT01Message.
private static ADT_A01 createADT01Message() throws Exception {
ADT_A01 adt = new ADT_A01();
adt.initQuickstart("ADT", "A01", "P");
// Populate the PID Segment
PID pid = adt.getPID();
pid.getPatientName(0).getFamilyName().getSurname().setValue("Doe");
pid.getPatientName(0).getGivenName().setValue("John");
pid.getPatientIdentifierList(0).getID().setValue("123456");
return adt;
}
use of ca.uhn.hl7v2.model.v26.segment.PID in project camel by apache.
the class HL7RouteTest method createADR19Message.
// END SNIPPET: e2
private static Message createADR19Message() throws Exception {
ADR_A19 adr = new ADR_A19();
// Populate the MSH Segment
MSH mshSegment = adr.getMSH();
mshSegment.getFieldSeparator().setValue("|");
mshSegment.getEncodingCharacters().setValue("^~\\&");
mshSegment.getDateTimeOfMessage().getTimeOfAnEvent().setValue("200701011539");
mshSegment.getSendingApplication().getNamespaceID().setValue("MYSENDER");
mshSegment.getSequenceNumber().setValue("123");
mshSegment.getMessageType().getMessageType().setValue("ADR");
mshSegment.getMessageType().getTriggerEvent().setValue("A19");
// Populate the PID Segment
MSA msa = adr.getMSA();
msa.getAcknowledgementCode().setValue("AA");
msa.getMessageControlID().setValue("123");
QRD qrd = adr.getQRD();
qrd.getQueryDateTime().getTimeOfAnEvent().setValue("20080805120000");
return adr.getMessage();
}
Aggregations