Skip to content
Permalink
Browse files

Included Returned allergies after search among returned results

  • Loading branch information
k-joseph committed Jun 28, 2015
1 parent f1cae45 commit 73ae6f38a42f4acfa2e5876666685f4b98d1e1bc
@@ -9,6 +9,8 @@
*/
package org.openmrs.module.chartsearch;

import java.util.Date;

public class AllergyItem extends ChartListItem {

private Integer allergyId;
@@ -27,6 +29,8 @@

private String allergenComment;

private Date allergenDate;

public Integer getAllergyId() {
return allergyId;
}
@@ -91,4 +95,12 @@ public void setAllergenComment(String allergenComment) {
this.allergenComment = allergenComment;
}

public Date getAllergenDate() {
return allergenDate;
}

public void setAllergenDate(Date allergenDate) {
this.allergenDate = allergenDate;
}

}
@@ -542,6 +542,7 @@ public static JSONArray generateAllergiesJSONFromResults(List<ChartListItem> ret
json.put("allergenCodedReaction", allergy.getAllergenCodedReaction());
json.put("allergenNonCodedReaction", allergy.getAllergenNonCodedReaction());
json.put("allergenComment", allergy.getAllergenComment());
json.put("allergenDate", allergy.getAllergenDate().getTime());

allergies.add(json);
}
@@ -14,6 +14,7 @@
import java.util.Collection;
import java.util.List;

import org.apache.commons.lang3.StringUtils;
import org.apache.solr.client.solrj.SolrServer;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.response.UpdateResponse;
@@ -79,7 +80,7 @@ private SolrInputDocument addAllergiesPropertiesToSolrDoc(Allergy allergy, Integ
List<AllergyReaction> reactions = allergy.getReactions();
String codedAllegen = null;
String severity = null;
String codedReaction = null;
String codedReaction = "";
String nonCodedReactions = null;

if (allergy.getAllergen().getCodedAllergen() != null) {
@@ -93,10 +94,20 @@ private SolrInputDocument addAllergiesPropertiesToSolrDoc(Allergy allergy, Integ
for (int i = 0; i < reactions.size(); i++) {
AllergyReaction reaction = reactions.get(i);

nonCodedReactions = reaction.getReactionNonCoded();
if (reaction.getReaction() != null) {
ConceptName codedReactioncName = reaction.getReaction().getName();
codedReaction = codedReactioncName.getName();
if (StringUtils.isNotBlank(reaction.getReactionNonCoded())) {
nonCodedReactions = reaction.getReactionNonCoded();
break;
} else {
if (reaction.getReaction() != null) {
String codedReactioncName = reaction.getReaction().getName().getName();
if (StringUtils.isNotBlank(codedReactioncName)) {
if (i == reactions.size() - 1) {
codedReaction += codedReactioncName;
} else {
codedReaction += codedReactioncName + ", ";
}
}
}
}

}
@@ -111,6 +122,8 @@ private SolrInputDocument addAllergiesPropertiesToSolrDoc(Allergy allergy, Integ
doc.addField("allergy_coded_reaction", codedReaction);
doc.addField("allergy_non_coded_reaction", nonCodedReactions);
doc.addField("allergy_comment", allergy.getComment());
doc.addField("allergy_date",
allergy.getDateChanged() != null ? allergy.getDateChanged() : allergy.getDateCreated());
}
return doc;
}
@@ -245,6 +245,7 @@ private void searchAllergiesAndGenerateSolrDoc(Integer patientId, String searchT
item.setAllergenCodedReaction((String) document.get("allergy_coded_reaction"));
item.setAllergenNonCodedReaction((String) document.get("allergy_non_coded_reaction"));
item.setAllergenComment((String) document.get("allergy_comment"));
item.setAllergenDate((Date) document.get("allergy_date"));

list.add(item);

@@ -271,17 +271,12 @@
if (typeof single_obsJSON !== 'undefined') {
if(key.keyCode == 39) {// =>>
var diffBtnIndecs = navigationIndex - peviousIndex;
var numberOfResults = jsonAfterParse.obs_groups.length + jsonAfterParse.obs_singles.length;
var numberOfResults = jsonAfterParse.obs_groups.length + jsonAfterParse.obs_singles.length + jsonAfterParse.patientAllergies.length;
if(wasGoingNext) {
if(navigationIndex != numberOfResults) {
if(navigationIndex >= 0 && diffBtnIndecs == 1) {
var obsId = single_obsJSON[navigationIndex].observation_id;
peviousIndex = navigationIndex;
navigationIndex++;
wasGoingNext = true;
focusOnNextObsAndDisplayItsDetails(obsId);
increamentNavigation(single_obsJSON);
}
}
} else {
@@ -291,12 +286,7 @@
navigationIndex = 1;
}
if(navigationIndex >= 0 && diffBtnIndecs == -1) {
var obsId = single_obsJSON[navigationIndex].observation_id;
peviousIndex = navigationIndex;
navigationIndex++;
wasGoingNext = true;
focusOnNextObsAndDisplayItsDetails(obsId);
increamentNavigation(single_obsJSON);
}
}
}
@@ -308,35 +298,57 @@
navigationIndex = navigationIndex - 2;
if(navigationIndex >= 0 && diffBtnIndecs == 1) {
var obsId = single_obsJSON[navigationIndex].observation_id;
peviousIndex = navigationIndex;
navigationIndex--;
wasGoingNext = false;
focusOnNextObsAndDisplayItsDetails(obsId);
decreamentNavigation(single_obsJSON);
}
} else {
if(navigationIndex >= 0 && diffBtnIndecs == -1) {
var obsId = single_obsJSON[navigationIndex].observation_id;
peviousIndex = navigationIndex;
navigationIndex--;
wasGoingNext = false;
focusOnNextObsAndDisplayItsDetails(obsId);
decreamentNavigation(single_obsJSON);
}
}
}
}
}
});
function increamentNavigation(single_obsJSON) {
var obs = single_obsJSON[navigationIndex];
var allergy = jsonAfterParse.patientAllergies[navigationIndex - (jsonAfterParse.obs_groups.length + jsonAfterParse.obs_singles.length)];
peviousIndex = navigationIndex;
navigationIndex++;
wasGoingNext = true;
if(obs && obs.observation_id) {
focusOnNextObsAndDisplayItsDetails(obs.observation_id);
} else if(allergy && allergy.allergenId > 0) {
focusOnNextAllergenAndDisplayItsDetails(allergy.allergenId);
}
}
function decreamentNavigation(single_obsJSON) {
var obs = single_obsJSON[navigationIndex];
var allergy = jsonAfterParse.patientAllergies[navigationIndex - (jsonAfterParse.obs_groups.length + jsonAfterParse.obs_singles.length)];
peviousIndex = navigationIndex;
navigationIndex--;
wasGoingNext = false;
if(obs && obs.observation_id) {
focusOnNextObsAndDisplayItsDetails(obs.observation_id);
} else if(allergy && allergy.allergenId > 0) {
focusOnNextAllergenAndDisplayItsDetails(allergy.allergenId);
}
}
function focusOnNextObsAndDisplayItsDetails(obsId) {
jq('#obs_single_'+obsId).focus();
load_single_detailed_obs(obsId);
}
function focusOnNextAllergenAndDisplayItsDetails(allergenId) {
jq('#allergen_' + allergenId).focus();
load_allergen(allergenId);
}
function hideSearchSuggestions() {
jq("#chart-searches-suggestions").hide();
}

0 comments on commit 73ae6f3

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