Package ca.uhn.hl7v2.model.v26.group

Examples of ca.uhn.hl7v2.model.v26.group.RSP_Q11_QUERY_RESULT_CLUSTER


            log.debug("Send HL7 message using EPR :" + targetEPR);
        }

        OMElement omElement = messageContext.getEnvelope().getBody().getFirstElement().getFirstElement();
        String xmlFormat = omElement.toString();
        Message returnMsg = null;

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


        mock.expectedMessageCount(1);
        mock.message(0).body().isInstanceOf(byte[].class);
        mock.message(0).body(String.class).contains("MSA|AA|123");
        mock.message(0).body(String.class).contains("QRD|20080805120000");

        Message message = createHL7AsMessage();
        template.sendBody("direct:marshal", message);

        assertMockEndpointsSatisfied();
    }
View Full Code Here

        String body = createHL7AsString();
        template.sendBody("direct:unmarshal", body);

        assertMockEndpointsSatisfied();

        Message msg = mock.getExchanges().get(0).getIn().getBody(Message.class);
        assertEquals("2.4", msg.getVersion());
        QRD qrd = (QRD) msg.get("QRD");
        assertEquals("0101701234", qrd.getWhoSubjectFilter(0).getIDNumber().getValue());
    }
View Full Code Here

* @see org.apache.camel.component.hl7.HL7MLLPCodec
*/
public class HL7DataFormat implements DataFormat {

    public void marshal(Exchange exchange, Object body, OutputStream outputStream) throws Exception {
        Message message = ExchangeHelper.convertToMandatoryType(exchange, Message.class, body);
        String encoded = HL7Converter.toString(message);
        outputStream.write(encoded.getBytes());
    }
View Full Code Here

        outputStream.write(encoded.getBytes());
    }

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

    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

        String encodedMessage = new PipeParser().encode(theIn);
        System.out.println("Received message:\n" + encodedMessage + "\n\n");

        // Now we need to generate a message to return. This will generally be an ACK message.
        Segment msh = (Segment) theIn.get("MSH");
        Message retVal;
        try {
            // This method takes in the MSH segment of an incoming message, and generates an
            // appropriate ACK
            retVal = DefaultApplication.makeACK(msh);
View Full Code Here

        if (log.isDebugEnabled()) {
            log.debug("Inside the HL7 formatter" + omElement.toString());
        }
        if (msgCtx.getFLOW() == MessageContext.OUT_FAULT_FLOW || msgCtx.getEnvelope().hasFault()) {
            SOAPFault soapFault = msgCtx.getEnvelope().getBody().getFault();
            ACK ack = new ACK();
            try {
                //TODO : need to complete the values of the complete hl7 message, this will not properly construct by the parser
                ack.getMSH().getFieldSeparator().setValue(HL7Constants.HL7_FIELD_SEPARATOR);
                ack.getMSH().getEncodingCharacters().setValue(HL7Constants.HL7_ENCODING_CHARS);
                ack.getMSA().getAcknowledgmentCode().setValue(HL7Constants.HL7_ACK_CODE_AR);
                ack.getERR().getErrorCodeAndLocation(0).getCodeIdentifyingError().getIdentifier()
                        .setValue("Backend service reject the value");
                String msg = new PipeParser().encode(ack);
                if (log.isDebugEnabled()) {
                    log.debug("Generate HL7 error : " + ack);
                }
View Full Code Here

    String string = "MSH|^~\\&|ULTRA|TML|OLIS|OLIS|200905011130||ORU^R01|20169838|T|2.3\r"
      + "PID|||7005728\r"
      + "OBR|1\r"
      + "OBX|||||Sample Value\r";

    ORU_R01 msg = new ORU_R01();
    try {
      // This throws an exception
      msg.parse(string);
    } catch (Exception e) {
      e.printStackTrace();
      /*
       * Prints:
       * ca.uhn.hl7v2.HL7Exception: OBX-5 is valued, but OBX-2 is not.  A datatype for OBX-5 must be specified using OBX-2. See JavaDoc for Varies#fixOBX5(Segment, ModelClassFactory)
       * at ca.uhn.hl7v2.model.Varies.fixOBX5(Varies.java:189)
       * at ca.uhn.hl7v2.parser.PipeParser.parse(PipeParser.java:377)
       * at ca.uhn.hl7v2.parser.PipeParser.parse(PipeParser.java:1009)
       * at ca.uhn.hl7v2.model.AbstractMessage.parse(AbstractMessage.java:189)
       * at ca.uhn.hl7v2.examples.ParseInvalidObx2Values.main(ParseInvalidObx2Values.java:28)
       */
    }
   
    /*
     * Setting the following system property allows you to specify a default
     * value to assume if OBX-2 is missing.
     */   
    System.setProperty(Varies.DEFAULT_OBX2_TYPE_PROP, "ST");

    // Parsing now succeeds
    msg = new ORU_R01();
    msg.parse(string);

   
   
    /*
     * The following message has an invalid value in OBX-2
     */
    string = "MSH|^~\\&|ULTRA|TML|OLIS|OLIS|200905011130||ORU^R01|20169838|T|2.3\r"
      + "PID|||7005728\r"
      + "OBR|1\r"
      + "OBX||BAD|||Sample Value\r";
   
    msg = new ORU_R01();
    try {
      // This throws an exception
      msg.parse(string);
    } catch (Exception e) {
      e.printStackTrace();
      /*
       * Prints:
       * ca.uhn.hl7v2.HL7Exception: 'BAD' in record null is invalid for version 2.6. See JavaDoc for Varies#fixOBX5(Segment, ModelClassFactory): Segment: OBX Field #2
       * at ca.uhn.hl7v2.model.Varies.fixOBX5(Varies.java:212)
       * at ca.uhn.hl7v2.parser.PipeParser.parse(PipeParser.java:377)
       * at ca.uhn.hl7v2.parser.PipeParser.parse(PipeParser.java:1009)
       * at ca.uhn.hl7v2.model.AbstractMessage.parse(AbstractMessage.java:189)
       * at ca.uhn.hl7v2.examples.ParseInvalidObx2Values.main(ParseInvalidObx2Values.java:62)
       */
    }
   
    /*
     * Setting the following system property allows you to specify a default
     * value to assume if OBX-2 is missing.
     */   
    System.setProperty(Varies.INVALID_OBX2_TYPE_PROP, "ST");

    // Parsing now succeeds
    msg = new ORU_R01();
    msg.parse(string);
   
   
  }
View Full Code Here

    /**
     * Creates a new ADT_AXX message with DefaultModelClassFactory.
     */
    public ADT_AXX() {
       this(new DefaultModelClassFactory());
    }
View Full Code Here

TOP

Related Classes of ca.uhn.hl7v2.model.v26.group.RSP_Q11_QUERY_RESULT_CLUSTER

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.