Search in sources :

Example 1 with QRD

use of ca.uhn.hl7v2.model.v24.segment.QRD in project camel by apache.

the class HL7DataFormatTest method testUnmarshalWithImplicitBig5Charset.

@Test
public void testUnmarshalWithImplicitBig5Charset() throws Exception {
    String charset = "Big5";
    MockEndpoint mock = getMockEndpoint("mock:unmarshalBig5");
    mock.expectedMessageCount(1);
    mock.message(0).body().isInstanceOf(Message.class);
    mock.expectedHeaderReceived(HL7Constants.HL7_CHARSET, null);
    mock.expectedHeaderReceived(Exchange.CHARSET_NAME, charset);
    // Message without explicit encoding in MSH-18, but the unmarshaller "guesses"
    // this time that it is Big5
    byte[] body = createHL7AsString().getBytes(Charset.forName(charset));
    template.sendBody("direct:unmarshalBig5", new ByteArrayInputStream(body));
    assertMockEndpointsSatisfied();
    Message msg = mock.getExchanges().get(0).getIn().getBody(Message.class);
    assertEquals("2.4", msg.getVersion());
    QRD qrd = (QRD) msg.get("QRD");
    assertEquals("0101701234", qrd.getWhoSubjectFilter(0).getIDNumber().getValue());
}
Also used : QRD(ca.uhn.hl7v2.model.v24.segment.QRD) Message(ca.uhn.hl7v2.model.Message) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) ByteArrayInputStream(java.io.ByteArrayInputStream) Test(org.junit.Test)

Example 2 with QRD

use of ca.uhn.hl7v2.model.v24.segment.QRD in project camel by apache.

the class HL7MLLPCodecStandAndEndBytesTest method createHL7AsMessage.

private static Message createHL7AsMessage() 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;
}
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)

Example 3 with QRD

use of ca.uhn.hl7v2.model.v24.segment.QRD in project camel by apache.

the class HL7MLLPCodecStandAndEndBytesTest method createRouteBuilder.

protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {

        public void configure() throws Exception {
            from("mina2:tcp://127.0.0.1:" + getPort() + "?sync=true&codec=#hl7codec").process(new Processor() {

                public void process(Exchange exchange) throws Exception {
                    Message input = exchange.getIn().getBody(Message.class);
                    assertEquals("2.4", input.getVersion());
                    QRD qrd = (QRD) input.get("QRD");
                    assertEquals("0101701234", qrd.getWhoSubjectFilter(0).getIDNumber().getValue());
                    Message response = createHL7AsMessage();
                    exchange.getOut().setBody(response);
                }
            }).to("mock:result");
        }
    };
}
Also used : Exchange(org.apache.camel.Exchange) QRD(ca.uhn.hl7v2.model.v24.segment.QRD) Processor(org.apache.camel.Processor) RouteBuilder(org.apache.camel.builder.RouteBuilder) Message(ca.uhn.hl7v2.model.Message)

Example 4 with QRD

use of ca.uhn.hl7v2.model.v24.segment.QRD in project camel by apache.

the class HL7ByteArrayRouteTest method createADR19Message.

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");
    mshSegment.getCharacterSet(0).setValue("UNICODE UTF-8");
    // 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)

Example 5 with QRD

use of ca.uhn.hl7v2.model.v24.segment.QRD in project camel by apache.

the class HL7DataFormatTest method testUnmarshalWithExplicitUTF16Charset.

@Test
public void testUnmarshalWithExplicitUTF16Charset() throws Exception {
    String charset = "UTF-16";
    MockEndpoint mock = getMockEndpoint("mock:unmarshal");
    mock.expectedMessageCount(1);
    mock.message(0).body().isInstanceOf(Message.class);
    mock.expectedHeaderReceived(HL7Constants.HL7_CHARSET, HL7Charset.getHL7Charset(charset).getHL7CharsetName());
    mock.expectedHeaderReceived(Exchange.CHARSET_NAME, charset);
    // Message with explicit encoding in MSH-18
    byte[] body = createHL7WithCharsetAsString(HL7Charset.UTF_16).getBytes(Charset.forName(charset));
    template.sendBodyAndHeader("direct:unmarshal", new ByteArrayInputStream(body), Exchange.CHARSET_NAME, charset);
    assertMockEndpointsSatisfied();
    Message msg = mock.getExchanges().get(0).getIn().getBody(Message.class);
    assertEquals("2.4", msg.getVersion());
    QRD qrd = (QRD) msg.get("QRD");
    assertEquals("0101701234", qrd.getWhoSubjectFilter(0).getIDNumber().getValue());
}
Also used : QRD(ca.uhn.hl7v2.model.v24.segment.QRD) Message(ca.uhn.hl7v2.model.Message) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) ByteArrayInputStream(java.io.ByteArrayInputStream) Test(org.junit.Test)

Aggregations

QRD (ca.uhn.hl7v2.model.v24.segment.QRD)20 Message (ca.uhn.hl7v2.model.Message)13 ADR_A19 (ca.uhn.hl7v2.model.v24.message.ADR_A19)10 MSA (ca.uhn.hl7v2.model.v24.segment.MSA)10 MSH (ca.uhn.hl7v2.model.v24.segment.MSH)10 Test (org.junit.Test)8 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)7 Exchange (org.apache.camel.Exchange)6 Processor (org.apache.camel.Processor)6 RouteBuilder (org.apache.camel.builder.RouteBuilder)5 QRY_A19 (ca.uhn.hl7v2.model.v24.message.QRY_A19)2 PipeParser (ca.uhn.hl7v2.parser.PipeParser)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 ST (ca.uhn.hl7v2.model.v24.datatype.ST)1 HL7DataFormat (org.apache.camel.component.hl7.HL7DataFormat)1 DataFormat (org.apache.camel.spi.DataFormat)1 SwitchYardMessage (org.switchyard.common.camel.SwitchYardMessage)1