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/options.inc.php");
26 require_once("portal.inc.php");
28 // Consider this a step towards converting the insurance form to layout-based.
29 // Faking it here makes things easier.
30 // Also note that some fields like SSN and most of the subscriber employer
31 // items have been omitted because they are not relevant for claims.
33 $insurance_layout = array(
34 array('field_id' => 'type',
38 'list_id' => 'insurance_types',
41 array('field_id' => 'date',
42 'title' => 'Effective Date',
44 'data_type' => '4', // Text-date
48 array('field_id' => 'provider',
49 'title' => 'Provider',
51 'data_type' => '16', // Insurance Providers
55 array('field_id' => 'plan_name',
56 'title' => 'Plan Name',
58 'data_type' => '2', // Text
62 array('field_id' => 'policy_number',
63 'title' => 'Policy Number',
65 'data_type' => '2', // Text
69 array('field_id' => 'group_number',
70 'title' => 'Group Number',
72 'data_type' => '2', // Text
76 array('field_id' => 'subscriber_employer',
77 'title' => 'Group Name',
79 'data_type' => '2', // Text
83 array('field_id' => 'subscriber_lname',
84 'title' => 'Subscriber Last Name',
86 'data_type' => '2', // Text
90 array('field_id' => 'subscriber_fname',
91 'title' => 'Subscriber First Name',
93 'data_type' => '2', // Text
97 array('field_id' => 'subscriber_mname',
98 'title' => 'Subscriber Middle Name',
100 'data_type' => '2', // Text
102 'edit_options' => '',
104 array('field_id' => 'subscriber_DOB',
105 'title' => 'Subscriber DOB',
107 'data_type' => '4', // Text-date
109 'edit_options' => '',
111 array('field_id' => 'subscriber_sex',
112 'title' => 'Subscriber Sex',
114 'data_type' => '1', // List
116 'edit_options' => '',
118 array('field_id' => 'subscriber_relationship',
119 'title' => 'Subscriber Relationship',
121 'data_type' => '1', // List
122 'list_id' => 'sub_relation',
123 'edit_options' => '',
125 array('field_id' => 'subscriber_street',
126 'title' => 'Subscriber Street',
128 'data_type' => '2', // Text
130 'edit_options' => '',
132 array('field_id' => 'subscriber_city',
133 'title' => 'Subscriber City',
135 'data_type' => '2', // Text
137 'edit_options' => '',
139 array('field_id' => 'subscriber_state',
140 'title' => 'Subscriber State',
142 'data_type' => '1', // List
143 'list_id' => 'state',
144 'edit_options' => '',
146 array('field_id' => 'subscriber_postal_code',
147 'title' => 'Subscriber Zip',
149 'data_type' => '2', // Text
151 'edit_options' => '',
153 array('field_id' => 'subscriber_phone',
154 'title' => 'Subscriber Phone',
156 'data_type' => '2', // Text
158 'edit_options' => '',
162 $postid = intval($_REQUEST['postid']);
164 if ($_POST['bn_save']) {
166 $ptid = intval($_POST['ptid']);
167 foreach ($insurance_layout as $frow) {
168 $data_type = $frow['data_type'];
169 $field_id = $frow['field_id'];
170 // newInsuranceData() does not escape for mysql so we have to do it here.
171 $newdata[$field_id] = add_escape_custom(get_layout_form_value($frow));
176 $newdata['provider'],
177 $newdata['policy_number'],
178 $newdata['group_number'],
179 $newdata['plan_name'],
180 $newdata['subscriber_lname'],
181 $newdata['subscriber_mname'],
182 $newdata['subscriber_fname'],
183 $newdata['subscriber_relationship'],
185 fixDate($newdata['subscriber_DOB']),
186 $newdata['subscriber_street'],
187 $newdata['subscriber_postal_code'],
188 $newdata['subscriber_city'],
189 $newdata['subscriber_state'],
190 '', // subscriber_country
191 $newdata['subscriber_phone'],
192 $newdata['subscriber_employer'],
193 '', // subscriber_employer_street
194 '', // subscriber_employer_city
195 '', // subscriber_employer_postal_code
196 '', // subscriber_employer_state
197 '', // subscriber_employer_country
199 $newdata['subscriber_sex'],
200 fixDate($newdata['date']),
201 'TRUE', // accept_assignment
204 // Finally, delete the request from the portal.
205 $result = cms_portal_call(array('action' => 'delpost', 'postid' => $postid));
206 if ($result['errmsg']) {
207 die(text($result['errmsg']));
209 echo "<html><body><script language='JavaScript'>\n";
210 echo "if (top.restoreSession) top.restoreSession(); else opener.top.restoreSession();\n";
211 echo "document.location.href = 'list_requests.php';\n";
212 echo "</script></body></html>\n";
216 // Get the portal request data.
217 if (!$postid) die(xlt('Request ID is missing!'));
218 $result = cms_portal_call(array('action' => 'getpost', 'postid' => $postid));
219 if ($result['errmsg']) {
220 die(text($result['errmsg']));
223 // Look up the patient in OpenEMR.
224 $ptid = lookup_openemr_patient($result['post']['user']);
228 <?php
html_header_show(); ?
>
229 <link rel
=stylesheet href
="<?php echo $css_header; ?>" type
="text/css">
231 <style type
="text/css">@import
url(../../library
/dynarch_calendar
.css
);</style
>
234 tr
.head
{ font
-size
:10pt
; background
-color
:#cccccc; text-align:center; }
235 tr
.detail
{ font
-size
:10pt
; background
-color
:#ddddff; }
236 td input
{ background
-color
:transparent
; }
240 <script type
="text/javascript" src
="../../library/textformat.js"></script
>
241 <script type
="text/javascript" src
="../../library/dynarch_calendar.js"></script
>
242 <?php
include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?
>
243 <script type
="text/javascript" src
="../../library/dynarch_calendar_setup.js"></script
>
244 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-2-2/index.js"></script
>
246 <script language
="JavaScript">
248 var mypcc
= '<?php echo $GLOBALS['phone_country_code
'] ?>';
250 function myRestoreSession() {
251 if (top
.restoreSession
) top
.restoreSession(); else opener
.top
.restoreSession();
255 // This capitalizes the first letter of each word in the passed input
256 // element. It also strips out extraneous spaces.
257 // Copied from demographics_full.php.
258 function capitalizeMe(elem
) {
259 var a
= elem
.value
.split(' ');
261 for(var i
= 0; i
< a
.length
; ++i
) {
262 if (a
[i
].length
> 0) {
263 if (s
.length
> 0) s +
= ' ';
264 s +
= a
[i
].charAt(0).toUpperCase() + a
[i
].substring(1);
270 function validate() {
271 var f
= document
.forms
[0];
279 <body
class="body_top">
282 <form method
='post' action
='insurance_form.php' onsubmit
='return validate()'>
284 <input type
='hidden' name
='ptid' value
='<?php echo attr($ptid); ?>' />
285 <input type
='hidden' name
='postid' value
='<?php echo attr($postid); ?>' />
287 <table width
='100%' cellpadding
='1' cellspacing
='2'>
289 <th align
='left'><?php
echo xlt('Field' ); ?
></th
>
290 <th align
='left'><?php
echo xlt('Current Value'); ?
></th
>
291 <th align
='left'><?php
echo xlt('New Value' ); ?
></th
>
295 $insrow = getInsuranceData($pid, $result['fields']['type']);
297 foreach ($insurance_layout as $lorow) {
298 $data_type = $lorow['data_type'];
299 $field_id = $lorow['field_id'];
301 $list_id = $lorow['list_id'];
302 $field_title = $lorow['title'];
305 if (isset($insrow[$field_id])) $currvalue = $insrow[$field_id];
308 if (isset($result['fields'][$field_id])) $newvalue = trim($result['fields'][$field_id]);
310 // Translate $newvalue for certain field types including lists.
311 if ($newvalue !== '') {
313 $tmp = sqlQuery("SELECT option_id FROM list_options WHERE " .
314 "list_id = ? AND title = ? AND activity = 1 ORDER BY option_id LIMIT 1",
315 array($list_id, $newvalue));
316 if (isset($tmp['option_id'])) $newvalue = $tmp['option_id'];
318 // Some data types like insurance provider are pretty hopeless, so let the display
319 // logic generate a "Fix me" message and the user can translate it.
322 echo " <tr class='detail'>\n";
323 echo " <td class='bold'>" . text($field_title) . "</td>\n";
325 echo generate_display_field($lorow, $currvalue);
328 generate_form_field($lorow, $newvalue);
337 <input type
='submit' name
='bn_save' value
='<?php echo xla('Save
and Delete Request
'); ?>' />
339 <input type
='button' value
='<?php echo xla('Back
'); ?>' onclick
="window.history.back()" />
340 <!-- Was
: onclick
="myRestoreSession();location='list_requests.php'" -->
345 <script language
="JavaScript">
347 // Fix inconsistently formatted phone numbers from the database.
348 var f
= document
.forms
[0];
349 if (f
.form_phone
) phonekeyup(f
.form_phone
, mypcc
);
351 // This is a by-product of generate_form_field().
352 <?php
echo $date_init; ?
>
356 <!-- include support
for the
list-add selectbox feature
-->
357 <?php
include $GLOBALS['fileroot'] . "/library/options_listadd.inc"; ?
>