Search in sources :

Example 1 with HL7DataFormat

use of org.apache.camel.model.dataformat.HL7DataFormat in project camel by apache.

the class DataFormatClause method hl7.

/**
     * Uses the HL7 data format
     */
public T hl7(Object parser) {
    HL7DataFormat hl7 = new HL7DataFormat();
    hl7.setParser(parser);
    return dataFormat(hl7);
}
Also used : HL7DataFormat(org.apache.camel.model.dataformat.HL7DataFormat)

Example 2 with HL7DataFormat

use of org.apache.camel.model.dataformat.HL7DataFormat in project camel by apache.

the class DataFormatClause method hl7.

/**
     * Uses the HL7 data format
     */
public T hl7(boolean validate) {
    HL7DataFormat hl7 = new HL7DataFormat();
    hl7.setValidate(validate);
    return dataFormat(hl7);
}
Also used : HL7DataFormat(org.apache.camel.model.dataformat.HL7DataFormat)

Example 3 with HL7DataFormat

use of org.apache.camel.model.dataformat.HL7DataFormat in project wildfly-camel by wildfly-extras.

the class HL7IntegrationTest method testMarshalUnmarshal.

@Test
@SuppressWarnings("resource")
public void testMarshalUnmarshal() throws Exception {
    final String msg = "MSH|^~\\&|MYSENDER|MYRECEIVER|MYAPPLICATION||200612211200||QRY^A19|1234|P|2.4\r";
    final HL7DataFormat format = new HL7DataFormat();
    CamelContext camelctx = new DefaultCamelContext();
    camelctx.addRoutes(new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            from("direct:start").marshal(format).unmarshal(format).to("mock:result");
        }
    });
    camelctx.start();
    try {
        HapiContext context = new DefaultHapiContext();
        Parser p = context.getGenericParser();
        Message hapimsg = p.parse(msg);
        ProducerTemplate producer = camelctx.createProducerTemplate();
        Message result = (Message) producer.requestBody("direct:start", hapimsg);
        Assert.assertEquals(hapimsg.toString(), result.toString());
    } finally {
        camelctx.stop();
    }
}
Also used : CamelContext(org.apache.camel.CamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) ProducerTemplate(org.apache.camel.ProducerTemplate) RouteBuilder(org.apache.camel.builder.RouteBuilder) Message(ca.uhn.hl7v2.model.Message) HL7DataFormat(org.apache.camel.model.dataformat.HL7DataFormat) DefaultHapiContext(ca.uhn.hl7v2.DefaultHapiContext) HapiContext(ca.uhn.hl7v2.HapiContext) DefaultHapiContext(ca.uhn.hl7v2.DefaultHapiContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) Parser(ca.uhn.hl7v2.parser.Parser) Test(org.junit.Test)

Aggregations

HL7DataFormat (org.apache.camel.model.dataformat.HL7DataFormat)3 DefaultHapiContext (ca.uhn.hl7v2.DefaultHapiContext)1 HapiContext (ca.uhn.hl7v2.HapiContext)1 Message (ca.uhn.hl7v2.model.Message)1 Parser (ca.uhn.hl7v2.parser.Parser)1 CamelContext (org.apache.camel.CamelContext)1 ProducerTemplate (org.apache.camel.ProducerTemplate)1 RouteBuilder (org.apache.camel.builder.RouteBuilder)1 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)1 Test (org.junit.Test)1