From 03cde8c53f156e189edf377076a03708f0f3cc90 Mon Sep 17 00:00:00 2001 From: James Agnew Date: Tue, 18 Aug 2020 13:56:37 -0400 Subject: [PATCH] Don't use remote termsvc on implied system validation (#2045) * Don't use remote termsvc on implied system validation * Add changelog --- ...lidate-implied-system-on-remote-termsvc.yaml | 6 ++++++ ...moteTerminologyServiceValidationSupport.java | 7 +++++++ ...TerminologyServiceValidationSupportTest.java | 17 ++++++++++++++++- 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/5_2_0/2045-dont-validate-implied-system-on-remote-termsvc.yaml diff --git a/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/5_2_0/2045-dont-validate-implied-system-on-remote-termsvc.yaml b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/5_2_0/2045-dont-validate-implied-system-on-remote-termsvc.yaml new file mode 100644 index 00000000000..cdeab560a5f --- /dev/null +++ b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/5_2_0/2045-dont-validate-implied-system-on-remote-termsvc.yaml @@ -0,0 +1,6 @@ +--- +type: add +issue: 2045 +title: "The `RemoteTerminologyServiceValidationSupport` class used for connecting to a remote terminology service + will no longer attempt to perform code validation for fields where the code system is implied, since there is no + FHIR operation allowing this style of validation to be performed remotely." diff --git a/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/support/RemoteTerminologyServiceValidationSupport.java b/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/support/RemoteTerminologyServiceValidationSupport.java index 5d62a28d619..e8baca627d9 100644 --- a/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/support/RemoteTerminologyServiceValidationSupport.java +++ b/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/support/RemoteTerminologyServiceValidationSupport.java @@ -48,6 +48,13 @@ public class RemoteTerminologyServiceValidationSupport extends BaseValidationSup @Override public CodeValidationResult validateCodeInValueSet(ValidationSupportContext theValidationSupportContext, ConceptValidationOptions theOptions, String theCodeSystem, String theCode, String theDisplay, @Nonnull IBaseResource theValueSet) { + + if (theOptions != null) { + if (theOptions.isInferSystem()) { + return null; + } + } + IBaseResource valueSet = theValueSet; String valueSetUrl = DefaultProfileValidationSupport.getConformanceResourceUrl(myCtx, valueSet); if (isNotBlank(valueSetUrl)) { diff --git a/hapi-fhir-validation/src/test/java/org/hl7/fhir/common/hapi/validation/support/RemoteTerminologyServiceValidationSupportTest.java b/hapi-fhir-validation/src/test/java/org/hl7/fhir/common/hapi/validation/support/RemoteTerminologyServiceValidationSupportTest.java index 7ef27d1716a..074e343ad42 100644 --- a/hapi-fhir-validation/src/test/java/org/hl7/fhir/common/hapi/validation/support/RemoteTerminologyServiceValidationSupportTest.java +++ b/hapi-fhir-validation/src/test/java/org/hl7/fhir/common/hapi/validation/support/RemoteTerminologyServiceValidationSupportTest.java @@ -1,6 +1,7 @@ package org.hl7.fhir.common.hapi.validation.support; import ca.uhn.fhir.context.FhirContext; +import ca.uhn.fhir.context.support.ConceptValidationOptions; import ca.uhn.fhir.context.support.IValidationSupport; import ca.uhn.fhir.rest.annotation.IdParam; import ca.uhn.fhir.rest.annotation.Operation; @@ -132,7 +133,7 @@ public class RemoteTerminologyServiceValidationSupportTest { ValueSet valueSet = new ValueSet(); valueSet.setUrl(VALUE_SET_URL); - IValidationSupport.CodeValidationResult outcome = mySvc.validateCodeInValueSet(null, null, CODE_SYSTEM, CODE, DISPLAY, valueSet); + IValidationSupport.CodeValidationResult outcome = mySvc.validateCodeInValueSet(null, new ConceptValidationOptions(), CODE_SYSTEM, CODE, DISPLAY, valueSet); assertEquals(CODE, outcome.getCode()); assertEquals(DISPLAY, outcome.getDisplay()); assertEquals(null, outcome.getSeverity()); @@ -145,6 +146,20 @@ public class RemoteTerminologyServiceValidationSupportTest { assertEquals(null, myValueSetProvider.myLastValueSet); } + /** + * Remote terminology services shouldn't be used to validatre codes with an implied system + */ + @Test + public void testValidateCodeInValueSet_InferSystem() { + createNextValueSetReturnParameters(true, DISPLAY, null); + + ValueSet valueSet = new ValueSet(); + valueSet.setUrl(VALUE_SET_URL); + + IValidationSupport.CodeValidationResult outcome = mySvc.validateCodeInValueSet(null, new ConceptValidationOptions().setInferSystem(true), null, CODE, DISPLAY, valueSet); + assertEquals(null, outcome); + } + @Test public void testIsValueSetSupported_False() { myValueSetProvider.myNextReturnValueSets = new ArrayList<>();