Package ca.uhn.hl7v2

Examples of ca.uhn.hl7v2.HL7Exception


    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


     *             existing number of repetitions.
     */
    public Structure get(String name, int rep) throws HL7Exception {
        List<Structure> list = structures.get(name);
        if (list == null)
            throw new HL7Exception(name + " does not exist in the group " + this.getClass().getName(), HL7Exception.APPLICATION_INTERNAL_ERROR);

        Structure ret;
        if (rep < list.size()) {
            // return existing Structure if it exists
            ret = list.get(rep);
        } else if (rep == list.size()) {
            // verify that Structure is repeating ...
            Boolean repeats = this.repeating.get(name);
            if (!repeats.booleanValue() && list.size() > 0)
                throw new HL7Exception("Can't create repetition #" + rep + " of Structure " + name + " - this Structure is non-repeating", HL7Exception.APPLICATION_INTERNAL_ERROR);

            // create a new Structure, add it to the list, and return it
            Class<? extends Structure> c = classes.get(name); // get class
            ret = tryToInstantiateStructure(c, name);
            list.add(ret);
        } else {
            throw new HL7Exception("Can't return repetition #" + rep + " of " + name + " - there are only " + list.size() + " repetitions.",
                    HL7Exception.APPLICATION_INTERNAL_ERROR);
        }
        return ret;
    }
View Full Code Here

     * defined as repeating and not required.
     */
    public String addNonstandardSegment(String name) throws HL7Exception {
        String version = this.getMessage().getVersion();
        if (version == null)
            throw new HL7Exception("Need message version to add segment by name; message.getVersion() returns null");
        Class<? extends Structure> c = myFactory.getSegmentClass(name, version);
        if (c == null)
            c = GenericSegment.class;

        int index = this.getNames().length;
View Full Code Here

        return newName;
    }

    public String addNonstandardSegment(String theName, int theIndex) throws HL7Exception {
        if (this instanceof Message && theIndex == 0) {
            throw new HL7Exception("Can not add nonstandard segment \"" + theName + "\" to start of message.");
        }

        String version = this.getMessage().getVersion();
        if (version == null)
            throw new HL7Exception("Need message version to add segment by name; message.getVersion() returns null");
        Class<? extends Structure> c = myFactory.getSegmentClass(theName, version);
       
        if (c == null) {
            c = GenericSegment.class;
        }
View Full Code Here

                    o = con.newInstance(argObjects);
                } catch (NoSuchMethodException nme) {
                    o = c.newInstance();
                }
                if (!(o instanceof Structure))
                    throw new HL7Exception("Class " + c.getName() + " does not implement " + "ca.on.uhn.hl7.message.Structure", HL7Exception.APPLICATION_INTERNAL_ERROR);
                s = (Structure) o;
            }
        } catch (Exception e) {
            if (e instanceof HL7Exception) {
                throw (HL7Exception) e;
            } else {
                throw new HL7Exception("Can't instantiate class " + c.getName(), HL7Exception.APPLICATION_INTERNAL_ERROR, e);
            }
        }
        return s;
    }
View Full Code Here

     * Returns true if the named structure is a group
     */
    public boolean isGroup(String name) throws HL7Exception {
        Class<? extends Structure> clazz = classes.get(name);
        if (clazz == null)
            throw new HL7Exception("The structure " + name + " does not exist in the group " + this.getClass().getName(), HL7Exception.APPLICATION_INTERNAL_ERROR);
        return Group.class.isAssignableFrom(clazz);
    }
View Full Code Here

     * Returns true if the named structure is required.
     */
    public boolean isRequired(String name) throws HL7Exception {
        Object o = required.get(name);
        if (o == null)
            throw new HL7Exception("The structure " + name + " does not exist in the group " + this.getClass().getName(), HL7Exception.APPLICATION_INTERNAL_ERROR);
        Boolean req = (Boolean) o;
        return req.booleanValue();
    }
View Full Code Here

     * Returns true if the named structure is required.
     */
    public boolean isRepeating(String name) throws HL7Exception {
        Object o = repeating.get(name);
        if (o == null)
            throw new HL7Exception("The structure " + name + " does not exist in the group " + this.getClass().getName(), HL7Exception.APPLICATION_INTERNAL_ERROR);
        Boolean rep = (Boolean) o;
        return rep.booleanValue();
    }
View Full Code Here

     * Returns the number of existing repetitions of the named structure.
     */
    public int currentReps(String name) throws HL7Exception {
        ArrayList<Structure> list = structures.get(name);
        if (list == null)
            throw new HL7Exception("The structure " + name + " does not exist in the group " + this.getClass().getName(), HL7Exception.APPLICATION_INTERNAL_ERROR);
        return list.size();
    }
View Full Code Here

     *             if the named Structure is not part of this Group.
     */
    public Structure[] getAll(String name) throws HL7Exception {
        ArrayList<Structure> list = structures.get(name);
        if (list == null)
            throw new HL7Exception("The structure " + name + " does not exist in the group " + this.getClass().getName(), HL7Exception.APPLICATION_INTERNAL_ERROR);
        Structure[] all = new Structure[list.size()];
        for (int i = 0; i < list.size(); i++) {
            all[i] = list.get(i);
        }
        return all;
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.