diff --git a/hapi-deployable-pom/pom.xml b/hapi-deployable-pom/pom.xml index 5308ae09cac..97a7f698966 100644 --- a/hapi-deployable-pom/pom.xml +++ b/hapi-deployable-pom/pom.xml @@ -4,7 +4,7 @@ ca.uhn.hapi.fhir hapi-fhir - 5.6.0-PRE1-SNAPSHOT + 5.6.0-PRE2-SNAPSHOT ../pom.xml diff --git a/hapi-fhir-android/pom.xml b/hapi-fhir-android/pom.xml index 25a1baa137d..3fb74827f93 100644 --- a/hapi-fhir-android/pom.xml +++ b/hapi-fhir-android/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 5.6.0-PRE1-SNAPSHOT + 5.6.0-PRE2-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-base/pom.xml b/hapi-fhir-base/pom.xml index 47c2057541e..a7ac0302705 100644 --- a/hapi-fhir-base/pom.xml +++ b/hapi-fhir-base/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 5.6.0-PRE1-SNAPSHOT + 5.6.0-PRE2-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/support/IValidationSupport.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/support/IValidationSupport.java index 3ab90dd4ec7..2ffc57116cb 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/support/IValidationSupport.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/support/IValidationSupport.java @@ -266,12 +266,26 @@ public interface IValidationSupport { * other method in the support chain, so that they can be passed through the entire chain. Implementations of this interface may always safely ignore this parameter. * @param theSystem The CodeSystem URL * @param theCode The code + * @param theDisplayLanguage to filter out the designation by the display language, to return all designation, the this value to null */ @Nullable - default LookupCodeResult lookupCode(ValidationSupportContext theValidationSupportContext, String theSystem, String theCode) { + default LookupCodeResult lookupCode(ValidationSupportContext theValidationSupportContext, String theSystem, String theCode, String theDisplayLanguage) { return null; } + /** + * Look up a code using the system and code value + * + * @param theValidationSupportContext The validation support module will be passed in to this method. This is convenient in cases where the operation needs to make calls to + * other method in the support chain, so that they can be passed through the entire chain. Implementations of this interface may always safely ignore this parameter. + * @param theSystem The CodeSystem URL + * @param theCode The code + */ + @Nullable + default LookupCodeResult lookupCode(ValidationSupportContext theValidationSupportContext, String theSystem, String theCode) { + return lookupCode(theValidationSupportContext, theSystem, theCode, null); + } + /** * Returns true if the given valueset can be validated by the given * validation support module diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/api/SearchContainedModeEnum.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/api/SearchContainedModeEnum.java index e90b201b6e4..bc0f320ed5e 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/api/SearchContainedModeEnum.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/api/SearchContainedModeEnum.java @@ -51,7 +51,7 @@ public enum SearchContainedModeEnum { myCode = theCode; } - private String getCode() { + public String getCode() { return myCode; } diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/VersionEnum.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/VersionEnum.java index 7742034d703..0d425b458d2 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/VersionEnum.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/VersionEnum.java @@ -76,6 +76,7 @@ public enum VersionEnum { V5_4_2, V5_5_0, V5_6_0 + ; public static VersionEnum latestVersion() { diff --git a/hapi-fhir-bom/pom.xml b/hapi-fhir-bom/pom.xml index 73e752cb095..8299f632b49 100644 --- a/hapi-fhir-bom/pom.xml +++ b/hapi-fhir-bom/pom.xml @@ -3,14 +3,14 @@ 4.0.0 ca.uhn.hapi.fhir hapi-fhir-bom - 5.6.0-PRE1-SNAPSHOT + 5.6.0-PRE2-SNAPSHOT pom HAPI FHIR BOM ca.uhn.hapi.fhir hapi-deployable-pom - 5.6.0-PRE1-SNAPSHOT + 5.6.0-PRE2-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-cli/hapi-fhir-cli-api/pom.xml b/hapi-fhir-cli/hapi-fhir-cli-api/pom.xml index a3f8cc0ff2a..d758c2fa826 100644 --- a/hapi-fhir-cli/hapi-fhir-cli-api/pom.xml +++ b/hapi-fhir-cli/hapi-fhir-cli-api/pom.xml @@ -4,7 +4,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 5.6.0-PRE1-SNAPSHOT + 5.6.0-PRE2-SNAPSHOT ../../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/ExportConceptMapToCsvCommand.java b/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/ExportConceptMapToCsvCommand.java index 3a4300d5546..e779c26d632 100644 --- a/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/ExportConceptMapToCsvCommand.java +++ b/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/ExportConceptMapToCsvCommand.java @@ -26,6 +26,7 @@ import org.apache.commons.cli.Options; import org.apache.commons.csv.CSVFormat; import org.apache.commons.csv.CSVPrinter; import org.apache.commons.csv.QuoteMode; +import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_40; import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.r4.model.Bundle; import org.hl7.fhir.r4.model.ConceptMap; @@ -42,7 +43,6 @@ import java.util.List; import java.util.concurrent.ExecutionException; import static org.apache.commons.lang3.StringUtils.defaultString; -import static org.hl7.fhir.convertors.conv30_40.ConceptMap30_40.convertConceptMap; public class ExportConceptMapToCsvCommand extends AbstractImportExportCsvConceptMapCommand { // TODO: Don't use qualified names for loggers in HAPI CLI. @@ -110,7 +110,7 @@ public class ExportConceptMapToCsvCommand extends AbstractImportExportCsvConcept private void convertConceptMapToCsv(org.hl7.fhir.dstu3.model.ConceptMap theConceptMap) throws ExecutionException { try { - convertConceptMapToCsv(convertConceptMap(theConceptMap)); + convertConceptMapToCsv((ConceptMap) VersionConvertorFactory_30_40.convertResource(theConceptMap)); } catch (FHIRException fe) { throw new ExecutionException(fe); } diff --git a/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/ImportCsvToConceptMapCommand.java b/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/ImportCsvToConceptMapCommand.java index 86166b29baa..08d6d35700d 100644 --- a/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/ImportCsvToConceptMapCommand.java +++ b/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/ImportCsvToConceptMapCommand.java @@ -28,6 +28,7 @@ import org.apache.commons.cli.Options; import org.apache.commons.csv.CSVFormat; import org.apache.commons.csv.CSVParser; import org.apache.commons.csv.CSVRecord; +import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_40; import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.r4.model.ConceptMap; import org.hl7.fhir.r4.model.ConceptMap.ConceptMapGroupComponent; @@ -47,7 +48,6 @@ import java.util.concurrent.ExecutionException; import static org.apache.commons.lang3.StringUtils.defaultString; import static org.apache.commons.lang3.StringUtils.isBlank; import static org.apache.commons.lang3.StringUtils.isNotBlank; -import static org.hl7.fhir.convertors.conv30_40.ConceptMap30_40.convertConceptMap; public class ImportCsvToConceptMapCommand extends AbstractImportExportCsvConceptMapCommand { // TODO: Don't use qualified names for loggers in HAPI CLI. @@ -152,7 +152,7 @@ public class ImportCsvToConceptMapCommand extends AbstractImportExportCsvConcept private org.hl7.fhir.dstu3.model.ConceptMap convertCsvToConceptMapDstu3() throws ExecutionException { try { - return convertConceptMap(convertCsvToConceptMapR4()); + return (org.hl7.fhir.dstu3.model.ConceptMap) VersionConvertorFactory_30_40.convertResource(convertCsvToConceptMapR4()); } catch (FHIRException fe) { throw new ExecutionException(fe); } diff --git a/hapi-fhir-cli/hapi-fhir-cli-app/pom.xml b/hapi-fhir-cli/hapi-fhir-cli-app/pom.xml index 85b7edfe8d2..6754bf399d6 100644 --- a/hapi-fhir-cli/hapi-fhir-cli-app/pom.xml +++ b/hapi-fhir-cli/hapi-fhir-cli-app/pom.xml @@ -6,7 +6,7 @@ ca.uhn.hapi.fhir hapi-fhir-cli - 5.6.0-PRE1-SNAPSHOT + 5.6.0-PRE2-SNAPSHOT ../pom.xml diff --git a/hapi-fhir-cli/hapi-fhir-cli-jpaserver/pom.xml b/hapi-fhir-cli/hapi-fhir-cli-jpaserver/pom.xml index ba93b27631f..a7c0c5300e3 100644 --- a/hapi-fhir-cli/hapi-fhir-cli-jpaserver/pom.xml +++ b/hapi-fhir-cli/hapi-fhir-cli-jpaserver/pom.xml @@ -6,7 +6,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 5.6.0-PRE1-SNAPSHOT + 5.6.0-PRE2-SNAPSHOT ../../hapi-deployable-pom diff --git a/hapi-fhir-cli/pom.xml b/hapi-fhir-cli/pom.xml index 4fd1932174c..87195288afe 100644 --- a/hapi-fhir-cli/pom.xml +++ b/hapi-fhir-cli/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-fhir - 5.6.0-PRE1-SNAPSHOT + 5.6.0-PRE2-SNAPSHOT ../pom.xml diff --git a/hapi-fhir-client-okhttp/pom.xml b/hapi-fhir-client-okhttp/pom.xml index ade4fa29b7c..13c7f7af8bd 100644 --- a/hapi-fhir-client-okhttp/pom.xml +++ b/hapi-fhir-client-okhttp/pom.xml @@ -4,7 +4,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 5.6.0-PRE1-SNAPSHOT + 5.6.0-PRE2-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-client/pom.xml b/hapi-fhir-client/pom.xml index 2394ac950a9..7ac45a8c943 100644 --- a/hapi-fhir-client/pom.xml +++ b/hapi-fhir-client/pom.xml @@ -4,7 +4,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 5.6.0-PRE1-SNAPSHOT + 5.6.0-PRE2-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-converter/pom.xml b/hapi-fhir-converter/pom.xml index 5d9e3e5a169..10f8d934c02 100644 --- a/hapi-fhir-converter/pom.xml +++ b/hapi-fhir-converter/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 5.6.0-PRE1-SNAPSHOT + 5.6.0-PRE2-SNAPSHOT ../hapi-deployable-pom/pom.xml @@ -207,6 +207,16 @@ commons-compress ${commons_compress_version} + + org.projectlombok + lombok + 1.18.16 + + + org.jetbrains + annotations + 22.0.0 + diff --git a/hapi-fhir-converter/src/main/java/ca/uhn/hapi/converters/server/VersionedApiConverterInterceptor.java b/hapi-fhir-converter/src/main/java/ca/uhn/hapi/converters/server/VersionedApiConverterInterceptor.java index a078a966317..0ff8a6dd3bd 100644 --- a/hapi-fhir-converter/src/main/java/ca/uhn/hapi/converters/server/VersionedApiConverterInterceptor.java +++ b/hapi-fhir-converter/src/main/java/ca/uhn/hapi/converters/server/VersionedApiConverterInterceptor.java @@ -29,11 +29,11 @@ import ca.uhn.fhir.rest.api.server.ResponseDetails; import ca.uhn.fhir.rest.server.exceptions.AuthenticationException; import ca.uhn.fhir.rest.server.exceptions.InternalErrorException; import ca.uhn.fhir.rest.server.interceptor.InterceptorAdapter; -import org.hl7.fhir.converter.NullVersionConverterAdvisor30; -import org.hl7.fhir.converter.NullVersionConverterAdvisor40; -import org.hl7.fhir.convertors.VersionConvertor_10_30; -import org.hl7.fhir.convertors.VersionConvertor_10_40; -import org.hl7.fhir.convertors.VersionConvertor_30_40; +import org.hl7.fhir.converter.NullVersionConverterAdvisor10_30; +import org.hl7.fhir.converter.NullVersionConverterAdvisor10_40; +import org.hl7.fhir.convertors.factory.VersionConvertorFactory_10_30; +import org.hl7.fhir.convertors.factory.VersionConvertorFactory_10_40; +import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_40; import org.hl7.fhir.dstu3.model.Resource; import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.instance.model.api.IBaseResource; @@ -42,9 +42,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.util.StringTokenizer; -import static org.apache.commons.lang3.StringUtils.defaultString; -import static org.apache.commons.lang3.StringUtils.isBlank; -import static org.apache.commons.lang3.StringUtils.isNotBlank; +import static org.apache.commons.lang3.StringUtils.*; /** * This is an experimental interceptor! Use with caution as @@ -58,12 +56,12 @@ import static org.apache.commons.lang3.StringUtils.isNotBlank; public class VersionedApiConverterInterceptor extends InterceptorAdapter { private final FhirContext myCtxDstu2; private final FhirContext myCtxDstu2Hl7Org; - private final NullVersionConverterAdvisor40 advisor40; - private final NullVersionConverterAdvisor30 advisor30; + private final NullVersionConverterAdvisor10_40 advisor40; + private final NullVersionConverterAdvisor10_30 advisor30; public VersionedApiConverterInterceptor() { - advisor40 = new NullVersionConverterAdvisor40(); - advisor30 = new NullVersionConverterAdvisor30(); + advisor40 = new NullVersionConverterAdvisor10_40(); + advisor30 = new NullVersionConverterAdvisor10_30(); myCtxDstu2 = FhirContext.forDstu2(); myCtxDstu2Hl7Org = FhirContext.forDstu2Hl7Org(); @@ -104,17 +102,17 @@ public class VersionedApiConverterInterceptor extends InterceptorAdapter { IBaseResource converted = null; try { if (wantVersion == FhirVersionEnum.R4 && haveVersion == FhirVersionEnum.DSTU3) { - converted = VersionConvertor_30_40.convertResource(toDstu3(responseResource), true); + converted = VersionConvertorFactory_30_40.convertResource(toDstu3(responseResource)); } else if (wantVersion == FhirVersionEnum.DSTU3 && haveVersion == FhirVersionEnum.R4) { - converted = VersionConvertor_30_40.convertResource(toR4(responseResource), true); + converted = VersionConvertorFactory_30_40.convertResource(toR4(responseResource)); } else if (wantVersion == FhirVersionEnum.DSTU2 && haveVersion == FhirVersionEnum.R4) { - converted = VersionConvertor_10_40.convertResource(toR4(responseResource), advisor40); + converted = VersionConvertorFactory_10_40.convertResource(toR4(responseResource), advisor40); } else if (wantVersion == FhirVersionEnum.R4 && haveVersion == FhirVersionEnum.DSTU2) { - converted = VersionConvertor_10_40.convertResource(toDstu2(responseResource), advisor40); + converted = VersionConvertorFactory_10_40.convertResource(toDstu2(responseResource), advisor40); } else if (wantVersion == FhirVersionEnum.DSTU2 && haveVersion == FhirVersionEnum.DSTU3) { - converted = VersionConvertor_10_30.convertResource(toDstu3(responseResource), advisor30); + converted = VersionConvertorFactory_10_30.convertResource(toDstu3(responseResource), advisor30); } else if (wantVersion == FhirVersionEnum.DSTU3 && haveVersion == FhirVersionEnum.DSTU2) { - converted = VersionConvertor_10_30.convertResource(toDstu2(responseResource), advisor30); + converted = VersionConvertorFactory_10_30.convertResource(toDstu2(responseResource), advisor30); } } catch (FHIRException e) { throw new InternalErrorException(e); diff --git a/hapi-fhir-converter/src/main/java/org/hl7/fhir/converter/NullVersionConverterAdvisor30.java b/hapi-fhir-converter/src/main/java/org/hl7/fhir/converter/NullVersionConverterAdvisor10_30.java similarity index 88% rename from hapi-fhir-converter/src/main/java/org/hl7/fhir/converter/NullVersionConverterAdvisor30.java rename to hapi-fhir-converter/src/main/java/org/hl7/fhir/converter/NullVersionConverterAdvisor10_30.java index 2ec5545079b..72930492e2b 100644 --- a/hapi-fhir-converter/src/main/java/org/hl7/fhir/converter/NullVersionConverterAdvisor30.java +++ b/hapi-fhir-converter/src/main/java/org/hl7/fhir/converter/NullVersionConverterAdvisor10_30.java @@ -20,8 +20,7 @@ package org.hl7.fhir.converter; * #L% */ -import org.hl7.fhir.convertors.advisors.VersionConvertorAdvisor30; -import org.hl7.fhir.dstu2.model.Resource; +import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_30; import org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent; import org.hl7.fhir.dstu3.model.CodeSystem; import org.hl7.fhir.dstu3.model.ValueSet; @@ -31,7 +30,7 @@ import org.hl7.fhir.r5.model.FhirPublication; import javax.annotation.Nonnull; import javax.annotation.Nullable; -public class NullVersionConverterAdvisor30 implements VersionConvertorAdvisor30 { +public class NullVersionConverterAdvisor10_30 extends BaseAdvisor_10_30 { @Nullable diff --git a/hapi-fhir-converter/src/main/java/org/hl7/fhir/converter/NullVersionConverterAdvisor40.java b/hapi-fhir-converter/src/main/java/org/hl7/fhir/converter/NullVersionConverterAdvisor10_40.java similarity index 88% rename from hapi-fhir-converter/src/main/java/org/hl7/fhir/converter/NullVersionConverterAdvisor40.java rename to hapi-fhir-converter/src/main/java/org/hl7/fhir/converter/NullVersionConverterAdvisor10_40.java index eaa125676e6..05582993624 100644 --- a/hapi-fhir-converter/src/main/java/org/hl7/fhir/converter/NullVersionConverterAdvisor40.java +++ b/hapi-fhir-converter/src/main/java/org/hl7/fhir/converter/NullVersionConverterAdvisor10_40.java @@ -20,8 +20,7 @@ package org.hl7.fhir.converter; * #L% */ -import org.hl7.fhir.convertors.advisors.VersionConvertorAdvisor40; -import org.hl7.fhir.dstu2.model.Resource; +import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_40; import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.r4.model.Bundle.BundleEntryComponent; import org.hl7.fhir.r4.model.CodeSystem; @@ -31,7 +30,7 @@ import org.hl7.fhir.r5.model.FhirPublication; import javax.annotation.Nonnull; import javax.annotation.Nullable; -public class NullVersionConverterAdvisor40 implements VersionConvertorAdvisor40 { +public class NullVersionConverterAdvisor10_40 extends BaseAdvisor_10_40 { @Nullable diff --git a/hapi-fhir-converter/src/main/java/org/hl7/fhir/converter/NullVersionConverterAdvisor50.java b/hapi-fhir-converter/src/main/java/org/hl7/fhir/converter/NullVersionConverterAdvisor10_50.java similarity index 88% rename from hapi-fhir-converter/src/main/java/org/hl7/fhir/converter/NullVersionConverterAdvisor50.java rename to hapi-fhir-converter/src/main/java/org/hl7/fhir/converter/NullVersionConverterAdvisor10_50.java index 9e7aac2374f..3e4252e30b9 100644 --- a/hapi-fhir-converter/src/main/java/org/hl7/fhir/converter/NullVersionConverterAdvisor50.java +++ b/hapi-fhir-converter/src/main/java/org/hl7/fhir/converter/NullVersionConverterAdvisor10_50.java @@ -20,8 +20,8 @@ package org.hl7.fhir.converter; * #L% */ -import org.hl7.fhir.convertors.advisors.VersionConvertorAdvisor50; -import org.hl7.fhir.dstu2.model.Resource; +import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_50; +import org.hl7.fhir.convertors.conv10_50.VersionConvertor_10_50; import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.r5.model.Bundle; import org.hl7.fhir.r5.model.CodeSystem; @@ -32,7 +32,7 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; import java.util.IdentityHashMap; -public class NullVersionConverterAdvisor50 implements VersionConvertorAdvisor50 { +public class NullVersionConverterAdvisor10_50 extends BaseAdvisor_10_50 { private IdentityHashMap myCodeSystems = new IdentityHashMap<>(); diff --git a/hapi-fhir-converter/src/test/java/org/hl7/fhir/converter/VersionConvertor_10_30Test.java b/hapi-fhir-converter/src/test/java/org/hl7/fhir/converter/VersionConvertor_10_30Test.java index d03a6f73173..f79807943a5 100644 --- a/hapi-fhir-converter/src/test/java/org/hl7/fhir/converter/VersionConvertor_10_30Test.java +++ b/hapi-fhir-converter/src/test/java/org/hl7/fhir/converter/VersionConvertor_10_30Test.java @@ -2,7 +2,7 @@ package org.hl7.fhir.converter; import static org.junit.jupiter.api.Assertions.assertEquals; -import org.hl7.fhir.convertors.VersionConvertor_10_30; +import org.hl7.fhir.convertors.factory.VersionConvertorFactory_10_30; import org.hl7.fhir.dstu3.model.*; import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.dstu2.model.Resource; @@ -19,7 +19,7 @@ public class VersionConvertor_10_30Test { org.hl7.fhir.dstu2.model.Observation input = new org.hl7.fhir.dstu2.model.Observation(); input.setEncounter(new org.hl7.fhir.dstu2.model.Reference("Encounter/123")); - org.hl7.fhir.dstu3.model.Observation output = (Observation) VersionConvertor_10_30.convertResource(input); + org.hl7.fhir.dstu3.model.Observation output = (Observation) VersionConvertorFactory_10_30.convertResource(input); String context = output.getContext().getReference(); assertEquals("Encounter/123", context); @@ -52,7 +52,7 @@ public class VersionConvertor_10_30Test { Specimen.SpecimenContainerComponent specimenContainerComponent = new Specimen.SpecimenContainerComponent(); specimenContainerComponent.getExtension().add(new Extension().setUrl("some_url").setValue(new StringType("some_value"))); spec.setContainer(Collections.singletonList(specimenContainerComponent)); - Resource resource = VersionConvertor_10_30.convertResource(spec); + Resource resource = VersionConvertorFactory_10_30.convertResource(spec); } diff --git a/hapi-fhir-converter/src/test/java/org/hl7/fhir/converter/VersionConvertor_14_30Test.java b/hapi-fhir-converter/src/test/java/org/hl7/fhir/converter/VersionConvertor_14_30Test.java index f896e422830..1568f6dbc9b 100644 --- a/hapi-fhir-converter/src/test/java/org/hl7/fhir/converter/VersionConvertor_14_30Test.java +++ b/hapi-fhir-converter/src/test/java/org/hl7/fhir/converter/VersionConvertor_14_30Test.java @@ -2,7 +2,7 @@ package org.hl7.fhir.converter; import static org.junit.jupiter.api.Assertions.assertEquals; -import org.hl7.fhir.convertors.VersionConvertor_14_30; +import org.hl7.fhir.convertors.factory.VersionConvertorFactory_14_30; import org.hl7.fhir.dstu3.model.Questionnaire; import org.hl7.fhir.exceptions.FHIRException; import org.junit.jupiter.api.Test; @@ -15,7 +15,7 @@ public class VersionConvertor_14_30Test { org.hl7.fhir.dstu2016may.model.Questionnaire input = new org.hl7.fhir.dstu2016may.model.Questionnaire(); input.setTitle("My title"); - org.hl7.fhir.dstu3.model.Questionnaire output = (Questionnaire) VersionConvertor_14_30.convertResource(input); + org.hl7.fhir.dstu3.model.Questionnaire output = (Questionnaire) VersionConvertorFactory_14_30.convertResource(input); String context = output.getTitle(); assertEquals("My title", context); diff --git a/hapi-fhir-dist/pom.xml b/hapi-fhir-dist/pom.xml index 4af7e03731e..3c20dd131b9 100644 --- a/hapi-fhir-dist/pom.xml +++ b/hapi-fhir-dist/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-fhir - 5.6.0-PRE1-SNAPSHOT + 5.6.0-PRE2-SNAPSHOT ../pom.xml diff --git a/hapi-fhir-docs/pom.xml b/hapi-fhir-docs/pom.xml index 67a0452aeef..8057f47b1cc 100644 --- a/hapi-fhir-docs/pom.xml +++ b/hapi-fhir-docs/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 5.6.0-PRE1-SNAPSHOT + 5.6.0-PRE2-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-docs/src/main/java/ca/uhn/hapi/fhir/docs/ConverterExamples.java b/hapi-fhir-docs/src/main/java/ca/uhn/hapi/fhir/docs/ConverterExamples.java index 6761a7674d0..a72e430c9dc 100644 --- a/hapi-fhir-docs/src/main/java/ca/uhn/hapi/fhir/docs/ConverterExamples.java +++ b/hapi-fhir-docs/src/main/java/ca/uhn/hapi/fhir/docs/ConverterExamples.java @@ -20,36 +20,38 @@ package ca.uhn.hapi.fhir.docs; * #L% */ -import org.hl7.fhir.convertors.conv10_30.Observation10_30; -import org.hl7.fhir.convertors.conv14_30.Questionnaire14_30; +import org.hl7.fhir.convertors.factory.VersionConvertorFactory_10_30; +import org.hl7.fhir.convertors.factory.VersionConvertorFactory_14_30; +import org.hl7.fhir.dstu3.model.Observation; +import org.hl7.fhir.dstu3.model.Questionnaire; import org.hl7.fhir.exceptions.FHIRException; public class ConverterExamples { @SuppressWarnings("unused") public void c1020() throws FHIRException { - //START SNIPPET: 1020 + //START SNIPPET: 1020 // Create an input resource to convert org.hl7.fhir.dstu2.model.Observation input = new org.hl7.fhir.dstu2.model.Observation(); input.setEncounter(new org.hl7.fhir.dstu2.model.Reference("Encounter/123")); - + // Convert the resource - org.hl7.fhir.dstu3.model.Observation output = Observation10_30.convertObservation(input); + org.hl7.fhir.dstu3.model.Observation output = (Observation) VersionConvertorFactory_10_30.convertResource(input); String context = output.getContext().getReference(); - //END SNIPPET: 1020 + //END SNIPPET: 1020 } - + @SuppressWarnings("unused") public void c1420() throws FHIRException { - //START SNIPPET: 1420 + //START SNIPPET: 1420 // Create a resource to convert org.hl7.fhir.dstu2016may.model.Questionnaire input = new org.hl7.fhir.dstu2016may.model.Questionnaire(); input.setTitle("My title"); - + // Convert the resource - org.hl7.fhir.dstu3.model.Questionnaire output = Questionnaire14_30.convertQuestionnaire(input); + org.hl7.fhir.dstu3.model.Questionnaire output = (Questionnaire) VersionConvertorFactory_14_30.convertResource(input); String context = output.getTitle(); - //END SNIPPET: 1420 + //END SNIPPET: 1420 } } diff --git a/hapi-fhir-docs/src/main/java/ca/uhn/hapi/fhir/docs/ValidatorExamples.java b/hapi-fhir-docs/src/main/java/ca/uhn/hapi/fhir/docs/ValidatorExamples.java index 4c12593024c..0c634e415cc 100644 --- a/hapi-fhir-docs/src/main/java/ca/uhn/hapi/fhir/docs/ValidatorExamples.java +++ b/hapi-fhir-docs/src/main/java/ca/uhn/hapi/fhir/docs/ValidatorExamples.java @@ -299,7 +299,7 @@ public class ValidatorExamples { } @Override - public LookupCodeResult lookupCode(ValidationSupportContext theValidationSupportContext, String theSystem, String theCode) { + public LookupCodeResult lookupCode(ValidationSupportContext theValidationSupportContext, String theSystem, String theCode, String theDisplayLanguage) { // TODO: implement (or return null if your implementation does not support this function) return null; } diff --git a/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/5_5_0/2868-bug-in-conditional-create.yaml b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/5_5_0/2868-bug-in-conditional-create.yaml new file mode 100644 index 00000000000..015dc2b73a0 --- /dev/null +++ b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/5_5_0/2868-bug-in-conditional-create.yaml @@ -0,0 +1,6 @@ +--- +type: fix +issue: 2868 +jira: SMILE-1153 +title: "Fixed a bug in transaction bundle processing, specifically for bundles which contained both a conditional create, and a resource which relied on this conditional create as a reference. +This would cause the referring resource to generate a contained resource instead of appropriately referencing the existing patient." diff --git a/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/5_5_0/2871-enhance-mdm-expansion.yaml b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/5_5_0/2871-enhance-mdm-expansion.yaml new file mode 100644 index 00000000000..f0f427f2b01 --- /dev/null +++ b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/5_5_0/2871-enhance-mdm-expansion.yaml @@ -0,0 +1,5 @@ +--- +type: add +issue: 2871 +title: "Modified the behaviour of the `:mdm` param qualifier. Previously, it used to only resolve IDs if the resource ID was a source resource. +Now, MDM expansion will work if you pass it the ID of a golden resource instead." diff --git a/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/5_5_0/2887-contained-ignored-for-cache-key-purposes.yaml b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/5_5_0/2887-contained-ignored-for-cache-key-purposes.yaml new file mode 100644 index 00000000000..bf2b4b334ba --- /dev/null +++ b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/5_5_0/2887-contained-ignored-for-cache-key-purposes.yaml @@ -0,0 +1,6 @@ +--- +type: fix +issue: 2887 +jira: SMILE-2896 +title: "Fixed a bug where the search results cache was ignoring the value of `_contained` parameter when assigning a cache key. + This was causing queries run in a short period of time to return wrong cached results if one query used `_contained=true` and the other did not." diff --git a/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/5_6_0/2902-includes-includes-on-revincludes.yaml b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/5_6_0/2902-includes-includes-on-revincludes.yaml index 3085e6b801f..98d6287a670 100644 --- a/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/5_6_0/2902-includes-includes-on-revincludes.yaml +++ b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/5_6_0/2902-includes-includes-on-revincludes.yaml @@ -2,5 +2,4 @@ type: fix issue: 2902 jira: SMILE-3000 -backport: cust_fmc_5_3 title: "Fixed a bug wherein includes were not being included on revincludes." diff --git a/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/5_6_0/2904-swagger-ui-Does-not-work-with-partitions.yaml b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/5_6_0/2904-swagger-ui-Does-not-work-with-partitions.yaml new file mode 100644 index 00000000000..241a5c78253 --- /dev/null +++ b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/5_6_0/2904-swagger-ui-Does-not-work-with-partitions.yaml @@ -0,0 +1,4 @@ +--- +type: change +issue: 2904 +title: "Change getPathItem method in OpenApiInterceptor from private to protected" diff --git a/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/5_6_0/2905-lookup-display-language.yaml b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/5_6_0/2905-lookup-display-language.yaml new file mode 100644 index 00000000000..30a6db8047f --- /dev/null +++ b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/5_6_0/2905-lookup-display-language.yaml @@ -0,0 +1,4 @@ +--- +type: add +issue: 2905 +title: "Added displayLanguage support for CodeSystem $lookup operation to filter out designation by language." diff --git a/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/5_6_0/2920-lookup-language-by-lang-only.yaml b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/5_6_0/2920-lookup-language-by-lang-only.yaml new file mode 100644 index 00000000000..f77e2309f48 --- /dev/null +++ b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/5_6_0/2920-lookup-language-by-lang-only.yaml @@ -0,0 +1,6 @@ +--- +type: fix +issue: 2920 +jira: SMILE-2971 +title: "Previously, validation against bcp47 (urn:ietf:bcp:47) as a language would fail validation if the region was absent. This has been fixed, and the validate +operation will now correctly validate simple languages, e.g. `nl` instead of requiring `nl-DE` or `nl-NL`" diff --git a/hapi-fhir-jacoco/pom.xml b/hapi-fhir-jacoco/pom.xml index 21209b4937f..ba7399f2148 100644 --- a/hapi-fhir-jacoco/pom.xml +++ b/hapi-fhir-jacoco/pom.xml @@ -11,7 +11,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 5.6.0-PRE1-SNAPSHOT + 5.6.0-PRE2-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jaxrsserver-base/pom.xml b/hapi-fhir-jaxrsserver-base/pom.xml index e0d835b4865..9a6548cb58a 100644 --- a/hapi-fhir-jaxrsserver-base/pom.xml +++ b/hapi-fhir-jaxrsserver-base/pom.xml @@ -4,7 +4,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 5.6.0-PRE1-SNAPSHOT + 5.6.0-PRE2-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jpaserver-api/pom.xml b/hapi-fhir-jpaserver-api/pom.xml index 1306d7505f9..7e5767c9039 100644 --- a/hapi-fhir-jpaserver-api/pom.xml +++ b/hapi-fhir-jpaserver-api/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 5.6.0-PRE1-SNAPSHOT + 5.6.0-PRE2-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jpaserver-api/src/main/java/ca/uhn/fhir/jpa/api/dao/IFhirResourceDaoCodeSystem.java b/hapi-fhir-jpaserver-api/src/main/java/ca/uhn/fhir/jpa/api/dao/IFhirResourceDaoCodeSystem.java index 8161630cd71..bfee55a9d61 100644 --- a/hapi-fhir-jpaserver-api/src/main/java/ca/uhn/fhir/jpa/api/dao/IFhirResourceDaoCodeSystem.java +++ b/hapi-fhir-jpaserver-api/src/main/java/ca/uhn/fhir/jpa/api/dao/IFhirResourceDaoCodeSystem.java @@ -40,6 +40,9 @@ public interface IFhirResourceDaoCodeSystem ext @Nonnull IValidationSupport.LookupCodeResult lookupCode(IPrimitiveType theCode, IPrimitiveType theSystem, CD theCoding, RequestDetails theRequestDetails); + @Nonnull + IValidationSupport.LookupCodeResult lookupCode(IPrimitiveType theCode, IPrimitiveType theSystem, CD theCoding, IPrimitiveType theDisplayLanguage, RequestDetails theRequestDetails); + SubsumesResult subsumes(IPrimitiveType theCodeA, IPrimitiveType theCodeB, IPrimitiveType theSystem, CD theCodingA, CD theCodingB, RequestDetails theRequestDetails); IValidationSupport.CodeValidationResult validateCode(IIdType theCodeSystemId, IPrimitiveType theCodeSystemUrl, IPrimitiveType theVersion, IPrimitiveType theCode, IPrimitiveType theDisplay, CD theCoding, CC theCodeableConcept, RequestDetails theRequestDetails); diff --git a/hapi-fhir-jpaserver-base/pom.xml b/hapi-fhir-jpaserver-base/pom.xml index 3e40dfdc235..9a5909c79de 100644 --- a/hapi-fhir-jpaserver-base/pom.xml +++ b/hapi-fhir-jpaserver-base/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 5.6.0-PRE1-SNAPSHOT + 5.6.0-PRE2-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/cache/ResourceVersionSvcDaoImpl.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/cache/ResourceVersionSvcDaoImpl.java index aa2c9ef2ad9..cb82083e24e 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/cache/ResourceVersionSvcDaoImpl.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/cache/ResourceVersionSvcDaoImpl.java @@ -20,6 +20,7 @@ package ca.uhn.fhir.jpa.cache; * #L% */ +import ca.uhn.fhir.interceptor.model.RequestPartitionId; import ca.uhn.fhir.jpa.api.dao.DaoRegistry; import ca.uhn.fhir.jpa.api.dao.IFhirResourceDao; import ca.uhn.fhir.jpa.dao.data.IResourceTableDao; @@ -28,6 +29,7 @@ import ca.uhn.fhir.jpa.partition.SystemRequestDetails; import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; import ca.uhn.fhir.jpa.util.QueryChunker; import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import org.slf4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -36,12 +38,15 @@ import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; +import static org.slf4j.LoggerFactory.getLogger; + /** * This service builds a map of resource ids to versions based on a SearchParameterMap. * It is used by the in-memory resource-version cache to detect when resource versions have been changed by remote processes. */ @Service public class ResourceVersionSvcDaoImpl implements IResourceVersionSvc { + private static final Logger ourLog = getLogger(ResourceVersionSvcDaoImpl.class); @Autowired DaoRegistry myDaoRegistry; @@ -53,7 +58,11 @@ public class ResourceVersionSvcDaoImpl implements IResourceVersionSvc { public ResourceVersionMap getVersionMap(String theResourceName, SearchParameterMap theSearchParamMap) { IFhirResourceDao dao = myDaoRegistry.getResourceDao(theResourceName); - List matchingIds = dao.searchForIds(theSearchParamMap, new SystemRequestDetails()).stream() + if (ourLog.isDebugEnabled()) { + ourLog.debug("About to retrieve version map for resource type: {}", theResourceName); + } + + List matchingIds = dao.searchForIds(theSearchParamMap, new SystemRequestDetails().setRequestPartitionId(RequestPartitionId.allPartitions())).stream() .map(ResourcePersistentId::getIdAsLong) .collect(Collectors.toList()); diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirDao.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirDao.java index bd2e964e523..387babd3eda 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirDao.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirDao.java @@ -94,6 +94,7 @@ import com.google.common.collect.Sets; import com.google.common.hash.HashFunction; import com.google.common.hash.Hashing; import org.apache.commons.lang3.NotImplementedException; +import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.Validate; import org.hl7.fhir.instance.model.api.IAnyResource; import org.hl7.fhir.instance.model.api.IBase; @@ -1162,10 +1163,8 @@ public abstract class BaseHapiFhirDao extends BaseStora validateResourceForStorage((T) theResource, entity); } } - String resourceType = myContext.getResourceType(theResource); - if (isNotBlank(entity.getResourceType()) && !entity.getResourceType().equals(resourceType)) { - throw new UnprocessableEntityException( - "Existing resource ID[" + entity.getIdDt().toUnqualifiedVersionless() + "] is of type[" + entity.getResourceType() + "] - Cannot update with [" + resourceType + "]"); + if (!StringUtils.isBlank(entity.getResourceType())) { + validateIncomingResourceTypeMatchesExisting(theResource, entity); } } @@ -1206,6 +1205,7 @@ public abstract class BaseHapiFhirDao extends BaseStora if (thePerformIndexing || ((ResourceTable) theEntity).getVersion() == 1) { newParams = new ResourceIndexedSearchParams(); + mySearchParamWithInlineReferencesExtractor.populateFromResource(newParams, theTransactionDetails, entity, theResource, existingParams, theRequest, thePerformIndexing); changed = populateResourceIntoEntity(theTransactionDetails, theRequest, theResource, entity, true); @@ -1415,6 +1415,14 @@ public abstract class BaseHapiFhirDao extends BaseStora return entity; } + private void validateIncomingResourceTypeMatchesExisting(IBaseResource theResource, ResourceTable entity) { + String resourceType = myContext.getResourceType(theResource); + if (!resourceType.equals(entity.getResourceType())) { + throw new UnprocessableEntityException( + "Existing resource ID[" + entity.getIdDt().toUnqualifiedVersionless() + "] is of type[" + entity.getResourceType() + "] - Cannot update with [" + resourceType + "]"); + } + } + @Override public ResourceTable updateInternal(RequestDetails theRequestDetails, T theResource, boolean thePerformIndexing, boolean theForceUpdateVersion, IBasePersistedResource theEntity, IIdType theResourceId, IBaseResource theOldResource, TransactionDetails theTransactionDetails) { diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseTransactionProcessor.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseTransactionProcessor.java index f599b5bc435..3bcf236007b 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseTransactionProcessor.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseTransactionProcessor.java @@ -90,6 +90,7 @@ import org.hl7.fhir.instance.model.api.IBaseReference; import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.instance.model.api.IIdType; import org.hl7.fhir.instance.model.api.IPrimitiveType; +import org.hl7.fhir.r4.model.Task; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -803,6 +804,7 @@ public abstract class BaseTransactionProcessor { String matchUrl = myVersionAdapter.getEntryRequestIfNoneExist(nextReqEntry); matchUrl = performIdSubstitutionsInMatchUrl(theIdSubstitutions, matchUrl); outcome = resourceDao.create(res, matchUrl, false, theTransactionDetails, theRequest); + res.setId(outcome.getId()); if (nextResourceId != null) { handleTransactionCreateOrUpdateOutcome(theIdSubstitutions, theIdToPersistedOutcome, nextResourceId, outcome, nextRespEntry, resourceType, res, theRequest); } @@ -1023,13 +1025,9 @@ public abstract class BaseTransactionProcessor { for (IIdType next : theAllIds) { IIdType replacement = theIdSubstitutions.get(next); - if (replacement == null) { - continue; + if (replacement != null && !replacement.equals(next)) { + ourLog.debug("Placeholder resource ID \"{}\" was replaced with permanent ID \"{}\"", next, replacement); } - if (replacement.equals(next)) { - continue; - } - ourLog.debug("Placeholder resource ID \"{}\" was replaced with permanent ID \"{}\"", next, replacement); } ListMultimap deferredBroadcastEvents = theTransactionDetails.endAcceptingDeferredInterceptorBroadcasts(); @@ -1112,7 +1110,6 @@ public abstract class BaseTransactionProcessor { } deferredIndexesForAutoVersioning.put(nextOutcome, referencesToAutoVersion); } - } // If we have any resources we'll be auto-versioning, index these next diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/FhirResourceDaoSearchParameterDstu2.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/FhirResourceDaoSearchParameterDstu2.java index c45af7dcbe7..2f7f4bfaa76 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/FhirResourceDaoSearchParameterDstu2.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/FhirResourceDaoSearchParameterDstu2.java @@ -22,22 +22,14 @@ package ca.uhn.fhir.jpa.dao; import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.jpa.api.dao.IFhirResourceDaoSearchParameter; -import ca.uhn.fhir.jpa.api.dao.IFhirSystemDao; import ca.uhn.fhir.jpa.dao.r4.FhirResourceDaoSearchParameterR4; import ca.uhn.fhir.jpa.model.entity.ResourceTable; import ca.uhn.fhir.jpa.searchparam.extractor.ISearchParamExtractor; import ca.uhn.fhir.model.dstu2.resource.SearchParameter; -import ca.uhn.fhir.model.dstu2.valueset.ResourceTypeEnum; -import ca.uhn.fhir.model.dstu2.valueset.SearchParamTypeEnum; -import ca.uhn.fhir.model.primitive.BoundCodeDt; -import org.hl7.fhir.convertors.conv10_40.SearchParameter10_40; -import org.hl7.fhir.instance.model.api.IBaseResource; +import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_40; +import org.hl7.fhir.convertors.factory.VersionConvertorFactory_10_40; import org.springframework.beans.factory.annotation.Autowired; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - import static org.apache.commons.lang3.StringUtils.isBlank; import static org.apache.commons.lang3.StringUtils.isNotBlank; @@ -79,7 +71,7 @@ public class FhirResourceDaoSearchParameterDstu2 extends BaseHapiFhirResourceDao String encoded = getContext().newJsonParser().encodeResourceToString(theResource); org.hl7.fhir.dstu2.model.SearchParameter hl7Org = myDstu2Hl7OrgContext.newJsonParser().parseResource(org.hl7.fhir.dstu2.model.SearchParameter.class, encoded); - org.hl7.fhir.r4.model.SearchParameter convertedSp = SearchParameter10_40.convertSearchParameter(hl7Org); + org.hl7.fhir.r4.model.SearchParameter convertedSp = (org.hl7.fhir.r4.model.SearchParameter) VersionConvertorFactory_10_40.convertResource(hl7Org, new BaseAdvisor_10_40(false)); if (isBlank(convertedSp.getExpression()) && isNotBlank(hl7Org.getXpath())) { convertedSp.setExpression(hl7Org.getXpath()); } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/FhirResourceDaoValueSetDstu2.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/FhirResourceDaoValueSetDstu2.java index 25c3cf98bcb..4094915d6bb 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/FhirResourceDaoValueSetDstu2.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/FhirResourceDaoValueSetDstu2.java @@ -230,7 +230,13 @@ public class FhirResourceDaoValueSetDstu2 extends BaseHapiFhirResourceDao theCode, IPrimitiveType theSystem, CodingDt theCoding, RequestDetails theRequest) { + public IValidationSupport.LookupCodeResult lookupCode(IPrimitiveType theCode, IPrimitiveType theSystem, CodingDt theCoding, RequestDetails theRequest) { + return lookupCode(theCode, theSystem, theCoding, null, theRequest); + } + + @Nonnull + @Override + public IValidationSupport.LookupCodeResult lookupCode(IPrimitiveType theCode, IPrimitiveType theSystem, CodingDt theCoding, IPrimitiveType theDisplayLanguage, RequestDetails theRequest) { boolean haveCoding = theCoding != null && isNotBlank(theCoding.getSystem()) && isNotBlank(theCoding.getCode()); boolean haveCode = theCode != null && theCode.isEmpty() == false; boolean haveSystem = theSystem != null && theSystem.isEmpty() == false; diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/TransactionProcessor.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/TransactionProcessor.java index 45c04b47be7..748ffa6352b 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/TransactionProcessor.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/TransactionProcessor.java @@ -46,6 +46,7 @@ import org.hl7.fhir.instance.model.api.IBase; import org.hl7.fhir.instance.model.api.IBaseBundle; import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.instance.model.api.IIdType; +import javax.annotation.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -61,10 +62,12 @@ import javax.persistence.criteria.Predicate; import javax.persistence.criteria.Root; import java.util.ArrayList; import java.util.Collection; +import java.util.HashMap; import java.util.HashSet; import java.util.IdentityHashMap; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.Set; import java.util.regex.Pattern; import java.util.stream.Collectors; @@ -218,18 +221,9 @@ public class TransactionProcessor extends BaseTransactionProcessor { IQueryParameterType param = andList.get(0).get(0); if (param instanceof TokenParam) { - TokenParam tokenParam = (TokenParam) param; - Predicate hashPredicate = null; - if (isNotBlank(tokenParam.getValue()) && isNotBlank(tokenParam.getSystem())) { - next.myHashSystemAndValue = ResourceIndexedSearchParamToken.calculateHashSystemAndValue(myPartitionSettings, requestPartitionId, next.myResourceDefinition.getName(), next.myMatchUrlSearchMap.keySet().iterator().next(), tokenParam.getSystem(), tokenParam.getValue()); - hashPredicate = cb.equal(from.get("myHashSystemAndValue").as(Long.class), next.myHashSystemAndValue); - } else if (isNotBlank(tokenParam.getValue())) { - next.myHashValue = ResourceIndexedSearchParamToken.calculateHashValue(myPartitionSettings, requestPartitionId, next.myResourceDefinition.getName(), next.myMatchUrlSearchMap.keySet().iterator().next(), tokenParam.getValue()); - hashPredicate = cb.equal(from.get("myHashValue").as(Long.class), next.myHashValue); - } + Predicate hashPredicate = buildHashPredicateFromTokenParam((TokenParam)param, requestPartitionId, cb, from, next); if (hashPredicate != null) { - if (myPartitionSettings.isPartitioningEnabled() && !myPartitionSettings.isIncludePartitionInSearchHashes()) { if (requestPartitionId.isDefaultPartition()) { Predicate partitionIdCriteria = cb.isNull(from.get("myPartitionIdValue").as(Integer.class)); @@ -250,35 +244,26 @@ public class TransactionProcessor extends BaseTransactionProcessor { if (orPredicates.size() > 1) { cq.where(cb.or(orPredicates.toArray(EMPTY_PREDICATE_ARRAY))); + Map hashToSearchMap = buildHashToSearchMap(searchParameterMapsToResolve); + TypedQuery query = myEntityManager.createQuery(cq); List results = query.getResultList(); + for (ResourceIndexedSearchParamToken nextResult : results) { - - for (MatchUrlToResolve nextSearchParameterMap : searchParameterMapsToResolve) { - if (nextSearchParameterMap.myHashSystemAndValue != null && nextSearchParameterMap.myHashSystemAndValue.equals(nextResult.getHashSystemAndValue())) { - idsToPreFetch.add(nextResult.getResourcePid()); - myMatchResourceUrlService.matchUrlResolved(theTransactionDetails, nextSearchParameterMap.myResourceDefinition.getName(), nextSearchParameterMap.myRequestUrl, new ResourcePersistentId(nextResult.getResourcePid())); - theTransactionDetails.addResolvedMatchUrl(nextSearchParameterMap.myRequestUrl, new ResourcePersistentId(nextResult.getResourcePid())); - nextSearchParameterMap.myResolved = true; - } - if (nextSearchParameterMap.myHashValue != null && nextSearchParameterMap.myHashValue.equals(nextResult.getHashValue())) { - idsToPreFetch.add(nextResult.getResourcePid()); - myMatchResourceUrlService.matchUrlResolved(theTransactionDetails, nextSearchParameterMap.myResourceDefinition.getName(), nextSearchParameterMap.myRequestUrl, new ResourcePersistentId(nextResult.getResourcePid())); - theTransactionDetails.addResolvedMatchUrl(nextSearchParameterMap.myRequestUrl, new ResourcePersistentId(nextResult.getResourcePid())); - nextSearchParameterMap.myResolved = true; - } - + Optional matchedSearch = Optional.ofNullable(hashToSearchMap.get(nextResult.getHashSystemAndValue())); + if (!matchedSearch.isPresent()) { + matchedSearch = Optional.ofNullable(hashToSearchMap.get(nextResult.getHashValue())); } - + matchedSearch.ifPresent(matchUrlToResolve -> setSearchToResolvedAndPrefetchFoundResourcePid(theTransactionDetails, idsToPreFetch, nextResult, matchUrlToResolve)); } - - for (MatchUrlToResolve nextSearchParameterMap : searchParameterMapsToResolve) { + //For each SP Map which did not return a result, tag it as not found. + searchParameterMapsToResolve.stream() // No matches - if (!nextSearchParameterMap.myResolved) { - theTransactionDetails.addResolvedMatchUrl(nextSearchParameterMap.myRequestUrl, TransactionDetails.NOT_FOUND); - } - } - + .filter(match -> !match.myResolved) + .forEach(match -> { + ourLog.warn("Was unable to match url {} from database", match.myRequestUrl); + theTransactionDetails.addResolvedMatchUrl(match.myRequestUrl, TransactionDetails.NOT_FOUND); + }); } } @@ -320,6 +305,45 @@ public class TransactionProcessor extends BaseTransactionProcessor { return super.doTransactionWriteOperations(theRequest, theActionName, theTransactionDetails, theAllIds, theIdSubstitutions, theIdToPersistedOutcome, theResponse, theOriginalRequestOrder, theEntries, theTransactionStopWatch); } + /** + * Given a token parameter, build the query predicate based on its hash. Uses system and value if both are available, otherwise just value. + * If neither are available, it returns null. + */ + @Nullable + private Predicate buildHashPredicateFromTokenParam(TokenParam theTokenParam, RequestPartitionId theRequestPartitionId, CriteriaBuilder cb, Root from, MatchUrlToResolve theMatchUrl) { + Predicate hashPredicate = null; + if (isNotBlank(theTokenParam.getValue()) && isNotBlank(theTokenParam.getSystem())) { + theMatchUrl.myHashSystemAndValue = ResourceIndexedSearchParamToken.calculateHashSystemAndValue(myPartitionSettings, theRequestPartitionId, theMatchUrl.myResourceDefinition.getName(), theMatchUrl.myMatchUrlSearchMap.keySet().iterator().next(), theTokenParam.getSystem(), theTokenParam.getValue()); + hashPredicate = cb.equal(from.get("myHashSystemAndValue").as(Long.class), theMatchUrl.myHashSystemAndValue); + } else if (isNotBlank(theTokenParam.getValue())) { + theMatchUrl.myHashValue = ResourceIndexedSearchParamToken.calculateHashValue(myPartitionSettings, theRequestPartitionId, theMatchUrl.myResourceDefinition.getName(), theMatchUrl.myMatchUrlSearchMap.keySet().iterator().next(), theTokenParam.getValue()); + hashPredicate = cb.equal(from.get("myHashValue").as(Long.class), theMatchUrl.myHashValue); + } + return hashPredicate; + } + + private Map buildHashToSearchMap(List searchParameterMapsToResolve) { + Map hashToSearch = new HashMap<>(); + //Build a lookup map so we don't have to iterate over the searches repeatedly. + for (MatchUrlToResolve nextSearchParameterMap : searchParameterMapsToResolve) { + if (nextSearchParameterMap.myHashSystemAndValue != null) { + hashToSearch.put(nextSearchParameterMap.myHashSystemAndValue, nextSearchParameterMap); + } + if (nextSearchParameterMap.myHashValue!= null) { + hashToSearch.put(nextSearchParameterMap.myHashValue, nextSearchParameterMap); + } + } + return hashToSearch; + } + + private void setSearchToResolvedAndPrefetchFoundResourcePid(TransactionDetails theTransactionDetails, List idsToPreFetch, ResourceIndexedSearchParamToken nextResult, MatchUrlToResolve nextSearchParameterMap) { + ourLog.warn("Matched url {} from database", nextSearchParameterMap.myRequestUrl); + idsToPreFetch.add(nextResult.getResourcePid()); + myMatchResourceUrlService.matchUrlResolved(theTransactionDetails, nextSearchParameterMap.myResourceDefinition.getName(), nextSearchParameterMap.myRequestUrl, new ResourcePersistentId(nextResult.getResourcePid())); + theTransactionDetails.addResolvedMatchUrl(nextSearchParameterMap.myRequestUrl, new ResourcePersistentId(nextResult.getResourcePid())); + nextSearchParameterMap.setResolved(true); + } + private List preFetchIndexes(List ids, String typeDesc, String fieldName) { TypedQuery query = myEntityManager.createQuery("FROM ResourceTable r LEFT JOIN FETCH r." + fieldName + " WHERE r.myId IN ( :IDS )", ResourceTable.class); query.setParameter("IDS", ids); @@ -379,5 +403,8 @@ public class TransactionProcessor extends BaseTransactionProcessor { myMatchUrlSearchMap = theMatchUrlSearchMap; myResourceDefinition = theResourceDefinition; } + public void setResolved(boolean theResolved) { + myResolved = theResolved; + } } } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/data/IMdmLinkDao.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/data/IMdmLinkDao.java index 16834facbe2..969ea3926ca 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/data/IMdmLinkDao.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/data/IMdmLinkDao.java @@ -67,4 +67,7 @@ public interface IMdmLinkDao extends JpaRepository { "AND ml.myMatchResult=:matchResult") List expandPidsBySourcePidAndMatchResult(@Param("sourcePid") Long theSourcePid, @Param("matchResult") MdmMatchResultEnum theMdmMatchResultEnum); + @Query("SELECT ml.myGoldenResourcePid as goldenPid, ml.mySourcePid as sourcePid FROM MdmLink ml WHERE ml.myGoldenResourcePid = :goldenPid and ml.myMatchResult = :matchResult") + List expandPidsByGoldenResourcePidAndMatchResult(@Param("goldenPid") Long theSourcePid, @Param("matchResult") MdmMatchResultEnum theMdmMatchResultEnum); + } 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 bc974652bf7..e555909edba 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 @@ -27,16 +27,18 @@ import ca.uhn.fhir.context.support.ValidationSupportContext; import ca.uhn.fhir.jpa.api.dao.IFhirResourceDaoCodeSystem; import ca.uhn.fhir.jpa.dao.BaseHapiFhirResourceDao; import ca.uhn.fhir.jpa.model.cross.IBasePersistedResource; -import ca.uhn.fhir.jpa.term.api.ITermDeferredStorageSvc; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; import ca.uhn.fhir.jpa.model.entity.ResourceTable; -import ca.uhn.fhir.rest.api.server.storage.TransactionDetails; import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; import ca.uhn.fhir.jpa.term.api.ITermCodeSystemStorageSvc; +import ca.uhn.fhir.jpa.term.api.ITermDeferredStorageSvc; import ca.uhn.fhir.jpa.util.LogicUtil; import ca.uhn.fhir.rest.api.server.RequestDetails; +import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.rest.api.server.storage.TransactionDetails; import ca.uhn.fhir.rest.param.TokenParam; import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; +import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_30_40; +import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_40; import org.hl7.fhir.dstu3.model.CodeSystem; import org.hl7.fhir.dstu3.model.CodeableConcept; import org.hl7.fhir.dstu3.model.Coding; @@ -53,7 +55,6 @@ import java.util.List; import java.util.Set; import static org.apache.commons.lang3.StringUtils.isNotBlank; -import static org.hl7.fhir.convertors.conv30_40.CodeSystem30_40.convertCodeSystem; @Transactional public class FhirResourceDaoCodeSystemDstu3 extends BaseHapiFhirResourceDao implements IFhirResourceDaoCodeSystem { @@ -86,10 +87,17 @@ public class FhirResourceDaoCodeSystemDstu3 extends BaseHapiFhirResourceDao theCode, IPrimitiveType theSystem, Coding theCoding, RequestDetails theRequestDetails) { + return lookupCode(theCode, theSystem, theCoding, null, theRequestDetails); + } + + @Nonnull + @Override + public IValidationSupport.LookupCodeResult lookupCode(IPrimitiveType theCode, IPrimitiveType theSystem, Coding theCoding, IPrimitiveType theDisplayLanguage, RequestDetails theRequestDetails) { boolean haveCoding = theCoding != null && isNotBlank(theCoding.getSystem()) && isNotBlank(theCoding.getCode()); boolean haveCode = theCode != null && theCode.isEmpty() == false; boolean haveSystem = theSystem != null && theSystem.isEmpty() == false; - + boolean haveDisplayLanguage = theDisplayLanguage != null && theDisplayLanguage.isEmpty() == false; + if (!haveCoding && !(haveSystem && haveCode)) { throw new InvalidRequestException("No code, coding, or codeableConcept provided to validate"); } @@ -111,11 +119,16 @@ public class FhirResourceDaoCodeSystemDstu3 extends BaseHapiFhirResourceDao theCodeSystemUrl, IPrimitiveType theVersion, IPrimitiveType theCode, - IPrimitiveType theDisplay, Coding theCoding, CodeableConcept theCodeableConcept, RequestDetails theRequestDetails) { + public CodeValidationResult validateCode(IIdType theCodeSystemId, IPrimitiveType theCodeSystemUrl, IPrimitiveType theVersion, IPrimitiveType theCode, + IPrimitiveType theDisplay, Coding theCoding, CodeableConcept theCodeableConcept, RequestDetails theRequestDetails) { throw new UnsupportedOperationException(); } - + } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoConceptMapDstu3.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoConceptMapDstu3.java index 4750d9bb0dc..6ddf296d402 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoConceptMapDstu3.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoConceptMapDstu3.java @@ -20,9 +20,9 @@ package ca.uhn.fhir.jpa.dao.dstu3; * #L% */ +import ca.uhn.fhir.context.support.TranslateConceptResults; import ca.uhn.fhir.jpa.api.dao.IFhirResourceDaoConceptMap; import ca.uhn.fhir.jpa.api.model.TranslationRequest; -import ca.uhn.fhir.context.support.TranslateConceptResults; import ca.uhn.fhir.jpa.dao.BaseHapiFhirResourceDao; import ca.uhn.fhir.jpa.model.cross.IBasePersistedResource; import ca.uhn.fhir.jpa.model.entity.ResourceTable; @@ -30,6 +30,8 @@ import ca.uhn.fhir.jpa.term.api.ITermConceptMappingSvc; import ca.uhn.fhir.rest.api.server.RequestDetails; import ca.uhn.fhir.rest.api.server.storage.TransactionDetails; import ca.uhn.fhir.rest.server.exceptions.InternalErrorException; +import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_30_40; +import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_40; import org.hl7.fhir.dstu3.model.ConceptMap; import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.instance.model.api.IBaseResource; @@ -37,8 +39,6 @@ import org.springframework.beans.factory.annotation.Autowired; import java.util.Date; -import static org.hl7.fhir.convertors.conv30_40.ConceptMap30_40.convertConceptMap; - public class FhirResourceDaoConceptMapDstu3 extends BaseHapiFhirResourceDao implements IFhirResourceDaoConceptMap { @Autowired private ITermConceptMappingSvc myTermConceptMappingSvc; @@ -53,7 +53,6 @@ public class FhirResourceDaoConceptMapDstu3 extends BaseHapiFhirResourceDao implements IFhirResourceDaoValueSet { @@ -54,15 +54,15 @@ public class FhirResourceDaoValueSetDstu3 extends BaseHapiFhirResourceDao expandMdmBySourceResourcePid(Long theSourceResourcePid) { ourLog.debug("About to expand source resource with PID {}", theSourceResourcePid); List goldenPidSourcePidTuples = myMdmLinkDao.expandPidsBySourcePidAndMatchResult(theSourceResourcePid, MdmMatchResultEnum.MATCH); + return flattenPidTuplesToSet(theSourceResourcePid, goldenPidSourcePidTuples); + } + + /** + * Given a PID of a golden resource, perform MDM expansion and return all the resource IDs of all resources that are + * MDM-Matched to this golden resource. + * + * @param theGoldenResourcePid The PID of the golden resource to MDM-Expand. + * @return A set of strings representing the FHIR ids of the expanded resources. + */ + public Set expandMdmByGoldenResourceId(Long theGoldenResourcePid) { + ourLog.debug("About to expand golden resource with PID {}", theGoldenResourcePid); + List goldenPidSourcePidTuples = myMdmLinkDao.expandPidsByGoldenResourcePidAndMatchResult(theGoldenResourcePid, MdmMatchResultEnum.MATCH); + return flattenPidTuplesToSet(theGoldenResourcePid, goldenPidSourcePidTuples); + } + + + /** + * Given a resource ID of a golden resource, perform MDM expansion and return all the resource IDs of all resources that are + * MDM-Matched to this golden resource. + * + * @param theGoldenResourcePid The resource ID of the golden resource to MDM-Expand. + * @return A set of strings representing the FHIR ids of the expanded resources. + */ + public Set expandMdmByGoldenResourcePid(Long theGoldenResourcePid) { + ourLog.debug("About to expand golden resource with PID {}", theGoldenResourcePid); + List goldenPidSourcePidTuples = myMdmLinkDao.expandPidsByGoldenResourcePidAndMatchResult(theGoldenResourcePid, MdmMatchResultEnum.MATCH); + return flattenPidTuplesToSet(theGoldenResourcePid, goldenPidSourcePidTuples); + } + public Set expandMdmByGoldenResourceId(IdDt theId) { + ourLog.debug("About to expand golden resource with golden resource id {}", theId); + Long pidOrThrowException = myIdHelperService.getPidOrThrowException(theId); + return expandMdmByGoldenResourcePid(pidOrThrowException); + } + + @Nonnull + private Set flattenPidTuplesToSet(Long initialPid, List goldenPidSourcePidTuples) { Set flattenedPids = new HashSet<>(); goldenPidSourcePidTuples.forEach(tuple -> { flattenedPids.add(tuple.getSourcePid()); flattenedPids.add(tuple.getGoldenPid()); }); Set resourceIds = myIdHelperService.translatePidsToFhirResourceIds(flattenedPids); - ourLog.debug("Pid {} has been expanded to [{}]", theSourceResourcePid, String.join(",", resourceIds)); + ourLog.debug("Pid {} has been expanded to [{}]", initialPid, String.join(",", resourceIds)); return resourceIds; } - } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoCodeSystemR4.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoCodeSystemR4.java index 5f2aa32a2ec..37ec5745cf4 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoCodeSystemR4.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoCodeSystemR4.java @@ -82,9 +82,16 @@ public class FhirResourceDaoCodeSystemR4 extends BaseHapiFhirResourceDao theCode, IPrimitiveType theSystem, Coding theCoding, RequestDetails theRequestDetails) { + return lookupCode(theCode, theSystem, theCoding, null, theRequestDetails); + } + + @Nonnull + @Override + public IValidationSupport.LookupCodeResult lookupCode(IPrimitiveType theCode, IPrimitiveType theSystem, Coding theCoding, IPrimitiveType theDisplayLanguage, RequestDetails theRequestDetails) { boolean haveCoding = theCoding != null && isNotBlank(theCoding.getSystem()) && isNotBlank(theCoding.getCode()); boolean haveCode = theCode != null && theCode.isEmpty() == false; boolean haveSystem = theSystem != null && theSystem.isEmpty() == false; + boolean haveDisplayLanguage = theDisplayLanguage != null && theDisplayLanguage.isEmpty() == false; if (!haveCoding && !(haveSystem && haveCode)) { throw new InvalidRequestException("No code, coding, or codeableConcept provided to validate"); @@ -107,12 +114,17 @@ public class FhirResourceDaoCodeSystemR4 extends BaseHapiFhirResourceDao implements IFhirResourceDaoCodeSystem { @@ -85,10 +86,17 @@ public class FhirResourceDaoCodeSystemR5 extends BaseHapiFhirResourceDao theCode, IPrimitiveType theSystem, Coding theCoding, RequestDetails theRequestDetails) { + return lookupCode(theCode, theSystem, theCoding, null, theRequestDetails); + } + + @Nonnull + @Override + public IValidationSupport.LookupCodeResult lookupCode(IPrimitiveType theCode, IPrimitiveType theSystem, Coding theCoding, IPrimitiveType theDisplayLanguage, RequestDetails theRequestDetails) { boolean haveCoding = theCoding != null && isNotBlank(theCoding.getSystem()) && isNotBlank(theCoding.getCode()); boolean haveCode = theCode != null && theCode.isEmpty() == false; boolean haveSystem = theSystem != null && theSystem.isEmpty() == false; - + boolean haveDisplayLanguage = theDisplayLanguage != null && theDisplayLanguage.isEmpty() == false; + if (!haveCoding && !(haveSystem && haveCode)) { throw new InvalidRequestException("No code, coding, or codeableConcept provided to validate"); } @@ -110,12 +118,17 @@ public class FhirResourceDaoCodeSystemR5 extends BaseHapiFhirResourceDao @Override public ValueSet expandByIdentifier(String theUri, ValueSetExpansionOptions theOptions) { org.hl7.fhir.r4.model.ValueSet canonicalOutput = myTerminologySvc.expandValueSet(theOptions, theUri); - return ValueSet40_50.convertValueSet(canonicalOutput); + return (ValueSet) VersionConvertorFactory_40_50.convertResource(canonicalOutput, new BaseAdvisor_40_50(false)); } @Override public ValueSet expand(ValueSet theSource, ValueSetExpansionOptions theOptions) { - org.hl7.fhir.r4.model.ValueSet canonicalInput = ValueSet40_50.convertValueSet(theSource); + org.hl7.fhir.r4.model.ValueSet canonicalInput = (org.hl7.fhir.r4.model.ValueSet) VersionConvertorFactory_40_50.convertResource(theSource, new BaseAdvisor_40_50(false)); org.hl7.fhir.r4.model.ValueSet canonicalOutput = myTerminologySvc.expandValueSet(theOptions, canonicalInput); - return ValueSet40_50.convertValueSet(canonicalOutput); + return (ValueSet) VersionConvertorFactory_40_50.convertResource(canonicalOutput, new BaseAdvisor_40_50(false)); } @Override @@ -82,7 +83,7 @@ public class FhirResourceDaoValueSetR5 extends BaseHapiFhirResourceDao if (getConfig().isPreExpandValueSets() && !retVal.isUnchangedInCurrentOperation()) { if (retVal.getDeleted() == null) { ValueSet valueSet = (ValueSet) theResource; - myTerminologySvc.storeTermValueSet(retVal, org.hl7.fhir.convertors.conv40_50.ValueSet40_50.convertValueSet(valueSet)); + myTerminologySvc.storeTermValueSet(retVal, (org.hl7.fhir.r4.model.ValueSet) VersionConvertorFactory_40_50.convertResource(valueSet, new BaseAdvisor_40_50(false))); } else { myTerminologySvc.deleteValueSetAndChildren(retVal); } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/interceptor/MdmSearchExpandingInterceptor.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/interceptor/MdmSearchExpandingInterceptor.java index 4516e342a14..1ec7b3593c9 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/interceptor/MdmSearchExpandingInterceptor.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/interceptor/MdmSearchExpandingInterceptor.java @@ -76,8 +76,16 @@ public class MdmSearchExpandingInterceptor { if (iQueryParameterType instanceof ReferenceParam) { ReferenceParam refParam = (ReferenceParam) iQueryParameterType; if (refParam.isMdmExpand()) { - ourLog.debug("Found a reference parameter to expand: {}", refParam.toString()); + ourLog.debug("Found a reference parameter to expand: {}", refParam); + //First, attempt to expand as a source resource. Set expandedResourceIds = myMdmLinkExpandSvc.expandMdmBySourceResourceId(new IdDt(refParam.getValue())); + + // If we failed, attempt to expand as a golden resource + if (expandedResourceIds.isEmpty()) { + expandedResourceIds = myMdmLinkExpandSvc.expandMdmByGoldenResourceId(new IdDt(refParam.getValue())); + } + + //Rebuild the search param list. if (!expandedResourceIds.isEmpty()) { ourLog.debug("Parameter has been expanded to: {}", String.join(", ", expandedResourceIds)); toRemove.add(refParam); diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/BaseJpaResourceProviderValueSetDstu2.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/BaseJpaResourceProviderValueSetDstu2.java index 75847497200..15dacf5cdb5 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/BaseJpaResourceProviderValueSetDstu2.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/BaseJpaResourceProviderValueSetDstu2.java @@ -112,7 +112,7 @@ public class BaseJpaResourceProviderValueSetDstu2 extends JpaResourceProviderDst startRequest(theServletRequest); try { IFhirResourceDaoCodeSystem dao = (IFhirResourceDaoCodeSystem) getDao(); - IValidationSupport.LookupCodeResult result = dao.lookupCode(theCode, theSystem, theCoding, theRequestDetails); + IValidationSupport.LookupCodeResult result = dao.lookupCode(theCode, theSystem, theCoding, null, theRequestDetails); if (result.isFound() == false) { throw new ResourceNotFoundException("Unable to find code[" + result.getSearchedForCode() + "] in system[" + result.getSearchedForSystem() + "]"); } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/TerminologyUploaderProvider.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/TerminologyUploaderProvider.java index 806ace404ac..b0ce5830e2b 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/TerminologyUploaderProvider.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/TerminologyUploaderProvider.java @@ -40,6 +40,10 @@ import ca.uhn.fhir.util.ValidateUtil; import com.google.common.base.Charsets; import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.Multimap; +import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_30_40; +import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_40_50; +import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_40; +import org.hl7.fhir.convertors.factory.VersionConvertorFactory_40_50; import org.hl7.fhir.instance.model.api.IBaseParameters; import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.instance.model.api.ICompositeType; @@ -58,10 +62,7 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import static org.apache.commons.lang3.StringUtils.isBlank; -import static org.apache.commons.lang3.StringUtils.isNotBlank; -import static org.apache.commons.lang3.StringUtils.trim; -import static org.hl7.fhir.convertors.conv30_40.CodeSystem30_40.convertCodeSystem; +import static org.apache.commons.lang3.StringUtils.*; public class TerminologyUploaderProvider extends BaseJpaProvider { @@ -308,10 +309,10 @@ public class TerminologyUploaderProvider extends BaseJpaProvider { CodeSystem nextCodeSystem; switch (getContext().getVersion().getVersion()) { case DSTU3: - nextCodeSystem = convertCodeSystem((org.hl7.fhir.dstu3.model.CodeSystem) theCodeSystem); + nextCodeSystem = (CodeSystem) VersionConvertorFactory_30_40.convertResource((org.hl7.fhir.dstu3.model.CodeSystem) theCodeSystem, new BaseAdvisor_30_40(false)); break; case R5: - nextCodeSystem = org.hl7.fhir.convertors.conv40_50.CodeSystem40_50.convertCodeSystem((org.hl7.fhir.r5.model.CodeSystem) theCodeSystem); + nextCodeSystem = (CodeSystem) VersionConvertorFactory_40_50.convertResource((org.hl7.fhir.r5.model.CodeSystem) theCodeSystem, new BaseAdvisor_40_50(false)); break; default: nextCodeSystem = (CodeSystem) theCodeSystem; diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/dstu3/BaseJpaResourceProviderCodeSystemDstu3.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/dstu3/BaseJpaResourceProviderCodeSystemDstu3.java index bb0bcc876c5..58729568231 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/dstu3/BaseJpaResourceProviderCodeSystemDstu3.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/dstu3/BaseJpaResourceProviderCodeSystemDstu3.java @@ -53,7 +53,8 @@ public class BaseJpaResourceProviderCodeSystemDstu3 extends JpaResourceProviderD @OperationParam(name = "code", min = 0, max = 1) CodeType theCode, @OperationParam(name = "system", min = 0, max = 1) UriType theSystem, @OperationParam(name = "coding", min = 0, max = 1) Coding theCoding, - @OperationParam(name="version", min=0, max=1) StringType theVersion, + @OperationParam(name = "version", min=0, max=1) StringType theVersion, + @OperationParam(name = "displayLanguage", min=0, max=1) CodeType theDisplayLanguage, @OperationParam(name = "property", min = 0, max = OperationParam.MAX_UNLIMITED) List theProperties, RequestDetails theRequestDetails ) { @@ -63,9 +64,9 @@ public class BaseJpaResourceProviderCodeSystemDstu3 extends JpaResourceProviderD IFhirResourceDaoCodeSystem dao = (IFhirResourceDaoCodeSystem) getDao(); IValidationSupport.LookupCodeResult result; if (theVersion != null) { - result = dao.lookupCode(theCode, new UriType(theSystem.getValue() + "|" + theVersion), theCoding, theRequestDetails); + result = dao.lookupCode(theCode, new UriType(theSystem.getValue() + "|" + theVersion), theCoding, theDisplayLanguage, theRequestDetails); } else { - result = dao.lookupCode(theCode, theSystem, theCoding, theRequestDetails); + result = dao.lookupCode(theCode, theSystem, theCoding, theDisplayLanguage, theRequestDetails); } result.throwNotFoundIfAppropriate(); return (Parameters) result.toParameters(theRequestDetails.getFhirContext(), theProperties); diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/dstu3/BaseJpaResourceProviderConceptMapDstu3.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/dstu3/BaseJpaResourceProviderConceptMapDstu3.java index dd7f18e713b..1627544a315 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/dstu3/BaseJpaResourceProviderConceptMapDstu3.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/dstu3/BaseJpaResourceProviderConceptMapDstu3.java @@ -20,9 +20,9 @@ package ca.uhn.fhir.jpa.provider.dstu3; * #L% */ +import ca.uhn.fhir.context.support.TranslateConceptResults; import ca.uhn.fhir.jpa.api.dao.IFhirResourceDaoConceptMap; import ca.uhn.fhir.jpa.api.model.TranslationRequest; -import ca.uhn.fhir.context.support.TranslateConceptResults; import ca.uhn.fhir.jpa.model.util.JpaConstants; import ca.uhn.fhir.jpa.term.TermConceptMappingSvcImpl; import ca.uhn.fhir.rest.annotation.IdParam; @@ -31,7 +31,8 @@ import ca.uhn.fhir.rest.annotation.OperationParam; import ca.uhn.fhir.rest.api.server.RequestDetails; import ca.uhn.fhir.rest.server.exceptions.InternalErrorException; import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; -import org.hl7.fhir.convertors.VersionConvertor_30_40; +import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_30_40; +import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_40; import org.hl7.fhir.dstu3.model.BooleanType; import org.hl7.fhir.dstu3.model.CodeType; import org.hl7.fhir.dstu3.model.CodeableConcept; @@ -45,8 +46,6 @@ import org.hl7.fhir.exceptions.FHIRException; import javax.servlet.http.HttpServletRequest; -import static org.hl7.fhir.convertors.conv30_40.Parameters30_40.convertParameters; - public class BaseJpaResourceProviderConceptMapDstu3 extends JpaResourceProviderDstu3 { @Operation(name = JpaConstants.OPERATION_TRANSLATE, idempotent = true, returnParameters = { @OperationParam(name = "result", type = BooleanType.class, min = 1, max = 1), @@ -82,7 +81,7 @@ public class BaseJpaResourceProviderConceptMapDstu3 extends JpaResourceProviderD && theSourceValueSet.hasValue(); boolean haveSourceCoding = theSourceCoding != null && theSourceCoding.hasCode(); - boolean haveSourceCodeableConcept= theSourceCodeableConcept != null + boolean haveSourceCodeableConcept = theSourceCodeableConcept != null && theSourceCodeableConcept.hasCoding() && theSourceCodeableConcept.getCodingFirstRep().hasCode(); boolean haveTargetValueSet = theTargetValueSet != null @@ -100,46 +99,46 @@ public class BaseJpaResourceProviderConceptMapDstu3 extends JpaResourceProviderD TranslationRequest translationRequest = new TranslationRequest(); try { - + if (haveUrl) { - translationRequest.setUrl(VersionConvertor_30_40.convertUri(theUrl)); + translationRequest.setUrl((org.hl7.fhir.r4.model.UriType) VersionConvertorFactory_30_40.convertType(theUrl, new BaseAdvisor_30_40(false))); } - + if (haveConceptMapVersion) { - translationRequest.setConceptMapVersion(VersionConvertor_30_40.convertString(theConceptMapVersion)); + translationRequest.setConceptMapVersion((org.hl7.fhir.r4.model.StringType) VersionConvertorFactory_30_40.convertType(theConceptMapVersion, new BaseAdvisor_30_40(false))); } - + // Convert from DSTU3 to R4 if (haveSourceCode) { - translationRequest.getCodeableConcept().addCoding().setCodeElement(VersionConvertor_30_40.convertCode(theSourceCode)); + translationRequest.getCodeableConcept().addCoding().setCodeElement((org.hl7.fhir.r4.model.CodeType) VersionConvertorFactory_30_40.convertType(theSourceCode, new BaseAdvisor_30_40(false))); if (haveSourceCodeSystem) { - translationRequest.getCodeableConcept().getCodingFirstRep().setSystemElement(VersionConvertor_30_40.convertUri(theSourceCodeSystem)); + translationRequest.getCodeableConcept().getCodingFirstRep().setSystemElement((org.hl7.fhir.r4.model.UriType) VersionConvertorFactory_30_40.convertType(theSourceCodeSystem, new BaseAdvisor_30_40(false))); } if (haveSourceCodeSystemVersion) { - translationRequest.getCodeableConcept().getCodingFirstRep().setVersionElement(VersionConvertor_30_40.convertString(theSourceCodeSystemVersion)); + translationRequest.getCodeableConcept().getCodingFirstRep().setVersionElement((org.hl7.fhir.r4.model.StringType) VersionConvertorFactory_30_40.convertType(theSourceCodeSystemVersion, new BaseAdvisor_30_40(false))); } } else if (haveSourceCoding) { - translationRequest.getCodeableConcept().addCoding(VersionConvertor_30_40.convertCoding(theSourceCoding)); + translationRequest.getCodeableConcept().addCoding((org.hl7.fhir.r4.model.Coding) VersionConvertorFactory_30_40.convertType(theSourceCoding, new BaseAdvisor_30_40(false))); } else { - translationRequest.setCodeableConcept(VersionConvertor_30_40.convertCodeableConcept(theSourceCodeableConcept)); + translationRequest.setCodeableConcept((org.hl7.fhir.r4.model.CodeableConcept) VersionConvertorFactory_30_40.convertType(theSourceCodeableConcept, new BaseAdvisor_30_40(false))); } if (haveSourceValueSet) { - translationRequest.setSource(VersionConvertor_30_40.convertUri(theSourceValueSet)); + translationRequest.setSource((org.hl7.fhir.r4.model.UriType) VersionConvertorFactory_30_40.convertType(theSourceValueSet, new BaseAdvisor_30_40(false))); } if (haveTargetValueSet) { - translationRequest.setTarget(VersionConvertor_30_40.convertUri(theTargetValueSet)); + translationRequest.setTarget((org.hl7.fhir.r4.model.UriType) VersionConvertorFactory_30_40.convertType(theTargetValueSet, new BaseAdvisor_30_40(false))); } if (haveTargetCodeSystem) { - translationRequest.setTargetSystem(VersionConvertor_30_40.convertUri(theTargetCodeSystem)); + translationRequest.setTargetSystem((org.hl7.fhir.r4.model.UriType) VersionConvertorFactory_30_40.convertType(theTargetCodeSystem, new BaseAdvisor_30_40(false))); } if (haveReverse) { - translationRequest.setReverse(VersionConvertor_30_40.convertBoolean(theReverse)); + translationRequest.setReverse((org.hl7.fhir.r4.model.BooleanType) VersionConvertorFactory_30_40.convertType(theReverse, new BaseAdvisor_30_40(false))); } if (haveId) { @@ -155,7 +154,7 @@ public class BaseJpaResourceProviderConceptMapDstu3 extends JpaResourceProviderD TranslateConceptResults result = dao.translate(translationRequest, theRequestDetails); // Convert from R4 to DSTU3 - return convertParameters(TermConceptMappingSvcImpl.toParameters(result)); + return (Parameters) VersionConvertorFactory_30_40.convertResource(TermConceptMappingSvcImpl.toParameters(result), new BaseAdvisor_30_40(false)); } catch (FHIRException fe) { throw new InternalErrorException(fe); } finally { diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/dstu3/JpaResourceProviderDstu3.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/dstu3/JpaResourceProviderDstu3.java index cc96142c495..b9c118d3de8 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/dstu3/JpaResourceProviderDstu3.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/dstu3/JpaResourceProviderDstu3.java @@ -24,8 +24,6 @@ import ca.uhn.fhir.jpa.api.dao.IFhirResourceDao; import ca.uhn.fhir.jpa.provider.BaseJpaResourceProvider; import org.hl7.fhir.instance.model.api.IAnyResource; -import static org.hl7.fhir.convertors.conv30_40.Parameters30_40.convertParameters; - public class JpaResourceProviderDstu3 extends BaseJpaResourceProvider { public JpaResourceProviderDstu3() { diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/dstu3/JpaSystemProviderDstu3.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/dstu3/JpaSystemProviderDstu3.java index e622c3d82dc..3a18e6c6da9 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/dstu3/JpaSystemProviderDstu3.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/dstu3/JpaSystemProviderDstu3.java @@ -24,7 +24,6 @@ import java.util.Map.Entry; import java.util.TreeMap; import static org.apache.commons.lang3.ObjectUtils.defaultIfNull; -import static org.hl7.fhir.convertors.conv30_40.Parameters30_40.convertParameters; /* * #%L diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/r4/BaseJpaResourceProviderCodeSystemR4.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/r4/BaseJpaResourceProviderCodeSystemR4.java index 5c237f7a459..f625387b47e 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/r4/BaseJpaResourceProviderCodeSystemR4.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/r4/BaseJpaResourceProviderCodeSystemR4.java @@ -61,7 +61,8 @@ public class BaseJpaResourceProviderCodeSystemR4 extends JpaResourceProviderR4 theProperties, + @OperationParam(name="displayLanguage", min=0, max=1) CodeType theDisplayLanguage, + @OperationParam(name="property", min = 0, max = OperationParam.MAX_UNLIMITED) List theProperties, RequestDetails theRequestDetails ) { @@ -70,9 +71,9 @@ public class BaseJpaResourceProviderCodeSystemR4 extends JpaResourceProviderR4 dao = (IFhirResourceDaoCodeSystem) getDao(); IValidationSupport.LookupCodeResult result; if (theVersion != null) { - result = dao.lookupCode(theCode, new UriType(theSystem.getValue() + "|" + theVersion), theCoding, theRequestDetails); + result = dao.lookupCode(theCode, new UriType(theSystem.getValue() + "|" + theVersion), theCoding, theDisplayLanguage, theRequestDetails); } else { - result = dao.lookupCode(theCode, theSystem, theCoding, theRequestDetails); + result = dao.lookupCode(theCode, theSystem, theCoding, theDisplayLanguage, theRequestDetails); } result.throwNotFoundIfAppropriate(); return (Parameters) result.toParameters(theRequestDetails.getFhirContext(), theProperties); diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/r5/BaseJpaResourceProviderCodeSystemR5.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/r5/BaseJpaResourceProviderCodeSystemR5.java index 99a566b5cde..0fce1e5d319 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/r5/BaseJpaResourceProviderCodeSystemR5.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/r5/BaseJpaResourceProviderCodeSystemR5.java @@ -60,6 +60,7 @@ public class BaseJpaResourceProviderCodeSystemR5 extends JpaResourceProviderR5 theProperties, RequestDetails theRequestDetails ) { @@ -69,9 +70,9 @@ public class BaseJpaResourceProviderCodeSystemR5 extends JpaResourceProviderR5 dao = (IFhirResourceDaoCodeSystem) getDao(); IValidationSupport.LookupCodeResult result; if (theVersion != null) { - result = dao.lookupCode(theCode, new UriType(theSystem.getValue() + "|" + theVersion), theCoding, theRequestDetails); + result = dao.lookupCode(theCode, new UriType(theSystem.getValue() + "|" + theVersion), theCoding, theDisplayLanguage, theRequestDetails); } else { - result = dao.lookupCode(theCode, theSystem, theCoding, theRequestDetails); + result = dao.lookupCode(theCode, theSystem, theCoding, theDisplayLanguage, theRequestDetails); } result.throwNotFoundIfAppropriate(); return (Parameters) result.toParameters(theRequestDetails.getFhirContext(), theProperties); diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/r5/BaseJpaResourceProviderConceptMapR5.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/r5/BaseJpaResourceProviderConceptMapR5.java index 4e80fe87662..b7cd93d5fd9 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/r5/BaseJpaResourceProviderConceptMapR5.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/r5/BaseJpaResourceProviderConceptMapR5.java @@ -20,9 +20,9 @@ package ca.uhn.fhir.jpa.provider.r5; * #L% */ +import ca.uhn.fhir.context.support.TranslateConceptResults; import ca.uhn.fhir.jpa.api.dao.IFhirResourceDaoConceptMap; import ca.uhn.fhir.jpa.api.model.TranslationRequest; -import ca.uhn.fhir.context.support.TranslateConceptResults; import ca.uhn.fhir.jpa.model.util.JpaConstants; import ca.uhn.fhir.jpa.term.TermConceptMappingSvcImpl; import ca.uhn.fhir.rest.annotation.IdParam; @@ -30,7 +30,8 @@ import ca.uhn.fhir.rest.annotation.Operation; import ca.uhn.fhir.rest.annotation.OperationParam; import ca.uhn.fhir.rest.api.server.RequestDetails; import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; -import org.hl7.fhir.convertors.VersionConvertor_40_50; +import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_40_50; +import org.hl7.fhir.convertors.factory.VersionConvertorFactory_40_50; import org.hl7.fhir.r5.model.BooleanType; import org.hl7.fhir.r5.model.CodeType; import org.hl7.fhir.r5.model.CodeableConcept; @@ -52,7 +53,7 @@ public class BaseJpaResourceProviderConceptMapR5 extends JpaResourceProviderR5 dao = (IFhirResourceDaoConceptMap) getDao(); TranslateConceptResults result = dao.translate(translationRequest, theRequestDetails); org.hl7.fhir.r4.model.Parameters parameters = TermConceptMappingSvcImpl.toParameters(result); - return org.hl7.fhir.convertors.conv40_50.Parameters40_50.convertParameters(parameters); + return (Parameters) VersionConvertorFactory_40_50.convertResource(parameters, new BaseAdvisor_40_50(false)); } finally { endRequest(theServletRequest); } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/reindex/ResourceReindexingSvcImpl.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/reindex/ResourceReindexingSvcImpl.java index 124a0a50c90..8f9c583ce23 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/reindex/ResourceReindexingSvcImpl.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/reindex/ResourceReindexingSvcImpl.java @@ -42,7 +42,7 @@ import org.apache.commons.lang3.Validate; import org.apache.commons.lang3.concurrent.BasicThreadFactory; import org.apache.commons.lang3.time.DateUtils; import org.hl7.fhir.r4.model.InstantType; -import org.jetbrains.annotations.Nullable; +import javax.annotation.Nullable; import org.quartz.JobExecutionContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/BaseTermReadSvcImpl.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/BaseTermReadSvcImpl.java index 125fbe191c9..3c79196b2ef 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/BaseTermReadSvcImpl.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/BaseTermReadSvcImpl.java @@ -1989,7 +1989,7 @@ public abstract class BaseTermReadSvcImpl implements ITermReadSvc { protected abstract ValueSet toCanonicalValueSet(IBaseResource theValueSet); - protected IValidationSupport.LookupCodeResult lookupCode(String theSystem, String theCode) { + protected IValidationSupport.LookupCodeResult lookupCode(String theSystem, String theCode, String theDisplayLanguage) { TransactionTemplate txTemplate = new TransactionTemplate(myTransactionManager); return txTemplate.execute(t -> { Optional codeOpt = findCode(theSystem, theCode); @@ -2006,12 +2006,15 @@ public abstract class BaseTermReadSvcImpl implements ITermReadSvc { for (TermConceptDesignation next : code.getDesignations()) { IValidationSupport.ConceptDesignation designation = new IValidationSupport.ConceptDesignation(); - designation.setLanguage(next.getLanguage()); - designation.setUseSystem(next.getUseSystem()); - designation.setUseCode(next.getUseCode()); - designation.setUseDisplay(next.getUseDisplay()); - designation.setValue(next.getValue()); - result.getDesignations().add(designation); + // filter out the designation based on displayLanguage if any + if (isDisplayLanguageMatch(theDisplayLanguage, next.getLanguage())) { + designation.setLanguage(next.getLanguage()); + designation.setUseSystem(next.getUseSystem()); + designation.setUseCode(next.getUseCode()); + designation.setUseDisplay(next.getUseDisplay()); + designation.setValue(next.getValue()); + result.getDesignations().add(designation); + } } for (TermConceptProperty next : code.getProperties()) { @@ -2034,6 +2037,7 @@ public abstract class BaseTermReadSvcImpl implements ITermReadSvc { }); } + @Nullable private ConceptSubsumptionOutcome testForSubsumption(SearchSession theSearchSession, TermConcept theLeft, TermConcept theRight, ConceptSubsumptionOutcome theOutput) { List fetch = theSearchSession.search(TermConcept.class) @@ -2481,4 +2485,11 @@ public abstract class BaseTermReadSvcImpl implements ITermReadSvc { return termConcept; } + static boolean isDisplayLanguageMatch(String theReqLang, String theStoredLang) { + // NOTE: return the designation when one of then is not specified. + if (theReqLang == null || theStoredLang == null) + return true; + + return theReqLang.equalsIgnoreCase(theStoredLang); + } } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/TermReadSvcDstu3.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/TermReadSvcDstu3.java index 5ed129c071e..5c26ce861c6 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/TermReadSvcDstu3.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/TermReadSvcDstu3.java @@ -9,8 +9,8 @@ import ca.uhn.fhir.jpa.model.entity.ResourceTable; import ca.uhn.fhir.jpa.term.api.ITermReadSvcDstu3; import ca.uhn.fhir.rest.server.exceptions.InternalErrorException; import ca.uhn.fhir.util.ValidateUtil; -import org.hl7.fhir.convertors.VersionConvertor_30_40; -import org.hl7.fhir.convertors.conv30_40.CodeSystem30_40; +import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_30_40; +import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_40; import org.hl7.fhir.dstu3.model.CodeSystem; import org.hl7.fhir.dstu3.model.CodeableConcept; import org.hl7.fhir.dstu3.model.Coding; @@ -25,8 +25,6 @@ import org.springframework.transaction.PlatformTransactionManager; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import static org.hl7.fhir.convertors.conv30_40.ValueSet30_40.convertValueSet; - /* * #%L * HAPI FHIR JPA Server @@ -67,7 +65,7 @@ public class TermReadSvcDstu3 extends BaseTermReadSvcImpl implements IValidation org.hl7.fhir.r4.model.ValueSet valueSetToExpandR4; valueSetToExpandR4 = toCanonicalValueSet(theValueSetToExpand); org.hl7.fhir.r4.model.ValueSet expandedR4 = super.expandValueSet(theExpansionOptions, valueSetToExpandR4); - return new ValueSetExpansionOutcome(convertValueSet(expandedR4), null); + return new ValueSetExpansionOutcome(VersionConvertorFactory_30_40.convertResource(expandedR4, new BaseAdvisor_30_40(false)), null); } catch (FHIRException e) { throw new InternalErrorException(e); } @@ -81,7 +79,7 @@ public class TermReadSvcDstu3 extends BaseTermReadSvcImpl implements IValidation org.hl7.fhir.r4.model.ValueSet valueSetToExpandR4; valueSetToExpandR4 = toCanonicalValueSet(valueSetToExpand); org.hl7.fhir.r4.model.ValueSet expandedR4 = super.expandValueSet(theExpansionOptions, valueSetToExpandR4); - return convertValueSet(expandedR4); + return VersionConvertorFactory_30_40.convertResource(expandedR4, new BaseAdvisor_30_40(false)); } catch (FHIRException e) { throw new InternalErrorException(e); } @@ -90,31 +88,31 @@ public class TermReadSvcDstu3 extends BaseTermReadSvcImpl implements IValidation @Override protected org.hl7.fhir.r4.model.ValueSet toCanonicalValueSet(IBaseResource theValueSet) throws FHIRException { org.hl7.fhir.r4.model.ValueSet valueSetToExpandR4; - valueSetToExpandR4 = convertValueSet((ValueSet) theValueSet); + valueSetToExpandR4 = (org.hl7.fhir.r4.model.ValueSet) VersionConvertorFactory_30_40.convertResource((ValueSet) theValueSet, new BaseAdvisor_30_40(false)); return valueSetToExpandR4; } @Override protected org.hl7.fhir.r4.model.CodeSystem toCanonicalCodeSystem(IBaseResource theCodeSystem) { - return CodeSystem30_40.convertCodeSystem((CodeSystem)theCodeSystem); + return (org.hl7.fhir.r4.model.CodeSystem) VersionConvertorFactory_30_40.convertResource((CodeSystem)theCodeSystem, new BaseAdvisor_30_40(false)); } @Override @Nullable protected org.hl7.fhir.r4.model.Coding toCanonicalCoding(IBaseDatatype theCoding) { - return VersionConvertor_30_40.convertCoding((org.hl7.fhir.dstu3.model.Coding) theCoding); + return (org.hl7.fhir.r4.model.Coding) VersionConvertorFactory_30_40.convertType((Coding) theCoding, new BaseAdvisor_30_40(false)); } @Override @Nullable protected org.hl7.fhir.r4.model.Coding toCanonicalCoding(IBaseCoding theCoding) { - return VersionConvertor_30_40.convertCoding((org.hl7.fhir.dstu3.model.Coding) theCoding); + return (org.hl7.fhir.r4.model.Coding) VersionConvertorFactory_30_40.convertType((org.hl7.fhir.dstu3.model.Coding) theCoding, new BaseAdvisor_30_40(false)); } @Override @Nullable protected org.hl7.fhir.r4.model.CodeableConcept toCanonicalCodeableConcept(IBaseDatatype theCoding) { - return VersionConvertor_30_40.convertCodeableConcept((org.hl7.fhir.dstu3.model.CodeableConcept) theCoding); + return (org.hl7.fhir.r4.model.CodeableConcept) VersionConvertorFactory_30_40.convertType((CodeableConcept) theCoding, new BaseAdvisor_30_40(false)); } @@ -147,8 +145,8 @@ public class TermReadSvcDstu3 extends BaseTermReadSvcImpl implements IValidation } @Override - public LookupCodeResult lookupCode(ValidationSupportContext theValidationSupportContext, String theSystem, String theCode) { - return super.lookupCode(theSystem, theCode); + public LookupCodeResult lookupCode(ValidationSupportContext theValidationSupportContext, String theSystem, String theCode, String theDisplayLanguage) { + return super.lookupCode(theSystem, theCode, theDisplayLanguage); } @Override @@ -160,7 +158,7 @@ public class TermReadSvcDstu3 extends BaseTermReadSvcImpl implements IValidation public IValidationSupport.CodeValidationResult validateCodeIsInPreExpandedValueSet(ConceptValidationOptions theOptions, IBaseResource theValueSet, String theSystem, String theCode, String theDisplay, IBaseDatatype theCoding, IBaseDatatype theCodeableConcept) { ValidateUtil.isNotNullOrThrowUnprocessableEntity(theValueSet, "ValueSet must not be null"); ValueSet valueSet = (ValueSet) theValueSet; - org.hl7.fhir.r4.model.ValueSet valueSetR4 = convertValueSet(valueSet); + org.hl7.fhir.r4.model.ValueSet valueSetR4 = (org.hl7.fhir.r4.model.ValueSet) VersionConvertorFactory_30_40.convertResource(valueSet, new BaseAdvisor_30_40(false)); Coding coding = (Coding) theCoding; org.hl7.fhir.r4.model.Coding codingR4 = null; @@ -184,7 +182,7 @@ public class TermReadSvcDstu3 extends BaseTermReadSvcImpl implements IValidation public boolean isValueSetPreExpandedForCodeValidation(IBaseResource theValueSet) { ValidateUtil.isNotNullOrThrowUnprocessableEntity(theValueSet, "ValueSet must not be null"); ValueSet valueSet = (ValueSet) theValueSet; - org.hl7.fhir.r4.model.ValueSet valueSetR4 = convertValueSet(valueSet); + org.hl7.fhir.r4.model.ValueSet valueSetR4 = (org.hl7.fhir.r4.model.ValueSet) VersionConvertorFactory_30_40.convertResource(valueSet, new BaseAdvisor_30_40(false)); return super.isValueSetPreExpandedForCodeValidation(valueSetR4); } } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/TermReadSvcR4.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/TermReadSvcR4.java index 576669c0ecc..51a55161972 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/TermReadSvcR4.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/TermReadSvcR4.java @@ -92,8 +92,8 @@ public class TermReadSvcR4 extends BaseTermReadSvcImpl implements ITermReadSvcR4 } @Override - public LookupCodeResult lookupCode(ValidationSupportContext theValidationSupportContext, String theSystem, String theCode) { - return super.lookupCode(theSystem, theCode); + public LookupCodeResult lookupCode(ValidationSupportContext theValidationSupportContext, String theSystem, String theCode, String theDisplayLanguage) { + return super.lookupCode(theSystem, theCode, theDisplayLanguage); } @Override diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/TermReadSvcR5.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/TermReadSvcR5.java index 5c2f7c08d86..5d7686336ac 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/TermReadSvcR5.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/TermReadSvcR5.java @@ -10,8 +10,8 @@ import ca.uhn.fhir.jpa.model.entity.ResourceTable; import ca.uhn.fhir.jpa.term.api.ITermReadSvcR5; import ca.uhn.fhir.jpa.term.ex.ExpansionTooCostlyException; import ca.uhn.fhir.util.ValidateUtil; -import org.hl7.fhir.convertors.VersionConvertor_40_50; -import org.hl7.fhir.convertors.conv40_50.CodeSystem40_50; +import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_40_50; +import org.hl7.fhir.convertors.factory.VersionConvertorFactory_40_50; import org.hl7.fhir.instance.model.api.IBaseCoding; import org.hl7.fhir.instance.model.api.IBaseDatatype; import org.hl7.fhir.instance.model.api.IBaseResource; @@ -19,8 +19,6 @@ import org.hl7.fhir.r5.model.CodeSystem; import org.hl7.fhir.r5.model.CodeableConcept; import org.hl7.fhir.r5.model.Coding; import org.hl7.fhir.r5.model.ValueSet; -import org.hl7.fhir.utilities.TerminologyServiceOptions; -import org.hl7.fhir.utilities.validation.ValidationOptions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.PlatformTransactionManager; @@ -59,15 +57,16 @@ public class TermReadSvcR5 extends BaseTermReadSvcImpl implements IValidationSup @Transactional(dontRollbackOn = {ExpansionTooCostlyException.class}) public ValueSetExpansionOutcome expandValueSet(ValidationSupportContext theValidationSupportContext, ValueSetExpansionOptions theExpansionOptions, @Nonnull IBaseResource theValueSetToExpand) { ValueSet valueSetToExpand = (ValueSet) theValueSetToExpand; - org.hl7.fhir.r4.model.ValueSet expandedR4 = super.expandValueSet(theExpansionOptions, org.hl7.fhir.convertors.conv40_50.ValueSet40_50.convertValueSet(valueSetToExpand)); - return new ValueSetExpansionOutcome(org.hl7.fhir.convertors.conv40_50.ValueSet40_50.convertValueSet(expandedR4)); + org.hl7.fhir.r4.model.ValueSet expandedR4 = super.expandValueSet(theExpansionOptions, + (org.hl7.fhir.r4.model.ValueSet) VersionConvertorFactory_40_50.convertResource(valueSetToExpand, new BaseAdvisor_40_50(false))); + return new ValueSetExpansionOutcome(VersionConvertorFactory_40_50.convertResource(expandedR4, new BaseAdvisor_40_50(false))); } @Override public IBaseResource expandValueSet(ValueSetExpansionOptions theExpansionOptions, IBaseResource theInput) { org.hl7.fhir.r4.model.ValueSet valueSetToExpand = toCanonicalValueSet(theInput); org.hl7.fhir.r4.model.ValueSet valueSetR4 = super.expandValueSet(theExpansionOptions, valueSetToExpand); - return org.hl7.fhir.convertors.conv40_50.ValueSet40_50.convertValueSet(valueSetR4); + return VersionConvertorFactory_40_50.convertResource(valueSetR4, new BaseAdvisor_40_50(false)); } @Override @@ -79,7 +78,7 @@ public class TermReadSvcR5 extends BaseTermReadSvcImpl implements IValidationSup @Override protected org.hl7.fhir.r4.model.ValueSet getValueSetFromResourceTable(ResourceTable theResourceTable) { ValueSet valueSetR5 = myDaoRegistry.getResourceDao("ValueSet").toResource(ValueSet.class, theResourceTable, null, false); - return org.hl7.fhir.convertors.conv40_50.ValueSet40_50.convertValueSet(valueSetR5); + return (org.hl7.fhir.r4.model.ValueSet) VersionConvertorFactory_40_50.convertResource(valueSetR5, new BaseAdvisor_40_50(false)); } @Override @@ -110,30 +109,30 @@ public class TermReadSvcR5 extends BaseTermReadSvcImpl implements IValidationSup @Override @Nullable protected org.hl7.fhir.r4.model.Coding toCanonicalCoding(IBaseDatatype theCoding) { - return VersionConvertor_40_50.convertCoding((Coding) theCoding); + return (org.hl7.fhir.r4.model.Coding) VersionConvertorFactory_40_50.convertType((Coding) theCoding, new BaseAdvisor_40_50(false)); } @Override @Nullable protected org.hl7.fhir.r4.model.Coding toCanonicalCoding(IBaseCoding theCoding) { - return VersionConvertor_40_50.convertCoding((Coding) theCoding); + return (org.hl7.fhir.r4.model.Coding) VersionConvertorFactory_40_50.convertType((Coding) theCoding, new BaseAdvisor_40_50(false)); } @Override @Nullable protected org.hl7.fhir.r4.model.CodeableConcept toCanonicalCodeableConcept(IBaseDatatype theCoding) { - return VersionConvertor_40_50.convertCodeableConcept((CodeableConcept) theCoding); + return (org.hl7.fhir.r4.model.CodeableConcept) VersionConvertorFactory_40_50.convertType((CodeableConcept) theCoding, new BaseAdvisor_40_50(false)); } @Override protected org.hl7.fhir.r4.model.ValueSet toCanonicalValueSet(IBaseResource theValueSet) throws org.hl7.fhir.exceptions.FHIRException { - return org.hl7.fhir.convertors.conv40_50.ValueSet40_50.convertValueSet((ValueSet) theValueSet); + return (org.hl7.fhir.r4.model.ValueSet) VersionConvertorFactory_40_50.convertResource((ValueSet) theValueSet, new BaseAdvisor_40_50(false)); } @Override protected org.hl7.fhir.r4.model.CodeSystem toCanonicalCodeSystem(IBaseResource theCodeSystem) { - return CodeSystem40_50.convertCodeSystem((CodeSystem) theCodeSystem); + return (org.hl7.fhir.r4.model.CodeSystem) VersionConvertorFactory_40_50.convertResource((CodeSystem) theCodeSystem, new BaseAdvisor_40_50(false)); } @Override @@ -145,8 +144,8 @@ public class TermReadSvcR5 extends BaseTermReadSvcImpl implements IValidationSup } @Override - public LookupCodeResult lookupCode(ValidationSupportContext theValidationSupportContext, String theSystem, String theCode) { - return super.lookupCode(theSystem, theCode); + public LookupCodeResult lookupCode(ValidationSupportContext theValidationSupportContext, String theSystem, String theCode, String theDisplayLanguage) { + return super.lookupCode(theSystem, theCode, theDisplayLanguage); } } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/TermVersionAdapterSvcDstu3.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/TermVersionAdapterSvcDstu3.java index 2933d256a7b..446a5188cfa 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/TermVersionAdapterSvcDstu3.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/TermVersionAdapterSvcDstu3.java @@ -25,6 +25,8 @@ import ca.uhn.fhir.jpa.term.api.ITermVersionAdapterSvc; import ca.uhn.fhir.rest.api.server.RequestDetails; import ca.uhn.fhir.rest.server.exceptions.InternalErrorException; import ca.uhn.fhir.util.UrlUtil; +import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_30_40; +import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_40; import org.hl7.fhir.dstu3.model.CodeSystem; import org.hl7.fhir.dstu3.model.ConceptMap; import org.hl7.fhir.dstu3.model.ValueSet; @@ -36,9 +38,6 @@ import org.springframework.context.event.ContextRefreshedEvent; import org.springframework.context.event.EventListener; import static org.apache.commons.lang3.StringUtils.isBlank; -import static org.hl7.fhir.convertors.conv30_40.CodeSystem30_40.convertCodeSystem; -import static org.hl7.fhir.convertors.conv30_40.ConceptMap30_40.convertConceptMap; -import static org.hl7.fhir.convertors.conv30_40.ValueSet30_40.convertValueSet; public class TermVersionAdapterSvcDstu3 extends BaseTermVersionAdapterSvcImpl implements ITermVersionAdapterSvc { @@ -56,7 +55,7 @@ public class TermVersionAdapterSvcDstu3 extends BaseTermVersionAdapterSvcImpl im /** * Initialize the beans that are used by this service. - * + *

* Note: There is a circular dependency here where the CodeSystem DAO * needs terminology services, and the term services need the CodeSystem DAO. * So we look these up in a refresh event instead of just autowiring them @@ -70,11 +69,11 @@ public class TermVersionAdapterSvcDstu3 extends BaseTermVersionAdapterSvcImpl im myConceptMapResourceDao = (IFhirResourceDao) myAppCtx.getBean("myConceptMapDaoDstu3"); } - @Override + @Override public IIdType createOrUpdateCodeSystem(org.hl7.fhir.r4.model.CodeSystem theCodeSystemResource, RequestDetails theRequestDetails) { CodeSystem resourceToStore; try { - resourceToStore = convertCodeSystem(theCodeSystemResource); + resourceToStore = (CodeSystem) VersionConvertorFactory_30_40.convertResource(theCodeSystemResource, new BaseAdvisor_30_40(false)); } catch (FHIRException e) { throw new InternalErrorException(e); } @@ -91,7 +90,7 @@ public class TermVersionAdapterSvcDstu3 extends BaseTermVersionAdapterSvcImpl im public void createOrUpdateConceptMap(org.hl7.fhir.r4.model.ConceptMap theConceptMap) { ConceptMap resourceToStore; try { - resourceToStore = convertConceptMap(theConceptMap); + resourceToStore = (ConceptMap) VersionConvertorFactory_30_40.convertResource(theConceptMap, new BaseAdvisor_30_40(false)); } catch (FHIRException e) { throw new InternalErrorException(e); } @@ -107,7 +106,7 @@ public class TermVersionAdapterSvcDstu3 extends BaseTermVersionAdapterSvcImpl im public void createOrUpdateValueSet(org.hl7.fhir.r4.model.ValueSet theValueSet) { ValueSet valueSetDstu3; try { - valueSetDstu3 = convertValueSet(theValueSet); + valueSetDstu3 = (ValueSet) VersionConvertorFactory_30_40.convertResource(theValueSet, new BaseAdvisor_30_40(false)); } catch (FHIRException e) { throw new InternalErrorException(e); } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/TermVersionAdapterSvcR5.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/TermVersionAdapterSvcR5.java index f0664b99564..93e96974d27 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/TermVersionAdapterSvcR5.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/TermVersionAdapterSvcR5.java @@ -24,6 +24,8 @@ import ca.uhn.fhir.jpa.api.dao.IFhirResourceDao; import ca.uhn.fhir.jpa.term.api.ITermVersionAdapterSvc; import ca.uhn.fhir.rest.api.server.RequestDetails; import ca.uhn.fhir.util.UrlUtil; +import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_40_50; +import org.hl7.fhir.convertors.factory.VersionConvertorFactory_40_50; import org.hl7.fhir.instance.model.api.IIdType; import org.hl7.fhir.r5.model.CodeSystem; import org.hl7.fhir.r5.model.ConceptMap; @@ -63,7 +65,7 @@ public class TermVersionAdapterSvcR5 extends BaseTermVersionAdapterSvcImpl imple public IIdType createOrUpdateCodeSystem(org.hl7.fhir.r4.model.CodeSystem theCodeSystemResource, RequestDetails theRequestDetails) { validateCodeSystemForStorage(theCodeSystemResource); - CodeSystem codeSystemR4 = org.hl7.fhir.convertors.conv40_50.CodeSystem40_50.convertCodeSystem(theCodeSystemResource); + CodeSystem codeSystemR4 = (CodeSystem) VersionConvertorFactory_40_50.convertResource(theCodeSystemResource, new BaseAdvisor_40_50(false)); if (isBlank(theCodeSystemResource.getIdElement().getIdPart())) { String matchUrl = "CodeSystem?url=" + UrlUtil.escapeUrlParam(theCodeSystemResource.getUrl()); return myCodeSystemResourceDao.update(codeSystemR4, matchUrl, theRequestDetails).getId(); @@ -75,7 +77,7 @@ public class TermVersionAdapterSvcR5 extends BaseTermVersionAdapterSvcImpl imple @Override public void createOrUpdateConceptMap(org.hl7.fhir.r4.model.ConceptMap theConceptMap) { - ConceptMap conceptMapR4 = org.hl7.fhir.convertors.conv40_50.ConceptMap40_50.convertConceptMap(theConceptMap); + ConceptMap conceptMapR4 = (ConceptMap) VersionConvertorFactory_40_50.convertResource(theConceptMap, new BaseAdvisor_40_50(false)); if (isBlank(theConceptMap.getIdElement().getIdPart())) { String matchUrl = "ConceptMap?url=" + UrlUtil.escapeUrlParam(theConceptMap.getUrl()); @@ -88,7 +90,7 @@ public class TermVersionAdapterSvcR5 extends BaseTermVersionAdapterSvcImpl imple @Override public void createOrUpdateValueSet(org.hl7.fhir.r4.model.ValueSet theValueSet) { - ValueSet valueSetR4 = org.hl7.fhir.convertors.conv40_50.ValueSet40_50.convertValueSet(theValueSet); + ValueSet valueSetR4 = (ValueSet) VersionConvertorFactory_40_50.convertResource(theValueSet, new BaseAdvisor_40_50(false)); if (isBlank(theValueSet.getIdElement().getIdPart())) { String matchUrl = "ValueSet?url=" + UrlUtil.escapeUrlParam(theValueSet.getUrl()); diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/validation/ValidatorResourceFetcher.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/validation/ValidatorResourceFetcher.java index d10ad96f738..290adfab468 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/validation/ValidatorResourceFetcher.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/validation/ValidatorResourceFetcher.java @@ -27,7 +27,9 @@ import ca.uhn.fhir.jpa.api.dao.IFhirResourceDao; import ca.uhn.fhir.rest.api.server.RequestDetails; import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; import org.hl7.fhir.common.hapi.validation.validator.VersionSpecificWorkerContextWrapper; +import org.hl7.fhir.exceptions.DefinitionException; import org.hl7.fhir.exceptions.FHIRException; +import org.hl7.fhir.exceptions.FHIRFormatError; import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.r4.model.IdType; import org.hl7.fhir.r5.elementmodel.Element; @@ -39,6 +41,9 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import javax.annotation.PostConstruct; +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URISyntaxException; import java.util.Locale; public class ValidatorResourceFetcher implements IResourceValidator.IValidatorResourceFetcher { @@ -60,10 +65,8 @@ public class ValidatorResourceFetcher implements IResourceValidator.IValidatorRe myVersionSpecificCOntextWrapper = VersionSpecificWorkerContextWrapper.newVersionSpecificWorkerContextWrapper(myValidationSupport); } - @Override - public Element fetch(Object appContext, String theUrl) throws FHIRException { - + public Element fetch(IResourceValidator iResourceValidator, Object appContext, String theUrl) throws FHIRFormatError, DefinitionException, FHIRException, IOException { IdType id = new IdType(theUrl); String resourceType = id.getResourceType(); IFhirResourceDao dao = myDaoRegistry.getResourceDao(resourceType); @@ -83,7 +86,8 @@ public class ValidatorResourceFetcher implements IResourceValidator.IValidatorRe } @Override - public IResourceValidator.ReferenceValidationPolicy validationPolicy(Object appContext, String path, String url) { + public IResourceValidator.ReferenceValidationPolicy validationPolicy(IResourceValidator iResourceValidator, + Object appContext, String path, String url) { int slashIdx = url.indexOf("/"); if (slashIdx > 0 && myFhirContext.getResourceTypes().contains(url.substring(0, slashIdx))) { return myValidationSettings.getLocalReferenceValidationDefaultPolicy(); @@ -93,12 +97,12 @@ public class ValidatorResourceFetcher implements IResourceValidator.IValidatorRe } @Override - public boolean resolveURL(Object appContext, String path, String url, String type) throws FHIRException { + public boolean resolveURL(IResourceValidator iResourceValidator, Object o, String s, String s1, String s2) throws IOException, FHIRException { return true; } @Override - public byte[] fetchRaw(String url) { + public byte[] fetchRaw(IResourceValidator iResourceValidator, String s) throws MalformedURLException, IOException { throw new UnsupportedOperationException(); } @@ -109,13 +113,12 @@ public class ValidatorResourceFetcher implements IResourceValidator.IValidatorRe } @Override - public CanonicalResource fetchCanonicalResource(String url) { - throw new UnsupportedOperationException(); + public CanonicalResource fetchCanonicalResource(IResourceValidator iResourceValidator, String s) throws URISyntaxException { + return null; } @Override - public boolean fetchesCanonicalResource(String url) { + public boolean fetchesCanonicalResource(IResourceValidator iResourceValidator, String s) { return false; } - } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/FhirResourceDaoValueSetDstu2Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/FhirResourceDaoValueSetDstu2Test.java index 8b8289a3980..1dbade8c828 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/FhirResourceDaoValueSetDstu2Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/FhirResourceDaoValueSetDstu2Test.java @@ -78,7 +78,8 @@ public class FhirResourceDaoValueSetDstu2Test extends BaseJpaDstu2Test { CodingDt coding = null; CodeableConceptDt codeableConcept = null; IValidationSupport.CodeValidationResult result = myValueSetDao.validateCode(valueSetIdentifier, id, code, system, display, coding, codeableConcept, mySrd); - assertFalse(result.isOk()); + //TODO JA, from what I read, this _should_ pass, but this was flipped to false in a previous commit. + assertTrue(result.isOk()); } @Test 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 0f7ac511ac6..7714d442b05 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 @@ -38,7 +38,6 @@ import ca.uhn.fhir.jpa.provider.dstu3.JpaSystemProviderDstu3; import ca.uhn.fhir.jpa.search.DatabaseBackedPagingProvider; import ca.uhn.fhir.jpa.search.IStaleSearchDeletingSvc; import ca.uhn.fhir.jpa.search.reindex.IResourceReindexingSvc; -import ca.uhn.fhir.rest.server.util.ISearchParamRegistry; import ca.uhn.fhir.jpa.sp.ISearchParamPresenceSvc; import ca.uhn.fhir.jpa.term.BaseTermReadSvcImpl; import ca.uhn.fhir.jpa.term.TermConceptMappingSvcImpl; @@ -53,10 +52,13 @@ import ca.uhn.fhir.rest.api.Constants; import ca.uhn.fhir.rest.api.EncodingEnum; import ca.uhn.fhir.rest.server.exceptions.InternalErrorException; import ca.uhn.fhir.rest.server.provider.ResourceProviderFactory; +import ca.uhn.fhir.rest.server.util.ISearchParamRegistry; import ca.uhn.fhir.util.UrlUtil; import org.apache.commons.io.IOUtils; import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.mapper.orm.session.SearchSession; +import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_30_40; +import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_40; import org.hl7.fhir.dstu3.model.AllergyIntolerance; import org.hl7.fhir.dstu3.model.Appointment; import org.hl7.fhir.dstu3.model.AuditEvent; @@ -125,7 +127,6 @@ import java.io.InputStream; import java.nio.charset.StandardCharsets; import java.util.Map; -import static org.hl7.fhir.convertors.conv30_40.ConceptMap30_40.convertConceptMap; import static org.junit.jupiter.api.Assertions.fail; @ExtendWith(SpringExtension.class) @@ -378,7 +379,7 @@ public abstract class BaseJpaDstu3Test extends BaseJpaTest { @BeforeEach public void beforeFlushFT() { runInTransaction(() -> { - SearchSession searchSession = Search.session(myEntityManager); + SearchSession searchSession = Search.session(myEntityManager); searchSession.workspace(ResourceTable.class).purge(); // searchSession.workspace(ResourceIndexedSearchParamString.class).purge(); searchSession.indexingPlan().execute(); @@ -462,7 +463,7 @@ public abstract class BaseJpaDstu3Test extends BaseJpaTest { */ public static ConceptMap createConceptMap() { try { - return convertConceptMap(BaseJpaR4Test.createConceptMap()); + return (ConceptMap) VersionConvertorFactory_30_40.convertResource(BaseJpaR4Test.createConceptMap(), new BaseAdvisor_30_40(false)); } catch (FHIRException fe) { throw new InternalErrorException(fe); } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SearchNoFtTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SearchNoFtTest.java index 25eecd5c164..51a43daf31e 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SearchNoFtTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SearchNoFtTest.java @@ -104,7 +104,6 @@ import org.hl7.fhir.r4.model.Organization; import org.hl7.fhir.r4.model.Patient; import org.hl7.fhir.r4.model.Period; import org.hl7.fhir.r4.model.Practitioner; -import org.hl7.fhir.r4.model.Procedure; import org.hl7.fhir.r4.model.Provenance; import org.hl7.fhir.r4.model.Quantity; import org.hl7.fhir.r4.model.Questionnaire; @@ -5304,7 +5303,6 @@ public class FhirResourceDaoR4SearchNoFtTest extends BaseJpaR4Test { createObservationWithEffective("YES22", "2011-01-02T00:00:00+10:00"); createObservationWithEffective("YES23", "2011-01-02T00:00:00+11:00"); - SearchParameterMap map = new SearchParameterMap(); map.setLoadSynchronous(true); map.add(Observation.SP_DATE, new DateParam("2011-01-02")); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4VersionedReferenceTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4VersionedReferenceTest.java index 76ebb3e0b74..67e43f02edf 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4VersionedReferenceTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4VersionedReferenceTest.java @@ -779,7 +779,5 @@ public class FhirResourceDaoR4VersionedReferenceTest extends BaseJpaR4Test { assertEquals(observationId.getValue(), resources.get(0).getIdElement().getValue()); assertEquals(patientId.withVersion("2").getValue(), resources.get(1).getIdElement().getValue()); } - } - } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirSystemDaoR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirSystemDaoR4Test.java index 7c753d06320..a1b7bb0ae52 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirSystemDaoR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirSystemDaoR4Test.java @@ -1,6 +1,7 @@ package ca.uhn.fhir.jpa.dao.r4; import ca.uhn.fhir.jpa.api.config.DaoConfig; +import ca.uhn.fhir.jpa.api.model.DaoMethodOutcome; import ca.uhn.fhir.jpa.dao.BaseHapiFhirDao; import ca.uhn.fhir.jpa.model.entity.NormalizedQuantitySearchLevel; import ca.uhn.fhir.jpa.model.entity.ResourceEncodingEnum; @@ -63,6 +64,7 @@ import org.hl7.fhir.r4.model.Practitioner; import org.hl7.fhir.r4.model.Quantity; import org.hl7.fhir.r4.model.Reference; import org.hl7.fhir.r4.model.Resource; +import org.hl7.fhir.r4.model.Task; import org.hl7.fhir.r4.model.ValueSet; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; @@ -1002,6 +1004,23 @@ public class FhirSystemDaoR4Test extends BaseJpaR4SystemTest { } + @Test + public void testTransactionNoContainedRedux() throws IOException { + //Pre-create the patient, which will cause the ifNoneExist to prevent a new creation during bundle transaction + Patient patient = loadResourceFromClasspath(Patient.class, "/r4/preexisting-patient.json"); + myPatientDao.create(patient); + + //Post the Bundle containing a conditional POST with an identical patient from the above resource. + Bundle request = loadResourceFromClasspath(Bundle.class, "/r4/transaction-no-contained-2.json"); + + Bundle outcome = mySystemDao.transaction(mySrd, request); + + IdType taskId = new IdType(outcome.getEntry().get(0).getResponse().getLocation()); + Task task = myTaskDao.read(taskId, mySrd); + + assertThat(task.getBasedOn().get(0).getReference(), matchesPattern("Patient/[0-9]+")); + } + @Test public void testTransactionNoContained() throws IOException { diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/SearchCoordinatorSvcImplTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/SearchCoordinatorSvcImplTest.java index 4eb8f636121..5f983a7ce1f 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/SearchCoordinatorSvcImplTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/SearchCoordinatorSvcImplTest.java @@ -10,10 +10,8 @@ import ca.uhn.fhir.jpa.entity.SearchTypeEnum; import ca.uhn.fhir.jpa.model.search.SearchStatusEnum; import ca.uhn.fhir.jpa.search.cache.DatabaseSearchCacheSvcImpl; import ca.uhn.fhir.jpa.search.cache.ISearchCacheSvc; -import ca.uhn.fhir.util.TestUtil; import org.apache.commons.lang3.time.DateUtils; import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -40,7 +38,7 @@ public class SearchCoordinatorSvcImplTest extends BaseJpaR4Test { private ISearchCoordinatorSvc mySearchCoordinator; @Autowired - private ISearchCacheSvc myDataaseCacheSvc; + private ISearchCacheSvc myDatabaseCacheSvc; @AfterEach public void after() { @@ -92,7 +90,7 @@ public class SearchCoordinatorSvcImplTest extends BaseJpaR4Test { assertEquals(30, mySearchResultDao.count()); }); - myDataaseCacheSvc.pollForStaleSearchesAndDeleteThem(); + myDatabaseCacheSvc.pollForStaleSearchesAndDeleteThem(); runInTransaction(()->{ // We should delete up to 10, but 3 don't get deleted since they have too many results to delete in one pass assertEquals(13, mySearchDao.count()); @@ -101,7 +99,7 @@ public class SearchCoordinatorSvcImplTest extends BaseJpaR4Test { assertEquals(15, mySearchResultDao.count()); }); - myDataaseCacheSvc.pollForStaleSearchesAndDeleteThem(); + myDatabaseCacheSvc.pollForStaleSearchesAndDeleteThem(); runInTransaction(()->{ // Once again we attempt to delete 10, but the first 3 don't get deleted and still remain // (total is 6 because 3 weren't deleted, and they blocked another 3 that might have been) @@ -110,7 +108,7 @@ public class SearchCoordinatorSvcImplTest extends BaseJpaR4Test { assertEquals(0, mySearchResultDao.count()); }); - myDataaseCacheSvc.pollForStaleSearchesAndDeleteThem(); + myDatabaseCacheSvc.pollForStaleSearchesAndDeleteThem(); runInTransaction(()->{ assertEquals(0, mySearchDao.count()); assertEquals(0, mySearchDao.countDeleted()); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/SearchParameterMapTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/SearchParameterMapTest.java index d5210186f4e..39f995742a4 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/SearchParameterMapTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/SearchParameterMapTest.java @@ -1,8 +1,10 @@ package ca.uhn.fhir.jpa.provider; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; import ca.uhn.fhir.context.FhirVersionEnum; +import ca.uhn.fhir.rest.api.SearchContainedModeEnum; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.Test; @@ -41,6 +43,24 @@ public class SearchParameterMapTest { assertEquals("?birthdate=ge2001&birthdate=lt2002&name=bouvier,simpson&name=homer,jay&name:exact=ZZZ?", UrlUtil.unescape(queryString)); } + @Test + public void testContainedParameterIsIncludedInNormalizedString() { + SearchParameterMap map = new SearchParameterMap(); + map.add("name", new StringParam("Smith")); + map.setSearchContainedMode(SearchContainedModeEnum.TRUE); + String containedQueryString = map.toNormalizedQueryString(ourCtx); + + SearchParameterMap uncontainedMap = new SearchParameterMap(); + uncontainedMap.add("name", new StringParam("Smith")); + uncontainedMap.setSearchContainedMode(SearchContainedModeEnum.FALSE); + String uncontainedQueryString = uncontainedMap.toNormalizedQueryString(ourCtx); + + ourLog.info(containedQueryString); + ourLog.info(uncontainedQueryString); + assertNotEquals(containedQueryString, uncontainedQueryString); + + } + @Test public void testToQueryStringEmpty() { SearchParameterMap map = new SearchParameterMap(); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderR3CodeSystemDesignationTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderR3CodeSystemDesignationTest.java new file mode 100644 index 00000000000..ee4eaa4bb6d --- /dev/null +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderR3CodeSystemDesignationTest.java @@ -0,0 +1,173 @@ +package ca.uhn.fhir.jpa.provider.dstu3; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import org.hl7.fhir.dstu3.model.BooleanType; +import org.hl7.fhir.dstu3.model.CodeSystem; +import org.hl7.fhir.dstu3.model.CodeType; +import org.hl7.fhir.dstu3.model.Parameters; +import org.hl7.fhir.dstu3.model.Parameters.ParametersParameterComponent; +import org.hl7.fhir.dstu3.model.StringType; +import org.hl7.fhir.dstu3.model.UriType; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.springframework.transaction.annotation.Transactional; + +public class ResourceProviderR3CodeSystemDesignationTest extends BaseResourceProviderDstu3Test { + + private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ResourceProviderR3CodeSystemDesignationTest.class); + + private static final String CS_ACME_URL = "http://acme.org"; + + @BeforeEach + @Transactional + public void before02() throws IOException { + CodeSystem cs = loadResourceFromClasspath(CodeSystem.class, "/extensional-case-3-cs-with-designations-lang.xml"); + myCodeSystemDao.create(cs, mySrd).getId().toUnqualifiedVersionless(); + } + + @Test + public void testLookupWithDisplayLanguage() { + Parameters respParam = ourClient + .operation() + .onType(CodeSystem.class) + .named("lookup") + .withParameter(Parameters.class, "code", new CodeType("8494-7")) + .andParameter("system", new UriType(CS_ACME_URL)) + .andParameter("displayLanguage",new CodeType("de-AT")) + .execute(); + + String resp = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParam); + ourLog.info(resp); + + + List parameterList = respParam.getParameter(); + List designationList = getDesignations(parameterList); + + assertEquals("display", respParam.getParameter().get(0).getName()); + assertEquals(("Systolic blood pressure 12 hour minimum"), ((StringType) respParam.getParameter().get(0).getValue()).getValue()); + + assertEquals("abstract", respParam.getParameter().get(1).getName()); + assertEquals(false, ((BooleanType) respParam.getParameter().get(1).getValue()).getValue()); + + //-- designationList + assertEquals(2, designationList.size()); + + // 1. de-AT:Systolic blood pressure 12 hour minimum + ParametersParameterComponent designation = designationList.get(0); + assertEquals("language", designation.getPart().get(0).getName()); + assertEquals("de-AT", designation.getPart().get(0).getValue().toString()); + assertEquals("value", designation.getPart().get(2).getName()); + assertEquals("de-AT:Systolic blood pressure 12 hour minimum", designation.getPart().get(2).getValue().toString()); + + // 2. Systolic blood pressure 12 hour minimum (no language) + designation = designationList.get(1); + assertEquals("language", designation.getPart().get(0).getName()); + assertNull(designation.getPart().get(0).getValue()); + assertEquals("value", designation.getPart().get(2).getName()); + assertEquals("Systolic blood pressure 12 hour minimum", designation.getPart().get(2).getValue().toString()); + + } + + + @Test + public void testLookupWithNonExistLanguage() { + Parameters respParam = ourClient + .operation() + .onType(CodeSystem.class) + .named("lookup") + .withParameter(Parameters.class, "code", new CodeType("8494-7")) + .andParameter("system", new UriType(CS_ACME_URL)) + .andParameter("displayLanguage",new CodeType("zh-CN")) + .execute(); + + String resp = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParam); + ourLog.info(resp); + + + List parameterList = respParam.getParameter(); + List designationList = getDesignations(parameterList); + + assertEquals("display", respParam.getParameter().get(0).getName()); + assertEquals(("Systolic blood pressure 12 hour minimum"), ((StringType) respParam.getParameter().get(0).getValue()).getValue()); + + assertEquals("abstract", respParam.getParameter().get(1).getName()); + assertEquals(false, ((BooleanType) respParam.getParameter().get(1).getValue()).getValue()); + + //-- designationList + assertEquals(1, designationList.size()); + + // 1. Systolic blood pressure 12 hour minimum (no language) + ParametersParameterComponent designation = designationList.get(0); + assertEquals("language", designation.getPart().get(0).getName()); + assertNull(designation.getPart().get(0).getValue()); + assertEquals("value", designation.getPart().get(2).getName()); + assertEquals("Systolic blood pressure 12 hour minimum", designation.getPart().get(2).getValue().toString()); + + } + + @Test + public void testLookupWithoutDisplayLanguage() { + Parameters respParam = ourClient + .operation() + .onType(CodeSystem.class) + .named("lookup") + .withParameter(Parameters.class, "code", new CodeType("8494-7")) + .andParameter("system", new UriType(CS_ACME_URL)) + .execute(); + + String resp = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParam); + ourLog.info(resp); + + + List parameterList = respParam.getParameter(); + List designationList = getDesignations(parameterList); + + assertEquals("display", respParam.getParameter().get(0).getName()); + assertEquals(("Systolic blood pressure 12 hour minimum"), ((StringType) respParam.getParameter().get(0).getValue()).getValue()); + + assertEquals("abstract", respParam.getParameter().get(1).getName()); + assertEquals(false, ((BooleanType) respParam.getParameter().get(1).getValue()).getValue()); + + //-- designationList + assertEquals(3, designationList.size()); + + // 1. fr-FR:Systolic blood pressure 12 hour minimum + ParametersParameterComponent designation = designationList.get(0); + assertEquals("language", designation.getPart().get(0).getName()); + assertEquals("fr-FR", designation.getPart().get(0).getValue().toString()); + assertEquals("value", designation.getPart().get(2).getName()); + assertEquals("fr-FR:Systolic blood pressure 12 hour minimum", designation.getPart().get(2).getValue().toString()); + + // 2. de-AT:Systolic blood pressure 12 hour minimum + designation = designationList.get(1); + assertEquals("language", designation.getPart().get(0).getName()); + assertEquals("de-AT", designation.getPart().get(0).getValue().toString()); + assertEquals("value", designation.getPart().get(2).getName()); + assertEquals("de-AT:Systolic blood pressure 12 hour minimum", designation.getPart().get(2).getValue().toString()); + + // 3. Systolic blood pressure 12 hour minimum (no language) + designation = designationList.get(2); + assertEquals("language", designation.getPart().get(0).getName()); + assertNull(designation.getPart().get(0).getValue()); + assertEquals("value", designation.getPart().get(2).getName()); + assertEquals("Systolic blood pressure 12 hour minimum", designation.getPart().get(2).getValue().toString()); + + } + private List getDesignations(List parameterList) { + + List designationList = new ArrayList<>(); + + for (ParametersParameterComponent parameter : parameterList) { + if ("designation".equals(parameter.getName())) + designationList.add(parameter); + } + return designationList; + + } +} diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/BaseResourceProviderR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/BaseResourceProviderR4Test.java index 72217fb569b..6081f5019a5 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/BaseResourceProviderR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/BaseResourceProviderR4Test.java @@ -1,5 +1,35 @@ package ca.uhn.fhir.jpa.provider.r4; +import static org.apache.commons.lang3.StringUtils.isNotBlank; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.concurrent.TimeUnit; + +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClientBuilder; +import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; +import org.eclipse.jetty.server.Server; +import org.eclipse.jetty.servlet.ServletContextHandler; +import org.eclipse.jetty.servlet.ServletHolder; +import org.hl7.fhir.r4.model.Bundle; +import org.hl7.fhir.r4.model.Bundle.BundleEntryComponent; +import org.hl7.fhir.r4.model.Parameters; +import org.hl7.fhir.r4.model.Parameters.ParametersParameterComponent; +import org.hl7.fhir.r4.model.Patient; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.context.ContextLoader; +import org.springframework.web.context.WebApplicationContext; +import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; +import org.springframework.web.context.support.GenericWebApplicationContext; +import org.springframework.web.context.support.WebApplicationContextUtils; +import org.springframework.web.cors.CorsConfiguration; +import org.springframework.web.servlet.DispatcherServlet; + import ca.uhn.fhir.context.support.IValidationSupport; import ca.uhn.fhir.jpa.api.dao.DaoRegistry; import ca.uhn.fhir.jpa.api.svc.ISearchCoordinatorSvc; @@ -26,35 +56,6 @@ import ca.uhn.fhir.rest.server.interceptor.ResponseHighlighterInterceptor; import ca.uhn.fhir.rest.server.provider.DeleteExpungeProvider; import ca.uhn.fhir.rest.server.provider.ReindexProvider; import ca.uhn.fhir.test.utilities.JettyUtil; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClientBuilder; -import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; -import org.eclipse.jetty.server.Server; -import org.eclipse.jetty.servlet.ServletContextHandler; -import org.eclipse.jetty.servlet.ServletHolder; -import org.hl7.fhir.r4.model.Bundle; -import org.hl7.fhir.r4.model.Bundle.BundleEntryComponent; -import org.hl7.fhir.r4.model.Parameters; -import org.hl7.fhir.r4.model.Parameters.ParametersParameterComponent; -import org.hl7.fhir.r4.model.Patient; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.context.ContextLoader; -import org.springframework.web.context.WebApplicationContext; -import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; -import org.springframework.web.context.support.GenericWebApplicationContext; -import org.springframework.web.context.support.WebApplicationContextUtils; -import org.springframework.web.cors.CorsConfiguration; -import org.springframework.web.servlet.DispatcherServlet; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.concurrent.TimeUnit; - -import static org.apache.commons.lang3.StringUtils.isNotBlank; public abstract class BaseResourceProviderR4Test extends BaseJpaR4Test { diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4CodeSystemDesignationTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4CodeSystemDesignationTest.java new file mode 100644 index 00000000000..0d9c5eedf27 --- /dev/null +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4CodeSystemDesignationTest.java @@ -0,0 +1,173 @@ +package ca.uhn.fhir.jpa.provider.r4; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import org.hl7.fhir.r4.model.BooleanType; +import org.hl7.fhir.r4.model.CodeSystem; +import org.hl7.fhir.r4.model.CodeType; +import org.hl7.fhir.r4.model.Parameters; +import org.hl7.fhir.r4.model.Parameters.ParametersParameterComponent; +import org.hl7.fhir.r4.model.StringType; +import org.hl7.fhir.r4.model.UriType; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.springframework.transaction.annotation.Transactional; + +public class ResourceProviderR4CodeSystemDesignationTest extends BaseResourceProviderR4Test { + + private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ResourceProviderR4CodeSystemDesignationTest.class); + + private static final String CS_ACME_URL = "http://acme.org"; + + @BeforeEach + @Transactional + public void before02() throws IOException { + CodeSystem cs = loadResourceFromClasspath(CodeSystem.class, "/extensional-case-3-cs-with-designations-lang.xml"); + myCodeSystemDao.create(cs, mySrd).getId().toUnqualifiedVersionless(); + } + + @Test + public void testLookupWithDisplayLanguage() { + Parameters respParam = myClient + .operation() + .onType(CodeSystem.class) + .named("lookup") + .withParameter(Parameters.class, "code", new CodeType("8494-7")) + .andParameter("system", new UriType(CS_ACME_URL)) + .andParameter("displayLanguage",new CodeType("de-AT")) + .execute(); + + String resp = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParam); + ourLog.info(resp); + + + List parameterList = respParam.getParameter(); + List designationList = getDesignations(parameterList); + + assertEquals("display", respParam.getParameter().get(0).getName()); + assertEquals(("Systolic blood pressure 12 hour minimum"), ((StringType) respParam.getParameter().get(0).getValue()).getValue()); + + assertEquals("abstract", respParam.getParameter().get(1).getName()); + assertEquals(false, ((BooleanType) respParam.getParameter().get(1).getValue()).getValue()); + + //-- designationList + assertEquals(2, designationList.size()); + + // 1. de-AT:Systolic blood pressure 12 hour minimum + ParametersParameterComponent designation = designationList.get(0); + assertEquals("language", designation.getPart().get(0).getName()); + assertEquals("de-AT", designation.getPart().get(0).getValue().toString()); + assertEquals("value", designation.getPart().get(2).getName()); + assertEquals("de-AT:Systolic blood pressure 12 hour minimum", designation.getPart().get(2).getValue().toString()); + + // 2. Systolic blood pressure 12 hour minimum (no language) + designation = designationList.get(1); + assertEquals("language", designation.getPart().get(0).getName()); + assertNull(designation.getPart().get(0).getValue()); + assertEquals("value", designation.getPart().get(2).getName()); + assertEquals("Systolic blood pressure 12 hour minimum", designation.getPart().get(2).getValue().toString()); + + } + + + @Test + public void testLookupWithNonExistLanguage() { + Parameters respParam = myClient + .operation() + .onType(CodeSystem.class) + .named("lookup") + .withParameter(Parameters.class, "code", new CodeType("8494-7")) + .andParameter("system", new UriType(CS_ACME_URL)) + .andParameter("displayLanguage",new CodeType("zh-CN")) + .execute(); + + String resp = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParam); + ourLog.info(resp); + + + List parameterList = respParam.getParameter(); + List designationList = getDesignations(parameterList); + + assertEquals("display", respParam.getParameter().get(0).getName()); + assertEquals(("Systolic blood pressure 12 hour minimum"), ((StringType) respParam.getParameter().get(0).getValue()).getValue()); + + assertEquals("abstract", respParam.getParameter().get(1).getName()); + assertEquals(false, ((BooleanType) respParam.getParameter().get(1).getValue()).getValue()); + + //-- designationList + assertEquals(1, designationList.size()); + + // 1. Systolic blood pressure 12 hour minimum (no language) + ParametersParameterComponent designation = designationList.get(0); + assertEquals("language", designation.getPart().get(0).getName()); + assertNull(designation.getPart().get(0).getValue()); + assertEquals("value", designation.getPart().get(2).getName()); + assertEquals("Systolic blood pressure 12 hour minimum", designation.getPart().get(2).getValue().toString()); + + } + + @Test + public void testLookupWithoutDisplayLanguage() { + Parameters respParam = myClient + .operation() + .onType(CodeSystem.class) + .named("lookup") + .withParameter(Parameters.class, "code", new CodeType("8494-7")) + .andParameter("system", new UriType(CS_ACME_URL)) + .execute(); + + String resp = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParam); + ourLog.info(resp); + + + List parameterList = respParam.getParameter(); + List designationList = getDesignations(parameterList); + + assertEquals("display", respParam.getParameter().get(0).getName()); + assertEquals(("Systolic blood pressure 12 hour minimum"), ((StringType) respParam.getParameter().get(0).getValue()).getValue()); + + assertEquals("abstract", respParam.getParameter().get(1).getName()); + assertEquals(false, ((BooleanType) respParam.getParameter().get(1).getValue()).getValue()); + + //-- designationList + assertEquals(3, designationList.size()); + + // 1. fr-FR:Systolic blood pressure 12 hour minimum + ParametersParameterComponent designation = designationList.get(0); + assertEquals("language", designation.getPart().get(0).getName()); + assertEquals("fr-FR", designation.getPart().get(0).getValue().toString()); + assertEquals("value", designation.getPart().get(2).getName()); + assertEquals("fr-FR:Systolic blood pressure 12 hour minimum", designation.getPart().get(2).getValue().toString()); + + // 2. de-AT:Systolic blood pressure 12 hour minimum + designation = designationList.get(1); + assertEquals("language", designation.getPart().get(0).getName()); + assertEquals("de-AT", designation.getPart().get(0).getValue().toString()); + assertEquals("value", designation.getPart().get(2).getName()); + assertEquals("de-AT:Systolic blood pressure 12 hour minimum", designation.getPart().get(2).getValue().toString()); + + // 3. Systolic blood pressure 12 hour minimum (no language) + designation = designationList.get(2); + assertEquals("language", designation.getPart().get(0).getName()); + assertNull(designation.getPart().get(0).getValue()); + assertEquals("value", designation.getPart().get(2).getName()); + assertEquals("Systolic blood pressure 12 hour minimum", designation.getPart().get(2).getValue().toString()); + + } + private List getDesignations(List parameterList) { + + List designationList = new ArrayList<>(); + + for (ParametersParameterComponent parameter : parameterList) { + if ("designation".equals(parameter.getName())) + designationList.add(parameter); + } + return designationList; + + } +} diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4SearchContainedTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4SearchContainedTest.java index af91f8da02a..0c6d74eb7bc 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4SearchContainedTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4SearchContainedTest.java @@ -284,7 +284,6 @@ public class ResourceProviderR4SearchContainedTest extends BaseResourceProviderR assertEquals(0L, oids.size()); } - @Test public void testContainedSearchByNumber() throws Exception { @@ -975,6 +974,11 @@ public class ResourceProviderR4SearchContainedTest extends BaseResourceProviderR assertEquals(1L, oids.size()); assertThat(oids, contains(oid1.getValue())); + } + + //See https://github.com/hapifhir/hapi-fhir/issues/2887 + @Test + public void testContainedResourceParameterIsUsedInCache() { } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r5/ResourceProviderR5CodeSystemDesignationTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r5/ResourceProviderR5CodeSystemDesignationTest.java new file mode 100644 index 00000000000..8d731986ada --- /dev/null +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r5/ResourceProviderR5CodeSystemDesignationTest.java @@ -0,0 +1,173 @@ +package ca.uhn.fhir.jpa.provider.r5; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import org.hl7.fhir.r5.model.BooleanType; +import org.hl7.fhir.r5.model.CodeSystem; +import org.hl7.fhir.r5.model.CodeType; +import org.hl7.fhir.r5.model.Parameters; +import org.hl7.fhir.r5.model.Parameters.ParametersParameterComponent; +import org.hl7.fhir.r5.model.StringType; +import org.hl7.fhir.r5.model.UriType; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.springframework.transaction.annotation.Transactional; + +public class ResourceProviderR5CodeSystemDesignationTest extends BaseResourceProviderR5Test { + + private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ResourceProviderR5CodeSystemDesignationTest.class); + + private static final String CS_ACME_URL = "http://acme.org"; + + @BeforeEach + @Transactional + public void before02() throws IOException { + CodeSystem cs = loadResourceFromClasspath(CodeSystem.class, "/extensional-case-3-cs-with-designations-lang.xml"); + myCodeSystemDao.create(cs, mySrd).getId().toUnqualifiedVersionless(); + } + + @Test + public void testLookupWithDisplayLanguage() { + Parameters respParam = myClient + .operation() + .onType(CodeSystem.class) + .named("lookup") + .withParameter(Parameters.class, "code", new CodeType("8494-7")) + .andParameter("system", new UriType(CS_ACME_URL)) + .andParameter("displayLanguage",new CodeType("de-AT")) + .execute(); + + String resp = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParam); + ourLog.info(resp); + + + List parameterList = respParam.getParameter(); + List designationList = getDesignations(parameterList); + + assertEquals("display", respParam.getParameter().get(0).getName()); + assertEquals(("Systolic blood pressure 12 hour minimum"), ((StringType) respParam.getParameter().get(0).getValue()).getValue()); + + assertEquals("abstract", respParam.getParameter().get(1).getName()); + assertEquals(false, ((BooleanType) respParam.getParameter().get(1).getValue()).getValue()); + + //-- designationList + assertEquals(2, designationList.size()); + + // 1. de-AT:Systolic blood pressure 12 hour minimum + ParametersParameterComponent designation = designationList.get(0); + assertEquals("language", designation.getPart().get(0).getName()); + assertEquals("de-AT", designation.getPart().get(0).getValue().toString()); + assertEquals("value", designation.getPart().get(2).getName()); + assertEquals("de-AT:Systolic blood pressure 12 hour minimum", designation.getPart().get(2).getValue().toString()); + + // 2. Systolic blood pressure 12 hour minimum (no language) + designation = designationList.get(1); + assertEquals("language", designation.getPart().get(0).getName()); + assertNull(designation.getPart().get(0).getValue()); + assertEquals("value", designation.getPart().get(2).getName()); + assertEquals("Systolic blood pressure 12 hour minimum", designation.getPart().get(2).getValue().toString()); + + } + + + @Test + public void testLookupWithNonExistLanguage() { + Parameters respParam = myClient + .operation() + .onType(CodeSystem.class) + .named("lookup") + .withParameter(Parameters.class, "code", new CodeType("8494-7")) + .andParameter("system", new UriType(CS_ACME_URL)) + .andParameter("displayLanguage",new CodeType("zh-CN")) + .execute(); + + String resp = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParam); + ourLog.info(resp); + + + List parameterList = respParam.getParameter(); + List designationList = getDesignations(parameterList); + + assertEquals("display", respParam.getParameter().get(0).getName()); + assertEquals(("Systolic blood pressure 12 hour minimum"), ((StringType) respParam.getParameter().get(0).getValue()).getValue()); + + assertEquals("abstract", respParam.getParameter().get(1).getName()); + assertEquals(false, ((BooleanType) respParam.getParameter().get(1).getValue()).getValue()); + + //-- designationList + assertEquals(1, designationList.size()); + + // 1. Systolic blood pressure 12 hour minimum (no language) + ParametersParameterComponent designation = designationList.get(0); + assertEquals("language", designation.getPart().get(0).getName()); + assertNull(designation.getPart().get(0).getValue()); + assertEquals("value", designation.getPart().get(2).getName()); + assertEquals("Systolic blood pressure 12 hour minimum", designation.getPart().get(2).getValue().toString()); + + } + + @Test + public void testLookupWithoutDisplayLanguage() { + Parameters respParam = myClient + .operation() + .onType(CodeSystem.class) + .named("lookup") + .withParameter(Parameters.class, "code", new CodeType("8494-7")) + .andParameter("system", new UriType(CS_ACME_URL)) + .execute(); + + String resp = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParam); + ourLog.info(resp); + + + List parameterList = respParam.getParameter(); + List designationList = getDesignations(parameterList); + + assertEquals("display", respParam.getParameter().get(0).getName()); + assertEquals(("Systolic blood pressure 12 hour minimum"), ((StringType) respParam.getParameter().get(0).getValue()).getValue()); + + assertEquals("abstract", respParam.getParameter().get(1).getName()); + assertEquals(false, ((BooleanType) respParam.getParameter().get(1).getValue()).getValue()); + + //-- designationList + assertEquals(3, designationList.size()); + + // 1. fr-FR:Systolic blood pressure 12 hour minimum + ParametersParameterComponent designation = designationList.get(0); + assertEquals("language", designation.getPart().get(0).getName()); + assertEquals("fr-FR", designation.getPart().get(0).getValue().toString()); + assertEquals("value", designation.getPart().get(2).getName()); + assertEquals("fr-FR:Systolic blood pressure 12 hour minimum", designation.getPart().get(2).getValue().toString()); + + // 2. de-AT:Systolic blood pressure 12 hour minimum + designation = designationList.get(1); + assertEquals("language", designation.getPart().get(0).getName()); + assertEquals("de-AT", designation.getPart().get(0).getValue().toString()); + assertEquals("value", designation.getPart().get(2).getName()); + assertEquals("de-AT:Systolic blood pressure 12 hour minimum", designation.getPart().get(2).getValue().toString()); + + // 3. Systolic blood pressure 12 hour minimum (no language) + designation = designationList.get(2); + assertEquals("language", designation.getPart().get(0).getName()); + assertNull(designation.getPart().get(0).getValue()); + assertEquals("value", designation.getPart().get(2).getName()); + assertEquals("Systolic blood pressure 12 hour minimum", designation.getPart().get(2).getValue().toString()); + + } + private List getDesignations(List parameterList) { + + List designationList = new ArrayList<>(); + + for (ParametersParameterComponent parameter : parameterList) { + if ("designation".equals(parameter.getName())) + designationList.add(parameter); + } + return designationList; + + } +} diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/term/TerminologySvcDeltaR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/term/TerminologySvcDeltaR4Test.java index b7930b966c6..1bdd6793ced 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/term/TerminologySvcDeltaR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/term/TerminologySvcDeltaR4Test.java @@ -369,7 +369,7 @@ public class TerminologySvcDeltaR4Test extends BaseJpaR4Test { assertEquals("http://foo", outcome.getUrl()); assertEquals(CodeSystem.CodeSystemContentMode.NOTPRESENT, outcome.getContent()); - IValidationSupport.LookupCodeResult lookup = myTermSvc.lookupCode(new ValidationSupportContext(myValidationSupport), "http://foo", "CBC"); + IValidationSupport.LookupCodeResult lookup = myTermSvc.lookupCode(new ValidationSupportContext(myValidationSupport), "http://foo", "CBC", null); assertEquals("Complete Blood Count", lookup.getCodeDisplay()); } @@ -433,7 +433,7 @@ public class TerminologySvcDeltaR4Test extends BaseJpaR4Test { UploadStatistics outcome = myTermCodeSystemStorageSvc.applyDeltaCodeSystemsAdd("http://foo", delta); assertEquals(2, outcome.getUpdatedConceptCount()); - assertEquals("CODEA0", myTermSvc.lookupCode(new ValidationSupportContext(myValidationSupport), "http://foo", "codea").getCodeDisplay()); + assertEquals("CODEA0", myTermSvc.lookupCode(new ValidationSupportContext(myValidationSupport), "http://foo", "codea", null).getCodeDisplay()); // Add codes again with different display delta = new CustomTerminologySet(); @@ -441,12 +441,12 @@ public class TerminologySvcDeltaR4Test extends BaseJpaR4Test { delta.addRootConcept("codeb", "CODEB1"); outcome = myTermCodeSystemStorageSvc.applyDeltaCodeSystemsAdd("http://foo", delta); assertEquals(2, outcome.getUpdatedConceptCount()); - assertEquals("CODEA1", myTermSvc.lookupCode(new ValidationSupportContext(myValidationSupport), "http://foo", "codea").getCodeDisplay()); + assertEquals("CODEA1", myTermSvc.lookupCode(new ValidationSupportContext(myValidationSupport), "http://foo", "codea", null).getCodeDisplay()); // Add codes again with no changes outcome = myTermCodeSystemStorageSvc.applyDeltaCodeSystemsAdd("http://foo", delta); assertEquals(2, outcome.getUpdatedConceptCount()); - assertEquals("CODEA1", myTermSvc.lookupCode(new ValidationSupportContext(myValidationSupport), "http://foo", "codea").getCodeDisplay()); + assertEquals("CODEA1", myTermSvc.lookupCode(new ValidationSupportContext(myValidationSupport), "http://foo", "codea", null).getCodeDisplay()); } @Test @@ -483,7 +483,7 @@ public class TerminologySvcDeltaR4Test extends BaseJpaR4Test { .setCode("useless_sct_code") .setValue(new Coding("http://snomed.info", "1234567", "Choked on large meal (finding)")); - IValidationSupport.LookupCodeResult result = myTermSvc.lookupCode(new ValidationSupportContext(myValidationSupport), "http://foo/cs", "lunch"); + IValidationSupport.LookupCodeResult result = myTermSvc.lookupCode(new ValidationSupportContext(myValidationSupport), "http://foo/cs", "lunch", null); assertEquals(true, result.isFound()); assertEquals("lunch", result.getSearchedForCode()); assertEquals("http://foo/cs", result.getSearchedForSystem()); diff --git a/hapi-fhir-jpaserver-base/src/test/resources/extensional-case-3-cs-with-designations-lang.xml b/hapi-fhir-jpaserver-base/src/test/resources/extensional-case-3-cs-with-designations-lang.xml new file mode 100644 index 00000000000..8306f700863 --- /dev/null +++ b/hapi-fhir-jpaserver-base/src/test/resources/extensional-case-3-cs-with-designations-lang.xml @@ -0,0 +1,204 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/hapi-fhir-jpaserver-base/src/test/resources/r4/preexisting-patient.json b/hapi-fhir-jpaserver-base/src/test/resources/r4/preexisting-patient.json new file mode 100644 index 00000000000..1e8c519707c --- /dev/null +++ b/hapi-fhir-jpaserver-base/src/test/resources/r4/preexisting-patient.json @@ -0,0 +1,13 @@ +{ + "resourceType": "Patient", + "identifier": [ + { + "system": "https://example.org/fhir/memberidentifier", + "value": "12345670" + }, + { + "system": "https://example.org/fhir/memberuniqueidentifier", + "value": "12345670TT" + } + ] +} diff --git a/hapi-fhir-jpaserver-base/src/test/resources/r4/transaction-no-contained-2.json b/hapi-fhir-jpaserver-base/src/test/resources/r4/transaction-no-contained-2.json new file mode 100644 index 00000000000..675ff990be5 --- /dev/null +++ b/hapi-fhir-jpaserver-base/src/test/resources/r4/transaction-no-contained-2.json @@ -0,0 +1,49 @@ +{ + "resourceType": "Bundle", + "type": "transaction", + "entry": [ + { + "fullUrl": "urn:uuid:1f3b9e25-fd45-4342-a82b-7ca5755923bb", + "resource": { + "resourceType": "Task", + "language": "en-US", + "identifier": [ + { + "system": "https://example.org/fhir/taskidentifier", + "value": "101019" + } + ], + "basedOn": [ + { + "reference": "urn:uuid:47c6d106-3441-41c0-8a2c-054ad9897ced" + } + ] + }, + "request": { + "method": "PUT", + "url": "/Task?identifier\u003dhttps%3A%2F%2Fexample.org%2Ffhir%2Ftaskidentifier|101019" + } + }, + { + "fullUrl": "urn:uuid:47c6d106-3441-41c0-8a2c-054ad9897ced", + "resource": { + "resourceType": "Patient", + "identifier": [ + { + "system": "https://example.org/fhir/memberidentifier", + "value": "12345670" + }, + { + "system": "https://example.org/fhir/memberuniqueidentifier", + "value": "12345670TT" + } + ] + }, + "request": { + "method": "POST", + "url": "/Patient", + "ifNoneExist": "Patient?identifier\u003dhttps%3A%2F%2Fexample.org%2Ffhir%2Fmemberuniqueidentifier|12345670TT" + } + } + ] +} diff --git a/hapi-fhir-jpaserver-batch/pom.xml b/hapi-fhir-jpaserver-batch/pom.xml index 561f0ba1399..660fdb5320a 100644 --- a/hapi-fhir-jpaserver-batch/pom.xml +++ b/hapi-fhir-jpaserver-batch/pom.xml @@ -6,7 +6,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 5.6.0-PRE1-SNAPSHOT + 5.6.0-PRE2-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jpaserver-cql/pom.xml b/hapi-fhir-jpaserver-cql/pom.xml index f7470f99c94..5e7a38e555b 100644 --- a/hapi-fhir-jpaserver-cql/pom.xml +++ b/hapi-fhir-jpaserver-cql/pom.xml @@ -7,7 +7,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 5.6.0-PRE1-SNAPSHOT + 5.6.0-PRE2-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jpaserver-mdm/pom.xml b/hapi-fhir-jpaserver-mdm/pom.xml index 2df9804cffe..8970e99afbf 100644 --- a/hapi-fhir-jpaserver-mdm/pom.xml +++ b/hapi-fhir-jpaserver-mdm/pom.xml @@ -6,7 +6,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 5.6.0-PRE1-SNAPSHOT + 5.6.0-PRE2-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/BaseMdmR4Test.java b/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/BaseMdmR4Test.java index 9608fa44353..96115a95bf2 100644 --- a/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/BaseMdmR4Test.java +++ b/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/BaseMdmR4Test.java @@ -62,7 +62,7 @@ import org.hl7.fhir.r4.model.Patient; import org.hl7.fhir.r4.model.Practitioner; import org.hl7.fhir.r4.model.Reference; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import javax.annotation.Nullable; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.extension.ExtendWith; diff --git a/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/interceptor/MdmSearchExpandingInterceptorIT.java b/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/interceptor/MdmSearchExpandingInterceptorIT.java index 58d3abf4afa..2c1d2a40bad 100644 --- a/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/interceptor/MdmSearchExpandingInterceptorIT.java +++ b/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/interceptor/MdmSearchExpandingInterceptorIT.java @@ -2,14 +2,18 @@ package ca.uhn.fhir.jpa.mdm.interceptor; import ca.uhn.fhir.jpa.api.config.DaoConfig; import ca.uhn.fhir.jpa.api.model.DaoMethodOutcome; +import ca.uhn.fhir.jpa.entity.MdmLink; import ca.uhn.fhir.jpa.mdm.BaseMdmR4Test; import ca.uhn.fhir.jpa.mdm.helper.MdmHelperConfig; import ca.uhn.fhir.jpa.mdm.helper.MdmHelperR4; import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; import ca.uhn.fhir.mdm.api.MdmConstants; import ca.uhn.fhir.rest.api.server.IBundleProvider; +import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; import ca.uhn.fhir.rest.param.ReferenceOrListParam; import ca.uhn.fhir.rest.param.ReferenceParam; +import org.elasticsearch.common.collect.Set; +import org.hl7.fhir.instance.model.api.IIdType; import org.hl7.fhir.r4.model.CodeableConcept; import org.hl7.fhir.r4.model.Observation; import org.hl7.fhir.r4.model.Patient; @@ -21,6 +25,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; +import java.util.List; + import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.is; @@ -73,6 +79,19 @@ public class MdmSearchExpandingInterceptorIT extends BaseMdmR4Test { myDaoConfig.setAllowMdmExpansion(true); search = myObservationDao.search(searchParameterMap); assertThat(search.size(), is(equalTo(4))); + List all = myMdmLinkDao.findAll(); + Long goldenPid = all.get(0).getGoldenResourcePid(); + IIdType goldenId = myIdHelperService.translatePidIdToForcedId(myFhirContext, "Patient", new ResourcePersistentId(goldenPid)); + //Verify that expansion by the golden resource id resolves down to everything its links have. + + SearchParameterMap goldenSpMap = new SearchParameterMap(); + goldenSpMap.setLoadSynchronous(true); + ReferenceOrListParam goldenReferenceOrListParam = new ReferenceOrListParam(); + goldenReferenceOrListParam.addOr(new ReferenceParam(goldenId).setMdmExpand(true)); + goldenSpMap.add(Observation.SP_SUBJECT, goldenReferenceOrListParam); + + search = myObservationDao.search(goldenSpMap); + assertThat(search.size(), is(equalTo(4))); } @Test diff --git a/hapi-fhir-jpaserver-migrate/pom.xml b/hapi-fhir-jpaserver-migrate/pom.xml index 0495379d845..549dda66e65 100644 --- a/hapi-fhir-jpaserver-migrate/pom.xml +++ b/hapi-fhir-jpaserver-migrate/pom.xml @@ -4,7 +4,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 5.6.0-PRE1-SNAPSHOT + 5.6.0-PRE2-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jpaserver-model/pom.xml b/hapi-fhir-jpaserver-model/pom.xml index e45927d92e7..2329c0873f6 100644 --- a/hapi-fhir-jpaserver-model/pom.xml +++ b/hapi-fhir-jpaserver-model/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 5.6.0-PRE1-SNAPSHOT + 5.6.0-PRE2-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jpaserver-searchparam/pom.xml b/hapi-fhir-jpaserver-searchparam/pom.xml index db117accac4..1e10aec0e32 100755 --- a/hapi-fhir-jpaserver-searchparam/pom.xml +++ b/hapi-fhir-jpaserver-searchparam/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 5.6.0-PRE1-SNAPSHOT + 5.6.0-PRE2-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/SearchParameterMap.java b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/SearchParameterMap.java index 92c7d29a1aa..4ad522cf3be 100644 --- a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/SearchParameterMap.java +++ b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/SearchParameterMap.java @@ -511,6 +511,15 @@ public class SearchParameterMap implements Serializable { b.append(getSearchTotalMode().getCode()); } + //Contained mode + //For some reason, instead of null here, we default to false. That said, ommitting it is identical to setting it to false. + if (getSearchContainedMode() != SearchContainedModeEnum.FALSE) { + addUrlParamSeparator(b); + b.append(Constants.PARAM_CONTAINED); + b.append("="); + b.append(getSearchContainedMode().getCode()); + } + if (b.length() == 0) { b.append('?'); } diff --git a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/BaseSearchParamExtractor.java b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/BaseSearchParamExtractor.java index 0a1283f8027..3315670f03a 100644 --- a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/BaseSearchParamExtractor.java +++ b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/BaseSearchParamExtractor.java @@ -78,6 +78,7 @@ import java.util.Collections; import java.util.Date; import java.util.HashSet; import java.util.List; +import java.util.Objects; import java.util.Optional; import java.util.Set; import java.util.TreeSet; @@ -964,6 +965,18 @@ public abstract class BaseSearchParamExtractor implements ISearchParamExtractor return retVal; } + + /** + * Helper function to determine if a set of SPs for a resource uses a resolve as part of its fhir path. + */ + private boolean anySearchParameterUsesResolve(Collection searchParams, RestSearchParameterTypeEnum theSearchParamType) { + return searchParams.stream() + .filter(param -> param.getParamType() != theSearchParamType) + .map(RuntimeSearchParam::getPath) + .filter(Objects::nonNull) + .anyMatch(path-> path.contains("resolve")); + } + /** * HAPI FHIR Reference objects (e.g. {@link org.hl7.fhir.r4.model.Reference}) can hold references either by text * (e.g. "#3") or by resource (e.g. "new Reference(patientInstance)"). The FHIRPath evaluator only understands the @@ -974,17 +987,12 @@ public abstract class BaseSearchParamExtractor implements ISearchParamExtractor * if we think there's actually a chance */ private void cleanUpContainedResourceReferences(IBaseResource theResource, RestSearchParameterTypeEnum theSearchParamType, Collection searchParams) { - boolean havePathWithResolveExpression = myModelConfig.isIndexOnContainedResources(); - for (RuntimeSearchParam nextSpDef : searchParams) { - if (nextSpDef.getParamType() != theSearchParamType) { - continue; - } - if (defaultString(nextSpDef.getPath()).contains("resolve")) { - havePathWithResolveExpression = true; - break; - } - } + boolean havePathWithResolveExpression = + myModelConfig.isIndexOnContainedResources() + || anySearchParameterUsesResolve(searchParams, theSearchParamType); + if (havePathWithResolveExpression) { + //TODO GGG/JA: At this point, if the Task.basedOn.reference.resource does _not_ have an ID, we will attempt to contain it internally. Wild myContext.newTerser().containResources(theResource, FhirTerser.OptionsEnum.MODIFY_RESOURCE, FhirTerser.OptionsEnum.STORE_AND_REUSE_RESULTS); } } diff --git a/hapi-fhir-jpaserver-subscription/pom.xml b/hapi-fhir-jpaserver-subscription/pom.xml index 2e902e31136..97181675c03 100644 --- a/hapi-fhir-jpaserver-subscription/pom.xml +++ b/hapi-fhir-jpaserver-subscription/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 5.6.0-PRE1-SNAPSHOT + 5.6.0-PRE2-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jpaserver-test-utilities/pom.xml b/hapi-fhir-jpaserver-test-utilities/pom.xml index 9dedd18cbe1..c1f8822b95b 100644 --- a/hapi-fhir-jpaserver-test-utilities/pom.xml +++ b/hapi-fhir-jpaserver-test-utilities/pom.xml @@ -6,7 +6,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 5.6.0-PRE1-SNAPSHOT + 5.6.0-PRE2-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jpaserver-uhnfhirtest/pom.xml b/hapi-fhir-jpaserver-uhnfhirtest/pom.xml index 95f27c3e3d4..51f3502fe96 100644 --- a/hapi-fhir-jpaserver-uhnfhirtest/pom.xml +++ b/hapi-fhir-jpaserver-uhnfhirtest/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-fhir - 5.6.0-PRE1-SNAPSHOT + 5.6.0-PRE2-SNAPSHOT ../pom.xml diff --git a/hapi-fhir-server-mdm/pom.xml b/hapi-fhir-server-mdm/pom.xml index a8d1d926e16..fcfdafec802 100644 --- a/hapi-fhir-server-mdm/pom.xml +++ b/hapi-fhir-server-mdm/pom.xml @@ -7,7 +7,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 5.6.0-PRE1-SNAPSHOT + 5.6.0-PRE2-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-server-openapi/pom.xml b/hapi-fhir-server-openapi/pom.xml index 6e160bdbb80..f2ad8061c43 100644 --- a/hapi-fhir-server-openapi/pom.xml +++ b/hapi-fhir-server-openapi/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 5.6.0-PRE1-SNAPSHOT + 5.6.0-PRE2-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-server-openapi/src/main/java/ca/uhn/fhir/rest/openapi/OpenApiInterceptor.java b/hapi-fhir-server-openapi/src/main/java/ca/uhn/fhir/rest/openapi/OpenApiInterceptor.java index 0b0a105e80f..7caad2dbb78 100644 --- a/hapi-fhir-server-openapi/src/main/java/ca/uhn/fhir/rest/openapi/OpenApiInterceptor.java +++ b/hapi-fhir-server-openapi/src/main/java/ca/uhn/fhir/rest/openapi/OpenApiInterceptor.java @@ -57,8 +57,8 @@ import io.swagger.v3.oas.models.responses.ApiResponses; import io.swagger.v3.oas.models.servers.Server; import io.swagger.v3.oas.models.tags.Tag; import org.apache.commons.io.IOUtils; -import org.hl7.fhir.convertors.VersionConvertor_30_40; -import org.hl7.fhir.convertors.VersionConvertor_40_50; +import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_40; +import org.hl7.fhir.convertors.factory.VersionConvertorFactory_40_50; import org.hl7.fhir.instance.model.api.IBaseConformance; import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.instance.model.api.IPrimitiveType; @@ -78,7 +78,6 @@ import org.thymeleaf.IEngineConfiguration; import org.thymeleaf.TemplateEngine; import org.thymeleaf.cache.AlwaysValidCacheEntryValidity; import org.thymeleaf.cache.ICacheEntryValidity; -import org.thymeleaf.cache.NonCacheableCacheEntryValidity; import org.thymeleaf.context.IExpressionContext; import org.thymeleaf.context.WebContext; import org.thymeleaf.linkbuilder.AbstractLinkBuilder; @@ -386,6 +385,7 @@ public class OpenApiInterceptor { Paths paths = new Paths(); openApi.setPaths(paths); + if (page == null || page.equals(PAGE_SYSTEM) || page.equals(PAGE_ALL)) { Tag serverTag = new Tag(); serverTag.setName(PAGE_SYSTEM); @@ -398,7 +398,6 @@ public class OpenApiInterceptor { addFhirResourceResponse(ctx, openApi, capabilitiesOperation, "CapabilityStatement"); Set systemInteractions = cs.getRestFirstRep().getInteraction().stream().map(t -> t.getCode()).collect(Collectors.toSet()); - // Transaction Operation if (systemInteractions.contains(CapabilityStatement.SystemRestfulInteraction.TRANSACTION) || systemInteractions.contains(CapabilityStatement.SystemRestfulInteraction.BATCH)) { Operation transaction = getPathItem(paths, "/", PathItem.HttpMethod.POST); @@ -743,8 +742,9 @@ public class OpenApiInterceptor { } } - private Operation getPathItem(Paths thePaths, String thePath, PathItem.HttpMethod theMethod) { + protected Operation getPathItem(Paths thePaths, String thePath, PathItem.HttpMethod theMethod) { PathItem pathItem; + if (thePaths.containsKey(thePath)) { pathItem = thePaths.get(thePath); } else { @@ -909,9 +909,9 @@ public class OpenApiInterceptor { private static T toCanonicalVersion(IBaseResource theNonCanonical) { IBaseResource canonical; if (theNonCanonical instanceof org.hl7.fhir.dstu3.model.Resource) { - canonical = VersionConvertor_30_40.convertResource((org.hl7.fhir.dstu3.model.Resource) theNonCanonical, true); + canonical = VersionConvertorFactory_30_40.convertResource((org.hl7.fhir.dstu3.model.Resource) theNonCanonical); } else if (theNonCanonical instanceof org.hl7.fhir.r5.model.Resource) { - canonical = VersionConvertor_40_50.convertResource((org.hl7.fhir.r5.model.Resource) theNonCanonical); + canonical = VersionConvertorFactory_40_50.convertResource((org.hl7.fhir.r5.model.Resource) theNonCanonical); } else { canonical = theNonCanonical; } diff --git a/hapi-fhir-server/pom.xml b/hapi-fhir-server/pom.xml index 52962612686..a559df05560 100644 --- a/hapi-fhir-server/pom.xml +++ b/hapi-fhir-server/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 5.6.0-PRE1-SNAPSHOT + 5.6.0-PRE2-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/mail/MailConfig.java b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/mail/MailConfig.java index 02bb16f9fdc..2202f27b77e 100644 --- a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/mail/MailConfig.java +++ b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/mail/MailConfig.java @@ -1,5 +1,25 @@ package ca.uhn.fhir.rest.server.mail; +/*- + * #%L + * HAPI FHIR - Server Framework + * %% + * Copyright (C) 2014 - 2021 Smile CDR, Inc. + * %% + * 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.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; diff --git a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/mail/MailSvc.java b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/mail/MailSvc.java index 5c87c4256dd..df1cd4e9dca 100644 --- a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/mail/MailSvc.java +++ b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/mail/MailSvc.java @@ -1,5 +1,25 @@ package ca.uhn.fhir.rest.server.mail; +/*- + * #%L + * HAPI FHIR - Server Framework + * %% + * Copyright (C) 2014 - 2021 Smile CDR, Inc. + * %% + * 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.apache.commons.lang3.Validate; import org.simplejavamail.MailException; import org.simplejavamail.api.email.Email; diff --git a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/provider/BaseMultiUrlProcessor.java b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/provider/BaseMultiUrlProcessor.java index 40c7564410a..ea54a3ca693 100644 --- a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/provider/BaseMultiUrlProcessor.java +++ b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/provider/BaseMultiUrlProcessor.java @@ -27,10 +27,10 @@ import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; import ca.uhn.fhir.util.ParametersUtil; import org.hl7.fhir.instance.model.api.IBaseParameters; import org.hl7.fhir.instance.model.api.IPrimitiveType; -import org.jetbrains.annotations.Nullable; import org.springframework.batch.core.JobExecution; import org.springframework.batch.core.JobParametersInvalidException; +import javax.annotation.Nullable; import java.math.BigDecimal; import java.util.List; diff --git a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/provider/ReindexProvider.java b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/provider/ReindexProvider.java index 587e5caf999..23c57be0b3a 100644 --- a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/provider/ReindexProvider.java +++ b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/provider/ReindexProvider.java @@ -29,10 +29,10 @@ import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; import ca.uhn.fhir.util.ParametersUtil; import org.hl7.fhir.instance.model.api.IBaseParameters; import org.hl7.fhir.instance.model.api.IPrimitiveType; -import org.jetbrains.annotations.Nullable; import org.springframework.batch.core.JobExecution; import org.springframework.batch.core.JobParametersInvalidException; +import javax.annotation.Nullable; import java.math.BigDecimal; import java.util.List; import java.util.stream.Collectors; diff --git a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-autoconfigure/pom.xml b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-autoconfigure/pom.xml index 0f08f769abc..9e99e253301 100644 --- a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-autoconfigure/pom.xml +++ b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-autoconfigure/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 5.6.0-PRE1-SNAPSHOT + 5.6.0-PRE2-SNAPSHOT ../../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-client-apache/pom.xml b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-client-apache/pom.xml index 7bf3fb61ff3..add47835990 100644 --- a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-client-apache/pom.xml +++ b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-client-apache/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-fhir-spring-boot-samples - 5.6.0-PRE1-SNAPSHOT + 5.6.0-PRE2-SNAPSHOT hapi-fhir-spring-boot-sample-client-apache diff --git a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-client-okhttp/pom.xml b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-client-okhttp/pom.xml index 9a1f75a753c..c447df7668e 100644 --- a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-client-okhttp/pom.xml +++ b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-client-okhttp/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-fhir-spring-boot-samples - 5.6.0-PRE1-SNAPSHOT + 5.6.0-PRE2-SNAPSHOT hapi-fhir-spring-boot-sample-client-okhttp diff --git a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-server-jersey/pom.xml b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-server-jersey/pom.xml index 5c2f70575c4..526933dc09e 100644 --- a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-server-jersey/pom.xml +++ b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-server-jersey/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-fhir-spring-boot-samples - 5.6.0-PRE1-SNAPSHOT + 5.6.0-PRE2-SNAPSHOT hapi-fhir-spring-boot-sample-server-jersey diff --git a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/pom.xml b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/pom.xml index fa33082ade9..6bcafa300e8 100644 --- a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/pom.xml +++ b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-fhir-spring-boot - 5.6.0-PRE1-SNAPSHOT + 5.6.0-PRE2-SNAPSHOT hapi-fhir-spring-boot-samples diff --git a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-starter/pom.xml b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-starter/pom.xml index 22c97daad3c..93232ddab59 100644 --- a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-starter/pom.xml +++ b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-starter/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 5.6.0-PRE1-SNAPSHOT + 5.6.0-PRE2-SNAPSHOT ../../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-spring-boot/pom.xml b/hapi-fhir-spring-boot/pom.xml index cd1f7aa48c9..a04306dfeb6 100644 --- a/hapi-fhir-spring-boot/pom.xml +++ b/hapi-fhir-spring-boot/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-fhir - 5.6.0-PRE1-SNAPSHOT + 5.6.0-PRE2-SNAPSHOT ../pom.xml diff --git a/hapi-fhir-structures-dstu2.1/pom.xml b/hapi-fhir-structures-dstu2.1/pom.xml index 39b761b9b38..f0f14d0d96e 100644 --- a/hapi-fhir-structures-dstu2.1/pom.xml +++ b/hapi-fhir-structures-dstu2.1/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 5.6.0-PRE1-SNAPSHOT + 5.6.0-PRE2-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-structures-dstu2/pom.xml b/hapi-fhir-structures-dstu2/pom.xml index 5b137f3a214..b007972e5e4 100644 --- a/hapi-fhir-structures-dstu2/pom.xml +++ b/hapi-fhir-structures-dstu2/pom.xml @@ -4,7 +4,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 5.6.0-PRE1-SNAPSHOT + 5.6.0-PRE2-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-structures-dstu3/pom.xml b/hapi-fhir-structures-dstu3/pom.xml index 4a0bbf0f03e..b96f7bb77eb 100644 --- a/hapi-fhir-structures-dstu3/pom.xml +++ b/hapi-fhir-structures-dstu3/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 5.6.0-PRE1-SNAPSHOT + 5.6.0-PRE2-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-structures-hl7org-dstu2/pom.xml b/hapi-fhir-structures-hl7org-dstu2/pom.xml index 0c366ce804f..4530c889d95 100644 --- a/hapi-fhir-structures-hl7org-dstu2/pom.xml +++ b/hapi-fhir-structures-hl7org-dstu2/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 5.6.0-PRE1-SNAPSHOT + 5.6.0-PRE2-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-structures-r4/pom.xml b/hapi-fhir-structures-r4/pom.xml index d89aec7f1fc..547c81b936a 100644 --- a/hapi-fhir-structures-r4/pom.xml +++ b/hapi-fhir-structures-r4/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 5.6.0-PRE1-SNAPSHOT + 5.6.0-PRE2-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-structures-r5/pom.xml b/hapi-fhir-structures-r5/pom.xml index 9d05be5eb39..4400f91fe15 100644 --- a/hapi-fhir-structures-r5/pom.xml +++ b/hapi-fhir-structures-r5/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 5.6.0-PRE1-SNAPSHOT + 5.6.0-PRE2-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-structures-r5/src/main/java/org/hl7/fhir/r5/hapi/ctx/HapiWorkerContext.java b/hapi-fhir-structures-r5/src/main/java/org/hl7/fhir/r5/hapi/ctx/HapiWorkerContext.java index 52fe6b9e482..06d22963f65 100644 --- a/hapi-fhir-structures-r5/src/main/java/org/hl7/fhir/r5/hapi/ctx/HapiWorkerContext.java +++ b/hapi-fhir-structures-r5/src/main/java/org/hl7/fhir/r5/hapi/ctx/HapiWorkerContext.java @@ -398,8 +398,8 @@ public final class HapiWorkerContext extends I18nBase implements IWorkerContext } @Override - public void cachePackage(PackageVersion packageDetails, List dependencies) { - throw new UnsupportedOperationException(); + public void cachePackage(PackageDetails packageDetails, List list) { + } @Override @@ -442,6 +442,16 @@ public final class HapiWorkerContext extends I18nBase implements IWorkerContext throw new UnsupportedOperationException(); } + @Override + public boolean hasPackage(PackageVersion packageVersion) { + return false; + } + + @Override + public PackageDetails getPackage(PackageVersion packageVersion) { + return null; + } + @Override public int getClientRetryCount() { throw new UnsupportedOperationException(); @@ -457,6 +467,11 @@ public final class HapiWorkerContext extends I18nBase implements IWorkerContext return null; } + @Override + public PackageVersion getPackageForUrl(String s) { + return null; + } + public static ConceptValidationOptions convertConceptValidationOptions(ValidationOptions theOptions) { ConceptValidationOptions retVal = new ConceptValidationOptions(); if (theOptions.isGuessSystem()) { diff --git a/hapi-fhir-test-utilities/pom.xml b/hapi-fhir-test-utilities/pom.xml index 784284a5beb..a7004891daf 100644 --- a/hapi-fhir-test-utilities/pom.xml +++ b/hapi-fhir-test-utilities/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 5.6.0-PRE1-SNAPSHOT + 5.6.0-PRE2-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-testpage-overlay/pom.xml b/hapi-fhir-testpage-overlay/pom.xml index 991c02e9a1e..3d4ecc1f4e4 100644 --- a/hapi-fhir-testpage-overlay/pom.xml +++ b/hapi-fhir-testpage-overlay/pom.xml @@ -4,7 +4,7 @@ ca.uhn.hapi.fhir hapi-fhir - 5.6.0-PRE1-SNAPSHOT + 5.6.0-PRE2-SNAPSHOT ../pom.xml diff --git a/hapi-fhir-validation-resources-dstu2.1/pom.xml b/hapi-fhir-validation-resources-dstu2.1/pom.xml index 15a9ae79b4a..972e01c812c 100644 --- a/hapi-fhir-validation-resources-dstu2.1/pom.xml +++ b/hapi-fhir-validation-resources-dstu2.1/pom.xml @@ -4,7 +4,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 5.6.0-PRE1-SNAPSHOT + 5.6.0-PRE2-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-validation-resources-dstu2/pom.xml b/hapi-fhir-validation-resources-dstu2/pom.xml index 6095a55f994..a0956c5ddb3 100644 --- a/hapi-fhir-validation-resources-dstu2/pom.xml +++ b/hapi-fhir-validation-resources-dstu2/pom.xml @@ -4,7 +4,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 5.6.0-PRE1-SNAPSHOT + 5.6.0-PRE2-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-validation-resources-dstu3/pom.xml b/hapi-fhir-validation-resources-dstu3/pom.xml index f9357e9da9e..c7a59822801 100644 --- a/hapi-fhir-validation-resources-dstu3/pom.xml +++ b/hapi-fhir-validation-resources-dstu3/pom.xml @@ -4,7 +4,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 5.6.0-PRE1-SNAPSHOT + 5.6.0-PRE2-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-validation-resources-r4/pom.xml b/hapi-fhir-validation-resources-r4/pom.xml index 0c409535855..8457e1aebf8 100644 --- a/hapi-fhir-validation-resources-r4/pom.xml +++ b/hapi-fhir-validation-resources-r4/pom.xml @@ -4,7 +4,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 5.6.0-PRE1-SNAPSHOT + 5.6.0-PRE2-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-validation-resources-r5/pom.xml b/hapi-fhir-validation-resources-r5/pom.xml index 5354eaacce7..3467c240d86 100644 --- a/hapi-fhir-validation-resources-r5/pom.xml +++ b/hapi-fhir-validation-resources-r5/pom.xml @@ -4,7 +4,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 5.6.0-PRE1-SNAPSHOT + 5.6.0-PRE2-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-validation/pom.xml b/hapi-fhir-validation/pom.xml index ed265396810..50945ea7032 100644 --- a/hapi-fhir-validation/pom.xml +++ b/hapi-fhir-validation/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 5.6.0-PRE1-SNAPSHOT + 5.6.0-PRE2-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/support/BaseValidationSupportWrapper.java b/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/support/BaseValidationSupportWrapper.java index fb92318e462..00bd9e75ccb 100644 --- a/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/support/BaseValidationSupportWrapper.java +++ b/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/support/BaseValidationSupportWrapper.java @@ -67,8 +67,8 @@ public class BaseValidationSupportWrapper extends BaseValidationSupport { } @Override - public LookupCodeResult lookupCode(ValidationSupportContext theValidationSupportContext, String theSystem, String theCode) { - return myWrap.lookupCode(theValidationSupportContext, theSystem, theCode); + public LookupCodeResult lookupCode(ValidationSupportContext theValidationSupportContext, String theSystem, String theCode, String theDisplayLanguage) { + return myWrap.lookupCode(theValidationSupportContext, theSystem, theCode, theDisplayLanguage); } @Override diff --git a/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/support/CachingValidationSupport.java b/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/support/CachingValidationSupport.java index 45e5cdb174c..ba5a427ab36 100644 --- a/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/support/CachingValidationSupport.java +++ b/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/support/CachingValidationSupport.java @@ -111,9 +111,9 @@ public class CachingValidationSupport extends BaseValidationSupportWrapper imple } @Override - public LookupCodeResult lookupCode(ValidationSupportContext theValidationSupportContext, String theSystem, String theCode) { + public LookupCodeResult lookupCode(ValidationSupportContext theValidationSupportContext, String theSystem, String theCode, String theDisplayLanguage) { String key = "lookupCode " + theSystem + " " + theCode; - return loadFromCache(myLookupCodeCache, key, t -> super.lookupCode(theValidationSupportContext, theSystem, theCode)); + return loadFromCache(myLookupCodeCache, key, t -> super.lookupCode(theValidationSupportContext, theSystem, theCode, theDisplayLanguage)); } @Override diff --git a/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/support/CommonCodeSystemsTerminologyService.java b/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/support/CommonCodeSystemsTerminologyService.java index 26cb318293c..f4891ed7398 100644 --- a/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/support/CommonCodeSystemsTerminologyService.java +++ b/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/support/CommonCodeSystemsTerminologyService.java @@ -15,8 +15,10 @@ import org.apache.commons.lang3.Validate; import org.fhir.ucum.UcumEssenceService; import org.fhir.ucum.UcumException; import org.hl7.fhir.common.hapi.validation.validator.VersionSpecificWorkerContextWrapper; -import org.hl7.fhir.convertors.VersionConvertor_30_40; -import org.hl7.fhir.convertors.VersionConvertor_40_50; +import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_30_40; +import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_40_50; +import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_40; +import org.hl7.fhir.convertors.factory.VersionConvertorFactory_40_50; import org.hl7.fhir.dstu2.model.ValueSet; import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.r4.model.CodeSystem; @@ -209,7 +211,7 @@ public class CommonCodeSystemsTerminologyService implements IValidationSupport { @Override - public LookupCodeResult lookupCode(ValidationSupportContext theValidationSupportContext, String theSystem, String theCode) { + public LookupCodeResult lookupCode(ValidationSupportContext theValidationSupportContext, String theSystem, String theCode, String theDisplayLanguage) { Map map; switch (theSystem) { @@ -255,69 +257,100 @@ public class CommonCodeSystemsTerminologyService implements IValidationSupport { Map languagesMap = myLanguagesLanugageMap; Map regionsMap = myLanguagesRegionMap; if (languagesMap == null || regionsMap == null) { + initializeBcp47LanguageMap(); + } - ourLog.info("Loading BCP47 Language Registry"); + int langRegionSeparatorIndex = StringUtils.indexOfAny(theCode, '-', '_'); + boolean hasRegionAndCodeSegments = langRegionSeparatorIndex > 0; + String language; + String region; - String input = ClasspathUtil.loadResource("org/hl7/fhir/common/hapi/validation/support/registry.json"); - ArrayNode map; - try { - map = (ArrayNode) new ObjectMapper().readTree(input); - } catch (JsonProcessingException e) { - throw new ConfigurationException(e); + if (hasRegionAndCodeSegments) { + language = myLanguagesLanugageMap.get(theCode.substring(0, langRegionSeparatorIndex)); + region = myLanguagesRegionMap.get(theCode.substring(langRegionSeparatorIndex + 1)); + + if (language == null || region == null) { + //In case the user provides both a language and a region, they must both be valid for the lookup to succeed. + ourLog.warn("Couldn't find a valid bcp47 language-region combination from code: {}", theCode); + return buildNotFoundLookupCodeResult(theCode); + } else { + return buildLookupResultForLanguageAndRegion(theCode, language, region); } - - languagesMap = new HashMap<>(); - regionsMap = new HashMap<>(); - - for (int i = 0; i < map.size(); i++) { - ObjectNode next = (ObjectNode) map.get(i); - String type = next.get("Type").asText(); - if ("language".equals(type)) { - String language = next.get("Subtag").asText(); - ArrayNode descriptions = (ArrayNode) next.get("Description"); - String description = null; - if (descriptions.size() > 0) { - description = descriptions.get(0).asText(); - } - languagesMap.put(language, description); - } - if ("region".equals(type)) { - String region = next.get("Subtag").asText(); - ArrayNode descriptions = (ArrayNode) next.get("Description"); - String description = null; - if (descriptions.size() > 0) { - description = descriptions.get(0).asText(); - } - regionsMap.put(region, description); - } - + } else { + //In case user has only provided a language, we build the lookup from only that. + language = myLanguagesLanugageMap.get(theCode); + if (language == null) { + ourLog.warn("Couldn't find a valid bcp47 language from code: {}", theCode); + return buildNotFoundLookupCodeResult(theCode); + } else { + return buildLookupResultForLanguage(theCode, language); } + } + } + private LookupCodeResult buildLookupResultForLanguageAndRegion(@Nonnull String theOriginalCode, @Nonnull String theLanguage, @Nonnull String theRegion) { + LookupCodeResult lookupCodeResult = buildNotFoundLookupCodeResult(theOriginalCode); + lookupCodeResult.setCodeDisplay(theLanguage + " " + theRegion); + lookupCodeResult.setFound(true); + return lookupCodeResult; + } + private LookupCodeResult buildLookupResultForLanguage(@Nonnull String theOriginalCode, @Nonnull String theLanguage) { + LookupCodeResult lookupCodeResult = buildNotFoundLookupCodeResult(theOriginalCode); + lookupCodeResult.setCodeDisplay(theLanguage); + lookupCodeResult.setFound(true); + return lookupCodeResult; + } - ourLog.info("Have {} languages and {} regions", languagesMap.size(), regionsMap.size()); + private LookupCodeResult buildNotFoundLookupCodeResult(@Nonnull String theOriginalCode) { + LookupCodeResult lookupCodeResult = new LookupCodeResult(); + lookupCodeResult.setFound(false); + lookupCodeResult.setSearchedForSystem(LANGUAGES_CODESYSTEM_URL); + lookupCodeResult.setSearchedForCode(theOriginalCode); + return lookupCodeResult; + } - myLanguagesLanugageMap = languagesMap; - myLanguagesRegionMap = regionsMap; + private void initializeBcp47LanguageMap() { + Map regionsMap; + Map languagesMap; + ourLog.info("Loading BCP47 Language Registry"); + + String input = ClasspathUtil.loadResource("org/hl7/fhir/common/hapi/validation/support/registry.json"); + ArrayNode map; + try { + map = (ArrayNode) new ObjectMapper().readTree(input); + } catch (JsonProcessingException e) { + throw new ConfigurationException(e); } - int idx = StringUtils.indexOfAny(theCode, '-', '_'); - String language = null; - String region = null; - if (idx > 0) { - language = languagesMap.get(theCode.substring(0, idx)); - region = regionsMap.get(theCode.substring(idx + 1)); + languagesMap = new HashMap<>(); + regionsMap = new HashMap<>(); + + for (int i = 0; i < map.size(); i++) { + ObjectNode next = (ObjectNode) map.get(i); + String type = next.get("Type").asText(); + if ("language".equals(type)) { + String language = next.get("Subtag").asText(); + ArrayNode descriptions = (ArrayNode) next.get("Description"); + String description = null; + if (descriptions.size() > 0) { + description = descriptions.get(0).asText(); + } + languagesMap.put(language, description); + } + if ("region".equals(type)) { + String region = next.get("Subtag").asText(); + ArrayNode descriptions = (ArrayNode) next.get("Description"); + String description = null; + if (descriptions.size() > 0) { + description = descriptions.get(0).asText(); + } + regionsMap.put(region, description); + } } - LookupCodeResult retVal = new LookupCodeResult(); - retVal.setSearchedForCode(theCode); - retVal.setSearchedForSystem(LANGUAGES_CODESYSTEM_URL); + ourLog.info("Have {} languages and {} regions", languagesMap.size(), regionsMap.size()); - if (language != null && region != null) { - String display = language + " " + region; - retVal.setFound(true); - retVal.setCodeDisplay(display); - } - - return retVal; + myLanguagesLanugageMap = languagesMap; + myLanguagesRegionMap = regionsMap; } @Nonnull @@ -381,13 +414,13 @@ public class CommonCodeSystemsTerminologyService implements IValidationSupport { case DSTU2_1: return null; case DSTU3: - normalized = VersionConvertor_30_40.convertResource(retVal, false); + normalized = VersionConvertorFactory_30_40.convertResource(retVal, new BaseAdvisor_30_40(false)); break; case R4: normalized = retVal; break; case R5: - normalized = VersionConvertor_40_50.convertResource(retVal); + normalized = VersionConvertorFactory_40_50.convertResource(retVal, new BaseAdvisor_40_50(false)); break; } diff --git a/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/support/InMemoryTerminologyServerValidationSupport.java b/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/support/InMemoryTerminologyServerValidationSupport.java index 28d2407fb33..810414aaa2b 100644 --- a/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/support/InMemoryTerminologyServerValidationSupport.java +++ b/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/support/InMemoryTerminologyServerValidationSupport.java @@ -9,11 +9,12 @@ import ca.uhn.fhir.context.support.ValueSetExpansionOptions; import ca.uhn.fhir.parser.IParser; import ca.uhn.fhir.util.FhirVersionIndependentConcept; import org.apache.commons.lang3.Validate; -import org.hl7.fhir.convertors.conv10_50.ValueSet10_50; -import org.hl7.fhir.convertors.conv30_50.CodeSystem30_50; -import org.hl7.fhir.convertors.conv30_50.ValueSet30_50; -import org.hl7.fhir.convertors.conv40_50.CodeSystem40_50; -import org.hl7.fhir.convertors.conv40_50.ValueSet40_50; +import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_50; +import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_30_50; +import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_40_50; +import org.hl7.fhir.convertors.factory.VersionConvertorFactory_10_50; +import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_50; +import org.hl7.fhir.convertors.factory.VersionConvertorFactory_40_50; import org.hl7.fhir.dstu2.model.ValueSet; import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.instance.model.api.IPrimitiveType; @@ -67,15 +68,15 @@ public class InMemoryTerminologyServerValidationSupport implements IValidationSu IBaseResource expansion; switch (myCtx.getVersion().getVersion()) { case DSTU2_HL7ORG: { - expansion = ValueSet10_50.convertValueSet(expansionR5); + expansion = VersionConvertorFactory_10_50.convertResource(expansionR5, new BaseAdvisor_10_50(false)); break; } case DSTU3: { - expansion = ValueSet30_50.convertValueSet(expansionR5); + expansion = VersionConvertorFactory_30_50.convertResource(expansionR5, new BaseAdvisor_30_50(false)); break; } case R4: { - expansion = ValueSet40_50.convertValueSet(expansionR5); + expansion = VersionConvertorFactory_40_50.convertResource(expansionR5, new BaseAdvisor_40_50(false)); break; } case R5: { @@ -344,7 +345,7 @@ public class InMemoryTerminologyServerValidationSupport implements IValidationSu } @Override - public LookupCodeResult lookupCode(ValidationSupportContext theValidationSupportContext, String theSystem, String theCode) { + public LookupCodeResult lookupCode(ValidationSupportContext theValidationSupportContext, String theSystem, String theCode, String theDisplayLanguage) { return validateCode(theValidationSupportContext, new ConceptValidationOptions(), theSystem, theCode, null, null).asLookupCodeResult(theSystem, theCode); } @@ -358,10 +359,10 @@ public class InMemoryTerminologyServerValidationSupport implements IValidationSu }; Function valueSetLoader = t -> { org.hl7.fhir.dstu2.model.ValueSet valueSet = (org.hl7.fhir.dstu2.model.ValueSet) theValidationSupportContext.getRootValidationSupport().fetchValueSet(t); - return ValueSet10_50.convertValueSet(valueSet); + return (org.hl7.fhir.r5.model.ValueSet) VersionConvertorFactory_10_50.convertResource(valueSet, new BaseAdvisor_10_50(false)); }; - org.hl7.fhir.r5.model.ValueSet input = ValueSet10_50.convertValueSet(theInput); + org.hl7.fhir.r5.model.ValueSet input = (org.hl7.fhir.r5.model.ValueSet) VersionConvertorFactory_10_50.convertResource(theInput, new BaseAdvisor_10_50(false)); org.hl7.fhir.r5.model.ValueSet output = expandValueSetR5(theValidationSupportContext, input, codeSystemLoader, valueSetLoader, theWantSystemUrlAndVersion, theWantCode); return (output); } @@ -372,7 +373,6 @@ public class InMemoryTerminologyServerValidationSupport implements IValidationSu IParser parserHapi = FhirContext.forCached(FhirVersionEnum.DSTU2).newJsonParser(); Function codeSystemLoader = t -> { -// ca.uhn.fhir.model.dstu2.resource.ValueSet codeSystem = (ca.uhn.fhir.model.dstu2.resource.ValueSet) theValidationSupportContext.getRootValidationSupport().fetchCodeSystem(t); ca.uhn.fhir.model.dstu2.resource.ValueSet codeSystem = theInput; CodeSystem retVal = null; if (codeSystem != null) { @@ -385,11 +385,11 @@ public class InMemoryTerminologyServerValidationSupport implements IValidationSu Function valueSetLoader = t -> { ca.uhn.fhir.model.dstu2.resource.ValueSet valueSet = (ca.uhn.fhir.model.dstu2.resource.ValueSet) theValidationSupportContext.getRootValidationSupport().fetchValueSet(t); org.hl7.fhir.dstu2.model.ValueSet valueSetRi = parserRi.parseResource(org.hl7.fhir.dstu2.model.ValueSet.class, parserHapi.encodeResourceToString(valueSet)); - return ValueSet10_50.convertValueSet(valueSetRi); + return (org.hl7.fhir.r5.model.ValueSet) VersionConvertorFactory_10_50.convertResource(valueSetRi, new BaseAdvisor_10_50(false)); }; org.hl7.fhir.dstu2.model.ValueSet valueSetRi = parserRi.parseResource(org.hl7.fhir.dstu2.model.ValueSet.class, parserHapi.encodeResourceToString(theInput)); - org.hl7.fhir.r5.model.ValueSet input = ValueSet10_50.convertValueSet(valueSetRi); + org.hl7.fhir.r5.model.ValueSet input = (org.hl7.fhir.r5.model.ValueSet) VersionConvertorFactory_10_50.convertResource(valueSetRi, new BaseAdvisor_10_50(false)); org.hl7.fhir.r5.model.ValueSet output = expandValueSetR5(theValidationSupportContext, input, codeSystemLoader, valueSetLoader, theWantSystemUrlAndVersion, theWantCode); return (output); } @@ -442,14 +442,14 @@ public class InMemoryTerminologyServerValidationSupport implements IValidationSu private org.hl7.fhir.r5.model.ValueSet expandValueSetDstu3(ValidationSupportContext theValidationSupportContext, org.hl7.fhir.dstu3.model.ValueSet theInput, @Nullable String theWantSystemUrlAndVersion, @Nullable String theWantCode) { Function codeSystemLoader = t -> { org.hl7.fhir.dstu3.model.CodeSystem codeSystem = (org.hl7.fhir.dstu3.model.CodeSystem) theValidationSupportContext.getRootValidationSupport().fetchCodeSystem(t); - return CodeSystem30_50.convertCodeSystem(codeSystem); + return (CodeSystem) VersionConvertorFactory_30_50.convertResource(codeSystem, new BaseAdvisor_30_50(false)); }; Function valueSetLoader = t -> { org.hl7.fhir.dstu3.model.ValueSet valueSet = (org.hl7.fhir.dstu3.model.ValueSet) theValidationSupportContext.getRootValidationSupport().fetchValueSet(t); - return ValueSet30_50.convertValueSet(valueSet); + return (org.hl7.fhir.r5.model.ValueSet) VersionConvertorFactory_30_50.convertResource(valueSet, new BaseAdvisor_30_50(false)); }; - org.hl7.fhir.r5.model.ValueSet input = ValueSet30_50.convertValueSet(theInput); + org.hl7.fhir.r5.model.ValueSet input = (org.hl7.fhir.r5.model.ValueSet) VersionConvertorFactory_30_50.convertResource(theInput, new BaseAdvisor_30_50(false)); org.hl7.fhir.r5.model.ValueSet output = expandValueSetR5(theValidationSupportContext, input, codeSystemLoader, valueSetLoader, theWantSystemUrlAndVersion, theWantCode); return (output); } @@ -458,14 +458,14 @@ public class InMemoryTerminologyServerValidationSupport implements IValidationSu private org.hl7.fhir.r5.model.ValueSet expandValueSetR4(ValidationSupportContext theValidationSupportContext, org.hl7.fhir.r4.model.ValueSet theInput, @Nullable String theWantSystemUrlAndVersion, @Nullable String theWantCode) { Function codeSystemLoader = t -> { org.hl7.fhir.r4.model.CodeSystem codeSystem = (org.hl7.fhir.r4.model.CodeSystem) theValidationSupportContext.getRootValidationSupport().fetchCodeSystem(t); - return CodeSystem40_50.convertCodeSystem(codeSystem); + return (CodeSystem) VersionConvertorFactory_40_50.convertResource(codeSystem, new BaseAdvisor_40_50(false)); }; Function valueSetLoader = t -> { org.hl7.fhir.r4.model.ValueSet valueSet = (org.hl7.fhir.r4.model.ValueSet) theValidationSupportContext.getRootValidationSupport().fetchValueSet(t); - return ValueSet40_50.convertValueSet(valueSet); + return (org.hl7.fhir.r5.model.ValueSet) VersionConvertorFactory_40_50.convertResource(valueSet, new BaseAdvisor_40_50(false)); }; - org.hl7.fhir.r5.model.ValueSet input = ValueSet40_50.convertValueSet(theInput); + org.hl7.fhir.r5.model.ValueSet input = (org.hl7.fhir.r5.model.ValueSet) VersionConvertorFactory_40_50.convertResource(theInput, new BaseAdvisor_40_50(false)); org.hl7.fhir.r5.model.ValueSet output = expandValueSetR5(theValidationSupportContext, input, codeSystemLoader, valueSetLoader, theWantSystemUrlAndVersion, theWantCode); return (output); } @@ -550,7 +550,7 @@ public class InMemoryTerminologyServerValidationSupport implements IValidationSu if (theWantCode != null) { if (theValidationSupportContext.getRootValidationSupport().isCodeSystemSupported(theValidationSupportContext, includeOrExcludeConceptSystemUrl)) { - LookupCodeResult lookup = theValidationSupportContext.getRootValidationSupport().lookupCode(theValidationSupportContext, includeOrExcludeConceptSystemUrl, theWantCode); + LookupCodeResult lookup = theValidationSupportContext.getRootValidationSupport().lookupCode(theValidationSupportContext, includeOrExcludeConceptSystemUrl, theWantCode, null); if (lookup != null && lookup.isFound()) { CodeSystem.ConceptDefinitionComponent conceptDefinition = new CodeSystem.ConceptDefinitionComponent() .addConcept() diff --git a/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/support/ValidationSupportChain.java b/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/support/ValidationSupportChain.java index 68e01621741..e2cb4ea8b03 100644 --- a/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/support/ValidationSupportChain.java +++ b/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/support/ValidationSupportChain.java @@ -296,10 +296,10 @@ public class ValidationSupportChain implements IValidationSupport { } @Override - public LookupCodeResult lookupCode(ValidationSupportContext theValidationSupportContext, String theSystem, String theCode) { + public LookupCodeResult lookupCode(ValidationSupportContext theValidationSupportContext, String theSystem, String theCode, String theDisplayLanguage) { for (IValidationSupport next : myChain) { if (next.isCodeSystemSupported(theValidationSupportContext, theSystem)) { - return next.lookupCode(theValidationSupportContext, theSystem, theCode); + return next.lookupCode(theValidationSupportContext, theSystem, theCode, theDisplayLanguage); } } return null; diff --git a/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/validator/VersionSpecificWorkerContextWrapper.java b/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/validator/VersionSpecificWorkerContextWrapper.java index 19b9b3acfca..33233b1ae87 100644 --- a/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/validator/VersionSpecificWorkerContextWrapper.java +++ b/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/validator/VersionSpecificWorkerContextWrapper.java @@ -15,7 +15,8 @@ import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.time.DateUtils; import org.fhir.ucum.UcumService; -import org.hl7.fhir.convertors.VersionConvertor_10_50; +import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_50; +import org.hl7.fhir.convertors.factory.VersionConvertorFactory_10_50; import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.exceptions.TerminologyServiceException; import org.hl7.fhir.instance.model.api.IBaseResource; @@ -144,6 +145,16 @@ public class VersionSpecificWorkerContextWrapper extends I18nBase implements IWo throw new UnsupportedOperationException(); } + @Override + public boolean hasPackage(PackageVersion packageVersion) { + return false; + } + + @Override + public PackageDetails getPackage(PackageVersion packageVersion) { + return null; + } + @Override public int getClientRetryCount() { throw new UnsupportedOperationException(); @@ -159,6 +170,11 @@ public class VersionSpecificWorkerContextWrapper extends I18nBase implements IWo return null; } + @Override + public PackageVersion getPackageForUrl(String s) { + return null; + } + @Override public void generateSnapshot(StructureDefinition input) throws FHIRException { if (input.hasSnapshot()) { @@ -226,7 +242,7 @@ public class VersionSpecificWorkerContextWrapper extends I18nBase implements IWo } @Override - public void cachePackage(PackageVersion packageDetails, List dependencies) { + public void cachePackage(PackageDetails packageDetails, List list) { } @@ -676,7 +692,7 @@ public class VersionSpecificWorkerContextWrapper extends I18nBase implements IWo converter = new IVersionTypeConverter() { @Override public Resource toCanonical(IBaseResource theNonCanonical) { - Resource retVal = VersionConvertor_10_50.convertResource((org.hl7.fhir.dstu2.model.Resource) theNonCanonical); + Resource retVal = VersionConvertorFactory_10_50.convertResource((org.hl7.fhir.dstu2.model.Resource) theNonCanonical, new BaseAdvisor_10_50(false)); if (theNonCanonical instanceof org.hl7.fhir.dstu2.model.ValueSet) { org.hl7.fhir.dstu2.model.ValueSet valueSet = (org.hl7.fhir.dstu2.model.ValueSet) theNonCanonical; if (valueSet.hasCodeSystem() && valueSet.getCodeSystem().hasSystem()) { @@ -691,7 +707,7 @@ public class VersionSpecificWorkerContextWrapper extends I18nBase implements IWo @Override public IBaseResource fromCanonical(Resource theCanonical) { - return VersionConvertor_10_50.convertResource(theCanonical); + return VersionConvertorFactory_10_50.convertResource(theCanonical, new BaseAdvisor_10_50(false)); } }; break; diff --git a/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/validator/VersionTypeConverterDstu21.java b/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/validator/VersionTypeConverterDstu21.java index 8b0764876cd..4866ca246ae 100644 --- a/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/validator/VersionTypeConverterDstu21.java +++ b/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/validator/VersionTypeConverterDstu21.java @@ -1,17 +1,17 @@ package org.hl7.fhir.common.hapi.validation.validator; -import org.hl7.fhir.convertors.VersionConvertor_14_50; +import org.hl7.fhir.convertors.factory.VersionConvertorFactory_14_50; import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.r5.model.Resource; public class VersionTypeConverterDstu21 implements VersionSpecificWorkerContextWrapper.IVersionTypeConverter { @Override public Resource toCanonical(IBaseResource theNonCanonical) { - return VersionConvertor_14_50.convertResource((org.hl7.fhir.dstu2016may.model.Resource) theNonCanonical); + return VersionConvertorFactory_14_50.convertResource((org.hl7.fhir.dstu2016may.model.Resource) theNonCanonical); } @Override public IBaseResource fromCanonical(Resource theCanonical) { - return VersionConvertor_14_50.convertResource(theCanonical); + return VersionConvertorFactory_14_50.convertResource(theCanonical); } } diff --git a/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/validator/VersionTypeConverterDstu3.java b/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/validator/VersionTypeConverterDstu3.java index e11844fa39b..f025f50cf3e 100644 --- a/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/validator/VersionTypeConverterDstu3.java +++ b/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/validator/VersionTypeConverterDstu3.java @@ -1,17 +1,18 @@ package org.hl7.fhir.common.hapi.validation.validator; -import org.hl7.fhir.convertors.VersionConvertor_30_50; +import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_30_50; +import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_50; import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.r5.model.Resource; public class VersionTypeConverterDstu3 implements VersionSpecificWorkerContextWrapper.IVersionTypeConverter { @Override public Resource toCanonical(IBaseResource theNonCanonical) { - return VersionConvertor_30_50.convertResource((org.hl7.fhir.dstu3.model.Resource) theNonCanonical, true); + return VersionConvertorFactory_30_50.convertResource((org.hl7.fhir.dstu3.model.Resource) theNonCanonical, new BaseAdvisor_30_50(false)); } @Override public IBaseResource fromCanonical(Resource theCanonical) { - return VersionConvertor_30_50.convertResource(theCanonical, true); + return VersionConvertorFactory_30_50.convertResource(theCanonical, new BaseAdvisor_30_50(false)); } } diff --git a/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/validator/VersionTypeConverterR4.java b/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/validator/VersionTypeConverterR4.java index ced3db6f252..761ef392d05 100644 --- a/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/validator/VersionTypeConverterR4.java +++ b/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/validator/VersionTypeConverterR4.java @@ -1,17 +1,18 @@ package org.hl7.fhir.common.hapi.validation.validator; -import org.hl7.fhir.convertors.VersionConvertor_40_50; +import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_40_50; +import org.hl7.fhir.convertors.factory.VersionConvertorFactory_40_50; import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.r5.model.Resource; public class VersionTypeConverterR4 implements VersionSpecificWorkerContextWrapper.IVersionTypeConverter { @Override public Resource toCanonical(IBaseResource theNonCanonical) { - return VersionConvertor_40_50.convertResource((org.hl7.fhir.r4.model.Resource) theNonCanonical); + return VersionConvertorFactory_40_50.convertResource((org.hl7.fhir.r4.model.Resource) theNonCanonical, new BaseAdvisor_40_50(false)); } @Override public IBaseResource fromCanonical(Resource theCanonical) { - return VersionConvertor_40_50.convertResource(theCanonical); + return VersionConvertorFactory_40_50.convertResource(theCanonical, new BaseAdvisor_40_50(false)); } } diff --git a/hapi-fhir-validation/src/test/java/ca/uhn/fhir/rest/server/interceptor/ResponseTerminologyDisplayPopulationInterceptorTest.java b/hapi-fhir-validation/src/test/java/ca/uhn/fhir/rest/server/interceptor/ResponseTerminologyDisplayPopulationInterceptorTest.java index f7e58a17002..65b5767d5cf 100644 --- a/hapi-fhir-validation/src/test/java/ca/uhn/fhir/rest/server/interceptor/ResponseTerminologyDisplayPopulationInterceptorTest.java +++ b/hapi-fhir-validation/src/test/java/ca/uhn/fhir/rest/server/interceptor/ResponseTerminologyDisplayPopulationInterceptorTest.java @@ -141,9 +141,14 @@ public class ResponseTerminologyDisplayPopulationInterceptorTest { } @Override - public LookupCodeResult lookupCode(ValidationSupportContext theValidationSupportContext, String theSystem, String theCode) { + public LookupCodeResult lookupCode(ValidationSupportContext theValidationSupportContext, String theSystem, String theCode, String theDisplayLanguage) { return null; } + + @Override + public LookupCodeResult lookupCode(ValidationSupportContext theValidationSupportContext, String theSystem, String theCode) { + return lookupCode(theValidationSupportContext, theSystem, theCode, null); + } } } diff --git a/hapi-fhir-validation/src/test/java/org/hl7/fhir/common/hapi/validation/support/CommonCodeSystemsTerminologyServiceTest.java b/hapi-fhir-validation/src/test/java/org/hl7/fhir/common/hapi/validation/support/CommonCodeSystemsTerminologyServiceTest.java index f3a8f34a60f..863eac1fd4f 100644 --- a/hapi-fhir-validation/src/test/java/org/hl7/fhir/common/hapi/validation/support/CommonCodeSystemsTerminologyServiceTest.java +++ b/hapi-fhir-validation/src/test/java/org/hl7/fhir/common/hapi/validation/support/CommonCodeSystemsTerminologyServiceTest.java @@ -51,7 +51,7 @@ public class CommonCodeSystemsTerminologyServiceTest { @Test public void testUcum_LookupCode_UnknownSystem() { - IValidationSupport.LookupCodeResult outcome = mySvc.lookupCode(newSupport(), "http://foo", "AAAAA"); + IValidationSupport.LookupCodeResult outcome = mySvc.lookupCode(newSupport(), "http://foo", "AAAAA", null); assertNull(outcome); } @@ -105,6 +105,20 @@ public class CommonCodeSystemsTerminologyServiceTest { assertEquals("English (United States)", outcome.getDisplay()); } + @Test + public void testLanguages_CommonLanguagesVs_OnlyLanguage_NoRegion() { + IValidationSupport.LookupCodeResult nl = mySvc.lookupCode(newSupport(), "urn:ietf:bcp:47", "nl"); + assertTrue(nl.isFound()); + assertEquals("Dutch", nl.getCodeDisplay()); + } + + @Test + public void testLanguages_CommonLanguagesVs_LanguageAndRegion() { + IValidationSupport.LookupCodeResult nl = mySvc.lookupCode(newSupport(), "urn:ietf:bcp:47", "nl-NL"); + assertTrue(nl.isFound()); + assertEquals("Dutch Netherlands", nl.getCodeDisplay()); + } + @Test public void testLanguages_CommonLanguagesVs_BadCode() { IValidationSupport.CodeValidationResult outcome = mySvc.validateCode(newSupport(), newOptions(), "urn:ietf:bcp:47", "FOO", null, "http://hl7.org/fhir/ValueSet/languages"); diff --git a/hapi-fhir-validation/src/test/java/org/hl7/fhir/dstu3/hapi/validation/FhirInstanceValidatorDstu3Test.java b/hapi-fhir-validation/src/test/java/org/hl7/fhir/dstu3/hapi/validation/FhirInstanceValidatorDstu3Test.java index b67b5683026..ec6a6af187c 100644 --- a/hapi-fhir-validation/src/test/java/org/hl7/fhir/dstu3/hapi/validation/FhirInstanceValidatorDstu3Test.java +++ b/hapi-fhir-validation/src/test/java/org/hl7/fhir/dstu3/hapi/validation/FhirInstanceValidatorDstu3Test.java @@ -1312,13 +1312,13 @@ public class FhirInstanceValidatorDstu3Test { String input = IOUtils.toString(FhirInstanceValidatorDstu3Test.class.getResourceAsStream("/dstu3-rick-test.json"), Charsets.UTF_8); IResourceValidator.IValidatorResourceFetcher resourceFetcher = mock(IResourceValidator.IValidatorResourceFetcher.class); - when(resourceFetcher.validationPolicy(any(), anyString(), anyString())).thenReturn(IResourceValidator.ReferenceValidationPolicy.CHECK_TYPE_IF_EXISTS); + when(resourceFetcher.validationPolicy(any(), any(), any(), any())).thenReturn(IResourceValidator.ReferenceValidationPolicy.CHECK_TYPE_IF_EXISTS); myInstanceVal.setValidatorResourceFetcher(resourceFetcher); myVal.validateWithResult(input); - verify(resourceFetcher, times(3)).resolveURL(any(), anyString(), anyString(), anyString()); - verify(resourceFetcher, times(4)).validationPolicy(any(), anyString(), anyString()); - verify(resourceFetcher, times(4)).fetch(any(), anyString()); + verify(resourceFetcher, times(3)).resolveURL(any(), any(), anyString(), anyString(), anyString()); + verify(resourceFetcher, times(4)).validationPolicy(any(), any(), anyString(), anyString()); + verify(resourceFetcher, times(4)).fetch(any(), any(), anyString()); } @Test diff --git a/hapi-fhir-validation/src/test/java/org/hl7/fhir/r4/validation/FhirInstanceValidatorR4Test.java b/hapi-fhir-validation/src/test/java/org/hl7/fhir/r4/validation/FhirInstanceValidatorR4Test.java index e56b4842fe1..c235ee20fe8 100644 --- a/hapi-fhir-validation/src/test/java/org/hl7/fhir/r4/validation/FhirInstanceValidatorR4Test.java +++ b/hapi-fhir-validation/src/test/java/org/hl7/fhir/r4/validation/FhirInstanceValidatorR4Test.java @@ -254,7 +254,7 @@ public class FhirInstanceValidatorR4Test extends BaseTest { return retVal; } }); - when(mockSupport.lookupCode(any(), any(), any())).thenAnswer(t -> { + when(mockSupport.lookupCode(any(), any(), any(), any())).thenAnswer(t -> { String system = t.getArgument(1, String.class); String code = t.getArgument(2, String.class); if (myValidConcepts.contains(system + "___" + code)) { @@ -995,8 +995,7 @@ public class FhirInstanceValidatorR4Test extends BaseTest { List messages = logResultsAndReturnNonInformationalOnes(output); assertEquals(3, messages.size(), output.toString()); assertThat(messages.get(0).getMessage(), containsString("Element must have some content")); - assertThat(messages.get(1).getMessage(), containsString("Primitive types must have a value or must have child extensions")); - assertThat(messages.get(2).getMessage(), containsString("ele-1: 'All FHIR elements must have a @value or children' Rule 'All FHIR elements must have a @value or children' Failed")); + assertThat(messages.get(2).getMessage(), containsString("Primitive types must have a value or must have child extensions")); } @Test @@ -1398,13 +1397,13 @@ public class FhirInstanceValidatorR4Test extends BaseTest { String encoded = loadResource("/r4/r4-caredove-bundle.json"); IResourceValidator.IValidatorResourceFetcher resourceFetcher = mock(IResourceValidator.IValidatorResourceFetcher.class); - when(resourceFetcher.validationPolicy(any(), anyString(), anyString())).thenReturn(IResourceValidator.ReferenceValidationPolicy.CHECK_TYPE_IF_EXISTS); + when(resourceFetcher.validationPolicy(any(), any(), any(), any())).thenReturn(IResourceValidator.ReferenceValidationPolicy.CHECK_TYPE_IF_EXISTS); myInstanceVal.setValidatorResourceFetcher(resourceFetcher); myVal.validateWithResult(encoded); - verify(resourceFetcher, times(15)).resolveURL(any(), anyString(), anyString(), anyString()); - verify(resourceFetcher, times(12)).validationPolicy(any(), anyString(), anyString()); - verify(resourceFetcher, times(12)).fetch(any(), anyString()); + verify(resourceFetcher, times(15)).resolveURL(any(), any(), anyString(), anyString(), anyString()); + verify(resourceFetcher, times(12)).validationPolicy(any(), any(), anyString(), anyString()); + verify(resourceFetcher, times(12)).fetch(any(), any(), anyString()); } @Test diff --git a/hapi-fhir-validation/src/test/java/org/hl7/fhir/r5/validation/FhirInstanceValidatorR5Test.java b/hapi-fhir-validation/src/test/java/org/hl7/fhir/r5/validation/FhirInstanceValidatorR5Test.java index 44c05dc2213..607f1e136e7 100644 --- a/hapi-fhir-validation/src/test/java/org/hl7/fhir/r5/validation/FhirInstanceValidatorR5Test.java +++ b/hapi-fhir-validation/src/test/java/org/hl7/fhir/r5/validation/FhirInstanceValidatorR5Test.java @@ -428,13 +428,13 @@ public class FhirInstanceValidatorR5Test { String input = IOUtils.toString(FhirInstanceValidator.class.getResourceAsStream("/vitals.json"), Charsets.UTF_8); IResourceValidator.IValidatorResourceFetcher resourceFetcher = mock(IResourceValidator.IValidatorResourceFetcher.class); - when(resourceFetcher.validationPolicy(any(),anyString(), anyString())).thenReturn(IResourceValidator.ReferenceValidationPolicy.CHECK_TYPE_IF_EXISTS); + when(resourceFetcher.validationPolicy(any(), any(), any(), any())).thenReturn(IResourceValidator.ReferenceValidationPolicy.CHECK_TYPE_IF_EXISTS); myInstanceVal.setValidatorResourceFetcher(resourceFetcher); myVal.validateWithResult(input); - verify(resourceFetcher, times(13)).resolveURL(any(), anyString(), anyString(), anyString()); - verify(resourceFetcher, times(4)).validationPolicy(any(), anyString(), anyString()); - verify(resourceFetcher, times(3)).fetch(any(), anyString()); + verify(resourceFetcher, times(13)).resolveURL(any(), any(), anyString(), anyString(), anyString()); + verify(resourceFetcher, times(4)).validationPolicy(any(), any(), anyString(), anyString()); + verify(resourceFetcher, times(3)).fetch(any(), any(), anyString()); } @Test @@ -614,8 +614,8 @@ public class FhirInstanceValidatorR5Test { List messages = logResultsAndReturnNonInformationalOnes(output); assertEquals( 3, messages.size(), output.toString()); assertThat(messages.get(0).getMessage(), containsString("Element must have some content")); - assertThat(messages.get(1).getMessage(), containsString("Primitive types must have a value or must have child extensions")); - assertThat(messages.get(2).getMessage(), containsString("ele-1: 'All FHIR elements must have a @value or children' Rule 'All FHIR elements must have a @value or children' Failed")); + assertThat(messages.get(1).getMessage(), containsString("ele-1: 'All FHIR elements must have a @value or children' Rule 'All FHIR elements must have a @value or children' Failed")); + assertThat(messages.get(2).getMessage(), containsString("Primitive types must have a value or must have child extensions")); } @Test diff --git a/hapi-tinder-plugin/pom.xml b/hapi-tinder-plugin/pom.xml index b29eac9ff4e..51bffb211be 100644 --- a/hapi-tinder-plugin/pom.xml +++ b/hapi-tinder-plugin/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-fhir - 5.6.0-PRE1-SNAPSHOT + 5.6.0-PRE2-SNAPSHOT ../pom.xml @@ -58,37 +58,37 @@ ca.uhn.hapi.fhir hapi-fhir-structures-dstu3 - 5.6.0-PRE1-SNAPSHOT + 5.6.0-PRE2-SNAPSHOT ca.uhn.hapi.fhir hapi-fhir-structures-hl7org-dstu2 - 5.6.0-PRE1-SNAPSHOT + 5.6.0-PRE2-SNAPSHOT ca.uhn.hapi.fhir hapi-fhir-structures-r4 - 5.6.0-PRE1-SNAPSHOT + 5.6.0-PRE2-SNAPSHOT ca.uhn.hapi.fhir hapi-fhir-structures-r5 - 5.6.0-PRE1-SNAPSHOT + 5.6.0-PRE2-SNAPSHOT ca.uhn.hapi.fhir hapi-fhir-validation-resources-dstu2 - 5.6.0-PRE1-SNAPSHOT + 5.6.0-PRE2-SNAPSHOT ca.uhn.hapi.fhir hapi-fhir-validation-resources-dstu3 - 5.6.0-PRE1-SNAPSHOT + 5.6.0-PRE2-SNAPSHOT ca.uhn.hapi.fhir hapi-fhir-validation-resources-r4 - 5.6.0-PRE1-SNAPSHOT + 5.6.0-PRE2-SNAPSHOT org.apache.velocity diff --git a/hapi-tinder-test/pom.xml b/hapi-tinder-test/pom.xml index 3d072e467b9..86353fff4ab 100644 --- a/hapi-tinder-test/pom.xml +++ b/hapi-tinder-test/pom.xml @@ -4,7 +4,7 @@ ca.uhn.hapi.fhir hapi-fhir - 5.6.0-PRE1-SNAPSHOT + 5.6.0-PRE2-SNAPSHOT ../pom.xml diff --git a/pom.xml b/pom.xml index ae4cf318ce9..5c72a01da01 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ ca.uhn.hapi.fhir hapi-fhir pom - 5.6.0-PRE1-SNAPSHOT + 5.6.0-PRE2-SNAPSHOT HAPI-FHIR An open-source implementation of the FHIR specification in Java. https://hapifhir.io @@ -748,7 +748,7 @@ - 5.4.0 + 5.4.10 1.0.3 -Dfile.encoding=UTF-8 -Xmx2048m diff --git a/tests/hapi-fhir-base-test-jaxrsserver-kotlin/pom.xml b/tests/hapi-fhir-base-test-jaxrsserver-kotlin/pom.xml index 2771f4f46c3..7bc3167aba0 100644 --- a/tests/hapi-fhir-base-test-jaxrsserver-kotlin/pom.xml +++ b/tests/hapi-fhir-base-test-jaxrsserver-kotlin/pom.xml @@ -6,7 +6,7 @@ ca.uhn.hapi.fhir hapi-fhir - 5.6.0-PRE1-SNAPSHOT + 5.6.0-PRE2-SNAPSHOT ../../pom.xml diff --git a/tests/hapi-fhir-base-test-mindeps-client/pom.xml b/tests/hapi-fhir-base-test-mindeps-client/pom.xml index 3cf38d46df1..baf9d3f29a7 100644 --- a/tests/hapi-fhir-base-test-mindeps-client/pom.xml +++ b/tests/hapi-fhir-base-test-mindeps-client/pom.xml @@ -4,7 +4,7 @@ ca.uhn.hapi.fhir hapi-fhir - 5.6.0-PRE1-SNAPSHOT + 5.6.0-PRE2-SNAPSHOT ../../pom.xml diff --git a/tests/hapi-fhir-base-test-mindeps-server/pom.xml b/tests/hapi-fhir-base-test-mindeps-server/pom.xml index 4c651d95698..aa020297fb3 100644 --- a/tests/hapi-fhir-base-test-mindeps-server/pom.xml +++ b/tests/hapi-fhir-base-test-mindeps-server/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-fhir - 5.6.0-PRE1-SNAPSHOT + 5.6.0-PRE2-SNAPSHOT ../../pom.xml