From ea99672e6c54159ffd0df362d2e0711b0ea38cbf Mon Sep 17 00:00:00 2001 From: James Agnew Date: Wed, 29 Jun 2016 09:56:05 -0400 Subject: [PATCH 1/3] Add tests for term svc --- .../dstu3/FhirResourceDaoValueSetDstu3.java | 21 +++----- .../jpa/term/HapiTerminologySvcDstu3.java | 1 - .../FhirResourceDaoDstu3TerminologyTest.java | 52 +++++++++++-------- .../dstu2/ServerConformanceProvider.java | 1 - .../terminologies/ValueSetExpanderSimple.java | 2 + 5 files changed, 40 insertions(+), 37 deletions(-) diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoValueSetDstu3.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoValueSetDstu3.java index ac9092beaef..249a7516b96 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoValueSetDstu3.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoValueSetDstu3.java @@ -23,21 +23,15 @@ package ca.uhn.fhir.jpa.dao.dstu3; import static org.apache.commons.lang3.StringUtils.isBlank; import static org.apache.commons.lang3.StringUtils.isNotBlank; -import java.nio.file.FileVisitOption; import java.util.ArrayList; import java.util.Collections; -import java.util.Date; -import java.util.Iterator; import java.util.List; import java.util.Set; import org.apache.commons.codec.binary.StringUtils; -import org.hl7.fhir.dstu3.exceptions.TerminologyServiceException; import org.hl7.fhir.dstu3.hapi.validation.HapiWorkerContext; import org.hl7.fhir.dstu3.hapi.validation.IValidationSupport; -import org.hl7.fhir.dstu3.hapi.validation.IValidationSupport.CodeValidationResult; import org.hl7.fhir.dstu3.model.CodeSystem; -import org.hl7.fhir.dstu3.model.CodeSystem.ConceptDefinitionComponent; import org.hl7.fhir.dstu3.model.CodeableConcept; import org.hl7.fhir.dstu3.model.Coding; import org.hl7.fhir.dstu3.model.IdType; @@ -46,7 +40,6 @@ import org.hl7.fhir.dstu3.model.ValueSet; import org.hl7.fhir.dstu3.model.ValueSet.ConceptSetComponent; import org.hl7.fhir.dstu3.model.ValueSet.ConceptSetFilterComponent; import org.hl7.fhir.dstu3.model.ValueSet.FilterOperator; -import org.hl7.fhir.dstu3.model.ValueSet.ValueSetExpansionComponent; import org.hl7.fhir.dstu3.model.ValueSet.ValueSetExpansionContainsComponent; import org.hl7.fhir.dstu3.terminologies.ValueSetExpander.ValueSetExpansionOutcome; import org.hl7.fhir.instance.model.api.IIdType; @@ -86,12 +79,14 @@ public class FhirResourceDaoValueSetDstu3 extends FhirResourceDaoDstu3 HapiWorkerContext workerContext = new HapiWorkerContext(getContext(), myValidationSupport); ValueSetExpansionOutcome outcome = workerContext.expand(theSource); - ValueSetExpansionComponent expansion = outcome.getValueset().getExpansion(); - - ValueSet retVal = new ValueSet(); - retVal.getMeta().setLastUpdated(new Date()); - retVal.setExpansion(expansion); - return retVal; + return outcome.getValueset(); + +// ValueSetExpansionComponent expansion = outcome.getValueset().getExpansion(); +// +// ValueSet retVal = new ValueSet(); +// retVal.getMeta().setLastUpdated(new Date()); +// retVal.setExpansion(expansion); +// return retVal; } private void validateIncludes(String name, List listToValidate) { 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 11c2fcc430c..1a74ec62b06 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 @@ -29,7 +29,6 @@ import java.util.List; import java.util.Set; import org.apache.lucene.search.Query; -import org.apache.lucene.search.QueryWrapperFilter; import org.hibernate.search.jpa.FullTextEntityManager; import org.hibernate.search.jpa.FullTextQuery; import org.hibernate.search.query.dsl.BooleanJunction; diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3TerminologyTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3TerminologyTest.java index 0b6b82eb461..078f2ea2870 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3TerminologyTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3TerminologyTest.java @@ -34,11 +34,14 @@ import ca.uhn.fhir.jpa.entity.ResourceTable; import ca.uhn.fhir.jpa.entity.TermCodeSystemVersion; import ca.uhn.fhir.jpa.entity.TermConcept; import ca.uhn.fhir.jpa.entity.TermConceptParentChildLink.RelationshipTypeEnum; +import ca.uhn.fhir.parser.IParser; import ca.uhn.fhir.rest.param.TokenParam; import ca.uhn.fhir.rest.param.TokenParamModifier; import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException; import ca.uhn.fhir.util.TestUtil; +import ca.uhn.fhir.validation.FhirValidator; +import ca.uhn.fhir.validation.ValidationResult; public class FhirResourceDaoDstu3TerminologyTest extends BaseJpaDstu3Test { @@ -192,14 +195,29 @@ public class FhirResourceDaoDstu3TerminologyTest extends BaseJpaDstu3Test { exclude.addConcept().setCode("childAAA"); ValueSet result = myValueSetDao.expand(vs, null); - - String encoded = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(result); - ourLog.info(encoded); + logAndValidateValueSet(result); ArrayList codes = toCodesContains(result.getExpansion().getContains()); assertThat(codes, containsInAnyOrder("ParentA", "ParentB", "childAB", "childAAB", "ParentC", "childBA", "childCA")); } + private void logAndValidateValueSet(ValueSet theResult) { + IParser parser = myFhirCtx.newXmlParser().setPrettyPrint(true); + String encoded = parser.encodeResourceToString(theResult); + ourLog.info(encoded); + + FhirValidator validator = myFhirCtx.newValidator(); + validator.setValidateAgainstStandardSchema(true); + validator.setValidateAgainstStandardSchematron(true); + ValidationResult result = validator.validateWithResult(theResult); + + if (!result.isSuccessful()) { + ourLog.info(parser.encodeResourceToString(result.toOperationOutcome())); + fail(parser.encodeResourceToString(result.toOperationOutcome())); + } + } + + @Test public void testExpandWithInvalidExclude() { createExternalCsAndLocalVs(); @@ -273,9 +291,7 @@ public class FhirResourceDaoDstu3TerminologyTest extends BaseJpaDstu3Test { include.addFilter().setProperty("display").setOp(FilterOperator.EQUAL).setValue("Parent B"); ValueSet result = myValueSetDao.expand(vs, null); - - String encoded = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(result); - ourLog.info(encoded); + logAndValidateValueSet(result); ArrayList codes = toCodesContains(result.getExpansion().getContains()); assertThat(codes, containsInAnyOrder("ParentA", "childAA", "childAAA", "ParentB")); @@ -295,8 +311,7 @@ public class FhirResourceDaoDstu3TerminologyTest extends BaseJpaDstu3Test { include.setSystem(URL_MY_CODE_SYSTEM); include.addFilter().setProperty("display").setOp(FilterOperator.EQUAL).setValue("parent a"); ValueSet result = myValueSetDao.expand(vs, null); - String encoded = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(result); - ourLog.info(encoded); + logAndValidateValueSet(result); ArrayList codes = toCodesContains(result.getExpansion().getContains()); assertThat(codes, containsInAnyOrder("ParentA")); @@ -305,8 +320,7 @@ public class FhirResourceDaoDstu3TerminologyTest extends BaseJpaDstu3Test { include.setSystem(URL_MY_CODE_SYSTEM); include.addFilter().setProperty("display").setOp(FilterOperator.EQUAL).setValue("pare"); result = myValueSetDao.expand(vs, null); - encoded = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(result); - ourLog.info(encoded); + logAndValidateValueSet(result); codes = toCodesContains(result.getExpansion().getContains()); assertThat(codes, containsInAnyOrder("ParentA", "ParentB", "ParentC")); @@ -315,8 +329,7 @@ public class FhirResourceDaoDstu3TerminologyTest extends BaseJpaDstu3Test { include.setSystem(URL_MY_CODE_SYSTEM); include.addFilter().setProperty("display:exact").setOp(FilterOperator.EQUAL).setValue("pare"); result = myValueSetDao.expand(vs, null); - encoded = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(result); - ourLog.info(encoded); + logAndValidateValueSet(result); codes = toCodesContains(result.getExpansion().getContains()); assertThat(codes, empty()); @@ -337,9 +350,7 @@ public class FhirResourceDaoDstu3TerminologyTest extends BaseJpaDstu3Test { include.addFilter().setProperty("display").setOp(FilterOperator.EQUAL).setValue("AAA"); ValueSet result = myValueSetDao.expand(vs, null); - - String encoded = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(result); - ourLog.info(encoded); + logAndValidateValueSet(result); ArrayList codes = toCodesContains(result.getExpansion().getContains()); assertThat(codes, containsInAnyOrder("AAA")); @@ -363,9 +374,7 @@ public class FhirResourceDaoDstu3TerminologyTest extends BaseJpaDstu3Test { include.addConcept().setCode("AB"); ValueSet result = myValueSetDao.expand(vs, null); - - String encoded = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(result); - ourLog.info(encoded); + logAndValidateValueSet(result); ArrayList codes = toCodesContains(result.getExpansion().getContains()); assertThat(codes, containsInAnyOrder("A", "AA", "AAA", "AB")); @@ -393,8 +402,7 @@ public class FhirResourceDaoDstu3TerminologyTest extends BaseJpaDstu3Test { include.addFilter().setProperty("concept").setOp(FilterOperator.ISA).setValue("ParentA"); ValueSet result = myValueSetDao.expand(vs, null); - String encoded = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(result); - ourLog.info(encoded); + logAndValidateValueSet(result); assertEquals(0, result.getExpansion().getContains().size()); @@ -412,11 +420,11 @@ public class FhirResourceDaoDstu3TerminologyTest extends BaseJpaDstu3Test { include.setSystem(URL_MY_CODE_SYSTEM); include.addFilter().setProperty("concept").setOp(FilterOperator.ISA).setValue("ParentA"); result = myValueSetDao.expand(vs, null); - encoded = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(result); - ourLog.info(encoded); + logAndValidateValueSet(result); assertEquals(4, result.getExpansion().getContains().size()); + String encoded = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(result); assertThat(encoded, containsStringIgnoringCase("")); } diff --git a/hapi-fhir-structures-dstu2/src/main/java/ca/uhn/fhir/rest/server/provider/dstu2/ServerConformanceProvider.java b/hapi-fhir-structures-dstu2/src/main/java/ca/uhn/fhir/rest/server/provider/dstu2/ServerConformanceProvider.java index 17d1e2f4ee9..7d3061e3844 100644 --- a/hapi-fhir-structures-dstu2/src/main/java/ca/uhn/fhir/rest/server/provider/dstu2/ServerConformanceProvider.java +++ b/hapi-fhir-structures-dstu2/src/main/java/ca/uhn/fhir/rest/server/provider/dstu2/ServerConformanceProvider.java @@ -43,7 +43,6 @@ import org.hl7.fhir.instance.model.api.IBaseResource; import ca.uhn.fhir.context.RuntimeResourceDefinition; import ca.uhn.fhir.context.RuntimeSearchParam; -import ca.uhn.fhir.model.api.IResource; import ca.uhn.fhir.model.dstu2.resource.Conformance; import ca.uhn.fhir.model.dstu2.resource.Conformance.Rest; import ca.uhn.fhir.model.dstu2.resource.Conformance.RestResource; diff --git a/hapi-fhir-structures-dstu3/src/main/java/org/hl7/fhir/dstu3/terminologies/ValueSetExpanderSimple.java b/hapi-fhir-structures-dstu3/src/main/java/org/hl7/fhir/dstu3/terminologies/ValueSetExpanderSimple.java index a80d8a9d78b..da615abba8d 100644 --- a/hapi-fhir-structures-dstu3/src/main/java/org/hl7/fhir/dstu3/terminologies/ValueSetExpanderSimple.java +++ b/hapi-fhir-structures-dstu3/src/main/java/org/hl7/fhir/dstu3/terminologies/ValueSetExpanderSimple.java @@ -45,6 +45,7 @@ import org.apache.commons.lang3.NotImplementedException; import org.hl7.fhir.dstu3.model.CodeSystem; import org.hl7.fhir.dstu3.model.CodeSystem.CodeSystemContentMode; import org.hl7.fhir.dstu3.model.CodeSystem.ConceptDefinitionComponent; +import org.hl7.fhir.dstu3.model.Enumerations.ConformanceResourceStatus; import org.hl7.fhir.dstu3.model.DateTimeType; import org.hl7.fhir.dstu3.model.Factory; import org.hl7.fhir.dstu3.model.PrimitiveType; @@ -170,6 +171,7 @@ public class ValueSetExpanderSimple implements ValueSetExpander { focus.setExpansion(new ValueSet.ValueSetExpansionComponent()); focus.getExpansion().setTimestampElement(DateTimeType.now()); focus.getExpansion().setIdentifier(Factory.createUUID()); + focus.setStatus(ConformanceResourceStatus.ACTIVE); if (source.hasCompose()) handleCompose(source.getCompose(), focus.getExpansion().getParameter()); From 38d30eef492ddac1672f70932ae35b1f765486b0 Mon Sep 17 00:00:00 2001 From: James Agnew Date: Wed, 29 Jun 2016 10:26:36 -0400 Subject: [PATCH 2/3] Respect order for order=REPLACE_PARENT --- ...BaseRuntimeElementCompositeDefinition.java | 9 ++- .../FooMessageHeaderWithExplicitField.java | 58 +++++++++++++++++++ .../uhn/fhir/parser/XmlParserDstu3Test.java | 30 +++++++++- src/changes/changes.xml | 7 +++ 4 files changed, 100 insertions(+), 4 deletions(-) create mode 100644 hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/parser/FooMessageHeaderWithExplicitField.java diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/BaseRuntimeElementCompositeDefinition.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/BaseRuntimeElementCompositeDefinition.java index d8e6a27d4f0..11f4743c219 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/BaseRuntimeElementCompositeDefinition.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/BaseRuntimeElementCompositeDefinition.java @@ -245,14 +245,17 @@ public abstract class BaseRuntimeElementCompositeDefinition ext String elementName = childAnnotation.name(); int order = childAnnotation.order(); boolean childIsChoiceType = false; + boolean orderIsReplaceParent = false; + if (order == Child.REPLACE_PARENT) { - + if (extensionAttr != null) { for (Entry nextEntry : orderMap.entrySet()) { BaseRuntimeDeclaredChildDefinition nextDef = nextEntry.getValue(); if (nextDef instanceof RuntimeChildDeclaredExtensionDefinition) { if (nextDef.getExtensionUrl().equals(extensionAttr.url())) { + orderIsReplaceParent = true; order = nextEntry.getKey(); orderMap.remove(nextEntry.getKey()); elementNames.remove(elementName); @@ -270,6 +273,7 @@ public abstract class BaseRuntimeElementCompositeDefinition ext for (Entry nextEntry : orderMap.entrySet()) { BaseRuntimeDeclaredChildDefinition nextDef = nextEntry.getValue(); if (elementName.equals(nextDef.getElementName())) { + orderIsReplaceParent = true; order = nextEntry.getKey(); BaseRuntimeDeclaredChildDefinition existing = orderMap.remove(nextEntry.getKey()); elementNames.remove(elementName); @@ -297,7 +301,8 @@ public abstract class BaseRuntimeElementCompositeDefinition ext if (order < 0 && order != Child.ORDER_UNKNOWN) { throw new ConfigurationException("Invalid order '" + order + "' on @Child for field '" + next.getName() + "' on target type: " + theClass); } - if (order != Child.ORDER_UNKNOWN) { + + if (order != Child.ORDER_UNKNOWN && !orderIsReplaceParent) { order = order + baseElementOrder; } // int min = childAnnotation.min(); diff --git a/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/parser/FooMessageHeaderWithExplicitField.java b/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/parser/FooMessageHeaderWithExplicitField.java new file mode 100644 index 00000000000..184fd144559 --- /dev/null +++ b/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/parser/FooMessageHeaderWithExplicitField.java @@ -0,0 +1,58 @@ +package ca.uhn.fhir.parser; + +import org.hl7.fhir.dstu3.exceptions.FHIRException; +import org.hl7.fhir.dstu3.model.Identifier; +import org.hl7.fhir.dstu3.model.MessageHeader; + +import ca.uhn.fhir.model.api.annotation.Block; +import ca.uhn.fhir.model.api.annotation.Child; +import ca.uhn.fhir.model.api.annotation.Description; +import ca.uhn.fhir.model.api.annotation.Extension; +import ca.uhn.fhir.model.api.annotation.ResourceDef; + +@ResourceDef(name = "FooMessageHeader") +public class FooMessageHeaderWithExplicitField extends MessageHeader { + + private static final long serialVersionUID = 1L; + + /** + * The source application from which this message originated. + */ + @Child(name = "source", type = {}, order = Child.REPLACE_PARENT, min = 1, max = 1, modifier = false, summary = true) + @Description(shortDefinition = "Message Source Application", formalDefinition = "The source application from which this message originated.") + protected FooMessageSourceComponent source; + + public void setSourceNew(FooMessageSourceComponent theSource) { + source = theSource; + } + + @Block() + public static class FooMessageSourceComponent extends MessageHeader.MessageSourceComponent { + + private static final long serialVersionUID = 1L; + @Child(name = "ext-messageheader-application-id", type = Identifier.class, modifier = true) + @Description(shortDefinition = "Message Header Application ID") + @Extension(url = "http://foo", definedLocally = false, isModifier = false) + private Identifier messageHeaderApplicationId; + + /* + * Get messageHeaderApplicationId + */ + public Identifier getMessageHeaderApplicationId() throws FHIRException { + + if (messageHeaderApplicationId == null) { + messageHeaderApplicationId = new Identifier(); + } + return messageHeaderApplicationId; + } + + /* + * Set messageHeaderApplicationId + */ + public void setmessageHeaderApplicationId(Identifier messageHeaderApplicationId) { + this.messageHeaderApplicationId = messageHeaderApplicationId; + } + + } + +} \ No newline at end of file diff --git a/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/parser/XmlParserDstu3Test.java b/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/parser/XmlParserDstu3Test.java index c450d65b78d..fb69576c935 100644 --- a/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/parser/XmlParserDstu3Test.java +++ b/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/parser/XmlParserDstu3Test.java @@ -34,7 +34,6 @@ import org.custommonkey.xmlunit.XMLUnit; import org.hamcrest.collection.IsEmptyCollection; import org.hamcrest.core.StringContains; import org.hamcrest.text.StringContainsInOrder; -import org.hl7.fhir.dstu3.exceptions.FHIRException; import org.hl7.fhir.dstu3.model.Address.AddressUse; import org.hl7.fhir.dstu3.model.Address.AddressUseEnumFactory; import org.hl7.fhir.dstu3.model.AllergyIntolerance; @@ -77,7 +76,6 @@ import org.hl7.fhir.dstu3.model.Location; import org.hl7.fhir.dstu3.model.Medication; import org.hl7.fhir.dstu3.model.MedicationOrder; import org.hl7.fhir.dstu3.model.MedicationStatement; -import org.hl7.fhir.dstu3.model.MessageHeader.MessageSourceComponent; import org.hl7.fhir.dstu3.model.Observation; import org.hl7.fhir.dstu3.model.Observation.ObservationRelationshipType; import org.hl7.fhir.dstu3.model.Observation.ObservationStatus; @@ -107,6 +105,7 @@ import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.model.api.annotation.Child; import ca.uhn.fhir.model.api.annotation.ResourceDef; import ca.uhn.fhir.narrative.DefaultThymeleafNarrativeGenerator; +import ca.uhn.fhir.parser.FooMessageHeaderWithExplicitField.FooMessageSourceComponent; import ca.uhn.fhir.parser.IParserErrorHandler.IParseLocation; import ca.uhn.fhir.rest.client.IGenericClient; import ca.uhn.fhir.rest.server.Constants; @@ -1407,6 +1406,8 @@ public class XmlParserDstu3Test { FooMessageHeader header = new FooMessageHeader(); header.setSource(source); + header.addDestination().setName("DEST"); + Bundle bundle = new Bundle(); bundle.addEntry().setResource(header); @@ -1417,6 +1418,31 @@ public class XmlParserDstu3Test { ourLog.info(encode); assertThat(encode, containsString("")); + assertThat(encode, stringContainsInOrder("")); + assertThat(encode, stringContainsInOrder(" + + When declaring a child with + order=Child.REPLACE_PARENT]]> + the serialized form still put the element at the + end of the resource instead of in the correct + order + From 7ef48413c40e54fb0400fa3a7141a8eebe1f85b3 Mon Sep 17 00:00:00 2001 From: James Agnew Date: Thu, 30 Jun 2016 17:45:41 -0400 Subject: [PATCH 3/3] Term service enhancements --- ...BaseRuntimeElementCompositeDefinition.java | 2 - .../fhir/model/primitive/BaseDateTimeDt.java | 20 ++ .../ca/uhn/fhir/rest/method/AtParameter.java | 20 ++ .../rest/method/BaseJavaPrimitiveBinder.java | 20 ++ .../uhn/fhir/rest/method/CalendarBinder.java | 20 ++ .../ca/uhn/fhir/rest/method/DateBinder.java | 20 ++ .../fhir/rest/method/FhirPrimitiveBinder.java | 20 ++ .../uhn/fhir/rest/method/SinceParameter.java | 20 ++ .../ca/uhn/fhir/rest/method/StringBinder.java | 20 ++ .../VerboseLoggingInterceptor.java | 20 ++ .../server/interceptor/auth/BaseRule.java | 20 ++ .../auth/IAuthRuleBuilderOperation.java | 20 ++ .../auth/IAuthRuleBuilderOperationNamed.java | 20 ++ .../interceptor/auth/OperationRule.java | 20 ++ .../main/java/ca/uhn/fhir/util/PortUtil.java | 20 ++ .../BaseJpaSystemProviderDstu2Plus.java | 20 ++ .../DeferConceptIndexingInterceptor.java | 20 ++ .../jpa/term/HapiTerminologySvcDstu3.java | 3 + .../java/ca/uhn/fhir/jpa/util/Counter.java | 20 ++ .../FhirResourceDaoDstu3TerminologyTest.java | 241 ++++++++++++------ .../rest/server/audit/IResourceAuditor.java | 2 +- 21 files changed, 503 insertions(+), 85 deletions(-) diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/BaseRuntimeElementCompositeDefinition.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/BaseRuntimeElementCompositeDefinition.java index 11f4743c219..1d111fcf01d 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/BaseRuntimeElementCompositeDefinition.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/BaseRuntimeElementCompositeDefinition.java @@ -45,12 +45,10 @@ import org.hl7.fhir.instance.model.api.IBaseEnumeration; import org.hl7.fhir.instance.model.api.IBaseExtension; import org.hl7.fhir.instance.model.api.IBaseReference; import org.hl7.fhir.instance.model.api.IBaseResource; -import org.hl7.fhir.instance.model.api.IBaseXhtml; import org.hl7.fhir.instance.model.api.ICompositeType; import org.hl7.fhir.instance.model.api.INarrative; import org.hl7.fhir.instance.model.api.IPrimitiveType; -import ca.uhn.fhir.model.api.ExtensionDt; import ca.uhn.fhir.model.api.IBoundCodeableConcept; import ca.uhn.fhir.model.api.IDatatype; import ca.uhn.fhir.model.api.IElement; diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/primitive/BaseDateTimeDt.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/primitive/BaseDateTimeDt.java index 5b4f001a5f8..4b9be10bbf6 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/primitive/BaseDateTimeDt.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/primitive/BaseDateTimeDt.java @@ -1,5 +1,25 @@ package ca.uhn.fhir.model.primitive; +/* + * #%L + * HAPI FHIR - Core Library + * %% + * Copyright (C) 2014 - 2016 University Health Network + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ + import static org.apache.commons.lang3.StringUtils.isBlank; import java.util.Calendar; diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/AtParameter.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/AtParameter.java index 14bc023553e..03cf6b10bbf 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/AtParameter.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/AtParameter.java @@ -1,5 +1,25 @@ package ca.uhn.fhir.rest.method; +/* + * #%L + * HAPI FHIR - Core Library + * %% + * Copyright (C) 2014 - 2016 University Health Network + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ + import ca.uhn.fhir.rest.annotation.At; import ca.uhn.fhir.rest.server.Constants; diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/BaseJavaPrimitiveBinder.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/BaseJavaPrimitiveBinder.java index 35fc2b1ecbf..074ec2ebdf4 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/BaseJavaPrimitiveBinder.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/BaseJavaPrimitiveBinder.java @@ -1,5 +1,25 @@ package ca.uhn.fhir.rest.method; +/* + * #%L + * HAPI FHIR - Core Library + * %% + * Copyright (C) 2014 - 2016 University Health Network + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ + import static org.apache.commons.lang3.StringUtils.isBlank; import java.util.Collections; diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/CalendarBinder.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/CalendarBinder.java index a8c8a804fc4..787b076d3d9 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/CalendarBinder.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/CalendarBinder.java @@ -1,5 +1,25 @@ package ca.uhn.fhir.rest.method; +/* + * #%L + * HAPI FHIR - Core Library + * %% + * Copyright (C) 2014 - 2016 University Health Network + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ + import java.util.Calendar; import ca.uhn.fhir.model.primitive.InstantDt; diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/DateBinder.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/DateBinder.java index 6fbe70982f1..1b7f46062d2 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/DateBinder.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/DateBinder.java @@ -1,5 +1,25 @@ package ca.uhn.fhir.rest.method; +/* + * #%L + * HAPI FHIR - Core Library + * %% + * Copyright (C) 2014 - 2016 University Health Network + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ + import java.util.Date; import ca.uhn.fhir.model.primitive.InstantDt; diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/FhirPrimitiveBinder.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/FhirPrimitiveBinder.java index c6cbb90d76f..320997c66c9 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/FhirPrimitiveBinder.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/FhirPrimitiveBinder.java @@ -1,5 +1,25 @@ package ca.uhn.fhir.rest.method; +/* + * #%L + * HAPI FHIR - Core Library + * %% + * Copyright (C) 2014 - 2016 University Health Network + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ + import static org.apache.commons.lang3.StringUtils.defaultString; import org.hl7.fhir.instance.model.api.IPrimitiveType; diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/SinceParameter.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/SinceParameter.java index fd540949917..b526207770f 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/SinceParameter.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/SinceParameter.java @@ -1,5 +1,25 @@ package ca.uhn.fhir.rest.method; +/* + * #%L + * HAPI FHIR - Core Library + * %% + * Copyright (C) 2014 - 2016 University Health Network + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ + import ca.uhn.fhir.rest.annotation.Since; import ca.uhn.fhir.rest.server.Constants; diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/StringBinder.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/StringBinder.java index d6d9dde5afd..1dece004619 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/StringBinder.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/StringBinder.java @@ -1,5 +1,25 @@ package ca.uhn.fhir.rest.method; +/* + * #%L + * HAPI FHIR - Core Library + * %% + * Copyright (C) 2014 - 2016 University Health Network + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ + final class StringBinder extends BaseJavaPrimitiveBinder { StringBinder() { } diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/interceptor/VerboseLoggingInterceptor.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/interceptor/VerboseLoggingInterceptor.java index b14f1f56cef..9df355891fb 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/interceptor/VerboseLoggingInterceptor.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/interceptor/VerboseLoggingInterceptor.java @@ -1,5 +1,25 @@ package ca.uhn.fhir.rest.server.interceptor; +/* + * #%L + * HAPI FHIR - Core Library + * %% + * Copyright (C) 2014 - 2016 University Health Network + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ + import java.util.Enumeration; import javax.servlet.http.HttpServletRequest; diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/interceptor/auth/BaseRule.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/interceptor/auth/BaseRule.java index 08a75b82092..b874b253d75 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/interceptor/auth/BaseRule.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/interceptor/auth/BaseRule.java @@ -1,5 +1,25 @@ package ca.uhn.fhir.rest.server.interceptor.auth; +/* + * #%L + * HAPI FHIR - Core Library + * %% + * Copyright (C) 2014 - 2016 University Health Network + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ + import ca.uhn.fhir.rest.server.interceptor.auth.AuthorizationInterceptor.Verdict; abstract class BaseRule implements IAuthRule { diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/interceptor/auth/IAuthRuleBuilderOperation.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/interceptor/auth/IAuthRuleBuilderOperation.java index 20c11bde773..7593ac753a9 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/interceptor/auth/IAuthRuleBuilderOperation.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/interceptor/auth/IAuthRuleBuilderOperation.java @@ -1,5 +1,25 @@ package ca.uhn.fhir.rest.server.interceptor.auth; +/* + * #%L + * HAPI FHIR - Core Library + * %% + * Copyright (C) 2014 - 2016 University Health Network + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ + public interface IAuthRuleBuilderOperation { /** diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/interceptor/auth/IAuthRuleBuilderOperationNamed.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/interceptor/auth/IAuthRuleBuilderOperationNamed.java index 49ca0e483a2..eb783673b03 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/interceptor/auth/IAuthRuleBuilderOperationNamed.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/interceptor/auth/IAuthRuleBuilderOperationNamed.java @@ -1,5 +1,25 @@ package ca.uhn.fhir.rest.server.interceptor.auth; +/* + * #%L + * HAPI FHIR - Core Library + * %% + * Copyright (C) 2014 - 2016 University Health Network + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ + import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.instance.model.api.IIdType; diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/interceptor/auth/OperationRule.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/interceptor/auth/OperationRule.java index a4581cb4710..1e97a1b0c6d 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/interceptor/auth/OperationRule.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/interceptor/auth/OperationRule.java @@ -1,5 +1,25 @@ package ca.uhn.fhir.rest.server.interceptor.auth; +/* + * #%L + * HAPI FHIR - Core Library + * %% + * Copyright (C) 2014 - 2016 University Health Network + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ + import java.util.HashSet; import java.util.List; diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/PortUtil.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/PortUtil.java index 7ac653d5286..25cc450e961 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/PortUtil.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/PortUtil.java @@ -1,5 +1,25 @@ package ca.uhn.fhir.util; +/* + * #%L + * HAPI FHIR - Core Library + * %% + * Copyright (C) 2014 - 2016 University Health Network + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ + import java.net.ServerSocket; /** diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/BaseJpaSystemProviderDstu2Plus.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/BaseJpaSystemProviderDstu2Plus.java index cadce02eaba..e8db8a5d253 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/BaseJpaSystemProviderDstu2Plus.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/BaseJpaSystemProviderDstu2Plus.java @@ -1,5 +1,25 @@ package ca.uhn.fhir.jpa.provider; +/* + * #%L + * HAPI FHIR JPA Server + * %% + * Copyright (C) 2014 - 2016 University Health Network + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ + import org.hl7.fhir.instance.model.api.IBaseParameters; import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.instance.model.api.IPrimitiveType; diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/DeferConceptIndexingInterceptor.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/DeferConceptIndexingInterceptor.java index 405016638bf..03c31bac0cc 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/DeferConceptIndexingInterceptor.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/DeferConceptIndexingInterceptor.java @@ -1,5 +1,25 @@ package ca.uhn.fhir.jpa.search; +/* + * #%L + * HAPI FHIR JPA Server + * %% + * Copyright (C) 2014 - 2016 University Health Network + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ + import org.hibernate.search.indexes.interceptor.EntityIndexingInterceptor; import org.hibernate.search.indexes.interceptor.IndexingOverride; 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 46e0586b6ab..515c053a57d 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 @@ -64,6 +64,7 @@ import ca.uhn.fhir.jpa.entity.TermCodeSystem; import ca.uhn.fhir.jpa.entity.TermCodeSystemVersion; import ca.uhn.fhir.jpa.entity.TermConcept; import ca.uhn.fhir.rest.method.RequestDetails; +import ca.uhn.fhir.rest.server.exceptions.BaseServerResponseException; import ca.uhn.fhir.rest.server.exceptions.InternalErrorException; import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; import ca.uhn.fhir.util.CoverageIgnore; @@ -278,6 +279,8 @@ public class HapiTerminologySvcDstu3 extends BaseHapiTerminologySvc implements I return retVal; + } catch (BaseServerResponseException e) { + throw e; } catch (Exception e) { throw new InternalErrorException(e); } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/util/Counter.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/util/Counter.java index f0552bf25cf..513c5cb48d1 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/util/Counter.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/util/Counter.java @@ -1,5 +1,25 @@ package ca.uhn.fhir.jpa.util; +/* + * #%L + * HAPI FHIR JPA Server + * %% + * Copyright (C) 2014 - 2016 University Health Network + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ + public class Counter { private long myCount; diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3TerminologyTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3TerminologyTest.java index d86ccb1acc8..a396d6f78ac 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3TerminologyTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3TerminologyTest.java @@ -56,7 +56,6 @@ public class FhirResourceDaoDstu3TerminologyTest extends BaseJpaDstu3Test { myDaoConfig.setDeferIndexingForCodesystemsOfSize(new DaoConfig().getDeferIndexingForCodesystemsOfSize()); } - @Before public void before() { myDaoConfig.setMaximumExpansionSize(5000); @@ -133,7 +132,6 @@ public class FhirResourceDaoDstu3TerminologyTest extends BaseJpaDstu3Test { createLocalVs(codeSystem); } - private void createLocalVs(CodeSystem codeSystem) { ValueSet valueSet = new ValueSet(); valueSet.setUrl(URL_MY_VALUE_SET); @@ -141,17 +139,16 @@ public class FhirResourceDaoDstu3TerminologyTest extends BaseJpaDstu3Test { myValueSetDao.create(valueSet, mySrd); } - @Test public void testCodeSystemCreateDuplicateFails() { CodeSystem codeSystem = new CodeSystem(); codeSystem.setUrl(URL_MY_CODE_SYSTEM); - codeSystem.setContent(CodeSystemContentMode.COMPLETE); + codeSystem.setContent(CodeSystemContentMode.COMPLETE); IIdType id = myCodeSystemDao.create(codeSystem, mySrd).getId().toUnqualified(); codeSystem = new CodeSystem(); codeSystem.setUrl(URL_MY_CODE_SYSTEM); - codeSystem.setContent(CodeSystemContentMode.COMPLETE); + codeSystem.setContent(CodeSystemContentMode.COMPLETE); try { myCodeSystemDao.create(codeSystem, mySrd); fail(); @@ -175,14 +172,14 @@ public class FhirResourceDaoDstu3TerminologyTest extends BaseJpaDstu3Test { .addConcept(new ConceptDefinitionComponent().setCode("BA").setDisplay("Code AA")) .addConcept(new ConceptDefinitionComponent().setCode("BB").setDisplay("Code AB")); //@formatter:on - + IIdType id = myCodeSystemDao.create(codeSystem, mySrd).getId().toUnqualified(); - + Set codes = myTermSvc.findCodesBelow(id.getIdPartAsLong(), id.getVersionIdPartAsLong(), "A"); assertThat(toCodes(codes), containsInAnyOrder("A", "AA", "AB")); - + } - + @Test public void testExpandWithExcludeInExternalValueSet() { createExternalCsAndLocalVs(); @@ -195,10 +192,10 @@ public class FhirResourceDaoDstu3TerminologyTest extends BaseJpaDstu3Test { exclude.setSystem(URL_MY_CODE_SYSTEM); exclude.addConcept().setCode("childAA"); exclude.addConcept().setCode("childAAA"); - + ValueSet result = myValueSetDao.expand(vs, null); logAndValidateValueSet(result); - + ArrayList codes = toCodesContains(result.getExpansion().getContains()); assertThat(codes, containsInAnyOrder("ParentA", "ParentB", "childAB", "childAAB", "ParentC", "childBA", "childCA")); } @@ -207,19 +204,18 @@ public class FhirResourceDaoDstu3TerminologyTest extends BaseJpaDstu3Test { IParser parser = myFhirCtx.newXmlParser().setPrettyPrint(true); String encoded = parser.encodeResourceToString(theResult); ourLog.info(encoded); - + FhirValidator validator = myFhirCtx.newValidator(); validator.setValidateAgainstStandardSchema(true); validator.setValidateAgainstStandardSchematron(true); ValidationResult result = validator.validateWithResult(theResult); - + if (!result.isSuccessful()) { ourLog.info(parser.encodeResourceToString(result.toOperationOutcome())); fail(parser.encodeResourceToString(result.toOperationOutcome())); } } - @Test public void testExpandWithInvalidExclude() { createExternalCsAndLocalVs(); @@ -257,7 +253,7 @@ public class FhirResourceDaoDstu3TerminologyTest extends BaseJpaDstu3Test { } catch (InvalidRequestException e) { assertEquals("Unable to find code 'ZZZZ' in code system http://example.com/my_code_system", e.getMessage()); } - + } @Test @@ -277,10 +273,8 @@ public class FhirResourceDaoDstu3TerminologyTest extends BaseJpaDstu3Test { } } - - @Test - public void testExpandWithSystemAndCodesAndFilterInExternalValueSet() { + public void testExpandWithSystemAndCodesInExternalValueSet() { createExternalCsAndLocalVs(); ValueSet vs = new ValueSet(); @@ -290,20 +284,36 @@ public class FhirResourceDaoDstu3TerminologyTest extends BaseJpaDstu3Test { include.addConcept().setCode("childAA"); include.addConcept().setCode("childAAA"); - include.addFilter().setProperty("display").setOp(FilterOperator.EQUAL).setValue("Parent B"); - ValueSet result = myValueSetDao.expand(vs, null); logAndValidateValueSet(result); - + ArrayList codes = toCodesContains(result.getExpansion().getContains()); - assertThat(codes, containsInAnyOrder("ParentA", "childAA", "childAAA", "ParentB")); - + assertThat(codes, containsInAnyOrder("ParentA", "childAA", "childAAA")); + int idx = codes.indexOf("childAA"); assertEquals("childAA", result.getExpansion().getContains().get(idx).getCode()); assertEquals("Child AA", result.getExpansion().getContains().get(idx).getDisplay()); assertEquals(URL_MY_CODE_SYSTEM, result.getExpansion().getContains().get(idx).getSystem()); } + @Test + public void testExpandWithSystemAndFilterInExternalValueSet() { + createExternalCsAndLocalVs(); + + ValueSet vs = new ValueSet(); + ConceptSetComponent include = vs.getCompose().addInclude(); + include.setSystem(URL_MY_CODE_SYSTEM); + + include.addFilter().setProperty("display").setOp(FilterOperator.EQUAL).setValue("Parent B"); + + ValueSet result = myValueSetDao.expand(vs, null); + logAndValidateValueSet(result); + + ArrayList codes = toCodesContains(result.getExpansion().getContains()); + assertThat(codes, containsInAnyOrder("ParentB")); + + } + @Test public void testExpandWithDisplayInExternalValueSetFuzzyMatching() { createExternalCsAndLocalVs(); @@ -344,23 +354,23 @@ public class FhirResourceDaoDstu3TerminologyTest extends BaseJpaDstu3Test { ValueSet vs = new ValueSet(); ConceptSetComponent include = vs.getCompose().addInclude(); include.setSystem(URL_MY_CODE_SYSTEM); -// include.addConcept().setCode("A"); -// include.addConcept().setCode("AA"); -// include.addConcept().setCode("AAA"); -// include.addConcept().setCode("AB"); + // include.addConcept().setCode("A"); + // include.addConcept().setCode("AA"); + // include.addConcept().setCode("AAA"); + // include.addConcept().setCode("AB"); include.addFilter().setProperty("display").setOp(FilterOperator.EQUAL).setValue("AAA"); - + ValueSet result = myValueSetDao.expand(vs, null); logAndValidateValueSet(result); - + ArrayList codes = toCodesContains(result.getExpansion().getContains()); assertThat(codes, containsInAnyOrder("AAA")); - + assertEquals("AAA", result.getExpansion().getContains().get(0).getCode()); assertEquals("Code AAA", result.getExpansion().getContains().get(0).getDisplay()); assertEquals(URL_MY_CODE_SYSTEM, result.getExpansion().getContains().get(0).getSystem()); -// + // } @Test @@ -374,40 +384,40 @@ public class FhirResourceDaoDstu3TerminologyTest extends BaseJpaDstu3Test { include.addConcept().setCode("AA"); include.addConcept().setCode("AAA"); include.addConcept().setCode("AB"); - + ValueSet result = myValueSetDao.expand(vs, null); logAndValidateValueSet(result); - + ArrayList codes = toCodesContains(result.getExpansion().getContains()); assertThat(codes, containsInAnyOrder("A", "AA", "AAA", "AB")); - + int idx = codes.indexOf("AAA"); assertEquals("AAA", result.getExpansion().getContains().get(idx).getCode()); assertEquals("Code AAA", result.getExpansion().getContains().get(idx).getDisplay()); assertEquals(URL_MY_CODE_SYSTEM, result.getExpansion().getContains().get(idx).getSystem()); -// ValueSet expansion = myValueSetDao.expandByIdentifier(URL_MY_VALUE_SET, "cervical"); -// ValueSet expansion = myValueSetDao.expandByIdentifier(URL_MY_VALUE_SET, "cervical"); -// + // ValueSet expansion = myValueSetDao.expandByIdentifier(URL_MY_VALUE_SET, "cervical"); + // ValueSet expansion = myValueSetDao.expandByIdentifier(URL_MY_VALUE_SET, "cervical"); + // } @Test public void testIndexingIsDeferredForLargeCodeSystems() { myDaoConfig.setDeferIndexingForCodesystemsOfSize(1); - + myTermSvc.setProcessDeferred(false); - + createExternalCsAndLocalVs(); ValueSet vs = new ValueSet(); ConceptSetComponent include = vs.getCompose().addInclude(); include.setSystem(URL_MY_CODE_SYSTEM); include.addFilter().setProperty("concept").setOp(FilterOperator.ISA).setValue("ParentA"); - + ValueSet result = myValueSetDao.expand(vs, null); logAndValidateValueSet(result); - + assertEquals(0, result.getExpansion().getContains().size()); - + myTermSvc.setProcessDeferred(true); myTermSvc.saveDeferred(); myTermSvc.saveDeferred(); @@ -416,14 +426,14 @@ public class FhirResourceDaoDstu3TerminologyTest extends BaseJpaDstu3Test { myTermSvc.saveDeferred(); myTermSvc.saveDeferred(); myTermSvc.saveDeferred(); - + vs = new ValueSet(); include = vs.getCompose().addInclude(); include.setSystem(URL_MY_CODE_SYSTEM); include.addFilter().setProperty("concept").setOp(FilterOperator.ISA).setValue("ParentA"); result = myValueSetDao.expand(vs, null); logAndValidateValueSet(result); - + assertEquals(4, result.getExpansion().getContains().size()); String encoded = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(result); @@ -431,14 +441,14 @@ public class FhirResourceDaoDstu3TerminologyTest extends BaseJpaDstu3Test { } /** - * Can't currently abort costly + * Can't currently abort costly */ @Test @Ignore public void testRefuseCostlyExpansionFhirCodesystem() { createLocalCsAndVs(); myDaoConfig.setMaximumExpansionSize(1); - + SearchParameterMap params = new SearchParameterMap(); params.add(AuditEvent.SP_TYPE, new TokenParam(null, "http://hl7.org/fhir/ValueSet/audit-event-type").setModifier(TokenParamModifier.IN)); try { @@ -453,7 +463,7 @@ public class FhirResourceDaoDstu3TerminologyTest extends BaseJpaDstu3Test { public void testRefuseCostlyExpansionLocalCodesystem() { createLocalCsAndVs(); myDaoConfig.setMaximumExpansionSize(1); - + SearchParameterMap params = new SearchParameterMap(); params.add(Observation.SP_CODE, new TokenParam(URL_MY_CODE_SYSTEM, "AAA").setModifier(TokenParamModifier.ABOVE)); try { @@ -467,7 +477,7 @@ public class FhirResourceDaoDstu3TerminologyTest extends BaseJpaDstu3Test { @Test public void testSearchCodeAboveLocalCodesystem() { createLocalCsAndVs(); - + Observation obsAA = new Observation(); obsAA.getCode().addCoding().setSystem(URL_MY_CODE_SYSTEM).setCode("AA"); IIdType idAA = myObservationDao.create(obsAA, mySrd).getId().toUnqualifiedVersionless(); @@ -483,18 +493,18 @@ public class FhirResourceDaoDstu3TerminologyTest extends BaseJpaDstu3Test { SearchParameterMap params = new SearchParameterMap(); params.add(Observation.SP_CODE, new TokenParam(URL_MY_CODE_SYSTEM, "AAA").setModifier(TokenParamModifier.ABOVE)); assertThat(toUnqualifiedVersionlessIdValues(myObservationDao.search(params)), containsInAnyOrder(idAA.getValue())); - + params = new SearchParameterMap(); params.add(Observation.SP_CODE, new TokenParam(URL_MY_CODE_SYSTEM, "A").setModifier(TokenParamModifier.ABOVE)); assertThat(toUnqualifiedVersionlessIdValues(myObservationDao.search(params)), empty()); - + } @Test public void testSearchCodeBelowAndAboveUnknownCodeSystem() { SearchParameterMap params = new SearchParameterMap(); - + params.add(Observation.SP_CODE, new TokenParam(URL_MY_CODE_SYSTEM, "childAA").setModifier(TokenParamModifier.BELOW)); assertThat(toUnqualifiedVersionlessIdValues(myObservationDao.search(params)), empty()); @@ -503,14 +513,13 @@ public class FhirResourceDaoDstu3TerminologyTest extends BaseJpaDstu3Test { params.add(Observation.SP_CODE, new TokenParam(null, URL_MY_VALUE_SET).setModifier(TokenParamModifier.IN)); assertThat(toUnqualifiedVersionlessIdValues(myObservationDao.search(params)), empty()); - - } + } @Test public void testSearchCodeBelowLocalCodesystem() { createLocalCsAndVs(); - + Observation obsAA = new Observation(); obsAA.getCode().addCoding().setSystem(URL_MY_CODE_SYSTEM).setCode("AA"); IIdType idAA = myObservationDao.create(obsAA, mySrd).getId().toUnqualifiedVersionless(); @@ -526,32 +535,106 @@ public class FhirResourceDaoDstu3TerminologyTest extends BaseJpaDstu3Test { SearchParameterMap params = new SearchParameterMap(); params.add(Observation.SP_CODE, new TokenParam(URL_MY_CODE_SYSTEM, "A").setModifier(TokenParamModifier.BELOW)); assertThat(toUnqualifiedVersionlessIdValues(myObservationDao.search(params)), containsInAnyOrder(idAA.getValue())); - + params = new SearchParameterMap(); params.add(Observation.SP_CODE, new TokenParam(URL_MY_CODE_SYSTEM, "AAA").setModifier(TokenParamModifier.BELOW)); assertThat(toUnqualifiedVersionlessIdValues(myObservationDao.search(params)), empty()); } + @Test + public void testSearchCodeInBuiltInValueSet() { + AllergyIntolerance ai1 = new AllergyIntolerance(); + ai1.setStatus(AllergyIntoleranceStatus.ACTIVE); + String id1 = myAllergyIntoleranceDao.create(ai1, mySrd).getId().toUnqualifiedVersionless().getValue(); + + AllergyIntolerance ai2 = new AllergyIntolerance(); + ai2.setStatus(AllergyIntoleranceStatus.CONFIRMED); + String id2 = myAllergyIntoleranceDao.create(ai2, mySrd).getId().toUnqualifiedVersionless().getValue(); + + AllergyIntolerance ai3 = new AllergyIntolerance(); + ai3.setStatus(AllergyIntoleranceStatus.INACTIVE); + String id3 = myAllergyIntoleranceDao.create(ai3, mySrd).getId().toUnqualifiedVersionless().getValue(); + + SearchParameterMap params; + params = new SearchParameterMap(); + params.add(AllergyIntolerance.SP_STATUS, new TokenParam(null, "http://hl7.org/fhir/ValueSet/allergy-intolerance-status").setModifier(TokenParamModifier.IN)); + assertThat(toUnqualifiedVersionlessIdValues(myAllergyIntoleranceDao.search(params)), containsInAnyOrder(id1, id2, id3)); + + // No codes in this one + params = new SearchParameterMap(); + params.add(AllergyIntolerance.SP_STATUS, new TokenParam(null, "http://hl7.org/fhir/ValueSet/allergy-intolerance-criticality").setModifier(TokenParamModifier.IN)); + assertThat(toUnqualifiedVersionlessIdValues(myAllergyIntoleranceDao.search(params)), empty()); + + // Invalid VS + params = new SearchParameterMap(); + params.add(AllergyIntolerance.SP_STATUS, new TokenParam(null, "http://hl7.org/fhir/ValueSet/FOO").setModifier(TokenParamModifier.IN)); + try { + myAllergyIntoleranceDao.search(params); + } catch (InvalidRequestException e) { + assertEquals("Unable to find imported value set http://hl7.org/fhir/ValueSet/FOO", e.getMessage()); + } + + } + + /** + * Todo: not yet implemented + */ + @Test + @Ignore + public void testSearchCodeNotInBuiltInValueSet() { + AllergyIntolerance ai1 = new AllergyIntolerance(); + ai1.setStatus(AllergyIntoleranceStatus.ACTIVE); + String id1 = myAllergyIntoleranceDao.create(ai1, mySrd).getId().toUnqualifiedVersionless().getValue(); + + AllergyIntolerance ai2 = new AllergyIntolerance(); + ai2.setStatus(AllergyIntoleranceStatus.CONFIRMED); + String id2 = myAllergyIntoleranceDao.create(ai2, mySrd).getId().toUnqualifiedVersionless().getValue(); + + AllergyIntolerance ai3 = new AllergyIntolerance(); + ai3.setStatus(AllergyIntoleranceStatus.INACTIVE); + String id3 = myAllergyIntoleranceDao.create(ai3, mySrd).getId().toUnqualifiedVersionless().getValue(); + + SearchParameterMap params; + params = new SearchParameterMap(); + params.add(AllergyIntolerance.SP_STATUS, new TokenParam(null, "http://hl7.org/fhir/ValueSet/allergy-intolerance-status").setModifier(TokenParamModifier.NOT_IN)); + assertThat(toUnqualifiedVersionlessIdValues(myAllergyIntoleranceDao.search(params)), empty()); + + // No codes in this one + params = new SearchParameterMap(); + params.add(AllergyIntolerance.SP_STATUS, new TokenParam(null, "http://hl7.org/fhir/ValueSet/allergy-intolerance-criticality").setModifier(TokenParamModifier.NOT_IN)); + assertThat(toUnqualifiedVersionlessIdValues(myAllergyIntoleranceDao.search(params)), containsInAnyOrder(id1, id2, id3)); + + // Invalid VS + params = new SearchParameterMap(); + params.add(AllergyIntolerance.SP_STATUS, new TokenParam(null, "http://hl7.org/fhir/ValueSet/FOO").setModifier(TokenParamModifier.NOT_IN)); + try { + myAllergyIntoleranceDao.search(params); + } catch (InvalidRequestException e) { + assertEquals("Unable to find imported value set http://hl7.org/fhir/ValueSet/FOO", e.getMessage()); + } + + } + @Test public void testSearchCodeBelowBuiltInCodesystem() { AllergyIntolerance ai1 = new AllergyIntolerance(); ai1.setStatus(AllergyIntoleranceStatus.ACTIVE); String id1 = myAllergyIntoleranceDao.create(ai1, mySrd).getId().toUnqualifiedVersionless().getValue(); - + AllergyIntolerance ai2 = new AllergyIntolerance(); ai2.setStatus(AllergyIntoleranceStatus.CONFIRMED); String id2 = myAllergyIntoleranceDao.create(ai2, mySrd).getId().toUnqualifiedVersionless().getValue(); - + AllergyIntolerance ai3 = new AllergyIntolerance(); ai3.setStatus(AllergyIntoleranceStatus.INACTIVE); String id3 = myAllergyIntoleranceDao.create(ai3, mySrd).getId().toUnqualifiedVersionless().getValue(); - + SearchParameterMap params; params = new SearchParameterMap(); params.add(AllergyIntolerance.SP_STATUS, new TokenParam("http://hl7.org/fhir/allergy-intolerance-status", AllergyIntoleranceStatus.ACTIVE.toCode())); assertThat(toUnqualifiedVersionlessIdValues(myAllergyIntoleranceDao.search(params)), containsInAnyOrder(id1)); - + params = new SearchParameterMap(); params.add(AllergyIntolerance.SP_STATUS, new TokenParam("http://hl7.org/fhir/allergy-intolerance-status", AllergyIntoleranceStatus.ACTIVE.toCode()).setModifier(TokenParamModifier.BELOW)); assertThat(toUnqualifiedVersionlessIdValues(myAllergyIntoleranceDao.search(params)), containsInAnyOrder(id1, id2)); @@ -586,20 +669,20 @@ public class FhirResourceDaoDstu3TerminologyTest extends BaseJpaDstu3Test { AllergyIntolerance ai1 = new AllergyIntolerance(); ai1.setStatus(AllergyIntoleranceStatus.ACTIVE); String id1 = myAllergyIntoleranceDao.create(ai1, mySrd).getId().toUnqualifiedVersionless().getValue(); - + AllergyIntolerance ai2 = new AllergyIntolerance(); ai2.setStatus(AllergyIntoleranceStatus.CONFIRMED); String id2 = myAllergyIntoleranceDao.create(ai2, mySrd).getId().toUnqualifiedVersionless().getValue(); - + AllergyIntolerance ai3 = new AllergyIntolerance(); ai3.setStatus(AllergyIntoleranceStatus.INACTIVE); String id3 = myAllergyIntoleranceDao.create(ai3, mySrd).getId().toUnqualifiedVersionless().getValue(); - + SearchParameterMap params; params = new SearchParameterMap(); params.add(AllergyIntolerance.SP_STATUS, new TokenParam(null, AllergyIntoleranceStatus.ACTIVE.toCode())); assertThat(toUnqualifiedVersionlessIdValues(myAllergyIntoleranceDao.search(params)), containsInAnyOrder(id1)); - + params = new SearchParameterMap(); params.add(AllergyIntolerance.SP_STATUS, new TokenParam(null, AllergyIntoleranceStatus.ACTIVE.toCode()).setModifier(TokenParamModifier.BELOW)); assertThat(toUnqualifiedVersionlessIdValues(myAllergyIntoleranceDao.search(params)), containsInAnyOrder(id1, id2)); @@ -618,14 +701,13 @@ public class FhirResourceDaoDstu3TerminologyTest extends BaseJpaDstu3Test { } - @Test @Ignore public void testSearchCodeInEmptyValueSet() { ValueSet valueSet = new ValueSet(); valueSet.setUrl(URL_MY_VALUE_SET); myValueSetDao.create(valueSet, mySrd); - + Observation obsAA = new Observation(); obsAA.setStatus(ObservationStatus.FINAL); obsAA.getCode().addCoding().setSystem(URL_MY_CODE_SYSTEM).setCode("AA"); @@ -642,11 +724,11 @@ public class FhirResourceDaoDstu3TerminologyTest extends BaseJpaDstu3Test { myObservationDao.create(obsCA, mySrd).getId().toUnqualifiedVersionless(); SearchParameterMap params; - + params = new SearchParameterMap(); params.add(Observation.SP_CODE, new TokenParam(null, URL_MY_VALUE_SET).setModifier(TokenParamModifier.IN)); assertThat(toUnqualifiedVersionlessIdValues(myObservationDao.search(params)), empty()); - + params = new SearchParameterMap(); params.add(Observation.SP_CODE, new TokenParam(null, URL_MY_VALUE_SET).setModifier(TokenParamModifier.IN)); params.add(Observation.SP_STATUS, new TokenParam(null, "final")); @@ -656,7 +738,7 @@ public class FhirResourceDaoDstu3TerminologyTest extends BaseJpaDstu3Test { @Test public void testSearchCodeInExternalCodesystem() { createExternalCsAndLocalVs(); - + Observation obsPA = new Observation(); obsPA.getCode().addCoding().setSystem(URL_MY_CODE_SYSTEM).setCode("ParentA"); IIdType idPA = myObservationDao.create(obsPA, mySrd).getId().toUnqualifiedVersionless(); @@ -673,7 +755,7 @@ public class FhirResourceDaoDstu3TerminologyTest extends BaseJpaDstu3Test { obsCA.getCode().addCoding().setSystem(URL_MY_CODE_SYSTEM).setCode("CA"); IIdType idCA = myObservationDao.create(obsCA, mySrd).getId().toUnqualifiedVersionless(); - SearchParameterMap params = new SearchParameterMap(); + SearchParameterMap params = new SearchParameterMap(); params.add(Observation.SP_CODE, new TokenParam(URL_MY_CODE_SYSTEM, "childAA").setModifier(TokenParamModifier.BELOW)); assertThat(toUnqualifiedVersionlessIdValues(myObservationDao.search(params)), containsInAnyOrder(idAAA.getValue(), idAAB.getValue())); @@ -684,17 +766,17 @@ public class FhirResourceDaoDstu3TerminologyTest extends BaseJpaDstu3Test { params = new SearchParameterMap(); params.add(Observation.SP_CODE, new TokenParam(null, URL_MY_VALUE_SET).setModifier(TokenParamModifier.IN)); assertThat(toUnqualifiedVersionlessIdValues(myObservationDao.search(params)), containsInAnyOrder(idPA.getValue(), idAAA.getValue(), idAAB.getValue())); - + } - + @Test public void testSearchCodeInFhirCodesystem() { createLocalCsAndVs(); - + AuditEvent aeIn1 = new AuditEvent(); aeIn1.getType().setSystem("http://nema.org/dicom/dicm").setCode("110102"); IIdType idIn1 = myAuditEventDao.create(aeIn1, mySrd).getId().toUnqualifiedVersionless(); - + AuditEvent aeIn2 = new AuditEvent(); aeIn2.getType().setSystem("http://hl7.org/fhir/audit-event-type").setCode("rest"); IIdType idIn2 = myAuditEventDao.create(aeIn2, mySrd).getId().toUnqualifiedVersionless(); @@ -705,17 +787,17 @@ public class FhirResourceDaoDstu3TerminologyTest extends BaseJpaDstu3Test { SearchParameterMap params = new SearchParameterMap(); params.add(AuditEvent.SP_TYPE, new TokenParam(null, "http://hl7.org/fhir/ValueSet/audit-event-type").setModifier(TokenParamModifier.IN)); - assertThat(toUnqualifiedVersionlessIdValues(myAuditEventDao.search(params)), containsInAnyOrder(idIn1.getValue(), idIn2.getValue())); + assertThat(toUnqualifiedVersionlessIdValues(myAuditEventDao.search(params)), containsInAnyOrder(idIn1.getValue(), idIn2.getValue())); params = new SearchParameterMap(); params.add(AuditEvent.SP_TYPE, new TokenParam(null, "http://hl7.org/fhir/ValueSet/v3-PurposeOfUse").setModifier(TokenParamModifier.IN)); - assertThat(toUnqualifiedVersionlessIdValues(myAuditEventDao.search(params)), empty()); + assertThat(toUnqualifiedVersionlessIdValues(myAuditEventDao.search(params)), empty()); } @Test public void testSearchCodeInLocalCodesystem() { createLocalCsAndVs(); - + Observation obsAA = new Observation(); obsAA.getCode().addCoding().setSystem(URL_MY_CODE_SYSTEM).setCode("AA"); IIdType idAA = myObservationDao.create(obsAA, mySrd).getId().toUnqualifiedVersionless(); @@ -731,9 +813,8 @@ public class FhirResourceDaoDstu3TerminologyTest extends BaseJpaDstu3Test { SearchParameterMap params = new SearchParameterMap(); params.add(Observation.SP_CODE, new TokenParam(null, URL_MY_VALUE_SET).setModifier(TokenParamModifier.IN)); assertThat(toUnqualifiedVersionlessIdValues(myObservationDao.search(params)), containsInAnyOrder(idAA.getValue(), idBA.getValue())); - - } + } private ArrayList toCodesContains(List theContains) { ArrayList retVal = new ArrayList(); @@ -743,13 +824,9 @@ public class FhirResourceDaoDstu3TerminologyTest extends BaseJpaDstu3Test { return retVal; } - @AfterClass public static void afterClassClearContext() { TestUtil.clearAllStaticFieldsForUnitTest(); } - - - } diff --git a/hapi-fhir-structures-dstu/src/main/java/ca/uhn/fhir/rest/server/audit/IResourceAuditor.java b/hapi-fhir-structures-dstu/src/main/java/ca/uhn/fhir/rest/server/audit/IResourceAuditor.java index 40f275b68d3..e8f458c5af6 100644 --- a/hapi-fhir-structures-dstu/src/main/java/ca/uhn/fhir/rest/server/audit/IResourceAuditor.java +++ b/hapi-fhir-structures-dstu/src/main/java/ca/uhn/fhir/rest/server/audit/IResourceAuditor.java @@ -2,7 +2,7 @@ package ca.uhn.fhir.rest.server.audit; /* * #%L - * HAPI FHIR - Core Library + * HAPI FHIR Structures - DSTU1 (FHIR v0.80) * %% * Copyright (C) 2014 - 2016 University Health Network * %%