Skip to content
Permalink
Browse files

Added allergies to search suggestions

  • Loading branch information
k-joseph committed Jun 29, 2015
1 parent f0454f5 commit 14e06903c1709cadb8335226c2bb600d76c5fc97
@@ -35,6 +35,9 @@
import org.openmrs.api.ObsService;
import org.openmrs.api.context.Context;
import org.openmrs.api.impl.BaseOpenmrsService;
import org.openmrs.module.allergyapi.Allergies;
import org.openmrs.module.allergyapi.Allergy;
import org.openmrs.module.allergyapi.api.PatientService;
import org.openmrs.module.chartsearch.GeneratingJson;
import org.openmrs.module.chartsearch.api.ChartSearchService;
import org.openmrs.module.chartsearch.api.db.CategoryFilterDAO;
@@ -50,7 +53,6 @@
import org.openmrs.util.PrivilegeConstants;
import org.springframework.transaction.annotation.Transactional;


/**
* It is a default implementation of {@link ChartSearchService}.
*/
@@ -330,21 +332,34 @@ public void indexAllPatientData(Integer numberOfResults, SolrServer solrServer,
@Override
public List<String> getAllPossibleSearchSuggestions(Integer patientId) {
ObsService obsService = Context.getObsService();
List<String> conceptNameSuggestions = new ArrayList<String>();
List<String> suggestions = new ArrayList<String>();

List<Obs> allPatientObs = obsService.getObservationsByPerson(new Patient(patientId));
Allergies allAllergies = Context.getService(PatientService.class).getAllergies(
Context.getPatientService().getPatient(patientId));

for (Obs currentObs : allPatientObs) {
if (currentObs != null && currentObs.getConcept() != null && currentObs.getConcept().getName() != null) {
String currentConceptName = currentObs.getConcept().getName().getName();
if (StringUtils.isNotBlank(currentConceptName)) {
conceptNameSuggestions.add(currentConceptName);
suggestions.add(currentConceptName);
}
}
}
//TODO add previous search terms, allergies and appointments to conceptNameSuggestions list
for (Allergy allergy : allAllergies) {
if (allergy != null) {
String nonCoded = allergy.getAllergen().getNonCodedAllergen();
String coded = allergy.getAllergen().getCodedAllergen().getName().getName();
if (StringUtils.isNotBlank(nonCoded)) {
suggestions.add(nonCoded);
} else {
suggestions.add(coded);
}
}
}

return conceptNameSuggestions;
return suggestions;
}

@Override

0 comments on commit 14e0690

Please sign in to comment.
You can’t perform that action at this time.