diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/BaseTermReadSvcImpl.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/BaseTermReadSvcImpl.java index f41d9285826..75da809c5cd 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/BaseTermReadSvcImpl.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/BaseTermReadSvcImpl.java @@ -395,7 +395,11 @@ public abstract class BaseTermReadSvcImpl implements ITermReadSvc { optionalTermValueSet = myValueSetDao.findTermValueSetByUrlAndVersion(theValueSetToExpand.getUrl(), theValueSetToExpand.getVersion()); } else { List termValueSets = myValueSetDao.findTermValueSetByUrl(PageRequest.of(0, 1), theValueSetToExpand.getUrl()); - optionalTermValueSet = Optional.of(termValueSets.get(0)); + if (termValueSets.size() > 0) { + optionalTermValueSet = Optional.of(termValueSets.get(0)); + } else { + optionalTermValueSet = Optional.empty(); + } } } else { optionalTermValueSet = Optional.empty(); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4CodeSystemTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4CodeSystemTest.java index 9d917a7af8a..fa4c2aae93b 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4CodeSystemTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4CodeSystemTest.java @@ -61,7 +61,7 @@ public class FhirResourceDaoR4CodeSystemTest extends BaseJpaR4Test { // Now the background scheduler will do its thing myTerminologyDeferredStorageSvc.saveDeferred(); runInTransaction(() -> { - assertEquals(0, myTermCodeSystemDao.count()); + assertEquals(1, myTermCodeSystemDao.count()); assertEquals(0, myTermCodeSystemVersionDao.count()); assertEquals(0, myTermConceptDao.count()); }); @@ -155,7 +155,7 @@ public class FhirResourceDaoR4CodeSystemTest extends BaseJpaR4Test { // The remaining versions and Code System entities should be gone now. runInTransaction(() -> { - assertEquals(0, myTermCodeSystemDao.count()); + assertEquals(1, myTermCodeSystemDao.count()); assertNull(myTermCodeSystemDao.findByCodeSystemUri("http://foo")); assertEquals(0, myTermCodeSystemVersionDao.count()); List resourceList = myResourceTableDao.findAll(); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4CodeSystemVersionedTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4CodeSystemVersionedTest.java index 8853d23a439..5e621e84ad7 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4CodeSystemVersionedTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4CodeSystemVersionedTest.java @@ -31,10 +31,18 @@ public class ResourceProviderR4CodeSystemVersionedTest extends BaseResourceProvi @BeforeEach @Transactional public void before02() throws IOException { - CodeSystem cs = loadResourceFromClasspath(CodeSystem.class, "/extensional-case-3-cs-v1.xml"); + CodeSystem cs = loadResourceFromClasspath(CodeSystem.class, "/extensional-case-3-cs.xml"); + cs.setVersion("1"); + for(CodeSystem.ConceptDefinitionComponent conceptDefinitionComponent : cs.getConcept()) { + conceptDefinitionComponent.setDisplay(conceptDefinitionComponent.getDisplay() + " v1"); + } myCodeSystemDao.create(cs, mySrd); - cs = loadResourceFromClasspath(CodeSystem.class, "/extensional-case-3-cs-v2.xml"); + cs = loadResourceFromClasspath(CodeSystem.class, "/extensional-case-3-cs.xml"); + cs.setVersion("2"); + for(CodeSystem.ConceptDefinitionComponent conceptDefinitionComponent : cs.getConcept()) { + conceptDefinitionComponent.setDisplay(conceptDefinitionComponent.getDisplay() + " v2"); + } myCodeSystemDao.create(cs, mySrd); CodeSystem parentChildCs = new CodeSystem(); @@ -310,7 +318,7 @@ public class ResourceProviderR4CodeSystemVersionedTest extends BaseResourceProvi assertEquals("version", respParam.getParameter().get(1).getName()); assertEquals("1", ((StringType) respParam.getParameter().get(1).getValue()).getValue()); assertEquals("display", respParam.getParameter().get(2).getName()); - assertEquals(("Systolic blood pressure--expiration"), ((StringType) respParam.getParameter().get(2).getValue()).getValue()); + assertEquals(("Systolic blood pressure--expiration v1"), ((StringType) respParam.getParameter().get(2).getValue()).getValue()); assertEquals("abstract", respParam.getParameter().get(3).getName()); assertEquals(false, ((BooleanType) respParam.getParameter().get(3).getValue()).getValue()); @@ -392,7 +400,7 @@ public class ResourceProviderR4CodeSystemVersionedTest extends BaseResourceProvi assertEquals("version", respParam.getParameter().get(1).getName()); assertEquals("1", ((StringType) respParam.getParameter().get(1).getValue()).getValue()); assertEquals("display", respParam.getParameter().get(2).getName()); - assertEquals(("Systolic blood pressure--expiration"), ((StringType) respParam.getParameter().get(2).getValue()).getValue()); + assertEquals(("Systolic blood pressure--expiration v1"), ((StringType) respParam.getParameter().get(2).getValue()).getValue()); assertEquals("abstract", respParam.getParameter().get(3).getName()); assertEquals(false, ((BooleanType) respParam.getParameter().get(3).getValue()).getValue()); diff --git a/hapi-fhir-jpaserver-base/src/test/resources/extensional-case-3-cs-v1.xml b/hapi-fhir-jpaserver-base/src/test/resources/extensional-case-3-cs-v1.xml deleted file mode 100644 index dc023fe3811..00000000000 --- a/hapi-fhir-jpaserver-base/src/test/resources/extensional-case-3-cs-v1.xml +++ /dev/null @@ -1,101 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/hapi-fhir-jpaserver-base/src/test/resources/extensional-case-3-cs-v2.xml b/hapi-fhir-jpaserver-base/src/test/resources/extensional-case-3-cs-v2.xml deleted file mode 100644 index a9868b624da..00000000000 --- a/hapi-fhir-jpaserver-base/src/test/resources/extensional-case-3-cs-v2.xml +++ /dev/null @@ -1,101 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -