Skip to content

Commit

Permalink
fix: speed up slow flow board using static methods (openemr#7330)
Browse files Browse the repository at this point in the history
* fix: speed up slow board using patient tracker services as globals

* use static calls

* fix using  when not in object context
  • Loading branch information
stephenwaite authored Apr 11, 2024
1 parent 10bcaed commit b681b42
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 27 deletions.
27 changes: 9 additions & 18 deletions library/patient_tracker.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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);
}


Expand All @@ -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
Expand All @@ -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);
}
4 changes: 2 additions & 2 deletions src/Services/AppointmentService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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));
Expand Down
14 changes: 7 additions & 7 deletions src/Services/PatientTrackerService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 " .
Expand Down Expand Up @@ -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 " .
Expand All @@ -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++) {
Expand All @@ -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 " .
Expand All @@ -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 " .
Expand All @@ -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);
Expand Down

0 comments on commit b681b42

Please sign in to comment.