Search in sources :

Example 1 with NoValidation

use of ca.uhn.hl7v2.validation.impl.NoValidation in project camel by apache.

the class HL7ValidateTest method createRouteBuilder.

protected RouteBuilder createRouteBuilder() throws Exception {
    HapiContext hapiContext = new DefaultHapiContext();
    hapiContext.setValidationContext(new NoValidation());
    Parser p = new GenericParser(hapiContext);
    hl7 = new HL7DataFormat();
    hl7.setParser(p);
    /*
         * Let's start by adding a validation rule to the default validation
         * that disallows PID-2 to be empty.
         */
    ValidationRuleBuilder builder = new ValidationRuleBuilder() {

        private static final long serialVersionUID = 1L;

        @Override
        protected void configure() {
            forVersion(Version.V24).message("ADT", "*").terser("PID-2", not(empty()));
        }
    };
    ValidationContext customValidationContext = ValidationContextFactory.fromBuilder(builder);
    HapiContext customContext = new DefaultHapiContext(customValidationContext);
    final Parser customParser = new GenericParser(customContext);
    return new RouteBuilder() {

        public void configure() throws Exception {
            from("direct:unmarshalFailed").unmarshal().hl7().to("mock:unmarshal");
            from("direct:unmarshalOk").unmarshal().hl7(false).to("mock:unmarshal");
            from("direct:unmarshalOkCustom").unmarshal(hl7).to("mock:unmarshal");
            from("direct:start1").marshal().hl7(customParser).to("mock:end");
            from("direct:start2").marshal().hl7(true).to("mock:end");
        }
    };
}
Also used : RouteBuilder(org.apache.camel.builder.RouteBuilder) DefaultHapiContext(ca.uhn.hl7v2.DefaultHapiContext) NoValidation(ca.uhn.hl7v2.validation.impl.NoValidation) HapiContext(ca.uhn.hl7v2.HapiContext) DefaultHapiContext(ca.uhn.hl7v2.DefaultHapiContext) ValidationRuleBuilder(ca.uhn.hl7v2.validation.builder.ValidationRuleBuilder) Parser(ca.uhn.hl7v2.parser.Parser) GenericParser(ca.uhn.hl7v2.parser.GenericParser) GenericParser(ca.uhn.hl7v2.parser.GenericParser) ValidationContext(ca.uhn.hl7v2.validation.ValidationContext)

Example 2 with NoValidation

use of ca.uhn.hl7v2.validation.impl.NoValidation in project tdi-studio-se by Talend.

the class HL7Parse method getHL7MessageInput.

/**
     * DOC gcui Comment method "getHL7MessageInput".
     * 
     * @param messageText
     * @return
     */
public Message getHL7MessageInput(String messageText) {
    GenericParser p = new GenericParser();
    // force use novalidation
    p.setValidationContext(new NoValidation());
    Message message = null;
    try {
        if (messageText != null) {
            messageText = messageText.replace('\n', '\r');
            message = p.parse(messageText);
        }
    } catch (Exception e) {
        ExceptionHandler.process(e);
        MessageBox errorBox = new MessageBox(new Shell(), SWT.APPLICATION_MODAL | SWT.OK);
        //$NON-NLS-1$
        errorBox.setText("Parse error");
        //$NON-NLS-1$
        errorBox.setMessage("The content can't be parsed correctly,please check the file");
        if (errorBox.open() == SWT.OK) {
            errorBox.getParent().getShell().close();
        }
    }
    return message;
}
Also used : Shell(org.eclipse.swt.widgets.Shell) Message(ca.uhn.hl7v2.model.Message) NoValidation(ca.uhn.hl7v2.validation.impl.NoValidation) IOException(java.io.IOException) GenericParser(ca.uhn.hl7v2.parser.GenericParser) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 3 with NoValidation

use of ca.uhn.hl7v2.validation.impl.NoValidation in project camel by apache.

the class HL7XmlDataFormatTest method createRouteBuilder.

protected RouteBuilder createRouteBuilder() throws Exception {
    HapiContext hapiContext = new DefaultHapiContext();
    hapiContext.setValidationContext(new NoValidation());
    Parser p = new GenericParser(hapiContext);
    hl7 = new HL7DataFormat();
    hl7.setParser(p);
    return new RouteBuilder() {

        public void configure() throws Exception {
            from("direct:unmarshalOk").unmarshal().hl7(false).to("mock:unmarshal");
            from("direct:unmarshalOkXml").unmarshal(hl7).to("mock:unmarshal");
        }
    };
}
Also used : RouteBuilder(org.apache.camel.builder.RouteBuilder) DefaultHapiContext(ca.uhn.hl7v2.DefaultHapiContext) NoValidation(ca.uhn.hl7v2.validation.impl.NoValidation) HapiContext(ca.uhn.hl7v2.HapiContext) DefaultHapiContext(ca.uhn.hl7v2.DefaultHapiContext) Parser(ca.uhn.hl7v2.parser.Parser) GenericParser(ca.uhn.hl7v2.parser.GenericParser) GenericParser(ca.uhn.hl7v2.parser.GenericParser)

Aggregations

GenericParser (ca.uhn.hl7v2.parser.GenericParser)3 NoValidation (ca.uhn.hl7v2.validation.impl.NoValidation)3 DefaultHapiContext (ca.uhn.hl7v2.DefaultHapiContext)2 HapiContext (ca.uhn.hl7v2.HapiContext)2 Parser (ca.uhn.hl7v2.parser.Parser)2 RouteBuilder (org.apache.camel.builder.RouteBuilder)2 Message (ca.uhn.hl7v2.model.Message)1 ValidationContext (ca.uhn.hl7v2.validation.ValidationContext)1 ValidationRuleBuilder (ca.uhn.hl7v2.validation.builder.ValidationRuleBuilder)1 IOException (java.io.IOException)1 MessageBox (org.eclipse.swt.widgets.MessageBox)1 Shell (org.eclipse.swt.widgets.Shell)1