Package ca.uhn.hl7v2.validation

Examples of ca.uhn.hl7v2.validation.ValidationException


  }

  protected ValidationException[] failed(Exception e, Location location) {
    if (e instanceof ValidationException)
      return new ValidationException[] { (ValidationException) e };
    ValidationException ve = new ValidationException(e.getMessage(), e, severity);
    ve.setError(getErrorCode());
    ve.setLocation(location);
    return new ValidationException[] { ve };
  }
View Full Code Here


                try {
                    ValidationException[] shortList = testAgainstProfile(msg, id);
                    log.debug("{} non-conformances", shortList.length);
                    problems.addAll(Arrays.asList(shortList));
                } catch (ProfileException e) {
                    problems.add(new ValidationException("Can't validate against profile: " + e.getMessage(), e));
                }
            }           
        } catch (HL7Exception e) {
            problems.add(new ValidationException("Can't validate against profile: " + e.getMessage(), e));
        }
       
        return problems.toArray(new ValidationException[problems.size()]);
    }
View Full Code Here

  public static final MessageRule WRONG_VERSION = new WrongVersionRule();
 
  public ValidationException[] apply(Message msg) {
    List<ValidationException> exceptions = new ArrayList<ValidationException>();

    ValidationException ve = new ValidationException("Invalid version: " + msg.getVersion());
    Location location = new Location()
        .withSegmentName("MSH")
        .withField(12);
    ve.setLocation(location);
    ve.setError(ErrorCode.UNSUPPORTED_VERSION_ID);
    exceptions.add(ve);

    return exceptions.toArray(new ValidationException[exceptions.size()]);
  }
View Full Code Here

         
          if (!rep.isEmpty()) {
            Set<String> structuresWhichChildAppliesTo = theMsg.getStructuresWhichChildAppliesTo(name);
            if (!structuresWhichChildAppliesTo.contains(messageStructure)) {
              String msgSimpleName = theMsg.getMessage().getClass().getSimpleName();
              theExceptions.add(new ValidationException("Message (superstructure " + msgSimpleName + ") of type " + messageStructure + " must not have content in " + name));
            }
            continue FORNAME;
          }
         
        }
View Full Code Here

    List<ValidationException> exceptions = new ArrayList<ValidationException>();

    for (Iterator<Structure> iter = ReadOnlyMessageIterator
        .createPopulatedStructureIterator(msg, GenericSegment.class); iter.hasNext();) {
      String segmentName = iter.next().getName();
      ValidationException ve = new ValidationException("Found unknown segment: " + segmentName);
      Location location = new Location().withSegmentName(segmentName);
      ve.setLocation(location);
      exceptions.add(ve);
    }
    return exceptions.toArray(new ValidationException[exceptions.size()]);
  }
View Full Code Here

        Parser ediParser = new PipeParser();
        ediParser.setValidationContext(new NoValidation());
        String xmlDoc = null;
        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);
View Full Code Here

    private ValidationContext defaultContext;
    private ValidationContextImpl customContext;

    @Override
    protected void doPreSetup() throws Exception {
        defaultContext = new DefaultValidation();
        customContext = new DefaultValidation();
        @SuppressWarnings("serial")
        MessageRule rule = new MessageRule() {

            @Override
            public String getDescription() {
View Full Code Here

            public ValidationException[] apply(Message msg) {
                return test(msg);
            }

        };
        MessageRuleBinding binding = new MessageRuleBinding("2.4", "ADT", "A01", rule);
        customContext.getMessageRuleBindings().add(binding);
    }
View Full Code Here

        // Helper class
    }

    private static Parser getParser() {
        PipeParser pipeParser = new PipeParser();
        pipeParser.setValidationContext(new NoValidation());
        return pipeParser;
    }
View Full Code Here

     * @return XML String
     */
    private String serializeHL7toXML(String rowHL7) {
        Parser xmlParser = new DefaultXMLParser();
        Parser ediParser = new PipeParser();
        ediParser.setValidationContext(new NoValidation());
        String xmlDoc = null;
        try {
            Message message = ediParser.parse(rowHL7);
            ConformanceProfileRule rule = new ConformanceProfileRule();
        ValidationException[] exs = rule.test(message);
View Full Code Here

TOP

Related Classes of ca.uhn.hl7v2.validation.ValidationException

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.