Package ca.uhn.hl7v2.model

Examples of ca.uhn.hl7v2.model.Message


   *      boolean, String)
   */
  protected Message instantiateMessageInASpecificPackage(String theName,
      String theVersion, boolean isExplicit, String packageName)
      throws HL7Exception {
    Message result = null;

    try {
      Class<? extends Message> messageClass = myFactory
          .getMessageClassInASpecificPackage(theName, theVersion,
              isExplicit, packageName);
      if (messageClass == null) {
        throw new ClassNotFoundException(
            "Can't find message class in current package list: "
                + theName);
      }

      log.debug("Instantiating msg of class {}", messageClass.getName());
      Constructor<? extends Message> constructor = messageClass
          .getConstructor(new Class[] { ModelClassFactory.class });
      result = (Message) constructor
          .newInstance(new Object[] { myFactory });
    } catch (Exception e) {
      throw new HL7Exception("Couldn't create Message object of type "
          + theName, HL7Exception.UNSUPPORTED_MESSAGE_TYPE, e);
    }

    result.setValidationContext(myContext);

    return result;
  }
View Full Code Here


  public static Segment makeControlMSH(String version,
      ModelClassFactory factory) throws HL7Exception {
    Segment msh = null;

    try {
      Message dummy = GenericMessage.getGenericMessageClass(version)
          .getConstructor(new Class[] { ModelClassFactory.class })
          .newInstance(new Object[] { factory });

      Class<?>[] constructorParamTypes = { Group.class,
          ModelClassFactory.class };
View Full Code Here

   *             be found or the Message class throws an exception on
   *             instantiation (e.g. if args are not as expected)
   */
  protected Message instantiateMessage(String theName, String theVersion,
      boolean isExplicit) throws HL7Exception {
    Message result = null;

    try {
      Class<? extends Message> messageClass = myFactory.getMessageClass(
          theName, theVersion, isExplicit);
      if (messageClass == null)
        throw new ClassNotFoundException(
            "Can't find message class in current package list: "
                + theName);
      log.debug("Instantiating msg of class {}", messageClass.getName());
      Constructor<? extends Message> constructor = messageClass
          .getConstructor(new Class[] { ModelClassFactory.class });
      result = constructor.newInstance(new Object[] { myFactory });
    } catch (Exception e) {
      throw new HL7Exception("Couldn't create Message object of type "
          + theName, HL7Exception.UNSUPPORTED_MESSAGE_TYPE, e);
    }

    result.setValidationContext(myContext);

    return result;
  }
View Full Code Here

     * object.  This method checks that the given message string is XML encoded, creates an
     * XML Document object (using Xerces) from the given String, and calls the abstract
     * method <code>parse(Document XMLMessage)</code></p>
     */
    protected Message doParse(String message, String version) throws HL7Exception, EncodingNotSupportedException {
        Message m = null;

        //parse message string into a DOM document
        Document doc = null;
        doc = parseStringIntoDocument(message);
        m = parseDocument(doc, version);
View Full Code Here

     * @throws EncodingNotSupportedException if the message encoded
     *     is not supported by this parser.
     */
    public Message parseDocument(org.w3c.dom.Document XMLMessage, String version) throws HL7Exception {
        String messageName = XMLMessage.getDocumentElement().getTagName();
        Message message = instantiateMessage(messageName, version, true);
        parse(message, XMLMessage.getDocumentElement());
        return message;
    }
View Full Code Here

            else if (xp.getEncoding(messString) != null) {
                inParser = xp;
                outParser = pp;
            }

            Message mess = inParser.parse(messString);
            System.out.println("Got message of type " + mess.getClass().getName());

            String otherEncoding = outParser.encode(mess);
            System.out.println(otherEncoding);
        }
        catch (Exception e) {
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

        return new RouteBuilder() {
            public void configure() throws Exception {
                from("mina:tcp://127.0.0.1:8888?sync=true&codec=#hl7codec")
                    .process(new Processor() {
                        public void process(Exchange exchange) throws Exception {
                            Message input = exchange.getIn().getBody(Message.class);

                            assertEquals("2.4", input.getVersion());
                            QRD qrd = (QRD)input.get("QRD");
                            assertEquals("0101701234", qrd.getWhoSubjectFilter(0).getIDNumber().getValue());

                            Message response = createHL7AsMessage();
                            exchange.getOut().setBody(response);
                        }
                    })
                    .to("mock:result");
            }
View Full Code Here

        return new RouteBuilder() {
            public void configure() throws Exception {
                from("mina:tcp://127.0.0.1:8888?sync=true&codec=#hl7codec")
                    .process(new Processor() {
                        public void process(Exchange exchange) throws Exception {
                            Message input = exchange.getIn().getBody(Message.class);

                            assertEquals("2.4", input.getVersion());
                            QRD qrd = (QRD)input.get("QRD");
                            assertEquals("0101701234", qrd.getWhoSubjectFilter(0).getIDNumber().getValue());

                            Message response = createHL7AsMessage();
                            exchange.getOut().setBody(response);
                        }
                    })
                    .to("mock:result");
            }
View Full Code Here

TOP

Related Classes of ca.uhn.hl7v2.model.Message

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.