Skip to content

Commit

Permalink
FM2-613: Upgrade Hapi Fhir version to v5.7.9 (#521)
Browse files Browse the repository at this point in the history
  • Loading branch information
mherman22 authored Oct 30, 2023
1 parent 6b00ddb commit 6196a97
Show file tree
Hide file tree
Showing 34 changed files with 402 additions and 365 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand Down Expand Up @@ -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);

This comment has been minimized.

Copy link
@taranpreet26-singh

taranpreet26-singh Dec 12, 2023

here return come twice and that why here compile time error come

This comment has been minimized.

Copy link
@taranpreet26-singh

taranpreet26-singh Dec 12, 2023

Here return convertResource((Resource) resource); not come

}

return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
Loading

0 comments on commit 6196a97

Please sign in to comment.