-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FM2-183: Add support for DSTU3 (#158)
- Loading branch information
1 parent
75a5517
commit c1548b3
Showing
111 changed files
with
9,348 additions
and
312 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
...in/java/org/openmrs/module/fhir2/providers/r3/AllergyIntoleranceFhirResourceProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/* | ||
* This Source Code Form is subject to the terms of the Mozilla Public License, | ||
* v. 2.0. If a copy of the MPL was not distributed with this file, You can | ||
* obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under | ||
* the terms of the Healthcare Disclaimer located at http://openmrs.org/license. | ||
* | ||
* Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS | ||
* graphic logo is a trademark of OpenMRS Inc. | ||
*/ | ||
package org.openmrs.module.fhir2.providers.r3; | ||
|
||
import javax.validation.constraints.NotNull; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
import ca.uhn.fhir.rest.annotation.History; | ||
import ca.uhn.fhir.rest.annotation.IdParam; | ||
import ca.uhn.fhir.rest.annotation.OptionalParam; | ||
import ca.uhn.fhir.rest.annotation.Read; | ||
import ca.uhn.fhir.rest.annotation.Search; | ||
import ca.uhn.fhir.rest.param.ReferenceAndListParam; | ||
import ca.uhn.fhir.rest.param.TokenAndListParam; | ||
import ca.uhn.fhir.rest.server.IResourceProvider; | ||
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; | ||
import lombok.AccessLevel; | ||
import lombok.Setter; | ||
import org.hl7.fhir.convertors.conv30_40.AllergyIntolerance30_40; | ||
import org.hl7.fhir.convertors.conv30_40.Bundle30_40; | ||
import org.hl7.fhir.convertors.conv30_40.Provenance30_40; | ||
import org.hl7.fhir.dstu3.model.AllergyIntolerance; | ||
import org.hl7.fhir.dstu3.model.Bundle; | ||
import org.hl7.fhir.dstu3.model.IdType; | ||
import org.hl7.fhir.dstu3.model.Patient; | ||
import org.hl7.fhir.dstu3.model.Resource; | ||
import org.hl7.fhir.instance.model.api.IBaseResource; | ||
import org.hl7.fhir.r4.model.Provenance; | ||
import org.openmrs.module.fhir2.api.FhirAllergyIntoleranceService; | ||
import org.openmrs.module.fhir2.providers.util.FhirProviderUtils; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.beans.factory.annotation.Qualifier; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component("allergyIntoleranceFhirR3ResourceProvider") | ||
@Qualifier("fhirR3Resources") | ||
@Setter(AccessLevel.PACKAGE) | ||
public class AllergyIntoleranceFhirResourceProvider implements IResourceProvider { | ||
|
||
@Override | ||
public Class<? extends IBaseResource> getResourceType() { | ||
return AllergyIntolerance.class; | ||
} | ||
|
||
@Autowired | ||
private FhirAllergyIntoleranceService allergyIntoleranceService; | ||
|
||
@Read | ||
@SuppressWarnings("unused") | ||
public AllergyIntolerance getAllergyIntoleranceById(@IdParam @NotNull IdType id) { | ||
org.hl7.fhir.r4.model.AllergyIntolerance allergyIntolerance = allergyIntoleranceService.get(id.getIdPart()); | ||
if (allergyIntolerance == null) { | ||
throw new ResourceNotFoundException("Could not find allergyIntolerance with Id " + id.getIdPart()); | ||
} | ||
|
||
return AllergyIntolerance30_40.convertAllergyIntolerance(allergyIntolerance); | ||
} | ||
|
||
@History | ||
@SuppressWarnings("unused") | ||
public List<Resource> getAllergyIntoleranceHistoryById(@IdParam @NotNull IdType id) { | ||
org.hl7.fhir.r4.model.AllergyIntolerance allergyIntolerance = allergyIntoleranceService.get(id.getIdPart()); | ||
if (allergyIntolerance == null) { | ||
throw new ResourceNotFoundException("Could not find allergy with Id " + id.getIdPart()); | ||
} | ||
|
||
return allergyIntolerance.getContained().stream().filter(r -> r instanceof Provenance).map(r -> (Provenance) r) | ||
.map(Provenance30_40::convertProvenance).collect(Collectors.toList()); | ||
} | ||
|
||
@Search | ||
@SuppressWarnings("unused") | ||
public Bundle searchForAllergies( | ||
@OptionalParam(name = AllergyIntolerance.SP_PATIENT, chainWhitelist = { "", Patient.SP_IDENTIFIER, | ||
Patient.SP_GIVEN, Patient.SP_FAMILY, | ||
Patient.SP_NAME }, targetTypes = Patient.class) ReferenceAndListParam patientReference, | ||
@OptionalParam(name = AllergyIntolerance.SP_CATEGORY) TokenAndListParam category, | ||
@OptionalParam(name = AllergyIntolerance.SP_CODE) TokenAndListParam allergen, | ||
@OptionalParam(name = AllergyIntolerance.SP_SEVERITY) TokenAndListParam severity, | ||
@OptionalParam(name = AllergyIntolerance.SP_MANIFESTATION) TokenAndListParam manifestationCode, | ||
@OptionalParam(name = AllergyIntolerance.SP_CLINICAL_STATUS) TokenAndListParam clinicalStatus) { | ||
return Bundle30_40.convertBundle(FhirProviderUtils.convertSearchResultsToBundle(allergyIntoleranceService | ||
.searchForAllergies(patientReference, category, allergen, severity, manifestationCode, clinicalStatus))); | ||
} | ||
} |
93 changes: 93 additions & 0 deletions
93
api/src/main/java/org/openmrs/module/fhir2/providers/r3/ConditionFhirResourceProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/* | ||
* This Source Code Form is subject to the terms of the Mozilla Public License, | ||
* v. 2.0. If a copy of the MPL was not distributed with this file, You can | ||
* obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under | ||
* the terms of the Healthcare Disclaimer located at http://openmrs.org/license. | ||
* | ||
* Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS | ||
* graphic logo is a trademark of OpenMRS Inc. | ||
*/ | ||
package org.openmrs.module.fhir2.providers.r3; | ||
|
||
import javax.validation.constraints.NotNull; | ||
|
||
import java.util.List; | ||
|
||
import ca.uhn.fhir.rest.annotation.*; | ||
import ca.uhn.fhir.rest.api.MethodOutcome; | ||
import ca.uhn.fhir.rest.api.SortSpec; | ||
import ca.uhn.fhir.rest.param.DateRangeParam; | ||
import ca.uhn.fhir.rest.param.QuantityAndListParam; | ||
import ca.uhn.fhir.rest.param.ReferenceAndListParam; | ||
import ca.uhn.fhir.rest.param.TokenAndListParam; | ||
import ca.uhn.fhir.rest.server.IResourceProvider; | ||
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; | ||
import lombok.AccessLevel; | ||
import lombok.Setter; | ||
import org.hl7.fhir.convertors.conv30_40.Bundle30_40; | ||
import org.hl7.fhir.convertors.conv30_40.Condition30_40; | ||
import org.hl7.fhir.dstu3.model.*; | ||
import org.hl7.fhir.instance.model.api.IBaseResource; | ||
import org.openmrs.module.fhir2.api.FhirConditionService; | ||
import org.openmrs.module.fhir2.providers.util.FhirProviderUtils; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.beans.factory.annotation.Qualifier; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component("conditionFhirR3ResourceProvider") | ||
@Qualifier("fhirR3Resources") | ||
@Setter(AccessLevel.PACKAGE) | ||
public class ConditionFhirResourceProvider implements IResourceProvider { | ||
|
||
@Autowired | ||
private FhirConditionService conditionService; | ||
|
||
@Override | ||
public Class<? extends IBaseResource> getResourceType() { | ||
return Condition.class; | ||
} | ||
|
||
@Read | ||
@SuppressWarnings("unused") | ||
public Condition getConditionById(@IdParam @NotNull IdType id) { | ||
org.hl7.fhir.r4.model.Condition condition = conditionService.getConditionByUuid(id.getIdPart()); | ||
if (condition == null) { | ||
throw new ResourceNotFoundException("Could not find condition with Id " + id.getIdPart()); | ||
} | ||
|
||
return Condition30_40.convertCondition(condition); | ||
} | ||
|
||
@History | ||
@SuppressWarnings("unused") | ||
public List<Resource> getConditionHistoryById(@IdParam @NotNull IdType id) { | ||
org.hl7.fhir.r4.model.Condition condition = conditionService.getConditionByUuid(id.getIdPart()); | ||
if (condition == null) { | ||
throw new ResourceNotFoundException("Could not find condition with Id " + id.getIdPart()); | ||
} | ||
return Condition30_40.convertCondition(condition).getContained(); | ||
} | ||
|
||
@Create | ||
@SuppressWarnings("unused") | ||
public MethodOutcome createCondition(@ResourceParam Condition newCondition) { | ||
return FhirProviderUtils.buildCreate(conditionService.saveCondition(Condition30_40.convertCondition(newCondition))); | ||
} | ||
|
||
@Search | ||
@SuppressWarnings("unused") | ||
public Bundle searchConditions( | ||
@OptionalParam(name = Condition.SP_PATIENT, chainWhitelist = { "", Patient.SP_IDENTIFIER, Patient.SP_NAME, | ||
Patient.SP_GIVEN, Patient.SP_FAMILY }) ReferenceAndListParam patientParam, | ||
@OptionalParam(name = Condition.SP_SUBJECT, chainWhitelist = { "", Patient.SP_IDENTIFIER, Patient.SP_NAME, | ||
Patient.SP_GIVEN, Patient.SP_FAMILY }) ReferenceAndListParam subjectParam, | ||
@OptionalParam(name = Condition.SP_CODE) TokenAndListParam code, | ||
@OptionalParam(name = Condition.SP_CLINICAL_STATUS) TokenAndListParam clinicalStatus, | ||
@OptionalParam(name = Condition.SP_ONSET_DATE) DateRangeParam onsetDate, | ||
@OptionalParam(name = Condition.SP_ONSET_AGE) QuantityAndListParam onsetAge, | ||
@OptionalParam(name = Condition.SP_ASSERTED_DATE) DateRangeParam recordedDate, @Sort SortSpec sort) { | ||
return Bundle30_40 | ||
.convertBundle(FhirProviderUtils.convertSearchResultsToBundle(conditionService.searchConditions(patientParam, | ||
subjectParam, code, clinicalStatus, onsetDate, onsetAge, recordedDate, sort))); | ||
} | ||
} |
71 changes: 71 additions & 0 deletions
71
...main/java/org/openmrs/module/fhir2/providers/r3/DiagnosticReportFhirResourceProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* This Source Code Form is subject to the terms of the Mozilla Public License, | ||
* v. 2.0. If a copy of the MPL was not distributed with this file, You can | ||
* obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under | ||
* the terms of the Healthcare Disclaimer located at http://openmrs.org/license. | ||
* | ||
* Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS | ||
* graphic logo is a trademark of OpenMRS Inc. | ||
*/ | ||
package org.openmrs.module.fhir2.providers.r3; | ||
|
||
import javax.validation.constraints.NotNull; | ||
|
||
import ca.uhn.fhir.rest.annotation.*; | ||
import ca.uhn.fhir.rest.api.MethodOutcome; | ||
import ca.uhn.fhir.rest.server.IResourceProvider; | ||
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; | ||
import lombok.AccessLevel; | ||
import lombok.Setter; | ||
import org.hl7.fhir.convertors.conv30_40.DiagnosticReport30_40; | ||
import org.hl7.fhir.dstu3.model.DiagnosticReport; | ||
import org.hl7.fhir.dstu3.model.IdType; | ||
import org.hl7.fhir.instance.model.api.IBaseResource; | ||
import org.openmrs.module.fhir2.api.FhirDiagnosticReportService; | ||
import org.openmrs.module.fhir2.providers.util.FhirProviderUtils; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.beans.factory.annotation.Qualifier; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component("diagnosticReportFhirR3ResourceProvider") | ||
@Qualifier("fhirR3Resources") | ||
@Setter(AccessLevel.PACKAGE) | ||
public class DiagnosticReportFhirResourceProvider implements IResourceProvider { | ||
|
||
@Autowired | ||
private FhirDiagnosticReportService diagnosticReportService; | ||
|
||
@Override | ||
public Class<? extends IBaseResource> getResourceType() { | ||
return DiagnosticReport.class; | ||
} | ||
|
||
@Read | ||
@SuppressWarnings("unused") | ||
public DiagnosticReport getDiagnosticReportById(@IdParam @NotNull IdType id) { | ||
org.hl7.fhir.r4.model.DiagnosticReport diagnosticReport = diagnosticReportService.get(id.getIdPart()); | ||
if (diagnosticReport == null) { | ||
throw new ResourceNotFoundException("Could not find diagnosticReport with Id " + id.getIdPart()); | ||
} | ||
|
||
return DiagnosticReport30_40.convertDiagnosticReport(diagnosticReport); | ||
} | ||
|
||
@Create | ||
public MethodOutcome createDiagnosticReport(@ResourceParam DiagnosticReport diagnosticReport) { | ||
return FhirProviderUtils.buildCreate( | ||
diagnosticReportService.create(DiagnosticReport30_40.convertDiagnosticReport(diagnosticReport))); | ||
} | ||
|
||
@Update | ||
public MethodOutcome updateDiagnosticReport(@IdParam IdType id, @ResourceParam DiagnosticReport diagnosticReport) { | ||
String idPart = null; | ||
|
||
if (id != null) { | ||
idPart = id.getIdPart(); | ||
} | ||
|
||
return FhirProviderUtils.buildUpdate( | ||
diagnosticReportService.update(idPart, DiagnosticReport30_40.convertDiagnosticReport(diagnosticReport))); | ||
} | ||
} |
83 changes: 83 additions & 0 deletions
83
api/src/main/java/org/openmrs/module/fhir2/providers/r3/EncounterFhirResourceProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
* This Source Code Form is subject to the terms of the Mozilla Public License, | ||
* v. 2.0. If a copy of the MPL was not distributed with this file, You can | ||
* obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under | ||
* the terms of the Healthcare Disclaimer located at http://openmrs.org/license. | ||
* | ||
* Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS | ||
* graphic logo is a trademark of OpenMRS Inc. | ||
*/ | ||
package org.openmrs.module.fhir2.providers.r3; | ||
|
||
import javax.validation.constraints.NotNull; | ||
|
||
import java.util.List; | ||
|
||
import ca.uhn.fhir.rest.annotation.*; | ||
import ca.uhn.fhir.rest.param.DateRangeParam; | ||
import ca.uhn.fhir.rest.param.ReferenceAndListParam; | ||
import ca.uhn.fhir.rest.server.IResourceProvider; | ||
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; | ||
import lombok.AccessLevel; | ||
import lombok.Setter; | ||
import org.hl7.fhir.convertors.conv30_40.Bundle30_40; | ||
import org.hl7.fhir.convertors.conv30_40.Encounter30_40; | ||
import org.hl7.fhir.dstu3.model.*; | ||
import org.hl7.fhir.instance.model.api.IBaseResource; | ||
import org.openmrs.module.fhir2.api.FhirEncounterService; | ||
import org.openmrs.module.fhir2.providers.util.FhirProviderUtils; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.beans.factory.annotation.Qualifier; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component("encounterFhirR3ResourceProvider") | ||
@Qualifier("fhirR3Resources") | ||
@Setter(AccessLevel.PACKAGE) | ||
public class EncounterFhirResourceProvider implements IResourceProvider { | ||
|
||
@Autowired | ||
private FhirEncounterService encounterService; | ||
|
||
@Override | ||
public Class<? extends IBaseResource> getResourceType() { | ||
return Encounter.class; | ||
} | ||
|
||
@Read | ||
@SuppressWarnings("unused") | ||
public Encounter getEncounterById(@IdParam @NotNull IdType id) { | ||
org.hl7.fhir.r4.model.Encounter encounter = encounterService.get(id.getIdPart()); | ||
if (encounter == null) { | ||
throw new ResourceNotFoundException("Could not find encounter with Id " + id.getIdPart()); | ||
} | ||
|
||
return Encounter30_40.convertEncounter(encounter); | ||
} | ||
|
||
@History | ||
@SuppressWarnings("unused") | ||
public List<Resource> getEncounterHistoryById(@IdParam @NotNull IdType id) { | ||
org.hl7.fhir.r4.model.Encounter encounter = encounterService.get(id.getIdPart()); | ||
if (encounter == null) { | ||
throw new ResourceNotFoundException("Could not find encounter with Id " + id.getIdPart()); | ||
} | ||
return Encounter30_40.convertEncounter(encounter).getContained(); | ||
} | ||
|
||
@Search | ||
public Bundle searchEncounter(@OptionalParam(name = Encounter.SP_DATE) DateRangeParam date, | ||
@OptionalParam(name = Encounter.SP_LOCATION, chainWhitelist = { "", Location.SP_ADDRESS_CITY, | ||
Location.SP_ADDRESS_STATE, Location.SP_ADDRESS_COUNTRY, | ||
Location.SP_ADDRESS_POSTALCODE }, targetTypes = Location.class) ReferenceAndListParam location, | ||
@OptionalParam(name = Encounter.SP_PARTICIPANT, chainWhitelist = { "", Practitioner.SP_IDENTIFIER, | ||
Practitioner.SP_GIVEN, Practitioner.SP_FAMILY, | ||
Practitioner.SP_NAME }, targetTypes = Practitioner.class) ReferenceAndListParam participantReference, | ||
@OptionalParam(name = Encounter.SP_SUBJECT, chainWhitelist = { "", Patient.SP_IDENTIFIER, Patient.SP_GIVEN, | ||
Patient.SP_FAMILY, | ||
Patient.SP_NAME }, targetTypes = Patient.class) ReferenceAndListParam subjectReference) { | ||
return Bundle30_40.convertBundle(FhirProviderUtils.convertSearchResultsToBundle( | ||
encounterService.searchForEncounters(date, location, participantReference, subjectReference))); | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.