示例#1
0
 private ValidationResult verifyCodeInExpansion(
     ValueSet vs, String system, String code, String display) {
   ValueSetExpansionContainsComponent cc = findCode(vs.getExpansion().getContains(), code);
   if (cc == null)
     return new ValidationResult(
         IssueSeverity.ERROR, "Unknown Code " + code + " in " + vs.getUrl());
   if (display == null)
     return new ValidationResult(
         new ConceptDefinitionComponent().setCode(code).setDisplay(cc.getDisplay()));
   if (cc.hasDisplay()) {
     if (display.equalsIgnoreCase(cc.getDisplay()))
       return new ValidationResult(
           new ConceptDefinitionComponent().setCode(code).setDisplay(cc.getDisplay()));
     return new ValidationResult(
         IssueSeverity.WARNING,
         "Display Name for " + code + " must be '" + cc.getDisplay() + "'",
         new ConceptDefinitionComponent().setCode(code).setDisplay(cc.getDisplay()));
   }
   return null;
 }
  private ca.uhn.fhir.jpa.dao.IFhirResourceDaoValueSet.ValidateCodeResult validateCodeIsInContains(
      List<ValueSetExpansionContainsComponent> contains,
      String theSystem,
      String theCode,
      Coding theCoding,
      CodeableConcept theCodeableConcept) {
    for (ValueSetExpansionContainsComponent nextCode : contains) {
      ca.uhn.fhir.jpa.dao.IFhirResourceDaoValueSet.ValidateCodeResult result =
          validateCodeIsInContains(
              nextCode.getContains(), theSystem, theCode, theCoding, theCodeableConcept);
      if (result != null) {
        return result;
      }

      String system = nextCode.getSystem();
      String code = nextCode.getCode();

      if (isNotBlank(theCode)) {
        if (theCode.equals(code) && (isBlank(theSystem) || theSystem.equals(system))) {
          return new ValidateCodeResult(true, "Validation succeeded", nextCode.getDisplay());
        }
      } else if (theCoding != null) {
        if (StringUtils.equals(system, theCoding.getSystem())
            && StringUtils.equals(code, theCoding.getCode())) {
          return new ValidateCodeResult(true, "Validation succeeded", nextCode.getDisplay());
        }
      } else {
        for (Coding next : theCodeableConcept.getCoding()) {
          if (StringUtils.equals(system, next.getSystem())
              && StringUtils.equals(code, next.getCode())) {
            return new ValidateCodeResult(true, "Validation succeeded", nextCode.getDisplay());
          }
        }
      }
    }

    return null;
  }