Пример #1
0
 private ValueSetExpansionContainsComponent findCode(
     List<ValueSetExpansionContainsComponent> contains, String code) {
   for (ValueSetExpansionContainsComponent cc : contains) {
     if (code.equals(cc.getCode())) return cc;
     ValueSetExpansionContainsComponent c = findCode(cc.getContains(), code);
     if (c != null) return c;
   }
   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;
  }