Portal credential enhancements
[openemr.git] / interface / patient_file / summary / demographics_full.php
blob50e863bdff7e14d958e534ff124f8da445435f66
1 <?php
2 /**
3 * Edit demographics.
5 * @package OpenEMR
6 * @link http://www.open-emr.org
7 * @author Brady Miller <brady.g.miller@gmail.com>
8 * @copyright Copyright (c) 2017 Brady Miller <brady.g.miller@gmail.com>
9 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
12 require_once("../../globals.php");
13 require_once("$srcdir/acl.inc");
14 require_once("$srcdir/options.inc.php");
15 require_once("$srcdir/erx_javascript.inc.php");
16 require_once("$srcdir/validation/LBF_Validation.php");
17 require_once("$srcdir/patientvalidation.inc.php");
18 require_once("$srcdir/pid.inc");
19 require_once("$srcdir/patient.inc");
21 use OpenEMR\Common\Csrf\CsrfUtils;
22 use OpenEMR\Core\Header;
23 use OpenEMR\Events\PatientDemographics\UpdateEvent;
25 // Session pid must be right or bad things can happen when demographics are saved!
27 $set_pid = $_GET["set_pid"] ? $_GET["set_pid"] : $_GET["pid"];
28 if ($set_pid && $set_pid != $_SESSION["pid"]) {
29 setpid($set_pid);
32 $result = getPatientData($pid, "*, DATE_FORMAT(DOB,'%Y-%m-%d') as DOB_YMD");
33 $result2 = getEmployerData($pid);
35 // Check authorization.
36 if ($pid) {
37 // Create and fire the patient demographics update event
38 $updateEvent = new UpdateEvent($pid);
39 $updateEvent = $GLOBALS["kernel"]->getEventDispatcher()->dispatch(UpdateEvent::EVENT_HANDLE, $updateEvent, 10);
41 if (!$updateEvent->authorized() ||
42 !acl_check('patients', 'demo', '', 'write')) {
43 die(xlt('Updating demographics is not authorized.'));
46 if ($result['squad'] && ! acl_check('squads', $result['squad'])) {
47 die(xlt('You are not authorized to access this squad.'));
49 } else {
50 if (!acl_check('patients', 'demo', '', array('write','addonly'))) {
51 die(xlt('Adding demographics is not authorized.'));
55 $CPR = 4; // cells per row
57 // $statii = array('married','single','divorced','widowed','separated','domestic partner');
58 // $langi = getLanguages();
59 // $ethnoraciali = getEthnoRacials();
60 // $provideri = getProviderInfo();
61 if ($GLOBALS['insurance_information'] != '0') {
62 $insurancei = getInsuranceProvidersExtra();
63 } else {
64 $insurancei = getInsuranceProviders();
67 $fres = sqlStatement("SELECT * FROM layout_options " .
68 "WHERE form_id = 'DEM' AND uor > 0 " .
69 "ORDER BY group_id, seq");
71 <html>
72 <head>
74 <title><?php echo xlt('Edit Current Patient'); ?></title>
76 <?php Header::setupHeader(['datetime-picker','common','select2']); ?>
78 <style>
79 .form-control {
80 width: auto;
81 display: inline;
82 height: auto;
84 </style>
86 <?php include_once($GLOBALS['srcdir'] . "/options.js.php"); ?>
88 <script type="text/javascript">
90 // Support for beforeunload handler.
91 var somethingChanged = false;
93 $(document).ready(function(){
94 tabbify();
96 $(".medium_modal").on('click', function(e) {
97 e.preventDefault();e.stopPropagation();
98 let title = <?php echo xlj('Insurance Search/Select/Add'); ?>;
99 dlgopen('', '', 700, 460, '', title, {
100 buttons: [
101 {text: <?php echo xlj('Close'); ?>, close: true, style: 'default btn-sm'}
103 allowResize: true,
104 allowDrag: true,
105 dialogId: '',
106 type: 'iframe',
107 url: $(this).attr('href')
111 $('.datepicker').datetimepicker({
112 <?php $datetimepicker_timepicker = false; ?>
113 <?php $datetimepicker_showseconds = false; ?>
114 <?php $datetimepicker_formatInput = true; ?>
115 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
116 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
118 $('.datetimepicker').datetimepicker({
119 <?php $datetimepicker_timepicker = true; ?>
120 <?php $datetimepicker_showseconds = false; ?>
121 <?php $datetimepicker_formatInput = true; ?>
122 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
123 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
126 // Support for beforeunload handler.
127 $('.tab input, .tab select, .tab textarea').change(function() {
128 somethingChanged = true;
130 window.addEventListener("beforeunload", function (e) {
131 if (somethingChanged && !top.timed_out) {
132 var msg = <?php echo xlj('You have unsaved changes.'); ?>;
133 e.returnValue = msg; // Gecko, Trident, Chrome 34+
134 return msg; // Gecko, WebKit, Chrome <34
138 if (window.checkSkipConditions) {
139 checkSkipConditions();
143 var mypcc = <?php echo js_escape($GLOBALS['phone_country_code']); ?>;
145 //code used from http://tech.irt.org/articles/js037/
146 function replace(string,text,by) {
147 // Replaces text with by in string
148 var strLength = string.length, txtLength = text.length;
149 if ((strLength == 0) || (txtLength == 0)) return string;
151 var i = string.indexOf(text);
152 if ((!i) && (text != string.substring(0,txtLength))) return string;
153 if (i == -1) return string;
155 var newstr = string.substring(0,i) + by;
157 if (i+txtLength < strLength)
158 newstr += replace(string.substring(i+txtLength,strLength),text,by);
160 return newstr;
163 function upperFirst(string,text) {
164 return replace(string,text,text.charAt(0).toUpperCase() + text.substring(1,text.length));
167 <?php for ($i=1; $i<=3; $i++) { ?>
168 function auto_populate_employer_address<?php echo attr($i); ?>(){
169 var f = document.demographics_form;
170 if (f.form_i<?php echo attr($i); ?>subscriber_relationship.options[f.form_i<?php echo attr($i); ?>subscriber_relationship.selectedIndex].value == "self")
172 f.i<?php echo attr($i); ?>subscriber_fname.value=f.form_fname.value;
173 f.i<?php echo attr($i); ?>subscriber_mname.value=f.form_mname.value;
174 f.i<?php echo attr($i); ?>subscriber_lname.value=f.form_lname.value;
175 f.i<?php echo attr($i); ?>subscriber_street.value=f.form_street.value;
176 f.i<?php echo attr($i); ?>subscriber_city.value=f.form_city.value;
177 f.form_i<?php echo attr($i); ?>subscriber_state.value=f.form_state.value;
178 f.i<?php echo attr($i); ?>subscriber_postal_code.value=f.form_postal_code.value;
179 if (f.form_country_code)
180 f.form_i<?php echo attr($i); ?>subscriber_country.value=f.form_country_code.value;
181 f.i<?php echo attr($i); ?>subscriber_phone.value=f.form_phone_home.value;
182 f.i<?php echo attr($i); ?>subscriber_DOB.value=f.form_DOB.value;
183 if(typeof f.form_ss!="undefined")
185 f.i<?php echo attr($i); ?>subscriber_ss.value=f.form_ss.value;
187 f.form_i<?php echo attr($i); ?>subscriber_sex.value = f.form_sex.value;
188 f.i<?php echo attr($i); ?>subscriber_employer.value=f.form_em_name.value;
189 f.i<?php echo attr($i); ?>subscriber_employer_street.value=f.form_em_street.value;
190 f.i<?php echo attr($i); ?>subscriber_employer_city.value=f.form_em_city.value;
191 f.form_i<?php echo attr($i); ?>subscriber_employer_state.value=f.form_em_state.value;
192 f.i<?php echo attr($i); ?>subscriber_employer_postal_code.value=f.form_em_postal_code.value;
193 if (f.form_em_country)
194 f.form_i<?php echo attr($i); ?>subscriber_employer_country.value=f.form_em_country.value;
198 <?php } ?>
200 function popUp(URL) {
201 day = new Date();
202 id = day.getTime();
203 top.restoreSession();
204 eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=400,height=300,left = 440,top = 362');");
207 function checkNum () {
208 var re= new RegExp();
209 re = /^\d*\.?\d*$/;
210 str=document.demographics_form.monthly_income.value;
211 if(re.exec(str))
213 }else{
214 alert(<?php echo xlj('Please enter a monetary amount using only numbers and a decimal point.'); ?>);
218 // Indicates which insurance slot is being updated.
219 var insurance_index = 0;
221 // The OnClick handler for searching/adding the insurance company.
222 function ins_search(ins) {
223 insurance_index = ins;
224 return false;
226 function InsSaveClose() {
227 top.restoreSession();
228 document.location.reload();
230 // The ins_search.php window calls this to set the selected insurance.
231 function set_insurance(ins_id, ins_name) {
232 var thesel = document.forms[0]['i' + insurance_index + 'provider'];
233 var theopts = thesel.options; // the array of Option objects
234 var i = 0;
235 for (; i < theopts.length; ++i) {
236 if (theopts[i].value == ins_id) {
237 theopts[i].selected = true;
238 return;
241 // no matching option was found so create one, append it to the
242 // end of the list, and select it.
243 theopts[i] = new Option(ins_name, ins_id, false, true);
246 // This capitalizes the first letter of each word in the passed input
247 // element. It also strips out extraneous spaces.
248 function capitalizeMe(elem) {
249 var a = elem.value.split(' ');
250 var s = '';
251 for(var i = 0; i < a.length; ++i) {
252 if (a[i].length > 0) {
253 if (s.length > 0) s += ' ';
254 s += a[i].charAt(0).toUpperCase() + a[i].substring(1);
257 elem.value = s;
260 function divclick(cb, divid) {
261 var divstyle = document.getElementById(divid).style;
262 if (cb.checked) {
263 divstyle.display = 'block';
264 } else {
265 divstyle.display = 'none';
267 return true;
270 // Compute the length of a string without leading and trailing spaces.
271 function trimlen(s) {
272 var i = 0;
273 var j = s.length - 1;
274 for (; i <= j && s.charAt(i) == ' '; ++i);
275 for (; i <= j && s.charAt(j) == ' '; --j);
276 if (i > j) return 0;
277 return j + 1 - i;
280 function validate(f) {
281 var errCount = 0;
282 var errMsgs = new Array();
283 <?php generate_layout_validation('DEM'); ?>
285 var msg = "";
286 msg += <?php echo xlj('The following fields are required'); ?> + ":\n\n";
287 for ( var i = 0; i < errMsgs.length; i++ ) {
288 msg += errMsgs[i] + "\n";
290 msg += "\n" + <?php echo xlj('Please fill them in before continuing.'); ?>;
292 if ( errMsgs.length > 0 ) {
293 alert(msg);
296 //Misc Deceased Date Validation for Future Date
297 var dateVal = document.getElementById("form_deceased_date").value;
298 var currentDate;
299 var d = new Date();
300 month = '' + (d.getMonth() + 1),
301 day = '' + d.getDate(),
302 year = d.getFullYear();
303 if (month.length < 2) month = '0' + month;
304 if (day.length < 2) day = '0' + day;
305 currentDate = year+'-'+month+'-'+day;
306 if(dateVal > currentDate)
308 alert (<?php echo xlj("Deceased Date should not be greater than Today"); ?>);
309 return false;
312 //Patient Data validations
313 <?php if ($GLOBALS['erx_enable']) { ?>
314 alertMsg='';
315 for(i=0;i<f.length;i++){
316 if(f[i].type=='text' && f[i].value)
318 if(f[i].name == 'form_fname' || f[i].name == 'form_mname' || f[i].name == 'form_lname')
320 alertMsg += checkLength(f[i].name,f[i].value,35);
321 alertMsg += checkUsername(f[i].name,f[i].value);
323 else if(f[i].name == 'form_street' || f[i].name == 'form_city')
325 alertMsg += checkLength(f[i].name,f[i].value,35);
326 alertMsg += checkAlphaNumericExtended(f[i].name,f[i].value);
328 else if(f[i].name == 'form_phone_home')
330 alertMsg += checkPhone(f[i].name,f[i].value);
334 if(alertMsg)
336 alert(alertMsg);
337 return false;
339 <?php } ?>
340 //return false;
342 // Some insurance validation.
343 for (var i = 1; i <= 3; ++i) {
344 subprov = 'i' + i + 'provider';
345 if (!f[subprov] || f[subprov].selectedIndex <= 0) continue;
346 var subpfx = 'i' + i + 'subscriber_';
347 var subrelat = f['form_' + subpfx + 'relationship'];
348 var samename =
349 f[subpfx + 'fname'].value == f.form_fname.value &&
350 f[subpfx + 'mname'].value == f.form_mname.value &&
351 f[subpfx + 'lname'].value == f.form_lname.value;
352 var ss_regexp=/[0-9][0-9][0-9]-?[0-9][0-9]-?[0-9][0-9][0-9][0-9]/;
353 var samess=true;
354 var ss_valid=false;
355 if(typeof f.form_ss!="undefined")
357 samess = f[subpfx + 'ss'].value == f.form_ss.value;
358 ss_valid=ss_regexp.test(f[subpfx + 'ss'].value) && ss_regexp.test(f.form_ss.value);
360 if (subrelat.options[subrelat.selectedIndex].value == "self") {
361 if (!samename) {
362 if (!confirm(<?php echo xlj('Subscriber relationship is self but name is different! Is this really OK?'); ?>))
363 return false;
365 if (!samess && ss_valid) {
366 if(!confirm(<?php echo js_escape(xl('Subscriber relationship is self but SS number is different!')." ".xl("Is this really OK?")); ?>))
367 return false;
369 } // end self
370 else {
371 if (samename) {
372 if (!confirm(<?php echo xlj('Subscriber relationship is not self but name is the same! Is this really OK?'); ?>))
373 return false;
375 if (samess && ss_valid) {
376 if(!confirm(<?php echo js_escape(xl('Subscriber relationship is not self but SS number is the same!')." ".xl("Is this really OK?")); ?>))
377 return false;
379 } // end not self
380 } // end for
382 return errMsgs.length < 1;
387 // Onkeyup handler for policy number. Allows only A-Z and 0-9.
388 function policykeyup(e) {
389 var v = e.value.toUpperCase();
390 var filteredString="";
391 for (var i = 0; i < v.length; ++i) {
392 var c = v.charAt(i);
393 if ((c >= '0' && c <= '9') ||
394 (c >= 'A' && c <= 'Z') ||
395 (c == '*') ||
396 (c == '-') ||
397 (c == '_') ||
398 (c == '(') ||
399 (c == ')') ||
400 (c == '#'))
402 filteredString+=c;
405 e.value = filteredString;
406 return;
409 // Added 06/2009 by BM to make compatible with list_options table and functions - using jquery
410 $(function() {
412 <?php for ($i=1; $i<=3; $i++) { ?>
413 $("#form_i<?php echo attr($i); ?>subscriber_relationship").change(function() { auto_populate_employer_address<?php echo attr($i); ?>(); });
414 <?php } ?>
418 </script>
419 </head>
421 <?php
422 /*Get the constraint from the DB-> LBF forms accordinf the form_id*/
423 $constraints = LBF_Validation::generate_validate_constraints("DEM");
425 <script> var constraints = <?php echo $constraints;?>; </script>
427 <body class="body_top">
429 <form action='demographics_save.php' name='demographics_form' id="DEM" method='post' onsubmit="submitme(<?php echo $GLOBALS['new_validate'] ? 1 : 0;?>,event,'DEM',constraints)">
430 <input type="hidden" name="csrf_token_form" value="<?php echo attr(CsrfUtils::collectCsrfToken()); ?>" />
431 <input type='hidden' name='mode' value='save' />
432 <input type='hidden' name='db_id' value="<?php echo attr($result['id']); ?>" />
434 <div class="container-fluid">
435 <div class="row">
436 <div class="col-xs-12">
437 <div class="page-header">
438 <h2><?php echo xlt('Edit Current Patient');?></h2>
439 </div>
440 </div>
441 <div class="col-xs-12">
442 <div class="btn-group">
443 <button type="submit" class="btn btn-default btn-save" id="submit_btn" disabled="disabled" value="<?php echo xla('Save'); ?>">
444 <?php echo xlt('Save'); ?>
445 </button>
446 <a class="btn btn-link btn-cancel" href="demographics.php" onclick="top.restoreSession()">
447 <?php echo xlt('Cancel'); ?>
448 </a>
449 </div>
450 <hr>
451 </div>
452 </div>
453 </div>
454 <?php
456 function end_cell()
458 global $item_count, $cell_count;
459 if ($item_count > 0) {
460 echo "</td>";
461 $item_count = 0;
465 function end_row()
467 global $cell_count, $CPR;
468 end_cell();
469 if ($cell_count > 0) {
470 for (; $cell_count < $CPR; ++$cell_count) {
471 echo "<td></td>";
474 echo "</tr>\n";
475 $cell_count = 0;
479 function end_group()
481 global $last_group;
482 if (strlen($last_group) > 0) {
483 end_row();
484 echo " </table>\n";
485 echo "</div>\n";
489 $last_group = '';
490 $cell_count = 0;
491 $item_count = 0;
492 $display_style = 'block';
494 $group_seq=0; // this gives the DIV blocks unique IDs
496 $condition_str = '';
498 <br>
499 <div class="section-header">
500 <span class="text"><b> <?php echo xlt("Demographics")?></b></span>
501 </div>
503 <div id="DEM" >
505 <ul class="tabNav">
506 <?php display_layout_tabs('DEM', $result, $result2); ?>
507 </ul>
509 <div class="tabContainer">
510 <?php display_layout_tabs_data_editable('DEM', $result, $result2); ?>
511 </div>
512 </div>
513 <br>
515 <div id="DEM" >
518 <?php
519 if (! $GLOBALS['simplified_demographics']) {
520 $insurance_headings = array(xl("Primary Insurance Provider"), xl("Secondary Insurance Provider"), xl("Tertiary Insurance provider"));
521 $insurance_info = array();
522 $insurance_info[1] = getInsuranceData($pid, "primary");
523 $insurance_info[2] = getInsuranceData($pid, "secondary");
524 $insurance_info[3] = getInsuranceData($pid, "tertiary");
527 <div class="section-header">
528 <span class="text"><b><?php echo xlt("Insurance")?></b></span>
529 </div>
530 <div id="INSURANCE" >
531 <ul class="tabNav">
532 <?php
533 foreach (array('primary','secondary','tertiary') as $instype) {
534 ?><li <?php echo $instype == 'primary' ? 'class="current"' : '' ?>><a href="#"><?php $CapInstype=ucfirst($instype);
535 echo xlt($CapInstype); ?></a></li><?php
538 </ul>
540 <div class="tabContainer">
542 <?php
543 for ($i=1; $i<=3; $i++) {
544 $result3 = $insurance_info[$i];
547 <div class="tab <?php echo $i == 1 ? 'current': '' ?>" style='height:auto;width:auto'> <!---display icky, fix to auto-->
549 <div class="row">
550 <div class="col-md-6">
551 <table border="0">
553 <tr>
554 <td valign='top'>
555 <label class='required'><?php echo text($insurance_headings[$i -1])."&nbsp;"?></label>
556 </td>
557 <td class='required'>:</td>
558 <td>
559 <a href="../../practice/ins_search.php" class="medium_modal css_button" onclick="ins_search(<?php echo attr_js($i); ?>)">
560 <span><?php echo xlt('Search/Add') ?></span>
561 </a>
562 <select name="i<?php echo attr($i); ?>provider" class="form-control sel2" style="width: 300;">
563 <option value=""><?php echo xlt('Unassigned'); ?></option>
564 <?php
565 foreach ($insurancei as $iid => $iname) {
566 echo "<option value='" . attr($iid) . "'";
567 if (strtolower($iid) == strtolower($result3["provider"])) {
568 echo " selected";
571 echo ">" . text($iname) . "</option>\n";
574 </select>
576 </td>
577 </tr>
579 <tr>
580 <td>
581 <label class='required'><?php echo xlt('Plan Name'); ?> </label>
582 </td>
583 <td class='required'>:</td>
584 <td>
585 <input type='entry' class='form-control' size='20' name='i<?php echo attr($i); ?>plan_name' value="<?php echo attr($result3["plan_name"]); ?>"
586 onchange="capitalizeMe(this);" />&nbsp;&nbsp;
587 </td>
588 </tr>
590 <tr>
591 <td>
592 <label class='required'><?php echo xlt('Effective Date'); ?></label>
593 </td>
594 <td class='required'>:</td>
595 <td>
596 <input type='entry' size='16' class='datepicker form-control' id='i<?php echo attr($i); ?>effective_date' name='i<?php echo attr($i); ?>effective_date'
597 value='<?php echo attr(oeFormatShortDate($result3['date'])); ?>'
599 </td>
600 </tr>
602 <tr>
603 <td><label class=required><?php echo xlt('Policy Number'); ?></label></td>
604 <td class='required'>:</td>
605 <td><input type='entry' class='form-control' size='16' name='i<?php echo attr($i); ?>policy_number' value="<?php echo attr($result3["policy_number"]); ?>"
606 onkeyup='policykeyup(this)'></td>
607 </tr>
609 <tr>
610 <td><label class=required><?php echo xlt('Group Number'); ?></label></td>
611 <td class='required'>:</td>
612 <td><input type=entry class='form-control' size=16 name=i<?php echo attr($i); ?>group_number value="<?php echo attr($result3["group_number"]); ?>" onkeyup='policykeyup(this)'></td>
613 </tr>
615 <tr<?php if ($GLOBALS['omit_employers']) {
616 echo " style='display:none'";
617 } ?>>
618 <td class='required'><?php echo xlt('Subscriber Employer (SE)'); ?><br><label style='font-weight:normal'>
619 (<?php echo xlt('if unemployed enter Student'); ?>,<br><?php echo xlt('PT Student, or leave blank'); ?>) </label></td>
620 <td class='required'>:</td>
621 <td><input type=entry class='form-control' size=25 name=i<?php echo attr($i); ?>subscriber_employer
622 value="<?php echo attr($result3["subscriber_employer"]); ?>"
623 onchange="capitalizeMe(this);" /></td>
624 </tr>
626 <tr<?php if ($GLOBALS['omit_employers']) {
627 echo " style='display:none'";
628 } ?>>
629 <td><label class=required><?php echo xlt('SE Address'); ?></label></td>
630 <td class='required'>:</td>
631 <td><input type=entry class='form-control' size=25 name=i<?php echo attr($i); ?>subscriber_employer_street
632 value="<?php echo attr($result3["subscriber_employer_street"]); ?>"
633 onchange="capitalizeMe(this);" /></td>
634 </tr>
636 <tr<?php if ($GLOBALS['omit_employers']) {
637 echo " style='display:none'";
638 } ?>>
639 <td colspan="3">
640 <table>
641 <tr>
642 <td><label class=required><?php echo xlt('SE City'); ?>: </label></td>
643 <td><input type=entry class='form-control' size=15 name=i<?php echo attr($i); ?>subscriber_employer_city
644 value="<?php echo attr($result3["subscriber_employer_city"]); ?>"
645 onchange="capitalizeMe(this);" /></td>
646 <td><label class=required><?php echo ($GLOBALS['phone_country_code'] == '1') ? xlt('SE State') : xlt('SE Locality') ?>: </label></td>
647 <td>
648 <?php
649 // Modified 7/2009 by BM to incorporate data types
650 generate_form_field(array('data_type'=>$GLOBALS['state_data_type'],'field_id'=>('i'.$i.'subscriber_employer_state'),'list_id'=>$GLOBALS['state_list'],'fld_length'=>'15','max_length'=>'63','edit_options'=>'C'), $result3['subscriber_employer_state']);
652 </td>
653 </tr>
654 <tr>
655 <td><label class=required><?php echo ($GLOBALS['phone_country_code'] == '1') ? xlt('SE Zip Code') : xlt('SE Postal Code') ?>: </label></td>
656 <td><input type=entry class='form-control' size=15 name=i<?php echo attr($i); ?>subscriber_employer_postal_code value="<?php echo attr($result3["subscriber_employer_postal_code"]); ?>"></td>
657 <td><label class=required><?php echo xlt('SE Country'); ?>: </label></td>
658 <td>
659 <?php
660 // Modified 7/2009 by BM to incorporate data types
661 generate_form_field(array('data_type'=>$GLOBALS['country_data_type'],'field_id'=>('i'.$i.'subscriber_employer_country'),'list_id'=>$GLOBALS['country_list'],'fld_length'=>'10','max_length'=>'63','edit_options'=>'C'), $result3['subscriber_employer_country']);
663 </td>
664 </tr>
665 </table>
666 </td>
667 </tr>
669 </table>
670 </div>
672 <div class="col-md-6">
673 <table border="0">
674 <tr>
675 <td><label class=required><?php echo xlt('Relationship'); ?></label></td>
676 <td class=required>:</td>
677 <td colspan=3><?php
678 // Modified 6/2009 by BM to use list_options and function
679 generate_form_field(array('data_type'=>1,'field_id'=>('i'.$i.'subscriber_relationship'),'list_id'=>'sub_relation','empty_title'=>' '), $result3['subscriber_relationship']);
682 <a href="javascript:popUp('browse.php?browsenum=<?php echo attr_url($i); ?>')" class=text>(<?php echo xlt('Browse'); ?>)</a></td>
683 <td></td><td></td><td></td><td></td>
684 </tr>
685 <tr>
686 <td width=120><label class=required><?php echo xlt('Subscriber'); ?> </label></td>
687 <td class=required>:</td>
688 <td colspan=3><input type=entry class='form-control'size=10 name=i<?php echo attr($i); ?>subscriber_fname value="<?php echo attr($result3["subscriber_fname"]); ?>" onchange="capitalizeMe(this);" />
689 <input type=entry class='form-control' size=3 name=i<?php echo attr($i); ?>subscriber_mname value="<?php echo attr($result3["subscriber_mname"]); ?>" onchange="capitalizeMe(this);" />
690 <input type=entry class='form-control' size=10 name=i<?php echo attr($i); ?>subscriber_lname value="<?php echo attr($result3["subscriber_lname"]); ?>" onchange="capitalizeMe(this);" /></td>
691 <td></td><td></td><td></td><td></td>
692 </tr>
693 <tr>
694 <td><label class=bold><?php echo xlt('D.O.B.'); ?> </label></td>
695 <td class=required>:</td>
696 <td><input type='entry' size='11' class='datepicker form-control' id='i<?php echo attr($i); ?>subscriber_DOB' name='i<?php echo attr($i); ?>subscriber_DOB' value='<?php echo attr(oeFormatShortDate($result3['subscriber_DOB'])); ?>' />
697 </td>
698 <td><label class=bold><?php echo xlt('Sex'); ?>: </label></td>
699 <td><?php
700 // Modified 6/2009 by BM to use list_options and function
701 generate_form_field(array('data_type'=>1,'field_id'=>('i'.$i.'subscriber_sex'),'list_id'=>'sex'), $result3['subscriber_sex']);
703 </td>
704 <td></td><td></td> <td></td><td></td>
705 </tr>
706 <tr>
707 <td class=leftborder><label class=bold><?php echo xlt('S.S.'); ?> </label></td>
708 <td class=required>:</td>
709 <td><input type=entry class='form-control' size=11 name=i<?php echo attr($i); ?>subscriber_ss value="<?php echo attr(trim($result3["subscriber_ss"])); ?>"></td>
710 </tr>
712 <tr>
713 <td><label class=required><?php echo xlt('Subscriber Address'); ?> </label></td>
714 <td class=required>:</td>
715 <td><input type=entry class='form-control' size=20 name=i<?php echo attr($i); ?>subscriber_street value="<?php echo attr($result3["subscriber_street"]); ?>" onchange="capitalizeMe(this);" /></td>
717 <td><label class=required><?php echo ($GLOBALS['phone_country_code'] == '1') ? xlt('State') : xlt('Locality') ?>: </label></td>
718 <td>
719 <?php
720 // Modified 7/2009 by BM to incorporate data types
721 generate_form_field(array('data_type'=>$GLOBALS['state_data_type'],'field_id'=>('i'.$i.'subscriber_state'),'list_id'=>$GLOBALS['state_list'],'fld_length'=>'15','max_length'=>'63','edit_options'=>'C'), $result3['subscriber_state']);
723 </td>
724 </tr>
725 <tr>
726 <td class=leftborder><label class=required><?php echo xlt('City'); ?></label></td>
727 <td class=required>:</td>
728 <td><input type=entry class='form-control' size=11 name=i<?php echo attr($i); ?>subscriber_city value="<?php echo attr($result3["subscriber_city"]); ?>" onchange="capitalizeMe(this);" /></td><td class=leftborder><label class='required'<?php if ($GLOBALS['omit_employers']) {
729 echo " style='display:none'";
730 } ?>><?php echo xlt('Country'); ?>: </label></td><td>
731 <?php
732 // Modified 7/2009 by BM to incorporate data types
733 generate_form_field(array('data_type'=>$GLOBALS['country_data_type'],'field_id'=>('i'.$i.'subscriber_country'),'list_id'=>$GLOBALS['country_list'],'fld_length'=>'10','max_length'=>'63','edit_options'=>'C'), $result3['subscriber_country']);
735 </td>
736 </tr>
737 <tr>
738 <td><label class=required><?php echo ($GLOBALS['phone_country_code'] == '1') ? xlt('Zip Code') : xlt('Postal Code') ?> </label></td>
739 <td class=required>:</td><td><input type=entry class='form-control' size=10 name=i<?php echo attr($i); ?>subscriber_postal_code value="<?php echo attr($result3["subscriber_postal_code"]); ?>"></td>
741 <td colspan=2>
742 </td><td></td>
743 </tr>
744 <tr>
745 <td><label class=bold><?php echo xlt('Subscriber Phone'); ?></label></td>
746 <td class=required>:</td>
747 <td><input type='text' class='form-control' size='20' name='i<?php echo attr($i); ?>subscriber_phone' value='<?php echo attr($result3["subscriber_phone"]); ?>' onkeyup='phonekeyup(this,mypcc)' /></td>
748 <td colspan=2><label class=bold><?php echo xlt('CoPay'); ?>: <input type=text class='form-control' size="6" name=i<?php echo attr($i); ?>copay value="<?php echo attr($result3["copay"]); ?>"></label></td>
749 <td colspan=2>
750 </td><td></td><td></td>
751 </tr>
752 <tr>
753 <td colspan=0><label class='required'><?php echo xlt('Accept Assignment'); ?></label></td>
754 <td class=required>:</td>
755 <td colspan=2>
756 <select class='form-control' name=i<?php echo attr($i); ?>accept_assignment>
757 <option value="TRUE" <?php if (strtoupper($result3["accept_assignment"]) == "TRUE") {
758 echo "selected";
759 }?>><?php echo xlt('YES'); ?></option>
760 <option value="FALSE" <?php if (strtoupper($result3["accept_assignment"]) == "FALSE") {
761 echo "selected";
762 }?>><?php echo xlt('NO'); ?></option>
763 </select>
764 </td>
765 <td></td><td></td>
766 <td colspan=2>
767 </td><td></td>
768 </tr>
769 <tr>
770 <td><label class='bold'><?php echo xlt('Secondary Medicare Type'); ?></label></td>
771 <td class='bold'>:</td>
772 <td colspan='6'>
773 <select class='form-control sel2' name=i<?php echo attr($i); ?>policy_type>
774 <?php
775 foreach ($policy_types as $key => $value) {
776 echo " <option value ='" . attr($key) . "'";
777 if ($key == $result3['policy_type']) {
778 echo " selected";
781 echo ">" . text($value) . "</option>\n";
784 </select>
785 </td>
786 </tr>
787 </table>
789 </div>
790 </div>
792 </div>
794 <?php
795 } //end insurer for loop ?>
797 </div>
798 </div>
800 <?php } // end of "if not simplified_demographics" ?>
801 </div></div>
803 </form>
805 <br>
807 <script language="JavaScript">
809 // Array of skip conditions for the checkSkipConditions() function.
810 var skipArray = [
811 <?php echo $condition_str; ?>
814 // hard code validation for old validation, in the new validation possible to add match rules
815 <?php if ($GLOBALS['new_validate'] == 0) { ?>
816 // fix inconsistently formatted phone numbers from the database
817 var f = document.forms[0];
818 if (f.form_phone_contact) phonekeyup(f.form_phone_contact,mypcc);
819 if (f.form_phone_home ) phonekeyup(f.form_phone_home ,mypcc);
820 if (f.form_phone_biz ) phonekeyup(f.form_phone_biz ,mypcc);
821 if (f.form_phone_cell ) phonekeyup(f.form_phone_cell ,mypcc);
823 <?php if (! $GLOBALS['simplified_demographics']) { ?>
824 phonekeyup(f.i1subscriber_phone,mypcc);
825 phonekeyup(f.i2subscriber_phone,mypcc);
826 phonekeyup(f.i3subscriber_phone,mypcc);
827 <?php } ?>
829 <?php }?>
831 <?php if ($set_pid) { ?>
832 parent.left_nav.setPatient(<?php echo js_escape($result['fname'] . " " . $result['lname']) . "," . js_escape($pid) . "," . js_escape($result['pubpid']) . ",''," . js_escape(" " . xl('DOB') . ": " . oeFormatShortDate($result['DOB_YMD']) . " " . xl('Age') . ": " . getPatientAgeDisplay($result['DOB_YMD'])); ?>);
833 <?php } ?>
835 <?php echo $date_init; ?>
836 </script>
838 <!-- include support for the list-add selectbox feature -->
839 <?php include $GLOBALS['fileroot']."/library/options_listadd.inc"; ?>
841 <?php /*Include the validation script and rules for this form*/
842 $form_id="DEM";
843 //LBF forms use the new validation depending on the global value
844 $use_validate_js=$GLOBALS['new_validate'];
847 <?php include_once("$srcdir/validation/validation_script.js.php");?>
850 </body>
851 <script language='JavaScript'>
852 var duplicateFieldsArray=[];
854 //This code deals with demographics before save action -
855 <?php if (($GLOBALS['gbl_edit_patient_form'] == '1') && (checkIfPatientValidationHookIsActive())) :?>
856 //Use the Zend patient validation hook.
857 //TODO - get the edit part of patient validation hook to work smoothly and then
858 // remove the closeBeforeOpening=1 in the url below.
860 var f = $("form");
862 // Use hook to open the controller and get the new patient validation .
863 // when no params are sent this window will be closed from the zend controller.
864 var url ='<?php echo $GLOBALS['web_root']."/interface/modules/zend_modules/public/patientvalidation";?>';
865 $("#submit_btn").attr("name","btnSubmit");
866 $("#submit_btn").attr("id","btnSubmit");
867 $("#btnSubmit").click(function( event ) {
869 top.restoreSession();
871 if(!submitme(<?php echo $GLOBALS['new_validate'] ? 1 : 0;?>,event,'DEM',constraints)){
872 event.preventDefault();
873 return;
875 somethingChanged = false;
876 <?php
877 // D in edit_options indicates the field is used in duplication checking.
878 // This constructs a list of the names of those fields.
879 $mflist = "";
880 $mfres = sqlStatement("SELECT field_id FROM layout_options " .
881 "WHERE form_id = 'DEM' AND uor > 0 AND field_id != '' AND " .
882 "(edit_options LIKE '%D%' OR edit_options LIKE '%E%') " .
883 "ORDER BY group_id, seq");
884 while ($mfrow = sqlFetchArray($mfres)) {
885 $field_id = $mfrow['field_id'];
886 if (strpos($field_id, 'em_') === 0) {
887 continue;
890 if (!empty($mflist)) {
891 $mflist .= ",";
894 $mflist .= js_escape($field_id);
895 } ?>
897 var flds = new Array(<?php echo $mflist; ?>);
898 var separator = '?';
899 var valueIsChanged=false;
900 for (var i = 0; i < flds.length; ++i) {
901 var fval = $('#form_' + flds[i]).val();
902 if(duplicateFieldsArray['#form_' + flds[i]]!=fval) {
903 valueIsChanged = true;
907 if (fval && fval != '') {
908 url += separator;
909 separator = '&';
910 url += 'mf_' + flds[i] + '=' + encodeURIComponent(fval);
915 //Only if check for duplicates values are changed open the popup hook screen
916 if(valueIsChanged) {
917 event.preventDefault();
918 //("value has changed for duplicate check inputs");
919 url += '&page=edit&closeBeforeOpening=1&mf_id=' + encodeURIComponent($("[name='db_id']").val());
920 dlgopen(url, '_blank', 700, 500);
922 else {//other wise submit me is a success just submit the form
923 $('#DEM').submit();
927 <?php endif;?>
929 $(document).ready(function(){
930 //When document is ready collect all the values Marked with D (check duplicate) stored in the db into array duplicateFieldsArray.
931 var flds = new Array(<?php echo $mflist; ?>);
932 for (var i = 0; i < flds.length; ++i) {
933 var fval = $('#form_' + flds[i]).val();
934 duplicateFieldsArray['#form_' + flds[i]] = fval;
936 $(".sel2").select2({
937 <?php require($GLOBALS['srcdir'] . '/js/xl/select2.js.php'); ?>
940 </script>
943 </html>