Search in sources :

Example 26 with ID

use of ca.uhn.hl7v2.model.v25.datatype.ID in project quickstarts by jboss-switchyard.

the class CamelServiceRoute method configure.

/**
 * The Camel route is configured via this method.  The from endpoint is required to be a SwitchYard service.
 */
public void configure() {
    DataFormat hl7 = new HL7DataFormat();
    from("switchyard://HL7Route").unmarshal(hl7).process(new Processor() {

        @Override
        public void process(Exchange exchange) throws Exception {
            String body = exchange.getIn().getBody(String.class);
            PipeParser pipeParser = new PipeParser();
            try {
                // Parse the HL7 message
                ca.uhn.hl7v2.model.Message message = pipeParser.parse(body);
                if (message instanceof QRY_A19) {
                    // Print out some details from the QRD
                    QRD qrd = (QRD) message.get("QRD");
                    System.out.println("Query Date/Time : " + qrd.getQueryDateTime().getTimeOfAnEvent().getValue());
                    System.out.println("Query Format Code : " + qrd.getQueryFormatCode().getValue());
                    System.out.println("Query Priority : " + qrd.getQueryPriority().getValue());
                    System.out.println("Query ID : " + qrd.getQueryID().getValue());
                    System.out.println("Deferred Response Type : " + qrd.getDeferredResponseType().getValue());
                    System.out.println("Deferred Response Date/Time : " + qrd.getDeferredResponseDateTime().getTimeOfAnEvent().getValue());
                    System.out.println("Quantity Limited Request : " + qrd.getQuantityLimitedRequest().getQuantity().getValue());
                    System.out.println("Query Results Level : " + qrd.getQueryResultsLevel().getValue());
                    qrd.getQueryID();
                }
            } catch (Exception e) {
                throw e;
            }
            SwitchYardMessage out = new SwitchYardMessage();
            out.setBody(body);
            exchange.setOut(out);
        }
    });
}
Also used : QRD(ca.uhn.hl7v2.model.v24.segment.QRD) Processor(org.apache.camel.Processor) PipeParser(ca.uhn.hl7v2.parser.PipeParser) SwitchYardMessage(org.switchyard.common.camel.SwitchYardMessage) HL7DataFormat(org.apache.camel.component.hl7.HL7DataFormat) SwitchYardMessage(org.switchyard.common.camel.SwitchYardMessage) Exchange(org.apache.camel.Exchange) DataFormat(org.apache.camel.spi.DataFormat) HL7DataFormat(org.apache.camel.component.hl7.HL7DataFormat) QRY_A19(ca.uhn.hl7v2.model.v24.message.QRY_A19)

Aggregations

HL7Exception (ca.uhn.hl7v2.HL7Exception)14 Message (ca.uhn.hl7v2.model.Message)10 ApplicationException (ca.uhn.hl7v2.app.ApplicationException)8 Test (org.junit.Test)7 Patient (org.openmrs.Patient)7 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)7 PID (ca.uhn.hl7v2.model.v25.segment.PID)6 Person (org.openmrs.Person)6 PatientIdentifierException (org.openmrs.api.PatientIdentifierException)6 EncodingNotSupportedException (ca.uhn.hl7v2.parser.EncodingNotSupportedException)5 FileNotFoundException (java.io.FileNotFoundException)5 IOException (java.io.IOException)5 URISyntaxException (java.net.URISyntaxException)5 ArrayList (java.util.ArrayList)5 APIException (org.openmrs.api.APIException)5 DAOException (org.openmrs.api.db.DAOException)5 CX (ca.uhn.hl7v2.model.v25.datatype.CX)4 XCN (ca.uhn.hl7v2.model.v25.datatype.XCN)4 ORU_R01 (ca.uhn.hl7v2.model.v25.message.ORU_R01)4 ORC (ca.uhn.hl7v2.model.v25.segment.ORC)4