diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/config/TestDstu3Config.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/config/TestDstu3Config.java index 578edef274d..4b418e87de0 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/config/TestDstu3Config.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/config/TestDstu3Config.java @@ -40,6 +40,7 @@ public class TestDstu3Config extends BaseJavaConfigDstu3 { DataSource dataSource = ProxyDataSourceBuilder .create(retVal) + .multiline() .logQueryBySlf4j(SLF4JLogLevel.INFO, "SQL") .logSlowQueryBySlf4j(10, TimeUnit.SECONDS) .countQuery() diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/BaseJpaDstu3Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/BaseJpaDstu3Test.java index 1f9dbd013b3..38d94f9af7f 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/BaseJpaDstu3Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/BaseJpaDstu3Test.java @@ -27,6 +27,7 @@ import org.hl7.fhir.dstu3.model.Condition; import org.hl7.fhir.dstu3.model.Device; import org.hl7.fhir.dstu3.model.DiagnosticReport; import org.hl7.fhir.dstu3.model.Encounter; +import org.hl7.fhir.dstu3.model.Group; import org.hl7.fhir.dstu3.model.Immunization; import org.hl7.fhir.dstu3.model.ImmunizationRecommendation; import org.hl7.fhir.dstu3.model.Location; @@ -77,7 +78,10 @@ import ca.uhn.fhir.jpa.dao.IFhirResourceDaoValueSet; import ca.uhn.fhir.jpa.dao.IFhirSystemDao; import ca.uhn.fhir.jpa.dao.IFulltextSearchSvc; import ca.uhn.fhir.jpa.dao.ISearchParamRegistry; -import ca.uhn.fhir.jpa.dao.data.*; +import ca.uhn.fhir.jpa.dao.data.IResourceTableDao; +import ca.uhn.fhir.jpa.dao.data.IResourceTagDao; +import ca.uhn.fhir.jpa.dao.data.ISearchDao; +import ca.uhn.fhir.jpa.dao.data.ITagDefinitionDao; import ca.uhn.fhir.jpa.dao.dstu2.FhirResourceDaoDstu2SearchNoFtTest; import ca.uhn.fhir.jpa.entity.ResourceIndexedSearchParamString; import ca.uhn.fhir.jpa.entity.ResourceTable; @@ -104,24 +108,13 @@ public abstract class BaseJpaDstu3Test extends BaseJpaTest { private static JpaValidationSupportChainDstu3 ourJpaValidationSupportChainDstu3; private static IFhirResourceDaoValueSet ourValueSetDao; - @Autowired - protected ITagDefinitionDao myTagDefinitionDao; - @Autowired - protected IResourceTagDao myResourceTagDao; - @Autowired - protected ISearchDao mySearchEntityDao; - @Autowired - @Qualifier("mySearchParameterDaoDstu3") - protected IFhirResourceDao mySearchParameterDao; - @Autowired - protected ISearchParamRegistry mySearchParamRegsitry; -// @Autowired + // @Autowired // protected HapiWorkerContext myHapiWorkerContext; @Autowired @Qualifier("myAllergyIntoleranceDaoDstu3") protected IFhirResourceDao myAllergyIntoleranceDao; @Autowired - protected ApplicationContext myAppCtx; + protected ApplicationContext myAppCtx; @Autowired @Qualifier("myAppointmentDaoDstu3") protected IFhirResourceDao myAppointmentDao; @@ -131,13 +124,10 @@ public abstract class BaseJpaDstu3Test extends BaseJpaTest { @Autowired @Qualifier("myBundleDaoDstu3") protected IFhirResourceDao myBundleDao; - @Autowired +@Autowired @Qualifier("myCarePlanDaoDstu3") protected IFhirResourceDao myCarePlanDao; @Autowired - @Qualifier("myProcedureRequestDaoDstu3") - protected IFhirResourceDao myProcedureRequestDao; - @Autowired @Qualifier("myCodeSystemDaoDstu3") protected IFhirResourceDaoCodeSystem myCodeSystemDao; @Autowired @@ -166,6 +156,9 @@ public abstract class BaseJpaDstu3Test extends BaseJpaTest { @Autowired protected FhirContext myFhirCtx; @Autowired + @Qualifier("myGroupDaoDstu3") + protected IFhirResourceDao myGroupDao; + @Autowired @Qualifier("myImmunizationDaoDstu3") protected IFhirResourceDao myImmunizationDao; @Autowired @@ -181,12 +174,12 @@ public abstract class BaseJpaDstu3Test extends BaseJpaTest { @Qualifier("myMediaDaoDstu3") protected IFhirResourceDao myMediaDao; @Autowired - @Qualifier("myMedicationDaoDstu3") - protected IFhirResourceDao myMedicationDao; - @Autowired @Qualifier("myMedicationAdministrationDaoDstu3") protected IFhirResourceDao myMedicationAdministrationDao; @Autowired + @Qualifier("myMedicationDaoDstu3") + protected IFhirResourceDao myMedicationDao; + @Autowired @Qualifier("myMedicationRequestDaoDstu3") protected IFhirResourceDao myMedicationRequestDao; @Autowired @@ -202,15 +195,15 @@ public abstract class BaseJpaDstu3Test extends BaseJpaTest { @Qualifier("myOrganizationDaoDstu3") protected IFhirResourceDao myOrganizationDao; @Autowired - @Qualifier("myTaskDaoDstu3") - protected IFhirResourceDao myTaskDao; - @Autowired @Qualifier("myPatientDaoDstu3") protected IFhirResourceDaoPatient myPatientDao; @Autowired @Qualifier("myPractitionerDaoDstu3") protected IFhirResourceDao myPractitionerDao; @Autowired + @Qualifier("myProcedureRequestDaoDstu3") + protected IFhirResourceDao myProcedureRequestDao; + @Autowired @Qualifier("myQuestionnaireDaoDstu3") protected IFhirResourceDao myQuestionnaireDao; @Autowired @@ -222,8 +215,21 @@ public abstract class BaseJpaDstu3Test extends BaseJpaTest { @Autowired protected IResourceTableDao myResourceTableDao; @Autowired + protected IResourceTagDao myResourceTagDao; + @Autowired + protected ISearchCoordinatorSvc mySearchCoordinatorSvc; + @Autowired protected IFulltextSearchSvc mySearchDao; @Autowired + protected ISearchDao mySearchEntityDao; + @Autowired + @Qualifier("mySearchParameterDaoDstu3") + protected IFhirResourceDao mySearchParameterDao; + @Autowired + protected ISearchParamPresenceSvc mySearchParamPresenceSvc; + @Autowired + protected ISearchParamRegistry mySearchParamRegsitry; + @Autowired protected IStaleSearchDeletingSvc myStaleSearchDeletingSvc; @Autowired @Qualifier("myStructureDefinitionDaoDstu3") @@ -241,8 +247,15 @@ public abstract class BaseJpaDstu3Test extends BaseJpaTest { @Qualifier("mySystemProviderDstu3") protected JpaSystemProviderDstu3 mySystemProvider; @Autowired + protected ITagDefinitionDao myTagDefinitionDao; + @Autowired + @Qualifier("myTaskDaoDstu3") + protected IFhirResourceDao myTaskDao; + @Autowired protected IHapiTerminologySvc myTermSvc; @Autowired + protected PlatformTransactionManager myTransactionMgr; + @Autowired protected PlatformTransactionManager myTxManager; @Autowired @Qualifier("myJpaValidationSupportChainDstu3") @@ -250,18 +263,6 @@ public abstract class BaseJpaDstu3Test extends BaseJpaTest { @Autowired @Qualifier("myValueSetDaoDstu3") protected IFhirResourceDaoValueSet myValueSetDao; - @Autowired - protected PlatformTransactionManager myTransactionMgr; - @Autowired - protected ISearchParamPresenceSvc mySearchParamPresenceSvc; - @Autowired - protected ISearchCoordinatorSvc mySearchCoordinatorSvc; - - @After() - public void afterGrabCaches() { - ourValueSetDao = myValueSetDao; - ourJpaValidationSupportChainDstu3 = myJpaValidationSupportChainDstu3; - } @After() public void afterCleanupDao() { @@ -271,6 +272,12 @@ public abstract class BaseJpaDstu3Test extends BaseJpaTest { myDaoConfig.setSuppressUpdatesWithNoChange(new DaoConfig().isSuppressUpdatesWithNoChange()); } + @After() + public void afterGrabCaches() { + ourValueSetDao = myValueSetDao; + ourJpaValidationSupportChainDstu3 = myJpaValidationSupportChainDstu3; + } + @Before public void beforeCreateInterceptor() { myInterceptor = mock(IServerInterceptor.class); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3SearchNoFtTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3SearchNoFtTest.java index 109984e1f9b..ee43c8f5e0d 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3SearchNoFtTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3SearchNoFtTest.java @@ -43,6 +43,7 @@ import org.hl7.fhir.dstu3.model.Device; import org.hl7.fhir.dstu3.model.DiagnosticReport; import org.hl7.fhir.dstu3.model.Encounter; import org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender; +import org.hl7.fhir.dstu3.model.Group; import org.hl7.fhir.dstu3.model.IdType; import org.hl7.fhir.dstu3.model.Immunization; import org.hl7.fhir.dstu3.model.ImmunizationRecommendation; @@ -157,13 +158,65 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test { public void testEmptyChain() { SearchParameterMap map = new SearchParameterMap(); - map.add(Encounter.SP_SUBJECT, new ReferenceAndListParam().addAnd(new ReferenceOrListParam().add((ReferenceParam)new ReferenceParam("subject", "04823543").setChain("identifier")))); + map.add(Encounter.SP_SUBJECT, new ReferenceAndListParam().addAnd(new ReferenceOrListParam().add(new ReferenceParam("subject", "04823543").setChain("identifier")))); IBundleProvider results = myMedicationAdministrationDao.search(map); List ids = toUnqualifiedIdValues(results); assertThat(ids, empty()); } + @Test + public void testChainWithMultipleTypePossibilities() { + + Patient sub1 = new Patient(); + sub1.setActive(true); + sub1.addIdentifier().setSystem("foo").setValue("bar"); + String sub1Id = myPatientDao.create(sub1).getId().toUnqualifiedVersionless().getValue(); + + Group sub2 = new Group(); + sub2.setActive(true); + sub2.addIdentifier().setSystem("foo").setValue("bar"); + String sub2Id = myGroupDao.create(sub2).getId().toUnqualifiedVersionless().getValue(); + + Encounter enc1 = new Encounter(); + enc1.getSubject().setReference(sub1Id); + String enc1Id = myEncounterDao.create(enc1).getId().toUnqualifiedVersionless().getValue(); + + Encounter enc2 = new Encounter(); + enc2.getSubject().setReference(sub2Id); + String enc2Id = myEncounterDao.create(enc2).getId().toUnqualifiedVersionless().getValue(); + + List ids; + SearchParameterMap map; + IBundleProvider results; + + map = new SearchParameterMap(); + map.add(Encounter.SP_SUBJECT, new ReferenceParam("subject", "foo|bar").setChain("identifier")); + results = myEncounterDao.search(map); + ids = toUnqualifiedVersionlessIdValues(results); + assertThat(ids, hasItems(enc1Id, enc2Id)); + + System.exit(0); + + map = new SearchParameterMap(); + map.add(Encounter.SP_SUBJECT, new ReferenceParam("subject:Patient", "foo|bar").setChain("identifier")); + results = myEncounterDao.search(map); + ids = toUnqualifiedVersionlessIdValues(results); + assertThat(ids, hasItems(enc1Id)); + + map = new SearchParameterMap(); + map.add(Encounter.SP_SUBJECT, new ReferenceParam("subject:Group", "foo|bar").setChain("identifier")); + results = myEncounterDao.search(map); + ids = toUnqualifiedVersionlessIdValues(results); + assertThat(ids, hasItems(enc2Id)); + + map = new SearchParameterMap(); + map.add(Encounter.SP_SUBJECT, new ReferenceParam("subject", "04823543").setChain("identifier")); + results = myEncounterDao.search(map); + ids = toUnqualifiedVersionlessIdValues(results); + assertThat(ids, empty()); + } + @Test public void testEverythingTimings() throws Exception { String methodName = "testEverythingTimings"; diff --git a/src/changes/changes.xml b/src/changes/changes.xml index c33817e9798..c3e90878508 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -45,7 +45,7 @@ Add configuration to JPA server DaoConfig that allows a maximum number of search results to be specified. Queries will never return more than this number, which can be good for avoiding accidental - performance problems in situations where lare queries should not be + performance problems in situations where large queries should not be needed