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-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-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-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..00e3fa05172 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,13 @@ 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.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 +70,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); 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/dstu3/FhirResourceDaoCodeSystemDstu3.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoCodeSystemDstu3.java index bc974652bf7..50a16b2a4f3 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,17 @@ 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.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 +54,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 { @@ -146,7 +146,7 @@ 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..d98ec89c2a6 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,7 @@ 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.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 +38,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 +52,6 @@ public class FhirResourceDaoConceptMapDstu3 extends BaseHapiFhirResourceDao implements IFhirResourceDaoValueSet { @@ -54,15 +53,15 @@ public class FhirResourceDaoValueSetDstu3 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); } @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); org.hl7.fhir.r4.model.ValueSet canonicalOutput = myTerminologySvc.expandValueSet(theOptions, canonicalInput); - return ValueSet40_50.convertValueSet(canonicalOutput); + return (ValueSet) VersionConvertorFactory_40_50.convertResource(canonicalOutput); } @Override @@ -82,7 +82,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)); } else { myTerminologySvc.deleteValueSetAndChildren(retVal); } 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..f9104a94cce 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,8 @@ 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.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 +60,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 +307,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); 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); break; default: nextCodeSystem = (CodeSystem) theCodeSystem; 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..94ddfdf4d18 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,7 @@ 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.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 +45,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 +80,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 +98,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)); } - + if (haveConceptMapVersion) { - translationRequest.setConceptMapVersion(VersionConvertor_30_40.convertString(theConceptMapVersion)); + translationRequest.setConceptMapVersion((org.hl7.fhir.r4.model.StringType) VersionConvertorFactory_30_40.convertType(theConceptMapVersion)); } - + // 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)); 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)); } 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)); } } 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)); } else { - translationRequest.setCodeableConcept(VersionConvertor_30_40.convertCodeableConcept(theSourceCodeableConcept)); + translationRequest.setCodeableConcept((org.hl7.fhir.r4.model.CodeableConcept) VersionConvertorFactory_30_40.convertType(theSourceCodeableConcept)); } if (haveSourceValueSet) { - translationRequest.setSource(VersionConvertor_30_40.convertUri(theSourceValueSet)); + translationRequest.setSource((org.hl7.fhir.r4.model.UriType) VersionConvertorFactory_30_40.convertType(theSourceValueSet)); } if (haveTargetValueSet) { - translationRequest.setTarget(VersionConvertor_30_40.convertUri(theTargetValueSet)); + translationRequest.setTarget((org.hl7.fhir.r4.model.UriType) VersionConvertorFactory_30_40.convertType(theTargetValueSet)); } if (haveTargetCodeSystem) { - translationRequest.setTargetSystem(VersionConvertor_30_40.convertUri(theTargetCodeSystem)); + translationRequest.setTargetSystem((org.hl7.fhir.r4.model.UriType) VersionConvertorFactory_30_40.convertType(theTargetCodeSystem)); } if (haveReverse) { - translationRequest.setReverse(VersionConvertor_30_40.convertBoolean(theReverse)); + translationRequest.setReverse((org.hl7.fhir.r4.model.BooleanType) VersionConvertorFactory_30_40.convertType(theReverse)); } if (haveId) { @@ -155,7 +153,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)); } 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/r5/BaseJpaResourceProviderConceptMapR5.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/r5/BaseJpaResourceProviderConceptMapR5.java index 4e80fe87662..50e1c3754c0 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,7 @@ 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.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 +52,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); } finally { endRequest(theServletRequest); } 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..1fe9e1dfe12 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,7 @@ 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.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 +24,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 +64,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), null); } catch (FHIRException e) { throw new InternalErrorException(e); } @@ -81,7 +78,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); } catch (FHIRException e) { throw new InternalErrorException(e); } @@ -90,31 +87,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); 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); } @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); } @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); } @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); } @@ -160,7 +157,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); Coding coding = (Coding) theCoding; org.hl7.fhir.r4.model.Coding codingR4 = null; @@ -184,7 +181,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); return super.isValueSetPreExpandedForCodeValidation(valueSetR4); } } 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..0463ce67dd4 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,7 @@ 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.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 +18,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 +56,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)); + return new ValueSetExpansionOutcome(VersionConvertorFactory_40_50.convertResource(expandedR4)); } @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); } @Override @@ -79,7 +77,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); } @Override @@ -110,30 +108,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); } @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); } @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); } @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); } @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); } @Override 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..3c4c09b40c4 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,7 @@ 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.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 +37,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 +54,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 +68,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); } catch (FHIRException e) { throw new InternalErrorException(e); } @@ -91,7 +89,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); } catch (FHIRException e) { throw new InternalErrorException(e); } @@ -107,7 +105,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); } 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..00316c41d5a 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,7 @@ 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.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 +64,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); if (isBlank(theCodeSystemResource.getIdElement().getIdPart())) { String matchUrl = "CodeSystem?url=" + UrlUtil.escapeUrlParam(theCodeSystemResource.getUrl()); return myCodeSystemResourceDao.update(codeSystemR4, matchUrl, theRequestDetails).getId(); @@ -75,7 +76,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); if (isBlank(theConceptMap.getIdElement().getIdPart())) { String matchUrl = "ConceptMap?url=" + UrlUtil.escapeUrlParam(theConceptMap.getUrl()); @@ -88,7 +89,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); 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/dstu3/BaseJpaDstu3Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/BaseJpaDstu3Test.java index 0f7ac511ac6..ab182edfd70 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,12 @@ 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.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 +126,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 +378,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 +462,7 @@ public abstract class BaseJpaDstu3Test extends BaseJpaTest { */ public static ConceptMap createConceptMap() { try { - return convertConceptMap(BaseJpaR4Test.createConceptMap()); + return (ConceptMap) VersionConvertorFactory_30_40.convertResource(BaseJpaR4Test.createConceptMap()); } catch (FHIRException fe) { throw new InternalErrorException(fe); } 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 83efd82ebcc..f986541db6c 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; @@ -902,9 +901,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/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-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-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..2a7b23e5fcc 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,9 @@ 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.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; @@ -381,13 +382,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); 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..1880fcf3003 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,9 @@ 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.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 +65,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); break; } case DSTU3: { - expansion = ValueSet30_50.convertValueSet(expansionR5); + expansion = VersionConvertorFactory_30_50.convertResource(expansionR5); break; } case R4: { - expansion = ValueSet40_50.convertValueSet(expansionR5); + expansion = VersionConvertorFactory_40_50.convertResource(expansionR5); break; } case R5: { @@ -358,10 +356,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); }; - 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); org.hl7.fhir.r5.model.ValueSet output = expandValueSetR5(theValidationSupportContext, input, codeSystemLoader, valueSetLoader, theWantSystemUrlAndVersion, theWantCode); return (output); } @@ -372,7 +370,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 +382,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); }; 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); org.hl7.fhir.r5.model.ValueSet output = expandValueSetR5(theValidationSupportContext, input, codeSystemLoader, valueSetLoader, theWantSystemUrlAndVersion, theWantCode); return (output); } @@ -442,14 +439,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); }; 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); }; - 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); org.hl7.fhir.r5.model.ValueSet output = expandValueSetR5(theValidationSupportContext, input, codeSystemLoader, valueSetLoader, theWantSystemUrlAndVersion, theWantCode); return (output); } @@ -458,14 +455,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); }; 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); }; - 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); org.hl7.fhir.r5.model.ValueSet output = expandValueSetR5(theValidationSupportContext, input, codeSystemLoader, valueSetLoader, theWantSystemUrlAndVersion, theWantCode); return (output); } 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..9d111bff259 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,7 @@ 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.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 +144,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 +169,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 +241,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 +691,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); 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 +706,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); } }; 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..e969bf75e5c 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,17 @@ package org.hl7.fhir.common.hapi.validation.validator; -import org.hl7.fhir.convertors.VersionConvertor_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); } @Override public IBaseResource fromCanonical(Resource theCanonical) { - return VersionConvertor_30_50.convertResource(theCanonical, true); + return VersionConvertorFactory_30_50.convertResource(theCanonical); } } 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..819261285c4 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,17 @@ package org.hl7.fhir.common.hapi.validation.validator; -import org.hl7.fhir.convertors.VersionConvertor_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); } @Override public IBaseResource fromCanonical(Resource theCanonical) { - return VersionConvertor_40_50.convertResource(theCanonical); + return VersionConvertorFactory_40_50.convertResource(theCanonical); } } 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..ca2b322d6e1 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(), anyString(), anyString(), anyString())).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(), anyString(), anyString(), anyString(), anyString()); + verify(resourceFetcher, times(4)).validationPolicy(any(), anyString(), anyString(), anyString()); + verify(resourceFetcher, times(4)).fetch(any(), anyString(), 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..044c97e5ebc 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 @@ -1398,13 +1398,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(), anyString(), anyString(), anyString())).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(), anyString(), anyString(), anyString(), anyString()); + verify(resourceFetcher, times(12)).validationPolicy(any(), anyString(), anyString(), anyString()); + verify(resourceFetcher, times(12)).fetch(any(), anyString(), 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..c7fee7d75a9 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(), anyString(), anyString(), anyString())).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(), anyString(), anyString(), anyString(), anyString()); + verify(resourceFetcher, times(4)).validationPolicy(any(), anyString(), anyString(), anyString()); + verify(resourceFetcher, times(3)).fetch(any(), anyString(), anyString()); } @Test