3 * Insurance form posting for the WordPress Patient Portal.
5 * LICENSE: This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
17 * @author Rod Roark <rod@sunsetsystems.com>
20 $sanitize_all_escapes = true;
21 $fake_register_globals = false;
23 require_once("../globals.php");
24 require_once("$srcdir/patient.inc");
25 require_once("$srcdir/formdata.inc.php");
26 require_once("$srcdir/options.inc.php");
27 require_once("portal.inc.php");
29 // Consider this a step towards converting the insurance form to layout-based.
30 // Faking it here makes things easier.
31 // Also note that some fields like SSN and most of the subscriber employer
32 // items have been omitted because they are not relevant for claims.
34 $insurance_layout = array(
35 array('field_id' => 'type',
39 'list_id' => 'insurance_types',
42 array('field_id' => 'date',
43 'title' => 'Effective Date',
45 'data_type' => '4', // Text-date
49 array('field_id' => 'provider',
50 'title' => 'Provider',
52 'data_type' => '16', // Insurance Providers
56 array('field_id' => 'plan_name',
57 'title' => 'Plan Name',
59 'data_type' => '2', // Text
63 array('field_id' => 'policy_number',
64 'title' => 'Policy Number',
66 'data_type' => '2', // Text
70 array('field_id' => 'group_number',
71 'title' => 'Group Number',
73 'data_type' => '2', // Text
77 array('field_id' => 'subscriber_employer',
78 'title' => 'Group Name',
80 'data_type' => '2', // Text
84 array('field_id' => 'subscriber_lname',
85 'title' => 'Subscriber Last Name',
87 'data_type' => '2', // Text
91 array('field_id' => 'subscriber_fname',
92 'title' => 'Subscriber First Name',
94 'data_type' => '2', // Text
98 array('field_id' => 'subscriber_mname',
99 'title' => 'Subscriber Middle Name',
101 'data_type' => '2', // Text
103 'edit_options' => '',
105 array('field_id' => 'subscriber_DOB',
106 'title' => 'Subscriber DOB',
108 'data_type' => '4', // Text-date
110 'edit_options' => '',
112 array('field_id' => 'subscriber_sex',
113 'title' => 'Subscriber Sex',
115 'data_type' => '1', // List
117 'edit_options' => '',
119 array('field_id' => 'subscriber_relationship',
120 'title' => 'Subscriber Relationship',
122 'data_type' => '1', // List
123 'list_id' => 'sub_relation',
124 'edit_options' => '',
126 array('field_id' => 'subscriber_street',
127 'title' => 'Subscriber Street',
129 'data_type' => '2', // Text
131 'edit_options' => '',
133 array('field_id' => 'subscriber_city',
134 'title' => 'Subscriber City',
136 'data_type' => '2', // Text
138 'edit_options' => '',
140 array('field_id' => 'subscriber_state',
141 'title' => 'Subscriber State',
143 'data_type' => '1', // List
144 'list_id' => 'state',
145 'edit_options' => '',
147 array('field_id' => 'subscriber_postal_code',
148 'title' => 'Subscriber Zip',
150 'data_type' => '2', // Text
152 'edit_options' => '',
154 array('field_id' => 'subscriber_phone',
155 'title' => 'Subscriber Phone',
157 'data_type' => '2', // Text
159 'edit_options' => '',
163 $postid = intval($_REQUEST['postid']);
165 if ($_POST['bn_save']) {
167 $ptid = intval($_POST['ptid']);
168 foreach ($insurance_layout as $frow) {
169 $data_type = $frow['data_type'];
170 $field_id = $frow['field_id'];
171 // newInsuranceData() does not escape for mysql so we have to do it here.
172 $newdata[$field_id] = add_escape_custom(get_layout_form_value($frow));
177 $newdata['provider'],
178 $newdata['policy_number'],
179 $newdata['group_number'],
180 $newdata['plan_name'],
181 $newdata['subscriber_lname'],
182 $newdata['subscriber_mname'],
183 $newdata['subscriber_fname'],
184 $newdata['subscriber_relationship'],
186 fixDate($newdata['subscriber_DOB']),
187 $newdata['subscriber_street'],
188 $newdata['subscriber_postal_code'],
189 $newdata['subscriber_city'],
190 $newdata['subscriber_state'],
191 '', // subscriber_country
192 $newdata['subscriber_phone'],
193 $newdata['subscriber_employer'],
194 '', // subscriber_employer_street
195 '', // subscriber_employer_city
196 '', // subscriber_employer_postal_code
197 '', // subscriber_employer_state
198 '', // subscriber_employer_country
200 $newdata['subscriber_sex'],
201 fixDate($newdata['date']),
202 'TRUE', // accept_assignment
205 // Finally, delete the request from the portal.
206 $result = cms_portal_call(array('action' => 'delpost', 'postid' => $postid));
207 if ($result['errmsg']) {
208 die(text($result['errmsg']));
210 echo "<html><body><script language='JavaScript'>\n";
211 echo "if (top.restoreSession) top.restoreSession(); else opener.top.restoreSession();\n";
212 echo "document.location.href = 'list_requests.php';\n";
213 echo "</script></body></html>\n";
217 // Get the portal request data.
218 if (!$postid) die(xlt('Request ID is missing!'));
219 $result = cms_portal_call(array('action' => 'getpost', 'postid' => $postid));
220 if ($result['errmsg']) {
221 die(text($result['errmsg']));
224 // Look up the patient in OpenEMR.
225 $ptid = lookup_openemr_patient($result['post']['user']);
229 <?php
html_header_show(); ?
>
230 <link rel
=stylesheet href
="<?php echo $css_header; ?>" type
="text/css">
232 <style type
="text/css">@import
url(../../library
/dynarch_calendar
.css
);</style
>
235 tr
.head
{ font
-size
:10pt
; background
-color
:#cccccc; text-align:center; }
236 tr
.detail
{ font
-size
:10pt
; background
-color
:#ddddff; }
237 td input
{ background
-color
:transparent
; }
241 <script type
="text/javascript" src
="../../library/textformat.js"></script
>
242 <script type
="text/javascript" src
="../../library/dynarch_calendar.js"></script
>
243 <?php
include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?
>
244 <script type
="text/javascript" src
="../../library/dynarch_calendar_setup.js"></script
>
245 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-2-2/index.js"></script
>
247 <script language
="JavaScript">
249 var mypcc
= '<?php echo $GLOBALS['phone_country_code
'] ?>';
251 function myRestoreSession() {
252 if (top
.restoreSession
) top
.restoreSession(); else opener
.top
.restoreSession();
256 // This capitalizes the first letter of each word in the passed input
257 // element. It also strips out extraneous spaces.
258 // Copied from demographics_full.php.
259 function capitalizeMe(elem
) {
260 var a
= elem
.value
.split(' ');
262 for(var i
= 0; i
< a
.length
; ++i
) {
263 if (a
[i
].length
> 0) {
264 if (s
.length
> 0) s +
= ' ';
265 s +
= a
[i
].charAt(0).toUpperCase() + a
[i
].substring(1);
271 function validate() {
272 var f
= document
.forms
[0];
280 <body
class="body_top">
283 <form method
='post' action
='insurance_form.php' onsubmit
='return validate()'>
285 <input type
='hidden' name
='ptid' value
='<?php echo attr($ptid); ?>' />
286 <input type
='hidden' name
='postid' value
='<?php echo attr($postid); ?>' />
288 <table width
='100%' cellpadding
='1' cellspacing
='2'>
290 <th align
='left'><?php
echo xlt('Field' ); ?
></th
>
291 <th align
='left'><?php
echo xlt('Current Value'); ?
></th
>
292 <th align
='left'><?php
echo xlt('New Value' ); ?
></th
>
296 $insrow = getInsuranceData($pid, $result['fields']['type']);
298 foreach ($insurance_layout as $lorow) {
299 $data_type = $lorow['data_type'];
300 $field_id = $lorow['field_id'];
302 $list_id = $lorow['list_id'];
303 $field_title = $lorow['title'];
306 if (isset($insrow[$field_id])) $currvalue = $insrow[$field_id];
309 if (isset($result['fields'][$field_id])) $newvalue = trim($result['fields'][$field_id]);
311 // Translate $newvalue for certain field types including lists.
312 if ($newvalue !== '') {
314 $tmp = sqlQuery("SELECT option_id FROM list_options WHERE " .
315 "list_id = ? AND title = ? AND activity = 1 ORDER BY option_id LIMIT 1",
316 array($list_id, $newvalue));
317 if (isset($tmp['option_id'])) $newvalue = $tmp['option_id'];
319 // Some data types like insurance provider are pretty hopeless, so let the display
320 // logic generate a "Fix me" message and the user can translate it.
323 echo " <tr class='detail'>\n";
324 echo " <td class='bold'>" . text($field_title) . "</td>\n";
326 echo generate_display_field($lorow, $currvalue);
329 generate_form_field($lorow, $newvalue);
338 <input type
='submit' name
='bn_save' value
='<?php echo xla('Save
and Delete Request
'); ?>' />
340 <input type
='button' value
='<?php echo xla('Back
'); ?>' onclick
="window.history.back()" />
341 <!-- Was
: onclick
="myRestoreSession();location='list_requests.php'" -->
346 <script language
="JavaScript">
348 // Fix inconsistently formatted phone numbers from the database.
349 var f
= document
.forms
[0];
350 if (f
.form_phone
) phonekeyup(f
.form_phone
, mypcc
);
352 // This is a by-product of generate_form_field().
353 <?php
echo $date_init; ?
>
357 <!-- include support
for the
list-add selectbox feature
-->
358 <?php
include $GLOBALS['fileroot'] . "/library/options_listadd.inc"; ?
>