From 12dc4d1c1162d48b3784fb07ebdc349a6eaf5f31 Mon Sep 17 00:00:00 2001 From: James Date: Sat, 4 Feb 2017 07:14:21 -0500 Subject: [PATCH] Work on custom params --- hapi-fhir-base-test-mindeps-client/.classpath | 23 ++++++----- hapi-fhir-base-test-mindeps-client/.project | 12 +++++- .../fhir/jpa/dao/BaseHapiFhirResourceDao.java | 4 ++ ...rceProviderCustomSearchParamDstu3Test.java | 38 ++++++++++++++++++- 4 files changed, 65 insertions(+), 12 deletions(-) diff --git a/hapi-fhir-base-test-mindeps-client/.classpath b/hapi-fhir-base-test-mindeps-client/.classpath index d1d9fe67b77..9d7b3cb8dc2 100644 --- a/hapi-fhir-base-test-mindeps-client/.classpath +++ b/hapi-fhir-base-test-mindeps-client/.classpath @@ -1,16 +1,21 @@ - - + + + + + + + + + + + + + - - - - - - - + diff --git a/hapi-fhir-base-test-mindeps-client/.project b/hapi-fhir-base-test-mindeps-client/.project index 9cf5c48e336..096c7c04956 100644 --- a/hapi-fhir-base-test-mindeps-client/.project +++ b/hapi-fhir-base-test-mindeps-client/.project @@ -1,7 +1,7 @@ - hapi-fhir-base-testmindeps-client - + hapi-fhir-base-test-mindeps-client + NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. @@ -10,6 +10,11 @@ + + org.eclipse.jdt.core.javabuilder + + + org.eclipse.m2e.core.maven2Builder @@ -17,7 +22,10 @@ + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature org.eclipse.m2e.core.maven2Nature + org.eclipse.jdt.core.javanature org.eclipse.wst.common.project.facet.core.nature diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirResourceDao.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirResourceDao.java index 63e74ffcd5c..337e0ad8321 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirResourceDao.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirResourceDao.java @@ -1051,6 +1051,10 @@ public abstract class BaseHapiFhirResourceDao extends B @Override public void translateRawParameters(Map> theSource, SearchParameterMap theTarget) { + if (theSource == null || theSource.isEmpty()) { + return; + } + Map searchParams = mySerarchParamRegistry.getActiveSearchParams(getResourceName()); Set paramNames = theSource.keySet(); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderCustomSearchParamDstu3Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderCustomSearchParamDstu3Test.java index 4494fc86423..695af8eda4a 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderCustomSearchParamDstu3Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderCustomSearchParamDstu3Test.java @@ -11,6 +11,7 @@ import java.util.List; import org.hl7.fhir.dstu3.model.Bundle; import org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender; import org.hl7.fhir.dstu3.model.Observation; +import org.hl7.fhir.dstu3.model.Observation.ObservationStatus; import org.hl7.fhir.dstu3.model.Patient; import org.hl7.fhir.dstu3.model.SearchParameter; import org.hl7.fhir.dstu3.model.SearchParameter.XPathUsageType; @@ -19,8 +20,10 @@ import org.junit.After; import org.junit.AfterClass; import org.junit.Test; +import ca.uhn.fhir.jpa.dao.BaseHapiFhirDao; import ca.uhn.fhir.jpa.dao.DaoConfig; import ca.uhn.fhir.jpa.dao.SearchParameterMap; +import ca.uhn.fhir.jpa.entity.ResourceTable; import ca.uhn.fhir.rest.gclient.ReferenceClientParam; import ca.uhn.fhir.rest.gclient.TokenClientParam; import ca.uhn.fhir.rest.server.IBundleProvider; @@ -78,7 +81,7 @@ public class ResourceProviderCustomSearchParamDstu3Test extends BaseResourceProv IIdType patId = myPatientDao.create(pat, mySrd).getId().toUnqualifiedVersionless(); Patient pat2 = new Patient(); - pat.setGender(AdministrativeGender.FEMALE); + pat2.setGender(AdministrativeGender.FEMALE); IIdType patId2 = myPatientDao.create(pat2, mySrd).getId().toUnqualifiedVersionless(); SearchParameterMap map; @@ -97,6 +100,39 @@ public class ResourceProviderCustomSearchParamDstu3Test extends BaseResourceProv } + + @Test + public void testCreatingParamMarksCorrectResourcesForReindexing() { + Patient pat = new Patient(); + pat.setGender(AdministrativeGender.MALE); + IIdType patId = myPatientDao.create(pat, mySrd).getId().toUnqualifiedVersionless(); + + Observation obs2 = new Observation(); + obs2.setStatus(ObservationStatus.FINAL); + IIdType obsId = myObservationDao.create(obs2, mySrd).getId().toUnqualifiedVersionless(); + + ResourceTable res = myResourceTableDao.findOne(patId.getIdPartAsLong()); + assertEquals(BaseHapiFhirDao.INDEX_STATUS_INDEXED, res.getIndexStatus().longValue()); + res = myResourceTableDao.findOne(obsId.getIdPartAsLong()); + assertEquals(BaseHapiFhirDao.INDEX_STATUS_INDEXED, res.getIndexStatus().longValue()); + + SearchParameter fooSp = new SearchParameter(); + fooSp.setCode("foo"); + fooSp.setType(org.hl7.fhir.dstu3.model.Enumerations.SearchParamType.TOKEN); + fooSp.setTitle("FOO SP"); + fooSp.setXpath("Patient.gender"); + fooSp.setXpathUsage(org.hl7.fhir.dstu3.model.SearchParameter.XPathUsageType.NORMAL); + fooSp.setStatus(org.hl7.fhir.dstu3.model.Enumerations.PublicationStatus.ACTIVE); + mySearchParameterDao.create(fooSp, mySrd); + + res = myResourceTableDao.findOne(patId.getIdPartAsLong()); + assertEquals(null, res.getIndexStatus()); + res = myResourceTableDao.findOne(obsId.getIdPartAsLong()); + assertEquals(BaseHapiFhirDao.INDEX_STATUS_INDEXED, res.getIndexStatus().longValue()); + + } + + @SuppressWarnings("unused") @Test public void testSearchQualifiedWithCustomReferenceParam() {