4 * Patient selector for insurance gui
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
;
26 if (!CsrfUtils
::verifyCsrfToken($_POST["csrf_token_form"])) {
27 CsrfUtils
::csrfNotVerified();
31 //the maximum number of patient records to display:
34 $browsenum = (is_numeric($_REQUEST['browsenum'])) ?
$_REQUEST['browsenum'] : 1;
38 <?php Header
::setupHeader(['datetime-picker', 'opener']); ?
>
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 ?>
52 $
('#searchparm').datetimepicker("destroy");
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' />
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
>
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
>
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
>
88 if (isset($_GET['set_pid'])) {
89 if (!isset($_POST['insurance'])) {
90 $insurance = "primary";
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);
102 function auto_populate_employer_address(){
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
;
111 window
.close(); // nothing else to do here, if the browser security context allows it
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']);?
>;
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
>
163 <table
class="table">
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
>
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
>
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
>
177 <td
><span
class='text'><?php
echo xlt('Address'); ?
>:</span
></td
>
178 <td
><span
class='text'><?php
echo text($result3['subscriber_street']);?
></span
></td
>
181 <td
><span
class='text'><?php
echo xlt('City'); ?
>:</span
></td
>
182 <td
><span
class='text'><?php
echo text($result3['subscriber_city']);?
></span
></td
>
185 <td
><span
class='text'><?php
echo xlt('State'); ?
>:</span
></td
>
186 <td
><span
class='text'>
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']);
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
>
198 <td
><span
class='text'><?php
echo xlt('Country'); ?
>:</span
></td
>
199 <td
><span
class='text'>
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']);
207 <td
><span
class='text'><?php
echo xlt('Phone'); ?
>:</span
></td
>
208 <td
><span
class='text'><?php
echo text($result3['subscriber_phone']);?
></span
></td
>
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
>
215 <td
><span
class='text'><?php
echo xlt('SS'); ?
>:</span
></td
>
216 <td
><span
class='text'><?php
echo text($result3['subscriber_ss']);?
></span
></td
>
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
>
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
>
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
>
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
>
236 <?php
if (empty($GLOBALS['omit_employers'])) { ?
>
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
>
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
>
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
>
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
>
254 <td
><span
class='text'><?php
echo xlt('Subscriber Employer State'); ?
>:</span
></td
>
255 <td
><span
class='text'>
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']);
263 <td
><span
class='text'><?php
echo xlt('Subscriber Employer Country'); ?
>:</span
></td
>
264 <td
><span
class='text'>
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']);
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
>
281 <a href
="javascript:auto_populate_employer_address();" class='btn btn-primary btn-sm'><?php
echo xlt('Copy Values'); ?
></a
>
287 <table
class="table">
291 <span
class='bold'><?php
echo xlt('Name'); ?
></span
>
294 <span
class='bold'><?php
echo xlt('SS'); ?
></span
>
297 <span
class='bold'><?php
echo xlt('DOB'); ?
></span
>
300 <span
class='bold'><?php
echo xlt('ID'); ?
></span
>
309 $findby = $_POST['findBy'];
310 $patient = $_POST['patient'];
311 if ($findby == "Last" && $result = getPatientLnames("$patient", "*")) {
312 foreach ($result as $iter) {
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"]) .
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>";
332 print "<td><a class='text' target='_top' href='browse.php?browsenum=" .
333 attr_url($browsenum) . "&set_pid=" .
334 attr_url($iter["pid"]) . "'> </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>";
346 if ($findby == "ID" && $result = getPatientId("$patient", "*")) {
347 foreach ($result as $iter) {
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"]) .
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>";
367 print "<td><a class='text' target='_top' href='browse.php?browsenum=" .
368 attr_url($browsenum) . "&set_pid=" .
369 attr_url($iter["pid"]) . "'> </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>";
381 if ($findby == "DOB" && $result = getPatientDOB(DateToYYYYMMDD($patient), "*")) {
382 foreach ($result as $iter) {
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"]) .
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>";
402 print "<td><a class='text' target='_top' href='browse.php?browsenum=" .
403 attr_url($browsenum) . "&set_pid=" .
404 attr_url($iter["pid"]) . "'> </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>";
416 if ($findby == "SSN" && $result = getPatientSSN("$patient", "*")) {
417 foreach ($result as $iter) {
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"]) .
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>";
437 print "<td><a class='text' target='_top' href='browse.php?browsenum=" .
438 attr_url($browsenum) . "&set_pid=" .
439 attr_url($iter["pid"]) . "'> </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>";