3 * Insurance form posting for the WordPress Patient Portal.
6 * @link http://www.open-emr.org
7 * @author Rod Roark <rod@sunsetsystems.com>
8 * @author Brady Miller <brady.g.miller@gmail.com>
9 * @copyright Copyright (c) 2014 Rod Roark <rod@sunsetsystems.com>
10 * @copyright Copyright (c) 2017 Brady Miller <brady.g.miller@gmail.com>
11 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
15 require_once("../globals.php");
16 require_once("$srcdir/patient.inc");
17 require_once("$srcdir/options.inc.php");
18 require_once("portal.inc.php");
20 // Consider this a step towards converting the insurance form to layout-based.
21 // Faking it here makes things easier.
22 // Also note that some fields like SSN and most of the subscriber employer
23 // items have been omitted because they are not relevant for claims.
25 $insurance_layout = array(
26 array('field_id' => 'type',
30 'list_id' => 'insurance_types',
33 array('field_id' => 'date',
34 'title' => 'Effective Date',
36 'data_type' => '4', // Text-date
40 array('field_id' => 'provider',
41 'title' => 'Provider',
43 'data_type' => '16', // Insurance Providers
47 array('field_id' => 'plan_name',
48 'title' => 'Plan Name',
50 'data_type' => '2', // Text
54 array('field_id' => 'policy_number',
55 'title' => 'Policy Number',
57 'data_type' => '2', // Text
61 array('field_id' => 'group_number',
62 'title' => 'Group Number',
64 'data_type' => '2', // Text
68 array('field_id' => 'subscriber_employer',
69 'title' => 'Group Name',
71 'data_type' => '2', // Text
75 array('field_id' => 'subscriber_lname',
76 'title' => 'Subscriber Last Name',
78 'data_type' => '2', // Text
82 array('field_id' => 'subscriber_fname',
83 'title' => 'Subscriber First Name',
85 'data_type' => '2', // Text
89 array('field_id' => 'subscriber_mname',
90 'title' => 'Subscriber Middle Name',
92 'data_type' => '2', // Text
96 array('field_id' => 'subscriber_DOB',
97 'title' => 'Subscriber DOB',
99 'data_type' => '4', // Text-date
101 'edit_options' => '',
103 array('field_id' => 'subscriber_sex',
104 'title' => 'Subscriber Sex',
106 'data_type' => '1', // List
108 'edit_options' => '',
110 array('field_id' => 'subscriber_relationship',
111 'title' => 'Subscriber Relationship',
113 'data_type' => '1', // List
114 'list_id' => 'sub_relation',
115 'edit_options' => '',
117 array('field_id' => 'subscriber_street',
118 'title' => 'Subscriber Street',
120 'data_type' => '2', // Text
122 'edit_options' => '',
124 array('field_id' => 'subscriber_city',
125 'title' => 'Subscriber City',
127 'data_type' => '2', // Text
129 'edit_options' => '',
131 array('field_id' => 'subscriber_state',
132 'title' => 'Subscriber State',
134 'data_type' => '1', // List
135 'list_id' => 'state',
136 'edit_options' => '',
138 array('field_id' => 'subscriber_postal_code',
139 'title' => 'Subscriber Zip',
141 'data_type' => '2', // Text
143 'edit_options' => '',
145 array('field_id' => 'subscriber_phone',
146 'title' => 'Subscriber Phone',
148 'data_type' => '2', // Text
150 'edit_options' => '',
154 $postid = intval($_REQUEST['postid']);
156 if ($_POST['bn_save']) {
158 $ptid = intval($_POST['ptid']);
159 foreach ($insurance_layout as $frow) {
160 $data_type = $frow['data_type'];
161 $field_id = $frow['field_id'];
162 $newdata[$field_id] = get_layout_form_value($frow);
168 $newdata['provider'],
169 $newdata['policy_number'],
170 $newdata['group_number'],
171 $newdata['plan_name'],
172 $newdata['subscriber_lname'],
173 $newdata['subscriber_mname'],
174 $newdata['subscriber_fname'],
175 $newdata['subscriber_relationship'],
177 $newdata['subscriber_DOB'],
178 $newdata['subscriber_street'],
179 $newdata['subscriber_postal_code'],
180 $newdata['subscriber_city'],
181 $newdata['subscriber_state'],
182 '', // subscriber_country
183 $newdata['subscriber_phone'],
184 $newdata['subscriber_employer'],
185 '', // subscriber_employer_street
186 '', // subscriber_employer_city
187 '', // subscriber_employer_postal_code
188 '', // subscriber_employer_state
189 '', // subscriber_employer_country
191 $newdata['subscriber_sex'],
193 'TRUE', // accept_assignment
196 // Finally, delete the request from the portal.
197 $result = cms_portal_call(array('action' => 'delpost', 'postid' => $postid));
198 if ($result['errmsg']) {
199 die(text($result['errmsg']));
202 echo "<html><body><script language='JavaScript'>\n";
203 echo "if (top.restoreSession) top.restoreSession(); else opener.top.restoreSession();\n";
204 echo "document.location.href = 'list_requests.php';\n";
205 echo "</script></body></html>\n";
209 // Get the portal request data.
211 die(xlt('Request ID is missing!'));
214 $result = cms_portal_call(array('action' => 'getpost', 'postid' => $postid));
215 if ($result['errmsg']) {
216 die(text($result['errmsg']));
219 // Look up the patient in OpenEMR.
220 $ptid = lookup_openemr_patient($result['post']['user']);
224 <?php
html_header_show(); ?
>
225 <link rel
=stylesheet href
="<?php echo $css_header; ?>" type
="text/css">
226 <link rel
="stylesheet" href
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker-2-5-4/build/jquery.datetimepicker.min.css">
230 tr
.head
{ font
-size
:10pt
; background
-color
:#cccccc; text-align:center; }
231 tr
.detail
{ font
-size
:10pt
; background
-color
:#ddddff; }
232 td input
{ background
-color
:transparent
; }
236 <script type
="text/javascript" src
="../../library/textformat.js?v=<?php echo $v_js_includes; ?>"></script
>
237 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-7-2/index.js"></script
>
238 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker-2-5-4/build/jquery.datetimepicker.full.min.js"></script
>
240 <script language
="JavaScript">
242 var mypcc
= '<?php echo $GLOBALS['phone_country_code
'] ?>';
244 function myRestoreSession() {
245 if (top
.restoreSession
) top
.restoreSession(); else opener
.top
.restoreSession();
249 // This capitalizes the first letter of each word in the passed input
250 // element. It also strips out extraneous spaces.
251 // Copied from demographics_full.php.
252 function capitalizeMe(elem
) {
253 var a
= elem
.value
.split(' ');
255 for(var i
= 0; i
< a
.length
; ++i
) {
256 if (a
[i
].length
> 0) {
257 if (s
.length
> 0) s +
= ' ';
258 s +
= a
[i
].charAt(0).toUpperCase() + a
[i
].substring(1);
264 function validate() {
265 var f
= document
.forms
[0];
270 $
(document
).ready(function() {
271 $
('.datepicker').datetimepicker({
272 <?php
$datetimepicker_timepicker = false; ?
>
273 <?php
$datetimepicker_showseconds = false; ?
>
274 <?php
$datetimepicker_formatInput = true; ?
>
275 <?php
require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?
>
276 <?php
// can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
278 $
('.datetimepicker').datetimepicker({
279 <?php
$datetimepicker_timepicker = true; ?
>
280 <?php
$datetimepicker_showseconds = false; ?
>
281 <?php
$datetimepicker_formatInput = true; ?
>
282 <?php
require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?
>
283 <?php
// can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
290 <body
class="body_top">
293 <form method
='post' action
='insurance_form.php' onsubmit
='return validate()'>
295 <input type
='hidden' name
='ptid' value
='<?php echo attr($ptid); ?>' />
296 <input type
='hidden' name
='postid' value
='<?php echo attr($postid); ?>' />
298 <table width
='100%' cellpadding
='1' cellspacing
='2'>
300 <th align
='left'><?php
echo xlt('Field'); ?
></th
>
301 <th align
='left'><?php
echo xlt('Current Value'); ?
></th
>
302 <th align
='left'><?php
echo xlt('New Value'); ?
></th
>
306 $insrow = getInsuranceData($pid, $result['fields']['type']);
308 foreach ($insurance_layout as $lorow) {
309 $data_type = $lorow['data_type'];
310 $field_id = $lorow['field_id'];
312 $list_id = $lorow['list_id'];
313 $field_title = $lorow['title'];
316 if (isset($insrow[$field_id])) {
317 $currvalue = $insrow[$field_id];
321 if (isset($result['fields'][$field_id])) {
322 $newvalue = trim($result['fields'][$field_id]);
325 // Translate $newvalue for certain field types including lists.
326 if ($newvalue !== '') {
329 "SELECT option_id FROM list_options WHERE " .
330 "list_id = ? AND title = ? AND activity = 1 ORDER BY option_id LIMIT 1",
331 array($list_id, $newvalue)
333 if (isset($tmp['option_id'])) {
334 $newvalue = $tmp['option_id'];
338 // Some data types like insurance provider are pretty hopeless, so let the display
339 // logic generate a "Fix me" message and the user can translate it.
342 echo " <tr class='detail'>\n";
343 echo " <td class='bold'>" . text($field_title) . "</td>\n";
345 echo generate_display_field($lorow, $currvalue);
348 generate_form_field($lorow, $newvalue);
357 <input type
='submit' name
='bn_save' value
='<?php echo xla('Save
and Delete Request
'); ?>' />
359 <input type
='button' value
='<?php echo xla('Back
'); ?>' onclick
="window.history.back()" />
360 <!-- Was
: onclick
="myRestoreSession();location='list_requests.php'" -->
365 <script language
="JavaScript">
367 // Fix inconsistently formatted phone numbers from the database.
368 var f
= document
.forms
[0];
369 if (f
.form_phone
) phonekeyup(f
.form_phone
, mypcc
);
371 // This is a by-product of generate_form_field().
372 <?php
echo $date_init; ?
>
376 <!-- include support
for the
list-add selectbox feature
-->
377 <?php
include $GLOBALS['fileroot'] . "/library/options_listadd.inc"; ?
>