From 6c3446dee1cf262724ccf579a694c821048ba145 Mon Sep 17 00:00:00 2001 From: James Agnew Date: Tue, 17 May 2016 11:30:57 -0400 Subject: [PATCH] Fix build --- .../rest/method/ConditionalParamBinder.java | 4 ++ .../dstu3/FhirResourceDaoCodeSystemDstu3.java | 4 +- .../dao/dstu3/SearchParamExtractorDstu3.java | 15 +++++++ .../fhir/jpa/dao/dstu3/BaseJpaDstu3Test.java | 4 ++ .../dao/dstu3/FhirResourceDaoDstu3Test.java | 41 +++++++++++++++++++ 5 files changed, 66 insertions(+), 2 deletions(-) diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/ConditionalParamBinder.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/ConditionalParamBinder.java index 1a418009522..073bd67a09c 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/ConditionalParamBinder.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/ConditionalParamBinder.java @@ -26,6 +26,7 @@ import java.util.Collection; import java.util.List; import java.util.Map; +import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.Validate; import org.hl7.fhir.instance.model.api.IBaseResource; @@ -85,6 +86,9 @@ class ConditionalParamBinder implements IParameter { } int questionMarkIndex = theRequest.getCompleteUrl().indexOf('?'); + if (questionMarkIndex == -1) { + return null; + } return theRequest.getResourceName() + theRequest.getCompleteUrl().substring(questionMarkIndex); } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoCodeSystemDstu3.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoCodeSystemDstu3.java index 5b58e02609f..ec63a7f7ce6 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoCodeSystemDstu3.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoCodeSystemDstu3.java @@ -213,9 +213,9 @@ public class FhirResourceDaoCodeSystemDstu3 extends FhirResourceDaoDstu3 myCarePlanDao; @Autowired + @Qualifier("myConditionDaoDstu3") + protected IFhirResourceDao myConditionDao; + @Autowired @Qualifier("myCodeSystemDaoDstu3") protected IFhirResourceDao myCodeSystemDao; @Autowired diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3Test.java index d2125459309..70ec07fadc8 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3Test.java @@ -35,23 +35,27 @@ import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.RandomStringUtils; import org.hamcrest.Matchers; import org.hamcrest.core.StringContains; +import org.hl7.fhir.dstu3.model.Age; import org.hl7.fhir.dstu3.model.BaseResource; import org.hl7.fhir.dstu3.model.Bundle; import org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent; import org.hl7.fhir.dstu3.model.Bundle.BundleType; import org.hl7.fhir.dstu3.model.Bundle.HTTPVerb; import org.hl7.fhir.dstu3.model.CarePlan; +import org.hl7.fhir.dstu3.model.CodeSystem; import org.hl7.fhir.dstu3.model.CodeType; import org.hl7.fhir.dstu3.model.CodeableConcept; import org.hl7.fhir.dstu3.model.Coding; import org.hl7.fhir.dstu3.model.CompartmentDefinition; import org.hl7.fhir.dstu3.model.ConceptMap; +import org.hl7.fhir.dstu3.model.Condition; import org.hl7.fhir.dstu3.model.DateTimeType; import org.hl7.fhir.dstu3.model.DateType; 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.Enumerations.ConformanceResourceStatus; import org.hl7.fhir.dstu3.model.IdType; import org.hl7.fhir.dstu3.model.Meta; import org.hl7.fhir.dstu3.model.NamingSystem; @@ -66,7 +70,9 @@ import org.hl7.fhir.dstu3.model.Period; import org.hl7.fhir.dstu3.model.Quantity; import org.hl7.fhir.dstu3.model.Quantity.QuantityComparator; import org.hl7.fhir.dstu3.model.Questionnaire; +import org.hl7.fhir.dstu3.model.Range; import org.hl7.fhir.dstu3.model.Reference; +import org.hl7.fhir.dstu3.model.SimpleQuantity; import org.hl7.fhir.dstu3.model.StringType; import org.hl7.fhir.dstu3.model.StructureDefinition; import org.hl7.fhir.dstu3.model.Timing; @@ -134,6 +140,41 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test { } } + @Test + public void testCodeSystemCreateAndDelete() { + CodeSystem cs = new CodeSystem(); + cs.setStatus(ConformanceResourceStatus.DRAFT); + IIdType id = myCodeSystemDao.create(cs, mySrd).getId().toUnqualifiedVersionless(); + + myCodeSystemDao.delete(id, mySrd); + + assertGone(id.toUnqualifiedVersionless()); + } + + @Test + public void testIndexConditionWithAllOnsetTypes() { + // DateTimeType.class, Age.class, Period.class, Range.class, StringType.class + + Condition c0 = new Condition(); + c0.setOnset(new DateTimeType("2011-01-01")); + IIdType id0 = myConditionDao.create(c0, mySrd).getId().toUnqualifiedVersionless(); + + Condition c1 = new Condition(); + c1.setOnset(new Age().setValue(100l).setCode("AGECODE")); + IIdType id1 = myConditionDao.create(c1, mySrd).getId().toUnqualifiedVersionless(); + + Condition c2 = new Condition(); + c2.setOnset(new Period().setStart(new Date()).setEnd(new Date())); + IIdType id2 = myConditionDao.create(c2, mySrd).getId().toUnqualifiedVersionless(); + + Condition c3 = new Condition(); + c3.setOnset(new Range().setLow((SimpleQuantity) new SimpleQuantity().setValue(200L)).setHigh((SimpleQuantity) new SimpleQuantity().setValue(300L))); + IIdType id3 = myConditionDao.create(c3, mySrd).getId().toUnqualifiedVersionless(); + + Condition c4 = new Condition(); + c4.setOnset(new StringType("FOO")); + IIdType id4 = myConditionDao.create(c4, mySrd).getId().toUnqualifiedVersionless(); +} @Test @Ignore