Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added allergies and appointments category filters
- Loading branch information
Showing
8 changed files
with
156 additions
and
34 deletions.
There are no files selected for viewing
88 changes: 88 additions & 0 deletions
88
api/src/main/java/org/openmrs/module/chartsearch/ChartSearchNonFacetFiltering.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,88 @@ | ||
/** | ||
* 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.chartsearch; | ||
|
||
import java.util.List; | ||
|
||
import org.apache.commons.lang3.StringUtils; | ||
import org.apache.solr.client.solrj.SolrQuery; | ||
import org.apache.solr.client.solrj.SolrServer; | ||
import org.apache.solr.client.solrj.SolrServerException; | ||
import org.openmrs.module.chartsearch.solr.ChartSearchSearcher; | ||
|
||
/** | ||
* Handles all the logic needed to support Allergies and Appointments etc category filtering which | ||
* is not supported using solr faceting | ||
*/ | ||
public class ChartSearchNonFacetFiltering { | ||
|
||
/** | ||
* Checks if categories collection contains a specified categgory such as allergies and | ||
* appointments | ||
* | ||
* @param categories | ||
* @param categoryName | ||
* @return | ||
*/ | ||
public boolean checkIfCategoriesContainNonFacetCategory(List<String> categories, String categoryName) { | ||
boolean contains = false; | ||
if (categories != null && !categories.isEmpty() && categories.size() > 1 && StringUtils.isNotBlank(categoryName)) { | ||
for (int i = 0; i < categories.size(); i++) { | ||
if (categories.get(i).equals(categoryName)) { | ||
contains = true; | ||
break; | ||
} | ||
} | ||
} | ||
return contains; | ||
} | ||
|
||
public boolean checkifCategoriesContainsOnlyOneNonFacetCategory(List<String> categories, String categoryName) { | ||
boolean contains = false; | ||
if (categories != null && !categories.isEmpty() && StringUtils.isNotBlank(categoryName)) { | ||
if (categories.size() == 1 && categories.get(0).equals(categoryName)) { | ||
contains = true; | ||
} | ||
} | ||
|
||
return contains; | ||
} | ||
|
||
public void applyNonFacetingLogicWhileSearching(Integer patientId, String searchText, List<String> selectedCategories, | ||
This comment has been minimized.
Sorry, something went wrong. |
||
SolrServer solrServer, SolrQuery query, List<ChartListItem> list) | ||
throws SolrServerException { | ||
ChartSearchSearcher searcher = new ChartSearchSearcher(); | ||
|
||
if (checkifCategoriesContainsOnlyOneNonFacetCategory(selectedCategories, "allergies")) { | ||
searcher.searchAllergiesAndGenerateSolrDoc(patientId, searchText, solrServer, list); | ||
} else if (checkifCategoriesContainsOnlyOneNonFacetCategory(selectedCategories, "appointments")) { | ||
searcher.searchAppointmentsAndGenerateSolrDoc(patientId, searchText, solrServer, list); | ||
} else if (checkIfCategoriesContainNonFacetCategory(selectedCategories, "allergies") | ||
&& !checkIfCategoriesContainNonFacetCategory(selectedCategories, "appointments")) { | ||
searcher.searchObservationsAndGenerateSolrDoc(solrServer, query, list); | ||
searcher.searchAllergiesAndGenerateSolrDoc(patientId, searchText, solrServer, list); | ||
searcher.searchEncounterTypesAndGenerateSolrDoc(patientId, searchText, solrServer, list); | ||
searcher.searchEFormsAndGenerateSolrDoc(searchText, solrServer, list); | ||
} else if (!checkIfCategoriesContainNonFacetCategory(selectedCategories, "allergies") | ||
&& checkIfCategoriesContainNonFacetCategory(selectedCategories, "appointments")) { | ||
searcher.searchObservationsAndGenerateSolrDoc(solrServer, query, list); | ||
searcher.searchAppointmentsAndGenerateSolrDoc(patientId, searchText, solrServer, list); | ||
searcher.searchEncounterTypesAndGenerateSolrDoc(patientId, searchText, solrServer, list); | ||
searcher.searchEFormsAndGenerateSolrDoc(searchText, solrServer, list); | ||
} else { | ||
searcher.searchObservationsAndGenerateSolrDoc(solrServer, query, list); | ||
searcher.searchAllergiesAndGenerateSolrDoc(patientId, searchText, solrServer, list); | ||
searcher.searchAppointmentsAndGenerateSolrDoc(patientId, searchText, solrServer, list); | ||
searcher.searchEncounterTypesAndGenerateSolrDoc(patientId, searchText, solrServer, list); | ||
searcher.searchEFormsAndGenerateSolrDoc(searchText, solrServer, list); | ||
} | ||
} | ||
|
||
} |
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
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
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
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
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
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
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
Still has some small issues