minor change to prior commit for 5.0.1-dev
[openemr.git] / interface / new / new_comprehensive.php
blob6b91b5510b4f56b1869ff37ae8fcb9a1b3e59060
1 <?php
2 /**
3 * New patient or search patient.
5 * @package OpenEMR
6 * @link http://www.open-emr.org
7 * @author Rod Roark <rod@sunsetsystems.com>
8 * @author Brady Miller <brady.g.miller@gmail.com>
9 * @copyright Copyright (c) 2009-2017 Rod Roark <rod@sunsetsystems.com>
10 * @copyright Copyright (c) 2017 Brady Miller <brady.g.miller@gmail.com>
11 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
14 require_once("../globals.php");
15 require_once("$srcdir/acl.inc");
16 require_once("$srcdir/options.inc.php");
17 require_once("$srcdir/patient.inc");
18 require_once("$srcdir/erx_javascript.inc.php");
19 require_once("$srcdir/validation/LBF_Validation.php");
20 require_once("$srcdir/patientvalidation.inc.php");
22 // Check authorization.
23 if (!acl_check('patients', 'demo', '', array('write','addonly'))) {
24 die(xlt("Adding demographics is not authorized."));
27 $CPR = 4; // cells per row
29 $searchcolor = empty($GLOBALS['layout_search_color']) ?
30 '#ffff55' : $GLOBALS['layout_search_color'];
32 $WITH_SEARCH = ($GLOBALS['full_new_patient_form'] == '1' || $GLOBALS['full_new_patient_form'] == '2' );
33 $SHORT_FORM = ($GLOBALS['full_new_patient_form'] == '2' || $GLOBALS['full_new_patient_form'] == '3' || $GLOBALS['full_new_patient_form'] == '4');
35 $grparr = array();
36 getLayoutProperties('DEM', $grparr);
38 function getLayoutRes()
40 global $SHORT_FORM;
41 return sqlStatement("SELECT * FROM layout_options " .
42 "WHERE form_id = 'DEM' AND uor > 0 AND field_id != '' " .
43 ($SHORT_FORM ? "AND ( uor > 1 OR edit_options LIKE '%N%' ) " : "") .
44 "ORDER BY group_id, seq");
47 // Determine layout field search treatment from its data type:
48 // 1 = text field
49 // 2 = select list
50 // 0 = not searchable
52 function getSearchClass($data_type)
54 switch ($data_type) {
55 case 1: // single-selection list
56 case 10: // local provider list
57 case 11: // provider list
58 case 12: // pharmacy list
59 case 13: // squads
60 case 14: // address book list
61 case 26: // single-selection list with add
62 case 35: // facilities
63 return 2;
64 case 2: // text field
65 case 3: // textarea
66 case 4: // date
67 return 1;
70 return 0;
73 $fres = getLayoutRes();
75 <html>
76 <head>
77 <?php html_header_show(); ?>
79 <title><?php echo xlt("Search or Add Patient"); ?></title>
81 <link rel="stylesheet" href="<?php echo $GLOBALS['assets_static_relative'] ?>/bootstrap-3-3-4/dist/css/bootstrap.min.css">
82 <?php if ($_SESSION['language_direction'] == 'rtl') { ?>
83 <link rel="stylesheet" href="<?php echo $GLOBALS['assets_static_relative'] ?>/bootstrap-rtl-3-3-4/dist/css/bootstrap-rtl.min.css">
84 <?php } ?>
85 <link rel="stylesheet" href="<?php echo $css_header; ?>" type="text/css">
86 <link rel="stylesheet" href="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker-2-5-4/build/jquery.datetimepicker.min.css">
87 <link rel="stylesheet" type="text/css" href="../../library/js/fancybox/jquery.fancybox-1.2.6.css" media="screen" />
89 <style>
90 body {
91 padding: 5pt 5pt 5pt 5pt;
94 div.section {
95 border: solid;
96 border-width: 1px;
97 border-color: #0000ff;
98 margin: 0 0 0 10pt;
99 padding: 5pt;
102 .form-control {
103 width: auto;
104 display: inline;
105 height: auto;
107 </style>
109 <script type="text/javascript" src="../../library/dialog.js?v=<?php echo $v_js_includes; ?>"></script>
110 <script type="text/javascript" src="../../library/textformat.js?v=<?php echo $v_js_includes; ?>"></script>
111 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-7-2/index.js"></script>
112 <script type="text/javascript" src="../../library/js/common.js?v=<?php echo $v_js_includes; ?>"></script>
113 <script type="text/javascript" src="../../library/js/fancybox/jquery.fancybox-1.2.6.js"></script>
114 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker-2-5-4/build/jquery.datetimepicker.full.min.js"></script>
116 <?php include_once("{$GLOBALS['srcdir']}/options.js.php"); ?>
118 <SCRIPT LANGUAGE="JavaScript"><!--
119 //Visolve - sync the radio buttons - Start
120 if((top.window.parent) && (parent.window)){
121 var wname = top.window.parent.left_nav;
122 fname = (parent.window.name)?parent.window.name:window.name;
123 wname.syncRadios();
124 }//Visolve - sync the radio buttons - End
126 var mypcc = '<?php echo $GLOBALS['phone_country_code'] ?>';
128 // This may be changed to true by the AJAX search script.
129 var force_submit = false;
131 //code used from http://tech.irt.org/articles/js037/
132 function replace(string,text,by) {
133 // Replaces text with by in string
134 var strLength = string.length, txtLength = text.length;
135 if ((strLength == 0) || (txtLength == 0)) return string;
137 var i = string.indexOf(text);
138 if ((!i) && (text != string.substring(0,txtLength))) return string;
139 if (i == -1) return string;
141 var newstr = string.substring(0,i) + by;
143 if (i+txtLength < strLength)
144 newstr += replace(string.substring(i+txtLength,strLength),text,by);
146 return newstr;
149 <?php for ($i=1; $i<=3; $i++) { ?>
150 function auto_populate_employer_address<?php echo $i ?>(){
151 var f = document.demographics_form;
152 if (f.form_i<?php echo $i?>subscriber_relationship.options[f.form_i<?php echo $i?>subscriber_relationship.selectedIndex].value == "self") {
153 f.i<?php echo $i?>subscriber_fname.value=f.form_fname.value;
154 f.i<?php echo $i?>subscriber_mname.value=f.form_mname.value;
155 f.i<?php echo $i?>subscriber_lname.value=f.form_lname.value;
156 f.i<?php echo $i?>subscriber_street.value=f.form_street.value;
157 f.i<?php echo $i?>subscriber_city.value=f.form_city.value;
158 f.form_i<?php echo $i?>subscriber_state.value=f.form_state.value;
159 f.i<?php echo $i?>subscriber_postal_code.value=f.form_postal_code.value;
160 if (f.form_country_code)
161 f.form_i<?php echo $i?>subscriber_country.value=f.form_country_code.value;
162 f.i<?php echo $i?>subscriber_phone.value=f.form_phone_home.value;
163 f.i<?php echo $i?>subscriber_DOB.value=f.form_DOB.value;
164 f.i<?php echo $i?>subscriber_ss.value=f.form_ss.value;
165 f.form_i<?php echo $i?>subscriber_sex.value = f.form_sex.value;
166 f.i<?php echo $i?>subscriber_employer.value=f.form_em_name.value;
167 f.i<?php echo $i?>subscriber_employer_street.value=f.form_em_street.value;
168 f.i<?php echo $i?>subscriber_employer_city.value=f.form_em_city.value;
169 f.form_i<?php echo $i?>subscriber_employer_state.value=f.form_em_state.value;
170 f.i<?php echo $i?>subscriber_employer_postal_code.value=f.form_em_postal_code.value;
171 if (f.form_em_country)
172 f.form_i<?php echo $i?>subscriber_employer_country.value=f.form_em_country.value;
176 <?php } ?>
178 function upperFirst(string,text) {
179 return replace(string,text,text.charAt(0).toUpperCase() + text.substring(1,text.length));
182 // The ins_search.php window calls this to set the selected insurance.
183 function set_insurance(ins_id, ins_name) {
184 var thesel = document.forms[0]['i' + insurance_index + 'provider'];
185 var theopts = thesel.options; // the array of Option objects
186 var i = 0;
187 for (; i < theopts.length; ++i) {
188 if (theopts[i].value == ins_id) {
189 theopts[i].selected = true;
190 return;
193 // no matching option was found so create one, append it to the
194 // end of the list, and select it.
195 theopts[i] = new Option(ins_name, ins_id, false, true);
198 // Indicates which insurance slot is being updated.
199 var insurance_index = 0;
201 // The OnClick handler for searching/adding the insurance company.
202 function ins_search(ins) {
203 insurance_index = ins;
204 return false;
207 function checkNum () {
208 var re= new RegExp();
209 re = /^\d*\.?\d*$/;
210 str=document.forms[0].monthly_income.value;
211 if(re.exec(str))
213 }else{
214 alert("<?php echo xls("Please enter a dollar amount using only numbers and a decimal point."); ?>");
218 // This capitalizes the first letter of each word in the passed input
219 // element. It also strips out extraneous spaces.
220 function capitalizeMe(elem) {
221 var a = elem.value.split(' ');
222 var s = '';
223 for(var i = 0; i < a.length; ++i) {
224 if (a[i].length > 0) {
225 if (s.length > 0) s += ' ';
226 s += a[i].charAt(0).toUpperCase() + a[i].substring(1);
229 elem.value = s;
232 // Onkeyup handler for policy number. Allows only A-Z and 0-9.
233 function policykeyup(e) {
234 var v = e.value.toUpperCase();
235 var filteredString="";
236 for (var i = 0; i < v.length; ++i) {
237 var c = v.charAt(i);
238 if ((c >= '0' && c <= '9') ||
239 (c >= 'A' && c <= 'Z') ||
240 (c == '*') ||
241 (c == '-') ||
242 (c == '_') ||
243 (c == '(') ||
244 (c == ')') ||
245 (c == '#'))
247 filteredString+=c;
250 e.value = filteredString;
251 return;
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 errMsgs = new Array();
276 <?php generate_layout_validation('DEM'); ?>
277 <?php if ($GLOBALS['erx_enable']) { ?>
278 alertMsg='';
279 for(i=0;i<f.length;i++){
280 if(f[i].type=='text' && f[i].value)
282 if(f[i].name == 'form_fname' || f[i].name == 'form_mname' || f[i].name == 'form_lname')
284 alertMsg += checkLength(f[i].name,f[i].value,35);
285 alertMsg += checkUsername(f[i].name,f[i].value);
287 else if(f[i].name == 'form_street' || f[i].name == 'form_city')
289 alertMsg += checkLength(f[i].name,f[i].value,35);
290 alertMsg += checkAlphaNumericExtended(f[i].name,f[i].value);
292 else if(f[i].name == 'form_phone_home')
294 alertMsg += checkPhone(f[i].name,f[i].value);
298 if(alertMsg)
300 alert(alertMsg);
301 return false;
303 <?php } ?>
304 var msg = "";
305 msg += "<?php echo xla('The following fields are required'); ?>:\n\n";
306 for ( var i = 0; i < errMsgs.length; i++ ) {
307 msg += errMsgs[i] + "\n";
309 msg += "\n<?php echo xla('Please fill them in before continuing.'); ?>";
312 //Misc Deceased Date Validation for Future Date
313 var dateVal = document.getElementById("form_deceased_date").value;
314 var currentDate;
315 var d = new Date();
316 month = '' + (d.getMonth() + 1),
317 day = '' + d.getDate(),
318 year = d.getFullYear();
319 if (month.length < 2) month = '0' + month;
320 if (day.length < 2) day = '0' + day;
321 currentDate = year+'-'+month+'-'+day;
322 if(errMsgs.length > 0 || dateVal > currentDate)
324 if(errMsgs.length > 0)
325 alert(msg);
326 if(dateVal > currentDate)
327 alert ('<?php echo xls("Deceased Date should not be greater than Today"); ?>');
328 return false;
330 return true;
333 function toggleSearch(elem) {
334 var f = document.forms[0];
335 <?php if ($WITH_SEARCH) { ?>
336 // Toggle background color.
337 if (elem.style.backgroundColor == '')
338 elem.style.backgroundColor = '<?php echo $searchcolor; ?>';
339 else
340 elem.style.backgroundColor = '';
341 <?php } ?>
342 if (force_submit) {
343 force_submit = false;
344 f.create.value = '<?php echo xla('Create New Patient'); ?>';
346 return true;
349 // If a <select> list is dropped down, this is its name.
350 var open_sel_name = '';
352 function selClick(elem) {
353 if (open_sel_name == elem.name) {
354 open_sel_name = '';
356 else {
357 open_sel_name = elem.name;
358 toggleSearch(elem);
360 return true;
363 function selBlur(elem) {
364 if (open_sel_name == elem.name) {
365 open_sel_name = '';
367 return true;
370 // This invokes the patient search dialog.
371 function searchme() {
372 var f = document.forms[0];
373 var url = '../main/finder/patient_select.php?popup=1';
375 <?php
376 $lres = getLayoutRes();
378 while ($lrow = sqlFetchArray($lres)) {
379 $field_id = $lrow['field_id'];
380 if (strpos($field_id, 'em_') === 0) {
381 continue;
384 $data_type = $lrow['data_type'];
385 $fldname = "form_$field_id";
386 switch (getSearchClass($data_type)) {
387 case 1:
388 echo
389 " if (f.$fldname.style.backgroundColor != '' && trimlen(f.$fldname.value) > 0) {\n" .
390 " url += '&$field_id=' + encodeURIComponent(f.$fldname.value);\n" .
391 " }\n";
392 break;
393 case 2:
394 echo
395 " if (f.$fldname.style.backgroundColor != '' && f.$fldname.selectedIndex > 0) {\n" .
396 " url += '&$field_id=' + encodeURIComponent(f.$fldname.options[f.$fldname.selectedIndex].value);\n" .
397 " }\n";
398 break;
403 dlgopen(url, '_blank', 700, 500);
406 //-->
408 </script>
409 </head>
411 <body class="body_top">
413 <?php
414 /*Get the constraint from the DB-> LBF forms accordinf the form_id*/
415 $constraints = LBF_Validation::generate_validate_constraints("DEM");
417 <script> var constraints = <?php echo $constraints;?>; </script>
419 <form action='new_comprehensive_save.php' name='demographics_form' id="DEM" method='post' onsubmit='return submitme(<?php echo $GLOBALS['new_validate'] ? 1 : 0;?>,event,"DEM",constraints)'>
421 <div class="container-fluid">
422 <div class="row">
423 <div class="col-xs-12">
424 <div class="page-header">
425 <h2><?php echo xlt('Search or Add Patient');?></h2>
426 </div>
427 </div>
428 <div class="col-xs-12">
429 <div class="btn-group">
430 <?php if ($WITH_SEARCH) { ?>
431 <button type="button" class="btn btn-default btn-search" id="search" value="<?php echo xla('Search'); ?>">
432 <?php echo xlt('Search'); ?>
433 </button>
434 <?php } ?>
435 <button type="button" class="btn btn-default btn-save" name='create' id="create" value="<?php echo xla('Create New Patient'); ?>">
436 <?php echo xlt('Create New Patient'); ?>
437 </button>
438 </div>
439 <hr>
440 </div>
441 </div>
442 </div>
444 <table width='100%' cellpadding='0' cellspacing='8'>
445 <tr>
446 <td align='left' valign='top'>
447 <?php if ($SHORT_FORM) {
448 echo " <center>\n";
449 } ?>
450 <?php
452 function end_cell()
454 global $item_count, $cell_count;
455 if ($item_count > 0) {
456 echo "</td>";
457 $item_count = 0;
461 function end_row()
463 global $cell_count, $CPR;
464 end_cell();
465 if ($cell_count > 0) {
466 for (; $cell_count < $CPR;
467 ++$cell_count) {
468 echo "<td></td>";
471 echo "</tr>\n";
472 $cell_count = 0;
476 function end_group()
478 global $last_group, $SHORT_FORM;
479 if (strlen($last_group) > 0) {
480 end_row();
481 echo " </table>\n";
482 if (!$SHORT_FORM) {
483 echo "</div>\n";
488 $last_group = '';
489 $cell_count = 0;
490 $item_count = 0;
491 $display_style = 'block';
492 $group_seq = 0; // this gives the DIV blocks unique IDs
494 $condition_str = '';
496 while ($frow = sqlFetchArray($fres)) {
497 $this_group = $frow['group_id'];
498 $titlecols = $frow['titlecols'];
499 $datacols = $frow['datacols'];
500 $data_type = $frow['data_type'];
501 $field_id = $frow['field_id'];
502 $list_id = $frow['list_id'];
503 $currvalue = '';
505 // Accumulate action conditions into a JSON expression for the browser side.
506 accumActionConditions($field_id, $condition_str, $frow['conditions']);
508 if (strpos($field_id, 'em_') === 0) {
509 $tmp = substr($field_id, 3);
510 if (isset($result2[$tmp])) {
511 $currvalue = $result2[$tmp];
513 } else {
514 if (isset($result[$field_id])) {
515 $currvalue = $result[$field_id];
519 // Handle a data category (group) change.
520 if (strcmp($this_group, $last_group) != 0) {
521 if (!$SHORT_FORM) {
522 end_group();
523 $group_seq++; // ID for DIV tags
524 $group_name = $grparr[$this_group]['grp_title'];
526 if (strlen($last_group) > 0) {
527 echo "<br />";
530 echo "<span class='bold'><input type='checkbox' name='form_cb_$group_seq' id='form_cb_$group_seq' value='1' " .
531 "onclick='return divclick(this,\"div_$group_seq\");'";
532 if ($display_style == 'block') {
533 echo " checked";
536 // Modified 6-09 by BM - Translate if applicable
537 echo " /><b>" . xl_layout_label($group_name) . "</b></span>\n";
539 echo "<div id='div_$group_seq' class='section' style='display:$display_style;'>\n";
540 echo " <table border='0' cellpadding='0'>\n";
541 $display_style = 'none';
542 } else if (strlen($last_group) == 0) {
543 echo " <table border='0' cellpadding='0'>\n";
546 $last_group = $this_group;
549 // Handle starting of a new row.
550 if (($titlecols > 0 && $cell_count >= $CPR) || $cell_count == 0) {
551 end_row();
552 echo " <tr>";
555 if ($item_count == 0 && $titlecols == 0) {
556 $titlecols = 1;
559 $field_id_label='label_'.$frow['field_id'];
560 // Handle starting of a new label cell.
561 if ($titlecols > 0) {
562 end_cell();
563 echo "<td colspan='$titlecols' id='$field_id_label'";
564 echo ($frow['uor'] == 2) ? " class='required'" : " class='bold'";
565 if ($cell_count == 2) {
566 echo " style='padding-left:10pt'";
569 echo ">";
570 $cell_count += $titlecols;
573 ++$item_count;
575 echo "<b>";
577 // Modified 6-09 by BM - Translate if applicable
578 if ($frow['title']) {
579 echo (xl_layout_label($frow['title']).":");
580 } else {
581 echo "&nbsp;";
584 echo "</b>";
586 // Handle starting of a new data cell.
587 if ($datacols > 0) {
588 $id_field_text = "text_".$frow['field_id'];
589 end_cell();
590 echo "<td colspan='$datacols' class='text data'";
591 if ($cell_count > 0) {
592 echo " style='padding-left:5pt'". " id='".$id_field_text."'";
595 echo ">";
596 $cell_count += $datacols;
599 ++$item_count;
600 generate_form_field($frow, $currvalue);
603 end_group();
606 <?php
607 if (! $GLOBALS['simplified_demographics']) {
608 $insurancei = getInsuranceProviders();
609 $pid = 0;
610 $insurance_headings = array(xl("Primary Insurance Provider"), xl("Secondary Insurance Provider"), xl("Tertiary Insurance provider"));
611 $insurance_info = array();
612 $insurance_info[1] = getInsuranceData($pid, "primary");
613 $insurance_info[2] = getInsuranceData($pid, "secondary");
614 $insurance_info[3] = getInsuranceData($pid, "tertiary");
616 echo "<br /><span class='bold'><input type='checkbox' name='form_cb_ins' value='1' " .
617 "onclick='return divclick(this,\"div_ins\");'";
618 if ($display_style == 'block') {
619 echo " checked";
622 echo " /><b>" . xlt('Insurance') . "</b></span>\n";
623 echo "<div id='div_ins' class='section' style='display:$display_style;'>\n";
625 for ($i=1; $i<=3; $i++) {
626 $result3 = $insurance_info[$i];
628 <table border="0">
629 <tr>
630 <td valign='top' colspan='2'>
631 <span class='required'><?php echo text($insurance_headings[$i -1]).":"?></span>
632 <select name="i<?php echo $i?>provider" class="form-control">
633 <option value=""><?php echo xlt('Unassigned'); ?></option>
634 <?php
635 foreach ($insurancei as $iid => $iname) {
636 echo "<option value='" . attr($iid) . "'";
637 if (strtolower($iid) == strtolower($result3{"provider"})) {
638 echo " selected";
641 echo ">" . text($iname) . "</option>\n";
644 </select>&nbsp;<a class='iframe medium_modal' href='../practice/ins_search.php' onclick='ins_search(<?php echo $i?>)'>
645 <span> <?php echo xlt('Search/Add Insurer'); ?></span></a>
646 </td>
647 </tr>
648 <tr>
649 <td valign=top>
650 <table border="0">
652 <tr>
653 <td>
654 <span class='required'><?php echo xlt('Plan Name'); ?>: </span>
655 </td>
656 <td>
657 <input type='entry' class='form-control' size='20' name='i<?php echo $i?>plan_name' value="<?php echo attr($result3{"plan_name"}); ?>"
658 onchange="capitalizeMe(this);" />&nbsp;&nbsp;
659 </td>
660 </tr>
662 <tr>
663 <td>
664 <span class='required'><?php echo xlt('Effective Date'); ?>: </span>
665 </td>
666 <td>
667 <input type='entry' size='11' class='datepicker form-control' name='i<?php echo $i ?>effective_date'
668 id='i<?php echo $i ?>effective_date'
669 value='<?php echo attr($result3['date']); ?>'
670 title='yyyy-mm-dd' />
671 </td>
672 </tr>
674 <tr>
675 <td><span class=required><?php echo xlt('Policy Number'); ?>: </span></td>
676 <td><input type='entry' class='form-control' size='16' name='i<?php echo $i?>policy_number' value="<?php echo attr($result3{"policy_number"}); ?>"
677 onkeyup='policykeyup(this)'></td>
678 </tr>
680 <tr>
681 <td><span class=required><?php echo xlt('Group Number'); ?>: </span></td>
682 <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>
683 </tr>
685 <tr<?php echo ($GLOBALS['omit_employers']) ? " style='display:none'" : ""; ?>>
686 <td class='required'><?php echo xlt('Subscriber Employer (SE)'); ?><br><span style='font-weight:normal'>
687 (<?php echo xlt('if unemployed enter Student'); ?>,<br><?php echo xlt('PT Student, or leave blank'); ?>): </span></td>
688 <td><input type=entry class='form-control' size=25 name=i<?php echo $i?>subscriber_employer
689 value="<?php echo attr($result3{"subscriber_employer"}); ?>"
690 onchange="capitalizeMe(this);" /></td>
691 </tr>
693 <tr<?php echo ($GLOBALS['omit_employers']) ? " style='display:none'" : ""; ?>>
694 <td><span class=required><?php echo xlt('SE Address'); ?>: </span></td>
695 <td><input type=entry class='form-control' size=25 name=i<?php echo $i?>subscriber_employer_street
696 value="<?php echo attr($result3{"subscriber_employer_street"}); ?>"
697 onchange="capitalizeMe(this);" /></td>
698 </tr>
700 <tr<?php echo ($GLOBALS['omit_employers']) ? " style='display:none'" : ""; ?>>
701 <td colspan="2">
702 <table>
703 <tr>
704 <td><span class=required><?php echo xlt('SE City'); ?>: </span></td>
705 <td><input type=entry class='form-control' size=15 name=i<?php echo $i?>subscriber_employer_city
706 value="<?php echo attr($result3{"subscriber_employer_city"}); ?>"
707 onchange="capitalizeMe(this);" /></td>
708 <td><span class=required><?php echo ($GLOBALS['phone_country_code'] == '1') ? xlt('SE State') : xlt('SE Locality') ?>: </span></td>
709 <td>
710 <?php
711 // Modified 7/2009 by BM to incorporate data types
712 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']);
714 </td>
715 </tr>
716 <tr>
717 <td><span class=required><?php echo ($GLOBALS['phone_country_code'] == '1') ? xlt('SE Zip Code') : xlt('SE Postal Code') ?>: </span></td>
718 <td><input type=entry class='form-control' size=10 name=i<?php echo $i?>subscriber_employer_postal_code value="<?php echo attr($result3{"subscriber_employer_postal_code"}); ?>"></td>
719 <td><span class=required><?php xl('SE Country', 'e'); ?>: </span></td>
720 <td>
721 <?php
722 // Modified 7/2009 by BM to incorporate data types
723 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']);
725 </td>
726 </tr>
727 </table>
728 </td>
729 </tr>
731 </table>
732 </td>
734 <td valign=top>
735 <span class=required><?php echo xlt('Subscriber'); ?>: </span>
736 <input type=entry class='form-control' size=10 name=i<?php echo $i?>subscriber_fname
737 value="<?php echo attr($result3{"subscriber_fname"}); ?>"
738 onchange="capitalizeMe(this);" />
739 <input type=entry class='form-control' size=3 name=i<?php echo $i?>subscriber_mname
740 value="<?php echo attr($result3{"subscriber_mname"}); ?>"
741 onchange="capitalizeMe(this);" />
742 <input type=entry class='form-control' size=10 name=i<?php echo $i?>subscriber_lname
743 value="<?php echo attr($result3{"subscriber_lname"}); ?>"
744 onchange="capitalizeMe(this);" />
745 <br>
746 <span class=required><?php echo xlt('Relationship'); ?>: </span>
747 <?php
748 // Modified 6/2009 by BM to use list_options and function
749 generate_form_field(array('data_type'=>1,'field_id'=>('i'.$i.'subscriber_relationship'),'list_id'=>'sub_relation','empty_title'=>' '), $result3['subscriber_relationship']);
751 <a href="javascript:popUp('../../interface/patient_file/summary/browse.php?browsenum=<?php echo $i?>')" class=text>(<?php echo xla('Browse'); ?>)</a><br />
753 <span class=bold><?php echo xlt('D.O.B.'); ?>: </span>
754 <input type='entry' size='11' class='datepicker form-control' name='i<?php echo $i?>subscriber_DOB'
755 id='i<?php echo $i?>subscriber_DOB'
756 value='<?php echo attr($result3['subscriber_DOB']); ?>'
757 title='yyyy-mm-dd' />
759 <span class=bold><?php echo xlt('S.S.'); ?>: </span>
760 <input type=entry class='form-control' size=11 name=i<?php echo $i?>subscriber_ss value="<?php echo attr($result3{"subscriber_ss"}); ?>">&nbsp;
761 <span class=bold><?php echo xlt('Sex'); ?>: </span>
762 <?php
763 // Modified 6/2009 by BM to use list_options and function
764 generate_form_field(array('data_type'=>1,'field_id'=>('i'.$i.'subscriber_sex'),'list_id'=>'sex'), $result3['subscriber_sex']);
766 <br>
767 <span class=required><?php echo xlt('Subscriber Address'); ?>: </span>
768 <input type=entry class='form-control' size=25 name=i<?php echo $i?>subscriber_street
769 value="<?php echo attr($result3{"subscriber_street"}); ?>"
770 onchange="capitalizeMe(this);" /><br>
771 <span class=required><?php echo xlt('City'); ?>: </span>
772 <input type=entry class='form-control' size=15 name=i<?php echo $i?>subscriber_city
773 value="<?php echo attr($result3{"subscriber_city"}); ?>"
774 onchange="capitalizeMe(this);" />
775 <span class=required><?php echo ($GLOBALS['phone_country_code'] == '1') ? xlt('State') : xlt('Locality') ?>: </span>
776 <?php
777 // Modified 7/2009 by BM to incorporate data types
778 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']);
780 <br />
781 <span class=required><?php echo ($GLOBALS['phone_country_code'] == '1') ? xlt('Zip Code') : xlt('Postal Code') ?>: </span>
782 <input type=entry class='form-control' size=10 name=i<?php echo $i?>subscriber_postal_code value="<?php echo attr($result3{"subscriber_postal_code"}); ?>">
783 <span class='required'<?php echo ($GLOBALS['omit_employers']) ? " style='display:none'" : ""; ?>>
784 <?php echo xlt('Country'); ?>: </span>
785 <?php
786 // Modified 7/2009 by BM to incorporate data types
787 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']);
789 <br />
790 <span class=bold><?php echo xlt('Subscriber Phone'); ?>:
791 <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)' />
792 </span><br />
793 <span 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"}); ?>">
794 </span><br />
795 <span class='required'><?php echo xlt('Accept Assignment'); ?>: </span>
796 <select class='form-control' name=i<?php echo $i?>accept_assignment>
797 <option value="TRUE" <?php echo (strtoupper($result3{"accept_assignment"}) == "TRUE") ? "selected" : ""; ?>><?php echo xlt('YES'); ?></option>
798 <option value="FALSE" <?php echo (strtoupper($result3{"accept_assignment"}) == "FALSE") ? "selected" : ""; ?>><?php echo xlt('NO'); ?></option>
799 </select>
800 </td>
801 </tr>
803 </table>
804 <hr />
805 <?php
808 echo "</div>\n";
809 } // end of "if not simplified_demographics"
812 <?php if ($SHORT_FORM) {
813 echo " </center>\n";
814 } ?>
816 </td>
817 <td align='right' valign='top' width='1%' nowrap>
818 <!-- Image upload stuff was here but got moved. -->
819 </td>
820 </tr>
821 </table>
823 </form>
825 <!-- include support for the list-add selectbox feature -->
826 <?php include($GLOBALS['fileroot']."/library/options_listadd.inc"); ?>
828 </body>
830 <script language="JavaScript">
832 // hard code validation for old validation, in the new validation possible to add match rules
833 <?php if ($GLOBALS['new_validate'] == 0) { ?>
835 // fix inconsistently formatted phone numbers from the database
836 var f = document.forms[0];
837 if (f.form_phone_contact) phonekeyup(f.form_phone_contact,mypcc);
838 if (f.form_phone_home ) phonekeyup(f.form_phone_home ,mypcc);
839 if (f.form_phone_biz ) phonekeyup(f.form_phone_biz ,mypcc);
840 if (f.form_phone_cell ) phonekeyup(f.form_phone_cell ,mypcc);
842 <?php }?>
844 <?php echo $date_init; ?>
846 // -=- jQuery makes life easier -=-
848 // var matches = 0; // number of patients that match the demographic information being entered
849 // var override = false; // flag that overrides the duplication warning
851 $(document).ready(function() {
852 enable_modals();
853 $(".medium_modal").fancybox( {
854 'overlayOpacity' : 0.0,
855 'showCloseButton' : true,
856 'frameHeight' : 460,
857 'frameWidth' : 650
859 // added to integrate insurance stuff
860 <?php for ($i=1; $i<=3; $i++) { ?>
861 $("#form_i<?php echo $i?>subscriber_relationship").change(function() { auto_populate_employer_address<?php echo $i?>(); });
862 <?php } ?>
864 $('#search').click(function() { searchme(); });
865 $('#create').click(function() { check()});
867 var check = function(e) {
868 <?php if ($GLOBALS['new_validate']) {?>
869 var valid = submitme(<?php echo $GLOBALS['new_validate'] ? 1 : 0;?>,e,"DEM",constraints);
870 <?php } else {?>
871 top.restoreSession();
872 var f = document.forms[0];
873 var valid = validate(f);
874 <?php }?>
875 if (valid) {
876 if (force_submit) {
877 // In this case dups were shown already and Save should just save.
878 top.restoreSession();
879 f.submit();
880 return;
883 <?php
884 // D in edit_options indicates the field is used in duplication checking.
885 // This constructs a list of the names of those fields.
886 $mflist = "";
887 $mfres = sqlStatement("SELECT * FROM layout_options " .
888 "WHERE form_id = 'DEM' AND uor > 0 AND field_id != '' AND " .
889 "(edit_options LIKE '%D%' OR edit_options LIKE '%W%' )" .
890 "ORDER BY group_id, seq");
891 while ($mfrow = sqlFetchArray($mfres)) {
892 $field_id = $mfrow['field_id'];
893 if (strpos($field_id, 'em_') === 0) {
894 continue;
897 if (!empty($mflist)) {
898 $mflist .= ",";
901 $mflist .= "'" . htmlentities($field_id) . "'";
904 <?php if (($GLOBALS['full_new_patient_form'] == '4') && (checkIfPatientValidationHookIsActive())) :?>
905 // Use zend module patient validation hook to open the controller and send the dup-checker fields.
906 var url ='<?php echo $GLOBALS['web_root']."/interface/modules/zend_modules/public/patientvalidation";?>';
907 <?php else :?>
908 // Build and invoke the URL to create the dup-checker dialog.
909 var url = 'new_search_popup.php';
910 <?php endif;?>
912 var flds = new Array(<?php echo $mflist; ?>);
913 var separator = '?';
914 for (var i = 0; i < flds.length; ++i) {
915 var fval = $('#form_' + flds[i]).val();
916 if (fval && fval != '') {
917 url += separator;
918 separator = '&';
919 url += 'mf_' + flds[i] + '=' + encodeURIComponent(fval);
922 url+="&close"
923 dlgopen(url, '_blank', 700, 500);
924 } // end function
925 } // end function
928 // Set onclick/onfocus handlers for toggling background color.
929 <?php
930 $lres = getLayoutRes();
931 while ($lrow = sqlFetchArray($lres)) {
932 $field_id = $lrow['field_id'];
933 if (strpos($field_id, 'em_') === 0) {
934 continue;
937 switch (getSearchClass($lrow['data_type'])) {
938 case 1:
939 echo " \$('#form_$field_id').click(function() { toggleSearch(this); });\n";
940 break;
941 case 2:
942 echo " \$('#form_$field_id').click(function() { selClick(this); });\n";
943 echo " \$('#form_$field_id').blur(function() { selBlur(this); });\n";
944 break;
949 $('.datepicker').datetimepicker({
950 <?php $datetimepicker_timepicker = false; ?>
951 <?php $datetimepicker_showseconds = false; ?>
952 <?php $datetimepicker_formatInput = false; ?>
953 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
954 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
956 $('.datetimepicker').datetimepicker({
957 <?php $datetimepicker_timepicker = true; ?>
958 <?php $datetimepicker_showseconds = false; ?>
959 <?php $datetimepicker_formatInput = false; ?>
960 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
961 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
964 }); // end document.ready
966 </script>
967 <?php /*Include the validation script and rules for this form*/
968 $form_id="DEM";
971 <?php
972 //LBF forms use the new validation depending on the global value
973 $use_validate_js=$GLOBALS['new_validate'];
974 include_once("$srcdir/validation/validation_script.js.php");?>
975 <script language='JavaScript'>
976 // Array of skip conditions for the checkSkipConditions() function.
977 var skipArray = [
978 <?php echo $condition_str; ?>
980 checkSkipConditions();
981 $("input").change(function() {
982 checkSkipConditions();
984 $("select").change(function() {
985 checkSkipConditions();
987 </script>
989 </html>