Add prepayments to front payment display (#6111)
[openemr.git] / library / patient_tracker.inc.php
blobca33fe829a5a10e0a405a8e5f90451b5d0426f8f
1 <?php
3 /**
4 * library/patient_tracker.inc.php Functions used in the Patient Flow Board.
6 * Functions for use in the Patient Flow Board and Patient Flow Board Reports.
9 * Copyright (C) 2015 Terry Hill <terry@lillysystems.com>
11 * LICENSE: This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 3
14 * of the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
22 * @package OpenEMR
23 * @author Terry Hill <terry@lillysystems.com>
24 * @link https://www.open-emr.org
26 * Please help the overall project by sending changes you make to the author and to the OpenEMR community.
30 require_once(dirname(__FILE__) . '/appointments.inc.php');
32 use OpenEMR\Services\AppointmentService;
33 use OpenEMR\Services\PatientTrackerService;
35 function get_Tracker_Time_Interval($tracker_from_time, $tracker_to_time, $allow_sec = false)
37 $patientTrackerService = new PatientTrackerService();
38 return $patientTrackerService->get_Tracker_Time_Interval($tracker_from_time, $tracker_to_time, $allow_sec);
41 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)
43 // TODO: refactor this method to use the PatientTrackerService There is a whole heirarchy of inner function calls
44 // inside the fetchAppointments method scattered across several different files which will require creating lots more classes
45 // (ie a bigger undertaking). Leaving this method alone until we can tackle this work at a later date in time.
46 # used to determine which providers to display in the Patient Tracker
47 if ($provider_id == 'ALL') {
48 //set null to $provider id if it's 'all'
49 $provider_id = null;
52 $events = fetchAppointments($from_date, $to_date, $form_patient_id, $provider_id, $facility_id, $form_apptstatus, null, null, $form_apptcat, true, 0, null, $form_patient_name);
53 return $events;
56 #check to see if a status code exist as a check in
57 function is_checkin($option)
59 $appointmentStatus = new AppointmentService();
60 return $appointmentStatus->isCheckInStatus($option);
63 #check to see if a status code exist as a check out
64 function is_checkout($option)
66 $service = new AppointmentService();
67 return $service->isCheckOutStatus($option);
71 # This function will return false for both below scenarios:
72 # 1. The tracker item does not exist
73 # 2. If the tracker item does exist, but the encounter has not been set
74 function is_tracker_encounter_exist($apptdate, $appttime, $pid, $eid)
76 $patientTrackerService = new PatientTrackerService();
77 return $patientTrackerService->is_tracker_encounter_exist($apptdate, $appttime, $pid, $eid);
80 # this function will return the tracker id that is managed
81 # or will return false if no tracker id was managed (in the case of a recurrent appointment)
82 function manage_tracker_status($apptdate, $appttime, $eid, $pid, $user, $status = '', $room = '', $enc_id = '')
84 $patientTrackerService = new PatientTrackerService();
85 return $patientTrackerService->manage_tracker_status($apptdate, $appttime, $eid, $pid, $user, $status, $room, $enc_id);
88 # This is used to break apart the information contained in the notes field of
89 #list_options. Currently the color and alert time are the only items stored
90 function collectApptStatusSettings($option)
92 $patientTrackerService = new PatientTrackerService();
93 return $patientTrackerService->collectApptStatusSettings($option);
96 # This is used to collect the tracker elements for the Patient Flow Board Report
97 # returns the elements in an array
98 function collect_Tracker_Elements($trackerid)
100 $patientTrackerService = new PatientTrackerService();
101 return $patientTrackerService->collect_Tracker_Elements($trackerid);
104 #used to determine check in time
105 function collect_checkin($trackerid)
107 $patientTrackerService = new PatientTrackerService();
108 return $patientTrackerService->collect_checkin($trackerid);
111 #used to determine check out time
112 function collect_checkout($trackerid)
114 $patientTrackerService = new PatientTrackerService();
115 return $patientTrackerService->collect_checkout($trackerid);
118 /* get information the statuses of the appointments*/
119 function getApptStatus($appointments)
121 $patientTrackerService = new PatientTrackerService();
122 return $patientTrackerService->getApptStatus($appointments);