diff --git a/api/src/main/java/org/openmrs/module/fhir2/api/search/SearchQueryBundleProviderR3Wrapper.java b/api/src/main/java/org/openmrs/module/fhir2/api/search/SearchQueryBundleProviderR3Wrapper.java index 9d2066d11e..c89ca111e4 100644 --- a/api/src/main/java/org/openmrs/module/fhir2/api/search/SearchQueryBundleProviderR3Wrapper.java +++ b/api/src/main/java/org/openmrs/module/fhir2/api/search/SearchQueryBundleProviderR3Wrapper.java @@ -9,6 +9,8 @@ */ package org.openmrs.module.fhir2.api.search; +import static org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_40.convertResource; + import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -19,7 +21,6 @@ import java.util.stream.Collectors; import ca.uhn.fhir.rest.api.server.IBundleProvider; -import org.hl7.fhir.convertors.VersionConvertor_30_40; import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.instance.model.api.IPrimitiveType; import org.hl7.fhir.r4.model.Resource; @@ -88,7 +89,7 @@ private IBaseResource transformToR3(IBaseResource resource) { return TaskVersionConverter.convertTask((Task) resource); } - return VersionConvertor_30_40.convertResource((Resource) resource, true); + return convertResource((Resource) resource); } return null; diff --git a/api/src/main/java/org/openmrs/module/fhir2/providers/r3/AllergyIntoleranceFhirResourceProvider.java b/api/src/main/java/org/openmrs/module/fhir2/providers/r3/AllergyIntoleranceFhirResourceProvider.java index 634bc887c8..a4e357b2fe 100644 --- a/api/src/main/java/org/openmrs/module/fhir2/providers/r3/AllergyIntoleranceFhirResourceProvider.java +++ b/api/src/main/java/org/openmrs/module/fhir2/providers/r3/AllergyIntoleranceFhirResourceProvider.java @@ -37,7 +37,7 @@ import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; import lombok.Setter; import org.apache.commons.collections.CollectionUtils; -import org.hl7.fhir.convertors.conv30_40.AllergyIntolerance30_40; +import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_40; import org.hl7.fhir.dstu3.model.AllergyIntolerance; import org.hl7.fhir.dstu3.model.IdType; import org.hl7.fhir.dstu3.model.OperationOutcome; @@ -73,14 +73,14 @@ public AllergyIntolerance getAllergyIntoleranceById(@IdParam @Nonnull IdType id) throw new ResourceNotFoundException("Could not find allergyIntolerance with Id " + id.getIdPart()); } - return AllergyIntolerance30_40.convertAllergyIntolerance(allergyIntolerance); + return (AllergyIntolerance) VersionConvertorFactory_30_40.convertResource(allergyIntolerance); } @Create @SuppressWarnings("unused") public MethodOutcome creatAllergyIntolerance(@ResourceParam AllergyIntolerance allergyIntolerance) { - return FhirProviderUtils.buildCreate(AllergyIntolerance30_40.convertAllergyIntolerance( - allergyIntoleranceService.create(AllergyIntolerance30_40.convertAllergyIntolerance(allergyIntolerance)))); + return FhirProviderUtils.buildCreate(VersionConvertorFactory_30_40.convertResource(allergyIntoleranceService.create( + (org.hl7.fhir.r4.model.AllergyIntolerance) VersionConvertorFactory_30_40.convertResource(allergyIntolerance)))); } @Update @@ -92,8 +92,9 @@ public MethodOutcome updateAllergyIntolerance(@IdParam IdType id, @ResourceParam allergyIntolerance.setId(id.getIdPart()); - return FhirProviderUtils.buildUpdate(AllergyIntolerance30_40.convertAllergyIntolerance(allergyIntoleranceService - .update(id.getIdPart(), AllergyIntolerance30_40.convertAllergyIntolerance(allergyIntolerance)))); + return FhirProviderUtils.buildUpdate(VersionConvertorFactory_30_40.convertResource(allergyIntoleranceService.update( + id.getIdPart(), + (org.hl7.fhir.r4.model.AllergyIntolerance) VersionConvertorFactory_30_40.convertResource(allergyIntolerance)))); } @Delete diff --git a/api/src/main/java/org/openmrs/module/fhir2/providers/r3/ConditionFhirResourceProvider.java b/api/src/main/java/org/openmrs/module/fhir2/providers/r3/ConditionFhirResourceProvider.java index 54e9afb344..24b8a70b28 100644 --- a/api/src/main/java/org/openmrs/module/fhir2/providers/r3/ConditionFhirResourceProvider.java +++ b/api/src/main/java/org/openmrs/module/fhir2/providers/r3/ConditionFhirResourceProvider.java @@ -38,7 +38,7 @@ import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; import lombok.Setter; import org.apache.commons.collections.CollectionUtils; -import org.hl7.fhir.convertors.conv30_40.Condition30_40; +import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_40; import org.hl7.fhir.dstu3.model.Condition; import org.hl7.fhir.dstu3.model.IdType; import org.hl7.fhir.dstu3.model.OperationOutcome; @@ -72,14 +72,14 @@ public Condition getConditionById(@IdParam @Nonnull IdType id) { throw new ResourceNotFoundException("Could not find condition with Id " + id.getIdPart()); } - return Condition30_40.convertCondition(condition); + return (Condition) VersionConvertorFactory_30_40.convertResource(condition); } @Create @SuppressWarnings("unused") public MethodOutcome createCondition(@ResourceParam Condition newCondition) { - return FhirProviderUtils.buildCreate( - Condition30_40.convertCondition(conditionService.create(Condition30_40.convertCondition(newCondition)))); + return FhirProviderUtils.buildCreate(VersionConvertorFactory_30_40.convertResource(conditionService + .create((org.hl7.fhir.r4.model.Condition) VersionConvertorFactory_30_40.convertResource(newCondition)))); } @Update @@ -90,8 +90,9 @@ public MethodOutcome updateCondition(@IdParam IdType id, @ResourceParam Conditio updatedCondition.setId(id); - return FhirProviderUtils.buildUpdate(Condition30_40.convertCondition( - conditionService.update(id.getIdPart(), Condition30_40.convertCondition(updatedCondition)))); + return FhirProviderUtils + .buildUpdate(VersionConvertorFactory_30_40.convertResource(conditionService.update(id.getIdPart(), + (org.hl7.fhir.r4.model.Condition) VersionConvertorFactory_30_40.convertResource(updatedCondition)))); } @Delete diff --git a/api/src/main/java/org/openmrs/module/fhir2/providers/r3/DiagnosticReportFhirResourceProvider.java b/api/src/main/java/org/openmrs/module/fhir2/providers/r3/DiagnosticReportFhirResourceProvider.java index 99f8784467..a2d887a46c 100644 --- a/api/src/main/java/org/openmrs/module/fhir2/providers/r3/DiagnosticReportFhirResourceProvider.java +++ b/api/src/main/java/org/openmrs/module/fhir2/providers/r3/DiagnosticReportFhirResourceProvider.java @@ -36,7 +36,7 @@ import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; import lombok.Setter; import org.apache.commons.collections.CollectionUtils; -import org.hl7.fhir.convertors.conv30_40.DiagnosticReport30_40; +import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_40; import org.hl7.fhir.dstu3.model.DiagnosticReport; import org.hl7.fhir.dstu3.model.Encounter; import org.hl7.fhir.dstu3.model.IdType; @@ -72,14 +72,14 @@ public DiagnosticReport getDiagnosticReportById(@IdParam @Nonnull IdType id) { throw new ResourceNotFoundException("Could not find diagnosticReport with Id " + id.getIdPart()); } - return DiagnosticReport30_40.convertDiagnosticReport(diagnosticReport); + return (DiagnosticReport) VersionConvertorFactory_30_40.convertResource(diagnosticReport); } @Create @SuppressWarnings("unused") public MethodOutcome createDiagnosticReport(@ResourceParam DiagnosticReport diagnosticReport) { - return FhirProviderUtils.buildCreate(DiagnosticReport30_40.convertDiagnosticReport( - diagnosticReportService.create(DiagnosticReport30_40.convertDiagnosticReport(diagnosticReport)))); + return FhirProviderUtils.buildCreate(VersionConvertorFactory_30_40.convertResource(diagnosticReportService.create( + (org.hl7.fhir.r4.model.DiagnosticReport) VersionConvertorFactory_30_40.convertResource(diagnosticReport)))); } @Update @@ -91,8 +91,9 @@ public MethodOutcome updateDiagnosticReport(@IdParam IdType id, @ResourceParam D idPart = id.getIdPart(); } - return FhirProviderUtils.buildUpdate(DiagnosticReport30_40.convertDiagnosticReport( - diagnosticReportService.update(idPart, DiagnosticReport30_40.convertDiagnosticReport(diagnosticReport)))); + return FhirProviderUtils.buildUpdate( + VersionConvertorFactory_30_40.convertResource(diagnosticReportService.update(idPart, + (org.hl7.fhir.r4.model.DiagnosticReport) VersionConvertorFactory_30_40.convertResource(diagnosticReport)))); } @Delete diff --git a/api/src/main/java/org/openmrs/module/fhir2/providers/r3/EncounterFhirResourceProvider.java b/api/src/main/java/org/openmrs/module/fhir2/providers/r3/EncounterFhirResourceProvider.java index eb388bcdc9..4cea9aeff3 100644 --- a/api/src/main/java/org/openmrs/module/fhir2/providers/r3/EncounterFhirResourceProvider.java +++ b/api/src/main/java/org/openmrs/module/fhir2/providers/r3/EncounterFhirResourceProvider.java @@ -45,7 +45,7 @@ import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; import lombok.Setter; import org.apache.commons.collections.CollectionUtils; -import org.hl7.fhir.convertors.conv30_40.Encounter30_40; +import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_40; import org.hl7.fhir.dstu3.model.DiagnosticReport; import org.hl7.fhir.dstu3.model.Encounter; import org.hl7.fhir.dstu3.model.IdType; @@ -88,14 +88,14 @@ public Encounter getEncounterById(@IdParam @Nonnull IdType id) { throw new ResourceNotFoundException("Could not find encounter with Id " + id.getIdPart()); } - return Encounter30_40.convertEncounter(encounter); + return (Encounter) VersionConvertorFactory_30_40.convertResource(encounter); } @Create @SuppressWarnings("unused") public MethodOutcome createEncounter(@ResourceParam Encounter encounter) { - return FhirProviderUtils.buildCreate( - Encounter30_40.convertEncounter(encounterService.create(Encounter30_40.convertEncounter(encounter)))); + return FhirProviderUtils.buildCreate(VersionConvertorFactory_30_40.convertResource(encounterService + .create((org.hl7.fhir.r4.model.Encounter) VersionConvertorFactory_30_40.convertResource(encounter)))); } @Update @@ -107,8 +107,9 @@ public MethodOutcome updateEncounter(@IdParam IdType id, @ResourceParam Encounte encounter.setId(id.getIdPart()); - return FhirProviderUtils.buildUpdate(Encounter30_40 - .convertEncounter(encounterService.update(id.getIdPart(), Encounter30_40.convertEncounter(encounter)))); + return FhirProviderUtils + .buildUpdate(VersionConvertorFactory_30_40.convertResource(encounterService.update(id.getIdPart(), + (org.hl7.fhir.r4.model.Encounter) VersionConvertorFactory_30_40.convertResource(encounter)))); } @Delete diff --git a/api/src/main/java/org/openmrs/module/fhir2/providers/r3/GroupFhirResourceProvider.java b/api/src/main/java/org/openmrs/module/fhir2/providers/r3/GroupFhirResourceProvider.java index b3a8e66054..dab7269cd8 100644 --- a/api/src/main/java/org/openmrs/module/fhir2/providers/r3/GroupFhirResourceProvider.java +++ b/api/src/main/java/org/openmrs/module/fhir2/providers/r3/GroupFhirResourceProvider.java @@ -24,7 +24,7 @@ import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; import lombok.Setter; -import org.hl7.fhir.convertors.conv30_40.Group30_40; +import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_40; import org.hl7.fhir.dstu3.model.Group; import org.hl7.fhir.dstu3.model.IdType; import org.hl7.fhir.dstu3.model.OperationOutcome; @@ -54,13 +54,14 @@ public Group getGroupByUuid(@IdParam @Nonnull IdType id) { if (group == null) { throw new ResourceNotFoundException("Could not find Group with Id " + id.getIdPart()); } - return Group30_40.convertGroup(group); + return (Group) VersionConvertorFactory_30_40.convertResource(group); } @Create @SuppressWarnings("unused") public MethodOutcome createGroup(@ResourceParam Group group) { - return FhirProviderUtils.buildCreate(Group30_40.convertGroup(groupService.create(Group30_40.convertGroup(group)))); + return FhirProviderUtils.buildCreate(VersionConvertorFactory_30_40.convertResource( + groupService.create((org.hl7.fhir.r4.model.Group) VersionConvertorFactory_30_40.convertResource(group)))); } @Update @@ -73,7 +74,8 @@ public MethodOutcome updateGroup(@IdParam IdType id, @ResourceParam Group group) group.setId(id.getIdPart()); return FhirProviderUtils - .buildUpdate(Group30_40.convertGroup(groupService.update(id.getIdPart(), Group30_40.convertGroup(group)))); + .buildUpdate(VersionConvertorFactory_30_40.convertResource(groupService.update(id.getIdPart(), + (org.hl7.fhir.r4.model.Group) VersionConvertorFactory_30_40.convertResource(group)))); } @Delete diff --git a/api/src/main/java/org/openmrs/module/fhir2/providers/r3/LocationFhirResourceProvider.java b/api/src/main/java/org/openmrs/module/fhir2/providers/r3/LocationFhirResourceProvider.java index 9492cf56fb..5e1611c57a 100644 --- a/api/src/main/java/org/openmrs/module/fhir2/providers/r3/LocationFhirResourceProvider.java +++ b/api/src/main/java/org/openmrs/module/fhir2/providers/r3/LocationFhirResourceProvider.java @@ -38,7 +38,7 @@ import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; import lombok.Setter; import org.apache.commons.collections.CollectionUtils; -import org.hl7.fhir.convertors.conv30_40.Location30_40; +import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_40; import org.hl7.fhir.dstu3.model.Encounter; import org.hl7.fhir.dstu3.model.IdType; import org.hl7.fhir.dstu3.model.Location; @@ -73,13 +73,13 @@ public Location getLocationById(@IdParam @Nonnull IdType id) { throw new ResourceNotFoundException("Could not find location with Id " + id.getIdPart()); } - return Location30_40.convertLocation(location); + return (Location) VersionConvertorFactory_30_40.convertResource(location); } @Create public MethodOutcome createLocation(@ResourceParam Location location) { - return FhirProviderUtils - .buildCreate(Location30_40.convertLocation(locationService.create(Location30_40.convertLocation(location)))); + return FhirProviderUtils.buildCreate(VersionConvertorFactory_30_40.convertResource(locationService + .create((org.hl7.fhir.r4.model.Location) VersionConvertorFactory_30_40.convertResource(location)))); } @Update @@ -91,8 +91,9 @@ public MethodOutcome updateLocation(@IdParam IdType id, @ResourceParam Location location.setId(id.getIdPart()); - return FhirProviderUtils.buildUpdate( - Location30_40.convertLocation(locationService.update(id.getIdPart(), Location30_40.convertLocation(location)))); + return FhirProviderUtils + .buildUpdate(VersionConvertorFactory_30_40.convertResource(locationService.update(id.getIdPart(), + (org.hl7.fhir.r4.model.Location) VersionConvertorFactory_30_40.convertResource(location)))); } @Delete diff --git a/api/src/main/java/org/openmrs/module/fhir2/providers/r3/MedicationDispenseFhirResourceProvider.java b/api/src/main/java/org/openmrs/module/fhir2/providers/r3/MedicationDispenseFhirResourceProvider.java index d6ed9a1427..3d6c4ad386 100644 --- a/api/src/main/java/org/openmrs/module/fhir2/providers/r3/MedicationDispenseFhirResourceProvider.java +++ b/api/src/main/java/org/openmrs/module/fhir2/providers/r3/MedicationDispenseFhirResourceProvider.java @@ -37,7 +37,7 @@ import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; import lombok.Setter; import org.apache.commons.collections.CollectionUtils; -import org.hl7.fhir.convertors.conv30_40.MedicationDispense30_40; +import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_40; import org.hl7.fhir.dstu3.model.Encounter; import org.hl7.fhir.dstu3.model.IdType; import org.hl7.fhir.dstu3.model.MedicationDispense; @@ -73,14 +73,14 @@ public MedicationDispense getMedicationDispenseByUuid(@IdParam @Nonnull IdType i if (r4Obj == null) { throw new ResourceNotFoundException("Could not find medicationDispense with Id " + id.getIdPart()); } - return MedicationDispense30_40.convertMedicationDispense(r4Obj); + return (MedicationDispense) VersionConvertorFactory_30_40.convertResource(r4Obj); } @Create public MethodOutcome createMedicationDispense(@ResourceParam MedicationDispense mDispense) { org.hl7.fhir.r4.model.MedicationDispense r4Obj = fhirMedicationDispenseService - .create(MedicationDispense30_40.convertMedicationDispense(mDispense)); - return FhirProviderUtils.buildCreate(MedicationDispense30_40.convertMedicationDispense(r4Obj)); + .create((org.hl7.fhir.r4.model.MedicationDispense) VersionConvertorFactory_30_40.convertResource(mDispense)); + return FhirProviderUtils.buildCreate(VersionConvertorFactory_30_40.convertResource(r4Obj)); } @Update @@ -90,7 +90,7 @@ public MethodOutcome updateMedicationDispense(@IdParam IdType id, @ResourceParam } mDispense.setId(id.getIdPart()); org.hl7.fhir.r4.model.MedicationDispense r4Obj = fhirMedicationDispenseService.update(id.getIdPart(), - MedicationDispense30_40.convertMedicationDispense(mDispense)); + (org.hl7.fhir.r4.model.MedicationDispense) VersionConvertorFactory_30_40.convertResource(mDispense)); return FhirProviderUtils.buildUpdate(r4Obj); } diff --git a/api/src/main/java/org/openmrs/module/fhir2/providers/r3/MedicationFhirResourceProvider.java b/api/src/main/java/org/openmrs/module/fhir2/providers/r3/MedicationFhirResourceProvider.java index 7a8db5f04e..afd73e1f7d 100644 --- a/api/src/main/java/org/openmrs/module/fhir2/providers/r3/MedicationFhirResourceProvider.java +++ b/api/src/main/java/org/openmrs/module/fhir2/providers/r3/MedicationFhirResourceProvider.java @@ -33,7 +33,7 @@ import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; import lombok.Setter; import org.apache.commons.collections.CollectionUtils; -import org.hl7.fhir.convertors.conv30_40.Medication30_40; +import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_40; import org.hl7.fhir.dstu3.model.IdType; import org.hl7.fhir.dstu3.model.Medication; import org.hl7.fhir.dstu3.model.MedicationDispense; @@ -69,14 +69,14 @@ public Medication getMedicationById(@IdParam @Nonnull IdType id) { throw new ResourceNotFoundException("Could not find medication with Id " + id.getIdPart()); } - return Medication30_40.convertMedication(medication); + return (Medication) VersionConvertorFactory_30_40.convertResource(medication); } @Create @SuppressWarnings("unused") public MethodOutcome createMedication(@ResourceParam Medication medication) { - return FhirProviderUtils.buildCreate( - Medication30_40.convertMedication(medicationService.create(Medication30_40.convertMedication(medication)))); + return FhirProviderUtils.buildCreate(VersionConvertorFactory_30_40.convertResource(medicationService + .create((org.hl7.fhir.r4.model.Medication) VersionConvertorFactory_30_40.convertResource(medication)))); } @Update @@ -86,8 +86,9 @@ public MethodOutcome updateMedication(@IdParam IdType id, @ResourceParam Medicat medication.setId(id.getIdPart()); } - return FhirProviderUtils.buildUpdate(Medication30_40.convertMedication( - medicationService.update(id == null ? null : id.getIdPart(), Medication30_40.convertMedication(medication)))); + return FhirProviderUtils.buildUpdate( + VersionConvertorFactory_30_40.convertResource(medicationService.update(id == null ? null : id.getIdPart(), + (org.hl7.fhir.r4.model.Medication) VersionConvertorFactory_30_40.convertResource(medication)))); } @Delete diff --git a/api/src/main/java/org/openmrs/module/fhir2/providers/r3/MedicationRequestFhirResourceProvider.java b/api/src/main/java/org/openmrs/module/fhir2/providers/r3/MedicationRequestFhirResourceProvider.java index 7327fb928b..524bfc74a6 100644 --- a/api/src/main/java/org/openmrs/module/fhir2/providers/r3/MedicationRequestFhirResourceProvider.java +++ b/api/src/main/java/org/openmrs/module/fhir2/providers/r3/MedicationRequestFhirResourceProvider.java @@ -35,7 +35,7 @@ import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; import lombok.Setter; import org.apache.commons.collections.CollectionUtils; -import org.hl7.fhir.convertors.conv30_40.MedicationRequest30_40; +import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_40; import org.hl7.fhir.dstu3.model.Encounter; import org.hl7.fhir.dstu3.model.IdType; import org.hl7.fhir.dstu3.model.Medication; @@ -75,7 +75,7 @@ public MedicationRequest getMedicationRequestById(@IdParam @Nonnull IdType id) { throw new ResourceNotFoundException("Could not find medicationRequest with Id " + id.getIdPart()); } - return MedicationRequest30_40.convertMedicationRequest(medicationRequest); + return (MedicationRequest) VersionConvertorFactory_30_40.convertResource(medicationRequest); } // NOTE: POST/Create not yet supported, see: https://issues.openmrs.org/browse/FM2-568 diff --git a/api/src/main/java/org/openmrs/module/fhir2/providers/r3/ObservationFhirResourceProvider.java b/api/src/main/java/org/openmrs/module/fhir2/providers/r3/ObservationFhirResourceProvider.java index c5044fc501..2735db8065 100644 --- a/api/src/main/java/org/openmrs/module/fhir2/providers/r3/ObservationFhirResourceProvider.java +++ b/api/src/main/java/org/openmrs/module/fhir2/providers/r3/ObservationFhirResourceProvider.java @@ -41,7 +41,7 @@ import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; import lombok.Setter; import org.apache.commons.collections.CollectionUtils; -import org.hl7.fhir.convertors.conv30_40.Observation30_40; +import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_40; import org.hl7.fhir.dstu3.model.DiagnosticReport; import org.hl7.fhir.dstu3.model.Encounter; import org.hl7.fhir.dstu3.model.IdType; @@ -78,13 +78,13 @@ public Observation getObservationById(@IdParam @Nonnull IdType id) { throw new ResourceNotFoundException("Could not find observation with Id " + id.getIdPart()); } - return Observation30_40.convertObservation(observation); + return (Observation) VersionConvertorFactory_30_40.convertResource(observation); } @Create public MethodOutcome createObservationResource(@ResourceParam Observation observation) { - return FhirProviderUtils.buildCreate(Observation30_40 - .convertObservation(observationService.create(Observation30_40.convertObservation(observation)))); + return FhirProviderUtils.buildCreate(VersionConvertorFactory_30_40.convertResource(observationService + .create((org.hl7.fhir.r4.model.Observation) VersionConvertorFactory_30_40.convertResource(observation)))); } @Delete diff --git a/api/src/main/java/org/openmrs/module/fhir2/providers/r3/PatientFhirResourceProvider.java b/api/src/main/java/org/openmrs/module/fhir2/providers/r3/PatientFhirResourceProvider.java index 531f78e3f2..0b20682ed9 100644 --- a/api/src/main/java/org/openmrs/module/fhir2/providers/r3/PatientFhirResourceProvider.java +++ b/api/src/main/java/org/openmrs/module/fhir2/providers/r3/PatientFhirResourceProvider.java @@ -40,7 +40,7 @@ import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; import lombok.Setter; import org.apache.commons.collections.CollectionUtils; -import org.hl7.fhir.convertors.conv30_40.Patient30_40; +import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_40; import org.hl7.fhir.dstu3.model.AllergyIntolerance; import org.hl7.fhir.dstu3.model.DiagnosticReport; import org.hl7.fhir.dstu3.model.Encounter; @@ -83,13 +83,13 @@ public Patient getPatientById(@IdParam @Nonnull IdType id) { throw new ResourceNotFoundException("Could not find patient with Id " + id.getIdPart()); } - return Patient30_40.convertPatient(patient); + return (Patient) VersionConvertorFactory_30_40.convertResource(patient); } @Create public MethodOutcome createPatient(@ResourceParam Patient patient) { - return FhirProviderUtils - .buildCreate(Patient30_40.convertPatient(patientService.create(Patient30_40.convertPatient(patient)))); + return FhirProviderUtils.buildCreate(VersionConvertorFactory_30_40.convertResource( + patientService.create((org.hl7.fhir.r4.model.Patient) VersionConvertorFactory_30_40.convertResource(patient)))); } @Update @@ -101,8 +101,9 @@ public MethodOutcome updatePatient(@IdParam IdType id, @ResourceParam Patient pa patient.setId(id.getIdPart()); - return FhirProviderUtils.buildUpdate( - Patient30_40.convertPatient(patientService.update(id.getIdPart(), Patient30_40.convertPatient(patient)))); + return FhirProviderUtils + .buildUpdate(VersionConvertorFactory_30_40.convertResource(patientService.update(id.getIdPart(), + (org.hl7.fhir.r4.model.Patient) VersionConvertorFactory_30_40.convertResource(patient)))); } @Delete diff --git a/api/src/main/java/org/openmrs/module/fhir2/providers/r3/PersonFhirResourceProvider.java b/api/src/main/java/org/openmrs/module/fhir2/providers/r3/PersonFhirResourceProvider.java index fbd0ab67c7..85244346eb 100644 --- a/api/src/main/java/org/openmrs/module/fhir2/providers/r3/PersonFhirResourceProvider.java +++ b/api/src/main/java/org/openmrs/module/fhir2/providers/r3/PersonFhirResourceProvider.java @@ -37,7 +37,7 @@ import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; import lombok.Setter; import org.apache.commons.collections.CollectionUtils; -import org.hl7.fhir.convertors.conv30_40.Person30_40; +import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_40; import org.hl7.fhir.dstu3.model.IdType; import org.hl7.fhir.dstu3.model.OperationOutcome; import org.hl7.fhir.dstu3.model.Person; @@ -71,13 +71,13 @@ public Person getPersonById(@IdParam @Nonnull IdType id) { throw new ResourceNotFoundException("Could not find person with Id " + id.getIdPart()); } - return Person30_40.convertPerson(person); + return (Person) VersionConvertorFactory_30_40.convertResource(person); } @Create public MethodOutcome createPerson(@ResourceParam Person person) { - return FhirProviderUtils - .buildCreate(Person30_40.convertPerson(personService.create(Person30_40.convertPerson(person)))); + return FhirProviderUtils.buildCreate(VersionConvertorFactory_30_40.convertResource( + personService.create((org.hl7.fhir.r4.model.Person) VersionConvertorFactory_30_40.convertResource(person)))); } @Update @@ -89,8 +89,9 @@ public MethodOutcome updatePerson(@IdParam IdType id, @ResourceParam Person pers person.setId(id.getIdPart()); - return FhirProviderUtils.buildUpdate( - Person30_40.convertPerson(personService.update(id.getIdPart(), Person30_40.convertPerson(person)))); + return FhirProviderUtils + .buildUpdate(VersionConvertorFactory_30_40.convertResource(personService.update(id.getIdPart(), + (org.hl7.fhir.r4.model.Person) VersionConvertorFactory_30_40.convertResource(person)))); } @Delete diff --git a/api/src/main/java/org/openmrs/module/fhir2/providers/r3/PractitionerFhirResourceProvider.java b/api/src/main/java/org/openmrs/module/fhir2/providers/r3/PractitionerFhirResourceProvider.java index 79efb4399f..42ab0a6d11 100644 --- a/api/src/main/java/org/openmrs/module/fhir2/providers/r3/PractitionerFhirResourceProvider.java +++ b/api/src/main/java/org/openmrs/module/fhir2/providers/r3/PractitionerFhirResourceProvider.java @@ -35,7 +35,7 @@ import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; import lombok.Setter; import org.apache.commons.collections.CollectionUtils; -import org.hl7.fhir.convertors.conv30_40.Practitioner30_40; +import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_40; import org.hl7.fhir.dstu3.model.Encounter; import org.hl7.fhir.dstu3.model.IdType; import org.hl7.fhir.dstu3.model.MedicationDispense; @@ -73,13 +73,13 @@ public Practitioner getPractitionerById(@IdParam @Nonnull IdType id) { throw new ResourceNotFoundException("Could not find practitioner with Id " + id.getIdPart()); } - return Practitioner30_40.convertPractitioner(practitioner); + return (Practitioner) VersionConvertorFactory_30_40.convertResource(practitioner); } @Create public MethodOutcome createPractitioner(@ResourceParam Practitioner practitioner) { - return FhirProviderUtils.buildCreate(Practitioner30_40 - .convertPractitioner(practitionerService.create(Practitioner30_40.convertPractitioner(practitioner)))); + return FhirProviderUtils.buildCreate(VersionConvertorFactory_30_40.convertResource(practitionerService + .create((org.hl7.fhir.r4.model.Practitioner) VersionConvertorFactory_30_40.convertResource(practitioner)))); } @Update @@ -91,8 +91,9 @@ public MethodOutcome updatePractitioner(@IdParam IdType id, @ResourceParam Pract practitioner.setId(id.getIdPart()); - return FhirProviderUtils.buildUpdate(Practitioner30_40.convertPractitioner( - practitionerService.update(id.getIdPart(), Practitioner30_40.convertPractitioner(practitioner)))); + return FhirProviderUtils + .buildUpdate(VersionConvertorFactory_30_40.convertResource(practitionerService.update(id.getIdPart(), + (org.hl7.fhir.r4.model.Practitioner) VersionConvertorFactory_30_40.convertResource(practitioner)))); } @Delete diff --git a/api/src/main/java/org/openmrs/module/fhir2/providers/r3/ProcedureRequestFhirResourceProvider.java b/api/src/main/java/org/openmrs/module/fhir2/providers/r3/ProcedureRequestFhirResourceProvider.java index b27824320b..6e51e4dc40 100644 --- a/api/src/main/java/org/openmrs/module/fhir2/providers/r3/ProcedureRequestFhirResourceProvider.java +++ b/api/src/main/java/org/openmrs/module/fhir2/providers/r3/ProcedureRequestFhirResourceProvider.java @@ -32,7 +32,7 @@ import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; import lombok.Setter; import org.apache.commons.collections.CollectionUtils; -import org.hl7.fhir.convertors.VersionConvertor_30_40; +import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_40; import org.hl7.fhir.dstu3.model.Encounter; import org.hl7.fhir.dstu3.model.IdType; import org.hl7.fhir.dstu3.model.OperationOutcome; @@ -68,13 +68,12 @@ public ProcedureRequest getProcedureRequestById(@IdParam @Nonnull IdType id) { if (serviceRequest == null) { throw new ResourceNotFoundException("Could not find serviceRequest with Id " + id.getIdPart()); } - return (ProcedureRequest) VersionConvertor_30_40.convertResource(serviceRequest, false); + return (ProcedureRequest) VersionConvertorFactory_30_40.convertResource(serviceRequest); } public MethodOutcome createProcedureRequest(@ResourceParam ProcedureRequest procedureRequest) { - return FhirProviderUtils.buildCreate(VersionConvertor_30_40.convertResource( - serviceRequestService.create((ServiceRequest) VersionConvertor_30_40.convertResource(procedureRequest, false)), - false)); + return FhirProviderUtils.buildCreate(VersionConvertorFactory_30_40.convertResource( + serviceRequestService.create((ServiceRequest) VersionConvertorFactory_30_40.convertResource(procedureRequest)))); } public MethodOutcome updateProcedureRequest(@IdParam IdType id, @ResourceParam ProcedureRequest procedureRequest) { @@ -84,9 +83,8 @@ public MethodOutcome updateProcedureRequest(@IdParam IdType id, @ResourceParam P procedureRequest.setId(id.getIdPart()); - return FhirProviderUtils - .buildUpdate(VersionConvertor_30_40.convertResource(serviceRequestService.update(id.getIdPart(), - (ServiceRequest) VersionConvertor_30_40.convertResource(procedureRequest, false)), false)); + return FhirProviderUtils.buildUpdate(VersionConvertorFactory_30_40.convertResource(serviceRequestService + .update(id.getIdPart(), (ServiceRequest) VersionConvertorFactory_30_40.convertResource(procedureRequest)))); } public OperationOutcome deleteProcedureRequest(@IdParam @Nonnull IdType id) { diff --git a/api/src/main/java/org/openmrs/module/fhir2/providers/r3/RelatedPersonFhirResourceProvider.java b/api/src/main/java/org/openmrs/module/fhir2/providers/r3/RelatedPersonFhirResourceProvider.java index 4be7da7f89..451b1c9a40 100644 --- a/api/src/main/java/org/openmrs/module/fhir2/providers/r3/RelatedPersonFhirResourceProvider.java +++ b/api/src/main/java/org/openmrs/module/fhir2/providers/r3/RelatedPersonFhirResourceProvider.java @@ -31,7 +31,7 @@ import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; import lombok.Setter; import org.apache.commons.collections.CollectionUtils; -import org.hl7.fhir.convertors.conv30_40.RelatedPerson30_40; +import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_40; import org.hl7.fhir.dstu3.model.IdType; import org.hl7.fhir.dstu3.model.RelatedPerson; import org.hl7.fhir.instance.model.api.IBaseResource; @@ -62,7 +62,7 @@ public RelatedPerson getRelatedPersonById(@IdParam @Nonnull IdType id) { if (relatedPerson == null) { throw new ResourceNotFoundException("Could not find relatedPerson with Id " + id.getIdPart()); } - return RelatedPerson30_40.convertRelatedPerson(relatedPerson); + return (RelatedPerson) VersionConvertorFactory_30_40.convertResource(relatedPerson); } @Search diff --git a/api/src/main/java/org/openmrs/module/fhir2/providers/r3/ValueSetFhirResourceProvider.java b/api/src/main/java/org/openmrs/module/fhir2/providers/r3/ValueSetFhirResourceProvider.java index 0e63cbcb70..d96bc261d5 100644 --- a/api/src/main/java/org/openmrs/module/fhir2/providers/r3/ValueSetFhirResourceProvider.java +++ b/api/src/main/java/org/openmrs/module/fhir2/providers/r3/ValueSetFhirResourceProvider.java @@ -22,7 +22,7 @@ import ca.uhn.fhir.rest.server.IResourceProvider; import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; import lombok.Setter; -import org.hl7.fhir.convertors.conv30_40.ValueSet30_40; +import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_40; import org.hl7.fhir.dstu3.model.IdType; import org.hl7.fhir.dstu3.model.ValueSet; import org.hl7.fhir.instance.model.api.IBaseResource; @@ -51,7 +51,7 @@ public ValueSet getValueSetByUuid(@IdParam @Nonnull IdType id) { if (valueSet == null) { throw new ResourceNotFoundException("Could not find valueset with Id" + id.getIdPart()); } - return ValueSet30_40.convertValueSet(valueSet); + return (ValueSet) VersionConvertorFactory_30_40.convertResource(valueSet); } @Search diff --git a/api/src/main/java/org/openmrs/module/fhir2/providers/util/TaskVersionConverter.java b/api/src/main/java/org/openmrs/module/fhir2/providers/util/TaskVersionConverter.java index 2bc8f9c74b..39c0c6eb76 100644 --- a/api/src/main/java/org/openmrs/module/fhir2/providers/util/TaskVersionConverter.java +++ b/api/src/main/java/org/openmrs/module/fhir2/providers/util/TaskVersionConverter.java @@ -9,7 +9,20 @@ */ package org.openmrs.module.fhir2.providers.util; -import org.hl7.fhir.convertors.VersionConvertor_30_40; +import static org.hl7.fhir.convertors.conv30_40.datatypes30_40.Reference30_40.convertReference; +import static org.hl7.fhir.convertors.conv30_40.datatypes30_40.complextypes30_40.Annotation30_40.convertAnnotation; +import static org.hl7.fhir.convertors.conv30_40.datatypes30_40.complextypes30_40.CodeableConcept30_40.convertCodeableConcept; +import static org.hl7.fhir.convertors.conv30_40.datatypes30_40.complextypes30_40.Identifier30_40.convertIdentifier; +import static org.hl7.fhir.convertors.conv30_40.datatypes30_40.complextypes30_40.Period30_40.convertPeriod; +import static org.hl7.fhir.convertors.conv30_40.datatypes30_40.primitivetypes30_40.DateTime30_40.convertDateTime; +import static org.hl7.fhir.convertors.conv30_40.datatypes30_40.primitivetypes30_40.PositiveInt30_40.convertPositiveInt; +import static org.hl7.fhir.convertors.conv30_40.datatypes30_40.primitivetypes30_40.String30_40.convertString; +import static org.hl7.fhir.convertors.conv30_40.datatypes30_40.primitivetypes30_40.Uri30_40.convertUri; +import static org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_40.convertType; + +import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_30_40; +import org.hl7.fhir.convertors.context.ConversionContext30_40; +import org.hl7.fhir.convertors.conv30_40.VersionConvertor_30_40; import org.hl7.fhir.dstu3.model.Task; import org.hl7.fhir.exceptions.FHIRException; @@ -17,99 +30,108 @@ public class TaskVersionConverter { public static org.hl7.fhir.dstu3.model.Task convertTask(org.hl7.fhir.r4.model.Task src) throws FHIRException { org.hl7.fhir.dstu3.model.Task tgt = new org.hl7.fhir.dstu3.model.Task(); - VersionConvertor_30_40.copyDomainResource(src, tgt); - for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier()) { - tgt.addIdentifier(VersionConvertor_30_40.convertIdentifier(t)); - } - //TODO: check - if (src.hasInstantiatesUri()) { - tgt.setDefinition(VersionConvertor_30_40.convertType(src.getInstantiatesUriElement())); - } - //TODO: check - if (src.hasInstantiatesCanonical()) { - tgt.setDefinition(VersionConvertor_30_40.convertType(src.getInstantiatesCanonicalElement())); - } - if (src.hasBasedOn()) { - for (org.hl7.fhir.r4.model.Reference t : src.getBasedOn()) { - tgt.addBasedOn(VersionConvertor_30_40.convertReference(t)); + + VersionConvertor_30_40 convertor = new VersionConvertor_30_40(new BaseAdvisor_30_40(false)); + ConversionContext30_40.INSTANCE.init(convertor, src.fhirType()); + try { + convertor.copyDomainResource(src, tgt); + + for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier()) { + tgt.addIdentifier(convertIdentifier(t)); } - } - if (src.hasGroupIdentifier()) { - tgt.setGroupIdentifier(VersionConvertor_30_40.convertIdentifier(src.getGroupIdentifier())); - } - if (src.hasPartOf()) { - for (org.hl7.fhir.r4.model.Reference t : src.getPartOf()) { - tgt.addPartOf(VersionConvertor_30_40.convertReference(t)); + //TODO: check + if (src.hasInstantiatesUri()) { + tgt.setDefinition(convertType(src.getInstantiatesUriElement())); + } + //TODO: check + if (src.hasInstantiatesCanonical()) { + tgt.setDefinition(convertType(src.getInstantiatesCanonicalElement())); + } + if (src.hasBasedOn()) { + for (org.hl7.fhir.r4.model.Reference t : src.getBasedOn()) { + tgt.addBasedOn(convertReference(t)); + } + } + if (src.hasGroupIdentifier()) { + tgt.setGroupIdentifier(convertIdentifier(src.getGroupIdentifier())); + } + if (src.hasPartOf()) { + for (org.hl7.fhir.r4.model.Reference t : src.getPartOf()) { + tgt.addPartOf(convertReference(t)); + } + } + if (src.hasStatus()) { + tgt.setStatusElement(convertTaskStatus(src.getStatusElement())); + } + if (src.hasStatusReason()) { + tgt.setStatusReason(convertCodeableConcept(src.getStatusReason())); + } + if (src.hasBusinessStatus()) { + tgt.setBusinessStatus(convertCodeableConcept(src.getBusinessStatus())); + } + if (src.hasIntent()) { + tgt.setIntentElement(convertTaskIntent(src.getIntentElement())); + } + if (src.hasPriority()) { + tgt.setPriorityElement(convertProcedureRequestPriority(src.getPriorityElement())); + } + if (src.hasCode()) { + tgt.setCode(convertCodeableConcept(src.getCode())); + } + if (src.hasDescription()) { + tgt.setDescriptionElement(convertString(src.getDescriptionElement())); + } + if (src.hasFocus()) { + tgt.setFocus(convertReference(src.getFocus())); + } + if (src.hasFor()) { + tgt.setFor(convertReference(src.getFor())); + } + if (src.hasEncounter()) { + tgt.setContext(convertReference(src.getEncounter())); + } + if (src.hasExecutionPeriod()) { + tgt.setExecutionPeriod(convertPeriod(src.getExecutionPeriod())); + } + if (src.hasAuthoredOn()) { + tgt.setAuthoredOnElement(convertDateTime(src.getAuthoredOnElement())); + } + if (src.hasLastModified()) { + tgt.setLastModifiedElement(convertDateTime(src.getLastModifiedElement())); + } + if (src.hasRequester()) { + tgt.getRequester().setAgent(convertReference(src.getRequester())); + } + if (src.hasPerformerType()) { + for (org.hl7.fhir.r4.model.CodeableConcept t : src.getPerformerType()) + tgt.addPerformerType(convertCodeableConcept(t)); + } + if (src.hasOwner()) { + tgt.setOwner(convertReference(src.getOwner())); + } + if (src.hasReasonCode()) { + tgt.setReason(convertCodeableConcept(src.getReasonCode())); + } + if (src.hasNote()) { + for (org.hl7.fhir.r4.model.Annotation t : src.getNote()) + tgt.addNote(convertAnnotation(t)); + } + if (src.hasRelevantHistory()) { + for (org.hl7.fhir.r4.model.Reference t : src.getRelevantHistory()) + tgt.addRelevantHistory(convertReference(t)); + } + if (src.hasRestriction()) { + tgt.setRestriction(convertTaskRestriction(src.getRestriction(), tgt.getRestriction())); + } + if (src.hasInput()) { + convertTaskInput(src, tgt); + } + if (src.hasOutput()) { + convertTaskOutput(src, tgt); } } - if (src.hasStatus()) { - tgt.setStatusElement(convertTaskStatus(src.getStatusElement())); - } - if (src.hasStatusReason()) { - tgt.setStatusReason(VersionConvertor_30_40.convertCodeableConcept(src.getStatusReason())); - } - if (src.hasBusinessStatus()) { - tgt.setBusinessStatus(VersionConvertor_30_40.convertCodeableConcept(src.getBusinessStatus())); - } - if (src.hasIntent()) { - tgt.setIntentElement(convertTaskIntent(src.getIntentElement())); - } - if (src.hasPriority()) { - tgt.setPriorityElement(convertProcedureRequestPriority(src.getPriorityElement())); - } - if (src.hasCode()) { - tgt.setCode(VersionConvertor_30_40.convertCodeableConcept(src.getCode())); - } - if (src.hasDescription()) { - tgt.setDescriptionElement(VersionConvertor_30_40.convertString(src.getDescriptionElement())); - } - if (src.hasFocus()) { - tgt.setFocus(VersionConvertor_30_40.convertReference(src.getFocus())); - } - if (src.hasFor()) { - tgt.setFor(VersionConvertor_30_40.convertReference(src.getFor())); - } - if (src.hasEncounter()) { - tgt.setContext(VersionConvertor_30_40.convertReference(src.getEncounter())); - } - if (src.hasExecutionPeriod()) { - tgt.setExecutionPeriod(VersionConvertor_30_40.convertPeriod(src.getExecutionPeriod())); - } - if (src.hasAuthoredOn()) { - tgt.setAuthoredOnElement(VersionConvertor_30_40.convertDateTime(src.getAuthoredOnElement())); - } - if (src.hasLastModified()) { - tgt.setLastModifiedElement(VersionConvertor_30_40.convertDateTime(src.getLastModifiedElement())); - } - if (src.hasRequester()) { - tgt.getRequester().setAgent(VersionConvertor_30_40.convertReference(src.getRequester())); - } - if (src.hasPerformerType()) { - for (org.hl7.fhir.r4.model.CodeableConcept t : src.getPerformerType()) - tgt.addPerformerType(VersionConvertor_30_40.convertCodeableConcept(t)); - } - if (src.hasOwner()) { - tgt.setOwner(VersionConvertor_30_40.convertReference(src.getOwner())); - } - if (src.hasReasonCode()) { - tgt.setReason(VersionConvertor_30_40.convertCodeableConcept(src.getReasonCode())); - } - if (src.hasNote()) { - for (org.hl7.fhir.r4.model.Annotation t : src.getNote()) - tgt.addNote(VersionConvertor_30_40.convertAnnotation(t)); - } - if (src.hasRelevantHistory()) { - for (org.hl7.fhir.r4.model.Reference t : src.getRelevantHistory()) - tgt.addRelevantHistory(VersionConvertor_30_40.convertReference(t)); - } - if (src.hasRestriction()) { - tgt.setRestriction(convertTaskRestriction(src.getRestriction(), tgt.getRestriction())); - } - if (src.hasInput()) { - convertTaskInput(src, tgt); - } - if (src.hasOutput()) { - convertTaskOutput(src, tgt); + finally { + ConversionContext30_40.INSTANCE.close(src.fhirType()); } return tgt; @@ -117,101 +139,108 @@ public static org.hl7.fhir.dstu3.model.Task convertTask(org.hl7.fhir.r4.model.Ta public static org.hl7.fhir.r4.model.Task convertTask(org.hl7.fhir.dstu3.model.Task src) throws FHIRException { org.hl7.fhir.r4.model.Task tgt = new org.hl7.fhir.r4.model.Task(); - VersionConvertor_30_40.copyDomainResource(src, tgt); - for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier()) { - tgt.addIdentifier(VersionConvertor_30_40.convertIdentifier(t)); - } - //TODO: check - if (src.hasDefinition()) { - tgt.setInstantiatesUri(String.valueOf(VersionConvertor_30_40.convertUri(src.getDefinitionUriType()))); - } - //TODO: check - if (src.hasDefinition()) { - tgt.setInstantiatesCanonical( - String.valueOf(VersionConvertor_30_40.convertReference(src.getDefinitionReference()))); - } - if (src.hasBasedOn()) { - for (org.hl7.fhir.dstu3.model.Reference t : src.getBasedOn()) { - tgt.addBasedOn(VersionConvertor_30_40.convertReference(t)); + VersionConvertor_30_40 convertor = new VersionConvertor_30_40(new BaseAdvisor_30_40(false)); + ConversionContext30_40.INSTANCE.init(convertor, src.fhirType()); + try { + convertor.copyDomainResource(src, tgt); + + for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier()) { + tgt.addIdentifier(convertIdentifier(t)); } - } - if (src.hasGroupIdentifier()) { - tgt.setGroupIdentifier(VersionConvertor_30_40.convertIdentifier(src.getGroupIdentifier())); - } - if (src.hasPartOf()) { - for (org.hl7.fhir.dstu3.model.Reference t : src.getPartOf()) { - tgt.addPartOf(VersionConvertor_30_40.convertReference(t)); + //TODO: check + if (src.hasDefinition()) { + tgt.setInstantiatesUri(String.valueOf(convertUri(src.getDefinitionUriType()))); + } + //TODO: check + if (src.hasDefinition()) { + tgt.setInstantiatesCanonical(String.valueOf(convertReference(src.getDefinitionReference()))); + } + if (src.hasBasedOn()) { + for (org.hl7.fhir.dstu3.model.Reference t : src.getBasedOn()) { + tgt.addBasedOn(convertReference(t)); + } + } + if (src.hasGroupIdentifier()) { + tgt.setGroupIdentifier(convertIdentifier(src.getGroupIdentifier())); + } + if (src.hasPartOf()) { + for (org.hl7.fhir.dstu3.model.Reference t : src.getPartOf()) { + tgt.addPartOf(convertReference(t)); + } + } + if (src.hasStatus()) { + tgt.setStatusElement(convertTaskStatus(src.getStatusElement())); + } + if (src.hasStatusReason()) { + tgt.setStatusReason(convertCodeableConcept(src.getStatusReason())); + } + if (src.hasBusinessStatus()) { + tgt.setBusinessStatus(convertCodeableConcept(src.getBusinessStatus())); + } + if (src.hasIntent()) { + tgt.setIntentElement(convertTaskIntent(src.getIntentElement())); + } + if (src.hasPriority()) { + tgt.setPriorityElement(convertProcedureRequestPriority(src.getPriorityElement())); + } + if (src.hasCode()) { + tgt.setCode(convertCodeableConcept(src.getCode())); + } + if (src.hasDescription()) { + tgt.setDescriptionElement(convertString(src.getDescriptionElement())); + } + if (src.hasFocus()) { + tgt.setFocus(convertReference(src.getFocus())); + } + if (src.hasFor()) { + tgt.setFor(convertReference(src.getFor())); + } + if (src.hasContext()) { + tgt.setFocus(convertReference(src.getContext())); + } + if (src.hasExecutionPeriod()) { + tgt.setExecutionPeriod(convertPeriod(src.getExecutionPeriod())); + } + if (src.hasAuthoredOn()) { + tgt.setAuthoredOnElement(convertDateTime(src.getAuthoredOnElement())); + } + if (src.hasLastModified()) { + tgt.setLastModifiedElement(convertDateTime(src.getLastModifiedElement())); + } + if (src.hasRequester()) { + tgt.setRequester(convertReference(src.getRequester().getAgent())); + } + if (src.hasPerformerType()) { + for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getPerformerType()) + tgt.addPerformerType(convertCodeableConcept(t)); + } + if (src.hasOwner()) { + tgt.setOwner(convertReference(src.getOwner())); + } + if (src.hasReason()) { + tgt.setReasonCode(convertCodeableConcept(src.getReason())); + } + if (src.hasNote()) { + for (org.hl7.fhir.dstu3.model.Annotation t : src.getNote()) + tgt.addNote(convertAnnotation(t)); + } + if (src.hasRelevantHistory()) { + for (org.hl7.fhir.dstu3.model.Reference t : src.getRelevantHistory()) + tgt.addRelevantHistory(convertReference(t)); + } + if (src.hasRestriction()) { + tgt.setRestriction(convertTaskRestriction(src.getRestriction(), tgt.getRestriction())); + } + if (src.hasInput()) { + convertTaskInput(src, tgt); + } + if (src.hasOutput()) { + convertTaskOutput(src, tgt); } } - if (src.hasStatus()) { - tgt.setStatusElement(convertTaskStatus(src.getStatusElement())); - } - if (src.hasStatusReason()) { - tgt.setStatusReason(VersionConvertor_30_40.convertCodeableConcept(src.getStatusReason())); - } - if (src.hasBusinessStatus()) { - tgt.setBusinessStatus(VersionConvertor_30_40.convertCodeableConcept(src.getBusinessStatus())); - } - if (src.hasIntent()) { - tgt.setIntentElement(convertTaskIntent(src.getIntentElement())); - } - if (src.hasPriority()) { - tgt.setPriorityElement(convertProcedureRequestPriority(src.getPriorityElement())); - } - if (src.hasCode()) { - tgt.setCode(VersionConvertor_30_40.convertCodeableConcept(src.getCode())); - } - if (src.hasDescription()) { - tgt.setDescriptionElement(VersionConvertor_30_40.convertString(src.getDescriptionElement())); - } - if (src.hasFocus()) { - tgt.setFocus(VersionConvertor_30_40.convertReference(src.getFocus())); - } - if (src.hasFor()) { - tgt.setFor(VersionConvertor_30_40.convertReference(src.getFor())); - } - if (src.hasContext()) { - tgt.setFocus(VersionConvertor_30_40.convertReference(src.getContext())); - } - if (src.hasExecutionPeriod()) { - tgt.setExecutionPeriod(VersionConvertor_30_40.convertPeriod(src.getExecutionPeriod())); - } - if (src.hasAuthoredOn()) { - tgt.setAuthoredOnElement(VersionConvertor_30_40.convertDateTime(src.getAuthoredOnElement())); - } - if (src.hasLastModified()) { - tgt.setLastModifiedElement(VersionConvertor_30_40.convertDateTime(src.getLastModifiedElement())); - } - if (src.hasRequester()) { - tgt.setRequester(VersionConvertor_30_40.convertReference(src.getRequester().getAgent())); - } - if (src.hasPerformerType()) { - for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getPerformerType()) - tgt.addPerformerType(VersionConvertor_30_40.convertCodeableConcept(t)); - } - if (src.hasOwner()) { - tgt.setOwner(VersionConvertor_30_40.convertReference(src.getOwner())); - } - if (src.hasReason()) { - tgt.setReasonCode(VersionConvertor_30_40.convertCodeableConcept(src.getReason())); - } - if (src.hasNote()) { - for (org.hl7.fhir.dstu3.model.Annotation t : src.getNote()) - tgt.addNote(VersionConvertor_30_40.convertAnnotation(t)); - } - if (src.hasRelevantHistory()) { - for (org.hl7.fhir.dstu3.model.Reference t : src.getRelevantHistory()) - tgt.addRelevantHistory(VersionConvertor_30_40.convertReference(t)); - } - if (src.hasRestriction()) { - tgt.setRestriction(convertTaskRestriction(src.getRestriction(), tgt.getRestriction())); - } - if (src.hasInput()) { - convertTaskInput(src, tgt); - } - if (src.hasOutput()) { - convertTaskOutput(src, tgt); + finally { + ConversionContext30_40.INSTANCE.close(src.fhirType()); } return tgt; @@ -260,9 +289,6 @@ public static org.hl7.fhir.r4.model.Enumeration convertTaskS case ENTEREDINERROR: tgt.setValue(Task.TaskStatus.ENTEREDINERROR); break; - case NULL: - tgt.setValue(Task.TaskStatus.NULL); - break; default: tgt.setValue(Task.TaskStatus.NULL); break; @@ -354,9 +377,6 @@ public static org.hl7.fhir.r4.model.Enumeration convertTaskI case OPTION: tgt.setValue(Task.TaskIntent.OPTION); break; - case NULL: - tgt.setValue(Task.TaskIntent.NULL); - break; default: tgt.setValue(Task.TaskIntent.NULL); break; @@ -424,9 +441,6 @@ public static org.hl7.fhir.r4.model.Enumeration tgt.addInput().setType(VersionConvertor_30_40.convertCodeableConcept(ti.getType())) - .setValue(VersionConvertor_30_40.convertType(ti.getValue()))); + src.getInput().forEach( + ti -> tgt.addInput().setType(convertCodeableConcept(ti.getType())).setValue(convertType(ti.getValue()))); } public static void convertTaskInput(org.hl7.fhir.dstu3.model.Task src, org.hl7.fhir.r4.model.Task tgt) { - src.getInput().forEach(ti -> tgt.addInput().setType(VersionConvertor_30_40.convertCodeableConcept(ti.getType())) - .setValue(VersionConvertor_30_40.convertType(ti.getValue()))); + src.getInput().forEach( + ti -> tgt.addInput().setType(convertCodeableConcept(ti.getType())).setValue(convertType(ti.getValue()))); } public static void convertTaskOutput(org.hl7.fhir.r4.model.Task src, org.hl7.fhir.dstu3.model.Task tgt) { - src.getOutput().forEach(to -> tgt.addOutput().setType(VersionConvertor_30_40.convertCodeableConcept(to.getType())) - .setValue(VersionConvertor_30_40.convertType(to.getValue()))); + src.getOutput().forEach( + to -> tgt.addOutput().setType(convertCodeableConcept(to.getType())).setValue(convertType(to.getValue()))); } public static void convertTaskOutput(org.hl7.fhir.dstu3.model.Task src, org.hl7.fhir.r4.model.Task tgt) { - src.getOutput().forEach(to -> tgt.addOutput().setType(VersionConvertor_30_40.convertCodeableConcept(to.getType())) - .setValue(VersionConvertor_30_40.convertType(to.getValue()))); + src.getOutput().forEach( + to -> tgt.addOutput().setType(convertCodeableConcept(to.getType())).setValue(convertType(to.getValue()))); } } diff --git a/api/src/test/java/org/openmrs/module/fhir2/providers/r3/AllergyIntoleranceFhirR3ResourceProviderTest.java b/api/src/test/java/org/openmrs/module/fhir2/providers/r3/AllergyIntoleranceFhirR3ResourceProviderTest.java index ffdb27971d..3ecaaddf07 100644 --- a/api/src/test/java/org/openmrs/module/fhir2/providers/r3/AllergyIntoleranceFhirR3ResourceProviderTest.java +++ b/api/src/test/java/org/openmrs/module/fhir2/providers/r3/AllergyIntoleranceFhirR3ResourceProviderTest.java @@ -39,7 +39,7 @@ import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; import ca.uhn.fhir.rest.server.exceptions.MethodNotAllowedException; import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; -import org.hl7.fhir.convertors.conv30_40.AllergyIntolerance30_40; +import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_40; import org.hl7.fhir.dstu3.model.AllergyIntolerance; import org.hl7.fhir.dstu3.model.IdType; import org.hl7.fhir.dstu3.model.OperationOutcome; @@ -429,8 +429,8 @@ public void searchForAllergies_shouldNotAddPatientsToReturnedResultsForEmptyIncl public void createAllergyIntolerance_shouldCreateNewAllergyIntolerance() { when(service.create(any(org.hl7.fhir.r4.model.AllergyIntolerance.class))).thenReturn(allergyIntolerance); - MethodOutcome result = resourceProvider - .creatAllergyIntolerance(AllergyIntolerance30_40.convertAllergyIntolerance(allergyIntolerance)); + MethodOutcome result = resourceProvider.creatAllergyIntolerance( + (AllergyIntolerance) VersionConvertorFactory_30_40.convertResource(allergyIntolerance)); assertThat(result, notNullValue()); assertThat(result.getCreated(), is(true)); assertThat(result.getResource(), notNullValue()); @@ -443,7 +443,7 @@ public void updateAllergyIntolerance_shouldUpdateAllergyIntolerance() { .thenReturn(allergyIntolerance); MethodOutcome result = resourceProvider.updateAllergyIntolerance(new IdType().setValue(ALLERGY_UUID), - AllergyIntolerance30_40.convertAllergyIntolerance(allergyIntolerance)); + (AllergyIntolerance) VersionConvertorFactory_30_40.convertResource(allergyIntolerance)); assertThat(result, notNullValue()); assertThat(result.getResource(), notNullValue()); assertThat(result.getResource().getIdElement().getIdPart(), equalTo(ALLERGY_UUID)); @@ -455,7 +455,7 @@ public void updateAllergyIntolerance_shouldThrowInvalidRequestForUuidMismatch() .thenThrow(InvalidRequestException.class); resourceProvider.updateAllergyIntolerance(new IdType().setValue(WRONG_ALLERGY_UUID), - AllergyIntolerance30_40.convertAllergyIntolerance(allergyIntolerance)); + (AllergyIntolerance) VersionConvertorFactory_30_40.convertResource(allergyIntolerance)); } @Test(expected = InvalidRequestException.class) @@ -466,7 +466,7 @@ public void updateAllergyIntolerance_shouldThrowInvalidRequestForMissingId() { .thenThrow(InvalidRequestException.class); resourceProvider.updateAllergyIntolerance(new IdType().setValue(ALLERGY_UUID), - AllergyIntolerance30_40.convertAllergyIntolerance(noIdAllergyIntolerance)); + (AllergyIntolerance) VersionConvertorFactory_30_40.convertResource(noIdAllergyIntolerance)); } @Test(expected = MethodNotAllowedException.class) @@ -478,7 +478,7 @@ public void updateAllergyIntolerance_shouldThrowMethodNotAllowedIfDoesNotExist() .thenThrow(MethodNotAllowedException.class); resourceProvider.updateAllergyIntolerance(new IdType().setValue(WRONG_ALLERGY_UUID), - AllergyIntolerance30_40.convertAllergyIntolerance(wrongAllergyIntolerance)); + (AllergyIntolerance) VersionConvertorFactory_30_40.convertResource(wrongAllergyIntolerance)); } @Test diff --git a/api/src/test/java/org/openmrs/module/fhir2/providers/r3/ConditionFhirR3ResourceProviderTest.java b/api/src/test/java/org/openmrs/module/fhir2/providers/r3/ConditionFhirR3ResourceProviderTest.java index e42e609ef5..9117f43fc2 100644 --- a/api/src/test/java/org/openmrs/module/fhir2/providers/r3/ConditionFhirR3ResourceProviderTest.java +++ b/api/src/test/java/org/openmrs/module/fhir2/providers/r3/ConditionFhirR3ResourceProviderTest.java @@ -41,7 +41,7 @@ import ca.uhn.fhir.rest.param.TokenParam; import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; import org.hamcrest.Matchers; -import org.hl7.fhir.convertors.conv30_40.Condition30_40; +import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_40; import org.hl7.fhir.dstu3.model.Condition; import org.hl7.fhir.dstu3.model.IdType; import org.hl7.fhir.dstu3.model.OperationOutcome; @@ -123,7 +123,8 @@ public void getConditionWithWrongUuid_shouldThrowResourceNotFoundException() { public void createCondition_shouldCreateNewCondition() { when(conditionService.create(any(org.hl7.fhir.r4.model.Condition.class))).thenReturn(condition); - MethodOutcome result = resourceProvider.createCondition(Condition30_40.convertCondition(condition)); + MethodOutcome result = resourceProvider + .createCondition((Condition) VersionConvertorFactory_30_40.convertResource(condition)); assertThat(result, notNullValue()); assertThat(result.getCreated(), is(true)); @@ -136,7 +137,7 @@ public void updateCondition_shouldUpdateRequestedCondition() { when(conditionService.update(anyString(), any(org.hl7.fhir.r4.model.Condition.class))).thenReturn(condition); MethodOutcome result = resourceProvider.updateCondition(new IdType().setValue(CONDITION_UUID), - Condition30_40.convertCondition(condition)); + (Condition) VersionConvertorFactory_30_40.convertResource(condition)); assertThat(result, notNullValue()); assertThat(result.getResource().getIdElement().getIdPart(), equalTo(CONDITION_UUID)); diff --git a/api/src/test/java/org/openmrs/module/fhir2/providers/r3/DiagnosticReportFhirResourceProviderTest.java b/api/src/test/java/org/openmrs/module/fhir2/providers/r3/DiagnosticReportFhirResourceProviderTest.java index f07ea06870..b9794b6cea 100644 --- a/api/src/test/java/org/openmrs/module/fhir2/providers/r3/DiagnosticReportFhirResourceProviderTest.java +++ b/api/src/test/java/org/openmrs/module/fhir2/providers/r3/DiagnosticReportFhirResourceProviderTest.java @@ -36,7 +36,7 @@ import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; import lombok.AccessLevel; import lombok.Getter; -import org.hl7.fhir.convertors.conv30_40.DiagnosticReport30_40; +import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_40; import org.hl7.fhir.dstu3.model.DiagnosticReport; import org.hl7.fhir.dstu3.model.IdType; import org.hl7.fhir.dstu3.model.OperationOutcome; @@ -125,7 +125,7 @@ public void createDiagnosticReport_shouldCreateNewDiagnosticReport() { when(service.create(any(org.hl7.fhir.r4.model.DiagnosticReport.class))).thenReturn(diagnosticReport); MethodOutcome result = resourceProvider - .createDiagnosticReport(DiagnosticReport30_40.convertDiagnosticReport(diagnosticReport)); + .createDiagnosticReport((DiagnosticReport) VersionConvertorFactory_30_40.convertResource(diagnosticReport)); assertThat(result, notNullValue()); assertThat(result.getResource(), notNullValue()); @@ -137,7 +137,7 @@ public void updateDiagnosticReport_shouldUpdateExistingDiagnosticReport() { when(service.update(eq(UUID), any(org.hl7.fhir.r4.model.DiagnosticReport.class))).thenReturn(diagnosticReport); MethodOutcome result = resourceProvider.updateDiagnosticReport(new IdType().setValue(UUID), - DiagnosticReport30_40.convertDiagnosticReport(diagnosticReport)); + (DiagnosticReport) VersionConvertorFactory_30_40.convertResource(diagnosticReport)); assertThat(result, notNullValue()); assertThat(result.getResource(), notNullValue()); @@ -150,7 +150,7 @@ public void updateDiagnosticReport_shouldThrowInvalidRequestForUuidMismatch() { .thenThrow(InvalidRequestException.class); resourceProvider.updateDiagnosticReport(new IdType().setValue(WRONG_UUID), - DiagnosticReport30_40.convertDiagnosticReport(diagnosticReport)); + (DiagnosticReport) VersionConvertorFactory_30_40.convertResource(diagnosticReport)); } @Test(expected = InvalidRequestException.class) diff --git a/api/src/test/java/org/openmrs/module/fhir2/providers/r3/EncounterFhirResourceProviderTest.java b/api/src/test/java/org/openmrs/module/fhir2/providers/r3/EncounterFhirResourceProviderTest.java index 5983f65db9..0f3615f4e0 100644 --- a/api/src/test/java/org/openmrs/module/fhir2/providers/r3/EncounterFhirResourceProviderTest.java +++ b/api/src/test/java/org/openmrs/module/fhir2/providers/r3/EncounterFhirResourceProviderTest.java @@ -41,7 +41,7 @@ import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; import ca.uhn.fhir.rest.server.exceptions.MethodNotAllowedException; import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; -import org.hl7.fhir.convertors.conv30_40.Encounter30_40; +import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_40; import org.hl7.fhir.dstu3.model.Encounter; import org.hl7.fhir.dstu3.model.IdType; import org.hl7.fhir.dstu3.model.OperationOutcome; @@ -291,7 +291,8 @@ public void searchEncounters_shouldIncludeAddResourcesThatMatchTagParam() { public void createEncounter_shouldCreateNewEncounter() { when(encounterService.create(any(org.hl7.fhir.r4.model.Encounter.class))).thenReturn(encounter); - MethodOutcome result = resourceProvider.createEncounter(Encounter30_40.convertEncounter(encounter)); + MethodOutcome result = resourceProvider + .createEncounter((Encounter) VersionConvertorFactory_30_40.convertResource(encounter)); assertThat(result, notNullValue()); assertThat(result.getCreated(), is(true)); assertThat(result.getResource(), notNullValue()); @@ -303,7 +304,7 @@ public void updateEncounter_shouldUpdateEncounter() { when(encounterService.update(eq(ENCOUNTER_UUID), any(org.hl7.fhir.r4.model.Encounter.class))).thenReturn(encounter); MethodOutcome result = resourceProvider.updateEncounter(new IdType().setValue(ENCOUNTER_UUID), - Encounter30_40.convertEncounter(encounter)); + (Encounter) VersionConvertorFactory_30_40.convertResource(encounter)); assertThat(result, notNullValue()); assertThat(result.getResource(), notNullValue()); assertThat(result.getResource().getIdElement().getIdPart(), equalTo(ENCOUNTER_UUID)); @@ -315,7 +316,7 @@ public void updateEncounter_shouldThrowInvalidRequestForUuidMismatch() { .thenThrow(InvalidRequestException.class); resourceProvider.updateEncounter(new IdType().setValue(WRONG_ENCOUNTER_UUID), - Encounter30_40.convertEncounter(encounter)); + (Encounter) VersionConvertorFactory_30_40.convertResource(encounter)); } @Test(expected = InvalidRequestException.class) @@ -326,7 +327,7 @@ public void updateEncounter_shouldThrowInvalidRequestForMissingId() { .thenThrow(InvalidRequestException.class); resourceProvider.updateEncounter(new IdType().setValue(ENCOUNTER_UUID), - Encounter30_40.convertEncounter(noIdEncounter)); + (Encounter) VersionConvertorFactory_30_40.convertResource(noIdEncounter)); } @Test(expected = MethodNotAllowedException.class) @@ -338,7 +339,7 @@ public void updateEncounter_shouldThrowMethodNotAllowedIfDoesNotExist() { .thenThrow(MethodNotAllowedException.class); resourceProvider.updateEncounter(new IdType().setValue(WRONG_ENCOUNTER_UUID), - Encounter30_40.convertEncounter(wrongEncounter)); + (Encounter) VersionConvertorFactory_30_40.convertResource(wrongEncounter)); } @Test diff --git a/api/src/test/java/org/openmrs/module/fhir2/providers/r3/GroupFhirResourceProviderTest.java b/api/src/test/java/org/openmrs/module/fhir2/providers/r3/GroupFhirResourceProviderTest.java index 7eda941d86..703868bacb 100644 --- a/api/src/test/java/org/openmrs/module/fhir2/providers/r3/GroupFhirResourceProviderTest.java +++ b/api/src/test/java/org/openmrs/module/fhir2/providers/r3/GroupFhirResourceProviderTest.java @@ -24,7 +24,7 @@ import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; import ca.uhn.fhir.rest.server.exceptions.MethodNotAllowedException; import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; -import org.hl7.fhir.convertors.conv30_40.Group30_40; +import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_40; import org.hl7.fhir.dstu3.model.Group; import org.hl7.fhir.dstu3.model.IdType; import org.hl7.fhir.dstu3.model.OperationOutcome; @@ -88,7 +88,7 @@ public void getGroupByUuid_shouldThrowResourceNotFoundException() { public void shouldCreateNewGroup() { when(fhirGroupService.create(any(org.hl7.fhir.r4.model.Group.class))).thenReturn(group); - MethodOutcome result = resourceProvider.createGroup(Group30_40.convertGroup(group)); + MethodOutcome result = resourceProvider.createGroup((Group) VersionConvertorFactory_30_40.convertResource(group)); assertThat(result, notNullValue()); assertThat(result.getCreated(), is(true)); @@ -108,7 +108,7 @@ public void shouldUpdateExistingGroup() { when(fhirGroupService.update(eq(COHORT_UUID), any(org.hl7.fhir.r4.model.Group.class))).thenReturn(group); MethodOutcome result = resourceProvider.updateGroup(new IdType().setValue(COHORT_UUID), - Group30_40.convertGroup(group)); + (Group) VersionConvertorFactory_30_40.convertResource(group)); assertThat(result, notNullValue()); assertThat(result.getResource(), notNullValue()); @@ -121,7 +121,8 @@ public void updateGroupShouldThrowInvalidRequestForUuidMismatch() { when(fhirGroupService.update(eq(BAD_COHORT_UUID), any(org.hl7.fhir.r4.model.Group.class))) .thenThrow(InvalidRequestException.class); - resourceProvider.updateGroup(new IdType().setValue(BAD_COHORT_UUID), Group30_40.convertGroup(group)); + resourceProvider.updateGroup(new IdType().setValue(BAD_COHORT_UUID), + (Group) VersionConvertorFactory_30_40.convertResource(group)); } @Test(expected = InvalidRequestException.class) @@ -131,7 +132,8 @@ public void ShouldThrowInvalidRequestForMissingIdInGroupToUpdate() { when(fhirGroupService.update(eq(COHORT_UUID), any(org.hl7.fhir.r4.model.Group.class))) .thenThrow(InvalidRequestException.class); - resourceProvider.updateGroup(new IdType().setValue(COHORT_UUID), Group30_40.convertGroup(noIdGroup)); + resourceProvider.updateGroup(new IdType().setValue(COHORT_UUID), + (Group) VersionConvertorFactory_30_40.convertResource(noIdGroup)); } @Test(expected = MethodNotAllowedException.class) @@ -142,7 +144,8 @@ public void shouldThrowMethodNotAllowedIfGroupToUpdateDoesNotExist() { when(fhirGroupService.update(eq(BAD_COHORT_UUID), any(org.hl7.fhir.r4.model.Group.class))) .thenThrow(MethodNotAllowedException.class); - resourceProvider.updateGroup(new IdType().setValue(BAD_COHORT_UUID), Group30_40.convertGroup(wrongGroup)); + resourceProvider.updateGroup(new IdType().setValue(BAD_COHORT_UUID), + (Group) VersionConvertorFactory_30_40.convertResource(wrongGroup)); } @Test diff --git a/api/src/test/java/org/openmrs/module/fhir2/providers/r3/LocationFhirResourceProviderTest.java b/api/src/test/java/org/openmrs/module/fhir2/providers/r3/LocationFhirResourceProviderTest.java index 4f1e7fd5a1..6317c89f8e 100644 --- a/api/src/test/java/org/openmrs/module/fhir2/providers/r3/LocationFhirResourceProviderTest.java +++ b/api/src/test/java/org/openmrs/module/fhir2/providers/r3/LocationFhirResourceProviderTest.java @@ -43,7 +43,7 @@ import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; import ca.uhn.fhir.rest.server.exceptions.MethodNotAllowedException; import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; -import org.hl7.fhir.convertors.conv30_40.Location30_40; +import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_40; import org.hl7.fhir.dstu3.model.Encounter; import org.hl7.fhir.dstu3.model.IdType; import org.hl7.fhir.dstu3.model.Location; @@ -517,7 +517,8 @@ private List get(IBundleProvider results) { public void createLocation_shouldCreateNewLocation() { when(locationService.create(any(org.hl7.fhir.r4.model.Location.class))).thenReturn(location); - MethodOutcome result = resourceProvider.createLocation(Location30_40.convertLocation(location)); + MethodOutcome result = resourceProvider + .createLocation((Location) VersionConvertorFactory_30_40.convertResource(location)); assertThat(result, notNullValue()); assertThat(result.getCreated(), is(true)); assertThat(result.getResource(), notNullValue()); @@ -540,7 +541,7 @@ public void updateLocation_shouldUpdateLocation() { when(locationService.update(eq(LOCATION_UUID), any(org.hl7.fhir.r4.model.Location.class))).thenReturn(location); MethodOutcome result = resourceProvider.updateLocation(new IdType().setValue(LOCATION_UUID), - Location30_40.convertLocation(location)); + (Location) VersionConvertorFactory_30_40.convertResource(location)); assertThat(result, notNullValue()); assertThat(result.getResource(), notNullValue()); assertThat(result.getResource().getIdElement().getIdPart(), equalTo(LOCATION_UUID)); @@ -551,7 +552,8 @@ public void updateLocation_shouldThrowInvalidRequestForUuidMismatch() { when(locationService.update(eq(WRONG_LOCATION_UUID), any(org.hl7.fhir.r4.model.Location.class))) .thenThrow(InvalidRequestException.class); - resourceProvider.updateLocation(new IdType().setValue(WRONG_LOCATION_UUID), Location30_40.convertLocation(location)); + resourceProvider.updateLocation(new IdType().setValue(WRONG_LOCATION_UUID), + (Location) VersionConvertorFactory_30_40.convertResource(location)); } @Test(expected = InvalidRequestException.class) diff --git a/api/src/test/java/org/openmrs/module/fhir2/providers/r3/MedicationDispenseFhirResourceProviderTest.java b/api/src/test/java/org/openmrs/module/fhir2/providers/r3/MedicationDispenseFhirResourceProviderTest.java index 30ccb4f4b3..a0c3e1c77b 100644 --- a/api/src/test/java/org/openmrs/module/fhir2/providers/r3/MedicationDispenseFhirResourceProviderTest.java +++ b/api/src/test/java/org/openmrs/module/fhir2/providers/r3/MedicationDispenseFhirResourceProviderTest.java @@ -35,7 +35,7 @@ import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; import ca.uhn.fhir.rest.server.exceptions.MethodNotAllowedException; import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; -import org.hl7.fhir.convertors.conv30_40.MedicationDispense30_40; +import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_40; import org.hl7.fhir.dstu3.model.IdType; import org.hl7.fhir.dstu3.model.MedicationDispense; import org.hl7.fhir.dstu3.model.OperationOutcome; @@ -129,8 +129,8 @@ public void getMedicationDispenseByUuid_shouldThrowResourceNotFoundException() { public void createMedicationDispense_shouldCreateMedicationDispense() { when(fhirMedicationDispenseService.create(any(org.hl7.fhir.r4.model.MedicationDispense.class))) .thenReturn(medicationDispense); - MethodOutcome result = resourceProvider - .createMedicationDispense(MedicationDispense30_40.convertMedicationDispense(medicationDispense)); + MethodOutcome result = resourceProvider.createMedicationDispense( + (MedicationDispense) VersionConvertorFactory_30_40.convertResource(medicationDispense)); assertThat(result, notNullValue()); assertThat(result.getCreated(), is(true)); assertThat(result.getResource().getIdElement().getIdPart(), equalTo(medicationDispense.getId())); @@ -142,7 +142,7 @@ public void updateMedicationDispense_shouldUpdateMedicationDispense() { any(org.hl7.fhir.r4.model.MedicationDispense.class))).thenReturn(medicationDispense); MethodOutcome result = resourceProvider.updateMedicationDispense(new IdType().setValue(MEDICATION_DISPENSE_UUID), - MedicationDispense30_40.convertMedicationDispense(medicationDispense)); + (MedicationDispense) VersionConvertorFactory_30_40.convertResource(medicationDispense)); assertThat(result, notNullValue()); assertThat(result.getResource(), notNullValue()); @@ -155,7 +155,7 @@ public void updateMedicationDispense_shouldThrowInvalidRequestForUuidMismatch() any(org.hl7.fhir.r4.model.MedicationDispense.class))).thenThrow(InvalidRequestException.class); resourceProvider.updateMedicationDispense(new IdType().setValue(WRONG_MEDICATION_DISPENSE_UUID), - MedicationDispense30_40.convertMedicationDispense(medicationDispense)); + (MedicationDispense) VersionConvertorFactory_30_40.convertResource(medicationDispense)); } @Test(expected = InvalidRequestException.class) diff --git a/api/src/test/java/org/openmrs/module/fhir2/providers/r3/MedicationFhirResourceProviderTest.java b/api/src/test/java/org/openmrs/module/fhir2/providers/r3/MedicationFhirResourceProviderTest.java index 88e2ac4f7e..81a6c5dc28 100644 --- a/api/src/test/java/org/openmrs/module/fhir2/providers/r3/MedicationFhirResourceProviderTest.java +++ b/api/src/test/java/org/openmrs/module/fhir2/providers/r3/MedicationFhirResourceProviderTest.java @@ -36,7 +36,7 @@ import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; import ca.uhn.fhir.rest.server.exceptions.MethodNotAllowedException; import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; -import org.hl7.fhir.convertors.conv30_40.Medication30_40; +import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_40; import org.hl7.fhir.dstu3.model.IdType; import org.hl7.fhir.dstu3.model.Medication; import org.hl7.fhir.dstu3.model.OperationOutcome; @@ -244,7 +244,8 @@ public void searchForMedication_shouldNotAddResourcesForEmptyRevInclude() { public void createMedication_shouldCreateNewMedication() { when(fhirMedicationService.create(any(org.hl7.fhir.r4.model.Medication.class))).thenReturn(medication); - MethodOutcome result = resourceProvider.createMedication(Medication30_40.convertMedication(medication)); + MethodOutcome result = resourceProvider + .createMedication((Medication) VersionConvertorFactory_30_40.convertResource(medication)); assertThat(result, notNullValue()); assertThat(result.getCreated(), is(true)); @@ -260,7 +261,7 @@ public void updateMedication_shouldUpdateMedication() { .thenReturn(medication); MethodOutcome result = resourceProvider.updateMedication(new IdType().setValue(MEDICATION_UUID), - Medication30_40.convertMedication(medication)); + (Medication) VersionConvertorFactory_30_40.convertResource(medication)); assertThat(result, notNullValue()); assertThat(result.getResource(), notNullValue()); @@ -273,7 +274,7 @@ public void updateMedicationShouldThrowInvalidRequestForUuidMismatch() { .thenThrow(InvalidRequestException.class); resourceProvider.updateMedication(new IdType().setValue(WRONG_MEDICATION_UUID), - Medication30_40.convertMedication(medication)); + (Medication) VersionConvertorFactory_30_40.convertResource(medication)); } @Test(expected = InvalidRequestException.class) @@ -284,7 +285,7 @@ public void updateMedicationShouldThrowInvalidRequestForMissingId() { .thenThrow(InvalidRequestException.class); resourceProvider.updateMedication(new IdType().setValue(MEDICATION_UUID), - Medication30_40.convertMedication(noIdMedication)); + (Medication) VersionConvertorFactory_30_40.convertResource(noIdMedication)); } @Test(expected = MethodNotAllowedException.class) @@ -296,7 +297,7 @@ public void updateMedicationShouldThrowMethodNotAllowedIfDoesNotExist() { .thenThrow(MethodNotAllowedException.class); resourceProvider.updateMedication(new IdType().setValue(WRONG_MEDICATION_UUID), - Medication30_40.convertMedication(wrongMedication)); + (Medication) VersionConvertorFactory_30_40.convertResource(wrongMedication)); } @Test diff --git a/api/src/test/java/org/openmrs/module/fhir2/providers/r3/ObservationFhirResourceProviderTest.java b/api/src/test/java/org/openmrs/module/fhir2/providers/r3/ObservationFhirResourceProviderTest.java index 5003ed4d5b..701f07c859 100644 --- a/api/src/test/java/org/openmrs/module/fhir2/providers/r3/ObservationFhirResourceProviderTest.java +++ b/api/src/test/java/org/openmrs/module/fhir2/providers/r3/ObservationFhirResourceProviderTest.java @@ -45,7 +45,7 @@ import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; import lombok.AccessLevel; import lombok.Getter; -import org.hl7.fhir.convertors.conv30_40.Observation30_40; +import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_40; import org.hl7.fhir.dstu3.model.IdType; import org.hl7.fhir.dstu3.model.Observation; import org.hl7.fhir.dstu3.model.OperationOutcome; @@ -284,7 +284,8 @@ public void searchObservations_shouldNotAddRelatedResourcesForEmptyReverseInclud public void createObservation_shouldCreateNewObservation() { when(observationService.create(any(org.hl7.fhir.r4.model.Observation.class))).thenReturn(observation); - MethodOutcome result = resourceProvider.createObservationResource(Observation30_40.convertObservation(observation)); + MethodOutcome result = resourceProvider + .createObservationResource((Observation) VersionConvertorFactory_30_40.convertResource(observation)); assertThat(result, notNullValue()); assertThat(result.getCreated(), is(true)); diff --git a/api/src/test/java/org/openmrs/module/fhir2/providers/r3/PatientFhirResourceProviderTest.java b/api/src/test/java/org/openmrs/module/fhir2/providers/r3/PatientFhirResourceProviderTest.java index 3c4cbe92fd..5711c33dd0 100644 --- a/api/src/test/java/org/openmrs/module/fhir2/providers/r3/PatientFhirResourceProviderTest.java +++ b/api/src/test/java/org/openmrs/module/fhir2/providers/r3/PatientFhirResourceProviderTest.java @@ -39,7 +39,7 @@ import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; import ca.uhn.fhir.rest.server.exceptions.MethodNotAllowedException; import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; -import org.hl7.fhir.convertors.conv30_40.Patient30_40; +import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_40; import org.hl7.fhir.dstu3.model.IdType; import org.hl7.fhir.dstu3.model.OperationOutcome; import org.hl7.fhir.dstu3.model.Patient; @@ -147,7 +147,8 @@ public void getPatientByWithWrongId_shouldThrowResourceNotFoundException() { public void createPatient_shouldCreateNewPatient() { when(patientService.create(any(org.hl7.fhir.r4.model.Patient.class))).thenReturn(patient); - MethodOutcome result = patientFhirResourceProvider.createPatient(Patient30_40.convertPatient(patient)); + MethodOutcome result = patientFhirResourceProvider + .createPatient((Patient) VersionConvertorFactory_30_40.convertResource(patient)); assertThat(result, notNullValue()); assertThat(result.getCreated(), is(true)); @@ -160,7 +161,7 @@ public void updatePatient_shouldUpdateRequestedPatient() { when(patientService.update(eq(PATIENT_UUID), any(org.hl7.fhir.r4.model.Patient.class))).thenReturn(patient); MethodOutcome result = patientFhirResourceProvider.updatePatient(new IdType().setValue(PATIENT_UUID), - Patient30_40.convertPatient(patient)); + (Patient) VersionConvertorFactory_30_40.convertResource(patient)); assertThat(result, notNullValue()); assertThat(result.getResource(), notNullValue()); @@ -173,7 +174,7 @@ public void updatePatient_shouldThrowInvalidRequestForUuidMismatch() { .thenThrow(InvalidRequestException.class); patientFhirResourceProvider.updatePatient(new IdType().setValue(WRONG_PATIENT_UUID), - Patient30_40.convertPatient(patient)); + (Patient) VersionConvertorFactory_30_40.convertResource(patient)); } @Test(expected = InvalidRequestException.class) @@ -184,7 +185,7 @@ public void updatePatient_shouldThrowInvalidRequestForMissingId() { .thenThrow(InvalidRequestException.class); patientFhirResourceProvider.updatePatient(new IdType().setValue(PATIENT_UUID), - Patient30_40.convertPatient(noIdPatient)); + (Patient) VersionConvertorFactory_30_40.convertResource(noIdPatient)); } @Test(expected = MethodNotAllowedException.class) @@ -196,7 +197,7 @@ public void updatePatient_shouldThrowMethodNotAllowedIfDoesNotExist() { .thenThrow(MethodNotAllowedException.class); patientFhirResourceProvider.updatePatient(new IdType().setValue(WRONG_PATIENT_UUID), - Patient30_40.convertPatient(wrongPatient)); + (Patient) VersionConvertorFactory_30_40.convertResource(wrongPatient)); } @Test diff --git a/api/src/test/java/org/openmrs/module/fhir2/providers/r3/PersonFhirResourceProviderTest.java b/api/src/test/java/org/openmrs/module/fhir2/providers/r3/PersonFhirResourceProviderTest.java index b318aba59d..68d4b4ae24 100644 --- a/api/src/test/java/org/openmrs/module/fhir2/providers/r3/PersonFhirResourceProviderTest.java +++ b/api/src/test/java/org/openmrs/module/fhir2/providers/r3/PersonFhirResourceProviderTest.java @@ -38,7 +38,7 @@ import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; import ca.uhn.fhir.rest.server.exceptions.MethodNotAllowedException; import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; -import org.hl7.fhir.convertors.conv30_40.Person30_40; +import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_40; import org.hl7.fhir.dstu3.model.IdType; import org.hl7.fhir.dstu3.model.OperationOutcome; import org.hl7.fhir.dstu3.model.Person; @@ -346,7 +346,7 @@ public void searchForPeople_shouldNotAddRelatedResourcesForEmptyInclude() { public void createPerson_shouldCreateNewPerson() { when(fhirPersonService.create(any(org.hl7.fhir.r4.model.Person.class))).thenReturn(person); - MethodOutcome result = resourceProvider.createPerson(Person30_40.convertPerson(person)); + MethodOutcome result = resourceProvider.createPerson((Person) VersionConvertorFactory_30_40.convertResource(person)); assertThat(result, notNullValue()); assertThat(result.getCreated(), is(true)); @@ -370,7 +370,7 @@ public void updatePerson_shouldUpdatePerson() { when(fhirPersonService.update(eq(PERSON_UUID), any(org.hl7.fhir.r4.model.Person.class))).thenReturn(person); MethodOutcome result = resourceProvider.updatePerson(new IdType().setValue(PERSON_UUID), - Person30_40.convertPerson(person)); + (Person) VersionConvertorFactory_30_40.convertResource(person)); assertThat(result, notNullValue()); assertThat(result.getResource(), notNullValue()); @@ -382,7 +382,8 @@ public void updatePerson_shouldThrowInvalidRequestForUuidMismatch() { when(fhirPersonService.update(eq(WRONG_PERSON_UUID), any(org.hl7.fhir.r4.model.Person.class))) .thenThrow(InvalidRequestException.class); - resourceProvider.updatePerson(new IdType().setValue(WRONG_PERSON_UUID), Person30_40.convertPerson(person)); + resourceProvider.updatePerson(new IdType().setValue(WRONG_PERSON_UUID), + (Person) VersionConvertorFactory_30_40.convertResource(person)); } @Test(expected = InvalidRequestException.class) @@ -392,7 +393,8 @@ public void updatePerson_shouldThrowInvalidRequestForMissingId() { when(fhirPersonService.update(eq(PERSON_UUID), any(org.hl7.fhir.r4.model.Person.class))) .thenThrow(InvalidRequestException.class); - resourceProvider.updatePerson(new IdType().setValue(PERSON_UUID), Person30_40.convertPerson(noIdPerson)); + resourceProvider.updatePerson(new IdType().setValue(PERSON_UUID), + (Person) VersionConvertorFactory_30_40.convertResource(noIdPerson)); } @Test(expected = MethodNotAllowedException.class) @@ -403,7 +405,8 @@ public void updatePerson_shouldThrowMethodNotAllowedIfDoesNotExist() { when(fhirPersonService.update(eq(WRONG_PERSON_UUID), any(org.hl7.fhir.r4.model.Person.class))) .thenThrow(MethodNotAllowedException.class); - resourceProvider.updatePerson(new IdType().setValue(WRONG_PERSON_UUID), Person30_40.convertPerson(wrongPerson)); + resourceProvider.updatePerson(new IdType().setValue(WRONG_PERSON_UUID), + (Person) VersionConvertorFactory_30_40.convertResource(wrongPerson)); } } diff --git a/api/src/test/java/org/openmrs/module/fhir2/providers/r3/PractitionerFhirResourceProviderTest.java b/api/src/test/java/org/openmrs/module/fhir2/providers/r3/PractitionerFhirResourceProviderTest.java index 6bdba2ec6e..b1fbef8c9e 100644 --- a/api/src/test/java/org/openmrs/module/fhir2/providers/r3/PractitionerFhirResourceProviderTest.java +++ b/api/src/test/java/org/openmrs/module/fhir2/providers/r3/PractitionerFhirResourceProviderTest.java @@ -39,7 +39,7 @@ import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; import ca.uhn.fhir.rest.server.exceptions.MethodNotAllowedException; import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; -import org.hl7.fhir.convertors.conv30_40.Practitioner30_40; +import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_40; import org.hl7.fhir.dstu3.model.IdType; import org.hl7.fhir.dstu3.model.OperationOutcome; import org.hl7.fhir.dstu3.model.Practitioner; @@ -553,7 +553,8 @@ public void findPractitioners_shouldNotAddRelatedResourcesForEmptyReverseInclude public void createPractitioner_shouldCreateNewPractitioner() { when(practitionerService.create(any(org.hl7.fhir.r4.model.Practitioner.class))).thenReturn(practitioner); - MethodOutcome result = resourceProvider.createPractitioner(Practitioner30_40.convertPractitioner(practitioner)); + MethodOutcome result = resourceProvider + .createPractitioner((Practitioner) VersionConvertorFactory_30_40.convertResource(practitioner)); assertThat(result, notNullValue()); assertThat(result.getCreated(), is(true)); assertThat(result.getResource(), notNullValue()); @@ -566,7 +567,7 @@ public void updatePractitioner_shouldUpdatePractitioner() { .thenReturn(practitioner); MethodOutcome result = resourceProvider.updatePractitioner(new IdType().setValue(PRACTITIONER_UUID), - Practitioner30_40.convertPractitioner(practitioner)); + (Practitioner) VersionConvertorFactory_30_40.convertResource(practitioner)); assertThat(result, notNullValue()); assertThat(result.getResource(), notNullValue()); assertThat(result.getResource().getIdElement().getIdPart(), equalTo(PRACTITIONER_UUID)); @@ -578,7 +579,7 @@ public void updatePractitioner_shouldThrowInvalidRequestForUuidMismatch() { .thenThrow(InvalidRequestException.class); resourceProvider.updatePractitioner(new IdType().setValue(WRONG_PRACTITIONER_UUID), - Practitioner30_40.convertPractitioner(practitioner)); + (Practitioner) VersionConvertorFactory_30_40.convertResource(practitioner)); } @Test(expected = InvalidRequestException.class) @@ -589,7 +590,7 @@ public void updatePractitioner_shouldThrowInvalidRequestForMissingId() { .thenThrow(InvalidRequestException.class); resourceProvider.updatePractitioner(new IdType().setValue(PRACTITIONER_UUID), - Practitioner30_40.convertPractitioner(noIdPractitioner)); + (Practitioner) VersionConvertorFactory_30_40.convertResource(noIdPractitioner)); } @Test(expected = MethodNotAllowedException.class) @@ -601,7 +602,7 @@ public void updatePractitioner_shouldThrowMethodNotAllowedIfDoesNotExist() { .thenThrow(MethodNotAllowedException.class); resourceProvider.updatePractitioner(new IdType().setValue(WRONG_PRACTITIONER_UUID), - Practitioner30_40.convertPractitioner(wrongPractitioner)); + (Practitioner) VersionConvertorFactory_30_40.convertResource(wrongPractitioner)); } @Test diff --git a/api/src/test/java/org/openmrs/module/fhir2/providers/r3/ProcedureRequestFhirResourceProviderTest.java b/api/src/test/java/org/openmrs/module/fhir2/providers/r3/ProcedureRequestFhirResourceProviderTest.java index 8fd1361b8d..46a1add94e 100644 --- a/api/src/test/java/org/openmrs/module/fhir2/providers/r3/ProcedureRequestFhirResourceProviderTest.java +++ b/api/src/test/java/org/openmrs/module/fhir2/providers/r3/ProcedureRequestFhirResourceProviderTest.java @@ -15,6 +15,7 @@ import static org.hamcrest.CoreMatchers.nullValue; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.hasSize; +import static org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_40.convertResource; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.isNull; @@ -39,7 +40,6 @@ import ca.uhn.fhir.rest.server.exceptions.MethodNotAllowedException; import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; import org.hamcrest.Matchers; -import org.hl7.fhir.convertors.VersionConvertor_30_40; import org.hl7.fhir.dstu3.model.IdType; import org.hl7.fhir.dstu3.model.OperationOutcome; import org.hl7.fhir.dstu3.model.Patient; @@ -260,8 +260,7 @@ public void searchProcedureRequest_shouldReturnMatchingProcedureRequestByEncount public void createProcedureRequest_shouldCreateNewProcedureRequest() { when(serviceRequestService.create(any(ServiceRequest.class))).thenReturn(serviceRequest); - MethodOutcome result = resourceProvider - .createProcedureRequest((ProcedureRequest) VersionConvertor_30_40.convertResource(serviceRequest, false)); + MethodOutcome result = resourceProvider.createProcedureRequest((ProcedureRequest) convertResource(serviceRequest)); assertThat(result, notNullValue()); assertThat(result.getCreated(), is(true)); @@ -274,7 +273,7 @@ public void updateProcedureRequest_shouldUpdateProcedureRequest() { when(serviceRequestService.update(eq(SERVICE_REQUEST_UUID), any(ServiceRequest.class))).thenReturn(serviceRequest); MethodOutcome result = resourceProvider.updateProcedureRequest(new IdType().setValue(SERVICE_REQUEST_UUID), - (ProcedureRequest) VersionConvertor_30_40.convertResource(serviceRequest, false)); + (ProcedureRequest) convertResource(serviceRequest)); assertThat(result, notNullValue()); assertThat(result.getResource(), notNullValue()); @@ -287,7 +286,7 @@ public void updateProcedureRequest_shouldThrowInvalidRequestForUuidMismatch() { .thenThrow(InvalidRequestException.class); resourceProvider.updateProcedureRequest(new IdType().setValue(WRONG_SERVICE_REQUEST_UUID), - (ProcedureRequest) VersionConvertor_30_40.convertResource(serviceRequest, false)); + (ProcedureRequest) convertResource(serviceRequest)); } @Test(expected = InvalidRequestException.class) @@ -298,7 +297,7 @@ public void updateProcedureRequest_shouldThrowInvalidRequestForMissingId() { .thenThrow(InvalidRequestException.class); resourceProvider.updateProcedureRequest(new IdType().setValue(SERVICE_REQUEST_UUID), - (ProcedureRequest) VersionConvertor_30_40.convertResource(noIdServiceRequest, false)); + (ProcedureRequest) convertResource(noIdServiceRequest)); } @Test(expected = MethodNotAllowedException.class) @@ -310,7 +309,7 @@ public void updateProcedureRequest_shouldThrowMethodNotAllowedIfDoesNotExist() { .thenThrow(MethodNotAllowedException.class); resourceProvider.updateProcedureRequest(new IdType().setValue(WRONG_SERVICE_REQUEST_UUID), - (ProcedureRequest) VersionConvertor_30_40.convertResource(wrongServiceRequest, false)); + (ProcedureRequest) convertResource(wrongServiceRequest)); } @Test diff --git a/integration-tests-2.6/pom.xml b/integration-tests-2.6/pom.xml index aa8afee47b..c4a2b3c21e 100644 --- a/integration-tests-2.6/pom.xml +++ b/integration-tests-2.6/pom.xml @@ -77,7 +77,7 @@ com.fasterxml.jackson.core jackson-databind - 2.10.5.1 + 2.13.1 provided diff --git a/integration-tests-2.7/pom.xml b/integration-tests-2.7/pom.xml index 97ef150dda..205706f373 100644 --- a/integration-tests-2.7/pom.xml +++ b/integration-tests-2.7/pom.xml @@ -77,7 +77,7 @@ com.fasterxml.jackson.core jackson-databind - 2.10.5.1 + 2.13.1 provided diff --git a/pom.xml b/pom.xml index 820187ce23..f6af368ad2 100644 --- a/pom.xml +++ b/pom.xml @@ -883,7 +883,7 @@ 1.18.26 2.4.1 2.4.1 - 5.4.0 + 5.7.9 1.0.3