",
diff --git a/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/parser/JsonParserR4Test.java b/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/parser/JsonParserR4Test.java
index 25100484649..b80251d2910 100644
--- a/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/parser/JsonParserR4Test.java
+++ b/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/parser/JsonParserR4Test.java
@@ -7,6 +7,7 @@ import ca.uhn.fhir.i18n.Msg;
import ca.uhn.fhir.model.api.annotation.DatatypeDef;
import ca.uhn.fhir.rest.api.Constants;
import ca.uhn.fhir.test.BaseTest;
+import ca.uhn.fhir.util.BundleBuilder;
import ca.uhn.fhir.util.StopWatch;
import ca.uhn.fhir.util.TestUtil;
import com.google.common.collect.Sets;
@@ -23,10 +24,12 @@ import org.hl7.fhir.r4.model.Composition;
import org.hl7.fhir.r4.model.DateTimeType;
import org.hl7.fhir.r4.model.DecimalType;
import org.hl7.fhir.r4.model.Device;
+import org.hl7.fhir.r4.model.DiagnosticReport;
import org.hl7.fhir.r4.model.DocumentReference;
import org.hl7.fhir.r4.model.Encounter;
import org.hl7.fhir.r4.model.Extension;
import org.hl7.fhir.r4.model.HumanName;
+import org.hl7.fhir.r4.model.IdType;
import org.hl7.fhir.r4.model.Identifier;
import org.hl7.fhir.r4.model.Medication;
import org.hl7.fhir.r4.model.MedicationDispense;
@@ -43,6 +46,7 @@ import org.hl7.fhir.r4.model.PrimitiveType;
import org.hl7.fhir.r4.model.Quantity;
import org.hl7.fhir.r4.model.QuestionnaireResponse;
import org.hl7.fhir.r4.model.Reference;
+import org.hl7.fhir.r4.model.Specimen;
import org.hl7.fhir.r4.model.StringType;
import org.hl7.fhir.r4.model.Type;
import org.hl7.fhir.r4.model.codesystems.DataAbsentReason;
@@ -55,7 +59,10 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import jakarta.annotation.Nonnull;
+import org.testcontainers.shaded.com.trilead.ssh2.packets.PacketDisconnect;
+
import java.io.IOException;
+import java.sql.Ref;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
@@ -261,6 +268,36 @@ public class JsonParserR4Test extends BaseTest {
idx = encoded.indexOf("\"Medication\"", idx + 1);
assertEquals(-1, idx);
+ }
+
+ @Test
+ public void testDuplicateContainedResourcesAcrossABundleAreReplicated() {
+ Bundle b = new Bundle();
+ Specimen specimen = new Specimen();
+ Practitioner practitioner = new Practitioner();
+ DiagnosticReport report = new DiagnosticReport();
+ report.addSpecimen(new Reference(specimen));
+ b.addEntry().setResource(report).getRequest().setMethod(Bundle.HTTPVerb.POST).setUrl("/DiagnosticReport");
+
+ Observation obs = new Observation();
+ obs.addPerformer(new Reference(practitioner));
+ obs.setSpecimen(new Reference(specimen));
+
+ b.addEntry().setResource(obs).getRequest().setMethod(Bundle.HTTPVerb.POST).setUrl("/Observation");
+
+ String encoded = ourCtx.newJsonParser().setPrettyPrint(false).encodeResourceToString(b);
+ //Then: Diag should contain one local contained specimen
+ assertThat(encoded).contains("[{\"resource\":{\"resourceType\":\"DiagnosticReport\",\"contained\":[{\"resourceType\":\"Specimen\",\"id\":\""+ specimen.getId().replaceFirst("#", "") +"\"}]");
+ //Then: Obs should contain one local contained specimen, and one local contained pract
+ assertThat(encoded).contains("\"resource\":{\"resourceType\":\"Observation\",\"contained\":[{\"resourceType\":\"Specimen\",\"id\":\""+ specimen.getId().replaceFirst("#", "") +"\"},{\"resourceType\":\"Practitioner\",\"id\":\"" + practitioner.getId().replaceAll("#","") + "\"}]");
+ assertThat(encoded).contains("\"performer\":[{\"reference\":\""+practitioner.getId()+"\"}],\"specimen\":{\"reference\":\""+specimen.getId()+"\"}");
+
+ //Also, reverting the operation should work too!
+ Bundle bundle = ourCtx.newJsonParser().parseResource(Bundle.class, encoded);
+ IBaseResource resource1 = ((DiagnosticReport) bundle.getEntry().get(0).getResource()).getSpecimenFirstRep().getResource();
+ IBaseResource resource = ((Observation) bundle.getEntry().get(1).getResource()).getSpecimen().getResource();
+ assertThat(resource1.getIdElement().getIdPart()).isEqualTo(resource.getIdElement().getIdPart());
+ assertThat(resource1).isNotSameAs(resource);
}
@@ -279,8 +316,9 @@ public class JsonParserR4Test extends BaseTest {
ourCtx.getParserOptions().setAutoContainReferenceTargetsWithNoId(true);
encoded = ourCtx.newJsonParser().setPrettyPrint(false).encodeResourceToString(md);
- assertEquals("{\"resourceType\":\"MedicationDispense\",\"contained\":[{\"resourceType\":\"Medication\",\"id\":\"1\",\"code\":{\"text\":\"MED\"}}],\"identifier\":[{\"value\":\"DISPENSE\"}],\"medicationReference\":{\"reference\":\"#1\"}}", encoded);
-
+ String guidWithHash = med.getId();
+ String withoutHash = guidWithHash.replace("#", "");
+ assertThat(encoded).contains("{\"resourceType\":\"MedicationDispense\",\"contained\":[{\"resourceType\":\"Medication\",\"id\":\"" + withoutHash + "\",\"code\":{\"text\":\"MED\"}}],\"identifier\":[{\"value\":\"DISPENSE\"}],\"medicationReference\":{\"reference\":\"" + guidWithHash +"\"}}"); //Note we dont check exact ID since its a GUID
}
@Test
@@ -571,7 +609,7 @@ public class JsonParserR4Test extends BaseTest {
obs = ourCtx.newJsonParser().parseResource(Observation.class, encoded);
assertEquals("#1", obs.getContained().get(0).getId());
- assertEquals("#2", obs.getContained().get(1).getId());
+ assertEquals(enc.getId(), obs.getContained().get(1).getId());
pt = (Patient) obs.getSubject().getResource();
assertEquals("FAM", pt.getNameFirstRep().getFamily());
@@ -600,7 +638,7 @@ public class JsonParserR4Test extends BaseTest {
obs = ourCtx.newJsonParser().parseResource(Observation.class, encoded);
assertEquals("#1", obs.getContained().get(0).getId());
- assertEquals("#2", obs.getContained().get(1).getId());
+ assertEquals(pt.getId(), obs.getContained().get(1).getId());
pt = (Patient) obs.getSubject().getResource();
assertEquals("FAM", pt.getNameFirstRep().getFamily());
@@ -620,13 +658,14 @@ public class JsonParserR4Test extends BaseTest {
ourLog.info(encoded);
mr = ourCtx.newJsonParser().parseResource(MedicationRequest.class, encoded);
- mr.setMedication(new Reference(new Medication().setStatus(Medication.MedicationStatus.ACTIVE)));
+ Medication med = new Medication().setStatus(Medication.MedicationStatus.ACTIVE);
+ mr.setMedication(new Reference(med));
encoded = ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(mr);
ourLog.info(encoded);
mr = ourCtx.newJsonParser().parseResource(MedicationRequest.class, encoded);
- assertEquals("#1", mr.getContained().get(0).getId());
- assertEquals("#2", mr.getContained().get(1).getId());
+ assertEquals(pract.getId(), mr.getContained().get(0).getId());
+ assertEquals(med.getId(), mr.getContained().get(1).getId());
}
diff --git a/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/util/FhirTerserR4Test.java b/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/util/FhirTerserR4Test.java
index 87a33805db6..0f2e122fd6f 100644
--- a/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/util/FhirTerserR4Test.java
+++ b/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/util/FhirTerserR4Test.java
@@ -6,7 +6,10 @@ import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.i18n.Msg;
import ca.uhn.fhir.model.api.annotation.Block;
import ca.uhn.fhir.parser.DataFormatException;
+import ca.uhn.fhir.parser.IParser;
+import ca.uhn.fhir.parser.JsonParser;
import com.google.common.collect.Lists;
+import org.apache.jena.base.Sys;
import org.hl7.fhir.instance.model.api.IBase;
import org.hl7.fhir.instance.model.api.IBaseExtension;
import org.hl7.fhir.instance.model.api.IBaseReference;
@@ -47,6 +50,8 @@ import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.testcontainers.shaded.com.fasterxml.jackson.core.JsonProcessingException;
+import org.testcontainers.shaded.com.fasterxml.jackson.databind.ObjectMapper;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
@@ -62,6 +67,7 @@ import java.util.concurrent.Future;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors;
+import static ca.uhn.fhir.test.utilities.UuidUtils.HASH_UUID_PATTERN;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
@@ -188,12 +194,12 @@ public class FhirTerserR4Test {
FhirTerser.ContainedResources contained = myCtx.newTerser().containResources(mr, FhirTerser.OptionsEnum.MODIFY_RESOURCE, FhirTerser.OptionsEnum.STORE_AND_REUSE_RESULTS);
- assertEquals("#1", mr.getContained().get(0).getId());
- assertEquals("#2", mr.getContained().get(1).getId());
+ assertThat(mr.getContained().get(0).getId()).containsPattern(HASH_UUID_PATTERN);
+ assertThat(mr.getContained().get(1).getId()).containsPattern(HASH_UUID_PATTERN);
assertEquals(ResourceType.Medication, mr.getContained().get(0).getResourceType());
assertEquals(ResourceType.Practitioner, mr.getContained().get(1).getResourceType());
- assertEquals("#1", mr.getMedicationReference().getReference());
- assertEquals("#2", mr.getRequester().getReference());
+ assertEquals(mr.getContained().get(0).getId(), mr.getMedicationReference().getReference());
+ assertEquals(mr.getContained().get(1).getId(), mr.getRequester().getReference());
FhirTerser.ContainedResources secondPass = myCtx.newTerser().containResources(mr, FhirTerser.OptionsEnum.MODIFY_RESOURCE, FhirTerser.OptionsEnum.STORE_AND_REUSE_RESULTS);
assertThat(secondPass).isSameAs(contained);
@@ -212,12 +218,12 @@ public class FhirTerserR4Test {
myCtx.newTerser().containResources(medAdmin, FhirTerser.OptionsEnum.MODIFY_RESOURCE, FhirTerser.OptionsEnum.STORE_AND_REUSE_RESULTS);
- assertEquals("#1", medAdmin.getContained().get(0).getId());
- assertEquals("#2", medAdmin.getContained().get(1).getId());
+ assertThat(medAdmin.getContained().get(0).getId()).containsPattern(HASH_UUID_PATTERN);
+ assertThat(medAdmin.getContained().get(1).getId()).containsPattern(HASH_UUID_PATTERN);
assertEquals(ResourceType.Medication, medAdmin.getContained().get(0).getResourceType());
assertEquals(ResourceType.Substance, medAdmin.getContained().get(1).getResourceType());
- assertEquals("#1", medAdmin.getMedicationReference().getReference());
- assertEquals("#2", ((Medication) (medAdmin.getContained().get(0))).getIngredientFirstRep().getItemReference().getReference());
+ assertEquals(medAdmin.getContained().get(0).getId(), medAdmin.getMedicationReference().getReference());
+ assertEquals(medAdmin.getContained().get(1).getId(), ((Medication) (medAdmin.getContained().get(0))).getIngredientFirstRep().getItemReference().getReference());
}
@@ -1545,23 +1551,29 @@ public class FhirTerserR4Test {
@Test
void copyingAndParsingCreatesDuplicateContainedResources() {
- var input = new Library();
+ var library = new Library();
var params = new Parameters();
var id = "#expansion-parameters-ecr";
params.setId(id);
params.addParameter("system-version", new StringType("test2"));
var paramsExt = new Extension();
+
paramsExt.setUrl("test").setValue(new Reference(id));
- input.addContained(params);
- input.addExtension(paramsExt);
+ library.addContained(params);
+ library.addExtension(paramsExt);
+
final var parser = FhirContext.forR4Cached().newJsonParser();
- var stringified = parser.encodeResourceToString(input);
+ var stringified = parser.encodeResourceToString(library);
+
+
var parsed = parser.parseResource(stringified);
var copy = ((Library) parsed).copy();
+
assertEquals(1, copy.getContained().size());
- var stringifiedCopy = parser.encodeResourceToString(copy);
- var parsedCopy = parser.parseResource(stringifiedCopy);
- assertEquals(1, ((Library) parsedCopy).getContained().size());
+
+ String stringifiedCopy = FhirContext.forR4Cached().newJsonParser().encodeResourceToString(copy);
+ Library parsedCopy = (Library) parser.parseResource(stringifiedCopy);
+ assertEquals(1, parsedCopy.getContained().size());
}
/**
diff --git a/hapi-fhir-test-utilities/src/main/java/ca/uhn/fhir/test/utilities/UuidUtils.java b/hapi-fhir-test-utilities/src/main/java/ca/uhn/fhir/test/utilities/UuidUtils.java
new file mode 100644
index 00000000000..7cd9e85f213
--- /dev/null
+++ b/hapi-fhir-test-utilities/src/main/java/ca/uhn/fhir/test/utilities/UuidUtils.java
@@ -0,0 +1,47 @@
+/*-
+ * #%L
+ * HAPI FHIR Test Utilities
+ * %%
+ * Copyright (C) 2014 - 2024 Smile CDR, Inc.
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+package ca.uhn.fhir.test.utilities;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class UuidUtils {
+
+ private UuidUtils() {
+ }
+
+ public static final String UUID_PATTERN = "[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}";
+ public static final String HASH_UUID_PATTERN = "#" + UUID_PATTERN;
+ private static final Pattern COMPILED_UUID_PATTERN = Pattern.compile(UUID_PATTERN);
+
+ /**
+ * Extracts first UUID from String.
+ * Returns null if no UUID present in the String.
+ */
+ public static String findFirstUUID(String input) {
+ Matcher matcher = COMPILED_UUID_PATTERN.matcher(input);
+
+ if (matcher.find()) {
+ return matcher.group();
+ }
+ return null;
+ }
+
+}
diff --git a/hapi-fhir-test-utilities/src/main/java/ca/uhn/fhir/test/utilities/validation/IValidationProviders.java b/hapi-fhir-test-utilities/src/main/java/ca/uhn/fhir/test/utilities/validation/IValidationProviders.java
new file mode 100644
index 00000000000..d9933708e47
--- /dev/null
+++ b/hapi-fhir-test-utilities/src/main/java/ca/uhn/fhir/test/utilities/validation/IValidationProviders.java
@@ -0,0 +1,123 @@
+/*-
+ * #%L
+ * HAPI FHIR Test Utilities
+ * %%
+ * Copyright (C) 2014 - 2024 Smile CDR, Inc.
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+package ca.uhn.fhir.test.utilities.validation;
+
+import ca.uhn.fhir.context.FhirContext;
+import ca.uhn.fhir.context.support.IValidationSupport;
+import ca.uhn.fhir.rest.annotation.RequiredParam;
+import ca.uhn.fhir.rest.annotation.Search;
+import ca.uhn.fhir.rest.param.UriParam;
+import ca.uhn.fhir.rest.server.IResourceProvider;
+import ca.uhn.fhir.util.ClasspathUtil;
+import org.hl7.fhir.instance.model.api.IBaseParameters;
+import org.hl7.fhir.instance.model.api.IDomainResource;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public interface IValidationProviders {
+ String CODE_SYSTEM = "http://code.system/url";
+ String CODE_SYSTEM_VERSION = "1.0.0";
+ String CODE_SYSTEM_NAME = "Test Code System";
+ String CODE = "CODE";
+ String VALUE_SET_URL = "http://value.set/url";
+ String DISPLAY = "Explanation for code TestCode.";
+ String LANGUAGE = "en";
+ String ERROR_MESSAGE = "This is an error message";
+
+ interface IMyValidationProvider extends IResourceProvider {
+ void addException(String theOperation, String theUrl, String theCode, Exception theException);
+ void addTerminologyResponse(String theOperation, String theUrl, String theCode, P theReturnParams);
+ IBaseParameters addTerminologyResponse(String theOperation, String theUrl, String theCode, FhirContext theFhirContext, String theTerminologyResponseFile);
+ }
+
+ abstract class MyValidationProvider implements IMyValidationProvider {
+ private final Map myExceptionMap = new HashMap<>();
+ private boolean myShouldThrowExceptionForResourceNotFound = true;
+ private final Map myTerminologyResponseMap = new HashMap<>();
+ private final Map myTerminologyResourceMap = new HashMap<>();
+
+ static String getInputKey(String theOperation, String theUrl, String theCode) {
+ return theOperation + "-" + theUrl + "#" + theCode;
+ }
+
+ public void setShouldThrowExceptionForResourceNotFound(boolean theShouldThrowExceptionForResourceNotFound) {
+ myShouldThrowExceptionForResourceNotFound = theShouldThrowExceptionForResourceNotFound;
+ }
+
+ public void addException(String theOperation, String theUrl, String theCode, Exception theException) {
+ String inputKey = getInputKey(theOperation, theUrl, theCode);
+ myExceptionMap.put(inputKey, theException);
+ }
+
+ abstract Class extends IBaseParameters> getParameterType();
+
+ @Override
+ public void addTerminologyResponse(String theOperation, String theUrl, String theCode, P theReturnParams) {
+ myTerminologyResponseMap.put(getInputKey(theOperation, theUrl, theCode), theReturnParams);
+ }
+
+ public IBaseParameters addTerminologyResponse(String theOperation, String theUrl, String theCode, FhirContext theFhirContext, String theTerminologyResponseFile) {
+ IBaseParameters responseParams = ClasspathUtil.loadResource(theFhirContext, getParameterType(), theTerminologyResponseFile);
+ addTerminologyResponse(theOperation, theUrl, theCode, responseParams);
+ return responseParams;
+ }
+
+ protected void addTerminologyResource(String theUrl, T theResource) {
+ myTerminologyResourceMap.put(theUrl, theResource);
+ }
+
+ public abstract T addTerminologyResource(String theUrl);
+
+ protected IBaseParameters getTerminologyResponse(String theOperation, String theUrl, String theCode) throws Exception {
+ String inputKey = getInputKey(theOperation, theUrl, theCode);
+ if (myExceptionMap.containsKey(inputKey)) {
+ throw myExceptionMap.get(inputKey);
+ }
+ IBaseParameters params = myTerminologyResponseMap.get(inputKey);
+ if (params == null) {
+ throw new IllegalStateException("Test setup incomplete. Missing return params for " + inputKey);
+ }
+ return params;
+ }
+
+ protected T getTerminologyResource(UriParam theUrlParam) {
+ if (theUrlParam.isEmpty()) {
+ throw new IllegalStateException("CodeSystem url should not be null.");
+ }
+ String urlValue = theUrlParam.getValue();
+ if (!myTerminologyResourceMap.containsKey(urlValue) && myShouldThrowExceptionForResourceNotFound) {
+ throw new IllegalStateException("Test setup incomplete. CodeSystem not found " + urlValue);
+ }
+ return myTerminologyResourceMap.get(urlValue);
+ }
+
+ @Search
+ public List find(@RequiredParam(name = "url") UriParam theUrlParam) {
+ T resource = getTerminologyResource(theUrlParam);
+ return resource != null ? List.of(resource) : List.of();
+ }
+ }
+
+ interface IMyLookupCodeProvider extends IResourceProvider {
+ void setLookupCodeResult(IValidationSupport.LookupCodeResult theLookupCodeResult);
+ }
+}
diff --git a/hapi-fhir-test-utilities/src/main/java/ca/uhn/fhir/test/utilities/validation/IValidationProvidersDstu3.java b/hapi-fhir-test-utilities/src/main/java/ca/uhn/fhir/test/utilities/validation/IValidationProvidersDstu3.java
new file mode 100644
index 00000000000..11c5244df41
--- /dev/null
+++ b/hapi-fhir-test-utilities/src/main/java/ca/uhn/fhir/test/utilities/validation/IValidationProvidersDstu3.java
@@ -0,0 +1,137 @@
+/*-
+ * #%L
+ * HAPI FHIR Test Utilities
+ * %%
+ * Copyright (C) 2014 - 2024 Smile CDR, Inc.
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+package ca.uhn.fhir.test.utilities.validation;
+
+import ca.uhn.fhir.rest.annotation.IdParam;
+import ca.uhn.fhir.rest.annotation.Operation;
+import ca.uhn.fhir.rest.annotation.OperationParam;
+import ca.uhn.fhir.rest.api.server.RequestDetails;
+import jakarta.servlet.http.HttpServletRequest;
+import org.hl7.fhir.dstu3.model.BooleanType;
+import org.hl7.fhir.dstu3.model.CodeSystem;
+import org.hl7.fhir.dstu3.model.CodeType;
+import org.hl7.fhir.dstu3.model.Coding;
+import org.hl7.fhir.dstu3.model.IdType;
+import org.hl7.fhir.dstu3.model.Parameters;
+import org.hl7.fhir.dstu3.model.StringType;
+import org.hl7.fhir.dstu3.model.UriType;
+import org.hl7.fhir.dstu3.model.ValueSet;
+import org.hl7.fhir.instance.model.api.IBaseParameters;
+import org.hl7.fhir.instance.model.api.IBaseResource;
+
+import java.util.List;
+
+public interface IValidationProvidersDstu3 {
+ @SuppressWarnings("unused")
+ class MyCodeSystemProviderDstu3 extends IValidationProviders.MyValidationProvider {
+ @Operation(name = "$validate-code", idempotent = true, returnParameters = {
+ @OperationParam(name = "result", type = BooleanType.class, min = 1),
+ @OperationParam(name = "message", type = StringType.class),
+ @OperationParam(name = "display", type = StringType.class)
+ })
+ public IBaseParameters validateCode(
+ HttpServletRequest theServletRequest,
+ @IdParam(optional = true) IdType theId,
+ @OperationParam(name = "url", min = 0, max = 1) UriType theCodeSystemUrl,
+ @OperationParam(name = "code", min = 0, max = 1) CodeType theCode,
+ @OperationParam(name = "display", min = 0, max = 1) StringType theDisplay
+ ) throws Exception {
+ String url = theCodeSystemUrl != null ? theCodeSystemUrl.getValue() : null;
+ String code = theCode != null ? theCode.getValue() : null;
+ return getTerminologyResponse("$validate-code", url, code);
+ }
+
+ @Operation(name = "$lookup", idempotent = true, returnParameters= {
+ @OperationParam(name = "name", type = StringType.class, min = 1),
+ @OperationParam(name = "version", type = StringType.class),
+ @OperationParam(name = "display", type = StringType.class, min = 1),
+ @OperationParam(name = "abstract", type = BooleanType.class, min = 1),
+ @OperationParam(name = "property", type = StringType.class, min = 0, max = OperationParam.MAX_UNLIMITED)
+ })
+ public IBaseParameters lookup(
+ HttpServletRequest theServletRequest,
+ @OperationParam(name = "code", max = 1) CodeType theCode,
+ @OperationParam(name = "system",max = 1) UriType theSystem,
+ @OperationParam(name = "coding", max = 1) Coding theCoding,
+ @OperationParam(name = "version", max = 1) StringType theVersion,
+ @OperationParam(name = "displayLanguage", max = 1) CodeType theDisplayLanguage,
+ @OperationParam(name = "property", max = OperationParam.MAX_UNLIMITED) List thePropertyNames,
+ RequestDetails theRequestDetails
+ ) throws Exception {
+ String url = theSystem != null ? theSystem.getValue() : null;
+ String code = theCode != null ? theCode.getValue() : null;
+ return getTerminologyResponse("$lookup", url, code);
+ }
+ @Override
+ public Class extends IBaseResource> getResourceType() {
+ return CodeSystem.class;
+ }
+ @Override
+ Class getParameterType() {
+ return Parameters.class;
+ }
+ @Override
+ public CodeSystem addTerminologyResource(String theUrl) {
+ CodeSystem codeSystem = new CodeSystem();
+ codeSystem.setId(theUrl.substring(0, theUrl.lastIndexOf("/")));
+ codeSystem.setUrl(theUrl);
+ addTerminologyResource(theUrl, codeSystem);
+ return codeSystem;
+ }
+ }
+
+ @SuppressWarnings("unused")
+ class MyValueSetProviderDstu3 extends IValidationProviders.MyValidationProvider {
+ @Operation(name = "$validate-code", idempotent = true, returnParameters = {
+ @OperationParam(name = "result", type = BooleanType.class, min = 1),
+ @OperationParam(name = "message", type = StringType.class),
+ @OperationParam(name = "display", type = StringType.class)
+ })
+ public IBaseParameters validateCode(
+ HttpServletRequest theServletRequest,
+ @IdParam(optional = true) IdType theId,
+ @OperationParam(name = "url", min = 0, max = 1) UriType theValueSetUrl,
+ @OperationParam(name = "code", min = 0, max = 1) CodeType theCode,
+ @OperationParam(name = "system", min = 0, max = 1) UriType theSystem,
+ @OperationParam(name = "display", min = 0, max = 1) StringType theDisplay,
+ @OperationParam(name = "valueSet") ValueSet theValueSet
+ ) throws Exception {
+ String url = theValueSetUrl != null ? theValueSetUrl.getValue() : null;
+ String code = theCode != null ? theCode.getValue() : null;
+ return getTerminologyResponse("$validate-code", url, code);
+ }
+ @Override
+ public Class extends IBaseResource> getResourceType() {
+ return ValueSet.class;
+ }
+ @Override
+ Class getParameterType() {
+ return Parameters.class;
+ }
+ @Override
+ public ValueSet addTerminologyResource(String theUrl) {
+ ValueSet valueSet = new ValueSet();
+ valueSet.setId(theUrl.substring(0, theUrl.lastIndexOf("/")));
+ valueSet.setUrl(theUrl);
+ addTerminologyResource(theUrl, valueSet);
+ return valueSet;
+ }
+ }
+}
diff --git a/hapi-fhir-validation/src/test/java/org/hl7/fhir/r4/validation/IValidateCodeProvidersR4.java b/hapi-fhir-test-utilities/src/main/java/ca/uhn/fhir/test/utilities/validation/IValidationProvidersR4.java
similarity index 55%
rename from hapi-fhir-validation/src/test/java/org/hl7/fhir/r4/validation/IValidateCodeProvidersR4.java
rename to hapi-fhir-test-utilities/src/main/java/ca/uhn/fhir/test/utilities/validation/IValidationProvidersR4.java
index fd03a8163ff..87a3dacb1fc 100644
--- a/hapi-fhir-validation/src/test/java/org/hl7/fhir/r4/validation/IValidateCodeProvidersR4.java
+++ b/hapi-fhir-test-utilities/src/main/java/ca/uhn/fhir/test/utilities/validation/IValidationProvidersR4.java
@@ -1,12 +1,29 @@
-package org.hl7.fhir.r4.validation;
+/*-
+ * #%L
+ * HAPI FHIR Test Utilities
+ * %%
+ * Copyright (C) 2014 - 2024 Smile CDR, Inc.
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+package ca.uhn.fhir.test.utilities.validation;
-import ca.uhn.fhir.jpa.model.util.JpaConstants;
import ca.uhn.fhir.rest.annotation.IdParam;
import ca.uhn.fhir.rest.annotation.Operation;
import ca.uhn.fhir.rest.annotation.OperationParam;
import ca.uhn.fhir.rest.api.server.RequestDetails;
import jakarta.servlet.http.HttpServletRequest;
-import org.hl7.fhir.common.hapi.validation.IValidationProviders;
import org.hl7.fhir.instance.model.api.IBaseParameters;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.r4.model.BooleanType;
@@ -21,38 +38,29 @@ import org.hl7.fhir.r4.model.ValueSet;
import java.util.List;
-public interface IValidateCodeProvidersR4 {
+public interface IValidationProvidersR4 {
@SuppressWarnings("unused")
- class MyCodeSystemProviderR4 implements IValidationProviders.IMyCodeSystemProvider {
- private UriType mySystemUrl;
- private CodeType myCode;
- private StringType myDisplay;
- private Exception myException;
- private Parameters myReturnParams;
+ class MyCodeSystemProviderR4 extends IValidationProviders.MyValidationProvider {
- @Operation(name = "validate-code", idempotent = true, returnParameters = {
+ @Operation(name = "$validate-code", idempotent = true, returnParameters = {
@OperationParam(name = "result", type = BooleanType.class, min = 1),
@OperationParam(name = "message", type = StringType.class),
@OperationParam(name = "display", type = StringType.class)
})
- public Parameters validateCode(
+ public IBaseParameters validateCode(
HttpServletRequest theServletRequest,
@IdParam(optional = true) IdType theId,
@OperationParam(name = "url", min = 0, max = 1) UriType theCodeSystemUrl,
@OperationParam(name = "code", min = 0, max = 1) CodeType theCode,
@OperationParam(name = "display", min = 0, max = 1) StringType theDisplay
) throws Exception {
- mySystemUrl = theCodeSystemUrl;
- myCode = theCode;
- myDisplay = theDisplay;
- if (myException != null) {
- throw myException;
- }
- return myReturnParams;
+ String url = theCodeSystemUrl != null ? theCodeSystemUrl.getValue() : null;
+ String code = theCode != null ? theCode.getValue() : null;
+ return getTerminologyResponse("$validate-code", url, code);
}
- @Operation(name = JpaConstants.OPERATION_LOOKUP, idempotent = true, returnParameters= {
+ @Operation(name = "$lookup", idempotent = true, returnParameters= {
@OperationParam(name = "name", type = StringType.class, min = 1),
@OperationParam(name = "version", type = StringType.class),
@OperationParam(name = "display", type = StringType.class, min = 1),
@@ -69,54 +77,39 @@ public interface IValidateCodeProvidersR4 {
@OperationParam(name = "property", max = OperationParam.MAX_UNLIMITED) List thePropertyNames,
RequestDetails theRequestDetails
) throws Exception {
- mySystemUrl = theSystem;
- myCode = theCode;
- if (myException != null) {
- throw myException;
- }
- return myReturnParams;
+ String url = theSystem != null ? theSystem.getValue() : null;
+ String code = theCode != null ? theCode.getValue() : null;
+ return getTerminologyResponse("$lookup", url, code);
}
-
@Override
public Class extends IBaseResource> getResourceType() {
return CodeSystem.class;
}
- public void setException(Exception theException) {
- myException = theException;
- }
@Override
- public void setReturnParams(IBaseParameters theParameters) {
- myReturnParams = (Parameters) theParameters;
+ Class getParameterType() {
+ return Parameters.class;
}
+
@Override
- public String getCode() {
- return myCode != null ? myCode.getValueAsString() : null;
- }
- @Override
- public String getSystem() {
- return mySystemUrl != null ? mySystemUrl.getValueAsString() : null;
- }
- public String getDisplay() {
- return myDisplay != null ? myDisplay.getValue() : null;
+ public CodeSystem addTerminologyResource(String theUrl) {
+ CodeSystem codeSystem = new CodeSystem();
+ codeSystem.setId(theUrl.substring(0, theUrl.lastIndexOf("/")));
+ codeSystem.setUrl(theUrl);
+ addTerminologyResource(theUrl, codeSystem);
+ return codeSystem;
}
}
@SuppressWarnings("unused")
- class MyValueSetProviderR4 implements IValidationProviders.IMyValueSetProvider {
- private Exception myException;
- private Parameters myReturnParams;
- private UriType mySystemUrl;
- private UriType myValueSetUrl;
- private CodeType myCode;
- private StringType myDisplay;
+ class MyValueSetProviderR4 extends IValidationProviders.MyValidationProvider {
- @Operation(name = "validate-code", idempotent = true, returnParameters = {
+ @Operation(name = "$validate-code", idempotent = true, returnParameters = {
@OperationParam(name = "result", type = BooleanType.class, min = 1),
@OperationParam(name = "message", type = StringType.class),
@OperationParam(name = "display", type = StringType.class)
})
- public Parameters validateCode(
+ public IBaseParameters validateCode(
HttpServletRequest theServletRequest,
@IdParam(optional = true) IdType theId,
@OperationParam(name = "url", min = 0, max = 1) UriType theValueSetUrl,
@@ -125,41 +118,25 @@ public interface IValidateCodeProvidersR4 {
@OperationParam(name = "display", min = 0, max = 1) StringType theDisplay,
@OperationParam(name = "valueSet") ValueSet theValueSet
) throws Exception {
- mySystemUrl = theSystem;
- myValueSetUrl = theValueSetUrl;
- myCode = theCode;
- myDisplay = theDisplay;
- if (myException != null) {
- throw myException;
- }
- return myReturnParams;
+ String url = theValueSetUrl != null ? theValueSetUrl.getValue() : null;
+ String code = theCode != null ? theCode.getValue() : null;
+ return getTerminologyResponse("$validate-code", url, code);
}
-
@Override
public Class extends IBaseResource> getResourceType() {
return ValueSet.class;
}
- public void setException(Exception theException) {
- myException = theException;
+ @Override
+ Class getParameterType() {
+ return Parameters.class;
}
@Override
- public void setReturnParams(IBaseParameters theParameters) {
- myReturnParams = (Parameters) theParameters;
- }
- @Override
- public String getCode() {
- return myCode != null ? myCode.getValueAsString() : null;
- }
- @Override
- public String getSystem() {
- return mySystemUrl != null ? mySystemUrl.getValueAsString() : null;
- }
- @Override
- public String getValueSet() {
- return myValueSetUrl != null ? myValueSetUrl.getValueAsString() : null;
- }
- public String getDisplay() {
- return myDisplay != null ? myDisplay.getValue() : null;
+ public ValueSet addTerminologyResource(String theUrl) {
+ ValueSet valueSet = new ValueSet();
+ valueSet.setId(theUrl.substring(0, theUrl.lastIndexOf("/")));
+ valueSet.setUrl(theUrl);
+ addTerminologyResource(theUrl, valueSet);
+ return valueSet;
}
}
}
diff --git a/hapi-fhir-test-utilities/src/test/java/ca/uhn/fhir/test/utilities/UuidUtilsTest.java b/hapi-fhir-test-utilities/src/test/java/ca/uhn/fhir/test/utilities/UuidUtilsTest.java
new file mode 100644
index 00000000000..c7c26bdf107
--- /dev/null
+++ b/hapi-fhir-test-utilities/src/test/java/ca/uhn/fhir/test/utilities/UuidUtilsTest.java
@@ -0,0 +1,29 @@
+package ca.uhn.fhir.test.utilities;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
+public class UuidUtilsTest {
+
+ @Test
+ void testFindsUuid() {
+ String xml = "";
+ String uuid = UuidUtils.findFirstUUID(xml);
+ assertEquals("cdb6dfa1-74b7-4ea9-88e0-d3afaef8c016", uuid);
+ }
+
+ @Test
+ void testFindsFirstUuid() {
+ String xml = "";
+ String uuid = UuidUtils.findFirstUUID(xml);
+ assertEquals("cdb6dfa1-74b7-4ea9-88e0-d3afaef8c016", uuid);
+ }
+
+ @Test
+ void testNoUuidReturnsNull() {
+ String xml = "";
+ assertNull(UuidUtils.findFirstUUID(xml));
+ }
+}
diff --git a/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/support/CommonCodeSystemsTerminologyService.java b/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/support/CommonCodeSystemsTerminologyService.java
index 1b12e20ec62..7a05e197ae6 100644
--- a/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/support/CommonCodeSystemsTerminologyService.java
+++ b/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/support/CommonCodeSystemsTerminologyService.java
@@ -190,7 +190,7 @@ public class CommonCodeSystemsTerminologyService implements IValidationSupport {
return new CodeValidationResult()
.setSeverity(IssueSeverity.ERROR)
.setMessage(theMessage)
- .setCodeValidationIssues(Collections.singletonList(new CodeValidationIssue(
+ .setIssues(Collections.singletonList(new CodeValidationIssue(
theMessage,
IssueSeverity.ERROR,
CodeValidationIssueCode.INVALID,
diff --git a/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/support/InMemoryTerminologyServerValidationSupport.java b/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/support/InMemoryTerminologyServerValidationSupport.java
index 67e553e3d3b..a617e04c41b 100644
--- a/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/support/InMemoryTerminologyServerValidationSupport.java
+++ b/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/support/InMemoryTerminologyServerValidationSupport.java
@@ -28,7 +28,6 @@ import org.hl7.fhir.instance.model.api.IPrimitiveType;
import org.hl7.fhir.r5.model.CanonicalType;
import org.hl7.fhir.r5.model.CodeSystem;
import org.hl7.fhir.r5.model.Enumerations;
-import org.hl7.fhir.utilities.validation.ValidationMessage;
import java.util.ArrayList;
import java.util.Collections;
@@ -258,7 +257,7 @@ public class InMemoryTerminologyServerValidationSupport implements IValidationSu
theValidationSupportContext, theValueSet, theCodeSystemUrlAndVersion, theCode);
} catch (ExpansionCouldNotBeCompletedInternallyException e) {
CodeValidationResult codeValidationResult = new CodeValidationResult();
- codeValidationResult.setSeverityCode("error");
+ codeValidationResult.setSeverity(IssueSeverity.ERROR);
String msg = "Failed to expand ValueSet '" + vsUrl + "' (in-memory). Could not validate code "
+ theCodeSystemUrlAndVersion + "#" + theCode;
@@ -267,7 +266,7 @@ public class InMemoryTerminologyServerValidationSupport implements IValidationSu
}
codeValidationResult.setMessage(msg);
- codeValidationResult.addCodeValidationIssue(e.getCodeValidationIssue());
+ codeValidationResult.addIssue(e.getCodeValidationIssue());
return codeValidationResult;
}
@@ -551,18 +550,18 @@ public class InMemoryTerminologyServerValidationSupport implements IValidationSu
if (valueSetResult != null) {
codeValidationResult = valueSetResult;
} else {
- ValidationMessage.IssueSeverity severity;
+ IValidationSupport.IssueSeverity severity;
String message;
CodeValidationIssueCode issueCode = CodeValidationIssueCode.CODE_INVALID;
CodeValidationIssueCoding issueCoding = CodeValidationIssueCoding.INVALID_CODE;
if ("fragment".equals(codeSystemResourceContentMode)) {
- severity = ValidationMessage.IssueSeverity.WARNING;
+ severity = IValidationSupport.IssueSeverity.WARNING;
message = "Unknown code in fragment CodeSystem '"
+ getFormattedCodeSystemAndCodeForMessage(
theCodeSystemUrlAndVersionToValidate, theCodeToValidate)
+ "'";
} else {
- severity = ValidationMessage.IssueSeverity.ERROR;
+ severity = IValidationSupport.IssueSeverity.ERROR;
message = "Unknown code '"
+ getFormattedCodeSystemAndCodeForMessage(
theCodeSystemUrlAndVersionToValidate, theCodeToValidate)
@@ -574,10 +573,9 @@ public class InMemoryTerminologyServerValidationSupport implements IValidationSu
}
codeValidationResult = new CodeValidationResult()
- .setSeverityCode(severity.toCode())
+ .setSeverity(severity)
.setMessage(message)
- .addCodeValidationIssue(new CodeValidationIssue(
- message, getIssueSeverityFromCodeValidationIssue(severity), issueCode, issueCoding));
+ .addIssue(new CodeValidationIssue(message, severity, issueCode, issueCoding));
}
return codeValidationResult;
@@ -589,19 +587,6 @@ public class InMemoryTerminologyServerValidationSupport implements IValidationSu
+ theCodeToValidate;
}
- private IValidationSupport.IssueSeverity getIssueSeverityFromCodeValidationIssue(
- ValidationMessage.IssueSeverity theSeverity) {
- switch (theSeverity) {
- case ERROR:
- return IValidationSupport.IssueSeverity.ERROR;
- case WARNING:
- return IValidationSupport.IssueSeverity.WARNING;
- case INFORMATION:
- return IValidationSupport.IssueSeverity.INFORMATION;
- }
- return null;
- }
-
private CodeValidationResult findCodeInExpansion(
String theCodeToValidate,
String theDisplayToValidate,
@@ -1123,8 +1108,8 @@ public class InMemoryTerminologyServerValidationSupport implements IValidationSu
new CodeValidationIssue(
theMessage,
IssueSeverity.ERROR,
- CodeValidationIssueCode.OTHER,
- CodeValidationIssueCoding.OTHER));
+ CodeValidationIssueCode.INVALID,
+ CodeValidationIssueCoding.VS_INVALID));
}
for (org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent next :
subExpansion.getExpansion().getContains()) {
@@ -1376,7 +1361,7 @@ public class InMemoryTerminologyServerValidationSupport implements IValidationSu
.setCodeSystemVersion(theCodeSystemVersion)
.setDisplay(theExpectedDisplay);
if (issueSeverity != null) {
- codeValidationResult.setCodeValidationIssues(Collections.singletonList(new CodeValidationIssue(
+ codeValidationResult.setIssues(Collections.singletonList(new CodeValidationIssue(
message,
theIssueSeverityForCodeDisplayMismatch,
CodeValidationIssueCode.INVALID,
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 370f8b423dd..398eacc52a2 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
@@ -28,6 +28,7 @@ import org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.r4.model.Base;
import org.hl7.fhir.r4.model.CodeSystem;
import org.hl7.fhir.r4.model.CodeType;
+import org.hl7.fhir.r4.model.CodeableConcept;
import org.hl7.fhir.r4.model.Coding;
import org.hl7.fhir.r4.model.OperationOutcome;
import org.hl7.fhir.r4.model.Parameters;
@@ -631,7 +632,7 @@ public class RemoteTerminologyServiceValidationSupport extends BaseValidationSup
return new CodeValidationResult()
.setSeverity(severity)
.setMessage(theMessage)
- .addCodeValidationIssue(new CodeValidationIssue(
+ .addIssue(new CodeValidationIssue(
theMessage, severity, theIssueCode, CodeValidationIssueCoding.INVALID_CODE));
}
@@ -680,13 +681,13 @@ public class RemoteTerminologyServiceValidationSupport extends BaseValidationSup
createCodeValidationIssues(
(IBaseOperationOutcome) issuesValue.get(),
fhirContext.getVersion().getVersion())
- .ifPresent(i -> i.forEach(result::addCodeValidationIssue));
+ .ifPresent(i -> i.forEach(result::addIssue));
} else {
// create a validation issue out of the message
// this is a workaround to overcome an issue in the FHIR Validator library
// where ValueSet bindings are only reading issues but not messages
// @see https://github.com/hapifhir/org.hl7.fhir.core/issues/1766
- result.addCodeValidationIssue(createCodeValidationIssue(result.getMessage()));
+ result.addIssue(createCodeValidationIssue(result.getMessage()));
}
return result;
}
@@ -717,23 +718,42 @@ public class RemoteTerminologyServiceValidationSupport extends BaseValidationSup
private static Collection createCodeValidationIssuesR4(OperationOutcome theOperationOutcome) {
return theOperationOutcome.getIssue().stream()
- .map(issueComponent ->
- createCodeValidationIssue(issueComponent.getDetails().getText()))
+ .map(issueComponent -> {
+ String diagnostics = issueComponent.getDiagnostics();
+ IssueSeverity issueSeverity =
+ IssueSeverity.fromCode(issueComponent.getSeverity().toCode());
+ String issueTypeCode = issueComponent.getCode().toCode();
+ CodeableConcept details = issueComponent.getDetails();
+ CodeValidationIssue issue = new CodeValidationIssue(diagnostics, issueSeverity, issueTypeCode);
+ CodeValidationIssueDetails issueDetails = new CodeValidationIssueDetails(details.getText());
+ details.getCoding().forEach(coding -> issueDetails.addCoding(coding.getSystem(), coding.getCode()));
+ issue.setDetails(issueDetails);
+ return issue;
+ })
.collect(Collectors.toList());
}
private static Collection createCodeValidationIssuesDstu3(
org.hl7.fhir.dstu3.model.OperationOutcome theOperationOutcome) {
return theOperationOutcome.getIssue().stream()
- .map(issueComponent ->
- createCodeValidationIssue(issueComponent.getDetails().getText()))
+ .map(issueComponent -> {
+ String diagnostics = issueComponent.getDiagnostics();
+ IssueSeverity issueSeverity =
+ IssueSeverity.fromCode(issueComponent.getSeverity().toCode());
+ String issueTypeCode = issueComponent.getCode().toCode();
+ org.hl7.fhir.dstu3.model.CodeableConcept details = issueComponent.getDetails();
+ CodeValidationIssue issue = new CodeValidationIssue(diagnostics, issueSeverity, issueTypeCode);
+ CodeValidationIssueDetails issueDetails = new CodeValidationIssueDetails(details.getText());
+ details.getCoding().forEach(coding -> issueDetails.addCoding(coding.getSystem(), coding.getCode()));
+ issue.setDetails(issueDetails);
+ return issue;
+ })
.collect(Collectors.toList());
}
private static CodeValidationIssue createCodeValidationIssue(String theMessage) {
return new CodeValidationIssue(
theMessage,
- // assume issue type is OperationOutcome.IssueType#CODEINVALID as it is the only match
IssueSeverity.ERROR,
CodeValidationIssueCode.INVALID,
CodeValidationIssueCoding.INVALID_CODE);
diff --git a/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/support/UnknownCodeSystemWarningValidationSupport.java b/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/support/UnknownCodeSystemWarningValidationSupport.java
index 1898292c451..265debed058 100644
--- a/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/support/UnknownCodeSystemWarningValidationSupport.java
+++ b/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/support/UnknownCodeSystemWarningValidationSupport.java
@@ -87,7 +87,7 @@ public class UnknownCodeSystemWarningValidationSupport extends BaseValidationSup
result.setSeverity(null);
result.setMessage(null);
} else {
- result.addCodeValidationIssue(new CodeValidationIssue(
+ result.addIssue(new CodeValidationIssue(
theMessage,
myNonExistentCodeSystemSeverity,
CodeValidationIssueCode.NOT_FOUND,
diff --git a/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/support/ValidationSupportUtils.java b/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/support/ValidationSupportUtils.java
index 7321f33d8c8..7093ab2a7ff 100644
--- a/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/support/ValidationSupportUtils.java
+++ b/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/support/ValidationSupportUtils.java
@@ -11,6 +11,17 @@ public final class ValidationSupportUtils {
private ValidationSupportUtils() {}
+ /**
+ * This method extracts a code system that can be (potentially) associated with a code when
+ * performing validation against a ValueSet. This method was created for internal purposes.
+ * Please use this method with care because it will only cover some
+ * use-cases (e.g. standard bindings) while for others it may not return correct results or return null.
+ * An incorrect result could be considered if the resource declares a code with a system, and you're calling
+ * this method to check a binding against a ValueSet that has nothing to do with that system.
+ * @param theValueSet the valueSet
+ * @param theCode the code
+ * @return the system which can be associated with the code
+ */
public static String extractCodeSystemForCode(IBaseResource theValueSet, String theCode) {
if (theValueSet instanceof org.hl7.fhir.dstu3.model.ValueSet) {
return extractCodeSystemForCodeDSTU3((org.hl7.fhir.dstu3.model.ValueSet) theValueSet, theCode);
diff --git a/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/validator/VersionSpecificWorkerContextWrapper.java b/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/validator/VersionSpecificWorkerContextWrapper.java
index f0f3f41e7f9..393d8ce1dc5 100644
--- a/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/validator/VersionSpecificWorkerContextWrapper.java
+++ b/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/validator/VersionSpecificWorkerContextWrapper.java
@@ -62,6 +62,7 @@ import java.util.Map;
import java.util.Objects;
import java.util.Set;
+import static ca.uhn.fhir.context.support.IValidationSupport.CodeValidationIssueCoding.INVALID_DISPLAY;
import static java.util.stream.Collectors.collectingAndThen;
import static java.util.stream.Collectors.toSet;
import static org.apache.commons.lang3.StringUtils.isBlank;
@@ -296,7 +297,7 @@ public class VersionSpecificWorkerContextWrapper extends I18nBase implements IWo
theResult.getCodeSystemVersion(),
conceptDefinitionComponent,
display,
- getIssuesForCodeValidation(theResult.getCodeValidationIssues()));
+ getIssuesForCodeValidation(theResult.getIssues()));
}
if (retVal == null) {
@@ -307,73 +308,36 @@ public class VersionSpecificWorkerContextWrapper extends I18nBase implements IWo
}
private List getIssuesForCodeValidation(
- List codeValidationIssues) {
- List issues = new ArrayList<>();
+ List theIssues) {
+ List issueComponents = new ArrayList<>();
- for (IValidationSupport.CodeValidationIssue codeValidationIssue : codeValidationIssues) {
+ for (IValidationSupport.CodeValidationIssue issue : theIssues) {
+ OperationOutcome.IssueSeverity severity =
+ OperationOutcome.IssueSeverity.fromCode(issue.getSeverity().getCode());
+ OperationOutcome.IssueType issueType =
+ OperationOutcome.IssueType.fromCode(issue.getType().getCode());
+ String diagnostics = issue.getDiagnostics();
- CodeableConcept codeableConcept = new CodeableConcept().setText(codeValidationIssue.getMessage());
- codeableConcept.addCoding(
- "http://hl7.org/fhir/tools/CodeSystem/tx-issue-type",
- getIssueCodingFromCodeValidationIssue(codeValidationIssue),
- null);
+ IValidationSupport.CodeValidationIssueDetails details = issue.getDetails();
+ CodeableConcept codeableConcept = new CodeableConcept().setText(details.getText());
+ details.getCodings().forEach(detailCoding -> codeableConcept
+ .addCoding()
+ .setSystem(detailCoding.getSystem())
+ .setCode(detailCoding.getCode()));
- OperationOutcome.OperationOutcomeIssueComponent issue =
+ OperationOutcome.OperationOutcomeIssueComponent issueComponent =
new OperationOutcome.OperationOutcomeIssueComponent()
- .setSeverity(getIssueSeverityFromCodeValidationIssue(codeValidationIssue))
- .setCode(getIssueTypeFromCodeValidationIssue(codeValidationIssue))
- .setDetails(codeableConcept);
- issue.getDetails().setText(codeValidationIssue.getMessage());
- issue.addExtension()
+ .setSeverity(severity)
+ .setCode(issueType)
+ .setDetails(codeableConcept)
+ .setDiagnostics(diagnostics);
+ issueComponent
+ .addExtension()
.setUrl("http://hl7.org/fhir/StructureDefinition/operationoutcome-message-id")
.setValue(new StringType("Terminology_PassThrough_TX_Message"));
- issues.add(issue);
+ issueComponents.add(issueComponent);
}
- return issues;
- }
-
- private String getIssueCodingFromCodeValidationIssue(IValidationSupport.CodeValidationIssue codeValidationIssue) {
- switch (codeValidationIssue.getCoding()) {
- case VS_INVALID:
- return "vs-invalid";
- case NOT_FOUND:
- return "not-found";
- case NOT_IN_VS:
- return "not-in-vs";
- case INVALID_CODE:
- return "invalid-code";
- case INVALID_DISPLAY:
- return "invalid-display";
- }
- return null;
- }
-
- private OperationOutcome.IssueType getIssueTypeFromCodeValidationIssue(
- IValidationSupport.CodeValidationIssue codeValidationIssue) {
- switch (codeValidationIssue.getCode()) {
- case NOT_FOUND:
- return OperationOutcome.IssueType.NOTFOUND;
- case CODE_INVALID:
- return OperationOutcome.IssueType.CODEINVALID;
- case INVALID:
- return OperationOutcome.IssueType.INVALID;
- }
- return null;
- }
-
- private OperationOutcome.IssueSeverity getIssueSeverityFromCodeValidationIssue(
- IValidationSupport.CodeValidationIssue codeValidationIssue) {
- switch (codeValidationIssue.getSeverity()) {
- case FATAL:
- return OperationOutcome.IssueSeverity.FATAL;
- case ERROR:
- return OperationOutcome.IssueSeverity.ERROR;
- case WARNING:
- return OperationOutcome.IssueSeverity.WARNING;
- case INFORMATION:
- return OperationOutcome.IssueSeverity.INFORMATION;
- }
- return null;
+ return issueComponents;
}
@Override
@@ -851,25 +815,22 @@ public class VersionSpecificWorkerContextWrapper extends I18nBase implements IWo
.getRootValidationSupport()
.validateCodeInValueSet(
myValidationSupportContext, theValidationOptions, theSystem, theCode, theDisplay, theValueSet);
- if (result != null) {
+ if (result != null && theSystem != null) {
/* We got a value set result, which could be successful, or could contain errors/warnings. The code
might also be invalid in the code system, so we will check that as well and add those issues
to our result.
*/
IValidationSupport.CodeValidationResult codeSystemResult =
validateCodeInCodeSystem(theValidationOptions, theSystem, theCode, theDisplay);
- final boolean valueSetResultContainsInvalidDisplay = result.getCodeValidationIssues().stream()
- .anyMatch(codeValidationIssue -> codeValidationIssue.getCoding()
- == IValidationSupport.CodeValidationIssueCoding.INVALID_DISPLAY);
+ final boolean valueSetResultContainsInvalidDisplay = result.getIssues().stream()
+ .anyMatch(VersionSpecificWorkerContextWrapper::hasInvalidDisplayDetailCode);
if (codeSystemResult != null) {
- for (IValidationSupport.CodeValidationIssue codeValidationIssue :
- codeSystemResult.getCodeValidationIssues()) {
+ for (IValidationSupport.CodeValidationIssue codeValidationIssue : codeSystemResult.getIssues()) {
/* Value set validation should already have checked the display name. If we get INVALID_DISPLAY
issues from code system validation, they will only repeat what was already caught.
*/
- if (codeValidationIssue.getCoding() != IValidationSupport.CodeValidationIssueCoding.INVALID_DISPLAY
- || !valueSetResultContainsInvalidDisplay) {
- result.addCodeValidationIssue(codeValidationIssue);
+ if (!hasInvalidDisplayDetailCode(codeValidationIssue) || !valueSetResultContainsInvalidDisplay) {
+ result.addIssue(codeValidationIssue);
}
}
}
@@ -877,6 +838,10 @@ public class VersionSpecificWorkerContextWrapper extends I18nBase implements IWo
return result;
}
+ private static boolean hasInvalidDisplayDetailCode(IValidationSupport.CodeValidationIssue theIssue) {
+ return theIssue.hasIssueDetailCode(INVALID_DISPLAY.getCode());
+ }
+
private IValidationSupport.CodeValidationResult validateCodeInCodeSystem(
ConceptValidationOptions theValidationOptions, String theSystem, String theCode, String theDisplay) {
return myValidationSupportContext
diff --git a/hapi-fhir-validation/src/test/java/org/hl7/fhir/common/hapi/validation/ILookupCodeTest.java b/hapi-fhir-validation/src/test/java/org/hl7/fhir/common/hapi/validation/ILookupCodeTest.java
index bb7eaf1c17b..eac448ad0eb 100644
--- a/hapi-fhir-validation/src/test/java/org/hl7/fhir/common/hapi/validation/ILookupCodeTest.java
+++ b/hapi-fhir-validation/src/test/java/org/hl7/fhir/common/hapi/validation/ILookupCodeTest.java
@@ -9,6 +9,7 @@ import ca.uhn.fhir.context.support.IValidationSupport.LookupCodeResult;
import ca.uhn.fhir.context.support.IValidationSupport.StringConceptProperty;
import ca.uhn.fhir.context.support.LookupCodeRequest;
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
+import ca.uhn.fhir.test.utilities.validation.IValidationProviders;
import org.hl7.fhir.instance.model.api.IBaseDatatype;
import org.junit.jupiter.api.Test;
@@ -21,12 +22,12 @@ import static ca.uhn.fhir.context.support.IValidationSupport.TYPE_GROUP;
import static ca.uhn.fhir.context.support.IValidationSupport.TYPE_STRING;
import static java.util.stream.IntStream.range;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.hl7.fhir.common.hapi.validation.IValidationProviders.CODE;
-import static org.hl7.fhir.common.hapi.validation.IValidationProviders.CODE_SYSTEM;
-import static org.hl7.fhir.common.hapi.validation.IValidationProviders.CODE_SYSTEM_NAME;
-import static org.hl7.fhir.common.hapi.validation.IValidationProviders.CODE_SYSTEM_VERSION;
-import static org.hl7.fhir.common.hapi.validation.IValidationProviders.DISPLAY;
-import static org.hl7.fhir.common.hapi.validation.IValidationProviders.LANGUAGE;
+import static ca.uhn.fhir.test.utilities.validation.IValidationProviders.CODE;
+import static ca.uhn.fhir.test.utilities.validation.IValidationProviders.CODE_SYSTEM;
+import static ca.uhn.fhir.test.utilities.validation.IValidationProviders.CODE_SYSTEM_NAME;
+import static ca.uhn.fhir.test.utilities.validation.IValidationProviders.CODE_SYSTEM_VERSION;
+import static ca.uhn.fhir.test.utilities.validation.IValidationProviders.DISPLAY;
+import static ca.uhn.fhir.test.utilities.validation.IValidationProviders.LANGUAGE;
import static org.hl7.fhir.common.hapi.validation.support.RemoteTerminologyServiceValidationSupport.createConceptProperty;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
@@ -189,8 +190,6 @@ public interface ILookupCodeTest {
// verify
assertNotNull(outcome);
- assertEquals(theRequest.getCode(), getLookupCodeProvider().getCode());
- assertEquals(theRequest.getSystem(), getLookupCodeProvider().getSystem());
assertEquals(theExpectedResult.isFound(), outcome.isFound());
assertEquals(theExpectedResult.getErrorMessage(), outcome.getErrorMessage());
assertEquals(theExpectedResult.getCodeSystemDisplayName(), outcome.getCodeSystemDisplayName());
diff --git a/hapi-fhir-validation/src/test/java/org/hl7/fhir/common/hapi/validation/IRemoteTerminologyLookupCodeTest.java b/hapi-fhir-validation/src/test/java/org/hl7/fhir/common/hapi/validation/IRemoteTerminologyLookupCodeTest.java
index 5ba79bd3e6f..95c4fd7d3b9 100644
--- a/hapi-fhir-validation/src/test/java/org/hl7/fhir/common/hapi/validation/IRemoteTerminologyLookupCodeTest.java
+++ b/hapi-fhir-validation/src/test/java/org/hl7/fhir/common/hapi/validation/IRemoteTerminologyLookupCodeTest.java
@@ -2,6 +2,7 @@ package org.hl7.fhir.common.hapi.validation;
import ca.uhn.fhir.context.support.IValidationSupport.LookupCodeResult;
import ca.uhn.fhir.context.support.LookupCodeRequest;
+import ca.uhn.fhir.test.utilities.validation.IValidationProviders;
import org.hl7.fhir.common.hapi.validation.support.RemoteTerminologyServiceValidationSupport;
import org.junit.jupiter.api.Test;
diff --git a/hapi-fhir-validation/src/test/java/org/hl7/fhir/common/hapi/validation/IRemoteTerminologyValidateCodeTest.java b/hapi-fhir-validation/src/test/java/org/hl7/fhir/common/hapi/validation/IRemoteTerminologyValidateCodeTest.java
index cb6bb02ac07..21c5d0dc5e7 100644
--- a/hapi-fhir-validation/src/test/java/org/hl7/fhir/common/hapi/validation/IRemoteTerminologyValidateCodeTest.java
+++ b/hapi-fhir-validation/src/test/java/org/hl7/fhir/common/hapi/validation/IRemoteTerminologyValidateCodeTest.java
@@ -1,17 +1,76 @@
package org.hl7.fhir.common.hapi.validation;
+import ca.uhn.fhir.context.FhirVersionEnum;
import ca.uhn.fhir.context.support.IValidationSupport;
import org.hl7.fhir.common.hapi.validation.support.RemoteTerminologyServiceValidationSupport;
import org.hl7.fhir.instance.model.api.IBaseOperationOutcome;
+import org.junit.jupiter.api.Test;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.hl7.fhir.common.hapi.validation.support.RemoteTerminologyServiceValidationSupport.createCodeValidationIssues;
+
public interface IRemoteTerminologyValidateCodeTest extends IValidateCodeTest {
default List getCodeValidationIssues(IBaseOperationOutcome theOperationOutcome) {
// this method should be removed once support for issues is fully implemented across all validator types
Optional> issues = RemoteTerminologyServiceValidationSupport.createCodeValidationIssues(theOperationOutcome, getService().getFhirContext().getVersion().getVersion());
return issues.map(theCodeValidationIssues -> theCodeValidationIssues.stream().toList()).orElseGet(List::of);
}
+
+ @Test
+ default void createCodeValidationIssues_withCodeSystemOutcomeForInvalidCode_returnsAsExpected() {
+ IBaseOperationOutcome outcome = getCodeSystemInvalidCodeOutcome();
+ FhirVersionEnum versionEnum = getService().getFhirContext().getVersion().getVersion();
+ Optional> issuesOptional = createCodeValidationIssues(outcome, versionEnum);
+ assertThat(issuesOptional).isPresent();
+ assertThat(issuesOptional.get()).hasSize(1);
+ IValidationSupport.CodeValidationIssue issue = issuesOptional.get().iterator().next();
+ assertThat(issue.getType().getCode()).isEqualTo("code-invalid");
+ assertThat(issue.getSeverity().getCode()).isEqualTo("error");
+ assertThat(issue.getDetails().getCodings()).hasSize(1);
+ IValidationSupport.CodeValidationIssueCoding issueCoding = issue.getDetails().getCodings().get(0);
+ assertThat(issueCoding.getSystem()).isEqualTo("http://hl7.org/fhir/tools/CodeSystem/tx-issue-type");
+ assertThat(issueCoding.getCode()).isEqualTo("invalid-code");
+ assertThat(issue.getDetails().getText()).isEqualTo("Unknown code 'CODE' in the CodeSystem 'http://code.system/url' version '1.0.0'");
+ assertThat(issue.getDiagnostics()).isNull();
+ }
+
+ @Test
+ default void createCodeValidationIssues_withValueSetOutcomeForInvalidCode_returnsAsExpected() {
+ IBaseOperationOutcome outcome = getValueSetInvalidCodeOutcome();
+ FhirVersionEnum versionEnum = getService().getFhirContext().getVersion().getVersion();
+ Optional> issuesOptional = createCodeValidationIssues(outcome, versionEnum);
+ assertThat(issuesOptional).isPresent();
+ assertThat(issuesOptional.get()).hasSize(2);
+ IValidationSupport.CodeValidationIssue issue = issuesOptional.get().iterator().next();
+ assertThat(issue.getType().getCode()).isEqualTo("code-invalid");
+ assertThat(issue.getSeverity().getCode()).isEqualTo("error");
+ assertThat(issue.getDetails().getCodings()).hasSize(1);
+ IValidationSupport.CodeValidationIssueCoding issueCoding = issue.getDetails().getCodings().get(0);
+ assertThat(issueCoding.getSystem()).isEqualTo("http://hl7.org/fhir/tools/CodeSystem/tx-issue-type");
+ assertThat(issueCoding.getCode()).isEqualTo("not-in-vs");
+ assertThat(issue.getDetails().getText()).isEqualTo("The provided code 'http://code.system/url#CODE' was not found in the value set 'http://value.set/url%7C1.0.0'");
+ assertThat(issue.getDiagnostics()).isNull();
+ }
+
+ @Test
+ default void createCodeValidationIssues_withValueSetOutcomeWithCustomDetailCode_returnsAsExpected() {
+ IBaseOperationOutcome outcome = getValueSetCustomDetailCodeOutcome();
+ FhirVersionEnum versionEnum = getService().getFhirContext().getVersion().getVersion();
+ Optional> issuesOptional = createCodeValidationIssues(outcome, versionEnum);
+ assertThat(issuesOptional).isPresent();
+ assertThat(issuesOptional.get()).hasSize(1);
+ IValidationSupport.CodeValidationIssue issue = issuesOptional.get().iterator().next();
+ assertThat(issue.getType().getCode()).isEqualTo("processing");
+ assertThat(issue.getSeverity().getCode()).isEqualTo("information");
+ assertThat(issue.getDetails().getCodings()).hasSize(1);
+ IValidationSupport.CodeValidationIssueCoding issueCoding = issue.getDetails().getCodings().get(0);
+ assertThat(issueCoding.getSystem()).isEqualTo("http://example.com/custom-issue-type");
+ assertThat(issueCoding.getCode()).isEqualTo("valueset-is-draft");
+ assertThat(issue.getDetails().getText()).isNull();
+ assertThat(issue.getDiagnostics()).isEqualTo("The ValueSet status is marked as draft.");
+ }
}
diff --git a/hapi-fhir-validation/src/test/java/org/hl7/fhir/common/hapi/validation/IValidateCodeTest.java b/hapi-fhir-validation/src/test/java/org/hl7/fhir/common/hapi/validation/IValidateCodeTest.java
index 52dbf1177a8..53411b440fe 100644
--- a/hapi-fhir-validation/src/test/java/org/hl7/fhir/common/hapi/validation/IValidateCodeTest.java
+++ b/hapi-fhir-validation/src/test/java/org/hl7/fhir/common/hapi/validation/IValidateCodeTest.java
@@ -4,6 +4,9 @@ import ca.uhn.fhir.context.support.IValidationSupport;
import ca.uhn.fhir.context.support.IValidationSupport.CodeValidationResult;
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
+import ca.uhn.fhir.test.utilities.validation.IValidationProviders;
+import ca.uhn.fhir.util.ClasspathUtil;
+import org.hl7.fhir.dstu3.model.OperationOutcome;
import org.hl7.fhir.instance.model.api.IBaseOperationOutcome;
import org.hl7.fhir.instance.model.api.IBaseParameters;
import org.hl7.fhir.instance.model.api.IBaseResource;
@@ -16,12 +19,13 @@ import java.util.List;
import java.util.stream.Stream;
import static ca.uhn.fhir.context.support.IValidationSupport.IssueSeverity.ERROR;
-import static org.hl7.fhir.common.hapi.validation.IValidationProviders.CODE;
-import static org.hl7.fhir.common.hapi.validation.IValidationProviders.CODE_SYSTEM;
-import static org.hl7.fhir.common.hapi.validation.IValidationProviders.CODE_SYSTEM_VERSION;
-import static org.hl7.fhir.common.hapi.validation.IValidationProviders.DISPLAY;
-import static org.hl7.fhir.common.hapi.validation.IValidationProviders.ERROR_MESSAGE;
-import static org.hl7.fhir.common.hapi.validation.IValidationProviders.VALUE_SET_URL;
+import static ca.uhn.fhir.jpa.model.util.JpaConstants.OPERATION_VALIDATE_CODE;
+import static ca.uhn.fhir.test.utilities.validation.IValidationProviders.CODE;
+import static ca.uhn.fhir.test.utilities.validation.IValidationProviders.CODE_SYSTEM;
+import static ca.uhn.fhir.test.utilities.validation.IValidationProviders.CODE_SYSTEM_VERSION;
+import static ca.uhn.fhir.test.utilities.validation.IValidationProviders.DISPLAY;
+import static ca.uhn.fhir.test.utilities.validation.IValidationProviders.ERROR_MESSAGE;
+import static ca.uhn.fhir.test.utilities.validation.IValidationProviders.VALUE_SET_URL;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
@@ -31,21 +35,35 @@ import static org.junit.jupiter.api.Assertions.fail;
public interface IValidateCodeTest {
- IValidationProviders.IMyCodeSystemProvider getCodeSystemProvider();
- IValidationProviders.IMyValueSetProvider getValueSetProvider();
+ IValidationProviders.IMyValidationProvider getCodeSystemProvider();
+ IValidationProviders.IMyValidationProvider getValueSetProvider();
IValidationSupport getService();
IBaseParameters createParameters(Boolean theResult, String theDisplay, String theMessage, IBaseResource theIssuesResource);
String getCodeSystemError();
String getValueSetError();
IBaseOperationOutcome getCodeSystemInvalidCodeOutcome();
IBaseOperationOutcome getValueSetInvalidCodeOutcome();
+ IBaseOperationOutcome getValueSetCustomDetailCodeOutcome();
+
+ default IBaseOperationOutcome getCodeSystemInvalidCodeOutcome(Class extends IBaseOperationOutcome> theResourceClass) {
+ return getOutcome(theResourceClass, "/terminology/OperationOutcome-CodeSystem-invalid-code.json");
+ }
+ default IBaseOperationOutcome getValueSetInvalidCodeOutcome(Class extends IBaseOperationOutcome> theResourceClass) {
+ return getOutcome(theResourceClass, "/terminology/OperationOutcome-ValueSet-invalid-code.json");
+ }
+ default IBaseOperationOutcome getValueSetCustomDetailCodeOutcome(Class extends IBaseOperationOutcome> theResourceClass) {
+ return getOutcome(theResourceClass, "/terminology/OperationOutcome-ValueSet-custom-issue-detail.json");
+ }
+ default IBaseOperationOutcome getOutcome(Class extends IBaseOperationOutcome> theResourceClass, String theFile) {
+ return ClasspathUtil.loadResource(getService().getFhirContext(), theResourceClass, theFile);
+ }
default void createCodeSystemReturnParameters(Boolean theResult, String theDisplay, String theMessage, IBaseResource theIssuesResource) {
- getCodeSystemProvider().setReturnParams(createParameters(theResult, theDisplay, theMessage, theIssuesResource));
+ getCodeSystemProvider().addTerminologyResponse(OPERATION_VALIDATE_CODE, CODE_SYSTEM, CODE, createParameters(theResult, theDisplay, theMessage, theIssuesResource));
}
default void createValueSetReturnParameters(Boolean theResult, String theDisplay, String theMessage, IBaseResource theIssuesResource) {
- getValueSetProvider().setReturnParams(createParameters(theResult, theDisplay, theMessage, theIssuesResource));
+ getValueSetProvider().addTerminologyResponse(OPERATION_VALIDATE_CODE, VALUE_SET_URL, CODE, createParameters(theResult, theDisplay, theMessage, theIssuesResource));
}
@Test
@@ -91,8 +109,8 @@ public interface IValidateCodeTest {
String theValidationMessage,
String theCodeSystem,
String theValueSetUrl) {
- getCodeSystemProvider().setException(theException);
- getValueSetProvider().setException(theException);
+ getCodeSystemProvider().addException(OPERATION_VALIDATE_CODE, theCodeSystem, CODE, theException);
+ getValueSetProvider().addException(OPERATION_VALIDATE_CODE, theValueSetUrl, CODE, theException);
CodeValidationResult outcome = getService().validateCode(null, null, theCodeSystem, CODE, DISPLAY, theValueSetUrl);
verifyErrorResultFromException(outcome, theValidationMessage, theServerMessage);
@@ -105,7 +123,7 @@ public interface IValidateCodeTest {
for (String message : theMessages) {
assertTrue(outcome.getMessage().contains(message));
}
- assertFalse(outcome.getCodeValidationIssues().isEmpty());
+ assertFalse(outcome.getIssues().isEmpty());
}
@Test
@@ -130,11 +148,7 @@ public interface IValidateCodeTest {
assertEquals(DISPLAY, outcome.getDisplay());
assertNull(outcome.getSeverity());
assertNull(outcome.getMessage());
- assertTrue(outcome.getCodeValidationIssues().isEmpty());
-
- assertEquals(CODE, getValueSetProvider().getCode());
- assertEquals(DISPLAY, getValueSetProvider().getDisplay());
- assertEquals(VALUE_SET_URL, getValueSetProvider().getValueSet());
+ assertTrue(outcome.getIssues().isEmpty());
}
@Test
@@ -147,9 +161,7 @@ public interface IValidateCodeTest {
assertEquals(DISPLAY, outcome.getDisplay());
assertNull(outcome.getSeverity());
assertNull(outcome.getMessage());
- assertTrue(outcome.getCodeValidationIssues().isEmpty());
-
- assertEquals(CODE, getCodeSystemProvider().getCode());
+ assertTrue(outcome.getIssues().isEmpty());
}
@Test
@@ -165,10 +177,7 @@ public interface IValidateCodeTest {
assertNull(outcome.getDisplay());
assertNull(outcome.getSeverity());
assertNull(outcome.getMessage());
- assertTrue(outcome.getCodeValidationIssues().isEmpty());
-
- assertEquals(CODE, getCodeSystemProvider().getCode());
- assertEquals(CODE_SYSTEM, getCodeSystemProvider().getSystem());
+ assertTrue(outcome.getIssues().isEmpty());
}
@Test
@@ -184,15 +193,11 @@ public interface IValidateCodeTest {
assertEquals(DISPLAY, outcome.getDisplay());
assertNull(outcome.getSeverity());
assertNull(outcome.getMessage());
- assertTrue(outcome.getCodeValidationIssues().isEmpty());
-
- assertEquals(CODE, getCodeSystemProvider().getCode());
- assertEquals(DISPLAY, getCodeSystemProvider().getDisplay());
- assertEquals(CODE_SYSTEM, getCodeSystemProvider().getSystem());
+ assertTrue(outcome.getIssues().isEmpty());
}
@Test
- default void validateCode_withCodeSystemError_returnsCorrectly() {
+ default void validateCode_withCodeSystemErrorWithDiagnosticsWithIssues_returnsCorrectly() {
IBaseOperationOutcome invalidCodeOutcome = getCodeSystemInvalidCodeOutcome();
createCodeSystemReturnParameters(false, null, ERROR_MESSAGE, invalidCodeOutcome);
@@ -204,12 +209,12 @@ public interface IValidateCodeTest {
// assertEquals(CODE, outcome.getCode());
assertEquals(ERROR, outcome.getSeverity());
assertEquals(getCodeSystemError(), outcome.getMessage());
- assertFalse(outcome.getCodeValidationIssues().isEmpty());
+ assertFalse(outcome.getIssues().isEmpty());
verifyIssues(invalidCodeOutcome, outcome);
}
@Test
- default void validateCode_withCodeSystemErrorAndIssues_returnsCorrectly() {
+ default void validateCode_withCodeSystemErrorWithDiagnosticsWithoutIssues_returnsCorrectly() {
createCodeSystemReturnParameters(false, null, ERROR_MESSAGE, null);
CodeValidationResult outcome = getService()
@@ -223,10 +228,32 @@ public interface IValidateCodeTest {
assertNull(outcome.getDisplay());
assertEquals(ERROR, outcome.getSeverity());
assertEquals(expectedError, outcome.getMessage());
- assertFalse(outcome.getCodeValidationIssues().isEmpty());
- assertEquals(1, outcome.getCodeValidationIssues().size());
- assertEquals(expectedError, outcome.getCodeValidationIssues().get(0).getMessage());
- assertEquals(ERROR, outcome.getCodeValidationIssues().get(0).getSeverity());
+ assertFalse(outcome.getIssues().isEmpty());
+ assertEquals(1, outcome.getIssues().size());
+ assertEquals(expectedError, outcome.getIssues().get(0).getDiagnostics());
+ assertEquals(ERROR, outcome.getIssues().get(0).getSeverity());
+ }
+
+ @Test
+ default void validateCode_withCodeSystemErrorWithoutDiagnosticsWithIssues_returnsCorrectly() {
+ IBaseOperationOutcome invalidCodeOutcome = getCodeSystemInvalidCodeOutcome();
+ createCodeSystemReturnParameters(false, null, null, invalidCodeOutcome);
+
+ CodeValidationResult outcome = getService()
+ .validateCode(null, null, CODE_SYSTEM, CODE, null, null);
+
+ String expectedError = getCodeSystemError();
+ assertNotNull(outcome);
+ assertEquals(CODE_SYSTEM, outcome.getCodeSystemName());
+ assertEquals(CODE_SYSTEM_VERSION, outcome.getCodeSystemVersion());
+ // assertEquals(CODE, outcome.getCode());
+ assertNull(outcome.getDisplay());
+ assertEquals(ERROR, outcome.getSeverity());
+ assertNull(outcome.getMessage());
+ assertFalse(outcome.getIssues().isEmpty());
+ assertEquals(1, outcome.getIssues().size());
+ assertNull(outcome.getIssues().get(0).getDiagnostics());
+ assertEquals(ERROR, outcome.getIssues().get(0).getSeverity());
}
@Test
@@ -242,10 +269,7 @@ public interface IValidateCodeTest {
assertNull(outcome.getDisplay());
assertNull(outcome.getSeverity());
assertNull(outcome.getMessage());
- assertTrue(outcome.getCodeValidationIssues().isEmpty());
-
- assertEquals(CODE, getValueSetProvider().getCode());
- assertEquals(VALUE_SET_URL, getValueSetProvider().getValueSet());
+ assertTrue(outcome.getIssues().isEmpty());
}
@Test
@@ -261,11 +285,7 @@ public interface IValidateCodeTest {
assertEquals(DISPLAY, outcome.getDisplay());
assertNull(outcome.getSeverity());
assertNull(outcome.getMessage());
- assertTrue(outcome.getCodeValidationIssues().isEmpty());
-
- assertEquals(CODE, getValueSetProvider().getCode());
- assertEquals(DISPLAY, getValueSetProvider().getDisplay());
- assertEquals(VALUE_SET_URL, getValueSetProvider().getValueSet());
+ assertTrue(outcome.getIssues().isEmpty());
}
@Test
@@ -283,13 +303,9 @@ public interface IValidateCodeTest {
assertEquals(DISPLAY, outcome.getDisplay());
assertEquals(ERROR, outcome.getSeverity());
assertEquals(expectedError, outcome.getMessage());
- assertEquals(1, outcome.getCodeValidationIssues().size());
- assertEquals(expectedError, outcome.getCodeValidationIssues().get(0).getMessage());
- assertEquals(ERROR, outcome.getCodeValidationIssues().get(0).getSeverity());
-
- assertEquals(CODE, getValueSetProvider().getCode());
- assertEquals(DISPLAY, getValueSetProvider().getDisplay());
- assertEquals(VALUE_SET_URL, getValueSetProvider().getValueSet());
+ assertEquals(1, outcome.getIssues().size());
+ assertEquals(expectedError, outcome.getIssues().get(0).getDiagnostics());
+ assertEquals(ERROR, outcome.getIssues().get(0).getSeverity());
}
@Test
@@ -306,24 +322,28 @@ public interface IValidateCodeTest {
assertEquals(DISPLAY, outcome.getDisplay());
assertEquals(ERROR, outcome.getSeverity());
assertEquals(getValueSetError(), outcome.getMessage());
- assertFalse(outcome.getCodeValidationIssues().isEmpty());
+ assertFalse(outcome.getIssues().isEmpty());
verifyIssues(invalidCodeOutcome, outcome);
-
- assertEquals(CODE, getValueSetProvider().getCode());
- assertEquals(DISPLAY, getValueSetProvider().getDisplay());
- assertEquals(VALUE_SET_URL, getValueSetProvider().getValueSet());
}
default void verifyIssues(IBaseOperationOutcome theOperationOutcome, CodeValidationResult theResult) {
List issues = getCodeValidationIssues(theOperationOutcome);
- assertEquals(issues.size(), theResult.getCodeValidationIssues().size());
+ assertEquals(issues.size(), theResult.getIssues().size());
for (int i = 0; i < issues.size(); i++) {
IValidationSupport.CodeValidationIssue expectedIssue = issues.get(i);
- IValidationSupport.CodeValidationIssue actualIssue = theResult.getCodeValidationIssues().get(i);
- assertEquals(expectedIssue.getCode(), actualIssue.getCode());
+ IValidationSupport.CodeValidationIssue actualIssue = theResult.getIssues().get(i);
+ assertEquals(expectedIssue.getType().getCode(), actualIssue.getType().getCode());
assertEquals(expectedIssue.getSeverity(), actualIssue.getSeverity());
- assertEquals(expectedIssue.getCoding(), actualIssue.getCoding());
- assertEquals(expectedIssue.getMessage(), actualIssue.getMessage());
+ assertEquals(expectedIssue.getDetails().getText(), actualIssue.getDetails().getText());
+ assertEquals(expectedIssue.getDetails().getCodings().size(), actualIssue.getDetails().getCodings().size());
+ for (int index = 0; index < expectedIssue.getDetails().getCodings().size(); index++) {
+ IValidationSupport.CodeValidationIssueCoding expectedCoding = expectedIssue.getDetails().getCodings().get(index);
+ IValidationSupport.CodeValidationIssueCoding actualCoding = actualIssue.getDetails().getCodings().get(index);
+ assertEquals(expectedCoding.getSystem(), actualCoding.getSystem());
+ assertEquals(expectedCoding.getCode(), actualCoding.getCode());
+ }
+ assertEquals(expectedIssue.getDetails().getText(), actualIssue.getDetails().getText());
+ assertEquals(expectedIssue.getDiagnostics(), actualIssue.getDiagnostics());
}
}
diff --git a/hapi-fhir-validation/src/test/java/org/hl7/fhir/common/hapi/validation/IValidationProviders.java b/hapi-fhir-validation/src/test/java/org/hl7/fhir/common/hapi/validation/IValidationProviders.java
deleted file mode 100644
index 1537f8e5c00..00000000000
--- a/hapi-fhir-validation/src/test/java/org/hl7/fhir/common/hapi/validation/IValidationProviders.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package org.hl7.fhir.common.hapi.validation;
-
-import ca.uhn.fhir.context.support.IValidationSupport;
-import ca.uhn.fhir.rest.server.IResourceProvider;
-import org.hl7.fhir.instance.model.api.IBaseParameters;
-
-public interface IValidationProviders {
- String CODE_SYSTEM = "http://code.system/url";
- String CODE_SYSTEM_VERSION = "1.0.0";
- String CODE_SYSTEM_NAME = "Test Code System";
- String CODE = "CODE";
- String VALUE_SET_URL = "http://value.set/url";
- String DISPLAY = "Explanation for code TestCode.";
- String LANGUAGE = "en";
- String ERROR_MESSAGE = "This is an error message";
-
- interface IMyCodeSystemProvider extends IResourceProvider {
- String getCode();
- String getSystem();
- String getDisplay();
- void setException(Exception theException);
- void setReturnParams(IBaseParameters theParameters);
- }
-
- interface IMyLookupCodeProvider extends IResourceProvider {
- String getCode();
- String getSystem();
- void setLookupCodeResult(IValidationSupport.LookupCodeResult theLookupCodeResult);
- }
-
- interface IMyValueSetProvider extends IResourceProvider {
- String getCode();
- String getSystem();
- String getDisplay();
- String getValueSet();
- void setException(Exception theException);
- void setReturnParams(IBaseParameters theParameters);
- }
-}
diff --git a/hapi-fhir-validation/src/test/java/org/hl7/fhir/common/hapi/validation/validator/VersionSpecificWorkerContextWrapperTest.java b/hapi-fhir-validation/src/test/java/org/hl7/fhir/common/hapi/validation/validator/VersionSpecificWorkerContextWrapperTest.java
index 57aae8d96f9..cbc79fadc98 100644
--- a/hapi-fhir-validation/src/test/java/org/hl7/fhir/common/hapi/validation/validator/VersionSpecificWorkerContextWrapperTest.java
+++ b/hapi-fhir-validation/src/test/java/org/hl7/fhir/common/hapi/validation/validator/VersionSpecificWorkerContextWrapperTest.java
@@ -7,7 +7,6 @@ import ca.uhn.fhir.context.support.ValidationSupportContext;
import ca.uhn.fhir.fhirpath.BaseValidationTestWithInlineMocks;
import ca.uhn.fhir.i18n.HapiLocalizer;
import ca.uhn.hapi.converters.canonical.VersionCanonicalizer;
-
import org.hl7.fhir.r5.model.Resource;
import org.hl7.fhir.r5.model.StructureDefinition;
import org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionKind;
@@ -16,17 +15,18 @@ import org.hl7.fhir.utilities.validation.ValidationOptions;
import org.junit.jupiter.api.Test;
import org.mockito.quality.Strictness;
+import java.util.List;
+
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.withSettings;
-import java.util.List;
-
public class VersionSpecificWorkerContextWrapperTest extends BaseValidationTestWithInlineMocks {
final byte[] EXPECTED_BINARY_CONTENT_1 = "dummyBinaryContent1".getBytes();
@@ -80,7 +80,7 @@ public class VersionSpecificWorkerContextWrapperTest extends BaseValidationTestW
}
@Test
- public void validateCode_normally_resolvesCodeSystemFromValueSet() {
+ public void validateCode_codeInValueSet_resolvesCodeSystemFromValueSet() {
// setup
IValidationSupport validationSupport = mockValidationSupport();
ValidationSupportContext mockContext = mockValidationSupportContext(validationSupport);
@@ -90,8 +90,7 @@ public class VersionSpecificWorkerContextWrapperTest extends BaseValidationTestW
ValueSet valueSet = new ValueSet();
valueSet.getCompose().addInclude().setSystem("http://codesystems.com/system").addConcept().setCode("code0");
valueSet.getCompose().addInclude().setSystem("http://codesystems.com/system2").addConcept().setCode("code2");
- when(validationSupport.fetchResource(eq(ValueSet.class), eq("http://somevalueset"))).thenReturn(valueSet);
- when(validationSupport.validateCodeInValueSet(any(), any(), any(), any(), any(), any())).thenReturn(new IValidationSupport.CodeValidationResult());
+ when(validationSupport.validateCodeInValueSet(any(), any(), any(), any(), any(), any())).thenReturn(mock(IValidationSupport.CodeValidationResult.class));
// execute
wrapper.validateCode(new ValidationOptions(), "code0", valueSet);
@@ -101,6 +100,26 @@ public class VersionSpecificWorkerContextWrapperTest extends BaseValidationTestW
verify(validationSupport, times(1)).validateCode(any(), any(), eq("http://codesystems.com/system"), eq("code0"), any(), any());
}
+ @Test
+ public void validateCode_codeNotInValueSet_doesNotResolveSystem() {
+ // setup
+ IValidationSupport validationSupport = mockValidationSupport();
+ ValidationSupportContext mockContext = mockValidationSupportContext(validationSupport);
+ VersionCanonicalizer versionCanonicalizer = new VersionCanonicalizer(FhirContext.forR5Cached());
+ VersionSpecificWorkerContextWrapper wrapper = new VersionSpecificWorkerContextWrapper(mockContext, versionCanonicalizer);
+
+ ValueSet valueSet = new ValueSet();
+ valueSet.getCompose().addInclude().setSystem("http://codesystems.com/system").addConcept().setCode("code0");
+ valueSet.getCompose().addInclude().setSystem("http://codesystems.com/system2").addConcept().setCode("code2");
+
+ // execute
+ wrapper.validateCode(new ValidationOptions(), "code1", valueSet);
+
+ // verify
+ verify(validationSupport, times(1)).validateCodeInValueSet(any(), any(), eq(null), eq("code1"), any(), any());
+ verify(validationSupport, never()).validateCode(any(), any(), any(), any(), any(), any());
+ }
+
@Test
public void isPrimitive_primitive() {
// setup
diff --git a/hapi-fhir-validation/src/test/java/org/hl7/fhir/dstu2/hapi/validation/FhirInstanceValidatorDstu2Test.java b/hapi-fhir-validation/src/test/java/org/hl7/fhir/dstu2/hapi/validation/FhirInstanceValidatorDstu2Test.java
index da73c0be800..5a53ba0ac3d 100644
--- a/hapi-fhir-validation/src/test/java/org/hl7/fhir/dstu2/hapi/validation/FhirInstanceValidatorDstu2Test.java
+++ b/hapi-fhir-validation/src/test/java/org/hl7/fhir/dstu2/hapi/validation/FhirInstanceValidatorDstu2Test.java
@@ -4,7 +4,6 @@ import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.context.support.ConceptValidationOptions;
import ca.uhn.fhir.context.support.DefaultProfileValidationSupport;
import ca.uhn.fhir.context.support.IValidationSupport;
-import ca.uhn.fhir.context.support.ValidationSupportContext;
import ca.uhn.fhir.fhirpath.BaseValidationTestWithInlineMocks;
import ca.uhn.fhir.model.dstu2.composite.PeriodDt;
import ca.uhn.fhir.model.dstu2.resource.Parameters;
@@ -28,10 +27,7 @@ import org.hl7.fhir.dstu2.model.Observation.ObservationStatus;
import org.hl7.fhir.dstu2.model.QuestionnaireResponse;
import org.hl7.fhir.dstu2.model.QuestionnaireResponse.QuestionnaireResponseStatus;
import org.hl7.fhir.dstu2.model.StringType;
-import org.hl7.fhir.dstu3.model.CodeSystem;
-import org.hl7.fhir.utilities.validation.ValidationMessage;
import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
@@ -41,9 +37,7 @@ import org.mockito.stubbing.Answer;
import java.io.IOException;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.HashSet;
-import java.util.Optional;
import java.util.Set;
import static org.assertj.core.api.Assertions.assertThat;
@@ -100,7 +94,7 @@ public class FhirInstanceValidatorDstu2Test extends BaseValidationTestWithInline
if (myValidConcepts.contains(system + "___" + code)) {
retVal = new IValidationSupport.CodeValidationResult().setCode(code);
} else if (myValidSystems.contains(system)) {
- return new IValidationSupport.CodeValidationResult().setSeverityCode(ValidationMessage.IssueSeverity.ERROR.toCode()).setMessage("Unknown code");
+ return new IValidationSupport.CodeValidationResult().setSeverity(IValidationSupport.IssueSeverity.ERROR).setMessage("Unknown code");
} else {
retVal = null;
}
diff --git a/hapi-fhir-validation/src/test/java/org/hl7/fhir/dstu3/hapi/validation/FhirInstanceValidatorDstu3Test.java b/hapi-fhir-validation/src/test/java/org/hl7/fhir/dstu3/hapi/validation/FhirInstanceValidatorDstu3Test.java
index ad6276f2761..cfbeca68626 100644
--- a/hapi-fhir-validation/src/test/java/org/hl7/fhir/dstu3/hapi/validation/FhirInstanceValidatorDstu3Test.java
+++ b/hapi-fhir-validation/src/test/java/org/hl7/fhir/dstu3/hapi/validation/FhirInstanceValidatorDstu3Test.java
@@ -58,7 +58,6 @@ import org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.r5.utils.validation.IValidationPolicyAdvisor;
import org.hl7.fhir.r5.utils.validation.IValidatorResourceFetcher;
import org.hl7.fhir.r5.utils.validation.constants.ReferenceValidationPolicy;
-import org.hl7.fhir.utilities.validation.ValidationMessage;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
@@ -229,10 +228,10 @@ public class FhirInstanceValidatorDstu3Test extends BaseValidationTestWithInline
retVal = new IValidationSupport.CodeValidationResult().setCode(code);
} else if (myValidSystems.contains(system)) {
final String message = "Unknown code (for '" + system + "#" + code + "')";
- retVal = new IValidationSupport.CodeValidationResult().setSeverityCode(ValidationMessage.IssueSeverity.ERROR.toCode()).setMessage(message).setCodeValidationIssues(Collections.singletonList(new IValidationSupport.CodeValidationIssue(message, IValidationSupport.IssueSeverity.ERROR, IValidationSupport.CodeValidationIssueCode.CODE_INVALID, IValidationSupport.CodeValidationIssueCoding.INVALID_CODE)));
+ retVal = new IValidationSupport.CodeValidationResult().setSeverity(IValidationSupport.IssueSeverity.ERROR).setMessage(message).setIssues(Collections.singletonList(new IValidationSupport.CodeValidationIssue(message, IValidationSupport.IssueSeverity.ERROR, IValidationSupport.CodeValidationIssueCode.CODE_INVALID, IValidationSupport.CodeValidationIssueCoding.INVALID_CODE)));
} else if (myValidSystemsNotReturningIssues.contains(system)) {
final String message = "Unknown code (for '" + system + "#" + code + "')";
- retVal = new IValidationSupport.CodeValidationResult().setSeverityCode(ValidationMessage.IssueSeverity.ERROR.toCode()).setMessage(message);
+ retVal = new IValidationSupport.CodeValidationResult().setSeverity(IValidationSupport.IssueSeverity.ERROR).setMessage(message);
} else if (myCodeSystems.containsKey(system)) {
CodeSystem cs = myCodeSystems.get(system);
Optional found = cs.getConcept().stream().filter(t -> t.getCode().equals(code)).findFirst();
diff --git a/hapi-fhir-validation/src/test/java/org/hl7/fhir/dstu3/hapi/validation/IValidateCodeProvidersDstu3.java b/hapi-fhir-validation/src/test/java/org/hl7/fhir/dstu3/hapi/validation/IValidateCodeProvidersDstu3.java
deleted file mode 100644
index 0c639e310ee..00000000000
--- a/hapi-fhir-validation/src/test/java/org/hl7/fhir/dstu3/hapi/validation/IValidateCodeProvidersDstu3.java
+++ /dev/null
@@ -1,159 +0,0 @@
-package org.hl7.fhir.dstu3.hapi.validation;
-
-import ca.uhn.fhir.jpa.model.util.JpaConstants;
-import ca.uhn.fhir.rest.annotation.IdParam;
-import ca.uhn.fhir.rest.annotation.Operation;
-import ca.uhn.fhir.rest.annotation.OperationParam;
-import ca.uhn.fhir.rest.api.server.RequestDetails;
-import jakarta.servlet.http.HttpServletRequest;
-import org.hl7.fhir.common.hapi.validation.IValidationProviders;
-import org.hl7.fhir.dstu3.model.BooleanType;
-import org.hl7.fhir.dstu3.model.CodeSystem;
-import org.hl7.fhir.dstu3.model.CodeType;
-import org.hl7.fhir.dstu3.model.Coding;
-import org.hl7.fhir.dstu3.model.IdType;
-import org.hl7.fhir.dstu3.model.Parameters;
-import org.hl7.fhir.dstu3.model.StringType;
-import org.hl7.fhir.dstu3.model.UriType;
-import org.hl7.fhir.dstu3.model.ValueSet;
-import org.hl7.fhir.instance.model.api.IBaseParameters;
-import org.hl7.fhir.instance.model.api.IBaseResource;
-
-import java.util.List;
-
-public interface IValidateCodeProvidersDstu3 {
- @SuppressWarnings("unused")
- class MyCodeSystemProviderDstu3 implements IValidationProviders.IMyCodeSystemProvider {
- private UriType mySystemUrl;
- private CodeType myCode;
- private StringType myDisplay;
- private Exception myException;
- private Parameters myReturnParams;
-
- @Operation(name = "validate-code", idempotent = true, returnParameters = {
- @OperationParam(name = "result", type = org.hl7.fhir.dstu3.model.BooleanType.class, min = 1),
- @OperationParam(name = "message", type = org.hl7.fhir.dstu3.model.StringType.class),
- @OperationParam(name = "display", type = org.hl7.fhir.dstu3.model.StringType.class)
- })
- public org.hl7.fhir.dstu3.model.Parameters validateCode(
- HttpServletRequest theServletRequest,
- @IdParam(optional = true) org.hl7.fhir.dstu3.model.IdType theId,
- @OperationParam(name = "url", min = 0, max = 1) org.hl7.fhir.dstu3.model.UriType theCodeSystemUrl,
- @OperationParam(name = "code", min = 0, max = 1) org.hl7.fhir.dstu3.model.CodeType theCode,
- @OperationParam(name = "display", min = 0, max = 1) org.hl7.fhir.dstu3.model.StringType theDisplay
- ) throws Exception {
- mySystemUrl = theCodeSystemUrl;
- myCode = theCode;
- myDisplay = theDisplay;
- if (myException != null) {
- throw myException;
- }
- return myReturnParams;
- }
-
- @Operation(name = JpaConstants.OPERATION_LOOKUP, idempotent = true, returnParameters= {
- @OperationParam(name = "name", type = org.hl7.fhir.dstu3.model.StringType.class, min = 1),
- @OperationParam(name = "version", type = org.hl7.fhir.dstu3.model.StringType.class),
- @OperationParam(name = "display", type = org.hl7.fhir.dstu3.model.StringType.class, min = 1),
- @OperationParam(name = "abstract", type = org.hl7.fhir.dstu3.model.BooleanType.class, min = 1),
- @OperationParam(name = "property", type = org.hl7.fhir.dstu3.model.StringType.class, min = 0, max = OperationParam.MAX_UNLIMITED)
- })
- public IBaseParameters lookup(
- HttpServletRequest theServletRequest,
- @OperationParam(name = "code", max = 1) org.hl7.fhir.dstu3.model.CodeType theCode,
- @OperationParam(name = "system",max = 1) org.hl7.fhir.dstu3.model.UriType theSystem,
- @OperationParam(name = "coding", max = 1) Coding theCoding,
- @OperationParam(name = "version", max = 1) org.hl7.fhir.dstu3.model.StringType theVersion,
- @OperationParam(name = "displayLanguage", max = 1) org.hl7.fhir.dstu3.model.CodeType theDisplayLanguage,
- @OperationParam(name = "property", max = OperationParam.MAX_UNLIMITED) List thePropertyNames,
- RequestDetails theRequestDetails
- ) {
- myCode = theCode;
- return myReturnParams;
- }
-
- @Override
- public Class extends IBaseResource> getResourceType() {
- return CodeSystem.class;
- }
-
- public void setException(Exception theException) {
- myException = theException;
- }
- @Override
- public void setReturnParams(IBaseParameters theParameters) {
- myReturnParams = (Parameters) theParameters;
- }
- @Override
- public String getCode() {
- return myCode != null ? myCode.getValueAsString() : null;
- }
- @Override
- public String getSystem() {
- return mySystemUrl != null ? mySystemUrl.getValueAsString() : null;
- }
- public String getDisplay() {
- return myDisplay != null ? myDisplay.getValue() : null;
- }
- }
-
- @SuppressWarnings("unused")
- class MyValueSetProviderDstu3 implements IValidationProviders.IMyValueSetProvider {
- private Exception myException;
- private Parameters myReturnParams;
- private UriType mySystemUrl;
- private UriType myValueSetUrl;
- private CodeType myCode;
- private StringType myDisplay;
-
- @Operation(name = "validate-code", idempotent = true, returnParameters = {
- @OperationParam(name = "result", type = BooleanType.class, min = 1),
- @OperationParam(name = "message", type = org.hl7.fhir.dstu3.model.StringType.class),
- @OperationParam(name = "display", type = org.hl7.fhir.dstu3.model.StringType.class)
- })
- public Parameters validateCode(
- HttpServletRequest theServletRequest,
- @IdParam(optional = true) IdType theId,
- @OperationParam(name = "url", min = 0, max = 1) org.hl7.fhir.dstu3.model.UriType theValueSetUrl,
- @OperationParam(name = "code", min = 0, max = 1) CodeType theCode,
- @OperationParam(name = "system", min = 0, max = 1) UriType theSystem,
- @OperationParam(name = "display", min = 0, max = 1) StringType theDisplay,
- @OperationParam(name = "valueSet") org.hl7.fhir.dstu3.model.ValueSet theValueSet
- ) throws Exception {
- mySystemUrl = theSystem;
- myValueSetUrl = theValueSetUrl;
- myCode = theCode;
- myDisplay = theDisplay;
- if (myException != null) {
- throw myException;
- }
- return myReturnParams;
- }
- @Override
- public Class extends IBaseResource> getResourceType() {
- return ValueSet.class;
- }
- public void setException(Exception theException) {
- myException = theException;
- }
- @Override
- public void setReturnParams(IBaseParameters theParameters) {
- myReturnParams = (Parameters) theParameters;
- }
- @Override
- public String getCode() {
- return myCode != null ? myCode.getValueAsString() : null;
- }
- @Override
- public String getSystem() {
- return mySystemUrl != null ? mySystemUrl.getValueAsString() : null;
- }
- @Override
- public String getValueSet() {
- return myValueSetUrl != null ? myValueSetUrl.getValueAsString() : null;
- }
- public String getDisplay() {
- return myDisplay != null ? myDisplay.getValue() : null;
- }
- }
-}
diff --git a/hapi-fhir-validation/src/test/java/org/hl7/fhir/dstu3/hapi/validation/QuestionnaireResponseValidatorDstu3Test.java b/hapi-fhir-validation/src/test/java/org/hl7/fhir/dstu3/hapi/validation/QuestionnaireResponseValidatorDstu3Test.java
index 7804b9df10f..57591b31e76 100644
--- a/hapi-fhir-validation/src/test/java/org/hl7/fhir/dstu3/hapi/validation/QuestionnaireResponseValidatorDstu3Test.java
+++ b/hapi-fhir-validation/src/test/java/org/hl7/fhir/dstu3/hapi/validation/QuestionnaireResponseValidatorDstu3Test.java
@@ -41,7 +41,6 @@ import org.hl7.fhir.dstu3.model.Type;
import org.hl7.fhir.dstu3.model.UriType;
import org.hl7.fhir.dstu3.model.ValueSet;
import org.hl7.fhir.instance.model.api.IBaseResource;
-import org.hl7.fhir.utilities.validation.ValidationMessage;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
@@ -56,6 +55,8 @@ import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
+import static ca.uhn.fhir.context.support.IValidationSupport.IssueSeverity.ERROR;
+import static ca.uhn.fhir.context.support.IValidationSupport.IssueSeverity.WARNING;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hl7.fhir.dstu3.model.Questionnaire.QuestionnaireItemType.BOOLEAN;
import static org.hl7.fhir.dstu3.model.Questionnaire.QuestionnaireItemType.CHOICE;
@@ -224,7 +225,7 @@ public class QuestionnaireResponseValidatorDstu3Test {
when(myValSupport.validateCodeInValueSet(any(), any(), eq("http://codesystems.com/system"), eq("code0"), any(), nullable(ValueSet.class)))
.thenReturn(new IValidationSupport.CodeValidationResult().setCode("code0"));
when(myValSupport.validateCodeInValueSet(any(), any(), eq("http://codesystems.com/system"), eq("code1"), any(), nullable(ValueSet.class)))
- .thenReturn(new IValidationSupport.CodeValidationResult().setSeverityCode(ValidationMessage.IssueSeverity.ERROR.toCode()).setMessage("Unknown code"));
+ .thenReturn(new IValidationSupport.CodeValidationResult().setSeverity(ERROR).setMessage("Unknown code"));
CodeSystem codeSystem = new CodeSystem();
codeSystem.setContent(CodeSystemContentMode.COMPLETE);
@@ -246,7 +247,7 @@ public class QuestionnaireResponseValidatorDstu3Test {
when(myValSupport.validateCode(any(), any(), eq("http://codesystems.com/system"), eq("code0"), any(), nullable(String.class)))
.thenReturn(new IValidationSupport.CodeValidationResult().setCode(CODE_ICC_SCHOOLTYPE_PT));
when(myValSupport.validateCode(any(), any(), eq("http://codesystems.com/system"), eq("code1"), any(), nullable(String.class)))
- .thenReturn(new IValidationSupport.CodeValidationResult().setSeverityCode("warning").setMessage("Unknown code: http://codesystems.com/system / code1"));
+ .thenReturn(new IValidationSupport.CodeValidationResult().setSeverity(WARNING).setMessage("Unknown code: http://codesystems.com/system / code1"));
QuestionnaireResponse qa;
@@ -1034,7 +1035,7 @@ public class QuestionnaireResponseValidatorDstu3Test {
when(myValSupport.validateCode(any(), any(), eq("http://codesystems.com/system"), eq("code0"), any(), nullable(String.class)))
.thenReturn(new IValidationSupport.CodeValidationResult().setCode("code0"));
when(myValSupport.validateCode(any(), any(), eq("http://codesystems.com/system"), eq("code1"), any(), nullable(String.class)))
- .thenReturn(new IValidationSupport.CodeValidationResult().setSeverityCode(ValidationMessage.IssueSeverity.ERROR.toCode()).setMessage("Unknown code"));
+ .thenReturn(new IValidationSupport.CodeValidationResult().setSeverity(ERROR).setMessage("Unknown code"));
CodeSystem codeSystem = new CodeSystem();
codeSystem.setContent(CodeSystemContentMode.COMPLETE);
diff --git a/hapi-fhir-validation/src/test/java/org/hl7/fhir/dstu3/hapi/validation/RemoteTerminologyLookupCodeDstu3Test.java b/hapi-fhir-validation/src/test/java/org/hl7/fhir/dstu3/hapi/validation/RemoteTerminologyLookupCodeDstu3Test.java
index 6e98c4b31a9..56bc892c3d4 100644
--- a/hapi-fhir-validation/src/test/java/org/hl7/fhir/dstu3/hapi/validation/RemoteTerminologyLookupCodeDstu3Test.java
+++ b/hapi-fhir-validation/src/test/java/org/hl7/fhir/dstu3/hapi/validation/RemoteTerminologyLookupCodeDstu3Test.java
@@ -12,9 +12,9 @@ import ca.uhn.fhir.rest.client.interceptor.LoggingInterceptor;
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
import ca.uhn.fhir.test.utilities.server.RestfulServerExtension;
+import ca.uhn.fhir.test.utilities.validation.IValidationProviders;
import jakarta.servlet.http.HttpServletRequest;
import org.hl7.fhir.common.hapi.validation.IRemoteTerminologyLookupCodeTest;
-import org.hl7.fhir.common.hapi.validation.IValidationProviders;
import org.hl7.fhir.common.hapi.validation.support.RemoteTerminologyServiceValidationSupport;
import org.hl7.fhir.dstu3.model.BooleanType;
import org.hl7.fhir.dstu3.model.CodeSystem;
@@ -164,8 +164,6 @@ public class RemoteTerminologyLookupCodeDstu3Test implements IRemoteTerminologyL
@SuppressWarnings("unused")
static class MyLookupCodeProviderDstu3 implements IValidationProviders.IMyLookupCodeProvider {
- private UriType mySystemUrl;
- private CodeType myCode;
private LookupCodeResult myLookupCodeResult;
@Override
@@ -190,8 +188,6 @@ public class RemoteTerminologyLookupCodeDstu3Test implements IRemoteTerminologyL
@OperationParam(name= " property", max = OperationParam.MAX_UNLIMITED) List thePropertyNames,
RequestDetails theRequestDetails
) {
- myCode = theCode;
- mySystemUrl = theSystem;
if (theSystem == null) {
throw new InvalidRequestException(MessageFormat.format(MESSAGE_RESPONSE_INVALID, theCode));
}
@@ -205,15 +201,5 @@ public class RemoteTerminologyLookupCodeDstu3Test implements IRemoteTerminologyL
public Class extends IBaseResource> getResourceType() {
return CodeSystem.class;
}
-
- @Override
- public String getCode() {
- return myCode != null ? myCode.getValueAsString() : null;
- }
-
- @Override
- public String getSystem() {
- return mySystemUrl != null ? mySystemUrl.getValueAsString() : null;
- }
}
}
diff --git a/hapi-fhir-validation/src/test/java/org/hl7/fhir/dstu3/hapi/validation/RemoteTerminologyLookupCodeWithResponseFileDstu3Test.java b/hapi-fhir-validation/src/test/java/org/hl7/fhir/dstu3/hapi/validation/RemoteTerminologyLookupCodeWithResponseFileDstu3Test.java
index 48a99f260d0..4817542ef4d 100644
--- a/hapi-fhir-validation/src/test/java/org/hl7/fhir/dstu3/hapi/validation/RemoteTerminologyLookupCodeWithResponseFileDstu3Test.java
+++ b/hapi-fhir-validation/src/test/java/org/hl7/fhir/dstu3/hapi/validation/RemoteTerminologyLookupCodeWithResponseFileDstu3Test.java
@@ -5,13 +5,10 @@ import ca.uhn.fhir.context.support.IValidationSupport;
import ca.uhn.fhir.context.support.LookupCodeRequest;
import ca.uhn.fhir.rest.client.interceptor.LoggingInterceptor;
import ca.uhn.fhir.test.utilities.server.RestfulServerExtension;
-import ca.uhn.fhir.util.ClasspathUtil;
-import org.hl7.fhir.common.hapi.validation.IValidationProviders;
+import ca.uhn.fhir.test.utilities.validation.IValidationProvidersDstu3;
import org.hl7.fhir.common.hapi.validation.support.RemoteTerminologyServiceValidationSupport;
-import org.hl7.fhir.dstu3.model.Parameters;
import org.hl7.fhir.dstu3.model.StringType;
import org.hl7.fhir.instance.model.api.IBaseParameters;
-import org.hl7.fhir.instance.model.api.IBaseResource;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -19,13 +16,15 @@ import org.junit.jupiter.api.extension.RegisterExtension;
import java.util.List;
+import static ca.uhn.fhir.jpa.model.util.JpaConstants.OPERATION_LOOKUP;
+import static ca.uhn.fhir.test.utilities.validation.IValidationProviders.CODE;
+import static ca.uhn.fhir.test.utilities.validation.IValidationProviders.CODE_SYSTEM;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
public class RemoteTerminologyLookupCodeWithResponseFileDstu3Test {
private static final FhirContext ourCtx = FhirContext.forDstu3Cached();
- private IValidateCodeProvidersDstu3.MyCodeSystemProviderDstu3 myCodeSystemProvider;
+ private IValidationProvidersDstu3.MyCodeSystemProviderDstu3 myCodeSystemProvider;
@RegisterExtension
public static RestfulServerExtension ourRestfulServerExtension = new RestfulServerExtension(ourCtx);
@@ -36,7 +35,7 @@ public class RemoteTerminologyLookupCodeWithResponseFileDstu3Test {
String baseUrl = "http://localhost:" + ourRestfulServerExtension.getPort();
mySvc = new RemoteTerminologyServiceValidationSupport(ourCtx, baseUrl);
mySvc.addClientInterceptor(new LoggingInterceptor(false).setLogRequestSummary(true).setLogResponseSummary(true));
- myCodeSystemProvider = new IValidateCodeProvidersDstu3.MyCodeSystemProviderDstu3();
+ myCodeSystemProvider = new IValidationProvidersDstu3.MyCodeSystemProviderDstu3();
ourRestfulServerExtension.getRestfulServer().registerProviders(myCodeSystemProvider);
}
@@ -47,13 +46,10 @@ public class RemoteTerminologyLookupCodeWithResponseFileDstu3Test {
}
@Test
void lookupCode_withParametersOutput_convertsCorrectly() {
- String paramsAsString = ClasspathUtil.loadResource("/terminology/CodeSystem-lookup-output-with-subproperties.json");
- IBaseResource baseResource = ourCtx.newJsonParser().parseResource(paramsAsString);
- assertTrue(baseResource instanceof Parameters);
- Parameters resultParameters = (Parameters) baseResource;
- myCodeSystemProvider.setReturnParams(resultParameters);
+ String outputFile ="/terminology/CodeSystem-lookup-output-with-subproperties.json";
+ IBaseParameters resultParameters = myCodeSystemProvider.addTerminologyResponse(OPERATION_LOOKUP, CODE_SYSTEM, CODE, ourCtx, outputFile);
- LookupCodeRequest request = new LookupCodeRequest(IValidationProviders.CODE_SYSTEM, IValidationProviders.CODE, null, List.of("interfaces"));
+ LookupCodeRequest request = new LookupCodeRequest(CODE_SYSTEM, CODE, null, List.of("interfaces"));
// test
IValidationSupport.LookupCodeResult outcome = mySvc.lookupCode(null, request);
diff --git a/hapi-fhir-validation/src/test/java/org/hl7/fhir/dstu3/hapi/validation/RemoteTerminologyValidateCodeDstu3Test.java b/hapi-fhir-validation/src/test/java/org/hl7/fhir/dstu3/hapi/validation/RemoteTerminologyValidateCodeDstu3Test.java
index af4f39f0926..2f573ad3e5f 100644
--- a/hapi-fhir-validation/src/test/java/org/hl7/fhir/dstu3/hapi/validation/RemoteTerminologyValidateCodeDstu3Test.java
+++ b/hapi-fhir-validation/src/test/java/org/hl7/fhir/dstu3/hapi/validation/RemoteTerminologyValidateCodeDstu3Test.java
@@ -4,16 +4,18 @@ import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.rest.client.api.ServerValidationModeEnum;
import ca.uhn.fhir.rest.client.interceptor.LoggingInterceptor;
import ca.uhn.fhir.test.utilities.server.RestfulServerExtension;
-import ca.uhn.fhir.util.ClasspathUtil;
+import ca.uhn.fhir.test.utilities.validation.IValidationProviders;
+import ca.uhn.fhir.test.utilities.validation.IValidationProvidersDstu3;
import org.hl7.fhir.common.hapi.validation.IRemoteTerminologyValidateCodeTest;
-import org.hl7.fhir.common.hapi.validation.IValidationProviders;
import org.hl7.fhir.common.hapi.validation.support.RemoteTerminologyServiceValidationSupport;
import org.hl7.fhir.dstu3.model.BooleanType;
+import org.hl7.fhir.dstu3.model.CodeSystem;
import org.hl7.fhir.dstu3.model.OperationOutcome;
import org.hl7.fhir.dstu3.model.Parameters;
import org.hl7.fhir.dstu3.model.Resource;
import org.hl7.fhir.dstu3.model.StringType;
import org.hl7.fhir.dstu3.model.UriType;
+import org.hl7.fhir.dstu3.model.ValueSet;
import org.hl7.fhir.instance.model.api.IBaseOperationOutcome;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.junit.jupiter.api.AfterEach;
@@ -22,6 +24,11 @@ import org.junit.jupiter.api.extension.RegisterExtension;
import java.util.List;
+import static ca.uhn.fhir.test.utilities.validation.IValidationProviders.CODE;
+import static ca.uhn.fhir.test.utilities.validation.IValidationProviders.CODE_SYSTEM;
+import static ca.uhn.fhir.test.utilities.validation.IValidationProviders.CODE_SYSTEM_VERSION;
+import static ca.uhn.fhir.test.utilities.validation.IValidationProviders.ERROR_MESSAGE;
+import static ca.uhn.fhir.test.utilities.validation.IValidationProviders.VALUE_SET_URL;
import static org.hl7.fhir.common.hapi.validation.support.RemoteTerminologyServiceValidationSupport.ERROR_CODE_UNKNOWN_CODE_IN_CODE_SYSTEM;
import static org.hl7.fhir.common.hapi.validation.support.RemoteTerminologyServiceValidationSupport.ERROR_CODE_UNKNOWN_CODE_IN_VALUE_SET;
@@ -38,8 +45,8 @@ public class RemoteTerminologyValidateCodeDstu3Test implements IRemoteTerminolog
private static final FhirContext ourCtx = FhirContext.forDstu3Cached();
@RegisterExtension
public static RestfulServerExtension ourRestfulServerExtension = new RestfulServerExtension(ourCtx);
- private IValidateCodeProvidersDstu3.MyCodeSystemProviderDstu3 myCodeSystemProvider;
- private IValidateCodeProvidersDstu3.MyValueSetProviderDstu3 myValueSetProvider;
+ private IValidationProviders.MyValidationProvider myCodeSystemProvider;
+ private IValidationProviders.MyValidationProvider myValueSetProvider;
private RemoteTerminologyServiceValidationSupport mySvc;
private String myCodeSystemError, myValueSetError;
@@ -48,14 +55,14 @@ public class RemoteTerminologyValidateCodeDstu3Test implements IRemoteTerminolog
String baseUrl = "http://localhost:" + ourRestfulServerExtension.getPort();
myCodeSystemError = ourCtx.getLocalizer().getMessage(
RemoteTerminologyServiceValidationSupport.class,
- ERROR_CODE_UNKNOWN_CODE_IN_CODE_SYSTEM, IValidationProviders.CODE_SYSTEM, IValidationProviders.CODE, baseUrl, IValidationProviders.ERROR_MESSAGE);
+ ERROR_CODE_UNKNOWN_CODE_IN_CODE_SYSTEM, CODE_SYSTEM, CODE, baseUrl, ERROR_MESSAGE);
myValueSetError = ourCtx.getLocalizer().getMessage(
RemoteTerminologyServiceValidationSupport.class,
- ERROR_CODE_UNKNOWN_CODE_IN_VALUE_SET, IValidationProviders.CODE_SYSTEM, IValidationProviders.CODE, IValidationProviders.VALUE_SET_URL, baseUrl, IValidationProviders.ERROR_MESSAGE);
+ ERROR_CODE_UNKNOWN_CODE_IN_VALUE_SET, CODE_SYSTEM, CODE, VALUE_SET_URL, baseUrl, ERROR_MESSAGE);
mySvc = new RemoteTerminologyServiceValidationSupport(ourCtx, baseUrl);
mySvc.addClientInterceptor(new LoggingInterceptor(false).setLogRequestSummary(true).setLogResponseSummary(true));
- myCodeSystemProvider = new IValidateCodeProvidersDstu3.MyCodeSystemProviderDstu3();
- myValueSetProvider = new IValidateCodeProvidersDstu3.MyValueSetProviderDstu3();
+ myCodeSystemProvider = new IValidationProvidersDstu3.MyCodeSystemProviderDstu3();
+ myValueSetProvider = new IValidationProvidersDstu3.MyValueSetProviderDstu3();
ourRestfulServerExtension.getRestfulServer().registerProviders(myCodeSystemProvider, myValueSetProvider);
}
@@ -82,45 +89,40 @@ public class RemoteTerminologyValidateCodeDstu3Test implements IRemoteTerminolog
}
@Override
- public IValidateCodeProvidersDstu3.MyCodeSystemProviderDstu3 getCodeSystemProvider() {
+ public IValidationProviders.IMyValidationProvider getCodeSystemProvider() {
return myCodeSystemProvider;
}
@Override
- public IValidateCodeProvidersDstu3.MyValueSetProviderDstu3 getValueSetProvider() {
+ public IValidationProviders.IMyValidationProvider getValueSetProvider() {
return myValueSetProvider;
}
@Override
public IBaseOperationOutcome getCodeSystemInvalidCodeOutcome() {
- return ClasspathUtil.loadResource(getService().getFhirContext(), OperationOutcome.class, "/terminology/OperationOutcome-CodeSystem-invalid-code.json");
+ return getCodeSystemInvalidCodeOutcome(OperationOutcome.class);
}
@Override
public IBaseOperationOutcome getValueSetInvalidCodeOutcome() {
- return ClasspathUtil.loadResource(getService().getFhirContext(), OperationOutcome.class, "/terminology/OperationOutcome-ValueSet-invalid-code.json");
+ return getValueSetInvalidCodeOutcome(OperationOutcome.class);
+ }
+
+ @Override
+ public IBaseOperationOutcome getValueSetCustomDetailCodeOutcome() {
+ return getValueSetCustomDetailCodeOutcome(OperationOutcome.class);
}
@Override
public Parameters createParameters(Boolean theResult, String theDisplay, String theMessage, IBaseResource theIssuesResource) {
Parameters parameters = new Parameters();
parameters.addParameter().setName("result").setValue(new BooleanType(theResult));
- parameters.addParameter().setName("code").setValue(new StringType(IValidationProviders.CODE));
- parameters.addParameter().setName("system").setValue(new UriType(IValidationProviders.CODE_SYSTEM));
- parameters.addParameter().setName("version").setValue(new StringType(IValidationProviders.CODE_SYSTEM_VERSION));
+ parameters.addParameter().setName("code").setValue(new StringType(CODE));
+ parameters.addParameter().setName("system").setValue(new UriType(CODE_SYSTEM));
+ parameters.addParameter().setName("version").setValue(new StringType(CODE_SYSTEM_VERSION));
parameters.addParameter().setName("display").setValue(new StringType(theDisplay));
parameters.addParameter().setName("message").setValue(new StringType(theMessage));
parameters.addParameter().setName("issues").setResource((Resource) theIssuesResource);
return parameters;
}
-
- @Override
- public void createCodeSystemReturnParameters(Boolean theResult, String theDisplay, String theMessage, IBaseResource theIssuesResource) {
- myCodeSystemProvider.setReturnParams(createParameters(theResult, theDisplay, theMessage, theIssuesResource));
- }
-
- @Override
- public void createValueSetReturnParameters(Boolean theResult, String theDisplay, String theMessage, IBaseResource theIssuesResource) {
- myValueSetProvider.setReturnParams(createParameters(theResult, theDisplay, theMessage, theIssuesResource));
- }
}
diff --git a/hapi-fhir-validation/src/test/java/org/hl7/fhir/r4/utils/FhirPathEngineR4Test.java b/hapi-fhir-validation/src/test/java/org/hl7/fhir/r4/utils/FhirPathEngineR4Test.java
index 15bbc3a8bf3..1c2382b6aac 100644
--- a/hapi-fhir-validation/src/test/java/org/hl7/fhir/r4/utils/FhirPathEngineR4Test.java
+++ b/hapi-fhir-validation/src/test/java/org/hl7/fhir/r4/utils/FhirPathEngineR4Test.java
@@ -54,6 +54,7 @@ public class FhirPathEngineR4Test extends BaseValidationTestWithInlineMocks {
List value;
+
value = ourCtx.newFhirPath().evaluate(o, "Observation.specimen", Base.class);
assertThat(value).hasSize(1);
value = ourCtx.newFhirPath().evaluate(o, "Observation.specimen.resolve()", Base.class);
@@ -65,6 +66,9 @@ public class FhirPathEngineR4Test extends BaseValidationTestWithInlineMocks {
assertEquals("2011-01-01", ((DateTimeType) value.get(0)).getValueAsString());
}
+
+
+
@Test
public void testComponentCode() {
String path = "(Observation.component.value.ofType(FHIR.Quantity)) ";
diff --git a/hapi-fhir-validation/src/test/java/org/hl7/fhir/r4/validation/FhirInstanceValidatorR4Test.java b/hapi-fhir-validation/src/test/java/org/hl7/fhir/r4/validation/FhirInstanceValidatorR4Test.java
index d03c3aa974d..fb46f7f8008 100644
--- a/hapi-fhir-validation/src/test/java/org/hl7/fhir/r4/validation/FhirInstanceValidatorR4Test.java
+++ b/hapi-fhir-validation/src/test/java/org/hl7/fhir/r4/validation/FhirInstanceValidatorR4Test.java
@@ -307,10 +307,10 @@ public class FhirInstanceValidatorR4Test extends BaseValidationTestWithInlineMoc
retVal = new IValidationSupport.CodeValidationResult().setCode(code);
} else if (myValidSystems.contains(system)) {
final String message = "Unknown code (for '" + system + "#" + code + "')";
- retVal = new IValidationSupport.CodeValidationResult().setSeverityCode(ValidationMessage.IssueSeverity.ERROR.toCode()).setMessage(message).setCodeValidationIssues(Collections.singletonList(new IValidationSupport.CodeValidationIssue(message, IValidationSupport.IssueSeverity.ERROR, IValidationSupport.CodeValidationIssueCode.CODE_INVALID, IValidationSupport.CodeValidationIssueCoding.INVALID_CODE)));
+ retVal = new IValidationSupport.CodeValidationResult().setSeverity(IValidationSupport.IssueSeverity.ERROR).setMessage(message).setIssues(Collections.singletonList(new IValidationSupport.CodeValidationIssue(message, IValidationSupport.IssueSeverity.ERROR, IValidationSupport.CodeValidationIssueCode.CODE_INVALID, IValidationSupport.CodeValidationIssueCoding.INVALID_CODE)));
} else if (myValidSystemsNotReturningIssues.contains(system)) {
final String message = "Unknown code (for '" + system + "#" + code + "')";
- retVal = new IValidationSupport.CodeValidationResult().setSeverityCode(ValidationMessage.IssueSeverity.ERROR.toCode()).setMessage(message);
+ retVal = new IValidationSupport.CodeValidationResult().setSeverity(IValidationSupport.IssueSeverity.ERROR).setMessage(message);
} else {
retVal = myDefaultValidationSupport.validateCode(new ValidationSupportContext(myDefaultValidationSupport), options, system, code, display, valueSetUrl);
}
diff --git a/hapi-fhir-validation/src/test/java/org/hl7/fhir/r4/validation/RemoteTerminologyLookupCodeR4Test.java b/hapi-fhir-validation/src/test/java/org/hl7/fhir/r4/validation/RemoteTerminologyLookupCodeR4Test.java
index d67966df6d4..382f621f547 100644
--- a/hapi-fhir-validation/src/test/java/org/hl7/fhir/r4/validation/RemoteTerminologyLookupCodeR4Test.java
+++ b/hapi-fhir-validation/src/test/java/org/hl7/fhir/r4/validation/RemoteTerminologyLookupCodeR4Test.java
@@ -11,9 +11,10 @@ import ca.uhn.fhir.rest.client.interceptor.LoggingInterceptor;
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
import ca.uhn.fhir.test.utilities.server.RestfulServerExtension;
+import ca.uhn.fhir.test.utilities.validation.IValidationProviders;
+import ca.uhn.fhir.test.utilities.validation.IValidationProvidersR4;
import jakarta.servlet.http.HttpServletRequest;
import org.hl7.fhir.common.hapi.validation.IRemoteTerminologyLookupCodeTest;
-import org.hl7.fhir.common.hapi.validation.IValidationProviders;
import org.hl7.fhir.common.hapi.validation.support.RemoteTerminologyServiceValidationSupport;
import org.hl7.fhir.instance.model.api.IBaseDatatype;
import org.hl7.fhir.instance.model.api.IBaseParameters;
@@ -52,7 +53,7 @@ public class RemoteTerminologyLookupCodeR4Test implements IRemoteTerminologyLook
@RegisterExtension
public static RestfulServerExtension ourRestfulServerExtension = new RestfulServerExtension(ourCtx);
private final RemoteTerminologyServiceValidationSupport mySvc = new RemoteTerminologyServiceValidationSupport(ourCtx);
- private IValidateCodeProvidersR4.MyCodeSystemProviderR4 myCodeSystemProvider;
+ private IValidationProvidersR4.MyCodeSystemProviderR4 myCodeSystemProvider;
private MyLookupCodeProviderR4 myLookupCodeProviderR4;
@BeforeEach
@@ -60,7 +61,7 @@ public class RemoteTerminologyLookupCodeR4Test implements IRemoteTerminologyLook
String baseUrl = "http://localhost:" + ourRestfulServerExtension.getPort();
mySvc.setBaseUrl(baseUrl);
mySvc.addClientInterceptor(new LoggingInterceptor(true));
- myCodeSystemProvider = new IValidateCodeProvidersR4.MyCodeSystemProviderR4();
+ myCodeSystemProvider = new IValidationProvidersR4.MyCodeSystemProviderR4();
myLookupCodeProviderR4 = new MyLookupCodeProviderR4();
ourRestfulServerExtension.getRestfulServer().registerProviders(myCodeSystemProvider, myLookupCodeProviderR4);
}
@@ -166,8 +167,6 @@ public class RemoteTerminologyLookupCodeR4Test implements IRemoteTerminologyLook
@SuppressWarnings("unused")
static class MyLookupCodeProviderR4 implements IValidationProviders.IMyLookupCodeProvider {
- private UriType mySystemUrl;
- private CodeType myCode;
private LookupCodeResult myLookupCodeResult;
@Override
@@ -192,8 +191,6 @@ public class RemoteTerminologyLookupCodeR4Test implements IRemoteTerminologyLook
@OperationParam(name = "property", max = OperationParam.MAX_UNLIMITED) List thePropertyNames,
RequestDetails theRequestDetails
) {
- myCode = theCode;
- mySystemUrl = theSystem;
if (theSystem == null) {
throw new InvalidRequestException(MessageFormat.format(MESSAGE_RESPONSE_INVALID, theCode));
}
@@ -206,15 +203,5 @@ public class RemoteTerminologyLookupCodeR4Test implements IRemoteTerminologyLook
public Class extends IBaseResource> getResourceType() {
return CodeSystem.class;
}
-
- @Override
- public String getCode() {
- return myCode != null ? myCode.getValueAsString() : null;
- }
-
- @Override
- public String getSystem() {
- return mySystemUrl != null ? mySystemUrl.getValueAsString() : null;
- }
}
}
diff --git a/hapi-fhir-validation/src/test/java/org/hl7/fhir/r4/validation/RemoteTerminologyLookupCodeWithResponseFileR4Test.java b/hapi-fhir-validation/src/test/java/org/hl7/fhir/r4/validation/RemoteTerminologyLookupCodeWithResponseFileR4Test.java
index 37eba91d0ca..a0896bd8c4e 100644
--- a/hapi-fhir-validation/src/test/java/org/hl7/fhir/r4/validation/RemoteTerminologyLookupCodeWithResponseFileR4Test.java
+++ b/hapi-fhir-validation/src/test/java/org/hl7/fhir/r4/validation/RemoteTerminologyLookupCodeWithResponseFileR4Test.java
@@ -5,12 +5,9 @@ import ca.uhn.fhir.context.support.IValidationSupport;
import ca.uhn.fhir.context.support.LookupCodeRequest;
import ca.uhn.fhir.rest.client.interceptor.LoggingInterceptor;
import ca.uhn.fhir.test.utilities.server.RestfulServerExtension;
-import ca.uhn.fhir.util.ClasspathUtil;
-import org.hl7.fhir.common.hapi.validation.IValidationProviders;
+import ca.uhn.fhir.test.utilities.validation.IValidationProvidersR4;
import org.hl7.fhir.common.hapi.validation.support.RemoteTerminologyServiceValidationSupport;
import org.hl7.fhir.instance.model.api.IBaseParameters;
-import org.hl7.fhir.instance.model.api.IBaseResource;
-import org.hl7.fhir.r4.model.Parameters;
import org.hl7.fhir.r4.model.StringType;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
@@ -19,13 +16,15 @@ import org.junit.jupiter.api.extension.RegisterExtension;
import java.util.List;
+import static ca.uhn.fhir.jpa.model.util.JpaConstants.OPERATION_LOOKUP;
+import static ca.uhn.fhir.test.utilities.validation.IValidationProviders.CODE;
+import static ca.uhn.fhir.test.utilities.validation.IValidationProviders.CODE_SYSTEM;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
public class RemoteTerminologyLookupCodeWithResponseFileR4Test {
private static final FhirContext ourCtx = FhirContext.forR4Cached();
- private IValidateCodeProvidersR4.MyCodeSystemProviderR4 myCodeSystemProvider;
+ private IValidationProvidersR4.MyCodeSystemProviderR4 myCodeSystemProvider;
@RegisterExtension
public static RestfulServerExtension ourRestfulServerExtension = new RestfulServerExtension(ourCtx);
@@ -36,7 +35,7 @@ public class RemoteTerminologyLookupCodeWithResponseFileR4Test {
String baseUrl = "http://localhost:" + ourRestfulServerExtension.getPort();
mySvc = new RemoteTerminologyServiceValidationSupport(ourCtx, baseUrl);
mySvc.addClientInterceptor(new LoggingInterceptor(false).setLogRequestSummary(true).setLogResponseSummary(true));
- myCodeSystemProvider = new IValidateCodeProvidersR4.MyCodeSystemProviderR4();
+ myCodeSystemProvider = new IValidationProvidersR4.MyCodeSystemProviderR4();
ourRestfulServerExtension.getRestfulServer().registerProviders(myCodeSystemProvider);
}
@@ -48,13 +47,10 @@ public class RemoteTerminologyLookupCodeWithResponseFileR4Test {
@Test
void lookupCode_withParametersOutput_convertsCorrectly() {
- String paramsAsString = ClasspathUtil.loadResource("/terminology/CodeSystem-lookup-output-with-subproperties.json");
- IBaseResource baseResource = ourCtx.newJsonParser().parseResource(paramsAsString);
- assertTrue(baseResource instanceof Parameters);
- Parameters resultParameters = (Parameters) baseResource;
- myCodeSystemProvider.setReturnParams(resultParameters);
+ String outputFile ="/terminology/CodeSystem-lookup-output-with-subproperties.json";
+ IBaseParameters resultParameters = myCodeSystemProvider.addTerminologyResponse(OPERATION_LOOKUP, CODE_SYSTEM, CODE, ourCtx, outputFile);
- LookupCodeRequest request = new LookupCodeRequest(IValidationProviders.CODE_SYSTEM, IValidationProviders.CODE, null, List.of("interfaces"));
+ LookupCodeRequest request = new LookupCodeRequest(CODE_SYSTEM, CODE, null, List.of("interfaces"));
// test
IValidationSupport.LookupCodeResult outcome = mySvc.lookupCode(null, request);
diff --git a/hapi-fhir-validation/src/test/java/org/hl7/fhir/r4/validation/RemoteTerminologyValidateCodeR4Test.java b/hapi-fhir-validation/src/test/java/org/hl7/fhir/r4/validation/RemoteTerminologyValidateCodeR4Test.java
index 08f6c251869..ffd8045a8a5 100644
--- a/hapi-fhir-validation/src/test/java/org/hl7/fhir/r4/validation/RemoteTerminologyValidateCodeR4Test.java
+++ b/hapi-fhir-validation/src/test/java/org/hl7/fhir/r4/validation/RemoteTerminologyValidateCodeR4Test.java
@@ -2,8 +2,8 @@ package org.hl7.fhir.r4.validation;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.context.support.ConceptValidationOptions;
-import ca.uhn.fhir.context.support.IValidationSupport;
import ca.uhn.fhir.context.support.IValidationSupport.CodeValidationResult;
+import ca.uhn.fhir.jpa.model.util.JpaConstants;
import ca.uhn.fhir.parser.IJsonLikeParser;
import ca.uhn.fhir.rest.client.api.IClientInterceptor;
import ca.uhn.fhir.rest.client.api.IHttpRequest;
@@ -13,11 +13,11 @@ import ca.uhn.fhir.rest.client.interceptor.LoggingInterceptor;
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
import ca.uhn.fhir.test.utilities.server.RestfulServerExtension;
-import ca.uhn.fhir.util.ClasspathUtil;
+import ca.uhn.fhir.test.utilities.validation.IValidationProviders;
+import ca.uhn.fhir.test.utilities.validation.IValidationProvidersR4;
import ca.uhn.fhir.util.ParametersUtil;
import com.google.common.collect.Lists;
import org.hl7.fhir.common.hapi.validation.IRemoteTerminologyValidateCodeTest;
-import org.hl7.fhir.common.hapi.validation.IValidationProviders;
import org.hl7.fhir.common.hapi.validation.support.RemoteTerminologyServiceValidationSupport;
import org.hl7.fhir.instance.model.api.IBaseOperationOutcome;
import org.hl7.fhir.instance.model.api.IBaseResource;
@@ -39,6 +39,12 @@ import java.util.Collections;
import java.util.List;
import java.util.stream.Stream;
+import static ca.uhn.fhir.test.utilities.validation.IValidationProviders.CODE;
+import static ca.uhn.fhir.test.utilities.validation.IValidationProviders.CODE_SYSTEM;
+import static ca.uhn.fhir.test.utilities.validation.IValidationProviders.CODE_SYSTEM_VERSION;
+import static ca.uhn.fhir.test.utilities.validation.IValidationProviders.DISPLAY;
+import static ca.uhn.fhir.test.utilities.validation.IValidationProviders.ERROR_MESSAGE;
+import static ca.uhn.fhir.test.utilities.validation.IValidationProviders.VALUE_SET_URL;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hl7.fhir.common.hapi.validation.support.RemoteTerminologyServiceValidationSupport.ERROR_CODE_UNKNOWN_CODE_IN_CODE_SYSTEM;
import static org.hl7.fhir.common.hapi.validation.support.RemoteTerminologyServiceValidationSupport.ERROR_CODE_UNKNOWN_CODE_IN_VALUE_SET;
@@ -61,8 +67,8 @@ public class RemoteTerminologyValidateCodeR4Test implements IRemoteTerminologyVa
private static final FhirContext ourCtx = FhirContext.forR4Cached();
@RegisterExtension
public static RestfulServerExtension ourRestfulServerExtension = new RestfulServerExtension(ourCtx);
- private IValidateCodeProvidersR4.MyCodeSystemProviderR4 myCodeSystemProvider;
- private IValidateCodeProvidersR4.MyValueSetProviderR4 myValueSetProvider;
+ private IValidationProviders.IMyValidationProvider myCodeSystemProvider;
+ private IValidationProviders.IMyValidationProvider myValueSetProvider;
private RemoteTerminologyServiceValidationSupport mySvc;
private String myCodeSystemError, myValueSetError;
@@ -71,14 +77,14 @@ public class RemoteTerminologyValidateCodeR4Test implements IRemoteTerminologyVa
String baseUrl = "http://localhost:" + ourRestfulServerExtension.getPort();
myCodeSystemError = ourCtx.getLocalizer().getMessage(
RemoteTerminologyServiceValidationSupport.class,
- ERROR_CODE_UNKNOWN_CODE_IN_CODE_SYSTEM, IValidationProviders.CODE_SYSTEM, IValidationProviders.CODE, baseUrl, IValidationProviders.ERROR_MESSAGE);
+ ERROR_CODE_UNKNOWN_CODE_IN_CODE_SYSTEM, CODE_SYSTEM, CODE, baseUrl, ERROR_MESSAGE);
myValueSetError = ourCtx.getLocalizer().getMessage(
RemoteTerminologyServiceValidationSupport.class,
- ERROR_CODE_UNKNOWN_CODE_IN_VALUE_SET, IValidationProviders.CODE_SYSTEM, IValidationProviders.CODE, IValidationProviders.VALUE_SET_URL, baseUrl, IValidationProviders.ERROR_MESSAGE);
+ ERROR_CODE_UNKNOWN_CODE_IN_VALUE_SET, CODE_SYSTEM, CODE, VALUE_SET_URL, baseUrl, ERROR_MESSAGE);
mySvc = new RemoteTerminologyServiceValidationSupport(ourCtx, baseUrl);
mySvc.addClientInterceptor(new LoggingInterceptor(false).setLogRequestSummary(true).setLogResponseSummary(true));
- myCodeSystemProvider = new IValidateCodeProvidersR4.MyCodeSystemProviderR4();
- myValueSetProvider = new IValidateCodeProvidersR4.MyValueSetProviderR4();
+ myCodeSystemProvider = new IValidationProvidersR4.MyCodeSystemProviderR4();
+ myValueSetProvider = new IValidationProvidersR4.MyValueSetProviderR4();
ourRestfulServerExtension.getRestfulServer().registerProviders(myCodeSystemProvider, myValueSetProvider);
}
@@ -95,12 +101,12 @@ public class RemoteTerminologyValidateCodeR4Test implements IRemoteTerminologyVa
}
@Override
- public IValidationProviders.IMyCodeSystemProvider getCodeSystemProvider() {
+ public IValidationProviders.IMyValidationProvider getCodeSystemProvider() {
return myCodeSystemProvider;
}
@Override
- public IValidationProviders.IMyValueSetProvider getValueSetProvider() {
+ public IValidationProviders.IMyValidationProvider getValueSetProvider() {
return myValueSetProvider;
}
@@ -116,51 +122,40 @@ public class RemoteTerminologyValidateCodeR4Test implements IRemoteTerminologyVa
@Override
public IBaseOperationOutcome getCodeSystemInvalidCodeOutcome() {
- return ClasspathUtil.loadResource(getService().getFhirContext(), OperationOutcome.class, "/terminology/OperationOutcome-CodeSystem-invalid-code.json");
+ return getCodeSystemInvalidCodeOutcome(OperationOutcome.class);
}
@Override
public IBaseOperationOutcome getValueSetInvalidCodeOutcome() {
- return ClasspathUtil.loadResource(getService().getFhirContext(), OperationOutcome.class, "/terminology/OperationOutcome-ValueSet-invalid-code.json");
+ return getValueSetInvalidCodeOutcome(OperationOutcome.class);
}
@Override
- public List getCodeValidationIssues(IBaseOperationOutcome theOperationOutcome) {
- return ((OperationOutcome)theOperationOutcome).getIssue().stream()
- .map(issueComponent -> new IValidationSupport.CodeValidationIssue(
- issueComponent.getDetails().getText(),
- IValidationSupport.IssueSeverity.ERROR,
- /* assume issue type is OperationOutcome.IssueType#CODEINVALID as it is the only match */
- IValidationSupport.CodeValidationIssueCode.INVALID,
- IValidationSupport.CodeValidationIssueCoding.INVALID_CODE))
- .toList();
+ public IBaseOperationOutcome getValueSetCustomDetailCodeOutcome() {
+ return getValueSetCustomDetailCodeOutcome(OperationOutcome.class);
}
@Test
void validateCodeInValueSet_success() {
- createValueSetReturnParameters(true, IValidationProviders.DISPLAY, null, null);
+ createValueSetReturnParameters(true, DISPLAY, null, null);
ValueSet valueSet = new ValueSet();
- valueSet.setUrl(IValidationProviders.VALUE_SET_URL);
+ valueSet.setUrl(VALUE_SET_URL);
- CodeValidationResult outcome = mySvc.validateCodeInValueSet(null, new ConceptValidationOptions(), IValidationProviders.CODE_SYSTEM, IValidationProviders.CODE, IValidationProviders.DISPLAY, valueSet);
+ CodeValidationResult outcome = mySvc.validateCodeInValueSet(null, new ConceptValidationOptions(), CODE_SYSTEM, CODE, DISPLAY, valueSet);
assertNotNull(outcome);
- assertEquals(IValidationProviders.CODE, outcome.getCode());
- assertEquals(IValidationProviders.DISPLAY, outcome.getDisplay());
+ assertEquals(CODE, outcome.getCode());
+ assertEquals(DISPLAY, outcome.getDisplay());
assertNull(outcome.getSeverity());
assertNull(outcome.getMessage());
-
- assertEquals(IValidationProviders.CODE, myValueSetProvider.getCode());
- assertEquals(IValidationProviders.DISPLAY, myValueSetProvider.getDisplay());
- assertEquals(IValidationProviders.VALUE_SET_URL, myValueSetProvider.getValueSet());
}
@Override
public Parameters createParameters(Boolean theResult, String theDisplay, String theMessage, IBaseResource theIssuesResource) {
Parameters parameters = new Parameters()
- .addParameter("code", IValidationProviders.CODE)
- .addParameter("system", IValidationProviders.CODE_SYSTEM)
- .addParameter("version", IValidationProviders.CODE_SYSTEM_VERSION)
+ .addParameter("code", CODE)
+ .addParameter("system", CODE_SYSTEM)
+ .addParameter("version", CODE_SYSTEM_VERSION)
.addParameter("display", theDisplay)
.addParameter("message", theMessage);
if (theResult != null) {
@@ -181,16 +176,16 @@ public class RemoteTerminologyValidateCodeR4Test implements IRemoteTerminologyVa
@Test
void validateCodeInValueSet_uniqueComposeInclude() {
- createValueSetReturnParameters(true, IValidationProviders.DISPLAY, null, null);
+ createValueSetReturnParameters(true, DISPLAY, null, null);
ValueSet valueSet = new ValueSet();
- valueSet.setUrl(IValidationProviders.VALUE_SET_URL);
+ valueSet.setUrl(VALUE_SET_URL);
String systemUrl = "http://hl7.org/fhir/ValueSet/administrative-gender";
valueSet.setCompose(new ValueSet.ValueSetComposeComponent().setInclude(
Collections.singletonList(new ValueSet.ConceptSetComponent().setSystem(systemUrl)) ));
CodeValidationResult outcome = mySvc.validateCodeInValueSet(null,
- new ConceptValidationOptions().setInferSystem(true), null, IValidationProviders.CODE, IValidationProviders.DISPLAY, valueSet);
+ new ConceptValidationOptions().setInferSystem(true), null, CODE, DISPLAY, valueSet);
// validate service doesn't return error message (as when no code system is present)
assertNotNull(outcome);
@@ -211,16 +206,16 @@ public class RemoteTerminologyValidateCodeR4Test implements IRemoteTerminologyVa
@ParameterizedTest
@MethodSource(value = "getRemoteTerminologyServerExceptions")
void validateCodeInValueSet_systemNotPresent_returnsValidationResultWithError(Exception theException, String theServerMessage) {
- myValueSetProvider.setException(theException);
- createValueSetReturnParameters(true, IValidationProviders.DISPLAY, null, null);
+ getValueSetProvider().addException("$validate-code", VALUE_SET_URL, CODE, theException);
+ createValueSetReturnParameters(true, DISPLAY, null, null);
ValueSet valueSet = new ValueSet();
- valueSet.setUrl(IValidationProviders.VALUE_SET_URL);
+ valueSet.setUrl(VALUE_SET_URL);
valueSet.setCompose(new ValueSet.ValueSetComposeComponent().setInclude(
Lists.newArrayList(new ValueSet.ConceptSetComponent(), new ValueSet.ConceptSetComponent())));
CodeValidationResult outcome = mySvc.validateCodeInValueSet(null,
- new ConceptValidationOptions().setInferSystem(true), null, IValidationProviders.CODE, IValidationProviders.DISPLAY, valueSet);
+ new ConceptValidationOptions().setInferSystem(true), null, CODE, DISPLAY, valueSet);
String unknownCodeForValueSetError = "Unknown code \"null#CODE\" for ValueSet with URL \"http://value.set/url\". The Remote Terminology server http://";
verifyErrorResultFromException(outcome, unknownCodeForValueSetError, theServerMessage);
@@ -230,11 +225,11 @@ public class RemoteTerminologyValidateCodeR4Test implements IRemoteTerminologyVa
@ParameterizedTest
@MethodSource(value = "getRemoteTerminologyServerExceptions")
void validateCodeInValueSet_systemPresentCodeNotPresent_returnsValidationResultWithError(Exception theException, String theServerMessage) {
- myValueSetProvider.setException(theException);
- createValueSetReturnParameters(true, IValidationProviders.DISPLAY, null, null);
+ getValueSetProvider().addException(JpaConstants.OPERATION_VALIDATE_CODE, VALUE_SET_URL, CODE, theException);
+ createValueSetReturnParameters(true, DISPLAY, null, null);
ValueSet valueSet = new ValueSet();
- valueSet.setUrl(IValidationProviders.VALUE_SET_URL);
+ valueSet.setUrl(VALUE_SET_URL);
String systemUrl = "http://hl7.org/fhir/ValueSet/administrative-gender";
String systemUrl2 = "http://hl7.org/fhir/ValueSet/other-valueset";
valueSet.setCompose(new ValueSet.ValueSetComposeComponent().setInclude(
@@ -243,7 +238,7 @@ public class RemoteTerminologyValidateCodeR4Test implements IRemoteTerminologyVa
new ValueSet.ConceptSetComponent().setSystem(systemUrl2))));
CodeValidationResult outcome = mySvc.validateCodeInValueSet(null,
- new ConceptValidationOptions().setInferSystem(true), null, IValidationProviders.CODE, IValidationProviders.DISPLAY, valueSet);
+ new ConceptValidationOptions().setInferSystem(true), null, CODE, DISPLAY, valueSet);
String unknownCodeForValueSetError = "Unknown code \"null#CODE\" for ValueSet with URL \"http://value.set/url\". The Remote Terminology server http://";
verifyErrorResultFromException(outcome, unknownCodeForValueSetError, theServerMessage);
@@ -252,10 +247,10 @@ public class RemoteTerminologyValidateCodeR4Test implements IRemoteTerminologyVa
@Test
void validateCodeInValueSet_systemPresentCodePresentValidatesOKNoVersioned() {
- createValueSetReturnParameters(true, IValidationProviders.DISPLAY, null, null);
+ createValueSetReturnParameters(true, DISPLAY, null, null);
ValueSet valueSet = new ValueSet();
- valueSet.setUrl(IValidationProviders.VALUE_SET_URL);
+ valueSet.setUrl(VALUE_SET_URL);
String systemUrl = "http://hl7.org/fhir/ValueSet/administrative-gender";
String systemUrl2 = "http://hl7.org/fhir/ValueSet/other-valueset";
valueSet.setCompose(new ValueSet.ValueSetComposeComponent().setInclude(
@@ -264,14 +259,14 @@ public class RemoteTerminologyValidateCodeR4Test implements IRemoteTerminologyVa
new ValueSet.ConceptSetComponent().setSystem(systemUrl2).setConcept(
Lists.newArrayList(
new ValueSet.ConceptReferenceComponent().setCode("not-the-code"),
- new ValueSet.ConceptReferenceComponent().setCode(IValidationProviders.CODE) )
+ new ValueSet.ConceptReferenceComponent().setCode(CODE) )
)) ));
TestClientInterceptor requestInterceptor = new TestClientInterceptor();
mySvc.addClientInterceptor(requestInterceptor);
CodeValidationResult outcome = mySvc.validateCodeInValueSet(null,
- new ConceptValidationOptions().setInferSystem(true), null, IValidationProviders.CODE, IValidationProviders.DISPLAY, valueSet);
+ new ConceptValidationOptions().setInferSystem(true), null, CODE, DISPLAY, valueSet);
assertNotNull(outcome);
assertEquals(systemUrl2, requestInterceptor.getCapturedSystemParameter());
@@ -280,10 +275,10 @@ public class RemoteTerminologyValidateCodeR4Test implements IRemoteTerminologyVa
@Test
void validateCodeInValueSet_systemPresentCodePresentValidatesOKVersioned() {
- createValueSetReturnParameters(true, IValidationProviders.DISPLAY, null, null);
+ createValueSetReturnParameters(true, DISPLAY, null, null);
ValueSet valueSet = new ValueSet();
- valueSet.setUrl(IValidationProviders.VALUE_SET_URL);
+ valueSet.setUrl(VALUE_SET_URL);
String systemUrl = "http://hl7.org/fhir/ValueSet/administrative-gender";
String systemVersion = "3.0.2";
String systemUrl2 = "http://hl7.org/fhir/ValueSet/other-valueset";
@@ -294,14 +289,14 @@ public class RemoteTerminologyValidateCodeR4Test implements IRemoteTerminologyVa
new ValueSet.ConceptSetComponent().setSystem(systemUrl2).setVersion(system2Version).setConcept(
Lists.newArrayList(
new ValueSet.ConceptReferenceComponent().setCode("not-the-code"),
- new ValueSet.ConceptReferenceComponent().setCode(IValidationProviders.CODE) )
+ new ValueSet.ConceptReferenceComponent().setCode(CODE) )
)) ));
TestClientInterceptor requestInterceptor = new TestClientInterceptor();
mySvc.addClientInterceptor(requestInterceptor);
CodeValidationResult outcome = mySvc.validateCodeInValueSet(null,
- new ConceptValidationOptions().setInferSystem(true), null, IValidationProviders.CODE, IValidationProviders.DISPLAY, valueSet);
+ new ConceptValidationOptions().setInferSystem(true), null, CODE, DISPLAY, valueSet);
assertNotNull(outcome);
assertEquals(systemUrl2 + "|" + system2Version, requestInterceptor.getCapturedSystemParameter());
diff --git a/hapi-fhir-validation/src/test/java/org/hl7/fhir/r4b/validation/FhirInstanceValidatorR4BTest.java b/hapi-fhir-validation/src/test/java/org/hl7/fhir/r4b/validation/FhirInstanceValidatorR4BTest.java
index ca55a41bf4c..d5035a8048e 100644
--- a/hapi-fhir-validation/src/test/java/org/hl7/fhir/r4b/validation/FhirInstanceValidatorR4BTest.java
+++ b/hapi-fhir-validation/src/test/java/org/hl7/fhir/r4b/validation/FhirInstanceValidatorR4BTest.java
@@ -31,6 +31,7 @@ import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.r4b.conformance.ProfileUtilities;
import org.hl7.fhir.r4b.context.IWorkerContext;
+import org.hl7.fhir.r4b.fhirpath.FHIRPathEngine;
import org.hl7.fhir.r4b.hapi.ctx.HapiWorkerContext;
import org.hl7.fhir.r4b.model.AllergyIntolerance;
import org.hl7.fhir.r4b.model.Base;
@@ -61,7 +62,6 @@ import org.hl7.fhir.r4b.model.StructureDefinition.StructureDefinitionKind;
import org.hl7.fhir.r4b.model.ValueSet;
import org.hl7.fhir.r4b.model.ValueSet.ValueSetExpansionComponent;
import org.hl7.fhir.r4b.terminologies.ValueSetExpander;
-import org.hl7.fhir.r4b.fhirpath.FHIRPathEngine;
import org.hl7.fhir.r5.test.utils.ClassesLoadedFlags;
import org.hl7.fhir.r5.utils.validation.IValidationPolicyAdvisor;
import org.hl7.fhir.r5.utils.validation.IValidatorResourceFetcher;
@@ -203,7 +203,7 @@ public class FhirInstanceValidatorR4BTest extends BaseValidationTestWithInlineMo
retVal = new IValidationSupport.CodeValidationResult().setCode(code);
} else if (myValidSystems.contains(system)) {
final String message = "Unknown code (for '" + system + "#" + code + "')";
- return new IValidationSupport.CodeValidationResult().setSeverityCode(ValidationMessage.IssueSeverity.ERROR.toCode()).setMessage(message).setCodeValidationIssues(Collections.singletonList(new IValidationSupport.CodeValidationIssue(message, IValidationSupport.IssueSeverity.ERROR, IValidationSupport.CodeValidationIssueCode.CODE_INVALID, IValidationSupport.CodeValidationIssueCoding.INVALID_CODE)));
+ return new IValidationSupport.CodeValidationResult().setSeverity(IValidationSupport.IssueSeverity.ERROR).setMessage(message).setIssues(Collections.singletonList(new IValidationSupport.CodeValidationIssue(message, IValidationSupport.IssueSeverity.ERROR, IValidationSupport.CodeValidationIssueCode.CODE_INVALID, IValidationSupport.CodeValidationIssueCoding.INVALID_CODE)));
} else {
retVal = myDefaultValidationSupport.validateCode(new ValidationSupportContext(myDefaultValidationSupport), options, system, code, display, valueSetUrl);
}
diff --git a/hapi-fhir-validation/src/test/java/org/hl7/fhir/r5/validation/FhirInstanceValidatorR5Test.java b/hapi-fhir-validation/src/test/java/org/hl7/fhir/r5/validation/FhirInstanceValidatorR5Test.java
index f0ea48686e1..abcb0f94704 100644
--- a/hapi-fhir-validation/src/test/java/org/hl7/fhir/r5/validation/FhirInstanceValidatorR5Test.java
+++ b/hapi-fhir-validation/src/test/java/org/hl7/fhir/r5/validation/FhirInstanceValidatorR5Test.java
@@ -48,7 +48,6 @@ import org.hl7.fhir.r5.utils.validation.IValidationPolicyAdvisor;
import org.hl7.fhir.r5.utils.validation.IValidatorResourceFetcher;
import org.hl7.fhir.r5.utils.validation.constants.BestPracticeWarningLevel;
import org.hl7.fhir.r5.utils.validation.constants.ReferenceValidationPolicy;
-import org.hl7.fhir.utilities.validation.ValidationMessage;
import org.hl7.fhir.utilities.xhtml.XhtmlNode;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeEach;
@@ -200,10 +199,10 @@ public class FhirInstanceValidatorR5Test extends BaseValidationTestWithInlineMoc
retVal = new IValidationSupport.CodeValidationResult().setCode(code);
} else if (myValidSystems.contains(system)) {
String theMessage = "Unknown code (for '" + system + "#" + code + "')";
- retVal = new IValidationSupport.CodeValidationResult().setSeverity(IValidationSupport.IssueSeverity.ERROR).setMessage(theMessage).setCodeValidationIssues(Collections.singletonList(new IValidationSupport.CodeValidationIssue(theMessage, IValidationSupport.IssueSeverity.ERROR, IValidationSupport.CodeValidationIssueCode.CODE_INVALID, IValidationSupport.CodeValidationIssueCoding.INVALID_CODE)));
+ retVal = new IValidationSupport.CodeValidationResult().setSeverity(IValidationSupport.IssueSeverity.ERROR).setMessage(theMessage).setIssues(Collections.singletonList(new IValidationSupport.CodeValidationIssue(theMessage, IValidationSupport.IssueSeverity.ERROR, IValidationSupport.CodeValidationIssueCode.CODE_INVALID, IValidationSupport.CodeValidationIssueCoding.INVALID_CODE)));
} else if (myValidSystemsNotReturningIssues.contains(system)) {
final String message = "Unknown code (for '" + system + "#" + code + "')";
- retVal = new IValidationSupport.CodeValidationResult().setSeverityCode(ValidationMessage.IssueSeverity.ERROR.toCode()).setMessage(message);
+ retVal = new IValidationSupport.CodeValidationResult().setSeverity(IValidationSupport.IssueSeverity.ERROR).setMessage(message);
} else {
retVal = myDefaultValidationSupport.validateCode(new ValidationSupportContext(myDefaultValidationSupport), options, system, code, display, valueSetUrl);
}
diff --git a/hapi-fhir-validation/src/test/resources/terminology/OperationOutcome-ValueSet-custom-issue-detail.json b/hapi-fhir-validation/src/test/resources/terminology/OperationOutcome-ValueSet-custom-issue-detail.json
new file mode 100644
index 00000000000..0823a430cf8
--- /dev/null
+++ b/hapi-fhir-validation/src/test/resources/terminology/OperationOutcome-ValueSet-custom-issue-detail.json
@@ -0,0 +1,22 @@
+{
+ "resourceType": "OperationOutcome",
+ "issue": [
+ {
+ "severity": "information",
+ "code": "processing",
+ "details": {
+ "coding": [
+ {
+ "system": "http://example.com/custom-issue-type",
+ "code": "valueset-is-draft"
+ }
+ ]
+ },
+ "diagnostics": "The ValueSet status is marked as draft.",
+ "location": [
+ "Bundle",
+ "Line[1] Col[2]"
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/Configuration.java b/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/Configuration.java
index 3fd0a49aa5e..640bde8c994 100644
--- a/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/Configuration.java
+++ b/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/Configuration.java
@@ -4,7 +4,7 @@ import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.context.FhirVersionEnum;
import ca.uhn.fhir.i18n.Msg;
import ca.uhn.fhir.tinder.parser.BaseStructureSpreadsheetParser;
-import org.apache.commons.lang.WordUtils;
+import org.apache.commons.text.WordUtils;
import java.io.File;
import java.io.IOException;
diff --git a/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/TinderGenericSingleFileMojo.java b/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/TinderGenericSingleFileMojo.java
index e5a2816340f..08fc8f2d7bb 100644
--- a/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/TinderGenericSingleFileMojo.java
+++ b/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/TinderGenericSingleFileMojo.java
@@ -7,7 +7,7 @@ import ca.uhn.fhir.tinder.TinderStructuresMojo.ValueSetFileDefinition;
import ca.uhn.fhir.tinder.parser.BaseStructureParser;
import ca.uhn.fhir.tinder.parser.DatatypeGeneratorUsingSpreadsheet;
import ca.uhn.fhir.tinder.parser.TargetType;
-import org.apache.commons.lang.WordUtils;
+import org.apache.commons.text.WordUtils;
import org.apache.maven.model.Resource;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
diff --git a/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/TinderJpaRestServerMojo.java b/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/TinderJpaRestServerMojo.java
index 4503b47061f..4f2fe43f8f6 100644
--- a/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/TinderJpaRestServerMojo.java
+++ b/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/TinderJpaRestServerMojo.java
@@ -6,7 +6,7 @@ import ca.uhn.fhir.i18n.Msg;
import ca.uhn.fhir.tinder.parser.BaseStructureSpreadsheetParser;
import ca.uhn.fhir.tinder.parser.ResourceGeneratorUsingModel;
import ca.uhn.fhir.util.ClasspathUtil;
-import org.apache.commons.lang.WordUtils;
+import org.apache.commons.text.WordUtils;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
diff --git a/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/ant/TinderGeneratorTask.java b/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/ant/TinderGeneratorTask.java
index 9819edcc795..c8304187c85 100644
--- a/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/ant/TinderGeneratorTask.java
+++ b/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/ant/TinderGeneratorTask.java
@@ -33,7 +33,7 @@ import ca.uhn.fhir.tinder.parser.BaseStructureParser;
import ca.uhn.fhir.tinder.parser.BaseStructureSpreadsheetParser;
import ca.uhn.fhir.tinder.parser.DatatypeGeneratorUsingSpreadsheet;
import ca.uhn.fhir.tinder.parser.TargetType;
-import org.apache.commons.lang.WordUtils;
+import org.apache.commons.text.WordUtils;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
diff --git a/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/model/BaseElement.java b/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/model/BaseElement.java
index 8de25b93376..69c30538f57 100644
--- a/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/model/BaseElement.java
+++ b/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/model/BaseElement.java
@@ -8,8 +8,8 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import static org.apache.commons.lang.StringUtils.defaultString;
-import static org.apache.commons.lang.StringUtils.isNotBlank;
+import static org.apache.commons.lang3.StringUtils.defaultString;
+import static org.apache.commons.lang3.StringUtils.isNotBlank;
public abstract class BaseElement {
diff --git a/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/model/SearchParameter.java b/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/model/SearchParameter.java
index 7ac33c81693..fe8233c02b9 100644
--- a/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/model/SearchParameter.java
+++ b/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/model/SearchParameter.java
@@ -1,7 +1,7 @@
package ca.uhn.fhir.tinder.model;
-import org.apache.commons.lang.WordUtils;
import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.text.WordUtils;
import java.util.ArrayList;
import java.util.Collections;
diff --git a/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/parser/BaseStructureParser.java b/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/parser/BaseStructureParser.java
index 68b28b0b96b..9e465ad18cf 100644
--- a/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/parser/BaseStructureParser.java
+++ b/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/parser/BaseStructureParser.java
@@ -25,9 +25,9 @@ import ca.uhn.fhir.tinder.model.SimpleSetter.Parameter;
import com.google.common.base.Charsets;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang.WordUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.text.WordUtils;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.VelocityEngine;
@@ -56,8 +56,8 @@ import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;
-import static org.apache.commons.lang.StringUtils.defaultString;
-import static org.apache.commons.lang.StringUtils.isNotBlank;
+import static org.apache.commons.lang3.StringUtils.defaultString;
+import static org.apache.commons.lang3.StringUtils.isNotBlank;
public abstract class BaseStructureParser {
diff --git a/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/parser/ResourceGeneratorUsingModel.java b/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/parser/ResourceGeneratorUsingModel.java
index 734a35822ab..0f90505d77b 100644
--- a/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/parser/ResourceGeneratorUsingModel.java
+++ b/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/parser/ResourceGeneratorUsingModel.java
@@ -6,7 +6,7 @@ import ca.uhn.fhir.i18n.Msg;
import ca.uhn.fhir.rest.api.RestSearchParameterTypeEnum;
import ca.uhn.fhir.tinder.model.Resource;
import ca.uhn.fhir.tinder.model.SearchParameter;
-import org.apache.commons.lang.WordUtils;
+import org.apache.commons.text.WordUtils;
import org.apache.maven.plugin.MojoFailureException;
import java.io.File;
diff --git a/pom.xml b/pom.xml
index 31b2d0c455f..9b19056b43d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -999,8 +999,8 @@
2.12.0
1.10.0
- 2.11.0
- 3.14.0
+ 2.17.0
+ 3.17.0
1.2
2.23.0
5.8.0
@@ -1013,15 +1013,15 @@
4.0.4
4.9.0
3.0.3
- 12.0.9
+ 12.0.14
3.0.2
5.10.1
0.64.8
9.4.0
- 6.4.1.Final
+ 6.4.10.Final
1.4.14
- 7.0.0.Final
+ 7.0.1.Final
9.8.0
2.2
@@ -1046,8 +1046,8 @@
2.2.22
2.0.13
2.19.0
- 6.1.8
- 2023.1.6
+ 6.1.14
+ 2024.0.5
4.3.10
3.2.6
2.0.6
@@ -1063,7 +1063,7 @@
1.0.8
- 3.13.0
+ 3.13.1
5.4.1
@@ -1673,7 +1673,7 @@
org.apache.velocity
velocity-engine-core
- 2.3
+ 2.4.1
org.awaitility