Package ca.uhn.hl7v2.validation

Examples of ca.uhn.hl7v2.validation.Rule


        System.out.println("[ Executing HL7Sender : HOST:" + host + "  ;port :" + port + " ]");
        // The connection hub connects to listening servers
        ConnectionHub connectionHub = ConnectionHub.getInstance();
        // A connection object represents a socket attached to an HL7 server
        Connection connection = connectionHub
                .attach(host, port, new PipeParser(), MinLowerLayerProtocol.class);

        // The initiator is used to transmit unsolicited messages
        Initiator initiator = connection.getInitiator();
        HL7Message sampleMessage = new HL7Message();

        //send
        Message response = null;
        try {
            response = initiator.sendAndReceive(sampleMessage.getHL7Message());
            PipeParser parser = new PipeParser();
            String responseString = parser.encode(response);
            System.out.println("Received response:\n" + responseString);
        } catch (LLPException e) {
            System.out.println("Error : " + e);
        } catch (IOException e) {
            System.out.println("Error : " + e);
View Full Code Here


    }

    @Override
    protected void startEndpoint(HL7Endpoint endpoint) throws AxisFault {
        LowerLayerProtocol llp = LowerLayerProtocol.makeLLP();
        PipeParser parser = new PipeParser();
        SimpleServer server = new SimpleServer(endpoint.getPort(), llp, parser);
        Application callback = new HL7MessageProcessor(endpoint);
        server.registerApplication("*", "*", callback);
        server.start();
        serverTable.put(endpoint, server);
View Full Code Here

            MessageContext messageContext = endpoint.createMessageContext();
            messageContext.setIncomingTransportName(HL7Constants.TRANSPORT_NAME);
            messageContext.setEnvelope(createEnvelope(message));
            /* set the raw HL7 message in message context to be used if needed later */
            messageContext.setProperty(HL7Constants.HL7_RAW_MESSAGE_PROPERTY_NAME,
                new PipeParser().encode(message));
            AxisEngine.receive(messageContext);
            return createAck(message);

        } catch (AxisFault axisFault) {
            return createNAck(message, "Error while processing the HL7 message " +
View Full Code Here

    private Connection getConnection(String targetEPR, ConnectionHub hub) throws AxisFault {
        try {
            URI url = new URI(targetEPR);
            String targetHost = url.getHost();
            int targetPort = url.getPort();
            return hub.attach(targetHost, targetPort, new PipeParser(),
                    MinLowerLayerProtocol.class);
        } catch (URISyntaxException e) {
            handleException("Malformed HL7 URI syntax: " + targetEPR, e);
        } catch (HL7Exception e) {
            handleException("Error while obtaining HL7 connection to: " + targetEPR, e);
View Full Code Here

        // Helper class
    }

    @Converter
    public static String toString(Message message) throws HL7Exception {
        Parser parser = new PipeParser();
        String encoded = parser.encode(message);
        return encoded;
    }
View Full Code Here

    @Converter
    public static Message toMessage(String body) throws HL7Exception {
        // replace \n with \r as HL7 uses 0x0d = \r as segment terminators and HAPI only parses with \r
        body = body.replace('\n', '\r');

        Parser parser = new PipeParser();
        Message message = parser.parse(body);
        return message;
    }
View Full Code Here

        }

        // convert to string
        String body;
        if (message instanceof Message) {
            Parser parser = new PipeParser();
            body = parser.encode((Message)message);
        } else if (message instanceof String) {
            body = (String)message;
        } else if (message instanceof byte[]) {
            body = new String((byte[])message);
        } else {
View Full Code Here

    public Object unmarshal(Exchange exchange, InputStream inputStream) throws Exception {
        String body = ExchangeHelper.convertToMandatoryType(exchange, String.class, inputStream);
        Message message = HL7Converter.toMessage(body);

        // add MSH fields as message out headers
        Terser terser = new Terser(message);
        exchange.getOut().setHeader("hl7.msh.sendingApplication", terser.get("MSH-3"));
        exchange.getOut().setHeader("hl7.msh.sendingFacility", terser.get("MSH-4"));
        exchange.getOut().setHeader("hl7.msh.receivingApplication", terser.get("MSH-5"));
        exchange.getOut().setHeader("hl7.msh.receivingFacility", terser.get("MSH-6"));
        exchange.getOut().setHeader("hl7.msh.timestamp", terser.get("MSH-7"));
        exchange.getOut().setHeader("hl7.msh.security", terser.get("MSH-8"));
        exchange.getOut().setHeader("hl7.msh.messageType", terser.get("MSH-9-1"));
        exchange.getOut().setHeader("hl7.msh.triggerEvent", terser.get("MSH-9-2"));
        exchange.getOut().setHeader("hl7.msh.messageControl", terser.get("MSH-10"));
        exchange.getOut().setHeader("hl7.msh.processingId", terser.get("MSH-11"));
        exchange.getOut().setHeader("hl7.msh.versionId", terser.get("MSH-12"));
        return message;
    }
View Full Code Here

    public Object unmarshal(Exchange exchange, InputStream inputStream) throws Exception {
        String body = ExchangeHelper.convertToMandatoryType(exchange, String.class, inputStream);
        Message message = HL7Converter.toMessage(body);

        // add MSH fields as message out headers
        Terser terser = new Terser(message);
        exchange.getOut().setHeader(HL7Constants.HL7_SENDING_APPLICATION, terser.get("MSH-3"));
        exchange.getOut().setHeader(HL7Constants.HL7_SENDING_FACILITY, terser.get("MSH-4"));
        exchange.getOut().setHeader(HL7Constants.HL7_RECEIVING_APPLICATION, terser.get("MSH-5"));
        exchange.getOut().setHeader(HL7Constants.HL7_RECEIVING_FACILITY, terser.get("MSH-6"));
        exchange.getOut().setHeader(HL7Constants.HL7_TIMESTAMP, terser.get("MSH-7"));
        exchange.getOut().setHeader(HL7Constants.HL7_SECURITY, terser.get("MSH-8"));
        exchange.getOut().setHeader(HL7Constants.HL7_MESSAGE_TYPE, terser.get("MSH-9-1"));
        exchange.getOut().setHeader(HL7Constants.HL7_TRIGGER_EVENT, terser.get("MSH-9-2"));
        exchange.getOut().setHeader(HL7Constants.HL7_MESSAGE_CONTROL, terser.get("MSH-10"));
        exchange.getOut().setHeader(HL7Constants.HL7_PROCESSING_ID, terser.get("MSH-11"));
        exchange.getOut().setHeader(HL7Constants.HL7_VERSION_ID, terser.get("MSH-12"));
        return message;
    }
View Full Code Here

    @Override
    protected void doPreSetup() throws Exception {
        defaultContext = new DefaultValidation();
        customContext = new DefaultValidation();
        @SuppressWarnings("serial")
        MessageRule rule = new MessageRule() {

            @Override
            public String getDescription() {
                return null;
            }
View Full Code Here

TOP

Related Classes of ca.uhn.hl7v2.validation.Rule

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.