Package org.apache.camel.component.hl7

Examples of org.apache.camel.component.hl7.HL7


    /**
     * The Camel route is configured via this method.  The from endpoint is required to be a SwitchYard service.
     */
    public void configure() {
        DataFormat hl7 = new HL7DataFormat();       
        from("switchyard://HL7Route")
            .unmarshal(hl7)
             .process(new Processor() {
                @Override
                public void process(Exchange exchange) throws Exception {
View Full Code Here


   

    public void testSendA19() throws Exception {

        SimpleRegistry registry = new SimpleRegistry();
        HL7MLLPCodec codec = new HL7MLLPCodec();
        codec.setCharset("iso-8859-1");
        codec.setConvertLFtoCR(true);

        registry.put("hl7codec", codec);
        CamelContext camelContext = new DefaultCamelContext(registry);
        camelContext.start();
        ProducerTemplate template = camelContext.createProducerTemplate();
View Full Code Here

    }

    private static void parseXML(String fname) throws Exception {
        SAXParserFactory f = SAXParserFactory.newInstance();
        SAXParser p = f.newSAXParser();
        HL7ContentHandler ch = new HL7ContentHandler(
                new OutputStreamWriter(System.out));
        if (fname.equals("-")) {
            p.parse(System.in, ch);
        } else {
            p.parse(new File(fname), ch);
View Full Code Here

        t.setParameter("MessageControlID", HL7Segment.nextMessageControlID());
        t.setParameter("DateTimeOfMessage", HL7Segment.timeStamp(new Date()));
        if (xsltParams != null)
            for (int i = 1; i < xsltParams.length; i++, i++)
                t.setParameter(xsltParams[i-1], xsltParams[i]);
        th.setResult(new SAXResult(new HL7ContentHandler(
                new OutputStreamWriter(out, charsetName))));
        new HL7Parser(th).parse(new InputStreamReader(
                new ByteArrayInputStream(msg, off, len),
                charsetName));
        return out.toByteArray();
View Full Code Here

    byte[] onMessage(HL7Segment msh, byte[] msg, int off, int len, int mshlen,
            Connection conn, Socket s) throws HL7Exception {
        HL7Application hl7App = getHL7Application(msh.getReceivingApplicationWithFacility());
        if (hl7App == null)
            throw new HL7Exception(HL7Exception.AR, "Receiving Application not recognized");
        return hl7App.onMessage(conn, s, msh, msg, off, len, mshlen);
    }
View Full Code Here

    }

    byte[] onMessage(Connection conn, Socket s, HL7Segment msh, byte[] msg, int off,
            int len, int mshlen) throws HL7Exception {
        if (!(isInstalled() && conns.contains(conn)))
            throw new HL7Exception(HL7Exception.AR, "Receiving Application not recognized");
        if (!(acceptedSendingApplications.isEmpty()
                || acceptedSendingApplications.contains(msh.getSendingApplicationWithFacility())))
            throw new HL7Exception(HL7Exception.AR, "Sending Application not recognized");
        if (!(acceptedMessageTypes.contains("*")
                || acceptedMessageTypes.contains(msh.getMessageType())))
            throw new HL7Exception(HL7Exception.AR, "Message Type not supported");

        HL7MessageListener listener = getHL7MessageListener();
        if (listener == null)
            throw new HL7Exception(HL7Exception.AE, "No HL7 Message Listener configured");
        return listener.onMessage(this, conn, s, msh, msg, off, len, mshlen);
    }
View Full Code Here

    public void close() {
        conn.close(sock);
    }

    public void query(String pid, String[] domains) throws IOException {
        HL7Message qbp = HL7Message.makePixQuery(pid, domains);
        HL7Segment msh = qbp.get(0);
        msh.setSendingApplicationWithFacility(sendingApplication);
        msh.setReceivingApplicationWithFacility(receivingApplication);
        msh.setField(17, charset);
        mllp.writeMessage(qbp.getBytes(charset));
        if (mllp.readMessage() == null)
            throw new IOException("Connection closed by receiver");
    }
View Full Code Here

                    charsetName);
            TransformerHandler th = getTransformerHandler();
            th.getTransformer().setOutputProperty(OutputKeys.INDENT,
                    indent ? "yes" : "no");
            th.setResult(new StreamResult(System.out));
            HL7Parser hl7Parser = new HL7Parser(th);
            hl7Parser.setIncludeNamespaceDeclaration(includeNamespaceDeclaration);
            hl7Parser.parse(reader);
        }
View Full Code Here

        if (xsltParams != null)
            for (int i = 1; i < xsltParams.length; i++, i++)
                t.setParameter(xsltParams[i-1], xsltParams[i]);
        th.setResult(new SAXResult(new HL7ContentHandler(
                new OutputStreamWriter(out, charsetName))));
        new HL7Parser(th).parse(new InputStreamReader(
                new ByteArrayInputStream(msg, off, len),
                charsetName));
        return out.toByteArray();
    }
View Full Code Here

        public void parse(InputStream is) throws IOException,
                TransformerConfigurationException, SAXException {
            byte[] buf = new byte[256];
            int len = is.read(buf);
            HL7Segment msh = HL7Segment.parseMSH(buf, buf.length);
            String charsetName = HL7Charset.toCharsetName(msh.getField(17, charset));
            Reader reader = new InputStreamReader(
                    new SequenceInputStream(
                            new ByteArrayInputStream(buf, 0, len), is),
                    charsetName);
            TransformerHandler th = getTransformerHandler();
View Full Code Here

TOP

Related Classes of org.apache.camel.component.hl7.HL7

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.