From 60a297f05f9c99537d1ec7ec0719df2b029e8efa Mon Sep 17 00:00:00 2001 From: Parth59 Date: Wed, 14 Apr 2021 14:46:35 -0700 Subject: [PATCH] Changed DWRPersonService for EMPT46 Reverted openmrs.js changes --- .../java/org/openmrs/web/dwr/DWRPersonService.java | 13 +++++++++++-- .../resources/scripts/jquery-ui/js/openmrsSearch.js | 4 ++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/omod/src/main/java/org/openmrs/web/dwr/DWRPersonService.java b/omod/src/main/java/org/openmrs/web/dwr/DWRPersonService.java index 2e490530..9e9e4682 100644 --- a/omod/src/main/java/org/openmrs/web/dwr/DWRPersonService.java +++ b/omod/src/main/java/org/openmrs/web/dwr/DWRPersonService.java @@ -32,6 +32,7 @@ import org.openmrs.api.PersonService; import org.openmrs.api.UserService; import org.openmrs.api.context.Context; +import org.openmrs.web.WebUtil; /** * DWR methods for ajaxy effects on {@link Person} objects. @@ -271,14 +272,22 @@ public Vector findBatchOfPeopleByRoles(String searchPhrase, boolean incl // if no roles were given, search for normal people PersonService ps = Context.getPersonService(); for (Person p : ps.getPeople(searchPhrase, null, includeVoided)) { - personList.add(PersonListItem.createBestMatch(p)); + PersonListItem personListItem = PersonListItem.createBestMatch(p); + personListItem.setGivenName(WebUtil.escapeHTML(personListItem.getGivenName())); + personListItem.setMiddleName(WebUtil.escapeHTML(personListItem.getMiddleName())); + personListItem.setFamilyName(WebUtil.escapeHTML(personListItem.getFamilyName())); + personList.add(personListItem); } // also search on patient identifier if the query contains a number if (searchPhrase.matches(".*\\d+.*")) { PatientService patientService = Context.getPatientService(); for (Patient p : patientService.getPatients(searchPhrase, null, null, false)) { - personList.add(PersonListItem.createBestMatch(p)); + PersonListItem personListItem = PersonListItem.createBestMatch(p); + personListItem.setGivenName(WebUtil.escapeHTML(personListItem.getGivenName())); + personListItem.setMiddleName(WebUtil.escapeHTML(personListItem.getMiddleName())); + personListItem.setFamilyName(WebUtil.escapeHTML(personListItem.getFamilyName())); + personList.add(personListItem); } } diff --git a/omod/src/main/webapp/resources/scripts/jquery-ui/js/openmrsSearch.js b/omod/src/main/webapp/resources/scripts/jquery-ui/js/openmrsSearch.js index 915baa46..12ba9b50 100644 --- a/omod/src/main/webapp/resources/scripts/jquery-ui/js/openmrsSearch.js +++ b/omod/src/main/webapp/resources/scripts/jquery-ui/js/openmrsSearch.js @@ -823,7 +823,7 @@ function OpenmrsSearch(div, showIncludeVoided, searchHandler, selectionHandler, $j('#openmrsSearchTable_paginate').show(); } - this._updatePageInfo($j('
').text(searchText).html()); + this._updatePageInfo(searchText); if(matchCount == 0){ if($j('#openmrsSearchTable_info').is(":visible")) $j('#openmrsSearchTable_info').hide(); @@ -841,7 +841,7 @@ function OpenmrsSearch(div, showIncludeVoided, searchHandler, selectionHandler, var data = rowData[c.fieldName]; if(data == null) data = " "; - return $j('
').text(data).html(); + return data; }); //include the attributes