diff --git a/hapi-fhir-validation/src/main/java/org/hl7/fhir/dstu3/hapi/validation/ValidationSupportChain.java b/hapi-fhir-validation/src/main/java/org/hl7/fhir/dstu3/hapi/validation/ValidationSupportChain.java index 1d7fb84585b7..c3480afd6b8b 100644 --- a/hapi-fhir-validation/src/main/java/org/hl7/fhir/dstu3/hapi/validation/ValidationSupportChain.java +++ b/hapi-fhir-validation/src/main/java/org/hl7/fhir/dstu3/hapi/validation/ValidationSupportChain.java @@ -94,9 +94,11 @@ public List fetchAllStructureDefinitions(FhirContext theCon @Override public CodeSystem fetchCodeSystem(FhirContext theCtx, String theSystem) { for (IValidationSupport next : myChain) { - CodeSystem retVal = next.fetchCodeSystem(theCtx, theSystem); - if (retVal != null) { - return retVal; + if (next.isCodeSystemSupported(theCtx, theSystem)) { + CodeSystem retVal = next.fetchCodeSystem(theCtx, theSystem); + if (retVal != null) { + return retVal; + } } } return null; diff --git a/hapi-fhir-validation/src/main/java/org/hl7/fhir/r4/hapi/validation/ValidationSupportChain.java b/hapi-fhir-validation/src/main/java/org/hl7/fhir/r4/hapi/validation/ValidationSupportChain.java index be28686504c6..549d26f5dfb9 100644 --- a/hapi-fhir-validation/src/main/java/org/hl7/fhir/r4/hapi/validation/ValidationSupportChain.java +++ b/hapi-fhir-validation/src/main/java/org/hl7/fhir/r4/hapi/validation/ValidationSupportChain.java @@ -71,11 +71,13 @@ public List fetchAllConformanceResources(FhirContext theContext) } @Override - public CodeSystem fetchCodeSystem(FhirContext theCtx, String uri) { + public CodeSystem fetchCodeSystem(FhirContext theCtx, String theSystem) { for (IValidationSupport next : myChain) { - CodeSystem retVal = next.fetchCodeSystem(theCtx, uri); - if (retVal != null) { - return retVal; + if (next.isCodeSystemSupported(theCtx, theSystem)) { + CodeSystem retVal = next.fetchCodeSystem(theCtx, theSystem); + if (retVal != null) { + return retVal; + } } } return null; diff --git a/src/changes/changes.xml b/src/changes/changes.xml index c3f29c86295c..06d3ba70d7bf 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -198,6 +198,11 @@ Fixed "because at least one resource has a reference to this resource" delete error message that mistakingly reported the target instead of the source with the reference. + + ValidationSupportChain will now call isCodeSystemSupported() on each entry in the chain before + calling fetchCodeSystem() in order to reduce the work required by chain entries. Thanks to + Anders Havn for the suggestion! +