Package ca.uhn.hl7v2

Examples of ca.uhn.hl7v2.HL7Exception


        }
      } else {
        msh = new GenericSegment(dummy, "MSH");     
      }
    } catch (Exception e) {
      throw new HL7Exception("Couldn't create MSH for version " + version
          + " (does your classpath include this version?) ... ", e);
    }
    return msh;
  }
View Full Code Here


            default:
                log.error("Attempting to send error message to remote system.", e);
                break;
        }

        HL7Exception hl7e = e instanceof HL7Exception ?
                (HL7Exception) e :
                new HL7Exception(e.getMessage(), e);

        try {
            Message out = hl7e.getResponseMessage();
            if (out == null) {
                Message in = getInMessage(inHeader);
                out = in.generateACK(DEFAULT_EXCEPTION_ACKNOWLEDGEMENT_CODE, hl7e);
            }
            return encoding != null ? p.encode(out, encoding) : p.encode(out);

        } catch (IOException ioe) {
            throw new HL7Exception(
                    "IOException creating error response message: "
                            + ioe.getMessage());
        }

    }
View Full Code Here

   * @param version HL7 version
   * @throws HL7Exception if version is unknown
   */
  public static void assertVersionExists(String version) throws HL7Exception {
    if (!Version.supportsVersion(version))
            throw new HL7Exception(
                    "The HL7 version " + version + " is not recognized",
                    ErrorCode.UNSUPPORTED_VERSION_ID);
  }
View Full Code Here

   */
  protected Message instantiateMessage(String theName, String theVersion, boolean isExplicit)
      throws HL7Exception {
    Class<? extends Message> messageClass = getFactory().getMessageClass(theName, theVersion, isExplicit);
    if (messageClass == null)
      throw new HL7Exception("Can't find message class in current package list: " + theName);
    return ReflectionUtil.instantiateMessage(messageClass, getFactory());
  }
View Full Code Here

    }

    private <R> void handleException(ValidationExceptionHandler<R> handler, R result)
            throws HL7Exception {
        if (handler.hasFailed()) {
            HL7Exception e = new HL7Exception("Validation has failed");
            e.setDetail(result);
            if (result instanceof Message) e.setResponseMessage((Message)result);
            throw e;
        }
    }
View Full Code Here

                }
               
                if (response != null && isError(response)) {
                    String[] errMsgPath = {"MSA-3"};
                    String[] errMsg = PreParser.getFields(response.getMessage(), errMsgPath);                   
                    throw new HL7Exception("Error message received: " + errMsg[0]);
                }
               
            } while (response == null && ++retries <= maxRetries);
        }
    }
View Full Code Here

    private void checkValidAckNeededCode(String theCode) throws HL7Exception {
        //must be one of the below ...
        if ( !(theCode == null || theCode.equals("")
                ||theCode.equals(AL) || theCode.equals(ER)
                || theCode.equals(NE) || theCode.equals(SU)) ) {
            throw new HL7Exception("MSH-15 must be AL, ER, NE, or SU in the outgoing message");
        }           
    }
View Full Code Here

                    "Can't parse message beginning " + message.substring(0, Math.min(message.length(), 50)));
        }
       
        String version = getVersion(message);
        if (!validVersion(version)) {
            throw new HL7Exception("Can't process message of version '" + version + "' - version not recognized",
                    HL7Exception.UNSUPPORTED_VERSION_ID);
        }
       
        myValidator.validate(message, encoding.equals("XML"), version);       
        Message result = doParse(message, version);
View Full Code Here

                "Can't parse message beginning " + message.substring(0, Math.min(message.length(), 50)));
    }
    
    String version = getVersion(message);
    if (!validVersion(version)) {
        throw new HL7Exception("Can't process message of version '" + version + "' - version not recognized",
                HL7Exception.UNSUPPORTED_VERSION_ID);
    }
    
    myValidator.validate(message, encoding.equals("XML"), version);
    
View Full Code Here

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

TOP

Related Classes of ca.uhn.hl7v2.HL7Exception

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.