Package ca.uhn.hl7v2

Examples of ca.uhn.hl7v2.HL7Exception


            Class<? extends Segment> c = factory.getSegmentClass("MSH", version);
            Constructor<? extends Segment> constructor = c.getConstructor(constructorParamTypes);
            msh = constructor.newInstance(constructorParamArgs);
        }
        catch (Exception e) {
            throw new HL7Exception(
                "Couldn't create MSH for version " + version + " (does your classpath include this version?) ... ",
                HL7Exception.APPLICATION_INTERNAL_ERROR,
                e);
        }
        return msh;
View Full Code Here


     */
    public static String getMessageStructureForEvent(String name, String version) throws HL7Exception {
        String structure = null;
       
        if (!validVersion(version))
            throw new HL7Exception("The version " + version + " is unknown");
       
        Properties p = null;
        try {
            p = (Properties) getMessageStructures().get(version);           
           
            if (p == null)
                throw new HL7Exception("No map found for version " + version + ". Only the following are available: " + getMessageStructures().keySet());
           
        } catch (IOException ioe) {
            throw new HL7Exception(ioe);
        }
       
        structure = p.getProperty(name);
       
        if (structure == null) {
View Full Code Here

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

                localToInterface.put(interfaceDirs[i].getName(), li);
            }

        }
        catch (IOException e) {
            throw new HL7Exception(
                "Can't read interface code maps from disk",
                HL7Exception.APPLICATION_INTERNAL_ERROR,
                e);
        }
    }
View Full Code Here

            HashMap interfaceMap = (HashMap) interfaceToLocal.get(interfaceName);
            localCode = getCode(interfaceMap, hl7Table, interfaceCode);
        }
        catch (NullPointerException npe) {
            if (this.throwIfNoMatch)
                throw new HL7Exception(
                    "No local mapping for the interface code "
                        + interfaceCode
                        + " for HL7 table "
                        + hl7Table
                        + " for the interface '"
View Full Code Here

            HashMap interfaceMap = (HashMap) localToInterface.get(interfaceName);
            interfaceCode = getCode(interfaceMap, hl7Table, localCode);
        }
        catch (NullPointerException npe) {
            if (this.throwIfNoMatch)
                throw new HL7Exception(
                    "No interface mapping for the local code "
                        + localCode
                        + " for HL7 table "
                        + hl7Table
                        + " for the interface '"
View Full Code Here

                if (comps.length < 3) {
                    buf.append(" HINT: there are only ");
                    buf.append(comps.length);
                    buf.append(" of 3 components present");
                }
                throw new HL7Exception(buf.toString(), HL7Exception.UNSUPPORTED_MESSAGE_TYPE);
            }
        } catch (IndexOutOfBoundsException e) {
            throw new HL7Exception("Can't find message structure (MSH-9-3): " + e.getMessage(), HL7Exception.UNSUPPORTED_MESSAGE_TYPE);
        }

        return new MessageStructure(messageStructure, explicityDefined);
    }
View Full Code Here

     * for this message.
     * @throws HL7Exception
     */
    private static EncodingCharacters getEncodingChars(String message) throws HL7Exception {
      if (message.length() < 8) {
          throw new HL7Exception("Invalid message content: \"" + message + "\"");
      }
        return new EncodingCharacters(message.charAt(3), message.substring(4, 8));
    }
View Full Code Here

        // get encoding characters ...
        Segment msh = (Segment) source.get("MSH");
        String fieldSepString = Terser.get(msh, 1, 0, 1, 1);

        if (fieldSepString == null)
            throw new HL7Exception("Can't encode message: MSH-1 (field separator) is missing");

        char fieldSep = '|';
        if (fieldSepString != null && fieldSepString.length() > 0)
            fieldSep = fieldSepString.charAt(0);

        String encCharString = Terser.get(msh, 2, 0, 1, 1);

        if (encCharString == null)
            throw new HL7Exception("Can't encode message: MSH-2 (encoding characters) is missing");

        if (encCharString.length() != 4)
            throw new HL7Exception("Encoding characters (MSH-2) value '" + encCharString + "' invalid -- must be 4 characters", HL7Exception.DATA_TYPE_ERROR);
        EncodingCharacters en = new EncodingCharacters(fieldSep, encCharString);

        // pass down to group encoding method which will operate recursively on
        // children ...
        return encode((Group) source, en, getParserConfiguration(), "");
View Full Code Here

     */
    public Segment getCriticalResponseData(String message) throws HL7Exception {
        // try to get MSH segment
        int locStartMSH = message.indexOf("MSH");
        if (locStartMSH < 0)
            throw new HL7Exception("Couldn't find MSH segment in message: " + message, HL7Exception.SEGMENT_SEQUENCE_ERROR);
        int locEndMSH = message.indexOf('\r', locStartMSH + 1);
        if (locEndMSH < 0)
            locEndMSH = message.length();
        String mshString = message.substring(locStartMSH, locEndMSH);

        // find out what the field separator is
        char fieldSep = mshString.charAt(3);

        // get field array
        String[] fields = split(mshString, String.valueOf(fieldSep));

        Segment msh = null;
        try {
            // parse required fields
            String encChars = fields[1];
            char compSep = encChars.charAt(0);
            String messControlID = fields[9];
            String[] procIDComps = split(fields[10], String.valueOf(compSep));

            // fill MSH segment
            String version = "2.4"; // default
            try {
                version = this.getVersion(message);
            } catch (Exception e) { /* use the default */
            }

            msh = Parser.makeControlMSH(version, getFactory());
            Terser.set(msh, 1, 0, 1, 1, String.valueOf(fieldSep));
            Terser.set(msh, 2, 0, 1, 1, encChars);
            Terser.set(msh, 10, 0, 1, 1, messControlID);
            Terser.set(msh, 11, 0, 1, 1, procIDComps[0]);
            Terser.set(msh, 12, 0, 1, 1, version);

        } catch (Exception e) {
            throw new HL7Exception("Can't parse critical fields from MSH segment (" + e.getClass().getName() + ": " + e.getMessage() + "): " + mshString, HL7Exception.REQUIRED_FIELD_MISSING, e);
        }

        return msh;
    }
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.