LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   hapi - is it possible to get information from abstract structures like Message? (http://www.linuxquestions.org/questions/programming-9/hapi-is-it-possible-to-get-information-from-abstract-structures-like-message-940275/)

eantoranz 04-17-2012 10:41 AM

hapi - is it possible to get information from abstract structures like Message?
 
Hi!

Does anybody know how to get information from hapi basic structures (when for example receiving a message from an unsupported version protocol).

Say you start with an instance of ca.uhn.hl7v2.model.Message and you want to work with the values of the MSH segment. How is that done?

Thanks in advance.

ntubski 04-24-2012 02:09 PM

ExampleUseTerser looks relevant. Also see HandlingMultipleVersions

eantoranz 05-24-2012 09:54 AM

I find it quite interesting.... however I don't know the different protocol versions that much to know if they change a lot between them (hell, I don't know any of them too well). What I will end up doing is supporting all protocol versions I need and use instanceof and casting a lot.

Code:

if (message instanceof ca.uhn.hl7v2.model.v21.message.ORU_R01) {
        ca.uhn.hl7v2.model.v21.message.ORU_R01 oru = (ca.uhn.hl7v2.model.v21.message.ORU_R01) message;
        patientID = oru.getPATIENT_RESULT().getPATIENT().getPID().getPid3_PATIENTIDINTERNALINTERNALID().getCk1_IDNumber().getValue();
        // what are the results?
} else if (message instanceof ca.uhn.hl7v2.model.v22.message.ORU_R01) {
        ca.uhn.hl7v2.model.v22.message.ORU_R01 oru = (ca.uhn.hl7v2.model.v22.message.ORU_R01) message;
        patientID = oru.getPATIENT_RESULT().getPATIENT().getPID().getPid3_PatientIDInternalID(0).getCm_pat_id1_IDNumber().getValue();
} else if (message instanceof ca.uhn.hl7v2.model.v23.message.ORU_R01) {
        ca.uhn.hl7v2.model.v23.message.ORU_R01 oru = (ca.uhn.hl7v2.model.v23.message.ORU_R01) message;
        patientID = oru.getRESPONSE().getPATIENT().getPID().getPid3_PatientIDInternalID(0).getCx1_ID().getValue();
} else if (message instanceof ca.uhn.hl7v2.model.v231.message.ORU_R01) {
        ca.uhn.hl7v2.model.v231.message.ORU_R01 oru = (ca.uhn.hl7v2.model.v231.message.ORU_R01) message;
        patientID = oru.getPIDPD1NK1NTEPV1PV2ORCOBRNTEOBXNTECTI().getPIDPD1NK1NTEPV1PV2().getPID()
                        .getPid3_PatientIdentifierList(0).getCx1_ID().getValue();
} else if (message instanceof ca.uhn.hl7v2.model.v24.message.ORU_R01) {
        ca.uhn.hl7v2.model.v24.message.ORU_R01 oru = (ca.uhn.hl7v2.model.v24.message.ORU_R01) message;
        patientID = oru.getPATIENT_RESULT().getPATIENT().getPID().getPid3_PatientIdentifierList(0).getCx1_ID().getValue();
} else if (message instanceof ca.uhn.hl7v2.model.v25.message.ORU_R01) {
        ca.uhn.hl7v2.model.v25.message.ORU_R01 oru = (ca.uhn.hl7v2.model.v25.message.ORU_R01) message;
        patientID = oru.getPATIENT_RESULT().getPATIENT().getPID().getPid3_PatientIdentifierList(0).getCx1_IDNumber().getValue();
} else if (message instanceof ca.uhn.hl7v2.model.v251.message.ORU_R01) {
        ca.uhn.hl7v2.model.v251.message.ORU_R01 oru = (ca.uhn.hl7v2.model.v251.message.ORU_R01) message;
        patientID = oru.getPATIENT_RESULT().getPATIENT().getPID().getPid3_PatientIdentifierList(0).getCx1_IDNumber().getValue();
} else if (message instanceof ca.uhn.hl7v2.model.v26.message.ORU_R01) {
        ca.uhn.hl7v2.model.v26.message.ORU_R01 oru = (ca.uhn.hl7v2.model.v26.message.ORU_R01) message;
        patientID = oru.getPATIENT_RESULT().getPATIENT().getPID().getPid3_PatientIdentifierList(0).getCx1_IDNumber().getValue();
}


eantoranz 05-24-2012 09:59 AM

By the way, I took that from a previous revision of my code so I think the way I'm getting the patient ID is not correct... but you get the concept, don't you?


All times are GMT -5. The time now is 04:42 AM.