Search in sources :

Example 11 with PID

use of ca.uhn.hl7v2.model.v24.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;
}
Also used : PID(ca.uhn.hl7v2.model.v24.segment.PID) ADT_A01(ca.uhn.hl7v2.model.v24.message.ADT_A01)

Example 12 with PID

use of ca.uhn.hl7v2.model.v24.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");
        }
    };
}
Also used : RouteBuilder(org.apache.camel.builder.RouteBuilder) DefaultHapiContext(ca.uhn.hl7v2.DefaultHapiContext) NoValidation(ca.uhn.hl7v2.validation.impl.NoValidation) HapiContext(ca.uhn.hl7v2.HapiContext) DefaultHapiContext(ca.uhn.hl7v2.DefaultHapiContext) ValidationRuleBuilder(ca.uhn.hl7v2.validation.builder.ValidationRuleBuilder) Parser(ca.uhn.hl7v2.parser.Parser) GenericParser(ca.uhn.hl7v2.parser.GenericParser) GenericParser(ca.uhn.hl7v2.parser.GenericParser) ValidationContext(ca.uhn.hl7v2.validation.ValidationContext)

Example 13 with PID

use of ca.uhn.hl7v2.model.v24.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;
}
Also used : PatientVisit(com.ibm.streamsx.health.ingest.types.model.PatientVisit) XCN(ca.uhn.hl7v2.model.v26.datatype.XCN) MSH(ca.uhn.hl7v2.model.v26.segment.MSH) ADTEvent(com.ibm.streamsx.health.ingest.types.model.ADTEvent) ArrayList(java.util.ArrayList) Patient(com.ibm.streamsx.health.ingest.types.model.Patient) PID(ca.uhn.hl7v2.model.v26.segment.PID) PV1(ca.uhn.hl7v2.model.v26.segment.PV1) MessageInfo(com.ibm.streamsx.health.ingest.types.model.MessageInfo) EventDetails(com.ibm.streamsx.health.ingest.types.model.EventDetails) Clinician(com.ibm.streamsx.health.ingest.types.model.Clinician) CX(ca.uhn.hl7v2.model.v26.datatype.CX) XPN(ca.uhn.hl7v2.model.v26.datatype.XPN) HL7Exception(ca.uhn.hl7v2.HL7Exception) ADT_AXX(ca.uhn.hl7v2.model.v26.message.ADT_AXX) EVN(ca.uhn.hl7v2.model.v26.segment.EVN)

Example 14 with PID

use of ca.uhn.hl7v2.model.v24.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;
}
Also used : PID(ca.uhn.hl7v2.model.v24.segment.PID) ADT_A01(ca.uhn.hl7v2.model.v24.message.ADT_A01)

Example 15 with PID

use of ca.uhn.hl7v2.model.v24.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();
}
Also used : QRD(ca.uhn.hl7v2.model.v24.segment.QRD) MSH(ca.uhn.hl7v2.model.v24.segment.MSH) ADR_A19(ca.uhn.hl7v2.model.v24.message.ADR_A19) MSA(ca.uhn.hl7v2.model.v24.segment.MSA)

Aggregations

MSH (ca.uhn.hl7v2.model.v24.segment.MSH)14 ADR_A19 (ca.uhn.hl7v2.model.v24.message.ADR_A19)10 MSA (ca.uhn.hl7v2.model.v24.segment.MSA)10 QRD (ca.uhn.hl7v2.model.v24.segment.QRD)10 ADT_A01 (ca.uhn.hl7v2.model.v24.message.ADT_A01)8 PID (ca.uhn.hl7v2.model.v24.segment.PID)8 DefaultHapiContext (ca.uhn.hl7v2.DefaultHapiContext)2 ValidationRuleBuilder (ca.uhn.hl7v2.validation.builder.ValidationRuleBuilder)2 HL7Exception (ca.uhn.hl7v2.HL7Exception)1 HapiContext (ca.uhn.hl7v2.HapiContext)1 CX (ca.uhn.hl7v2.model.v26.datatype.CX)1 XCN (ca.uhn.hl7v2.model.v26.datatype.XCN)1 XPN (ca.uhn.hl7v2.model.v26.datatype.XPN)1 ADT_AXX (ca.uhn.hl7v2.model.v26.message.ADT_AXX)1 EVN (ca.uhn.hl7v2.model.v26.segment.EVN)1 MSH (ca.uhn.hl7v2.model.v26.segment.MSH)1 PID (ca.uhn.hl7v2.model.v26.segment.PID)1 PV1 (ca.uhn.hl7v2.model.v26.segment.PV1)1 GenericParser (ca.uhn.hl7v2.parser.GenericParser)1 Parser (ca.uhn.hl7v2.parser.Parser)1