Skip to content

Commit

Permalink
Fixed some bug in ChartSearchNonFacetFiltering and adding appointment…
Browse files Browse the repository at this point in the history
…s to display results
  • Loading branch information
k-joseph committed Jul 7, 2015
1 parent 0ec93e8 commit 4e6a69f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
Expand Up @@ -31,9 +31,11 @@ public class ChartSearchNonFacetFiltering {
* @param categoryName
* @return
*/
public boolean checkIfCategoriesContainNonFacetCategory(List<String> categories, String categoryName) {
private boolean checkIfCategoriesContainNonFacetCategory(List<String> categories, String categoryName) {
boolean contains = false;
if (categories != null && !categories.isEmpty() && categories.size() > 1 && StringUtils.isNotBlank(categoryName)) {
if (categories != null && !categories.isEmpty() && categories.size() > 1
&& !checkIfCategoriesContainBothAndOnlyAllergiesAndAppointments(categories)
&& StringUtils.isNotBlank(categoryName)) {
for (int i = 0; i < categories.size(); i++) {
if (categories.get(i).equals(categoryName)) {
contains = true;
Expand All @@ -44,7 +46,7 @@ public boolean checkIfCategoriesContainNonFacetCategory(List<String> categories,
return contains;
}

public boolean checkifCategoriesContainsOnlyOneNonFacetCategory(List<String> categories, String categoryName) {
private 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)) {
Expand All @@ -55,15 +57,31 @@ public boolean checkifCategoriesContainsOnlyOneNonFacetCategory(List<String> cat
return contains;
}

private boolean checkIfCategoriesContainBothAndOnlyAllergiesAndAppointments(List<String> categories) {
boolean contains = false;
if (categories != null && !categories.isEmpty()) {
if (categories.size() == 2
&& ((categories.get(0).equals("allergies") && categories.get(1).equals("appointments")) || (categories
.get(0).equals("appointments") && categories.get(1).equals("allergies")))) {
contains = true;
}
}

return contains;
}

public void applyNonFacetingLogicWhileSearching(Integer patientId, String searchText, List<String> selectedCategories,
SolrServer solrServer, SolrQuery query, List<ChartListItem> list)
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 (checkIfCategoriesContainBothAndOnlyAllergiesAndAppointments(selectedCategories)) {
searcher.searchAllergiesAndGenerateSolrDoc(patientId, searchText, solrServer, list);
searcher.searchAppointmentsAndGenerateSolrDoc(patientId, searchText, solrServer, list);
} else if (checkIfCategoriesContainNonFacetCategory(selectedCategories, "allergies")
&& !checkIfCategoriesContainNonFacetCategory(selectedCategories, "appointments")) {
searcher.searchObservationsAndGenerateSolrDoc(solrServer, query, list);
Expand Down
2 changes: 1 addition & 1 deletion omod/src/main/webapp/resources/scripts/views_factory.js
Expand Up @@ -228,7 +228,7 @@ function addAppointmentsToResults(app) {

if (jsonAfterParse.obs_singles.length === 0
&& jsonAfterParse.patientAllergies.length === 0
&& jsonAfterParse.patientAllergies[0].id === app.id) {
&& jsonAfterParse.patientAppointments[0].id === app.id) {
appointmentIdHtml = 'id="first_appointment"';
appId = "first_appointment";
} else {
Expand Down

0 comments on commit 4e6a69f

Please sign in to comment.