Package ca.uhn.hl7v2.util

Examples of ca.uhn.hl7v2.util.MessageIterator


            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

        throw new UnsupportedOperationException("Not supported yet.");
  }
   
    public void parse(Message message, String string) throws HL7Exception {
        //MessagePointer ptr = new MessagePointer(this, m, getEncodingChars(message));
        MessageIterator messageIter = new MessageIterator(message, "MSH", true);
        FilterIterator.Predicate segmentsOnly = new FilterIterator.Predicate() {
            public boolean evaluate(Object obj) {
                if (Segment.class.isAssignableFrom(obj.getClass())) {
                    return true;
                } else {
                    return false;
                }
            }
        };
        FilterIterator segmentIter = new FilterIterator(messageIter, segmentsOnly);

        String[] segments = split(string, segDelim);

        char delim = '|';
        for (int i = 0; i < segments.length; i++) {

            //get rid of any leading whitespace characters ...
            if (segments[i] != null && segments[i].length() > 0 && Character.isWhitespace(segments[i].charAt(0)))
                segments[i] = stripLeadingWhitespace(segments[i]);

            //sometimes people put extra segment delimiters at end of msg ...
            if (segments[i] != null && segments[i].length() >= 3) {
                final String name;
                if (i == 0) {
                    name = segments[i].substring(0, 3);
                    delim = segments[i].charAt(3);
                } else {
                    if (segments[i].indexOf(delim) >= 0 ) {
                        name = segments[i].substring(0, segments[i].indexOf(delim));
                      } else {
                        name = segments[i];
                      }
                 }

                log.debug("Parsing segment {}", name);

                messageIter.setDirection(name);
                FilterIterator.Predicate byDirection = new FilterIterator.Predicate() {
                    public boolean evaluate(Object obj) {
                        Structure s = (Structure) obj;
                        log.debug("PipeParser iterating message in direction {} at {} ", name, s.getName());
                        return s.getName().matches(name + "\\d*");
 
View Full Code Here

        throw new UnsupportedOperationException("Not supported yet.");
  }
   
    public void parse(Message message, String string) throws HL7Exception {
        //MessagePointer ptr = new MessagePointer(this, m, getEncodingChars(message));
        MessageIterator messageIter = new MessageIterator(message, "MSH", true);
        FilterIterator.Predicate<Structure> segmentsOnly = new FilterIterator.Predicate<Structure>() {
            public boolean evaluate(Structure obj) {
                if (Segment.class.isAssignableFrom(obj.getClass())) {
                    return true;
                } else {
                    return false;
                }
            }
        };
        FilterIterator<Structure> segmentIter = new FilterIterator<Structure>(messageIter, segmentsOnly);

        String[] segments = split(string, segDelim);

        char delim = '|';
        for (int i = 0; i < segments.length; i++) {

            //get rid of any leading whitespace characters ...
            if (segments[i] != null && segments[i].length() > 0 && Character.isWhitespace(segments[i].charAt(0)))
                segments[i] = stripLeadingWhitespace(segments[i]);

            //sometimes people put extra segment delimiters at end of msg ...
            if (segments[i] != null && segments[i].length() >= 3) {
                final String name;
                if (i == 0) {
                    name = segments[i].substring(0, 3);
                    delim = segments[i].charAt(3);
                } else {
                    if (segments[i].indexOf(delim) >= 0 ) {
                        name = segments[i].substring(0, segments[i].indexOf(delim));
                      } else {
                        name = segments[i];
                      }
                 }

                log.debug("Parsing segment {}", name);

                messageIter.setDirection(name);
                FilterIterator.Predicate<Structure> byDirection = new FilterIterator.Predicate<Structure>() {
                    public boolean evaluate(Structure obj) {
                        Structure s = (Structure) obj;
                        log.debug("PipeParser iterating message in direction {} at {} ", name, s.getName());
                        return s.getName().matches(name + "\\d*");
 
View Full Code Here

        throw new UnsupportedOperationException("Not supported yet.");
  }
   
    public void parse(Message message, String string) throws HL7Exception {
        //MessagePointer ptr = new MessagePointer(this, m, getEncodingChars(message));
        MessageIterator messageIter = new MessageIterator(message, "MSH", true);
        FilterIterator.Predicate<Structure> segmentsOnly = new FilterIterator.Predicate<Structure>() {
            public boolean evaluate(Structure obj) {
                if (Segment.class.isAssignableFrom(obj.getClass())) {
                    return true;
                } else {
                    return false;
                }
            }
        };
        FilterIterator<Structure> segmentIter = new FilterIterator<Structure>(messageIter, segmentsOnly);

        String[] segments = split(string, segDelim);

        char delim = '|';
        for (int i = 0; i < segments.length; i++) {

            //get rid of any leading whitespace characters ...
            if (segments[i] != null && segments[i].length() > 0 && Character.isWhitespace(segments[i].charAt(0)))
                segments[i] = stripLeadingWhitespace(segments[i]);

            //sometimes people put extra segment delimiters at end of msg ...
            if (segments[i] != null && segments[i].length() >= 3) {
                final String name;
                if (i == 0) {
                    name = segments[i].substring(0, 3);
                    delim = segments[i].charAt(3);
                } else {
                    if (segments[i].indexOf(delim) >= 0 ) {
                        name = segments[i].substring(0, segments[i].indexOf(delim));
                      } else {
                        name = segments[i];
                      }
                 }

                log.debug("Parsing segment {}", name);

                messageIter.setDirection(name);
                FilterIterator.Predicate<Structure> byDirection = new FilterIterator.Predicate<Structure>() {
                    public boolean evaluate(Structure obj) {
                        Structure s = (Structure) obj;
                        log.debug("PipeParser iterating message in direction {} at {} ", name, s.getName());
                        return s.getName().matches(name + "\\d*");
 
View Full Code Here

        throw new UnsupportedOperationException("Not supported yet.");
  }
   
    public void parse(Message message, String string) throws HL7Exception {
        //MessagePointer ptr = new MessagePointer(this, m, getEncodingChars(message));
        MessageIterator messageIter = new MessageIterator(message, "MSH", true);
        FilterIterator.Predicate<Structure> segmentsOnly = new FilterIterator.Predicate<Structure>() {
            public boolean evaluate(Structure obj) {
                if (Segment.class.isAssignableFrom(obj.getClass())) {
                    return true;
                } else {
                    return false;
                }
            }
        };
        FilterIterator<Structure> segmentIter = new FilterIterator<Structure>(messageIter, segmentsOnly);

        String[] segments = split(string, segDelim);

        char delim = '|';
        for (int i = 0; i < segments.length; i++) {

            //get rid of any leading whitespace characters ...
            if (segments[i] != null && segments[i].length() > 0 && Character.isWhitespace(segments[i].charAt(0)))
                segments[i] = stripLeadingWhitespace(segments[i]);

            //sometimes people put extra segment delimiters at end of msg ...
            if (segments[i] != null && segments[i].length() >= 3) {
                final String name;
                if (i == 0) {
                    name = segments[i].substring(0, 3);
                    delim = segments[i].charAt(3);
                } else {
                    if (segments[i].indexOf(delim) >= 0 ) {
                        name = segments[i].substring(0, segments[i].indexOf(delim));
                      } else {
                        name = segments[i];
                      }
                 }

                log.debug("Parsing segment {}", name);

                messageIter.setDirection(name);
                FilterIterator.Predicate<Structure> byDirection = new FilterIterator.Predicate<Structure>() {
                    public boolean evaluate(Structure obj) {
                        Structure s = (Structure) obj;
                        log.debug("PipeParser iterating message in direction {} at {} ", name, s.getName());
                        return s.getName().matches(name + "\\d*");
 
View Full Code Here

        return encode(type, encodingCharacters);
    }

    public void parse(Message message, String string) throws HL7Exception {
        //MessagePointer ptr = new MessagePointer(this, m, getEncodingChars(message));
        MessageIterator messageIter = new MessageIterator(message, "MSH", true);
        FilterIterator.Predicate segmentsOnly = new FilterIterator.Predicate() {
            public boolean evaluate(Object obj) {
                if (Segment.class.isAssignableFrom(obj.getClass())) {
                    return true;
                } else {
                    return false;
                }
            }
        };
        FilterIterator segmentIter = new FilterIterator(messageIter, segmentsOnly);

        String[] segments = split(string, segDelim);

        char delim = '|';
        for (int i = 0; i < segments.length; i++) {

            //get rid of any leading whitespace characters ...
            if (segments[i] != null && segments[i].length() > 0 && Character.isWhitespace(segments[i].charAt(0)))
                segments[i] = stripLeadingWhitespace(segments[i]);

            //sometimes people put extra segment delimiters at end of msg ...
            if (segments[i] != null && segments[i].length() >= 3) {
                final String name;
                if (i == 0) {
                    name = segments[i].substring(0, 3);
                    delim = segments[i].charAt(3);
                } else {
                    if (segments[i].indexOf(delim) >= 0 ) {
                        name = segments[i].substring(0, segments[i].indexOf(delim));
                      } else {
                        name = segments[i];
                      }
                 }

                log.debug("Parsing segment " + name);

                messageIter.setDirection(name);
                FilterIterator.Predicate byDirection = new FilterIterator.Predicate() {
                    public boolean evaluate(Object obj) {
                        Structure s = (Structure) obj;
                        log.debug("PipeParser iterating message in direction " + name + " at " + s.getName());
                        if (s.getName().matches(name + "\\d*")) {
View Full Code Here

TOP

Related Classes of ca.uhn.hl7v2.util.MessageIterator

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.