Package ca.uhn.hl7v2

Examples of ca.uhn.hl7v2.HL7Exception


     * @param usage the usage code
     * @param name the name of the repeating structure (used in exception msg)
     * @return null if cardinality OK, exception otherwise
     */
    protected HL7Exception testCardinality(int reps, int min, int max, String usage, String name) {
        HL7Exception e = null;
        if (reps < min && usage.equalsIgnoreCase("R")) {
            e = new ProfileNotFollowedException(name + " must have at least " + min + " repetitions (has " + reps + ")");
        } else if (max > 0 && reps > max) {
            e = new ProfileNotFollowedException(name + " must have no more than " + max + " repetitions (has " + reps + ")");
        }
View Full Code Here


                    ArrayList<Type> instancesWithContent = new ArrayList<Type>(10);
                    for (int j = 0; j < instances.length; j++) {
                        if (hasContent(instances[j])) instancesWithContent.add(instances[j]);
                    }
                   
                    HL7Exception ce = testCardinality(instancesWithContent.size(),
                    field.getMin(), field.getMax(), field.getUsage(), field.getName());
                    if (ce != null) {
                        ce.setFieldPosition(i);
                        exList.add(ce);
                    }
                   
                    //test field instances with content
                    if (validateChildren) {
View Full Code Here

            if (!allowedFields.contains(new Integer(i))) {
                try {
                    Type[] reps = segment.getField(i);
                    for (int j = 0; j < reps.length; j++) {
                        if (hasContent(reps[j])) {
                            HL7Exception e =  new XElementPresentException(
                                "Field " + i + " in " + segment.getName() + " appears in the message but not in the profile");
                            exList.add(e);
                        }
                    }
                } catch (HL7Exception he) {
View Full Code Here

     */
    public HL7Exception[] testType(Type type, AbstractComponent profile, String encoded, String profileID) {
        ArrayList<HL7Exception> exList = new ArrayList<HL7Exception>();
        if (encoded == null) encoded = PipeParser.encode(type, this.enc);

        HL7Exception ue = testUsage(encoded, profile.getUsage(), profile.getName());
        if (ue != null) exList.add(ue);

        if ( !profile.getUsage().equals("X") ) {
            //check datatype
            String typeName = type.getName();
View Full Code Here

    /**
     * Tests whether the given type falls within a maximum length. 
     * @return null of OK, an HL7Exception otherwise
     */
    public HL7Exception testLength(Type type, int maxLength) {
        HL7Exception e = null;
        String encoded = PipeParser.encode(type, this.enc);
        if (encoded.length() > maxLength) {
            e = new ProfileNotFollowedException("Length of " + encoded.length() + " exceeds maximum of " + maxLength);
        }
        return e;
View Full Code Here

     * @param usage the usage code (e.g. "CE")
     * @param name the name of the element (for use in exception messages)
     * @returns null if there is no problem, an HL7Exception otherwise
     */
    private HL7Exception testUsage(String encoded, String usage, String name) {
        HL7Exception e = null;
        if (usage.equalsIgnoreCase("R")) {
            if (encoded.length() == 0)
                e = new ProfileNotFollowedException("Required element " + name + " is missing");
        } else if (usage.equalsIgnoreCase("RE")) {
            //can't test anything
View Full Code Here

        return this.toArray(exList);
    }
   
    private void addTableTestResult(ArrayList<HL7Exception> exList, String profileID, String codeSystem, String value) {
        if (codeSystem != null && value != null) {
            HL7Exception e = testValueAgainstTable(profileID, codeSystem, value);
            if (e != null) exList.add(e);
        }       
    }
View Full Code Here

            if (e != null) exList.add(e);
        }       
    }
   
    private HL7Exception testValueAgainstTable(String profileID, String codeSystem, String value) {
        HL7Exception ret = null;
        CodeStore store = ProfileStoreFactory.getCodeStore(profileID, codeSystem);
        if (store == null) {
            log.warn("Not checking value {}: no code store was found for profile {} code system {}"
                , new Object[] {value, profileID, codeSystem});
        } else {
View Full Code Here

        if (Group.class.isAssignableFrom(struct.getClass())) {
            return hasContent( (Group) struct );
        } else if (Segment.class.isAssignableFrom(struct.getClass())) {
            return hasContent( (Segment) struct );
        } else {
            throw new HL7Exception("Structure " + struct.getClass().getName() + " not recognized", HL7Exception.APPLICATION_INTERNAL_ERROR);
        }
    }
View Full Code Here

            doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
            Element root = doc.createElement(messageName);
            doc.appendChild(root);
        }
        catch (Exception e) {
            throw new HL7Exception(
                "Can't create XML document - " + e.getClass().getName(),
                HL7Exception.APPLICATION_INTERNAL_ERROR,
                e);
        }
        encode(source, doc.getDocumentElement());
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.