Skip to content

Commit

Permalink
Povided an extra informative message when indexing is in progress at …
Browse files Browse the repository at this point in the history
…first chart load
  • Loading branch information
k-joseph committed Jul 9, 2015
1 parent f1a2012 commit 1d03968
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 20 deletions.
Expand Up @@ -336,7 +336,7 @@ public List<String> getAllPossibleSearchSuggestions(Integer patientId) {
ObsService obsService = Context.getObsService();
List<String> suggestions = new ArrayList<String>();

List<Obs> allPatientObs = obsService.getObservationsByPerson(new Patient(patientId));
List<Obs> allPatientObs = obsService.getObservationsByPerson(Context.getPatientService().getPatient(patientId));
Allergies allAllergies = Context.getService(PatientService.class).getAllergies(
Context.getPatientService().getPatient(patientId));
List<Appointment> appointments = Context.getService(AppointmentService.class).getAllAppointments();
Expand Down
57 changes: 38 additions & 19 deletions omod/src/main/webapp/resources/scripts/views_factory.js
Expand Up @@ -1203,9 +1203,23 @@ function refresh_data(json) {
var numberOfResults = json.obs_groups.length + json.obs_singles.length
+ json.patientAllergies.length
+ json.patientAppointments.length;
document.getElementById('found-results-summary').innerHTML = "<b>"
+ numberOfResults + "</b> Results (<b>" + json.retrievalTime
+ "</b> seconds)";
var noResultsMessage = "<b>" + numberOfResults + "</b> Results (<b>"
+ json.retrievalTime + "</b> seconds)";
var noResultsMessageNote = "";

if (numberOfResults === 0 && json.searchSuggestions.length > 0
&& json.search_phrase === "") {
noResultsMessageNote = "<br /><br /><br /><br /><p style='color:black;'><b>NOTE:</b> If this is the first time you are accessing this patient's chart, <b>Indexing patient data could still be in progress. </b>"
+ "So refresh the page a few moments from now. Otherwise the <b>patient has no data</b> (observations, allergies and appointments) in the Database</p>";
}

if (noResultsMessageNote !== "") {
document.getElementById('found-results-summary').innerHTML = noResultsMessage
+ noResultsMessageNote;
} else {
document.getElementById('found-results-summary').innerHTML = noResultsMessage;
}

addAllObsGroups(json);
addAllResultsFromJSONFromTheServer(json);
displayFailedPrivileges(json);
Expand Down Expand Up @@ -1310,14 +1324,16 @@ function displayNonFacetCategories(cat, catName) {
}

/*
* In-case the has doesn't have privileges to view some results, they are not
* returned and a message is instead displayed
* In-case the user has doesn't have privileges to view some results, they are
* not returned and a message is instead displayed
*/
function displayFailedPrivileges(jsonAfterParse) {
document.getElementById('failed_privileges').innerHTML == "";
for ( var i = 0; i < jsonAfterParse.failedPrivileges.length; i++) {
document.getElementById('failed_privileges').innerHTML += jsonAfterParse.failedPrivileges[i].message
+ "<br />";
if (jsonAfterParse.failedPrivileges) {
document.getElementById('failed_privileges').innerHTML == "";
for ( var i = 0; i < jsonAfterParse.failedPrivileges.length; i++) {
document.getElementById('failed_privileges').innerHTML += jsonAfterParse.failedPrivileges[i].message
+ "<br />";
}
}
}

Expand Down Expand Up @@ -1558,16 +1574,19 @@ function reInitializeGlobalVars() {
}

function autoClickFirstResultToShowItsDetails(json) {
if (json.obs_singles.length && json.obs_singles.length > 0) {
$('#first_obs_single').trigger('click');
} else if ((!json.obs_singles.length || json.obs_singles.length === 0)
&& json.patientAllergies.length && json.patientAllergies.length > 0) {
$('#first_alergen').trigger('click');
} else if ((!json.obs_singles.length || json.obs_singles.length === 0)
&& (!json.patientAllergies.length || json.patientAllergies.length === 0)
&& json.patientAppointments.length
&& json.patientAppointments.length > 0) {
$('#first_appointment').trigger('click');
if (json.obs_singles) {
if (json.obs_singles.length && json.obs_singles.length > 0) {
$('#first_obs_single').trigger('click');
} else if ((!json.obs_singles.length || json.obs_singles.length === 0)
&& json.patientAllergies.length
&& json.patientAllergies.length > 0) {
$('#first_alergen').trigger('click');
} else if ((!json.obs_singles.length || json.obs_singles.length === 0)
&& (!json.patientAllergies.length || json.patientAllergies.length === 0)
&& json.patientAppointments.length
&& json.patientAppointments.length > 0) {
$('#first_appointment').trigger('click');
}
}
}

Expand Down

0 comments on commit 1d03968

Please sign in to comment.