added cache clearing support for dialog.js (#411)
[openemr.git] / interface / patient_file / summary / demographics_full.php
blobfe89ba29744120c0a8c23f8b5ae95f2608b6b5ab
1 <?php
2 // This program is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU General Public License
4 // as published by the Free Software Foundation; either version 2
5 // of the License, or (at your option) any later version.
7 require_once("../../globals.php");
8 require_once("$srcdir/acl.inc");
9 require_once("$srcdir/options.inc.php");
10 require_once("$srcdir/formatting.inc.php");
11 require_once("$srcdir/erx_javascript.inc.php");
12 require_once("$srcdir/validation/LBF_Validation.php");
13 require_once ("$srcdir/patientvalidation.inc.php");
15 // Session pid must be right or bad things can happen when demographics are saved!
17 include_once("$srcdir/pid.inc");
18 $set_pid = $_GET["set_pid"] ? $_GET["set_pid"] : $_GET["pid"];
19 if ($set_pid && $set_pid != $_SESSION["pid"]) {
20 setpid($set_pid);
23 include_once("$srcdir/patient.inc");
25 $result = getPatientData($pid, "*, DATE_FORMAT(DOB,'%Y-%m-%d') as DOB_YMD");
26 $result2 = getEmployerData($pid);
28 // Check authorization.
29 if ($pid) {
30 if (!acl_check('patients', 'demo', '', 'write'))
31 die(xl('Updating demographics is not authorized.'));
32 if ($result['squad'] && ! acl_check('squads', $result['squad']))
33 die(xl('You are not authorized to access this squad.'));
34 } else {
35 if (!acl_check('patients', 'demo', '', array('write','addonly') ))
36 die(xl('Adding demographics is not authorized.'));
39 $CPR = 4; // cells per row
41 // $statii = array('married','single','divorced','widowed','separated','domestic partner');
42 // $langi = getLanguages();
43 // $ethnoraciali = getEthnoRacials();
44 // $provideri = getProviderInfo();
45 if ($GLOBALS['insurance_information'] != '0') {
46 $insurancei = getInsuranceProvidersExtra();
47 }else{
48 $insurancei = getInsuranceProviders();
51 $fres = sqlStatement("SELECT * FROM layout_options " .
52 "WHERE form_id = 'DEM' AND uor > 0 " .
53 "ORDER BY group_name, seq");
55 <html>
56 <head>
57 <?php html_header_show();?>
59 <link rel="stylesheet" href="<?php echo $css_header; ?>" type="text/css">
61 <style type="text/css">@import url(../../../library/dynarch_calendar.css);</style>
63 <script type="text/javascript" src="../../../library/dialog.js?v=<?php echo $v_js_includes; ?>"></script>
64 <script type="text/javascript" src="../../../library/textformat.js"></script>
65 <script type="text/javascript" src="../../../library/dynarch_calendar.js"></script>
66 <?php include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?>
67 <script type="text/javascript" src="../../../library/dynarch_calendar_setup.js"></script>
68 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-9-1/index.js"></script>
69 <script type="text/javascript" src="../../../library/js/common.js"></script>
70 <script type="text/javascript" src="../../../library/js/fancybox/jquery.fancybox-1.2.6.js"></script>
72 <?php include_once("{$GLOBALS['srcdir']}/options.js.php"); ?>
74 <link rel="stylesheet" type="text/css" href="../../../library/js/fancybox/jquery.fancybox-1.2.6.css" media="screen" />
76 <script type="text/javascript">
78 // Support for beforeunload handler.
79 var somethingChanged = false;
81 $(document).ready(function(){
82 tabbify();
83 enable_modals();
85 // special size for
86 $(".medium_modal").fancybox( {
87 'overlayOpacity' : 0.0,
88 'showCloseButton' : true,
89 'frameHeight' : 460,
90 'frameWidth' : 650
91 });
93 // Support for beforeunload handler.
94 $('.tab input, .tab select, .tab textarea').change(function() {
95 somethingChanged = true;
96 });
97 window.addEventListener("beforeunload", function (e) {
98 if (somethingChanged && !top.timed_out) {
99 var msg = "<?php echo xls('You have unsaved changes.'); ?>";
100 e.returnValue = msg; // Gecko, Trident, Chrome 34+
101 return msg; // Gecko, WebKit, Chrome <34
106 var mypcc = '<?php echo $GLOBALS['phone_country_code'] ?>';
108 //code used from http://tech.irt.org/articles/js037/
109 function replace(string,text,by) {
110 // Replaces text with by in string
111 var strLength = string.length, txtLength = text.length;
112 if ((strLength == 0) || (txtLength == 0)) return string;
114 var i = string.indexOf(text);
115 if ((!i) && (text != string.substring(0,txtLength))) return string;
116 if (i == -1) return string;
118 var newstr = string.substring(0,i) + by;
120 if (i+txtLength < strLength)
121 newstr += replace(string.substring(i+txtLength,strLength),text,by);
123 return newstr;
126 function upperFirst(string,text) {
127 return replace(string,text,text.charAt(0).toUpperCase() + text.substring(1,text.length));
130 <?php for ($i=1;$i<=3;$i++) { ?>
131 function auto_populate_employer_address<?php echo $i ?>(){
132 var f = document.demographics_form;
133 if (f.form_i<?php echo $i?>subscriber_relationship.options[f.form_i<?php echo $i?>subscriber_relationship.selectedIndex].value == "self")
135 f.i<?php echo $i?>subscriber_fname.value=f.form_fname.value;
136 f.i<?php echo $i?>subscriber_mname.value=f.form_mname.value;
137 f.i<?php echo $i?>subscriber_lname.value=f.form_lname.value;
138 f.i<?php echo $i?>subscriber_street.value=f.form_street.value;
139 f.i<?php echo $i?>subscriber_city.value=f.form_city.value;
140 f.form_i<?php echo $i?>subscriber_state.value=f.form_state.value;
141 f.i<?php echo $i?>subscriber_postal_code.value=f.form_postal_code.value;
142 if (f.form_country_code)
143 f.form_i<?php echo $i?>subscriber_country.value=f.form_country_code.value;
144 f.i<?php echo $i?>subscriber_phone.value=f.form_phone_home.value;
145 f.i<?php echo $i?>subscriber_DOB.value=f.form_DOB.value;
146 if(typeof f.form_ss!="undefined")
148 f.i<?php echo $i?>subscriber_ss.value=f.form_ss.value;
150 f.form_i<?php echo $i?>subscriber_sex.value = f.form_sex.value;
151 f.i<?php echo $i?>subscriber_employer.value=f.form_em_name.value;
152 f.i<?php echo $i?>subscriber_employer_street.value=f.form_em_street.value;
153 f.i<?php echo $i?>subscriber_employer_city.value=f.form_em_city.value;
154 f.form_i<?php echo $i?>subscriber_employer_state.value=f.form_em_state.value;
155 f.i<?php echo $i?>subscriber_employer_postal_code.value=f.form_em_postal_code.value;
156 if (f.form_em_country)
157 f.form_i<?php echo $i?>subscriber_employer_country.value=f.form_em_country.value;
161 <?php } ?>
163 function popUp(URL) {
164 day = new Date();
165 id = day.getTime();
166 top.restoreSession();
167 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');");
170 function checkNum () {
171 var re= new RegExp();
172 re = /^\d*\.?\d*$/;
173 str=document.demographics_form.monthly_income.value;
174 if(re.exec(str))
176 }else{
177 alert("<?php xl('Please enter a monetary amount using only numbers and a decimal point.','e'); ?>");
181 // Indicates which insurance slot is being updated.
182 var insurance_index = 0;
184 // The OnClick handler for searching/adding the insurance company.
185 function ins_search(ins) {
186 insurance_index = ins;
187 return false;
190 // The ins_search.php window calls this to set the selected insurance.
191 function set_insurance(ins_id, ins_name) {
192 var thesel = document.forms[0]['i' + insurance_index + 'provider'];
193 var theopts = thesel.options; // the array of Option objects
194 var i = 0;
195 for (; i < theopts.length; ++i) {
196 if (theopts[i].value == ins_id) {
197 theopts[i].selected = true;
198 return;
201 // no matching option was found so create one, append it to the
202 // end of the list, and select it.
203 theopts[i] = new Option(ins_name, ins_id, false, true);
206 // This capitalizes the first letter of each word in the passed input
207 // element. It also strips out extraneous spaces.
208 function capitalizeMe(elem) {
209 var a = elem.value.split(' ');
210 var s = '';
211 for(var i = 0; i < a.length; ++i) {
212 if (a[i].length > 0) {
213 if (s.length > 0) s += ' ';
214 s += a[i].charAt(0).toUpperCase() + a[i].substring(1);
217 elem.value = s;
220 function divclick(cb, divid) {
221 var divstyle = document.getElementById(divid).style;
222 if (cb.checked) {
223 divstyle.display = 'block';
224 } else {
225 divstyle.display = 'none';
227 return true;
230 // Compute the length of a string without leading and trailing spaces.
231 function trimlen(s) {
232 var i = 0;
233 var j = s.length - 1;
234 for (; i <= j && s.charAt(i) == ' '; ++i);
235 for (; i <= j && s.charAt(j) == ' '; --j);
236 if (i > j) return 0;
237 return j + 1 - i;
240 function validate(f) {
241 var errCount = 0;
242 var errMsgs = new Array();
243 <?php generate_layout_validation('DEM'); ?>
245 var msg = "";
246 msg += "<?php xl('The following fields are required', 'e' ); ?>:\n\n";
247 for ( var i = 0; i < errMsgs.length; i++ ) {
248 msg += errMsgs[i] + "\n";
250 msg += "\n<?php xl('Please fill them in before continuing.', 'e'); ?>";
252 if ( errMsgs.length > 0 ) {
253 alert(msg);
256 //Misc Deceased Date Validation for Future Date
257 var dateVal = document.getElementById("form_deceased_date").value;
258 var currentDate;
259 var d = new Date();
260 month = '' + (d.getMonth() + 1),
261 day = '' + d.getDate(),
262 year = d.getFullYear();
263 if (month.length < 2) month = '0' + month;
264 if (day.length < 2) day = '0' + day;
265 currentDate = year+'-'+month+'-'+day;
266 if(dateVal > currentDate)
268 alert ('<?php echo xls("Deceased Date should not be greater than Today"); ?>');
269 return false;
272 //Patient Data validations
273 <?php if($GLOBALS['erx_enable']){ ?>
274 alertMsg='';
275 for(i=0;i<f.length;i++){
276 if(f[i].type=='text' && f[i].value)
278 if(f[i].name == 'form_fname' || f[i].name == 'form_mname' || f[i].name == 'form_lname')
280 alertMsg += checkLength(f[i].name,f[i].value,35);
281 alertMsg += checkUsername(f[i].name,f[i].value);
283 else if(f[i].name == 'form_street' || f[i].name == 'form_city')
285 alertMsg += checkLength(f[i].name,f[i].value,35);
286 alertMsg += checkAlphaNumericExtended(f[i].name,f[i].value);
288 else if(f[i].name == 'form_phone_home')
290 alertMsg += checkPhone(f[i].name,f[i].value);
294 if(alertMsg)
296 alert(alertMsg);
297 return false;
299 <?php } ?>
300 //return false;
302 // Some insurance validation.
303 for (var i = 1; i <= 3; ++i) {
304 subprov = 'i' + i + 'provider';
305 if (!f[subprov] || f[subprov].selectedIndex <= 0) continue;
306 var subpfx = 'i' + i + 'subscriber_';
307 var subrelat = f['form_' + subpfx + 'relationship'];
308 var samename =
309 f[subpfx + 'fname'].value == f.form_fname.value &&
310 f[subpfx + 'mname'].value == f.form_mname.value &&
311 f[subpfx + 'lname'].value == f.form_lname.value;
312 var ss_regexp=/[0-9][0-9][0-9]-?[0-9][0-9]-?[0-9][0-9][0-9][0-9]/;
313 var samess=true;
314 var ss_valid=false;
315 if(typeof f.form_ss!="undefined")
317 samess = f[subpfx + 'ss'].value == f.form_ss.value;
318 ss_valid=ss_regexp.test(f[subpfx + 'ss'].value) && ss_regexp.test(f.form_ss.value);
320 if (subrelat.options[subrelat.selectedIndex].value == "self") {
321 if (!samename) {
322 if (!confirm("<?php echo xls('Subscriber relationship is self but name is different! Is this really OK?'); ?>"))
323 return false;
325 if (!samess && ss_valid) {
326 if(!confirm("<?php echo xls('Subscriber relationship is self but SS number is different!')." ". xls("Is this really OK?"); ?>"))
327 return false;
329 } // end self
330 else {
331 if (samename) {
332 if (!confirm("<?php echo xls('Subscriber relationship is not self but name is the same! Is this really OK?'); ?>"))
333 return false;
335 if (samess && ss_valid) {
336 if(!confirm("<?php echo xls('Subscriber relationship is not self but SS number is the same!') ." ". xls("Is this really OK?"); ?>"))
337 return false;
339 } // end not self
340 } // end for
342 return errMsgs.length < 1;
347 // Onkeyup handler for policy number. Allows only A-Z and 0-9.
348 function policykeyup(e) {
349 var v = e.value.toUpperCase();
350 var filteredString="";
351 for (var i = 0; i < v.length; ++i) {
352 var c = v.charAt(i);
353 if ((c >= '0' && c <= '9') ||
354 (c >= 'A' && c <= 'Z') ||
355 (c == '*') ||
356 (c == '-') ||
357 (c == '_') ||
358 (c == '(') ||
359 (c == ')') ||
360 (c == '#'))
362 filteredString+=c;
365 e.value = filteredString;
366 return;
369 // Added 06/2009 by BM to make compatible with list_options table and functions - using jquery
370 $(document).ready(function() {
372 <?php for ($i=1;$i<=3;$i++) { ?>
373 $("#form_i<?php echo $i?>subscriber_relationship").change(function() { auto_populate_employer_address<?php echo $i?>(); });
374 <?php } ?>
378 </script>
379 </head>
381 <?php
382 /*Get the constraint from the DB-> LBF forms accordinf the form_id*/
383 $constraints = LBF_Validation::generate_validate_constraints("DEM");
385 <script> var constraints = <?php echo $constraints;?>; </script>
387 <body class="body_top">
389 <form action='demographics_save.php' name='demographics_form' id="DEM" method='post' onsubmit="submitme(<?php echo $GLOBALS['new_validate'] ? 1 : 0;?>,event,'DEM',constraints)">
390 <input type='hidden' name='mode' value='save' />
391 <input type='hidden' name='db_id' value="<?php echo $result['id']?>" />
392 <table cellpadding='0' cellspacing='0' border='0'>
393 <tr>
394 <td>
395 <a href="demographics.php" onclick="top.restoreSession()">
396 <font class=title><?php xl('Current Patient','e'); ?></font>
397 </a>
398 &nbsp;&nbsp;
399 </td>
400 <td>
401 <input id="submit_btn" class="css_btn" type="submit" disabled="disabled" value="<?php xl('Save','e'); ?>">
402 </td>
403 <td>
404 <a class="css_button" href="demographics.php" onclick="top.restoreSession()">
405 <span><?php xl('Cancel','e'); ?></span>
406 </a>
407 </td>
408 </tr>
409 </table>
410 <?php
412 function end_cell() {
413 global $item_count, $cell_count;
414 if ($item_count > 0) {
415 echo "</td>";
416 $item_count = 0;
420 function end_row() {
421 global $cell_count, $CPR;
422 end_cell();
423 if ($cell_count > 0) {
424 for (; $cell_count < $CPR; ++$cell_count) echo "<td></td>";
425 echo "</tr>\n";
426 $cell_count = 0;
430 function end_group() {
431 global $last_group;
432 if (strlen($last_group) > 0) {
433 end_row();
434 echo " </table>\n";
435 echo "</div>\n";
439 $last_group = '';
440 $cell_count = 0;
441 $item_count = 0;
442 $display_style = 'block';
444 $group_seq=0; // this gives the DIV blocks unique IDs
447 <br>
448 <div class="section-header">
449 <span class="text"><b> <?php xl("Demographics", "e" )?></b></span>
450 </div>
452 <div id="DEM" >
454 <ul class="tabNav">
455 <?php display_layout_tabs('DEM', $result, $result2); ?>
456 </ul>
458 <div class="tabContainer">
459 <?php display_layout_tabs_data_editable('DEM', $result, $result2); ?>
460 </div>
461 </div>
462 <br>
464 <div id="DEM" >
467 <?php
468 if (! $GLOBALS['simplified_demographics']) {
470 $insurance_headings = array(xl("Primary Insurance Provider"), xl("Secondary Insurance Provider"), xl("Tertiary Insurance provider"));
471 $insurance_info = array();
472 $insurance_info[1] = getInsuranceData($pid,"primary");
473 $insurance_info[2] = getInsuranceData($pid,"secondary");
474 $insurance_info[3] = getInsuranceData($pid,"tertiary");
477 <div class="section-header">
478 <span class="text"><b><?php xl("Insurance", "e" )?></b></span>
479 </div>
480 <div id="INSURANCE" >
481 <ul class="tabNav">
482 <?php
483 foreach (array('primary','secondary','tertiary') as $instype) {
484 ?><li <?php echo $instype == 'primary' ? 'class="current"' : '' ?>><a href="#"><?php $CapInstype=ucfirst($instype); xl($CapInstype,'e'); ?></a></li><?php
487 </ul>
489 <div class="tabContainer">
491 <?php
492 for($i=1;$i<=3;$i++) {
493 $result3 = $insurance_info[$i];
496 <div class="tab <?php echo $i == 1 ? 'current': '' ?>" style='height:auto;width:auto'> <!---display icky, fix to auto-->
498 <table border="0">
500 <tr>
501 <td valign=top width="430">
502 <table border="0">
504 <tr>
505 <td valign='top'>
506 <span class='required'><?php echo $insurance_headings[$i -1]."&nbsp;"?></span>
507 </td>
508 <td class='required'>:</td>
509 <td>
510 <a href="../../practice/ins_search.php" class="iframe medium_modal css_button" onclick="ins_search(<?php echo $i?>)">
511 <span><?php echo xl('Search/Add') ?></span>
512 </a>
513 <select name="i<?php echo $i?>provider">
514 <option value=""><?php xl('Unassigned','e'); ?></option>
515 <?php
516 foreach ($insurancei as $iid => $iname) {
517 echo "<option value='" . $iid . "'";
518 if (strtolower($iid) == strtolower($result3{"provider"}))
519 echo " selected";
520 echo ">" . $iname . "</option>\n";
523 </select>
525 </td>
526 </tr>
528 <tr>
529 <td>
530 <span class='required'><?php xl('Plan Name','e'); ?> </span>
531 </td>
532 <td class='required'>:</td>
533 <td>
534 <input type='entry' size='20' name='i<?php echo $i?>plan_name' value="<?php echo $result3{"plan_name"} ?>"
535 onchange="capitalizeMe(this);" />&nbsp;&nbsp;
536 </td>
537 </tr>
539 <tr>
540 <td>
541 <span class='required'><?php xl('Effective Date','e'); ?></span>
542 </td>
543 <td class='required'>:</td>
544 <td>
545 <input type='entry' size='16' id='i<?php echo $i ?>effective_date' name='i<?php echo $i ?>effective_date'
546 value='<?php echo $result3['date'] ?>'
547 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)'
548 title='yyyy-mm-dd' />
549 <img src='../../pic/show_calendar.gif' align='absbottom' width='24' height='22' id='img_i<?php echo $i ?>effective_date' border='0' alt='[?]' style='cursor:pointer' title='<?php xl('Click here to choose a date','e'); ?>'>
550 </td>
551 </tr>
553 <tr>
554 <td><span class=required><?php xl('Policy Number','e'); ?></span></td>
555 <td class='required'>:</td>
556 <td><input type='entry' size='16' name='i<?php echo $i?>policy_number' value="<?php echo $result3{"policy_number"}?>"
557 onkeyup='policykeyup(this)'></td>
558 </tr>
560 <tr>
561 <td><span class=required><?php xl('Group Number','e'); ?></span></td>
562 <td class='required'>:</td>
563 <td><input type=entry size=16 name=i<?php echo $i?>group_number value="<?php echo $result3{"group_number"}?>" onkeyup='policykeyup(this)'></td>
564 </tr>
566 <tr<?php if ($GLOBALS['omit_employers']) echo " style='display:none'"; ?>>
567 <td class='required'><?php xl('Subscriber Employer (SE)','e'); ?><br><span style='font-weight:normal'>
568 (<?php xl('if unemployed enter Student','e'); ?>,<br><?php xl('PT Student, or leave blank','e'); ?>) </span></td>
569 <td class='required'>:</td>
570 <td><input type=entry size=25 name=i<?php echo $i?>subscriber_employer
571 value="<?php echo $result3{"subscriber_employer"}?>"
572 onchange="capitalizeMe(this);" /></td>
573 </tr>
575 <tr<?php if ($GLOBALS['omit_employers']) echo " style='display:none'"; ?>>
576 <td><span class=required><?php xl('SE Address','e'); ?></span></td>
577 <td class='required'>:</td>
578 <td><input type=entry size=25 name=i<?php echo $i?>subscriber_employer_street
579 value="<?php echo $result3{"subscriber_employer_street"}?>"
580 onchange="capitalizeMe(this);" /></td>
581 </tr>
583 <tr<?php if ($GLOBALS['omit_employers']) echo " style='display:none'"; ?>>
584 <td colspan="3">
585 <table>
586 <tr>
587 <td><span class=required><?php xl('SE City','e'); ?>: </span></td>
588 <td><input type=entry size=15 name=i<?php echo $i?>subscriber_employer_city
589 value="<?php echo $result3{"subscriber_employer_city"}?>"
590 onchange="capitalizeMe(this);" /></td>
591 <td><span class=required><?php echo ($GLOBALS['phone_country_code'] == '1') ? xl('SE State','e') : xl('SE Locality','e') ?>: </span></td>
592 <td>
593 <?php
594 // Modified 7/2009 by BM to incorporate data types
595 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']);
597 </td>
598 </tr>
599 <tr>
600 <td><span class=required><?php echo ($GLOBALS['phone_country_code'] == '1') ? xl('SE Zip Code','e') : xl('SE Postal Code','e') ?>: </span></td>
601 <td><input type=entry size=15 name=i<?php echo $i?>subscriber_employer_postal_code value="<?php echo $result3{"subscriber_employer_postal_code"}?>"></td>
602 <td><span class=required><?php xl('SE Country','e'); ?>: </span></td>
603 <td>
604 <?php
605 // Modified 7/2009 by BM to incorporate data types
606 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']);
608 </td>
609 </tr>
610 </table>
611 </td>
612 </tr>
614 </table>
615 </td>
617 <td valign=top>
618 <table border="0">
619 <tr>
620 <td><span class=required><?php xl('Relationship','e'); ?></span></td>
621 <td class=required>:</td>
622 <td colspan=3><?php
623 // Modified 6/2009 by BM to use list_options and function
624 generate_form_field(array('data_type'=>1,'field_id'=>('i'.$i.'subscriber_relationship'),'list_id'=>'sub_relation','empty_title'=>' '), $result3['subscriber_relationship']);
627 <a href="javascript:popUp('browse.php?browsenum=<?php echo $i?>')" class=text>(<?php xl('Browse','e'); ?>)</a></td>
628 <td></td><td></td><td></td><td></td>
629 </tr>
630 <tr>
631 <td width=120><span class=required><?php xl('Subscriber','e'); ?> </span></td>
632 <td class=required>:</td>
633 <td colspan=3><input type=entry size=10 name=i<?php echo $i?>subscriber_fname value="<?php echo $result3{"subscriber_fname"}?>" onchange="capitalizeMe(this);" />
634 <input type=entry size=3 name=i<?php echo $i?>subscriber_mname value="<?php echo $result3{"subscriber_mname"}?>" onchange="capitalizeMe(this);" />
635 <input type=entry size=10 name=i<?php echo $i?>subscriber_lname value="<?php echo $result3{"subscriber_lname"}?>" onchange="capitalizeMe(this);" /></td>
636 <td></td><td></td><td></td><td></td>
637 </tr>
638 <tr>
639 <td><span class=bold><?php xl('D.O.B.','e'); ?> </span></td>
640 <td class=required>:</td>
641 <td><input type='entry' size='11' id='i<?php echo $i?>subscriber_DOB' name='i<?php echo $i?>subscriber_DOB' value='<?php echo $result3['subscriber_DOB'] ?>' onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)' title='yyyy-mm-dd' /><img src='../../pic/show_calendar.gif' align='absbottom' width='24' height='22' id='img_i<?php echo $i; ?>dob_date' border='0' alt='[?]' style='cursor:pointer' title='<?php xl('Click here to choose a date','e'); ?>'></td>
643 <td><span class=bold><?php xl('Sex','e'); ?>: </span></td>
644 <td><?php
645 // Modified 6/2009 by BM to use list_options and function
646 generate_form_field(array('data_type'=>1,'field_id'=>('i'.$i.'subscriber_sex'),'list_id'=>'sex'), $result3['subscriber_sex']);
648 </td>
649 <td></td><td></td> <td></td><td></td>
650 </tr>
651 <tr>
652 <td class=leftborder><span class=bold><?php xl('S.S.','e'); ?> </span></td>
653 <td class=required>:</td>
654 <td><input type=entry size=11 name=i<?php echo $i?>subscriber_ss value="<?php echo trim($result3{"subscriber_ss"})?>"></td>
655 </tr>
657 <tr>
658 <td><span class=required><?php xl('Subscriber Address','e'); ?> </span></td>
659 <td class=required>:</td>
660 <td><input type=entry size=20 name=i<?php echo $i?>subscriber_street value="<?php echo $result3{"subscriber_street"}?>" onchange="capitalizeMe(this);" /></td>
662 <td><span class=required><?php echo ($GLOBALS['phone_country_code'] == '1') ? xl('State','e') : xl('Locality','e') ?>: </span></td>
663 <td>
664 <?php
665 // Modified 7/2009 by BM to incorporate data types
666 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']);
668 </td>
669 </tr>
670 <tr>
671 <td class=leftborder><span class=required><?php xl('City','e'); ?></span></td>
672 <td class=required>:</td>
673 <td><input type=entry size=11 name=i<?php echo $i?>subscriber_city value="<?php echo $result3{"subscriber_city"}?>" onchange="capitalizeMe(this);" /></td><td class=leftborder><span class='required'<?php if ($GLOBALS['omit_employers']) echo " style='display:none'"; ?>><?php xl('Country','e'); ?>: </span></td><td>
674 <?php
675 // Modified 7/2009 by BM to incorporate data types
676 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']);
678 </td>
679 </tr>
680 <tr>
681 <td><span class=required><?php echo ($GLOBALS['phone_country_code'] == '1') ? xl('Zip Code','e') : xl('Postal Code','e') ?> </span></td><td class=required>:</td><td><input type=entry size=10 name=i<?php echo $i?>subscriber_postal_code value="<?php echo $result3{"subscriber_postal_code"}?>"></td>
683 <td colspan=2>
684 </td><td></td>
685 </tr>
686 <tr>
687 <td><span class=bold><?php xl('Subscriber Phone','e'); ?></span></td>
688 <td class=required>:</td>
689 <td><input type='text' size='20' name='i<?php echo $i?>subscriber_phone' value='<?php echo $result3["subscriber_phone"] ?>' onkeyup='phonekeyup(this,mypcc)' /></td>
690 <td colspan=2><span class=bold><?php xl('CoPay','e'); ?>: <input type=text size="6" name=i<?php echo $i?>copay value="<?php echo $result3{"copay"}?>"></span></td>
691 <td colspan=2>
692 </td><td></td><td></td>
693 </tr>
694 <tr>
695 <td colspan=0><span class='required'><?php xl('Accept Assignment','e'); ?></span></td>
696 <td class=required>:</td>
697 <td colspan=2>
698 <select name=i<?php echo $i?>accept_assignment>
699 <option value="TRUE" <?php if (strtoupper($result3{"accept_assignment"}) == "TRUE") echo "selected"?>><?php xl('YES','e'); ?></option>
700 <option value="FALSE" <?php if (strtoupper($result3{"accept_assignment"}) == "FALSE") echo "selected"?>><?php xl('NO','e'); ?></option>
701 </select>
702 </td>
703 <td></td><td></td>
704 <td colspan=2>
705 </td><td></td>
706 </tr>
707 <tr>
708 <td><span class='bold'><?php xl('Secondary Medicare Type','e'); ?></span></td>
709 <td class='bold'>:</td>
710 <td colspan='6'>
711 <select name=i<?php echo $i?>policy_type>
712 <?php
713 foreach ($policy_types AS $key => $value) {
714 echo " <option value ='$key'";
715 if ($key == $result3['policy_type']) echo " selected";
716 echo ">" . htmlspecialchars($value) . "</option>\n";
719 </select>
720 </td>
721 </tr>
722 </table>
724 </td>
725 </tr>
726 </table>
728 </div>
730 <?php } //end insurer for loop ?>
732 </div>
733 </div>
735 <?php } // end of "if not simplified_demographics" ?>
736 </div></div>
738 </form>
740 <br>
742 <script language="JavaScript">
743 // hard code validation for old validation, in the new validation possible to add match rules
744 <?php if($GLOBALS['new_validate'] == 0) { ?>
745 // fix inconsistently formatted phone numbers from the database
746 var f = document.forms[0];
747 if (f.form_phone_contact) phonekeyup(f.form_phone_contact,mypcc);
748 if (f.form_phone_home ) phonekeyup(f.form_phone_home ,mypcc);
749 if (f.form_phone_biz ) phonekeyup(f.form_phone_biz ,mypcc);
750 if (f.form_phone_cell ) phonekeyup(f.form_phone_cell ,mypcc);
752 <?php if (! $GLOBALS['simplified_demographics']) { ?>
753 phonekeyup(f.i1subscriber_phone,mypcc);
754 phonekeyup(f.i2subscriber_phone,mypcc);
755 phonekeyup(f.i3subscriber_phone,mypcc);
756 <?php } ?>
758 <?php }?>
760 <?php if ($set_pid) { ?>
761 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'])) . "'"; ?>);
762 <?php } ?>
764 <?php echo $date_init; ?>
765 <?php if (! $GLOBALS['simplified_demographics']) { for ($i=1; $i<=3; $i++): ?>
766 Calendar.setup({inputField:"i<?php echo $i?>effective_date", ifFormat:"%Y-%m-%d", button:"img_i<?php echo $i?>effective_date"});
767 Calendar.setup({inputField:"i<?php echo $i?>subscriber_DOB", ifFormat:"%Y-%m-%d", button:"img_i<?php echo $i?>dob_date"});
768 <?php endfor; } ?>
769 </script>
771 <!-- include support for the list-add selectbox feature -->
772 <?php include $GLOBALS['fileroot']."/library/options_listadd.inc"; ?>
774 <?php /*Include the validation script and rules for this form*/
775 $form_id="DEM";
776 //LBF forms use the new validation depending on the global value
777 $use_validate_js=$GLOBALS['new_validate'];
780 <?php include_once("$srcdir/validation/validation_script.js.php");?>
783 </body>
784 <script language='JavaScript'>
785 var duplicateFieldsArray=[];
788 // Array of skip conditions for the checkSkipConditions() function.
789 var skipArray = [
790 <?php echo $condition_str; ?>
792 checkSkipConditions();
793 $("input").change(function() {
794 checkSkipConditions();
796 $("select").change(function() {
797 checkSkipConditions();
800 //This code deals with demographics before save action -
801 <?php if ( ($GLOBALS['gbl_edit_patient_form'] == '1') && (checkIfPatientValidationHookIsActive()) ):?>
803 //Use the Zend patient validation hook.
804 //TODO - get the edit part of patient validation hook to work smoothly and then
805 // remove the closeBeforeOpening=1 in the url below.
807 var f = $("form");
809 // Use hook to open the controller and get the new patient validation .
810 // when no params are sent this window will be closed from the zend controller.
811 var url ='<?php echo $GLOBALS['web_root']."/interface/modules/zend_modules/public/patientvalidation";?>';
812 $("#submit_btn").attr("type","button");
813 $("#submit_btn").attr("name","btnSubmit");
814 $("#submit_btn").attr("id","btnSubmit");
815 $("#btnSubmit").click(function( event ) {
816 if(!submitme(<?php echo $GLOBALS['new_validate'] ? 1 : 0;?>,event,'DEM',constraints)){
817 event.preventDefault();
818 return;
820 somethingChanged = false;
821 <?php
822 // D in edit_options indicates the field is used in duplication checking.
823 // This constructs a list of the names of those fields.
824 $mflist = "";
825 $mfres = sqlStatement("SELECT field_id FROM layout_options " .
826 "WHERE form_id = 'DEM' AND uor > 0 AND field_id != '' AND " .
827 "edit_options LIKE '%D%' " .
828 "ORDER BY group_name, seq");
829 while ($mfrow = sqlFetchArray($mfres)) {
830 $field_id = $mfrow['field_id'];
831 if (strpos($field_id, 'em_') === 0) continue;
832 if (!empty($mflist)) $mflist .= ",";
833 $mflist .= "'" . text($field_id) . "'";
834 } ?>
836 var flds = new Array(<?php echo $mflist; ?>);
837 var separator = '?';
838 var valueIsChanged=false;
839 for (var i = 0; i < flds.length; ++i) {
840 var fval = $('#form_' + flds[i]).val();
841 if(duplicateFieldsArray['#form_' + flds[i]]!=fval) {
842 valueIsChanged = true;
846 if (fval && fval != '') {
847 url += separator;
848 separator = '&';
849 url += 'mf_' + flds[i] + '=' + encodeURIComponent(fval);
854 //Only if check for duplicates values are changed open the popup hook screen
855 if(valueIsChanged) {
856 //("value has changed for duplicate check inputs");
857 url += '&page=edit&closeBeforeOpening=1&mf_id='+$("[name='db_id']").val();
858 dlgopen(url, '_blank', 700, 500);
860 else {//other wise submit me is a success just submit the form
861 $('#DEM').submit();
865 <?php endif;?>
867 $(document).ready(function(){
868 //When document is ready collect all the values Marked with D (check duplicate) stored in the db into array duplicateFieldsArray.
869 var flds = new Array(<?php echo $mflist; ?>);
870 for (var i = 0; i < flds.length; ++i) {
871 var fval = $('#form_' + flds[i]).val();
872 duplicateFieldsArray['#form_' + flds[i]] = fval;
875 </script>
878 </html>