Package model

Examples of model.Message


        HL7Exception[] problems = test(in);       
        sendNotifications(problems);
       
        NDC.pop();
       
        Message ack = null;
        try {
            ack = ca.uhn.hl7v2.app.DefaultApplication.makeACK((Segment) in.get("MSH"));
            addProblemsToACK(ack, problems);
        } catch (java.io.IOException e) {
            throw new HL7Exception(e);
View Full Code Here


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

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

    Message incomingMessageObject = null;
    String outgoingMessageString = null;
    try {
      incomingMessageObject = parser.parse(incomingMessageString);
    } catch (HL7Exception e) {
      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", MessageIDGenerator.getInstance().getNewID());
      } catch (IOException ioe) {
        throw new HL7Exception("Problem creating error message ID: "
            + ioe.getMessage());
      }

      // populate MSA ...
      t.set("/MSA-1", "AE"); // should this come from HL7Exception
                  // constructor?
      t.set("/MSA-2", Terser.get(inHeader, 10, 0, 1, 1));
      String excepMessage = e.getMessage();
      if (excepMessage != null)
        t.set("/MSA-3",
            excepMessage.substring(0,
                Math.min(80, excepMessage.length())));

      /*
       * Some earlier ACKs don't have ERRs, but I think we'll change this
       * within HAPI so that there is a single ACK for each version (with
       * an ERR).
       */
      // see if it's an HL7Exception (so we can get specific information)
      // ...
      if (e.getClass().equals(HL7Exception.class)) {
        Segment err = (Segment) out.get("ERR");
        // ((HL7Exception) e).populate(err); // FIXME: this is broken,
        // it relies on the database in a place where it's not available
      } else {
        t.set("/ERR-1-4-1", "207");
        t.set("/ERR-1-4-2", "Application Internal Error");
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

     * Creates and returns an acknowledgement -- the details are determined by fillDetails().
     */
    public Message processMessage(Message in) throws ApplicationException {
        try {
            //get default ACK
          Message out = makeACK((Segment) in.get("MSH"));
            fillDetails(out);
            return out;
        } catch (Exception e) {
            throw new ApplicationException("Couldn't create response message: " + e.getMessage());
        }       
View Full Code Here

        }
        if (version == null) version = "2.4";

        String ackClassName = DefaultModelClassFactory.getVersionPackageName(version) + "message.ACK";

        Message out = null;
        try {
            @SuppressWarnings("unchecked")
      Class<? extends Message> ackClass = (Class<? extends Message>) Class.forName(ackClassName);
            out = ackClass.newInstance();
        }
        catch (Exception e) {
            throw new HL7Exception("Can't instantiate ACK of class " + ackClassName + ": " + e.getClass().getName());
        }
        Terser terser = new Terser(out);

        //populate outbound MSH using data from inbound message ...            
        Segment outHeader = (Segment) out.get("MSH");
        fillResponseHeader(inboundHeader, outHeader);

        terser.set("/MSH-9", "ACK");
        terser.set("/MSH-12", version);
        terser.set("/MSA-1", "AA");
View Full Code Here

   * @throws ApplicationException
   *             if no such Applications are registered, or if the underlying
   *             Application throws this exception during processing.
   */
  public Message processMessage(Message in) throws ApplicationException {
    Message out;
    try {
      Application matchingApp = this.getMatchingApplication(in);
      out = matchingApp.processMessage(in);
    } catch (HL7Exception e) {
      throw new ApplicationException("Error internally routing message: "
View Full Code Here

   */
  public void parseOutbound() throws HL7Exception,
      EncodingNotSupportedException {
    // replace all the line feeds in the text area with carriage returns ...
    String messageString = this.outboundText.getText().replace('\n', '\r');
    Message out = parser.parse(messageString);
    this.outboundTree.setMessage(out);

    if (messages.getDividerLocation() < 0)
      messages.setDividerLocation(0.5);
    this.validate();
View Full Code Here

  /**
   * Sends the message that is currently displayed in the outbound tree to the
   * remote system that is currently connected.
   */
  public void sendAndRecieve() throws Exception {
    Message outbound = this.outboundTree.getMessage();
    Message inbound;
    try {
      inbound = connectionHub.getKnownConnection(getCurrentConnection())
          .getInitiator().sendAndReceive(outbound);
    } catch (NullPointerException e) {
      throw new IOException("Please select a Connection.");
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

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.