diff --git a/api-2.2/src/main/java/org/openmrs/module/fhir2/api/impl/FhirConditionServiceImpl_2_2.java b/api-2.2/src/main/java/org/openmrs/module/fhir2/api/impl/FhirConditionServiceImpl_2_2.java index fa3893fe27..6c1b5abf51 100644 --- a/api-2.2/src/main/java/org/openmrs/module/fhir2/api/impl/FhirConditionServiceImpl_2_2.java +++ b/api-2.2/src/main/java/org/openmrs/module/fhir2/api/impl/FhirConditionServiceImpl_2_2.java @@ -29,7 +29,6 @@ import org.openmrs.module.fhir2.api.dao.FhirConditionDao; import org.openmrs.module.fhir2.api.search.SearchQuery; import org.openmrs.module.fhir2.api.search.SearchQueryInclude; -import org.openmrs.module.fhir2.api.search.SearchQueryInclude_2_2; import org.openmrs.module.fhir2.api.search.param.SearchParameterMap; import org.openmrs.module.fhir2.api.translators.ConditionTranslator; import org.springframework.beans.factory.annotation.Autowired; @@ -50,7 +49,7 @@ public class FhirConditionServiceImpl_2_2 extends BaseFhirService translator; @Autowired - private SearchQueryInclude_2_2 searchQueryInclude; + private SearchQueryInclude searchQueryInclude; @Autowired private SearchQuery, ConditionTranslator, SearchQueryInclude> searchQuery; diff --git a/api-2.2/src/main/java/org/openmrs/module/fhir2/api/search/SearchQueryInclude_2_2.java b/api-2.2/src/main/java/org/openmrs/module/fhir2/api/search/SearchQueryInclude_2_2.java deleted file mode 100644 index 81c770af95..0000000000 --- a/api-2.2/src/main/java/org/openmrs/module/fhir2/api/search/SearchQueryInclude_2_2.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * 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.api.search; - -import java.util.HashSet; -import java.util.List; -import java.util.Objects; -import java.util.Set; - -import ca.uhn.fhir.model.api.Include; -import lombok.NoArgsConstructor; -import org.apache.commons.collections.CollectionUtils; -import org.hl7.fhir.instance.model.api.IBaseResource; -import org.hl7.fhir.r4.model.Condition; -import org.openmrs.module.fhir2.FhirConstants; -import org.openmrs.module.fhir2.api.FhirPatientService; -import org.openmrs.module.fhir2.api.search.param.PropParam; -import org.openmrs.module.fhir2.api.search.param.SearchParameterMap; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -@Component -@NoArgsConstructor -public class SearchQueryInclude_2_2 extends SearchQueryInclude { - - @Autowired - private FhirPatientService patientService; - - @Override - @SuppressWarnings("unchecked") - public Set getIncludedResources(List resourceList, SearchParameterMap theParams) { - Set includedResourcesSet = new HashSet<>(); - - List> includeParamList = theParams.getParameters(FhirConstants.INCLUDE_SEARCH_HANDLER); - - if (CollectionUtils.isEmpty(includeParamList)) { - return includedResourcesSet; - } - - Set includeSet = (HashSet) includeParamList.get(0).getParam(); - includeSet.forEach(includeParam -> { - switch (includeParam.getParamName()) { - case FhirConstants.INCLUDE_PATIENT_PARAM: - includedResourcesSet.addAll(handlePatientInclude(resourceList, includeParam.getParamType())); - break; - } - }); - - return includedResourcesSet; - } - - private Set handlePatientInclude(List resourceList, String paramType) { - Set includedResources = new HashSet<>(); - Set uniquePatientUUIDs = new HashSet<>(); - - switch (paramType) { - case FhirConstants.CONDITION: - resourceList.forEach(resource -> uniquePatientUUIDs.add(getIdFromReference(resource.getSubject()))); - break; - } - - uniquePatientUUIDs.removeIf(Objects::isNull); - includedResources.addAll(patientService.get(uniquePatientUUIDs)); - - return includedResources; - } - -} diff --git a/api-2.2/src/test/java/org/openmrs/module/fhir2/api/impl/FhirConditionServiceImpl_2_2Test.java b/api-2.2/src/test/java/org/openmrs/module/fhir2/api/impl/FhirConditionServiceImpl_2_2Test.java index 6efbe3cb6e..34cb99645a 100644 --- a/api-2.2/src/test/java/org/openmrs/module/fhir2/api/impl/FhirConditionServiceImpl_2_2Test.java +++ b/api-2.2/src/test/java/org/openmrs/module/fhir2/api/impl/FhirConditionServiceImpl_2_2Test.java @@ -53,7 +53,6 @@ import org.openmrs.module.fhir2.api.search.SearchQuery; import org.openmrs.module.fhir2.api.search.SearchQueryBundleProvider; import org.openmrs.module.fhir2.api.search.SearchQueryInclude; -import org.openmrs.module.fhir2.api.search.SearchQueryInclude_2_2; import org.openmrs.module.fhir2.api.search.param.SearchParameterMap; import org.openmrs.module.fhir2.api.translators.ConditionTranslator; @@ -80,7 +79,7 @@ public class FhirConditionServiceImpl_2_2Test { private FhirGlobalPropertyService globalPropertyService; @Mock - private SearchQueryInclude_2_2 searchQueryInclude; + private SearchQueryInclude searchQueryInclude; @Mock private SearchQuery, ConditionTranslator, SearchQueryInclude> searchQuery; diff --git a/api-2.2/src/test/java/org/openmrs/module/fhir2/api/search/ConditionSearchQueryImpl_2_2Test.java b/api-2.2/src/test/java/org/openmrs/module/fhir2/api/search/ConditionSearchQueryImpl_2_2Test.java index 3b371c9908..6dcc2e3171 100644 --- a/api-2.2/src/test/java/org/openmrs/module/fhir2/api/search/ConditionSearchQueryImpl_2_2Test.java +++ b/api-2.2/src/test/java/org/openmrs/module/fhir2/api/search/ConditionSearchQueryImpl_2_2Test.java @@ -135,7 +135,7 @@ public class ConditionSearchQueryImpl_2_2Test extends BaseModuleContextSensitive private ConditionTranslator translator; @Autowired - private SearchQueryInclude_2_2 searchQueryInclude; + private SearchQueryInclude searchQueryInclude; @Autowired private SearchQuery, ConditionTranslator, SearchQueryInclude> searchQuery; diff --git a/api-2.6/src/main/java/org/openmrs/module/fhir2/api/search/SearchQueryInclude_2_6.java b/api-2.6/src/main/java/org/openmrs/module/fhir2/api/search/SearchQueryInclude_2_6.java deleted file mode 100644 index 71e3915f9e..0000000000 --- a/api-2.6/src/main/java/org/openmrs/module/fhir2/api/search/SearchQueryInclude_2_6.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * 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.api.search; - -import java.util.HashSet; -import java.util.List; -import java.util.Objects; -import java.util.Set; - -import ca.uhn.fhir.model.api.Include; -import lombok.NoArgsConstructor; -import org.apache.commons.collections.CollectionUtils; -import org.hl7.fhir.instance.model.api.IBaseResource; -import org.hl7.fhir.r4.model.MedicationDispense; -import org.openmrs.module.fhir2.FhirConstants; -import org.openmrs.module.fhir2.api.FhirPatientService; -import org.openmrs.module.fhir2.api.search.param.PropParam; -import org.openmrs.module.fhir2.api.search.param.SearchParameterMap; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -@Component -@NoArgsConstructor -public class SearchQueryInclude_2_6 extends SearchQueryInclude { - - @Autowired - private FhirPatientService patientService; - - @Override - @SuppressWarnings("unchecked") - public Set getIncludedResources(List resourceList, SearchParameterMap theParams) { - Set includedResourcesSet = new HashSet<>(); - - List> includeParamList = theParams.getParameters(FhirConstants.INCLUDE_SEARCH_HANDLER); - - if (CollectionUtils.isEmpty(includeParamList)) { - return includedResourcesSet; - } - - Set includeSet = (HashSet) includeParamList.get(0).getParam(); - includeSet.forEach(includeParam -> { - switch (includeParam.getParamName()) { - case FhirConstants.INCLUDE_PATIENT_PARAM: - includedResourcesSet.addAll(handlePatientInclude(resourceList, includeParam.getParamType())); - break; - } - }); - - return includedResourcesSet; - } - - private Set handlePatientInclude(List resourceList, String paramType) { - Set includedResources = new HashSet<>(); - Set uniquePatientUUIDs = new HashSet<>(); - - switch (paramType) { - case FhirConstants.MEDICATION_DISPENSE: - resourceList.forEach(resource -> uniquePatientUUIDs.add(getIdFromReference(resource.getSubject()))); - break; - } - - uniquePatientUUIDs.removeIf(Objects::isNull); - includedResources.addAll(patientService.get(uniquePatientUUIDs)); - - return includedResources; - } - -} diff --git a/api-2.6/src/test/java/org/openmrs/module/fhir2/api/impl/FhirMedicationDispenseServiceImpl_2_6Test.java b/api-2.6/src/test/java/org/openmrs/module/fhir2/api/impl/FhirMedicationDispenseServiceImpl_2_6Test.java index e9b6f5588f..118d16a243 100644 --- a/api-2.6/src/test/java/org/openmrs/module/fhir2/api/impl/FhirMedicationDispenseServiceImpl_2_6Test.java +++ b/api-2.6/src/test/java/org/openmrs/module/fhir2/api/impl/FhirMedicationDispenseServiceImpl_2_6Test.java @@ -48,7 +48,6 @@ import org.openmrs.module.fhir2.api.search.SearchQuery; import org.openmrs.module.fhir2.api.search.SearchQueryBundleProvider; import org.openmrs.module.fhir2.api.search.SearchQueryInclude; -import org.openmrs.module.fhir2.api.search.SearchQueryInclude_2_6; import org.openmrs.module.fhir2.api.search.param.MedicationDispenseSearchParams; import org.openmrs.module.fhir2.api.search.param.SearchParameterMap; import org.openmrs.module.fhir2.api.translators.MedicationDispenseTranslator; @@ -70,7 +69,7 @@ public class FhirMedicationDispenseServiceImpl_2_6Test { private FhirGlobalPropertyService globalPropertyService; @Mock - private SearchQueryInclude_2_6 searchQueryInclude; + private SearchQueryInclude searchQueryInclude; @Mock private SearchQuery, MedicationDispenseTranslator, SearchQueryInclude> searchQuery; diff --git a/api-2.6/src/test/java/org/openmrs/module/fhir2/api/search/MedicationDispenseSearchQueryImpl_2_6Test.java b/api-2.6/src/test/java/org/openmrs/module/fhir2/api/search/MedicationDispenseSearchQueryImpl_2_6Test.java index 672e5b253e..2d783ddaef 100644 --- a/api-2.6/src/test/java/org/openmrs/module/fhir2/api/search/MedicationDispenseSearchQueryImpl_2_6Test.java +++ b/api-2.6/src/test/java/org/openmrs/module/fhir2/api/search/MedicationDispenseSearchQueryImpl_2_6Test.java @@ -9,15 +9,6 @@ */ package org.openmrs.module.fhir2.api.search; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.anyOf; -import static org.hamcrest.Matchers.endsWith; -import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.notNullValue; -import static org.hl7.fhir.r4.model.Patient.SP_IDENTIFIER; - -import java.util.List; - import ca.uhn.fhir.rest.api.server.IBundleProvider; import ca.uhn.fhir.rest.param.ReferenceAndListParam; import ca.uhn.fhir.rest.param.ReferenceOrListParam; @@ -42,6 +33,15 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; +import java.util.List; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.anyOf; +import static org.hamcrest.Matchers.endsWith; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.notNullValue; +import static org.hl7.fhir.r4.model.Patient.SP_IDENTIFIER; + @ContextConfiguration(classes = TestFhirSpringConfiguration.class, inheritLocations = false) public class MedicationDispenseSearchQueryImpl_2_6Test extends BaseModuleContextSensitiveTest { @@ -52,7 +52,7 @@ public class MedicationDispenseSearchQueryImpl_2_6Test extends BaseModuleContext private MedicationDispenseTranslator translator; @Autowired - private SearchQueryInclude_2_6 searchQueryInclude; + private SearchQueryInclude searchQueryInclude; @Autowired private SearchQuery, MedicationDispenseTranslator, SearchQueryInclude> searchQuery; diff --git a/api-2.6/src/test/java/org/openmrs/module/fhir2/api/search/MedicationRequestSearchQueryImpl_2_6Test.java b/api-2.6/src/test/java/org/openmrs/module/fhir2/api/search/MedicationRequestSearchQueryImpl_2_6Test.java index 3e6311374d..a543148101 100644 --- a/api-2.6/src/test/java/org/openmrs/module/fhir2/api/search/MedicationRequestSearchQueryImpl_2_6Test.java +++ b/api-2.6/src/test/java/org/openmrs/module/fhir2/api/search/MedicationRequestSearchQueryImpl_2_6Test.java @@ -1,3 +1,12 @@ +/* + * 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.api.search; import static org.hamcrest.MatcherAssert.assertThat;