diff --git a/api/src/main/java/org/openmrs/module/ugandaemr/api/impl/UgandaEMRServiceImpl.java b/api/src/main/java/org/openmrs/module/ugandaemr/api/impl/UgandaEMRServiceImpl.java index 8a164a33f..a7a32d16a 100644 --- a/api/src/main/java/org/openmrs/module/ugandaemr/api/impl/UgandaEMRServiceImpl.java +++ b/api/src/main/java/org/openmrs/module/ugandaemr/api/impl/UgandaEMRServiceImpl.java @@ -1299,6 +1299,7 @@ public void sendPatientToNextLocation(FormEntrySession session, String locationT patientQueue.setLocationFrom(session.getEncounter().getLocation()); patientQueue.setPatient(session.getEncounter().getPatient()); patientQueue.setLocationTo(locationTo); + patientQueue.setQueueRoom(locationTo); patientQueue.setProvider(provider); patientQueue.setEncounter(session.getEncounter()); patientQueue.setStatus(nextQueueStatus); @@ -2032,6 +2033,7 @@ public PatientQueue sendPatientBackToClinician(Encounter encounter, Location loc patientQueue.setLocationFrom(locationFrom); patientQueue.setPatient(encounter.getPatient()); patientQueue.setLocationTo(encounter.getLocation()); + patientQueue.setQueueRoom(encounter.getLocation()); patientQueue.setProvider(provider); patientQueue.setEncounter(encounter); patientQueue.setStatus(PatientQueue.Status.PENDING); diff --git a/omod/src/main/java/org/openmrs/module/ugandaemr/fragment/controller/CheckInFragmentController.java b/omod/src/main/java/org/openmrs/module/ugandaemr/fragment/controller/CheckInFragmentController.java index 041016d68..9329f12e4 100644 --- a/omod/src/main/java/org/openmrs/module/ugandaemr/fragment/controller/CheckInFragmentController.java +++ b/omod/src/main/java/org/openmrs/module/ugandaemr/fragment/controller/CheckInFragmentController.java @@ -77,6 +77,7 @@ public SimpleObject post(@SpringBean("patientService") PatientService patientSer patientQueue.setLocationFrom(currentLocation); patientQueue.setPatient(patient); patientQueue.setLocationTo(location); + patientQueue.setQueueRoom(location); patientQueue.setProvider(provider); patientQueue.setStatus(PatientQueue.Status.PENDING); patientQueue.setCreator(uiSessionContext.getCurrentUser()); diff --git a/omod/src/main/java/org/openmrs/module/ugandaemr/fragment/controller/ClinicianQueueListFragmentController.java b/omod/src/main/java/org/openmrs/module/ugandaemr/fragment/controller/ClinicianQueueListFragmentController.java index ca701573c..741c72346 100644 --- a/omod/src/main/java/org/openmrs/module/ugandaemr/fragment/controller/ClinicianQueueListFragmentController.java +++ b/omod/src/main/java/org/openmrs/module/ugandaemr/fragment/controller/ClinicianQueueListFragmentController.java @@ -17,6 +17,7 @@ import org.springframework.web.bind.annotation.RequestParam; import java.io.IOException; +import java.text.ParseException; import java.util.ArrayList; import java.util.Arrays; import java.util.Date; @@ -31,7 +32,6 @@ public ClinicianQueueListFragmentController() { } public void controller(@SpringBean FragmentModel pageModel, @SpringBean("locationService") LocationService locationService,UiSessionContext uiSessionContext) { - List list = new ArrayList(); String locationUUIDS = Context.getAdministrationService() .getGlobalProperty("ugandaemr.clinicianLocationUUIDS"); @@ -46,25 +46,16 @@ public void controller(@SpringBean FragmentModel pageModel, @SpringBean("locatio pageModel.put("enablePatientQueueSelection", Context.getAdministrationService().getGlobalProperty("ugandaemr.enablePatientQueueSelection")); } - public SimpleObject getPatientQueueList(@RequestParam(value = "searchfilter", required = false) String searchfilter, UiSessionContext uiSessionContext) { - UgandaEMRService ugandaEMRService = Context.getService(UgandaEMRService.class); + public SimpleObject getEncounterId(@RequestParam(value = "patientQueueUuid", required = false) String patientQueueUuid) throws ParseException, IOException { PatientQueueingService patientQueueingService = Context.getService(PatientQueueingService.class); + PatientQueue patientQueue = patientQueueingService.getPatientQueueByUuid(patientQueueUuid); ObjectMapper objectMapper = new ObjectMapper(); - - SimpleObject simpleObject = new SimpleObject(); - - List patientQueueList = new ArrayList(); - if (!searchfilter.equals("")) { - patientQueueList = patientQueueingService.getPatientQueueListBySearchParams(searchfilter, OpenmrsUtil.firstSecondOfDay(new Date()), OpenmrsUtil.getLastMomentOfDay(new Date()), uiSessionContext.getSessionLocation(), null, null); + String encounterId = ""; + if (patientQueue != null && patientQueue.getEncounter() != null) { + encounterId = objectMapper.writeValueAsString(patientQueue.getEncounter().getEncounterId()); } else { - patientQueueList = patientQueueingService.getPatientQueueListBySearchParams(searchfilter, OpenmrsUtil.firstSecondOfDay(new Date()), OpenmrsUtil.getLastMomentOfDay(new Date()), uiSessionContext.getSessionLocation(), null, null); - } - List patientQueueMappers = ugandaEMRService.mapPatientQueueToMapper(patientQueueList); - try { - simpleObject.put("patientClinicianQueueList", objectMapper.writeValueAsString(patientQueueMappers)); - } catch (IOException e) { - log.error(e); + encounterId = objectMapper.writeValueAsString(""); } - return simpleObject; + return SimpleObject.create("encounterId", encounterId); } } diff --git a/omod/src/main/java/org/openmrs/module/ugandaemr/fragment/controller/RadiologyQueueListFragmentController.java b/omod/src/main/java/org/openmrs/module/ugandaemr/fragment/controller/RadiologyQueueListFragmentController.java index 141560b2c..77b293c9d 100644 --- a/omod/src/main/java/org/openmrs/module/ugandaemr/fragment/controller/RadiologyQueueListFragmentController.java +++ b/omod/src/main/java/org/openmrs/module/ugandaemr/fragment/controller/RadiologyQueueListFragmentController.java @@ -346,6 +346,7 @@ private PatientQueue sendPatientBackToClinician(Encounter encounter, Location lo patientQueue.setLocationFrom(locationFrom); patientQueue.setPatient(encounter.getPatient()); patientQueue.setLocationTo(encounter.getLocation()); + patientQueue.setQueueRoom(encounter.getLocation()); patientQueue.setProvider(provider); patientQueue.setEncounter(encounter); patientQueue.setStatus(PatientQueue.Status.PENDING); diff --git a/omod/src/main/java/org/openmrs/module/ugandaemr/fragment/controller/ReferToNextLocationFragmentController.java b/omod/src/main/java/org/openmrs/module/ugandaemr/fragment/controller/ReferToNextLocationFragmentController.java index 5663ba249..1fd510062 100644 --- a/omod/src/main/java/org/openmrs/module/ugandaemr/fragment/controller/ReferToNextLocationFragmentController.java +++ b/omod/src/main/java/org/openmrs/module/ugandaemr/fragment/controller/ReferToNextLocationFragmentController.java @@ -73,6 +73,7 @@ public SimpleObject post(@SpringBean("patientService") PatientService patientSer patientQueue.setLocationFrom(currentLocation); patientQueue.setPatient(patient); patientQueue.setLocationTo(location); + patientQueue.setQueueRoom(location); patientQueue.setProvider(provider); patientQueue.setStatus(PatientQueue.Status.PENDING); patientQueue.setCreator(uiSessionContext.getCurrentUser()); diff --git a/omod/src/main/java/org/openmrs/module/ugandaemr/fragment/controller/TriageQueueListFragmentController.java b/omod/src/main/java/org/openmrs/module/ugandaemr/fragment/controller/TriageQueueListFragmentController.java index 29b2c1c3d..8c5c3635d 100644 --- a/omod/src/main/java/org/openmrs/module/ugandaemr/fragment/controller/TriageQueueListFragmentController.java +++ b/omod/src/main/java/org/openmrs/module/ugandaemr/fragment/controller/TriageQueueListFragmentController.java @@ -35,8 +35,6 @@ public TriageQueueListFragmentController() { } public void controller(FragmentConfiguration config, @SpringBean FragmentModel pageModel, UiSessionContext uiSessionContext) { - - pageModel.put("specimenSource", Context.getOrderService().getTestSpecimenSources()); SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); String dateStr = sdf.format(new Date()); pageModel.addAttribute("currentDate", dateStr); @@ -46,39 +44,16 @@ public void controller(FragmentConfiguration config, @SpringBean FragmentModel p pageModel.put("enablePatientQueueSelection", Context.getAdministrationService().getGlobalProperty("ugandaemr.enablePatientQueueSelection")); } - /** - * Get Patients in Lab Queue - * - * @param searchFilter - * @param uiSessionContext - * @return - * @throws IOException - * @throws ParseException - */ - public SimpleObject getPatientQueueList(@RequestParam(value = "triageSearchFilter", required = false) String searchFilter, UiSessionContext uiSessionContext) throws IOException, ParseException { - UgandaEMRService ugandaEMRService = Context.getService(UgandaEMRService.class); + public SimpleObject getEncounterId(@RequestParam(value = "patientQueueUuid", required = false) String patientQueueUuid) throws ParseException, IOException { PatientQueueingService patientQueueingService = Context.getService(PatientQueueingService.class); + PatientQueue patientQueue = patientQueueingService.getPatientQueueByUuid(patientQueueUuid); ObjectMapper objectMapper = new ObjectMapper(); - SimpleObject simpleObject = new SimpleObject(); - List patientQueueList = new ArrayList(); - if (!searchFilter.equals("")) { - patientQueueList = patientQueueingService.getPatientQueueListBySearchParams(searchFilter, OpenmrsUtil.firstSecondOfDay(new Date()), OpenmrsUtil.getLastMomentOfDay(new Date()), uiSessionContext.getSessionLocation(), null, null); + String encounterId = ""; + if (patientQueue != null && patientQueue.getEncounter() != null) { + encounterId = objectMapper.writeValueAsString(patientQueue.getEncounter().getEncounterId()); } else { - patientQueueList = patientQueueingService.getPatientQueueListBySearchParams(null, OpenmrsUtil.firstSecondOfDay(new Date()), OpenmrsUtil.getLastMomentOfDay(new Date()), uiSessionContext.getSessionLocation(), null, null); - } - simpleObject.put("patientTriageQueueList", objectMapper.writeValueAsString(ugandaEMRService.mapPatientQueueToMapper(patientQueueList))); - return simpleObject; - } - - public SimpleObject getActiveVisit(@RequestParam(value = "patientId", required = false) Patient patient) throws ParseException, IOException { - VisitService visitService = Context.getVisitService(); - List visits = visitService.getActiveVisitsByPatient(patient); - ObjectMapper objectMapper = new ObjectMapper(); - String visitId = null; - - if (visits.size() > 0) { - visitId = visits.get(0).getUuid(); + encounterId = objectMapper.writeValueAsString(""); } - return SimpleObject.create("visitId", objectMapper.writeValueAsString(visitId)); + return SimpleObject.create("encounterId", encounterId); } } diff --git a/omod/src/main/webapp/fragments/clinicianQueueList.gsp b/omod/src/main/webapp/fragments/clinicianQueueList.gsp index d3fc3f0b1..7d305b06c 100644 --- a/omod/src/main/webapp/fragments/clinicianQueueList.gsp +++ b/omod/src/main/webapp/fragments/clinicianQueueList.gsp @@ -28,7 +28,7 @@ setInterval(function () { console.log("Checking IF Reloading works"); getPatientQueue(); - }, 1*60000); + }, 1 * 60000); jq(document).ready(function () { jq(document).on('sessionLocationChanged', function () { @@ -70,24 +70,46 @@ jq('#pick_patient_queue_dialog').on('show.bs.modal', function (event) { var button = jq(event.relatedTarget) - jq("#patientQueueId").val(button.data('patientqueueid')); - jq("#goToURL").val(button.data('url')); + + var enounterId = getEncounterId(button.data('patientqueueid')); + if (enounterId !== "" && enounterId !== null) { + jq("#patientQueueId").val(button.data('patientqueueid')); + var url = button.data('url'); + url = url.replace("encounterIdToReplace", enounterId) + jq("#goToURL").val(url); + } else { + var urlToPatientDashBoard = '${ui.pageLink("coreapps","clinicianfacing/patient",[patientId: "patientIdElement"])}'.replace("patientIdElement", button.data('patientuuid')); + jq("#goToURL").val(urlToPatientDashBoard); + } }) }); } - function getPatientQueue() { - jq("#clinician-queue-list-table").html(""); - jq.get('${ ui.actionLink("getPatientQueueList") }', { - searchfilter: jq("#patient-search").val().trim().toLowerCase() - }, function (response) { - if (response) { - var responseData = response; - displayClinicianData(responseData); - } else if (!response) { - jq("#clinician-queue-list-table").append(${ ui.message("coreapps.none ") }); + function queryRestData(url, method, data) { + var responseData = null; + jq.ajax({ + type: method, + url: '/' + OPENMRS_CONTEXT_PATH + "/ws/rest/v1/" + url, + dataType: "json", + contentType: "application/json", + accept: "application/json", + async: false, + data: data, + success: function (response) { + responseData = response; + }, + error: function (response) { + responseData = response } }); + return responseData; + } + + function getPatientQueue() { + var url = "patientqueue?location=${currentLocation.uuid}&v=custom:(uuid,creator:(uuid,person:(uuid,display)),dateCreated,dateChanged,voided,patient:(uuid,names:(display),display,gender,birthdate,identifiers:(voided,preferred,uuid,display,location:(uuid,display))),provider:(uuid,display,person:(uuid,display)),locationFrom:(uuid,display,tags:(uuid,display)),locationTo:(uuid,display,tags:(uuid,display)),queueRoom:(uuid,display,tags:(uuid,display)),encounter:(uuid,visit:(uuid)),status,priority,priorityComment,visitNumber,comment,datePicked,dateCompleted)" + var responseData = queryRestData(url, "GET", {}) + + displayClinicianData(responseData); } function setLocationsToSelect() { @@ -104,17 +126,43 @@ jq("#location_id").append(content); } - function identifierToDisplay(identifiers){ - var identifierToDisplay=""; + function identifierToDisplay(identifiers) { + var identifierToDisplay = ""; jq.each(identifiers, function (index, element) { - if(element.identifierLocationUuid==="${currentLocation.uuid}"){ - identifierToDisplay+=element.identifierTypeName+" : "+element.identifier+"
" + if (element.voided === false && element.preferred === true) { + identifierToDisplay += element.display.replace("=", ":") + "
" } }); return identifierToDisplay } + function navigateToVisit(url, patientuuid, patientqueueuuid) { + var enounterId = getEncounterId(patientqueueuuid); + if (enounterId !== "" && enounterId !== null) { + url = url.replace("encounterIdToReplace", enounterId) + window.location.href = url; + } else { + url = '${ui.pageLink("coreapps","clinicianfacing/patient",[patientId: "patientIdElement"])}'.replace("patientIdElement", button.data('patientuuid')); + window.location.href = url; + } + } + + function getEncounterId(patientQueueUuid) { + var encounterId = null; + jq.ajax({ + type: "GET", + url: "${ui.actionLink("getEncounterId")}" + "&patientQueueUuid=" + patientQueueUuid, + async: false, + success: function (response) { + encounterId = response.encounterId; + }, + error: function (response) { + } + }); + return encounterId + } + function displayClinicianData(response) { jq("#clinician-queue-list-table").html("No Patient In Pending List"); jq("#clinician-completed-list-table").html("No Patient In Completed List"); @@ -127,17 +175,17 @@ completedQueue = 0; servingQueue = 0; fromLabQueue = 0; - var headerPending = ""; - var headerServing = "
VISIT IDPATIENT NO.NAMESGENDERAGEVISIT TYPEENTRY POINTSTATUSWAITING TIMEACTION
"; - var headerCompleted = "
VISIT IDPATIENT NO.NAMESGENDERAGEVISIT TYPEATTENDING PROVIDERSTATUSSERVING TIMEACTION
"; - var headerFromLab = "
VISIT IDPATIENT NO.NAMESGENDERAGEENTRY POINTSTATUSTIMEACTION
"; + var headerPending = "
VISIT IDPATIENT NO.NAMESGENDERAGEENTRY POINTSTATUSWAITING TIMEACTION
"; + var headerServing = "
TOKENPATIENT IDNAMESGENDERDOBVISIT TYPEENTRY POINTSTATUSWAITING TIMEACTION
"; + var headerCompleted = "
TOKENPATIENT IDNAMESGENDERDOBVISIT TYPEATTENDING PROVIDERSTATUSSERVING TIMEACTION
"; + var headerFromLab = "
TOKENPATIENT IDNAMESGENDERDOBENTRY POINTSTATUSTIMEACTION
"; var footer = "
TOKENPATIENT IDNAMESGENDERDOBENTRY POINTSTATUSWAITING TIMEACTION
"; var dataToDisplay = []; - if (response.patientClinicianQueueList.length > 0) { - dataToDisplay = JSON.parse(response.patientClinicianQueueList).sort(function (a, b) { - return a.patientQueueId - b.patientQueueId; + if (response.results.length > 0) { + dataToDisplay = response.results.sort(function (a, b) { + return a.dateCreated - b.dateCreated; }); } @@ -150,74 +198,77 @@ } jq.each(dataToDisplay, function (index, element) { - var patientQueueListElement = element; + var patientQueue = element; var dataRowTable = ""; - var urlToPatientDashBoard = '${ui.pageLink("coreapps","clinicianfacing/patient",[patientId: "patientIdElement"])}'.replace("patientIdElement", element.patientId); - var encounterUrl = "/" + OPENMRS_CONTEXT_PATH + "/htmlformentryui/htmlform/editHtmlFormWithStandardUi.page?patientId=" + element.patientId + "&encounterId=" + element.encounterId + "&returnUrl=" + "/" + OPENMRS_CONTEXT_PATH + "/patientqueueing/providerDashboard.page"; - - var waitingTime = getWaitingTime(patientQueueListElement.dateCreated, patientQueueListElement.dateChanged); + var urlToPatientDashBoard = '${ui.pageLink("coreapps","clinicianfacing/patient",[patientId: "patientIdElement"])}'.replace("patientIdElement", element.patient.uuid); + var encounterUrl = ""; + if (element.encounter !== null) { + encounterUrl = "/" + OPENMRS_CONTEXT_PATH + "/htmlformentryui/htmlform/editHtmlFormWithStandardUi.page?patientId=" + element.patient.uuid + "&encounterId=encounterIdToReplace&returnUrl=" + "/" + OPENMRS_CONTEXT_PATH + "/patientqueueing/providerDashboard.page"; + } + var waitingTime = getWaitingTime(patientQueue.dateCreated, patientQueue.dateChanged); dataRowTable += ""; - if (patientQueueListElement.visitNumber !== null) { - dataRowTable += "" + patientQueueListElement.visitNumber.substring(15) + ""; + if (patientQueue.visitNumber !== null) { + dataRowTable += "" + patientQueue.visitNumber.substring(15) + ""; } else { dataRowTable += ""; } - dataRowTable += "" + identifierToDisplay(patientQueueListElement.patientIdentifier) + ""; - dataRowTable += "" + patientQueueListElement.patientNames + ""; - dataRowTable += "" + patientQueueListElement.gender + ""; - dataRowTable += "" + patientQueueListElement.age + ""; - - if (element.status === "PENDING" && element.locationFrom !== "Main Laboratory") { - if (patientQueueListElement.priorityComment != null) { - dataRowTable += "" + patientQueueListElement.priorityComment + ""; + dataRowTable += "" + identifierToDisplay(patientQueue.patient.identifiers) + ""; + dataRowTable += "" + patientQueue.patient.names[0].display + ""; + dataRowTable += "" + patientQueue.patient.gender + ""; + dataRowTable += "" + jq.datepicker.formatDate('dd.M.yy', new Date(patientQueue.patient.birthdate)) + ""; + + + if (element.status === "PENDING" && element.locationFrom.display !== "Main Laboratory") { + if (patientQueue.priorityComment != null) { + dataRowTable += "" + patientQueue.priorityComment + ""; } else { dataRowTable += ""; } } - dataRowTable += "" + patientQueueListElement.locationFrom.substring(0, 3) + ""; + dataRowTable += "" + patientQueue.locationFrom.display.substring(0, 3) + ""; if (element.status === "PICKED") { - if (element.providerNames != null) { - dataRowTable += "" + element.providerNames + ""; + if (element.provider != null) { + dataRowTable += "" + element.provider.person.display + ""; } else { dataRowTable += ""; } } - dataRowTable += "" + patientQueueListElement.status + ""; + dataRowTable += "" + patientQueue.status + ""; dataRowTable += "" + waitingTime + ""; dataRowTable += ""; - if ("${enablePatientQueueSelection}".trim() === "true" && patientQueueListElement.status === "PENDING") { - dataRowTable += ""; + if ("${enablePatientQueueSelection}".trim() === "true" && patientQueue.status === "PENDING") { + dataRowTable += ""; } else { dataRowTable += ""; } - if (element.status === "PENDING" && element.locationFrom !== "Main Laboratory") { - dataRowTable += "".replace("%s", element.patientId); - } else if ((element.status === "PENDING" || element.status === "from lab") && element.locationFrom === "Main Laboratory" && "${enablePatientQueueSelection}".trim() === "true") { - dataRowTable += ""; - } else if ((element.status === "PENDING" || element.status === "from lab") && element.locationFrom === "Main Laboratory" && "${enablePatientQueueSelection}".trim() !== "true") { - dataRowTable += ""; + if (element.status === "PENDING" && element.locationFrom.display !== "Main Laboratory") { + dataRowTable += "".replace("%s", element.patient.uuid); + } else if ((element.status === "PENDING" || element.status === "from lab") && element.locationFrom.display === "Main Laboratory" && "${enablePatientQueueSelection}".trim() === "true") { + dataRowTable += ""; + } else if ((element.status === "PENDING" || element.status === "from lab") && element.locationFrom.display === "Main Laboratory" && "${enablePatientQueueSelection}".trim() !== "true") { + dataRowTable += ""; } dataRowTable += ""; - if ((element.status === "PENDING" || element.status === "from lab") && element.locationFrom === "Main Laboratory") { + if ((element.status === "PENDING" || element.status === "from lab") && element.locationFrom.display === "Main Laboratory") { fromLabQueue += 1; fromLabDataRows += dataRowTable; - } else if (element.status === "PENDING" && element.locationFrom !== "Main Laboratory") { + } else if (element.status === "PENDING" && element.locationFrom.display !== "Main Laboratory") { stillInQueue += 1; stillInQueueDataRows += dataRowTable; } else if (element.status === "PICKED") { servingQueue += 1; servingDataRows += dataRowTable; - } else if (element.status === "COMPLETED" && element.locationFrom !== "Main Laboratory") { + } else if (element.status === "COMPLETED" && element.locationFrom.display !== "Main Laboratory") { completedQueue += 1; completedDataRows += dataRowTable; } diff --git a/omod/src/main/webapp/fragments/pharmacy/newDispensingForm.gsp b/omod/src/main/webapp/fragments/pharmacy/newDispensingForm.gsp index 5bef2a5f8..226ef8f22 100644 --- a/omod/src/main/webapp/fragments/pharmacy/newDispensingForm.gsp +++ b/omod/src/main/webapp/fragments/pharmacy/newDispensingForm.gsp @@ -461,13 +461,6 @@ form input { - - - - @@ -481,7 +474,7 @@ form input { - + @@ -510,8 +503,17 @@ form input {
+ + + + +