Package ca.uhn.hl7v2.examples.custommodel.v25.segment

Examples of ca.uhn.hl7v2.examples.custommodel.v25.segment.ZPI


public class HL7Sender {

    public void send(String host, int port) throws HL7Exception {
        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);
        }

        // Close the connection and server
        connectionHub.discard(connection);
    }
View Full Code Here


        Map<String,String> params = getURLParameters(targetEPR);

        try {
            Message message = parser.parse(xmlFormat);
            ConnectionHub connectionHub = ConnectionHub.getInstance();
            Connection connection = getConnection(targetEPR, connectionHub);
            Initiator initiator = connection.getInitiator();
            String timeout = params.get(HL7Constants.TIMEOUT_PARAM);
            if (timeout != null) {
                initiator.setTimeoutMillis(Integer.parseInt(timeout));
            } else {
                initiator.setTimeoutMillis(HL7Constants.DEFAULT_TIMEOUT);
            }

            returnMsg = initiator.sendAndReceive(message);
            connectionHub.detach(connection);

            if (log.isDebugEnabled()) {
                log.debug("HL7 message successfully dispatched to URL " + targetEPR);
                log.debug("Response message received from target EP : " + returnMsg.toString());
            }
View Full Code Here

        // 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);
View Full Code Here

        try {
            Message message = parser.parse(xmlFormat);
            ConnectionHub connectionHub = ConnectionHub.getInstance();
            Connection connection = getConnection(targetEPR, connectionHub);
            Initiator initiator = connection.getInitiator();
            String timeout = params.get(HL7Constants.TIMEOUT_PARAM);
            if (timeout != null) {
                initiator.setTimeoutMillis(Integer.parseInt(timeout));
            } else {
                initiator.setTimeoutMillis(HL7Constants.DEFAULT_TIMEOUT);
            }

            returnMsg = initiator.sendAndReceive(message);
            connectionHub.detach(connection);

            if (log.isDebugEnabled()) {
                log.debug("HL7 message successfully dispatched to URL " + targetEPR);
                log.debug("Response message received from target EP : " + returnMsg.toString());
View Full Code Here

    private SimpleServer server;

    public HL7Server(int port) {
        LowerLayerProtocol llp = LowerLayerProtocol.makeLLP(); // The transport protocol
        PipeParser parser = new PipeParser();
        server = new SimpleServer(port, llp, parser);
    }
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);

        log.info("Started HL7 endpoint on port: " + endpoint.getPort());
    }
View Full Code Here

        log.info("Started HL7 endpoint on port: " + endpoint.getPort());
    }

    @Override
    protected void stopEndpoint(HL7Endpoint endpoint) {
        SimpleServer server = serverTable.remove(endpoint);
        if (server != null) {
            server.stop();
        }

        log.info("Stopped HL7 endpoint on port: " + endpoint.getPort());
    }
View Full Code Here

        // Here is a segment class we have created (click to view):
        ZPI zpi;

        // Here is a message class we have created (click to view):
        ZDT_A01 zdtA01;

        // These classes are both in the package ca.uhn.hl7v2.examples.custommodel.[version].[type]
        // We can create a parser with a custom model class factory to use it
        ModelClassFactory cmf = new CustomModelClassFactory("ca.uhn.hl7v2.examples.custommodel");

        // We then pass the model class factory to the parser
        Parser parser = new PipeParser(cmf);

        // The resulting message will be an instance of our custom type (this time, MSH-9 says ZDT^A01)
    messageText = "MSH|^~\\&|IRIS|SANTER|AMB_R|SANTER|200803051508||ZDT^A01|263206|P|2.5\r"
        + "EVN||200803051509||||200803031508\r"
        + "PID|||5520255^^^PK^PK~ZZZZZZ83M64Z148R^^^CF^CF~ZZZZZZ83M64Z148R^^^SSN^SSN^^20070103^99991231~^^^^TEAM||ZZZ^ZZZ||19830824|F||||||||||||||||||||||N\r"
        + "ZPI|Fido~Fred|13\r"
        + "PV1||I|6402DH^^^^^^^^MED. 1 - ONCOLOGIA^^OSPEDALE MAGGIORE DI LODI&LODI|||^^^^^^^^^^OSPEDALE MAGGIORE DI LODI&LODI|13936^TEST^TEST||||||||||5068^TEST2^TEST2||2008003369||||||||||||||||||||||||||200803031508\r"
        + "PR1|1||1111^Mastoplastica|Protesi|20090224|02|";
        zdtA01 = (ZDT_A01) parser.parse(messageText);

        // Now we have easy access to our new segment and fields
        zpi = zdtA01.getZPI();

        System.out.println(zpi.getPetName()[0].encode()); // Fido
        System.out.println(zpi.getPetName()[1].encode()); // Fred
        System.out.println(zpi.getShoeSize().encode()); // 13
View Full Code Here

        // Now, suppose our message is actually called ZDT^A01, and we plan on
        // using it frequently, so we want to explicitly define a class to
        // handle it. That can be done as well.

        // Here is a segment class we have created (click to view):
        ZPI zpi;

        // Here is a message class we have created (click to view):
        ZDT_A01 zdtA01;

        // These classes are both in the package ca.uhn.hl7v2.examples.custommodel.[version].[type]
        // We can create a parser with a custom model class factory to use it
        ModelClassFactory cmf = new CustomModelClassFactory("ca.uhn.hl7v2.examples.custommodel");

        // We then pass the model class factory to the parser
        Parser parser = new PipeParser(cmf);

        // The resulting message will be an instance of our custom type (this time, MSH-9 says ZDT^A01)
    messageText = "MSH|^~\\&|IRIS|SANTER|AMB_R|SANTER|200803051508||ZDT^A01|263206|P|2.5\r"
        + "EVN||200803051509||||200803031508\r"
        + "PID|||5520255^^^PK^PK~ZZZZZZ83M64Z148R^^^CF^CF~ZZZZZZ83M64Z148R^^^SSN^SSN^^20070103^99991231~^^^^TEAM||ZZZ^ZZZ||19830824|F||||||||||||||||||||||N\r"
        + "ZPI|Fido~Fred|13\r"
        + "PV1||I|6402DH^^^^^^^^MED. 1 - ONCOLOGIA^^OSPEDALE MAGGIORE DI LODI&LODI|||^^^^^^^^^^OSPEDALE MAGGIORE DI LODI&LODI|13936^TEST^TEST||||||||||5068^TEST2^TEST2||2008003369||||||||||||||||||||||||||200803031508\r"
        + "PR1|1||1111^Mastoplastica|Protesi|20090224|02|";
        zdtA01 = (ZDT_A01) parser.parse(messageText);

        // Now we have easy access to our new segment and fields
        zpi = zdtA01.getZPI();

        System.out.println(zpi.getPetName()[0].encode()); // Fido
        System.out.println(zpi.getPetName()[1].encode()); // Fred
        System.out.println(zpi.getShoeSize().encode()); // 13

    }
View Full Code Here

public class HL7Server {

    private SimpleServer server;

    public HL7Server(int port) {
        LowerLayerProtocol llp = LowerLayerProtocol.makeLLP(); // The transport protocol
        PipeParser parser = new PipeParser();
        server = new SimpleServer(port, llp, parser);
    }
View Full Code Here

TOP

Related Classes of ca.uhn.hl7v2.examples.custommodel.v25.segment.ZPI

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.