Package ca.uhn.hl7v2.model.v26.message

Examples of ca.uhn.hl7v2.model.v26.message.ORU_R01


        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 any processing problem occurs
     */
    public static void main(String[] args) throws HL7Exception {

        // First, a message object is constructed
        ORU_R01 message = new ORU_R01();

        // A few basic MSH fields are populated. In a real situation, this would not be enough
        // to produce a valid message, but for demonstration purposes we'll skip a few
        // fields.
        message.getMSH().getEncodingCharacters().setValue("^~\\&");
        message.getMSH().getFieldSeparator().setValue("|");

        ORU_R01_ORDER_OBSERVATION orderObservation = message.getPATIENT_RESULT().getORDER_OBSERVATION();

        // Populate the OBR
        OBR obr = orderObservation.getOBR();
        obr.getSetIDOBR().setValue("1");
        obr.getFillerOrderNumber().getEntityIdentifier().setValue("1234");
View Full Code Here

       
        // We can also use the terser to set values
        terser.set("/.MSH-3-1", "new_sending_app");
       
        // Let's try something more complicated, adding values to an OBX in an ORU^R01
        ORU_R01 oru = new ORU_R01();
        oru.getMSH().getEncodingCharacters().setValue("^~\\&");
        oru.getMSH().getFieldSeparator().setValue("|");
        oru.getMSH().getMessageType().getMessageCode().setValue("ORU");
        oru.getMSH().getMessageType().getTriggerEvent().setValue("R01");
        oru.getMSH().getVersionID().getVersionID().setValue("2.5");
       
        terser = new Terser(oru);
        for (int i = 0; i < 5; i++) {
            terser.set("/PATIENT_RESULT/ORDER_OBSERVATION/OBSERVATION(" + i + ")/OBX-1", "" + (i + 1));
            terser.set("/PATIENT_RESULT/ORDER_OBSERVATION/OBSERVATION(" + i + ")/OBX-3", "ST");
View Full Code Here

     * @throws IOException
     */
    public static void main(String[] args) throws HL7Exception, IOException {

        // First, a message object is constructed
        ORU_R01 message = new ORU_R01();

        /*
         * The initQuickstart method populates all of the mandatory fields in the
         * MSH segment of the message, including the message type, the timestamp,
         * and the control ID.
         */
        message.initQuickstart("ORU", "R01", "T");
       
        /*
         * The OBR segment is contained within a group called ORDER_OBSERVATION,
         * which is itself in a group called PATIENT_RESULT. These groups are
         * reached using named accessors.
         */
        ORU_R01_ORDER_OBSERVATION orderObservation = message.getPATIENT_RESULT().getORDER_OBSERVATION();

        // Populate the OBR
        OBR obr = orderObservation.getOBR();
        obr.getSetIDOBR().setValue("1");
        obr.getFillerOrderNumber().getEntityIdentifier().setValue("1234");
View Full Code Here

       
        // We can also use the terser to set values
        terser.set("/.MSH-3-1", "new_sending_app");
       
        // Let's try something more complicated, adding values to an OBX in an ORU^R01
        ORU_R01 oru = new ORU_R01();
        oru.getMSH().getEncodingCharacters().setValue("^~\\&");
        oru.getMSH().getFieldSeparator().setValue("|");
        oru.getMSH().getMessageType().getMessageCode().setValue("ORU");
        oru.getMSH().getMessageType().getTriggerEvent().setValue("R01");
        oru.getMSH().getVersionID().getVersionID().setValue("2.5");
       
        terser = new Terser(oru);
        for (int i = 0; i < 5; i++) {
            terser.set("/PATIENT_RESULT/ORDER_OBSERVATION/OBSERVATION(" + i + ")/OBX-1", "" + (i + 1));
            terser.set("/PATIENT_RESULT/ORDER_OBSERVATION/OBSERVATION(" + i + ")/OBX-3", "ST");
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.message.ORU_R01

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.