Internationalization by OpenEMR of the select2 asset
[openemr.git] / interface / patient_file / summary / demographics_full.php
blobffc87754d354038a7a8fdb5d3b85a9133403e70c
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");
19 use OpenEMR\Core\Header;
21 // Session pid must be right or bad things can happen when demographics are saved!
23 include_once("$srcdir/pid.inc");
24 $set_pid = $_GET["set_pid"] ? $_GET["set_pid"] : $_GET["pid"];
25 if ($set_pid && $set_pid != $_SESSION["pid"]) {
26 setpid($set_pid);
29 include_once("$srcdir/patient.inc");
31 $result = getPatientData($pid, "*, DATE_FORMAT(DOB,'%Y-%m-%d') as DOB_YMD");
32 $result2 = getEmployerData($pid);
34 // Check authorization.
35 if ($pid) {
36 if (!acl_check('patients', 'demo', '', 'write')) {
37 die(xlt('Updating demographics is not authorized.'));
40 if ($result['squad'] && ! acl_check('squads', $result['squad'])) {
41 die(xlt('You are not authorized to access this squad.'));
43 } else {
44 if (!acl_check('patients', 'demo', '', array('write','addonly'))) {
45 die(xlt('Adding demographics is not authorized.'));
49 $CPR = 4; // cells per row
51 // $statii = array('married','single','divorced','widowed','separated','domestic partner');
52 // $langi = getLanguages();
53 // $ethnoraciali = getEthnoRacials();
54 // $provideri = getProviderInfo();
55 if ($GLOBALS['insurance_information'] != '0') {
56 $insurancei = getInsuranceProvidersExtra();
57 } else {
58 $insurancei = getInsuranceProviders();
61 $fres = sqlStatement("SELECT * FROM layout_options " .
62 "WHERE form_id = 'DEM' AND uor > 0 " .
63 "ORDER BY group_id, seq");
65 <html>
66 <head>
68 <title><?php echo xlt('Edit Current Patient'); ?></title>
70 <?php Header::setupHeader(['datetime-picker','common','select2']); ?>
72 <style>
73 .form-control {
74 width: auto;
75 display: inline;
76 height: auto;
78 </style>
80 <?php include_once("{$GLOBALS['srcdir']}/options.js.php"); ?>
82 <script type="text/javascript">
84 // Support for beforeunload handler.
85 var somethingChanged = false;
87 $(document).ready(function(){
88 tabbify();
90 $(".medium_modal").on('click', function(e) {
91 e.preventDefault();e.stopPropagation();
92 let title = '<?php echo xla('Insurance Search/Select/Add'); ?>';
93 dlgopen('', '', 700, 460, '', title, {
94 buttons: [
95 {text: '<?php echo xla('Close'); ?>', close: true, style: 'default btn-sm'}
97 allowResize: true,
98 allowDrag: true,
99 dialogId: '',
100 type: 'iframe',
101 url: $(this).attr('href')
105 $('.datepicker').datetimepicker({
106 <?php $datetimepicker_timepicker = false; ?>
107 <?php $datetimepicker_showseconds = false; ?>
108 <?php $datetimepicker_formatInput = true; ?>
109 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
110 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
112 $('.datetimepicker').datetimepicker({
113 <?php $datetimepicker_timepicker = true; ?>
114 <?php $datetimepicker_showseconds = false; ?>
115 <?php $datetimepicker_formatInput = true; ?>
116 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
117 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
120 // Support for beforeunload handler.
121 $('.tab input, .tab select, .tab textarea').change(function() {
122 somethingChanged = true;
124 window.addEventListener("beforeunload", function (e) {
125 if (somethingChanged && !top.timed_out) {
126 var msg = "<?php echo xls('You have unsaved changes.'); ?>";
127 e.returnValue = msg; // Gecko, Trident, Chrome 34+
128 return msg; // Gecko, WebKit, Chrome <34
132 if (window.checkSkipConditions) {
133 checkSkipConditions();
137 var mypcc = '<?php echo $GLOBALS['phone_country_code'] ?>';
139 //code used from http://tech.irt.org/articles/js037/
140 function replace(string,text,by) {
141 // Replaces text with by in string
142 var strLength = string.length, txtLength = text.length;
143 if ((strLength == 0) || (txtLength == 0)) return string;
145 var i = string.indexOf(text);
146 if ((!i) && (text != string.substring(0,txtLength))) return string;
147 if (i == -1) return string;
149 var newstr = string.substring(0,i) + by;
151 if (i+txtLength < strLength)
152 newstr += replace(string.substring(i+txtLength,strLength),text,by);
154 return newstr;
157 function upperFirst(string,text) {
158 return replace(string,text,text.charAt(0).toUpperCase() + text.substring(1,text.length));
161 <?php for ($i=1; $i<=3; $i++) { ?>
162 function auto_populate_employer_address<?php echo $i ?>(){
163 var f = document.demographics_form;
164 if (f.form_i<?php echo $i?>subscriber_relationship.options[f.form_i<?php echo $i?>subscriber_relationship.selectedIndex].value == "self")
166 f.i<?php echo $i?>subscriber_fname.value=f.form_fname.value;
167 f.i<?php echo $i?>subscriber_mname.value=f.form_mname.value;
168 f.i<?php echo $i?>subscriber_lname.value=f.form_lname.value;
169 f.i<?php echo $i?>subscriber_street.value=f.form_street.value;
170 f.i<?php echo $i?>subscriber_city.value=f.form_city.value;
171 f.form_i<?php echo $i?>subscriber_state.value=f.form_state.value;
172 f.i<?php echo $i?>subscriber_postal_code.value=f.form_postal_code.value;
173 if (f.form_country_code)
174 f.form_i<?php echo $i?>subscriber_country.value=f.form_country_code.value;
175 f.i<?php echo $i?>subscriber_phone.value=f.form_phone_home.value;
176 f.i<?php echo $i?>subscriber_DOB.value=f.form_DOB.value;
177 if(typeof f.form_ss!="undefined")
179 f.i<?php echo $i?>subscriber_ss.value=f.form_ss.value;
181 f.form_i<?php echo $i?>subscriber_sex.value = f.form_sex.value;
182 f.i<?php echo $i?>subscriber_employer.value=f.form_em_name.value;
183 f.i<?php echo $i?>subscriber_employer_street.value=f.form_em_street.value;
184 f.i<?php echo $i?>subscriber_employer_city.value=f.form_em_city.value;
185 f.form_i<?php echo $i?>subscriber_employer_state.value=f.form_em_state.value;
186 f.i<?php echo $i?>subscriber_employer_postal_code.value=f.form_em_postal_code.value;
187 if (f.form_em_country)
188 f.form_i<?php echo $i?>subscriber_employer_country.value=f.form_em_country.value;
192 <?php } ?>
194 function popUp(URL) {
195 day = new Date();
196 id = day.getTime();
197 top.restoreSession();
198 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');");
201 function checkNum () {
202 var re= new RegExp();
203 re = /^\d*\.?\d*$/;
204 str=document.demographics_form.monthly_income.value;
205 if(re.exec(str))
207 }else{
208 alert("<?php echo xls('Please enter a monetary amount using only numbers and a decimal point.'); ?>");
212 // Indicates which insurance slot is being updated.
213 var insurance_index = 0;
215 // The OnClick handler for searching/adding the insurance company.
216 function ins_search(ins) {
217 insurance_index = ins;
218 return false;
220 function InsSaveClose() {
221 top.restoreSession();
222 document.location.reload();
224 // The ins_search.php window calls this to set the selected insurance.
225 function set_insurance(ins_id, ins_name) {
226 var thesel = document.forms[0]['i' + insurance_index + 'provider'];
227 var theopts = thesel.options; // the array of Option objects
228 var i = 0;
229 for (; i < theopts.length; ++i) {
230 if (theopts[i].value == ins_id) {
231 theopts[i].selected = true;
232 return;
235 // no matching option was found so create one, append it to the
236 // end of the list, and select it.
237 theopts[i] = new Option(ins_name, ins_id, false, true);
240 // This capitalizes the first letter of each word in the passed input
241 // element. It also strips out extraneous spaces.
242 function capitalizeMe(elem) {
243 var a = elem.value.split(' ');
244 var s = '';
245 for(var i = 0; i < a.length; ++i) {
246 if (a[i].length > 0) {
247 if (s.length > 0) s += ' ';
248 s += a[i].charAt(0).toUpperCase() + a[i].substring(1);
251 elem.value = s;
254 function divclick(cb, divid) {
255 var divstyle = document.getElementById(divid).style;
256 if (cb.checked) {
257 divstyle.display = 'block';
258 } else {
259 divstyle.display = 'none';
261 return true;
264 // Compute the length of a string without leading and trailing spaces.
265 function trimlen(s) {
266 var i = 0;
267 var j = s.length - 1;
268 for (; i <= j && s.charAt(i) == ' '; ++i);
269 for (; i <= j && s.charAt(j) == ' '; --j);
270 if (i > j) return 0;
271 return j + 1 - i;
274 function validate(f) {
275 var errCount = 0;
276 var errMsgs = new Array();
277 <?php generate_layout_validation('DEM'); ?>
279 var msg = "";
280 msg += "<?php echo xla('The following fields are required'); ?>:\n\n";
281 for ( var i = 0; i < errMsgs.length; i++ ) {
282 msg += errMsgs[i] + "\n";
284 msg += "\n<?php echo xla('Please fill them in before continuing.'); ?>";
286 if ( errMsgs.length > 0 ) {
287 alert(msg);
290 //Misc Deceased Date Validation for Future Date
291 var dateVal = document.getElementById("form_deceased_date").value;
292 var currentDate;
293 var d = new Date();
294 month = '' + (d.getMonth() + 1),
295 day = '' + d.getDate(),
296 year = d.getFullYear();
297 if (month.length < 2) month = '0' + month;
298 if (day.length < 2) day = '0' + day;
299 currentDate = year+'-'+month+'-'+day;
300 if(dateVal > currentDate)
302 alert ('<?php echo xls("Deceased Date should not be greater than Today"); ?>');
303 return false;
306 //Patient Data validations
307 <?php if ($GLOBALS['erx_enable']) { ?>
308 alertMsg='';
309 for(i=0;i<f.length;i++){
310 if(f[i].type=='text' && f[i].value)
312 if(f[i].name == 'form_fname' || f[i].name == 'form_mname' || f[i].name == 'form_lname')
314 alertMsg += checkLength(f[i].name,f[i].value,35);
315 alertMsg += checkUsername(f[i].name,f[i].value);
317 else if(f[i].name == 'form_street' || f[i].name == 'form_city')
319 alertMsg += checkLength(f[i].name,f[i].value,35);
320 alertMsg += checkAlphaNumericExtended(f[i].name,f[i].value);
322 else if(f[i].name == 'form_phone_home')
324 alertMsg += checkPhone(f[i].name,f[i].value);
328 if(alertMsg)
330 alert(alertMsg);
331 return false;
333 <?php } ?>
334 //return false;
336 // Some insurance validation.
337 for (var i = 1; i <= 3; ++i) {
338 subprov = 'i' + i + 'provider';
339 if (!f[subprov] || f[subprov].selectedIndex <= 0) continue;
340 var subpfx = 'i' + i + 'subscriber_';
341 var subrelat = f['form_' + subpfx + 'relationship'];
342 var samename =
343 f[subpfx + 'fname'].value == f.form_fname.value &&
344 f[subpfx + 'mname'].value == f.form_mname.value &&
345 f[subpfx + 'lname'].value == f.form_lname.value;
346 var ss_regexp=/[0-9][0-9][0-9]-?[0-9][0-9]-?[0-9][0-9][0-9][0-9]/;
347 var samess=true;
348 var ss_valid=false;
349 if(typeof f.form_ss!="undefined")
351 samess = f[subpfx + 'ss'].value == f.form_ss.value;
352 ss_valid=ss_regexp.test(f[subpfx + 'ss'].value) && ss_regexp.test(f.form_ss.value);
354 if (subrelat.options[subrelat.selectedIndex].value == "self") {
355 if (!samename) {
356 if (!confirm("<?php echo xls('Subscriber relationship is self but name is different! Is this really OK?'); ?>"))
357 return false;
359 if (!samess && ss_valid) {
360 if(!confirm("<?php echo xls('Subscriber relationship is self but SS number is different!')." ". xls("Is this really OK?"); ?>"))
361 return false;
363 } // end self
364 else {
365 if (samename) {
366 if (!confirm("<?php echo xls('Subscriber relationship is not self but name is the same! Is this really OK?'); ?>"))
367 return false;
369 if (samess && ss_valid) {
370 if(!confirm("<?php echo xls('Subscriber relationship is not self but SS number is the same!') ." ". xls("Is this really OK?"); ?>"))
371 return false;
373 } // end not self
374 } // end for
376 return errMsgs.length < 1;
381 // Onkeyup handler for policy number. Allows only A-Z and 0-9.
382 function policykeyup(e) {
383 var v = e.value.toUpperCase();
384 var filteredString="";
385 for (var i = 0; i < v.length; ++i) {
386 var c = v.charAt(i);
387 if ((c >= '0' && c <= '9') ||
388 (c >= 'A' && c <= 'Z') ||
389 (c == '*') ||
390 (c == '-') ||
391 (c == '_') ||
392 (c == '(') ||
393 (c == ')') ||
394 (c == '#'))
396 filteredString+=c;
399 e.value = filteredString;
400 return;
403 // Added 06/2009 by BM to make compatible with list_options table and functions - using jquery
404 $(document).ready(function() {
406 <?php for ($i=1; $i<=3; $i++) { ?>
407 $("#form_i<?php echo $i?>subscriber_relationship").change(function() { auto_populate_employer_address<?php echo $i?>(); });
408 <?php } ?>
412 </script>
413 </head>
415 <?php
416 /*Get the constraint from the DB-> LBF forms accordinf the form_id*/
417 $constraints = LBF_Validation::generate_validate_constraints("DEM");
419 <script> var constraints = <?php echo $constraints;?>; </script>
421 <body class="body_top">
423 <form action='demographics_save.php' name='demographics_form' id="DEM" method='post' onsubmit="submitme(<?php echo $GLOBALS['new_validate'] ? 1 : 0;?>,event,'DEM',constraints)">
424 <input type='hidden' name='mode' value='save' />
425 <input type='hidden' name='db_id' value="<?php echo attr($result['id']); ?>" />
427 <div class="container-fluid">
428 <div class="row">
429 <div class="col-xs-12">
430 <div class="page-header">
431 <h2><?php echo xlt('Edit Current Patient');?></h2>
432 </div>
433 </div>
434 <div class="col-xs-12">
435 <div class="btn-group">
436 <button type="submit" class="btn btn-default btn-save" id="submit_btn" disabled="disabled" value="<?php echo xla('Save'); ?>">
437 <?php echo xlt('Save'); ?>
438 </button>
439 <a class="btn btn-link btn-cancel" href="demographics.php" onclick="top.restoreSession()">
440 <?php echo xlt('Cancel'); ?>
441 </a>
442 </div>
443 <hr>
444 </div>
445 </div>
446 </div>
447 <?php
449 function end_cell()
451 global $item_count, $cell_count;
452 if ($item_count > 0) {
453 echo "</td>";
454 $item_count = 0;
458 function end_row()
460 global $cell_count, $CPR;
461 end_cell();
462 if ($cell_count > 0) {
463 for (; $cell_count < $CPR;
464 ++$cell_count) {
465 echo "<td></td>";
468 echo "</tr>\n";
469 $cell_count = 0;
473 function end_group()
475 global $last_group;
476 if (strlen($last_group) > 0) {
477 end_row();
478 echo " </table>\n";
479 echo "</div>\n";
483 $last_group = '';
484 $cell_count = 0;
485 $item_count = 0;
486 $display_style = 'block';
488 $group_seq=0; // this gives the DIV blocks unique IDs
490 $condition_str = '';
492 <br>
493 <div class="section-header">
494 <span class="text"><b> <?php echo xlt("Demographics")?></b></span>
495 </div>
497 <div id="DEM" >
499 <ul class="tabNav">
500 <?php display_layout_tabs('DEM', $result, $result2); ?>
501 </ul>
503 <div class="tabContainer">
504 <?php display_layout_tabs_data_editable('DEM', $result, $result2); ?>
505 </div>
506 </div>
507 <br>
509 <div id="DEM" >
512 <?php
513 if (! $GLOBALS['simplified_demographics']) {
514 $insurance_headings = array(xl("Primary Insurance Provider"), xl("Secondary Insurance Provider"), xl("Tertiary Insurance provider"));
515 $insurance_info = array();
516 $insurance_info[1] = getInsuranceData($pid, "primary");
517 $insurance_info[2] = getInsuranceData($pid, "secondary");
518 $insurance_info[3] = getInsuranceData($pid, "tertiary");
521 <div class="section-header">
522 <span class="text"><b><?php echo xlt("Insurance")?></b></span>
523 </div>
524 <div id="INSURANCE" >
525 <ul class="tabNav">
526 <?php
527 foreach (array('primary','secondary','tertiary') as $instype) {
528 ?><li <?php echo $instype == 'primary' ? 'class="current"' : '' ?>><a href="#"><?php $CapInstype=ucfirst($instype);
529 echo xlt($CapInstype); ?></a></li><?php
532 </ul>
534 <div class="tabContainer">
536 <?php
537 for ($i=1; $i<=3; $i++) {
538 $result3 = $insurance_info[$i];
541 <div class="tab <?php echo $i == 1 ? 'current': '' ?>" style='height:auto;width:auto'> <!---display icky, fix to auto-->
543 <div class="row">
544 <div class="col-md-6">
545 <table border="0">
547 <tr>
548 <td valign='top'>
549 <label class='required'><?php echo text($insurance_headings[$i -1])."&nbsp;"?></label>
550 </td>
551 <td class='required'>:</td>
552 <td>
553 <a href="../../practice/ins_search.php" class="medium_modal css_button" onclick="ins_search(<?php echo $i?>)">
554 <span><?php echo xlt('Search/Add') ?></span>
555 </a>
556 <select name="i<?php echo $i?>provider" class="form-control sel2" style="width: 300;">
557 <option value=""><?php echo xlt('Unassigned'); ?></option>
558 <?php
559 foreach ($insurancei as $iid => $iname) {
560 echo "<option value='" . attr($iid) . "'";
561 if (strtolower($iid) == strtolower($result3{"provider"})) {
562 echo " selected";
565 echo ">" . text($iname) . "</option>\n";
568 </select>
570 </td>
571 </tr>
573 <tr>
574 <td>
575 <label class='required'><?php echo xlt('Plan Name'); ?> </label>
576 </td>
577 <td class='required'>:</td>
578 <td>
579 <input type='entry' class='form-control' size='20' name='i<?php echo $i?>plan_name' value="<?php echo attr($result3{"plan_name"}); ?>"
580 onchange="capitalizeMe(this);" />&nbsp;&nbsp;
581 </td>
582 </tr>
584 <tr>
585 <td>
586 <label class='required'><?php echo xlt('Effective Date'); ?></label>
587 </td>
588 <td class='required'>:</td>
589 <td>
590 <input type='entry' size='16' class='datepicker form-control' id='i<?php echo $i ?>effective_date' name='i<?php echo $i ?>effective_date'
591 value='<?php echo attr(oeFormatShortDate($result3['date'])); ?>'
593 </td>
594 </tr>
596 <tr>
597 <td><label class=required><?php echo xlt('Policy Number'); ?></label></td>
598 <td class='required'>:</td>
599 <td><input type='entry' class='form-control' size='16' name='i<?php echo $i?>policy_number' value="<?php echo attr($result3{"policy_number"}); ?>"
600 onkeyup='policykeyup(this)'></td>
601 </tr>
603 <tr>
604 <td><label class=required><?php echo xlt('Group Number'); ?></label></td>
605 <td class='required'>:</td>
606 <td><input type=entry class='form-control' size=16 name=i<?php echo $i?>group_number value="<?php echo attr($result3{"group_number"}); ?>" onkeyup='policykeyup(this)'></td>
607 </tr>
609 <tr<?php if ($GLOBALS['omit_employers']) {
610 echo " style='display:none'";
611 } ?>>
612 <td class='required'><?php echo xlt('Subscriber Employer (SE)'); ?><br><label style='font-weight:normal'>
613 (<?php echo xlt('if unemployed enter Student'); ?>,<br><?php echo xlt('PT Student, or leave blank'); ?>) </label></td>
614 <td class='required'>:</td>
615 <td><input type=entry class='form-control' size=25 name=i<?php echo $i?>subscriber_employer
616 value="<?php echo attr($result3{"subscriber_employer"}); ?>"
617 onchange="capitalizeMe(this);" /></td>
618 </tr>
620 <tr<?php if ($GLOBALS['omit_employers']) {
621 echo " style='display:none'";
622 } ?>>
623 <td><label class=required><?php echo xlt('SE Address'); ?></label></td>
624 <td class='required'>:</td>
625 <td><input type=entry class='form-control' size=25 name=i<?php echo $i?>subscriber_employer_street
626 value="<?php echo attr($result3{"subscriber_employer_street"}); ?>"
627 onchange="capitalizeMe(this);" /></td>
628 </tr>
630 <tr<?php if ($GLOBALS['omit_employers']) {
631 echo " style='display:none'";
632 } ?>>
633 <td colspan="3">
634 <table>
635 <tr>
636 <td><label class=required><?php echo xlt('SE City'); ?>: </label></td>
637 <td><input type=entry class='form-control' size=15 name=i<?php echo $i?>subscriber_employer_city
638 value="<?php echo attr($result3{"subscriber_employer_city"}); ?>"
639 onchange="capitalizeMe(this);" /></td>
640 <td><label class=required><?php echo ($GLOBALS['phone_country_code'] == '1') ? xlt('SE State') : xlt('SE Locality') ?>: </label></td>
641 <td>
642 <?php
643 // Modified 7/2009 by BM to incorporate data types
644 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']);
646 </td>
647 </tr>
648 <tr>
649 <td><label class=required><?php echo ($GLOBALS['phone_country_code'] == '1') ? xlt('SE Zip Code') : xlt('SE Postal Code') ?>: </label></td>
650 <td><input type=entry class='form-control' size=15 name=i<?php echo $i?>subscriber_employer_postal_code value="<?php echo text($result3{"subscriber_employer_postal_code"}); ?>"></td>
651 <td><label class=required><?php echo xlt('SE Country'); ?>: </label></td>
652 <td>
653 <?php
654 // Modified 7/2009 by BM to incorporate data types
655 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']);
657 </td>
658 </tr>
659 </table>
660 </td>
661 </tr>
663 </table>
664 </div>
666 <div class="col-md-6">
667 <table border="0">
668 <tr>
669 <td><label class=required><?php echo xlt('Relationship'); ?></label></td>
670 <td class=required>:</td>
671 <td colspan=3><?php
672 // Modified 6/2009 by BM to use list_options and function
673 generate_form_field(array('data_type'=>1,'field_id'=>('i'.$i.'subscriber_relationship'),'list_id'=>'sub_relation','empty_title'=>' '), $result3['subscriber_relationship']);
676 <a href="javascript:popUp('browse.php?browsenum=<?php echo $i?>')" class=text>(<?php echo xlt('Browse'); ?>)</a></td>
677 <td></td><td></td><td></td><td></td>
678 </tr>
679 <tr>
680 <td width=120><label class=required><?php echo xlt('Subscriber'); ?> </label></td>
681 <td class=required>:</td>
682 <td colspan=3><input type=entry class='form-control'size=10 name=i<?php echo $i?>subscriber_fname value="<?php echo attr($result3{"subscriber_fname"}); ?>" onchange="capitalizeMe(this);" />
683 <input type=entry class='form-control' size=3 name=i<?php echo $i?>subscriber_mname value="<?php echo attr($result3{"subscriber_mname"}); ?>" onchange="capitalizeMe(this);" />
684 <input type=entry class='form-control' size=10 name=i<?php echo $i?>subscriber_lname value="<?php echo attr($result3{"subscriber_lname"}); ?>" onchange="capitalizeMe(this);" /></td>
685 <td></td><td></td><td></td><td></td>
686 </tr>
687 <tr>
688 <td><label class=bold><?php echo xlt('D.O.B.'); ?> </label></td>
689 <td class=required>:</td>
690 <td><input type='entry' size='11' class='datepicker form-control' id='i<?php echo $i?>subscriber_DOB' name='i<?php echo $i?>subscriber_DOB' value='<?php echo attr(oeFormatShortDate($result3['subscriber_DOB'])); ?>' />
691 </td>
692 <td><label class=bold><?php echo xlt('Sex'); ?>: </label></td>
693 <td><?php
694 // Modified 6/2009 by BM to use list_options and function
695 generate_form_field(array('data_type'=>1,'field_id'=>('i'.$i.'subscriber_sex'),'list_id'=>'sex'), $result3['subscriber_sex']);
697 </td>
698 <td></td><td></td> <td></td><td></td>
699 </tr>
700 <tr>
701 <td class=leftborder><label class=bold><?php echo xlt('S.S.'); ?> </label></td>
702 <td class=required>:</td>
703 <td><input type=entry class='form-control' size=11 name=i<?php echo $i?>subscriber_ss value="<?php echo attr(trim($result3{"subscriber_ss"})); ?>"></td>
704 </tr>
706 <tr>
707 <td><label class=required><?php echo xlt('Subscriber Address'); ?> </label></td>
708 <td class=required>:</td>
709 <td><input type=entry class='form-control' size=20 name=i<?php echo $i?>subscriber_street value="<?php echo attr($result3{"subscriber_street"}); ?>" onchange="capitalizeMe(this);" /></td>
711 <td><label class=required><?php echo ($GLOBALS['phone_country_code'] == '1') ? xlt('State') : xlt('Locality') ?>: </label></td>
712 <td>
713 <?php
714 // Modified 7/2009 by BM to incorporate data types
715 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']);
717 </td>
718 </tr>
719 <tr>
720 <td class=leftborder><label class=required><?php echo xlt('City'); ?></label></td>
721 <td class=required>:</td>
722 <td><input type=entry class='form-control' size=11 name=i<?php echo $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']) {
723 echo " style='display:none'";
724 } ?>><?php echo xlt('Country'); ?>: </label></td><td>
725 <?php
726 // Modified 7/2009 by BM to incorporate data types
727 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']);
729 </td>
730 </tr>
731 <tr>
732 <td><label class=required><?php echo ($GLOBALS['phone_country_code'] == '1') ? xlt('Zip Code') : xlt('Postal Code') ?> </label></td>
733 <td class=required>:</td><td><input type=entry class='form-control' size=10 name=i<?php echo $i?>subscriber_postal_code value="<?php echo attr($result3{"subscriber_postal_code"}); ?>"></td>
735 <td colspan=2>
736 </td><td></td>
737 </tr>
738 <tr>
739 <td><label class=bold><?php echo xlt('Subscriber Phone'); ?></label></td>
740 <td class=required>:</td>
741 <td><input type='text' class='form-control' size='20' name='i<?php echo $i?>subscriber_phone' value='<?php echo attr($result3["subscriber_phone"]); ?>' onkeyup='phonekeyup(this,mypcc)' /></td>
742 <td colspan=2><label class=bold><?php echo xlt('CoPay'); ?>: <input type=text class='form-control' size="6" name=i<?php echo $i?>copay value="<?php echo attr($result3{"copay"}); ?>"></label></td>
743 <td colspan=2>
744 </td><td></td><td></td>
745 </tr>
746 <tr>
747 <td colspan=0><label class='required'><?php echo xlt('Accept Assignment'); ?></label></td>
748 <td class=required>:</td>
749 <td colspan=2>
750 <select class='form-control' name=i<?php echo $i?>accept_assignment>
751 <option value="TRUE" <?php if (strtoupper($result3{"accept_assignment"}) == "TRUE") {
752 echo "selected";
753 }?>><?php echo xlt('YES'); ?></option>
754 <option value="FALSE" <?php if (strtoupper($result3{"accept_assignment"}) == "FALSE") {
755 echo "selected";
756 }?>><?php echo xlt('NO'); ?></option>
757 </select>
758 </td>
759 <td></td><td></td>
760 <td colspan=2>
761 </td><td></td>
762 </tr>
763 <tr>
764 <td><label class='bold'><?php echo xlt('Secondary Medicare Type'); ?></label></td>
765 <td class='bold'>:</td>
766 <td colspan='6'>
767 <select class='form-control sel2' name=i<?php echo $i?>policy_type>
768 <?php
769 foreach ($policy_types as $key => $value) {
770 echo " <option value ='" . attr($key) . "'";
771 if ($key == $result3['policy_type']) {
772 echo " selected";
775 echo ">" . text($value) . "</option>\n";
778 </select>
779 </td>
780 </tr>
781 </table>
783 </div>
784 </div>
786 </div>
788 <?php
789 } //end insurer for loop ?>
791 </div>
792 </div>
794 <?php } // end of "if not simplified_demographics" ?>
795 </div></div>
797 </form>
799 <br>
801 <script language="JavaScript">
803 // Array of skip conditions for the checkSkipConditions() function.
804 var skipArray = [
805 <?php echo $condition_str; ?>
808 // hard code validation for old validation, in the new validation possible to add match rules
809 <?php if ($GLOBALS['new_validate'] == 0) { ?>
810 // fix inconsistently formatted phone numbers from the database
811 var f = document.forms[0];
812 if (f.form_phone_contact) phonekeyup(f.form_phone_contact,mypcc);
813 if (f.form_phone_home ) phonekeyup(f.form_phone_home ,mypcc);
814 if (f.form_phone_biz ) phonekeyup(f.form_phone_biz ,mypcc);
815 if (f.form_phone_cell ) phonekeyup(f.form_phone_cell ,mypcc);
817 <?php if (! $GLOBALS['simplified_demographics']) { ?>
818 phonekeyup(f.i1subscriber_phone,mypcc);
819 phonekeyup(f.i2subscriber_phone,mypcc);
820 phonekeyup(f.i3subscriber_phone,mypcc);
821 <?php } ?>
823 <?php }?>
825 <?php if ($set_pid) { ?>
826 parent.left_nav.setPatient(<?php echo "'" . addslashes($result['fname']) . " " . addslashes($result['lname']) . "'," . addslashes($pid) . ",'" . addslashes($result['pubpid']) . "','', ' " . xls('DOB') . ": " . addslashes(oeFormatShortDate($result['DOB_YMD'])) . " " . xls('Age') . ": " . addslashes(getPatientAgeDisplay($result['DOB_YMD'])) . "'"; ?>);
827 <?php } ?>
829 <?php echo $date_init; ?>
830 </script>
832 <!-- include support for the list-add selectbox feature -->
833 <?php include $GLOBALS['fileroot']."/library/options_listadd.inc"; ?>
835 <?php /*Include the validation script and rules for this form*/
836 $form_id="DEM";
837 //LBF forms use the new validation depending on the global value
838 $use_validate_js=$GLOBALS['new_validate'];
841 <?php include_once("$srcdir/validation/validation_script.js.php");?>
844 </body>
845 <script language='JavaScript'>
846 var duplicateFieldsArray=[];
848 //This code deals with demographics before save action -
849 <?php if (($GLOBALS['gbl_edit_patient_form'] == '1') && (checkIfPatientValidationHookIsActive())) :?>
851 //Use the Zend patient validation hook.
852 //TODO - get the edit part of patient validation hook to work smoothly and then
853 // remove the closeBeforeOpening=1 in the url below.
855 var f = $("form");
857 // Use hook to open the controller and get the new patient validation .
858 // when no params are sent this window will be closed from the zend controller.
859 var url ='<?php echo $GLOBALS['web_root']."/interface/modules/zend_modules/public/patientvalidation";?>';
860 $("#submit_btn").attr("name","btnSubmit");
861 $("#submit_btn").attr("id","btnSubmit");
862 $("#btnSubmit").click(function( event ) {
864 top.restoreSession();
866 if(!submitme(<?php echo $GLOBALS['new_validate'] ? 1 : 0;?>,event,'DEM',constraints)){
867 event.preventDefault();
868 return;
870 somethingChanged = false;
871 <?php
872 // D in edit_options indicates the field is used in duplication checking.
873 // This constructs a list of the names of those fields.
874 $mflist = "";
875 $mfres = sqlStatement("SELECT field_id FROM layout_options " .
876 "WHERE form_id = 'DEM' AND uor > 0 AND field_id != '' AND " .
877 "(edit_options LIKE '%D%' OR edit_options LIKE '%E%') " .
878 "ORDER BY group_id, seq");
879 while ($mfrow = sqlFetchArray($mfres)) {
880 $field_id = $mfrow['field_id'];
881 if (strpos($field_id, 'em_') === 0) {
882 continue;
885 if (!empty($mflist)) {
886 $mflist .= ",";
889 $mflist .= "'" . text($field_id) . "'";
890 } ?>
892 var flds = new Array(<?php echo $mflist; ?>);
893 var separator = '?';
894 var valueIsChanged=false;
895 for (var i = 0; i < flds.length; ++i) {
896 var fval = $('#form_' + flds[i]).val();
897 if(duplicateFieldsArray['#form_' + flds[i]]!=fval) {
898 valueIsChanged = true;
902 if (fval && fval != '') {
903 url += separator;
904 separator = '&';
905 url += 'mf_' + flds[i] + '=' + encodeURIComponent(fval);
910 //Only if check for duplicates values are changed open the popup hook screen
911 if(valueIsChanged) {
912 event.preventDefault();
913 //("value has changed for duplicate check inputs");
914 url += '&page=edit&closeBeforeOpening=1&mf_id='+$("[name='db_id']").val();
915 dlgopen(url, '_blank', 700, 500);
917 else {//other wise submit me is a success just submit the form
918 $('#DEM').submit();
922 <?php endif;?>
924 $(document).ready(function(){
925 //When document is ready collect all the values Marked with D (check duplicate) stored in the db into array duplicateFieldsArray.
926 var flds = new Array(<?php echo $mflist; ?>);
927 for (var i = 0; i < flds.length; ++i) {
928 var fval = $('#form_' + flds[i]).val();
929 duplicateFieldsArray['#form_' + flds[i]] = fval;
931 $(".sel2").select2({
932 <?php require($GLOBALS['srcdir'] . '/js/xl/select2.js.php'); ?>
935 </script>
938 </html>