Package model

Examples of model.Message


        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

public class HL7DataFormat implements DataFormat {

    private boolean validate = true;

    public void marshal(Exchange exchange, Object body, OutputStream outputStream) throws Exception {
        Message message = ExchangeHelper.convertToMandatoryType(exchange, Message.class, body);
        String encoded = HL7Converter.encode(message, validate);
        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.parse(body, validate);

        // 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

    /**
     * Converts XML message to ER7, first checking integrity of parse and throwing
     * an exception if parse not correct
     */
    private static String safeER7Conversion(String xmlMessage) throws HL7Exception {
        Message m = parser.parse(xmlMessage);

        String check = parser.encode(m, "XML");
        if (!equivalent(xmlMessage, check)) {
            throw new HL7Exception("Parsed and encoded message not equivalent to original (possibilities: invalid message, bug in parser)");
        }
View Full Code Here

    Logger rawInbound = LoggerFactory.getLogger("ca.uhn.hl7v2.raw.inbound");

    log.debug("Responder got message: {}", incomingMessageString);
    rawInbound.debug(incomingMessageString);

    Message incomingMessageObject = null;
    String outgoingMessageString = null;
    try {
      incomingMessageObject = parser.parse(incomingMessageString);
    } catch (HL7Exception e) {
      // TODO this may also throw an Exception, which hides the
      // previous one.
      outgoingMessageString = logAndMakeErrorMessage(e,
          parser.getCriticalResponseData(incomingMessageString),
          parser, parser.getEncoding(incomingMessageString));
      for (Object app : apps) {
        if (app instanceof ApplicationExceptionHandler) {
          ApplicationExceptionHandler aeh = (ApplicationExceptionHandler) app;
          outgoingMessageString = aeh.processException(
              incomingMessageString, outgoingMessageString, e);
        }
      }
    }

    if (outgoingMessageString == null) {
      try {
        // optionally check integrity of parse
        try {
          if (checkWriter != null)
            checkParse(incomingMessageString,
                incomingMessageObject, parser);
        } catch (IOException e) {
          log.error("Unable to write parse check results to file", e);
        }

        // message validation (in terms of optionality, cardinality)
        // would go here ***

        Application app = findApplication(incomingMessageObject);
        Message response = app.processMessage(incomingMessageObject);

        if (response == null) {
          throw new HL7Exception("Application of type " + app.getClass().getName() + " failed to return a response message from 'processMessage'");
        }
       
View Full Code Here

    log.error("Attempting to send error message to remote system.", e);

    // create error message ...
    String errorMessage = null;
    try {
      Message out = DefaultApplication.makeACK(inHeader);
      Terser t = new Terser(out);

      // copy required data from incoming message ...
      try {
        t.set("/MSH-10", out.getParser().getParserConfiguration().getIdGenerator().getID());
      } catch (IOException ioe) {
        throw new HL7Exception("Problem creating error message ID: "
            + ioe.getMessage());
      }
View Full Code Here

      in.read(cbuf, 0, fileLength);
      String messageString = new String(cbuf);

      // parse inbound message ...
      final Parser parser = new PipeParser();
      Message inMessage = null;
      try {
        inMessage = parser.parse(messageString);
      } catch (HL7Exception e) {
        e.printStackTrace();
      }
View Full Code Here

      conn.getSendWriter().writeMessage(outbound);
      if (inbound != null && (message = inbound.get()) != null) {
        // log that we got the message
        log.debug("Initiator received message: {}", message);
        rawInbound.debug(message);
        Message response = conn.getParser().parse(message);
        log.debug("response parsed");
        return response;
      }
    } catch (IOException e) {
      if (inbound != null)
View Full Code Here

         
          public void run() {
            try {
              // get message ID
              String ID = generator.getID();
              Message out = parser.parse(outText);
              Terser tOut = new Terser(out);
              tOut.set("/MSH-10", ID);

              // send, get response
              Message in = initiator.sendAndReceive(out);
              // get ACK ID
              Terser tIn = new Terser(in);
              String ackID = tIn.get("/MSA-2");
              if (ID.equals(ackID)) {
                System.out.println("OK - ack ID matches");
View Full Code Here

TOP

Related Classes of 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.