fix: calendar event edit provider out of office php math error (#7850)
[openemr.git] / custom / chart_tracker.php
blob3f372e10e5eae92faf6d4141b921878617e11d70
1 <?php
3 /**
4 * The Chart Tracker feature facilitates the old traditional paper charts updates.
5 * This feature requires a new list:
6 * <pre>
7 * INSERT INTO list_options VALUES ('lists','chartloc','Chart Storage Locations',51,0,0);
8 * </pre>
10 * @package OpenEMR
11 * @link http://www.open-emr.org
12 * @author Rod Roark <rod@sunsetsystems.com>
13 * @author Brady Miller <brady.g.miller@gmail.com>
14 * @author Roberto Vasquez <robertogagliotta@gmail.com>
15 * @Copyright (C) 2008-2012 Rod Roark <rod@sunsetsystems.com>
16 * @Copyright (C) 2011-2018 Brady Miller <brady.g.miller@gmail.com>
17 * @Copyright (C) 2017 Roberto Vasquez <robertogagliotta@gmail.com>
20 require_once("../interface/globals.php");
21 require_once("$srcdir/options.inc.php");
23 use OpenEMR\Common\Csrf\CsrfUtils;
24 use OpenEMR\Core\Header;
25 use OpenEMR\Services\UserService;
27 $form_newid = isset($_POST['form_newid' ]) ? trim($_POST['form_newid' ]) : '';
28 $form_curpid = isset($_POST['form_curpid' ]) ? trim($_POST['form_curpid' ]) : '';
29 $form_curid = isset($_POST['form_curid' ]) ? trim($_POST['form_curid' ]) : '';
30 $form_newloc = isset($_POST['form_newloc' ]) ? trim($_POST['form_newloc' ]) : '';
31 $form_newuser = isset($_POST['form_newuser']) ? trim($_POST['form_newuser']) : '';
33 if ($form_newuser) {
34 $form_newloc = '';
35 } else {
36 $form_newuser = 0;
39 <html>
41 <head>
42 <?php Header::setupHeader(); ?>
43 <title><?php echo xlt('Chart Tracker'); ?></title>
45 <script>
47 function locationSelect() {
48 var f = document.forms[0];
49 var i = f.form_newloc.selectedIndex;
50 if (i > 0) {
51 f.form_newuser.selectedIndex = 0;
55 function userSelect() {
56 var f = document.forms[0];
57 var i = f.form_newuser.selectedIndex;
58 if (i > 0) {
59 f.form_newloc.selectedIndex = 0;
63 </script>
65 </head>
67 <body class="body_top">
68 <div class="container">
70 <div class="row">
71 <div class="col-12">
72 <h1><?php echo xlt('Chart Tracker'); ?></h1>
73 </div>
74 </div>
76 <form method='post' action='chart_tracker.php' class='form-horizontal' onsubmit='return top.restoreSession()'>
77 <input type="hidden" name="csrf_token_form" value="<?php echo attr(CsrfUtils::collectCsrfToken()); ?>" />
79 <?php
80 // This is the place for status messages.
82 if ($form_newloc || $form_newuser) {
83 if (!CsrfUtils::verifyCsrfToken($_POST["csrf_token_form"])) {
84 CsrfUtils::csrfNotVerified();
86 sqlStatement("INSERT INTO `chart_tracker` (`ct_pid`, `ct_when`, `ct_userid`, `ct_location`) VALUES (?, NOW(), ?, ?)", [$form_curpid, $form_newuser, $form_newloc]);
87 echo "<div class='alert alert-success'>" . xlt('Save Successful for chart ID') . " " . "'" . text($form_curid) . "'.</div>";
90 $row = array();
92 if ($form_newid) {
93 if (!CsrfUtils::verifyCsrfToken($_POST["csrf_token_form"])) {
94 CsrfUtils::csrfNotVerified();
97 // Find out where the chart is now.
98 $query = "SELECT pd.pid, pd.pubpid, pd.fname, pd.mname, pd.lname, " .
99 "pd.ss, pd.DOB, ct.ct_userid, ct.ct_location, ct.ct_when " .
100 "FROM patient_data AS pd " .
101 "LEFT OUTER JOIN chart_tracker AS ct ON ct.ct_pid = pd.pid " .
102 "WHERE pd.pubpid = ? " .
103 "ORDER BY pd.pid ASC, ct.ct_when DESC LIMIT 1";
104 $row = sqlQuery($query, array($form_newid));
105 if (empty($row)) {
106 echo "<div class='alert alert-danger'>" . xlt('Chart ID') . " " . "'" . text($form_newid) . "' " . xlt('not found') . "!</div>";
111 <?php
112 if (!empty($row)) {
113 $userService = new UserService();
114 $ct_userid = $row['ct_userid'];
115 $ct_location = $row['ct_location'];
116 $current_location = xlt('Unassigned');
117 if ($ct_userid) {
118 $user = $userService->getUser($ct_userid);
119 $current_location = text($user['lname'] . ", " . $user['fname'] . " " . $user['mname'] . " " . oeFormatDateTime($row['ct_when'], "global", true));
120 } elseif ($ct_location) {
121 $current_location = generate_display_field(array('data_type' => '1','list_id' => 'chartloc'), $ct_location);
125 <div class="row">
126 <div class="col-sm-6 jumbotron jumbotron-fluid p-3">
127 <div class="form-row">
128 <label for="form_pat_id" class='col-form-label col-sm-3'><?php echo xlt('Patient ID') . ":"; ?></label>
129 <div class='col-sm-9'>
130 <p class="form-control-static"><?php echo text($row['pid']) ?></p>
131 <input type='hidden' name='form_curpid' value='<?php echo attr($row['pid']); ?>' />
132 <input type='hidden' name='form_curid' value='<?php echo attr($row['pubpid']); ?>' />
133 </div>
134 </div>
135 <div class="form-row">
136 <label for="form_pat_id" class='col-form-label col-sm-3'><?php echo xlt('Name') . ":"; ?></label>
137 <div class='col-sm-9'>
138 <p class="form-control-static"><?php echo text($row['lname'] . ", " . $row['fname'] . " " . $row['mname']) ?></p>
139 </div>
140 </div>
141 <div class="form-row">
142 <label for="form_pat_id" class='col-form-label col-sm-3'><?php echo xlt('DOB') . ":"; ?></label>
143 <div class='col-sm-9'>
144 <p class="form-control-static"><?php echo text(oeFormatShortDate($row['DOB'])) ?></p>
145 </div>
146 </div>
147 <div class="form-row">
148 <label for="form_pat_id" class='col-form-label col-sm-3'><?php echo xlt('SSN') . ":"; ?></label>
149 <div class='col-sm-9'>
150 <p class="form-control-static"><?php echo text($row['ss']) ?></p>
151 </div>
152 </div>
153 <div class="form-row">
154 <label for="form_pat_id" class='col-form-label col-sm-3'><?php echo xlt('Current Location') . ":"; ?></label>
155 <div class='col-sm-9'>
156 <p class="form-control-static"><?php echo text($current_location) ?></p>
157 </div>
158 </div>
159 <div class="form-row">
160 <label for="form_curr_loc" class='col-form-label col-sm-3'><?php echo xlt('Check In To') . ":"; ?></label>
161 <div class='col-sm-9'>
162 <?php generate_form_field(array('data_type' => 1,'field_id' => 'newloc','list_id' => 'chartloc','empty_title' => ''), ''); ?>
163 </div>
164 </div>
165 <div class="form-row">
166 <label for="form_out_to" class='col-form-label col-sm-3'><?php echo xlt('Our Out To') . ":"; ?></label>
167 <div class='col-sm-9'>
168 <select name='form_newuser' class='form-control' onchange='userSelect()'>
169 <option value=''></option>
170 <?php
171 $users = $userService->getActiveUsers();
173 foreach ($users as $activeUser) {
174 echo " <option value='" . attr($activeUser['id']) . "'";
175 echo ">" . text($activeUser['lname']) . ', ' . text($activeUser['fname']) . ' ' . text($activeUser['mname']) .
176 "</option>\n";
179 </select>
180 </div>
181 </div>
182 <div class="form-row">
183 <div class="offset-sm-3 col-sm-9">
184 <button type='submit' class='btn btn-secondary btn-save' name='form_save'><?php echo xlt("Save"); ?></button>
185 </div>
186 </div>
187 </div>
190 <?php
193 <div class="col-sm-6 jumbotron jumbotron-fluid p-3">
194 <div class="form-row">
195 <label for='form_newid' class='col-form-label col-sm-3'><?php echo xlt('New Patient ID') . ":"; ?></label>
196 <div class='col-sm-9'>
197 <input type='text' name='form_newid' id='form_newid' class='form-control' title='<?php echo xla('Type or scan the patient identifier here'); ?>' />
198 </div>
199 </div>
200 <div class="form-row">
201 <div class='offset-sm-3 col-sm-9'>
202 <button type='submit' class='btn btn-secondary btn-search' name='form_lookup'><?php echo xlt("Look Up"); ?></button>
203 </div>
204 </div>
205 </div>
206 </div>
207 </form>
209 </div>
211 </body>
212 </html>