Search in sources :

Example 11 with MSA

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

the class HL7DataFormatTest method testMarshalISO8859.

@Test
public void testMarshalISO8859() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:marshal");
    mock.expectedMessageCount(1);
    mock.message(0).body().isInstanceOf(byte[].class);
    mock.message(0).body(String.class).contains("MSA|AA|123");
    mock.message(0).body(String.class).contains("QRD|20080805120000");
    mock.message(0).body(String.class).not().contains(NONE_ISO_8859_1);
    Message message = createHL7AsMessage();
    template.sendBodyAndProperty("direct:marshal", message, Exchange.CHARSET_NAME, "ISO-8859-1");
    assertMockEndpointsSatisfied();
}
Also used : Message(ca.uhn.hl7v2.model.Message) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Test(org.junit.Test)

Example 12 with MSA

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

the class HL7DataFormatTest method testMarshalUTF16InMessage.

@Test
public void testMarshalUTF16InMessage() throws Exception {
    String charsetName = "UTF-16";
    MockEndpoint mock = getMockEndpoint("mock:marshal");
    mock.expectedMessageCount(1);
    Message message = createHL7WithCharsetAsMessage(HL7Charset.getHL7Charset(charsetName));
    template.sendBodyAndProperty("direct:marshal", message, Exchange.CHARSET_NAME, charsetName);
    assertMockEndpointsSatisfied();
    byte[] body = (byte[]) mock.getExchanges().get(0).getIn().getBody();
    String msg = new String(body, Charset.forName(charsetName));
    assertTrue(msg.contains("MSA|AA|123"));
    assertTrue(msg.contains("QRD|20080805120000"));
}
Also used : Message(ca.uhn.hl7v2.model.Message) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Test(org.junit.Test)

Example 13 with MSA

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

the class HL7DataFormatTest method createHL7AsMessage.

private static ADR_A19 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");
    msa.getMsa3_TextMessage().setValue(NONE_ISO_8859_1);
    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 14 with MSA

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

the class HL7DataFormatTest method testMarshalUTF8.

@Test
public void testMarshalUTF8() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:marshal");
    mock.expectedMessageCount(1);
    mock.message(0).body().isInstanceOf(byte[].class);
    mock.message(0).body(String.class).contains("MSA|AA|123");
    mock.message(0).body(String.class).contains("QRD|20080805120000");
    mock.message(0).body(String.class).contains(NONE_ISO_8859_1);
    Message message = createHL7AsMessage();
    template.sendBodyAndProperty("direct:marshal", message, Exchange.CHARSET_NAME, "UTF-8");
    assertMockEndpointsSatisfied();
}
Also used : Message(ca.uhn.hl7v2.model.Message) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Test(org.junit.Test)

Aggregations

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 QRD (ca.uhn.hl7v2.model.v24.segment.QRD)10 Message (ca.uhn.hl7v2.model.Message)4 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)4 Test (org.junit.Test)4