From b681b42fddc20494441115d71177f19cb72f94a0 Mon Sep 17 00:00:00 2001 From: stephen waite Date: Thu, 11 Apr 2024 09:49:00 -0400 Subject: [PATCH] fix: speed up slow flow board using static methods (#7330) * fix: speed up slow board using patient tracker services as globals * use static calls * fix using when not in object context --- library/patient_tracker.inc.php | 27 +++++++++----------------- src/Services/AppointmentService.php | 4 ++-- src/Services/PatientTrackerService.php | 14 ++++++------- 3 files changed, 18 insertions(+), 27 deletions(-) diff --git a/library/patient_tracker.inc.php b/library/patient_tracker.inc.php index ca33fe829a5..4796677f26d 100644 --- a/library/patient_tracker.inc.php +++ b/library/patient_tracker.inc.php @@ -34,8 +34,7 @@ function get_Tracker_Time_Interval($tracker_from_time, $tracker_to_time, $allow_sec = false) { - $patientTrackerService = new PatientTrackerService(); - return $patientTrackerService->get_Tracker_Time_Interval($tracker_from_time, $tracker_to_time, $allow_sec); + return PatientTrackerService::get_Tracker_Time_Interval($tracker_from_time, $tracker_to_time, $allow_sec); } function fetch_Patient_Tracker_Events($from_date, $to_date, $provider_id = null, $facility_id = null, $form_apptstatus = null, $form_apptcat = null, $form_patient_name = null, $form_patient_id = null) @@ -56,15 +55,13 @@ function fetch_Patient_Tracker_Events($from_date, $to_date, $provider_id = null, #check to see if a status code exist as a check in function is_checkin($option) { - $appointmentStatus = new AppointmentService(); - return $appointmentStatus->isCheckInStatus($option); + return AppointmentService::isCheckInStatus($option); } #check to see if a status code exist as a check out function is_checkout($option) { - $service = new AppointmentService(); - return $service->isCheckOutStatus($option); + return AppointmentService::isCheckOutStatus($option); } @@ -73,8 +70,7 @@ function is_checkout($option) # 2. If the tracker item does exist, but the encounter has not been set function is_tracker_encounter_exist($apptdate, $appttime, $pid, $eid) { - $patientTrackerService = new PatientTrackerService(); - return $patientTrackerService->is_tracker_encounter_exist($apptdate, $appttime, $pid, $eid); + return PatientTrackerService::is_tracker_encounter_exist($apptdate, $appttime, $pid, $eid); } # this function will return the tracker id that is managed @@ -89,35 +85,30 @@ function manage_tracker_status($apptdate, $appttime, $eid, $pid, $user, $status #list_options. Currently the color and alert time are the only items stored function collectApptStatusSettings($option) { - $patientTrackerService = new PatientTrackerService(); - return $patientTrackerService->collectApptStatusSettings($option); + return PatientTrackerService::collectApptStatusSettings($option); } # This is used to collect the tracker elements for the Patient Flow Board Report # returns the elements in an array function collect_Tracker_Elements($trackerid) { - $patientTrackerService = new PatientTrackerService(); - return $patientTrackerService->collect_Tracker_Elements($trackerid); + return PatientTrackerService::collect_Tracker_Elements($trackerid); } #used to determine check in time function collect_checkin($trackerid) { - $patientTrackerService = new PatientTrackerService(); - return $patientTrackerService->collect_checkin($trackerid); + return PatientTrackerService::collect_checkin($trackerid); } #used to determine check out time function collect_checkout($trackerid) { - $patientTrackerService = new PatientTrackerService(); - return $patientTrackerService->collect_checkout($trackerid); + return PatientTrackerService::collect_checkout($trackerid); } /* get information the statuses of the appointments*/ function getApptStatus($appointments) { - $patientTrackerService = new PatientTrackerService(); - return $patientTrackerService->getApptStatus($appointments); + return PatientTrackerService::getApptStatus($appointments); } diff --git a/src/Services/AppointmentService.php b/src/Services/AppointmentService.php index af1d6f100b0..ba73d14374a 100644 --- a/src/Services/AppointmentService.php +++ b/src/Services/AppointmentService.php @@ -480,7 +480,7 @@ public function getCalendarCategories() * @param $option * @return bool */ - public function isCheckInStatus($option) + public static function isCheckInStatus($option) { $row = sqlQuery("SELECT toggle_setting_1 FROM list_options WHERE " . "list_id = 'apptstat' AND option_id = ? AND activity = 1", array($option)); @@ -496,7 +496,7 @@ public function isCheckInStatus($option) * @param $option * @return bool */ - public function isCheckOutStatus($option) + public static function isCheckOutStatus($option) { $row = sqlQuery("SELECT toggle_setting_2 FROM list_options WHERE " . "list_id = 'apptstat' AND option_id = ? AND activity = 1", array($option)); diff --git a/src/Services/PatientTrackerService.php b/src/Services/PatientTrackerService.php index e421b9e2dc6..2aa868c71ae 100644 --- a/src/Services/PatientTrackerService.php +++ b/src/Services/PatientTrackerService.php @@ -35,7 +35,7 @@ public function __construct() * @param bool $allow_sec * @return string */ - public function get_Tracker_Time_Interval($tracker_from_time, $tracker_to_time, $allow_sec = false) + public static function get_Tracker_Time_Interval($tracker_from_time, $tracker_to_time, $allow_sec = false) { $tracker_time_calc = strtotime($tracker_to_time) - strtotime($tracker_from_time); @@ -142,7 +142,7 @@ public function get_Tracker_Time_Interval($tracker_from_time, $tracker_to_time, * @param $eid * @return int */ - public function is_tracker_encounter_exist($apptdate, $appttime, $pid, $eid) + public static function is_tracker_encounter_exist($apptdate, $appttime, $pid, $eid) { #Check to see if there is an encounter in the patient_tracker table. $enc_yn = sqlQuery("SELECT encounter from patient_tracker WHERE `apptdate` = ? AND encounter > 0 " . @@ -282,7 +282,7 @@ public function manage_tracker_status($apptdate, $appttime, $eid, $pid, $user, $ * @param $option * @return array */ - public function collectApptStatusSettings($option) + public static function collectApptStatusSettings($option) { $color_settings = array(); $row = sqlQuery("SELECT notes FROM list_options WHERE " . @@ -301,7 +301,7 @@ public function collectApptStatusSettings($option) * @param $trackerid * @return mixed */ - public function collect_Tracker_Elements($trackerid) + public static function collect_Tracker_Elements($trackerid) { $res = sqlStatement("SELECT * FROM patient_tracker_element WHERE pt_tracker_id = ? ORDER BY LENGTH(seq), seq ", array($trackerid)); for ($iter = 0; $row = sqlFetchArray($res); $iter++) { @@ -316,7 +316,7 @@ public function collect_Tracker_Elements($trackerid) * @param $trackerid * @return bool */ - public function collect_checkin($trackerid) + public static function collect_checkin($trackerid) { $tracker = sqlQuery( "SELECT patient_tracker_element.start_datetime " . @@ -340,7 +340,7 @@ public function collect_checkin($trackerid) * @param $trackerid * @return bool */ - public function collect_checkout($trackerid) + public static function collect_checkout($trackerid) { $tracker = sqlQuery( "SELECT patient_tracker_element.start_datetime " . @@ -359,7 +359,7 @@ public function collect_checkout($trackerid) } } - public function getApptStatus($appointments) + public static function getApptStatus($appointments) { $astat = array(); $astat['count_all'] = count($appointments);