diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/BaseHapiTerminologySvcImpl.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/BaseHapiTerminologySvcImpl.java index 0887a04f6bd..fe562f4298c 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/BaseHapiTerminologySvcImpl.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/BaseHapiTerminologySvcImpl.java @@ -32,9 +32,11 @@ import ca.uhn.fhir.jpa.util.ScrollableResultsIterator; import ca.uhn.fhir.rest.api.server.RequestDetails; import ca.uhn.fhir.rest.server.exceptions.InternalErrorException; import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; +import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException; import ca.uhn.fhir.util.ObjectUtil; import ca.uhn.fhir.util.StopWatch; +import ca.uhn.fhir.util.UrlUtil; import ca.uhn.fhir.util.ValidateUtil; import com.github.benmanes.caffeine.cache.Cache; import com.github.benmanes.caffeine.cache.Caffeine; @@ -487,7 +489,6 @@ public abstract class BaseHapiTerminologySvcImpl implements IHapiTerminologySvc, if (!optionalTermValueSet.isPresent()) { ourLog.warn("ValueSet is not present in terminology tables. Will perform in-memory expansion without parameters. Will schedule this ValueSet for pre-expansion. {}", getValueSetInfo(theValueSetToExpand)); - myDeferredValueSets.add(theValueSetToExpand); return expandValueSet(theValueSetToExpand); // In-memory expansion. } @@ -2366,6 +2367,10 @@ public abstract class BaseHapiTerminologySvcImpl implements IHapiTerminologySvc, return retVal; } + protected void throwInvalidValueSet(String theValueSet) { + throw new ResourceNotFoundException("Unknown ValueSet: " + UrlUtil.escapeUrlParam(theValueSet)); + } + private static void extractLinksFromConceptAndChildren(TermConcept theConcept, List theLinks) { theLinks.addAll(theConcept.getParents()); for (TermConceptParentChildLink child : theConcept.getChildren()) { diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/HapiTerminologySvcDstu3.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/HapiTerminologySvcDstu3.java index 0070469c00f..e50a2fecb7c 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/HapiTerminologySvcDstu3.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/HapiTerminologySvcDstu3.java @@ -212,7 +212,7 @@ public class HapiTerminologySvcDstu3 extends BaseHapiTerminologySvcImpl implemen public List expandValueSet(String theValueSet) { ValueSet vs = myValidationSupport.fetchResource(myContext, ValueSet.class, theValueSet); if (vs == null) { - return Collections.emptyList(); + super.throwInvalidValueSet(theValueSet); } org.hl7.fhir.r4.model.ValueSet valueSetToExpandR4; diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/HapiTerminologySvcR4.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/HapiTerminologySvcR4.java index e9498856f14..e0845156c09 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/HapiTerminologySvcR4.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/HapiTerminologySvcR4.java @@ -124,7 +124,7 @@ public class HapiTerminologySvcR4 extends BaseHapiTerminologySvcImpl implements public List expandValueSet(String theValueSet) {//FIXME: DM COWABUNGA ValueSet vs = myValidationSupport.fetchResource(myContext, ValueSet.class, theValueSet); if (vs == null) { - return Collections.emptyList(); + super.throwInvalidValueSet(theValueSet); } return expandValueSetAndReturnVersionIndependentConcepts(vs); diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/HapiTerminologySvcR5.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/HapiTerminologySvcR5.java index ede8dc78120..a23d7120fa4 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/HapiTerminologySvcR5.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/HapiTerminologySvcR5.java @@ -133,7 +133,7 @@ public class HapiTerminologySvcR5 extends BaseHapiTerminologySvcImpl implements public List expandValueSet(String theValueSet) { ValueSet valueSetR5 = myValidationSupport.fetchResource(myContext, ValueSet.class, theValueSet); if (valueSetR5 == null) { - return Collections.emptyList(); + super.throwInvalidValueSet(theValueSet); } return expandValueSetAndReturnVersionIndependentConcepts(org.hl7.fhir.convertors.conv40_50.ValueSet.convertValueSet(valueSetR5));