Package ca.uhn.hl7v2

Examples of ca.uhn.hl7v2.Version


    @Override
    public Object evaluate(Exchange exchange) {
        Throwable t = exchange.getProperty(Exchange.EXCEPTION_CAUGHT, Throwable.class);
        Message msg = exchange.getIn().getBody(Message.class);
        try {
            HL7Exception hl7e = generateHL7Exception(t);
            AckCode code = acknowledgementCode;
            if (t != null && code == null) {
                code = AckCode.AE;
            }
            return msg.generateACK(code == null ? AcknowledgmentCode.AA : code.toAcknowledgmentCode(), hl7e);
View Full Code Here


            throw ObjectHelper.wrapRuntimeCamelException(e);
        }
    }

    private HL7Exception generateHL7Exception(Throwable t) {
        HL7Exception hl7Exception = null;
        if (t == null) {
            if (acknowledgementCode != null && acknowledgementCode.isError()) {
                hl7Exception = new HL7Exception(errorMessage, errorCode);
            }
        } else {
            if (t instanceof HL7Exception) {
                hl7Exception = (HL7Exception)t;
            } else {
                hl7Exception = new HL7Exception(errorMessage != null ? errorMessage : t.getMessage(),
                                                errorCode, t);
            }
        }
        return hl7Exception;
    }
View Full Code Here

        try {
            Message message = ediParser.parse(rowHL7);
            ConformanceProfileRule rule = new ConformanceProfileRule();
        ValidationException[] exs = rule.test(message);
        if (exs != null && exs.length > 0) {
          throw new HL7Exception(exs[0].getMessage());
       
            if(log.isDebugEnabled()){
                log.debug("HL7 parsing completed." + message);
            }
            xmlDoc = xmlParser.encode(message);
View Full Code Here

        try {
            // This method takes in the MSH segment of an incoming message, and generates an
            // appropriate ACK
            retVal = DefaultApplication.makeACK(msh);
        } catch (IOException e) {
            throw new HL7Exception(e);
        }

        return retVal;
    }
View Full Code Here

        version = getVersion(message);
      } catch (Exception e) { /* use the default */
      }

      if (version == null) {
        Version availableVersion = Version.highestAvailableVersionOrDefault();
        version = availableVersion.getVersion();
      }

      Segment msh = Parser.makeControlMSH(version, getFactory());
      Terser.set(msh, 1, 0, 1, 1, String.valueOf(fieldSep));
      Terser.set(msh, 2, 0, 1, 1, encChars);
View Full Code Here

     * is parsed. 
     */
  @SuppressWarnings("unchecked")
  public static Class<? extends Message> getGenericMessageClass(String version) {
   
    Version v = Version.versionOf(version);
        if (v != null) {      
          try {
            String className = GenericMessage.class.getName() + "$" + v.name();
            return (Class<? extends Message>)Class.forName(className);
          } catch (ClassNotFoundException e) {
            // should not happen as long Version corresponds with the static
            // subclasses of GenericMessage
          }
View Full Code Here

    String schemaFilename = null;
    log.debug("Lookup HL7 version in MSH-12 to know which default schema to use");
    NodeList nodeList = doc.getElementsByTagNameNS(DEFAULT_NS, "VID.1");
    if (nodeList.getLength() == 1) {
      Node versionNode = nodeList.item(0);
      Version version = Version.versionOf(versionNode.getFirstChild().getNodeValue());
      String schemaLocation = locations.get(version.getVersion());

      // use the message structure as schema file name (root)
      schemaFilename = schemaLocation + "/" + doc.getDocumentElement().getNodeName() + ".xsd";
      File myFile = new File(schemaFilename);
      if (myFile.exists()) {
View Full Code Here

        version = getVersion(message);
      } catch (Exception e) { /* use the default */
      }

      if (version == null) {
        Version availableVersion = Version.highestAvailableVersionOrDefault();
        version = availableVersion.getVersion();
      }

      Segment msh = Parser.makeControlMSH(version, getFactory());
      Terser.set(msh, 1, 0, 1, 1, String.valueOf(fieldSep));
      Terser.set(msh, 2, 0, 1, 1, encChars);
View Full Code Here

    String schemaFilename = null;
    log.debug("Lookup HL7 version in MSH-12 to know which default schema to use");
    NodeList nodeList = doc.getElementsByTagNameNS(DEFAULT_NS, "VID.1");
    if (nodeList.getLength() == 1) {
      Node versionNode = nodeList.item(0);
      Version version = Version.versionOf(versionNode.getFirstChild().getNodeValue());
      String schemaLocation = locations.get(version.getVersion());

      // use the message structure as schema file name (root)
      schemaFilename = schemaLocation + "/" + doc.getDocumentElement().getNodeName() + ".xsd";
      File myFile = new File(schemaFilename);
      if (myFile.exists()) {
View Full Code Here

  private Message instantiateACK(AcknowledgmentCode theAcknowledgementCode) throws HL7Exception {
    ModelClassFactory mcf = getParser() != null ?
        getParser().getFactory() :
        new DefaultModelClassFactory();
    Version version = Version.versionOf(getVersion());
    Message out = null;
    if (version != null && version.available()) {
      Class<? extends Message> clazz = mcf.getMessageClass("ACK", version.getVersion(), false);
      if (clazz != null) {
          out = ReflectionUtil.instantiateMessage(clazz, mcf);
      }
    }
    if (out == null) {
View Full Code Here

TOP

Related Classes of ca.uhn.hl7v2.Version

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.