Feat openemr fix 7480 7494 email prescription (#7495)
[openemr.git] / interface / patient_file / summary / browse.php
blob21e7d0d7d8e3964af63c51e9633202e78e7166ed
1 <?php
3 /**
4 * Patient selector for insurance gui
6 * @package OpenEMR
7 * @link http://www.open-emr.org
8 * @author Brady Miller <brady.g.miller@gmail.com>
9 * @author Tyler Wrenn <tyler@tylerwrenn.com>
10 * @author Stephen Nielson <snielson@discoverandchange.com>
11 * @copyright Copyright (c) 2018 Brady Miller <brady.g.miller@gmail.com>
12 * @copyright Copyright (c) 2020 Tyler Wrenn <tyler@tylerwrenn.com>
13 * @copyright Copyright (c) 2024 Care Management Solutions, Inc. <stephen.waite@cmsvt.com>
14 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
17 require_once("../../globals.php");
18 require_once("$srcdir/patient.inc.php");
19 require_once("$srcdir/options.inc.php");
21 use OpenEMR\Common\Csrf\CsrfUtils;
22 use OpenEMR\Core\Header;
23 use OpenEMR\Common\Uuid\UuidRegistry;
25 if (!empty($_POST)) {
26 if (!CsrfUtils::verifyCsrfToken($_POST["csrf_token_form"])) {
27 CsrfUtils::csrfNotVerified();
31 //the maximum number of patient records to display:
32 $M = 100;
34 $browsenum = (is_numeric($_REQUEST['browsenum'])) ? $_REQUEST['browsenum'] : 1;
36 <html>
37 <head>
38 <?php Header::setupHeader(['datetime-picker', 'opener']); ?>
40 <script>
41 $(function () {
42 $('[name="findBy"').on('change', function () {
43 if($(this).val() === 'DOB'){
44 $('#searchparm').datetimepicker({
45 <?php $datetimepicker_timepicker = false; ?>
46 <?php $datetimepicker_showseconds = false; ?>
47 <?php $datetimepicker_formatInput = true; ?>
48 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
49 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
50 });
51 } else {
52 $('#searchparm').datetimepicker("destroy");
54 });
55 });
56 </script>
58 </head>
60 <body class="body_top">
62 <a href="javascript:window.close();"><span class="title"><?php echo xlt('Browse for Record'); ?></span><span class="back"><?php echo text($tback);?></span></a>
64 <form border='0' method='post' name="find_patient" action="browse.php?browsenum=<?php echo attr_url($browsenum); ?>">
65 <input type="hidden" name="csrf_token_form" value="<?php echo attr(CsrfUtils::collectCsrfToken()); ?>" />
66 <div class="form-row">
67 <div class="col-auto">
68 <input type='entry' size='10' class='form-control form-control-sm' name='patient' id='searchparm' />
69 </div>
70 <div class="col-auto">
71 <select name="findBy" size='1' class="form-control form-control-sm">
72 <option value="ID"><?php echo xlt('ID'); ?></option>
73 <option value="Last" selected><?php echo xlt('Last Name'); ?></option>
74 <option value="SSN"><?php echo xlt('SSN'); ?></option>
75 <option value="DOB"><?php echo xlt('DOB'); ?></option>
76 </select>
77 </div>
78 <div class="col-auto">
79 <a href="javascript:document.find_patient.submit();" role="button" class="btn btn-primary btn-sm"><?php echo xlt('Find'); ?></a>
80 </div>
81 <div class="col-auto">
82 <a href="javascript:auto_populate_employer_address();" role="button" class="btn btn-primary btn-sm"><?php echo xlt('Copy Values'); ?></a>
83 </div>
84 </div>
85 </form>
87 <?php
88 if (isset($_GET['set_pid'])) {
89 if (!isset($_POST['insurance'])) {
90 $insurance = "primary";
91 } else {
92 $insurance = $_POST['insurance'];
95 $result = getPatientData($_GET['set_pid']);
96 // $result2 = getEmployerData($_GET['set_pid']); // not used!
97 $result3 = getInsuranceData($_GET['set_pid'], $insurance);
100 <script>
101 <!--
102 function auto_populate_employer_address(){
104 let data = {
105 action: 'insurance-patient-browser-selected',
106 patientUuid: <?php echo js_escape(UuidRegistry::uuidToString($result['uuid'])); ?>,
107 insuranceUuid: <?php echo js_escape(UuidRegistry::uuidToString($result3['uuid'])); ?>
109 let opener = window.opener;
110 if (!opener) {
111 window.close(); // nothing else to do here, if the browser security context allows it
112 return;
114 opener.postMessage(data, window.location.origin);
115 if (!(opener.document && opener.document.demographics_form)) {
116 window.close(); // nothing else to do here, if the browser security context allows it
117 return; // we did not open in a popup from a demographics LBF form.
119 var df = opener.document.demographics_form;
120 df.i<?php echo attr($browsenum);?>subscriber_fname.value=<?php echo js_escape($result3['subscriber_fname']);?>;
121 df.i<?php echo attr($browsenum);?>subscriber_mname.value=<?php echo js_escape($result3['subscriber_mname']);?>;
122 df.i<?php echo attr($browsenum);?>subscriber_lname.value=<?php echo js_escape($result3['subscriber_lname']);?>;
123 df.i<?php echo attr($browsenum);?>subscriber_street.value=<?php echo js_escape($result3['subscriber_street']);?>;
124 df.i<?php echo attr($browsenum);?>subscriber_city.value=<?php echo js_escape($result3['subscriber_city']);?>;
125 df.form_i<?php echo attr($browsenum);?>subscriber_state.value=<?php echo js_escape($result3['subscriber_state']);?>;
126 df.i<?php echo attr($browsenum);?>subscriber_postal_code.value=<?php echo js_escape($result3['subscriber_postal_code']);?>;
127 if (df.form_i<?php echo attr($browsenum);?>subscriber_country) // in case this is commented out
128 df.form_i<?php echo attr($browsenum);?>subscriber_country.value=<?php echo js_escape($result3['subscriber_country']);?>;
129 df.i<?php echo attr($browsenum);?>subscriber_phone.value=<?php echo js_escape($result3['subscriber_phone']);?>;
130 df.i<?php echo attr($browsenum);?>subscriber_DOB.value=<?php echo js_escape(oeFormatShortDate($result3['subscriber_DOB']));?>;
131 df.i<?php echo attr($browsenum);?>subscriber_ss.value=<?php echo js_escape($result3['subscriber_ss']);?>;
132 df.form_i<?php echo attr($browsenum);?>subscriber_sex.value=<?php echo js_escape($result3['subscriber_sex']);?>;
134 df.i<?php echo attr($browsenum);?>plan_name.value=<?php echo js_escape($result3['plan_name']);?>;
135 df.i<?php echo attr($browsenum);?>policy_number.value=<?php echo js_escape($result3['policy_number']);?>;
136 df.i<?php echo attr($browsenum);?>group_number.value=<?php echo js_escape($result3['group_number']);?>;
137 df.i<?php echo attr($browsenum);?>provider.value=<?php echo js_escape($result3['provider']);?>;
139 // One clinic comments out the subscriber employer stuff.
140 if (df.i<?php echo attr($browsenum);?>subscriber_employer) {
141 df.i<?php echo attr($browsenum);?>subscriber_employer.value=<?php echo js_escape($result3['subscriber_employer']);?>;
142 df.i<?php echo attr($browsenum);?>subscriber_employer_street.value=<?php echo js_escape($result3['subscriber_employer_street']);?>;
143 df.i<?php echo attr($browsenum);?>subscriber_employer_city.value=<?php echo js_escape($result3['subscriber_employer_city']);?>;
144 df.form_i<?php echo attr($browsenum);?>subscriber_employer_state.value=<?php echo js_escape($result3['subscriber_employer_state']);?>;
145 df.i<?php echo attr($browsenum);?>subscriber_employer_postal_code.value=<?php echo js_escape($result3['subscriber_employer_postal_code']);?>;
146 df.form_i<?php echo attr($browsenum);?>subscriber_employer_country.value=<?php echo js_escape($result3['subscriber_employer_country']);?>;
149 //-->
150 </script>
152 <form method="post" name="insurance_form" action="browse.php?browsenum=<?php echo attr_url($browsenum); ?>&set_pid=<?php echo attr_url($_GET['set_pid']); ?>">
153 <input type="hidden" name="csrf_token_form" value="<?php echo attr(CsrfUtils::collectCsrfToken()); ?>" />
154 <input type="hidden" name="browsenum" value="<?php echo attr($browsenum); ?>">
155 <span class='bold'> <?php echo xlt('Insurance Provider'); ?>:</span>
156 <select name='insurance' onchange="javascript:document.insurance_form.submit();">
157 <option value="primary" <?php echo ($insurance == "primary") ? "selected" : ""?>><?php echo xlt('Primary'); ?></option>
158 <option value="secondary" <?php echo ($insurance == "secondary") ? "selected" : ""?>><?php echo xlt('Secondary'); ?></option>
159 <option value="tertiary" <?php echo ($insurance == "tertiary") ? "selected" : ""?>><?php echo xlt('Tertiary'); ?></option>
160 </select>
162 </form>
163 <table class="table">
164 <tr>
165 <td><span class='text'><?php echo xlt('First Name'); ?>:</span></td>
166 <td><span class='text'><?php echo text($result3['subscriber_fname']);?></span></td>
167 </tr>
168 <tr>
169 <td><span class='text'><?php echo xlt('Middle Name'); ?>:</span></td>
170 <td><span class='text'><?php echo text($result3['subscriber_mname']);?></span></td>
171 </tr>
172 <tr>
173 <td><span class='text'><?php echo xlt('Last Name'); ?>:</span></td>
174 <td><span class='text'><?php echo text($result3['subscriber_lname']);?></span></td>
175 </tr>
176 <tr>
177 <td><span class='text'><?php echo xlt('Address'); ?>:</span></td>
178 <td><span class='text'><?php echo text($result3['subscriber_street']);?></span></td>
179 </tr>
180 <tr>
181 <td><span class='text'><?php echo xlt('City'); ?>:</span></td>
182 <td><span class='text'><?php echo text($result3['subscriber_city']);?></span></td>
183 </tr>
184 <tr>
185 <td><span class='text'><?php echo xlt('State'); ?>:</span></td>
186 <td><span class='text'>
187 <?php
188 //Modified 7/2009 by BM to incorporate data types
189 echo generate_display_field(array('data_type' => $GLOBALS['state_data_type'],'list_id' => $GLOBALS['state_list']), $result3['subscriber_state']);
191 </span></td>
192 </tr>
193 <tr>
194 <td><span class='text'><?php echo xlt('Zip Code'); ?>:</span></td>
195 <td><span class='text'><?php echo htmlspecialchars($result3['subscriber_postal_code']);?></span></td>
196 </tr>
197 <tr>
198 <td><span class='text'><?php echo xlt('Country'); ?>:</span></td>
199 <td><span class='text'>
200 <?php
201 //Modified 7/2009 by BM to incorporate data types
202 echo generate_display_field(array('data_type' => $GLOBALS['country_data_type'],'list_id' => $GLOBALS['country_list']), $result3['subscriber_country']);
204 </span></td>
205 </tr>
206 <tr>
207 <td><span class='text'><?php echo xlt('Phone'); ?>:</span></td>
208 <td><span class='text'><?php echo text($result3['subscriber_phone']);?></span></td>
209 </tr>
210 <tr>
211 <td><span class='text'><?php echo xlt('DOB'); ?>:</span></td>
212 <td><span class='text'><?php echo text(oeFormatShortDate($result3['subscriber_DOB']));?></span></td>
213 </tr>
214 <tr>
215 <td><span class='text'><?php echo xlt('SS'); ?>:</span></td>
216 <td><span class='text'><?php echo text($result3['subscriber_ss']);?></span></td>
217 </tr>
218 <tr>
219 <td><span class='text'><?php echo xlt('Primary Insurance Provider'); ?>:</span></td>
220 <td><span class='text'><?php echo text($result3['provider_name']);?></span></td>
221 </tr>
222 <tr>
223 <td><span class='text'><?php echo xlt('Plan Name'); ?>:</span>
224 </td><td><span class='text'><?php echo text($result3['plan_name']);?></span></td>
225 </tr>
226 <tr>
227 <td><span class='text'><?php echo xlt('Group Number'); ?>:</span></td>
228 <td><span class='text'><?php echo text($result3['group_number']);?></span></td>
229 </tr>
230 <tr>
231 <tr>
232 <td><span class='text'><?php echo xlt('Policy Number'); ?>:</span></td>
233 <td><span class='text'><?php echo text($result3['policy_number']);?></span></td>
234 </tr>
236 <?php if (empty($GLOBALS['omit_employers'])) { ?>
237 <tr>
238 <td><span class='text'><?php echo xlt('Subscriber Employer'); ?>:</span></td>
239 <td><span class='text'><?php echo text($result3['subscriber_employer']);?></span></td>
240 </tr>
241 <tr>
242 <td><span class='text'><?php echo xlt('Subscriber Employer Address'); ?>:</span></td>
243 <td><span class='text'><?php echo text($result3['subscriber_employer_street']);?></span></td>
244 </tr>
245 <tr>
246 <td><span class='text'><?php echo xlt('Subscriber Employer Zip Code'); ?>:</span></td>
247 <td><span class='text'><?php echo text($result3['subscriber_employer_postal_code']);?></span></td>
248 </tr>
249 <tr>
250 <td><span class='text'><?php echo xlt('Subscriber Employer City'); ?>:</span></td>
251 <td><span class='text'><?php echo text($result3['subscriber_employer_city']);?></span></td>
252 </tr>
253 <tr>
254 <td><span class='text'><?php echo xlt('Subscriber Employer State'); ?>:</span></td>
255 <td><span class='text'>
256 <?php
257 //Modified 7/2009 by BM to incorporate data types
258 echo generate_display_field(array('data_type' => $GLOBALS['state_data_type'],'list_id' => $GLOBALS['state_list']), $result3['subscriber_employer_state']);
260 </span></td>
261 </tr>
262 <tr>
263 <td><span class='text'><?php echo xlt('Subscriber Employer Country'); ?>:</span></td>
264 <td><span class='text'>
265 <?php
266 //Modified 7/2009 by BM to incorporate data types
267 echo generate_display_field(array('data_type' => $GLOBALS['country_data_type'],'list_id' => $GLOBALS['country_list']), $result3['subscriber_employer_country']);
269 </span></td>
270 </tr>
272 <?php } ?>
274 <tr>
275 <td><span class='text'><?php echo xlt('Subscriber Sex'); ?>:</span></td>
276 <td><span class='text'><?php echo generate_display_field(array('data_type' => '1','list_id' => 'sex'), $result3['subscriber_sex']); ?></span></td>
277 </tr>
278 </table>
280 <br />
281 <a href="javascript:auto_populate_employer_address();" class='btn btn-primary btn-sm'><?php echo xlt('Copy Values'); ?></a>
283 <?php
284 } else {
287 <table class="table">
288 <tr>
289 <thead>
290 <th>
291 <span class='bold'><?php echo xlt('Name'); ?></span>
292 </th>
293 <th>
294 <span class='bold'><?php echo xlt('SS'); ?></span>
295 </th>
296 <th>
297 <span class='bold'><?php echo xlt('DOB'); ?></span>
298 </th>
299 <th>
300 <span class='bold'><?php echo xlt('ID'); ?></span>
301 </th>
302 </thead>
303 </tr>
304 <?php
306 $count = 0;
307 $total = 0;
309 $findby = $_POST['findBy'];
310 $patient = $_POST['patient'];
311 if ($findby == "Last" && $result = getPatientLnames("$patient", "*")) {
312 foreach ($result as $iter) {
313 if ($total >= $M) {
314 break;
317 print "<tr><td><a class='text' target='_top' href='browse.php?browsenum=" .
318 attr_url($browsenum) . "&set_pid=" .
319 attr_url($iter["pid"]) . "'>" .
320 text($iter["lname"] . ", " . $iter["fname"]) .
321 "</td></a>\n";
322 print "<td><a class='text' target='_top' href='browse.php?browsenum=" .
323 attr_url($browsenum) . "&set_pid=" .
324 attr_url($iter["pid"]) . "'>" .
325 text($iter["ss"]) . "</a></td>";
326 if ($iter["DOB"] != "0000-00-00 00:00:00") {
327 print "<td><a class='text' target='_top' href='browse.php?browsenum=" .
328 attr_url($browsenum) . "&set_pid=" .
329 attr_url($iter["pid"]) . "'>" .
330 text(oeFormatShortDate($iter["DOB"])) . "</a></td>";
331 } else {
332 print "<td><a class='text' target='_top' href='browse.php?browsenum=" .
333 attr_url($browsenum) . "&set_pid=" .
334 attr_url($iter["pid"]) . "'>&nbsp;</a></td>";
337 print "<td><a class='text' target='_top' href='browse.php?browsenum=" .
338 attr_url($browsenum) . "&set_pid=" .
339 attr_url($iter["pid"]) . "'>" .
340 text($iter["pubpid"]) . "</a></td>";
342 $total++;
346 if ($findby == "ID" && $result = getPatientId("$patient", "*")) {
347 foreach ($result as $iter) {
348 if ($total >= $M) {
349 break;
352 print "<tr><td><a class='text' target='_top' href='browse.php?browsenum=" .
353 attr_url($browsenum) . "&set_pid=" .
354 attr_url($iter["pid"]) . "'>" .
355 text($iter["lname"] . ", " . $iter["fname"]) .
356 "</td></a>\n";
357 print "<td><a class='text' target='_top' href='browse.php?browsenum=" .
358 attr_url($browsenum) . "&set_pid=" .
359 attr_url($iter["pid"]) . "'>" .
360 text($iter["ss"]) . "</a></td>";
361 if ($iter["DOB"] != "0000-00-00 00:00:00") {
362 print "<td><a class='text' target='_top' href='browse.php?browsenum=" .
363 attr_url($browsenum) . "&set_pid=" .
364 attr_url($iter["pid"]) . "'>" .
365 text(oeFormatShortDate($iter["DOB"])) . "</a></td>";
366 } else {
367 print "<td><a class='text' target='_top' href='browse.php?browsenum=" .
368 attr_url($browsenum) . "&set_pid=" .
369 attr_url($iter["pid"]) . "'>&nbsp;</a></td>";
372 print "<td><a class='text' target='_top' href='browse.php?browsenum=" .
373 attr_url($browsenum) . "&set_pid=" .
374 attr_url($iter["pid"]) . "'>" .
375 text($iter["pubpid"]) . "</a></td>";
377 $total++;
381 if ($findby == "DOB" && $result = getPatientDOB(DateToYYYYMMDD($patient), "*")) {
382 foreach ($result as $iter) {
383 if ($total >= $M) {
384 break;
387 print "<tr><td><a class='text' target='_top' href='browse.php?browsenum=" .
388 attr_url($browsenum) . "&set_pid=" .
389 attr_url($iter["pid"]) . "'>" .
390 text($iter["lname"] . ", " . $iter["fname"]) .
391 "</td></a>\n";
392 print "<td><a class='text' target='_top' href='browse.php?browsenum=" .
393 attr_url($browsenum) . "&set_pid=" .
394 attr_url($iter["pid"]) . "'>" .
395 text($iter["ss"]) . "</a></td>";
396 if ($iter["DOB"] != "0000-00-00 00:00:00") {
397 print "<td><a class='text' target='_top' href='browse.php?browsenum=" .
398 attr_url($browsenum) . "&set_pid=" .
399 attr_url($iter["pid"]) . "'>" .
400 text(oeFormatShortDate($iter["DOB"])) . "</a></td>";
401 } else {
402 print "<td><a class='text' target='_top' href='browse.php?browsenum=" .
403 attr_url($browsenum) . "&set_pid=" .
404 attr_url($iter["pid"]) . "'>&nbsp;</a></td>";
407 print "<td><a class='text' target='_top' href='browse.php?browsenum=" .
408 attr_url($browsenum) . "&set_pid=" .
409 attr_url($iter["pid"]) . "'>" .
410 text($iter["pubpid"]) . "</a></td>";
412 $total++;
416 if ($findby == "SSN" && $result = getPatientSSN("$patient", "*")) {
417 foreach ($result as $iter) {
418 if ($total >= $M) {
419 break;
422 print "<tr><td><a class='text' target='_top' href='browse.php?browsenum=" .
423 attr_url($browsenum) . "&set_pid=" .
424 attr_url($iter["pid"]) . "'>" .
425 text($iter["lname"] . ", " . $iter["fname"]) .
426 "</td></a>\n";
427 print "<td><a class='text' target='_top' href='browse.php?browsenum=" .
428 attr_url($browsenum) . "&set_pid=" .
429 attr_url($iter["pid"]) . "'>" .
430 text($iter["ss"]) . "</a></td>";
431 if ($iter["DOB"] != "0000-00-00 00:00:00") {
432 print "<td><a class='text' target='_top' href='browse.php?browsenum=" .
433 attr_url($browsenum) . "&set_pid=" .
434 attr_url($iter["pid"]) . "'>" .
435 text(oeFormatShortDate($iter["DOB"])) . "</a></td>";
436 } else {
437 print "<td><a class='text' target='_top' href='browse.php?browsenum=" .
438 attr_url($browsenum) . "&set_pid=" .
439 attr_url($iter["pid"]) . "'>&nbsp;</a></td>";
442 print "<td><a class='text' target='_top' href='browse.php?browsenum=" .
443 attr_url($browsenum) . "&set_pid=" .
444 attr_url($iter["pid"]) . "'>" .
445 text($iter["pubpid"]) . "</a></td>";
447 $total++;
451 </table>
452 <?php
455 </body>
456 </html>