Search in sources :

Example 1 with ORU_R01_VISIT

use of ca.uhn.hl7v2.model.v26.group.ORU_R01_VISIT in project streamsx.health by IBMStreams.

the class ObxToSplMapper method messageToModel.

@SuppressWarnings("unchecked")
public <T> Iterable<T> messageToModel(Message message) {
    ArrayList<Observation> observations = new ArrayList<Observation>();
    if (message instanceof ORU_R01) {
        ORU_R01 oruMsg = (ORU_R01) message;
        String obxTs = "";
        String obxLocation = "";
        String sendingApp = "";
        String sendingFacility = "";
        try {
            MSH msh = oruMsg.getMSH();
            sendingApp = msh.getSendingApplication().encode();
            sendingFacility = msh.getSendingFacility().encode();
            List<ORU_R01_PATIENT_RESULT> patient_RESULTAll = ((ORU_R01) message).getPATIENT_RESULTAll();
            for (ORU_R01_PATIENT_RESULT result : patient_RESULTAll) {
                ORU_R01_ORDER_OBSERVATION order_OBSERVATION = result.getORDER_OBSERVATION();
                OBR obr = order_OBSERVATION.getOBR();
                DTM ts = obr.getObservationDateTime();
                obxTs = ts.getValue();
                ORU_R01_PATIENT patient = result.getPATIENT();
                ORU_R01_VISIT visit = patient.getVISIT();
                PL location = visit.getPV1().getAssignedPatientLocation();
                obxLocation = location.encode();
                List<ORU_R01_OBSERVATION> observationAll = order_OBSERVATION.getOBSERVATIONAll();
                for (ORU_R01_OBSERVATION oru_R01_OBSERVATION : observationAll) {
                    parseOBX(observations, obxTs, obxLocation, oru_R01_OBSERVATION.getOBX(), sendingApp, sendingFacility);
                }
            }
        } catch (HL7Exception e) {
            if (TRACE.isDebugEnabled())
                TRACE.log(TraceLevel.WARN, e);
        }
        try {
            OBR obr = (OBR) oruMsg.get("OBR");
            DTM ts = obr.getObservationDateTime();
            obxTs = ts.getValue();
            Structure tmp = oruMsg.get("PV1");
            if (tmp != null) {
                PV1 pv1 = (PV1) tmp;
                PL location = pv1.getAssignedPatientLocation();
                obxLocation = location.encode();
            }
            Structure[] structures = oruMsg.getAll("OBX");
            for (Structure structure : structures) {
                parseOBX(observations, obxTs, obxLocation, (OBX) structure, sendingApp, sendingFacility);
            }
        } catch (HL7Exception e) {
            if (TRACE.isDebugEnabled())
                TRACE.log(TraceLevel.WARN, e);
        }
    }
    return (Iterable<T>) observations;
}
Also used : ORU_R01_OBSERVATION(ca.uhn.hl7v2.model.v26.group.ORU_R01_OBSERVATION) MSH(ca.uhn.hl7v2.model.v26.segment.MSH) ORU_R01_PATIENT_RESULT(ca.uhn.hl7v2.model.v26.group.ORU_R01_PATIENT_RESULT) ORU_R01_VISIT(ca.uhn.hl7v2.model.v26.group.ORU_R01_VISIT) ArrayList(java.util.ArrayList) PV1(ca.uhn.hl7v2.model.v26.segment.PV1) ORU_R01_ORDER_OBSERVATION(ca.uhn.hl7v2.model.v26.group.ORU_R01_ORDER_OBSERVATION) ORU_R01_PATIENT(ca.uhn.hl7v2.model.v26.group.ORU_R01_PATIENT) ORU_R01(ca.uhn.hl7v2.model.v26.message.ORU_R01) Observation(com.ibm.streamsx.health.hapi.model.Observation) HL7Exception(ca.uhn.hl7v2.HL7Exception) DTM(ca.uhn.hl7v2.model.v26.datatype.DTM) PL(ca.uhn.hl7v2.model.v26.datatype.PL) Structure(ca.uhn.hl7v2.model.Structure) OBR(ca.uhn.hl7v2.model.v26.segment.OBR)

Aggregations

HL7Exception (ca.uhn.hl7v2.HL7Exception)1 Structure (ca.uhn.hl7v2.model.Structure)1 DTM (ca.uhn.hl7v2.model.v26.datatype.DTM)1 PL (ca.uhn.hl7v2.model.v26.datatype.PL)1 ORU_R01_OBSERVATION (ca.uhn.hl7v2.model.v26.group.ORU_R01_OBSERVATION)1 ORU_R01_ORDER_OBSERVATION (ca.uhn.hl7v2.model.v26.group.ORU_R01_ORDER_OBSERVATION)1 ORU_R01_PATIENT (ca.uhn.hl7v2.model.v26.group.ORU_R01_PATIENT)1 ORU_R01_PATIENT_RESULT (ca.uhn.hl7v2.model.v26.group.ORU_R01_PATIENT_RESULT)1 ORU_R01_VISIT (ca.uhn.hl7v2.model.v26.group.ORU_R01_VISIT)1 ORU_R01 (ca.uhn.hl7v2.model.v26.message.ORU_R01)1 MSH (ca.uhn.hl7v2.model.v26.segment.MSH)1 OBR (ca.uhn.hl7v2.model.v26.segment.OBR)1 PV1 (ca.uhn.hl7v2.model.v26.segment.PV1)1 Observation (com.ibm.streamsx.health.hapi.model.Observation)1 ArrayList (java.util.ArrayList)1