minor changes in ui
[openemr.git] / interface / new / new_comprehensive.php
blobed59dc678aaef605d78977f70dd48c2204407dea
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-2010 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 function getLayoutRes()
37 global $SHORT_FORM;
38 return sqlStatement("SELECT * FROM layout_options " .
39 "WHERE form_id = 'DEM' AND uor > 0 AND field_id != '' " .
40 ($SHORT_FORM ? "AND ( uor > 1 OR edit_options LIKE '%N%' ) " : "") .
41 "ORDER BY group_name, seq");
44 // Determine layout field search treatment from its data type:
45 // 1 = text field
46 // 2 = select list
47 // 0 = not searchable
49 function getSearchClass($data_type)
51 switch ($data_type) {
52 case 1: // single-selection list
53 case 10: // local provider list
54 case 11: // provider list
55 case 12: // pharmacy list
56 case 13: // squads
57 case 14: // address book list
58 case 26: // single-selection list with add
59 case 35: // facilities
60 return 2;
61 case 2: // text field
62 case 3: // textarea
63 case 4: // date
64 return 1;
67 return 0;
70 $fres = getLayoutRes();
72 <html>
73 <head>
74 <?php html_header_show(); ?>
76 <title><?php echo xlt("Search or Add Patient"); ?></title>
78 <link rel="stylesheet" href="<?php echo $css_header; ?>" type="text/css">
79 <link rel="stylesheet" href="<?php echo $GLOBALS['assets_static_relative'] ?>/bootstrap-3-3-4/dist/css/bootstrap.min.css">
80 <?php if ($_SESSION['language_direction'] == 'rtl') { ?>
81 <link rel="stylesheet" href="<?php echo $GLOBALS['assets_static_relative'] ?>/bootstrap-rtl-3-3-4/dist/css/bootstrap-rtl.min.css">
82 <?php } ?>
83 <link rel="stylesheet" href="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker-2-5-4/build/jquery.datetimepicker.min.css">
84 <link rel="stylesheet" type="text/css" href="../../library/js/fancybox/jquery.fancybox-1.2.6.css" media="screen" />
86 <style>
87 body {
88 padding: 5pt 5pt 5pt 5pt;
91 div.section {
92 border: solid;
93 border-width: 1px;
94 border-color: #0000ff;
95 margin: 0 0 0 10pt;
96 padding: 5pt;
99 .form-control {
100 width: auto;
101 display: inline;
102 height: auto;
104 </style>
106 <script type="text/javascript" src="../../library/dialog.js?v=<?php echo $v_js_includes; ?>"></script>
107 <script type="text/javascript" src="../../library/textformat.js?v=<?php echo $v_js_includes; ?>"></script>
108 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-7-2/index.js"></script>
109 <script type="text/javascript" src="../../library/js/common.js?v=<?php echo $v_js_includes; ?>"></script>
110 <script type="text/javascript" src="../../library/js/fancybox/jquery.fancybox-1.2.6.js"></script>
111 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker-2-5-4/build/jquery.datetimepicker.full.min.js"></script>
113 <?php include_once("{$GLOBALS['srcdir']}/options.js.php"); ?>
115 <SCRIPT LANGUAGE="JavaScript"><!--
116 //Visolve - sync the radio buttons - Start
117 if((top.window.parent) && (parent.window)){
118 var wname = top.window.parent.left_nav;
119 fname = (parent.window.name)?parent.window.name:window.name;
120 wname.syncRadios();
121 }//Visolve - sync the radio buttons - End
123 var mypcc = '<?php echo $GLOBALS['phone_country_code'] ?>';
125 // This may be changed to true by the AJAX search script.
126 var force_submit = false;
128 //code used from http://tech.irt.org/articles/js037/
129 function replace(string,text,by) {
130 // Replaces text with by in string
131 var strLength = string.length, txtLength = text.length;
132 if ((strLength == 0) || (txtLength == 0)) return string;
134 var i = string.indexOf(text);
135 if ((!i) && (text != string.substring(0,txtLength))) return string;
136 if (i == -1) return string;
138 var newstr = string.substring(0,i) + by;
140 if (i+txtLength < strLength)
141 newstr += replace(string.substring(i+txtLength,strLength),text,by);
143 return newstr;
146 <?php for ($i=1; $i<=3; $i++) { ?>
147 function auto_populate_employer_address<?php echo $i ?>(){
148 var f = document.demographics_form;
149 if (f.form_i<?php echo $i?>subscriber_relationship.options[f.form_i<?php echo $i?>subscriber_relationship.selectedIndex].value == "self") {
150 f.i<?php echo $i?>subscriber_fname.value=f.form_fname.value;
151 f.i<?php echo $i?>subscriber_mname.value=f.form_mname.value;
152 f.i<?php echo $i?>subscriber_lname.value=f.form_lname.value;
153 f.i<?php echo $i?>subscriber_street.value=f.form_street.value;
154 f.i<?php echo $i?>subscriber_city.value=f.form_city.value;
155 f.form_i<?php echo $i?>subscriber_state.value=f.form_state.value;
156 f.i<?php echo $i?>subscriber_postal_code.value=f.form_postal_code.value;
157 if (f.form_country_code)
158 f.form_i<?php echo $i?>subscriber_country.value=f.form_country_code.value;
159 f.i<?php echo $i?>subscriber_phone.value=f.form_phone_home.value;
160 f.i<?php echo $i?>subscriber_DOB.value=f.form_DOB.value;
161 f.i<?php echo $i?>subscriber_ss.value=f.form_ss.value;
162 f.form_i<?php echo $i?>subscriber_sex.value = f.form_sex.value;
163 f.i<?php echo $i?>subscriber_employer.value=f.form_em_name.value;
164 f.i<?php echo $i?>subscriber_employer_street.value=f.form_em_street.value;
165 f.i<?php echo $i?>subscriber_employer_city.value=f.form_em_city.value;
166 f.form_i<?php echo $i?>subscriber_employer_state.value=f.form_em_state.value;
167 f.i<?php echo $i?>subscriber_employer_postal_code.value=f.form_em_postal_code.value;
168 if (f.form_em_country)
169 f.form_i<?php echo $i?>subscriber_employer_country.value=f.form_em_country.value;
173 <?php } ?>
175 function upperFirst(string,text) {
176 return replace(string,text,text.charAt(0).toUpperCase() + text.substring(1,text.length));
179 // The ins_search.php window calls this to set the selected insurance.
180 function set_insurance(ins_id, ins_name) {
181 var thesel = document.forms[0]['i' + insurance_index + 'provider'];
182 var theopts = thesel.options; // the array of Option objects
183 var i = 0;
184 for (; i < theopts.length; ++i) {
185 if (theopts[i].value == ins_id) {
186 theopts[i].selected = true;
187 return;
190 // no matching option was found so create one, append it to the
191 // end of the list, and select it.
192 theopts[i] = new Option(ins_name, ins_id, false, true);
195 // Indicates which insurance slot is being updated.
196 var insurance_index = 0;
198 // The OnClick handler for searching/adding the insurance company.
199 function ins_search(ins) {
200 insurance_index = ins;
201 return false;
204 function checkNum () {
205 var re= new RegExp();
206 re = /^\d*\.?\d*$/;
207 str=document.forms[0].monthly_income.value;
208 if(re.exec(str))
210 }else{
211 alert("<?php echo xls("Please enter a dollar amount using only numbers and a decimal point."); ?>");
215 // This capitalizes the first letter of each word in the passed input
216 // element. It also strips out extraneous spaces.
217 function capitalizeMe(elem) {
218 var a = elem.value.split(' ');
219 var s = '';
220 for(var i = 0; i < a.length; ++i) {
221 if (a[i].length > 0) {
222 if (s.length > 0) s += ' ';
223 s += a[i].charAt(0).toUpperCase() + a[i].substring(1);
226 elem.value = s;
229 // Onkeyup handler for policy number. Allows only A-Z and 0-9.
230 function policykeyup(e) {
231 var v = e.value.toUpperCase();
232 var filteredString="";
233 for (var i = 0; i < v.length; ++i) {
234 var c = v.charAt(i);
235 if ((c >= '0' && c <= '9') ||
236 (c >= 'A' && c <= 'Z') ||
237 (c == '*') ||
238 (c == '-') ||
239 (c == '_') ||
240 (c == '(') ||
241 (c == ')') ||
242 (c == '#'))
244 filteredString+=c;
247 e.value = filteredString;
248 return;
251 function divclick(cb, divid) {
252 var divstyle = document.getElementById(divid).style;
253 if (cb.checked) {
254 divstyle.display = 'block';
255 } else {
256 divstyle.display = 'none';
258 return true;
261 // Compute the length of a string without leading and trailing spaces.
262 function trimlen(s) {
263 var i = 0;
264 var j = s.length - 1;
265 for (; i <= j && s.charAt(i) == ' '; ++i);
266 for (; i <= j && s.charAt(j) == ' '; --j);
267 if (i > j) return 0;
268 return j + 1 - i;
271 function validate(f) {
272 var errMsgs = new Array();
273 <?php generate_layout_validation('DEM'); ?>
274 <?php if ($GLOBALS['erx_enable']) { ?>
275 alertMsg='';
276 for(i=0;i<f.length;i++){
277 if(f[i].type=='text' && f[i].value)
279 if(f[i].name == 'form_fname' || f[i].name == 'form_mname' || f[i].name == 'form_lname')
281 alertMsg += checkLength(f[i].name,f[i].value,35);
282 alertMsg += checkUsername(f[i].name,f[i].value);
284 else if(f[i].name == 'form_street' || f[i].name == 'form_city')
286 alertMsg += checkLength(f[i].name,f[i].value,35);
287 alertMsg += checkAlphaNumericExtended(f[i].name,f[i].value);
289 else if(f[i].name == 'form_phone_home')
291 alertMsg += checkPhone(f[i].name,f[i].value);
295 if(alertMsg)
297 alert(alertMsg);
298 return false;
300 <?php } ?>
301 var msg = "";
302 msg += "<?php echo xla('The following fields are required'); ?>:\n\n";
303 for ( var i = 0; i < errMsgs.length; i++ ) {
304 msg += errMsgs[i] + "\n";
306 msg += "\n<?php echo xla('Please fill them in before continuing.'); ?>";
309 //Misc Deceased Date Validation for Future Date
310 var dateVal = document.getElementById("form_deceased_date").value;
311 var currentDate;
312 var d = new Date();
313 month = '' + (d.getMonth() + 1),
314 day = '' + d.getDate(),
315 year = d.getFullYear();
316 if (month.length < 2) month = '0' + month;
317 if (day.length < 2) day = '0' + day;
318 currentDate = year+'-'+month+'-'+day;
319 if(errMsgs.length > 0 || dateVal > currentDate)
321 if(errMsgs.length > 0)
322 alert(msg);
323 if(dateVal > currentDate)
324 alert ('<?php echo xls("Deceased Date should not be greater than Today"); ?>');
325 return false;
327 return true;
330 function toggleSearch(elem) {
331 var f = document.forms[0];
332 <?php if ($WITH_SEARCH) { ?>
333 // Toggle background color.
334 if (elem.style.backgroundColor == '')
335 elem.style.backgroundColor = '<?php echo $searchcolor; ?>';
336 else
337 elem.style.backgroundColor = '';
338 <?php } ?>
339 if (force_submit) {
340 force_submit = false;
341 f.create.value = '<?php echo xla('Create New Patient'); ?>';
343 return true;
346 // If a <select> list is dropped down, this is its name.
347 var open_sel_name = '';
349 function selClick(elem) {
350 if (open_sel_name == elem.name) {
351 open_sel_name = '';
353 else {
354 open_sel_name = elem.name;
355 toggleSearch(elem);
357 return true;
360 function selBlur(elem) {
361 if (open_sel_name == elem.name) {
362 open_sel_name = '';
364 return true;
367 // This invokes the patient search dialog.
368 function searchme() {
369 var f = document.forms[0];
370 var url = '../main/finder/patient_select.php?popup=1';
372 <?php
373 $lres = getLayoutRes();
375 while ($lrow = sqlFetchArray($lres)) {
376 $field_id = $lrow['field_id'];
377 if (strpos($field_id, 'em_') === 0) {
378 continue;
381 $data_type = $lrow['data_type'];
382 $fldname = "form_$field_id";
383 switch (getSearchClass($data_type)) {
384 case 1:
385 echo
386 " if (f.$fldname.style.backgroundColor != '' && trimlen(f.$fldname.value) > 0) {\n" .
387 " url += '&$field_id=' + encodeURIComponent(f.$fldname.value);\n" .
388 " }\n";
389 break;
390 case 2:
391 echo
392 " if (f.$fldname.style.backgroundColor != '' && f.$fldname.selectedIndex > 0) {\n" .
393 " url += '&$field_id=' + encodeURIComponent(f.$fldname.options[f.$fldname.selectedIndex].value);\n" .
394 " }\n";
395 break;
400 dlgopen(url, '_blank', 700, 500);
403 //-->
405 </script>
406 </head>
408 <body class="body_top">
410 <?php
411 /*Get the constraint from the DB-> LBF forms accordinf the form_id*/
412 $constraints = LBF_Validation::generate_validate_constraints("DEM");
414 <script> var constraints = <?php echo $constraints;?>; </script>
416 <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)'>
418 <div class="container-fluid">
419 <div class="row">
420 <div class="col-xs-12">
421 <div class="page-header">
422 <h2><?php echo xlt('Search or Add Patient');?></h2>
423 </div>
424 </div>
425 <div class="col-xs-12">
426 <div class="btn-group">
427 <?php if ($WITH_SEARCH) { ?>
428 <button type="button" class="btn btn-default btn-search" id="search" value="<?php echo xla('Search'); ?>">
429 <?php echo xlt('Search'); ?>
430 </button>
431 <?php } ?>
432 <button type="button" class="btn btn-default btn-save" name='create' id="create" value="<?php echo xla('Create New Patient'); ?>">
433 <?php echo xlt('Create New Patient'); ?>
434 </button>
435 </div>
436 <hr>
437 </div>
438 </div>
439 </div>
441 <table width='100%' cellpadding='0' cellspacing='8'>
442 <tr>
443 <td align='left' valign='top'>
444 <?php if ($SHORT_FORM) {
445 echo " <center>\n";
446 } ?>
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, $SHORT_FORM;
476 if (strlen($last_group) > 0) {
477 end_row();
478 echo " </table>\n";
479 if (!$SHORT_FORM) {
480 echo "</div>\n";
485 $last_group = '';
486 $cell_count = 0;
487 $item_count = 0;
488 $display_style = 'block';
489 $group_seq = 0; // this gives the DIV blocks unique IDs
491 while ($frow = sqlFetchArray($fres)) {
492 $this_group = $frow['group_name'];
493 $titlecols = $frow['titlecols'];
494 $datacols = $frow['datacols'];
495 $data_type = $frow['data_type'];
496 $field_id = $frow['field_id'];
497 $list_id = $frow['list_id'];
498 $currvalue = '';
499 $condition_str = get_conditions_str($condition_str, $group_fields);
501 if (strpos($field_id, 'em_') === 0) {
502 $tmp = substr($field_id, 3);
503 if (isset($result2[$tmp])) {
504 $currvalue = $result2[$tmp];
506 } else {
507 if (isset($result[$field_id])) {
508 $currvalue = $result[$field_id];
512 // Handle a data category (group) change.
513 if (strcmp($this_group, $last_group) != 0) {
514 if (!$SHORT_FORM) {
515 end_group();
516 $group_seq++; // ID for DIV tags
517 $group_name = substr($this_group, 1);
518 if (strlen($last_group) > 0) {
519 echo "<br />";
522 echo "<span class='bold'><input type='checkbox' name='form_cb_$group_seq' id='form_cb_$group_seq' value='1' " .
523 "onclick='return divclick(this,\"div_$group_seq\");'";
524 if ($display_style == 'block') {
525 echo " checked";
528 // Modified 6-09 by BM - Translate if applicable
529 echo " /><b>" . xl_layout_label($group_name) . "</b></span>\n";
531 echo "<div id='div_$group_seq' class='section' style='display:$display_style;'>\n";
532 echo " <table border='0' cellpadding='0'>\n";
533 $display_style = 'none';
534 } else if (strlen($last_group) == 0) {
535 echo " <table border='0' cellpadding='0'>\n";
538 $last_group = $this_group;
541 // Handle starting of a new row.
542 if (($titlecols > 0 && $cell_count >= $CPR) || $cell_count == 0) {
543 end_row();
544 echo " <tr>";
547 if ($item_count == 0 && $titlecols == 0) {
548 $titlecols = 1;
551 $field_id_label='label_'.$frow['field_id'];
552 // Handle starting of a new label cell.
553 if ($titlecols > 0) {
554 end_cell();
555 echo "<td colspan='$titlecols' id='$field_id_label'";
556 echo ($frow['uor'] == 2) ? " class='required'" : " class='bold'";
557 if ($cell_count == 2) {
558 echo " style='padding-left:10pt'";
561 echo ">";
562 $cell_count += $titlecols;
565 ++$item_count;
567 echo "<b>";
569 // Modified 6-09 by BM - Translate if applicable
570 if ($frow['title']) {
571 echo (xl_layout_label($frow['title']).":");
572 } else {
573 echo "&nbsp;";
576 echo "</b>";
578 // Handle starting of a new data cell.
579 if ($datacols > 0) {
580 $id_field_text = "text_".$frow['field_id'];
581 end_cell();
582 echo "<td colspan='$datacols' class='text data'";
583 if ($cell_count > 0) {
584 echo " style='padding-left:5pt'". " id='".$id_field_text."'";
587 echo ">";
588 $cell_count += $datacols;
591 ++$item_count;
592 generate_form_field($frow, $currvalue);
595 end_group();
598 <?php
599 if (! $GLOBALS['simplified_demographics']) {
600 $insurancei = getInsuranceProviders();
601 $pid = 0;
602 $insurance_headings = array(xl("Primary Insurance Provider"), xl("Secondary Insurance Provider"), xl("Tertiary Insurance provider"));
603 $insurance_info = array();
604 $insurance_info[1] = getInsuranceData($pid, "primary");
605 $insurance_info[2] = getInsuranceData($pid, "secondary");
606 $insurance_info[3] = getInsuranceData($pid, "tertiary");
608 echo "<br /><span class='bold'><input type='checkbox' name='form_cb_ins' value='1' " .
609 "onclick='return divclick(this,\"div_ins\");'";
610 if ($display_style == 'block') {
611 echo " checked";
614 echo " /><b>" . xlt('Insurance') . "</b></span>\n";
615 echo "<div id='div_ins' class='section' style='display:$display_style;'>\n";
617 for ($i=1; $i<=3; $i++) {
618 $result3 = $insurance_info[$i];
620 <table border="0">
621 <tr>
622 <td valign='top' colspan='2'>
623 <span class='required'><?php echo text($insurance_headings[$i -1]).":"?></span>
624 <select name="i<?php echo $i?>provider" class="form-control">
625 <option value=""><?php echo xlt('Unassigned'); ?></option>
626 <?php
627 foreach ($insurancei as $iid => $iname) {
628 echo "<option value='" . attr($iid) . "'";
629 if (strtolower($iid) == strtolower($result3{"provider"})) {
630 echo " selected";
633 echo ">" . text($iname) . "</option>\n";
636 </select>&nbsp;<a class='iframe medium_modal' href='../practice/ins_search.php' onclick='ins_search(<?php echo $i?>)'>
637 <span> <?php echo xlt('Search/Add Insurer'); ?></span></a>
638 </td>
639 </tr>
640 <tr>
641 <td valign=top>
642 <table border="0">
644 <tr>
645 <td>
646 <span class='required'><?php echo xlt('Plan Name'); ?>: </span>
647 </td>
648 <td>
649 <input type='entry' class='form-control' size='20' name='i<?php echo $i?>plan_name' value="<?php echo attr($result3{"plan_name"}); ?>"
650 onchange="capitalizeMe(this);" />&nbsp;&nbsp;
651 </td>
652 </tr>
654 <tr>
655 <td>
656 <span class='required'><?php echo xlt('Effective Date'); ?>: </span>
657 </td>
658 <td>
659 <input type='entry' size='11' class='datepicker form-control' name='i<?php echo $i ?>effective_date'
660 id='i<?php echo $i ?>effective_date'
661 value='<?php echo attr($result3['date']); ?>'
662 title='yyyy-mm-dd' />
663 </td>
664 </tr>
666 <tr>
667 <td><span class=required><?php echo xlt('Policy Number'); ?>: </span></td>
668 <td><input type='entry' class='form-control' size='16' name='i<?php echo $i?>policy_number' value="<?php echo attr($result3{"policy_number"}); ?>"
669 onkeyup='policykeyup(this)'></td>
670 </tr>
672 <tr>
673 <td><span class=required><?php echo xlt('Group Number'); ?>: </span></td>
674 <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>
675 </tr>
677 <tr<?php echo ($GLOBALS['omit_employers']) ? " style='display:none'" : ""; ?>>
678 <td class='required'><?php echo xlt('Subscriber Employer (SE)'); ?><br><span style='font-weight:normal'>
679 (<?php echo xlt('if unemployed enter Student'); ?>,<br><?php echo xlt('PT Student, or leave blank'); ?>): </span></td>
680 <td><input type=entry class='form-control' size=25 name=i<?php echo $i?>subscriber_employer
681 value="<?php echo attr($result3{"subscriber_employer"}); ?>"
682 onchange="capitalizeMe(this);" /></td>
683 </tr>
685 <tr<?php echo ($GLOBALS['omit_employers']) ? " style='display:none'" : ""; ?>>
686 <td><span class=required><?php echo xlt('SE Address'); ?>: </span></td>
687 <td><input type=entry class='form-control' size=25 name=i<?php echo $i?>subscriber_employer_street
688 value="<?php echo attr($result3{"subscriber_employer_street"}); ?>"
689 onchange="capitalizeMe(this);" /></td>
690 </tr>
692 <tr<?php echo ($GLOBALS['omit_employers']) ? " style='display:none'" : ""; ?>>
693 <td colspan="2">
694 <table>
695 <tr>
696 <td><span class=required><?php echo xlt('SE City'); ?>: </span></td>
697 <td><input type=entry class='form-control' size=15 name=i<?php echo $i?>subscriber_employer_city
698 value="<?php echo attr($result3{"subscriber_employer_city"}); ?>"
699 onchange="capitalizeMe(this);" /></td>
700 <td><span class=required><?php echo ($GLOBALS['phone_country_code'] == '1') ? xlt('SE State') : xlt('SE Locality') ?>: </span></td>
701 <td>
702 <?php
703 // Modified 7/2009 by BM to incorporate data types
704 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']);
706 </td>
707 </tr>
708 <tr>
709 <td><span class=required><?php echo ($GLOBALS['phone_country_code'] == '1') ? xlt('SE Zip Code') : xlt('SE Postal Code') ?>: </span></td>
710 <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>
711 <td><span class=required><?php xl('SE Country', 'e'); ?>: </span></td>
712 <td>
713 <?php
714 // Modified 7/2009 by BM to incorporate data types
715 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']);
717 </td>
718 </tr>
719 </table>
720 </td>
721 </tr>
723 </table>
724 </td>
726 <td valign=top>
727 <span class=required><?php echo xlt('Subscriber'); ?>: </span>
728 <input type=entry class='form-control' size=10 name=i<?php echo $i?>subscriber_fname
729 value="<?php echo attr($result3{"subscriber_fname"}); ?>"
730 onchange="capitalizeMe(this);" />
731 <input type=entry class='form-control' size=3 name=i<?php echo $i?>subscriber_mname
732 value="<?php echo attr($result3{"subscriber_mname"}); ?>"
733 onchange="capitalizeMe(this);" />
734 <input type=entry class='form-control' size=10 name=i<?php echo $i?>subscriber_lname
735 value="<?php echo attr($result3{"subscriber_lname"}); ?>"
736 onchange="capitalizeMe(this);" />
737 <br>
738 <span class=required><?php echo xlt('Relationship'); ?>: </span>
739 <?php
740 // Modified 6/2009 by BM to use list_options and function
741 generate_form_field(array('data_type'=>1,'field_id'=>('i'.$i.'subscriber_relationship'),'list_id'=>'sub_relation','empty_title'=>' '), $result3['subscriber_relationship']);
743 <a href="javascript:popUp('../../interface/patient_file/summary/browse.php?browsenum=<?php echo $i?>')" class=text>(<?php echo xla('Browse'); ?>)</a><br />
745 <span class=bold><?php echo xlt('D.O.B.'); ?>: </span>
746 <input type='entry' size='11' class='datepicker form-control' name='i<?php echo $i?>subscriber_DOB'
747 id='i<?php echo $i?>subscriber_DOB'
748 value='<?php echo attr($result3['subscriber_DOB']); ?>'
749 title='yyyy-mm-dd' />
751 <span class=bold><?php echo xlt('S.S.'); ?>: </span>
752 <input type=entry class='form-control' size=11 name=i<?php echo $i?>subscriber_ss value="<?php echo attr($result3{"subscriber_ss"}); ?>">&nbsp;
753 <span class=bold><?php echo xlt('Sex'); ?>: </span>
754 <?php
755 // Modified 6/2009 by BM to use list_options and function
756 generate_form_field(array('data_type'=>1,'field_id'=>('i'.$i.'subscriber_sex'),'list_id'=>'sex'), $result3['subscriber_sex']);
758 <br>
759 <span class=required><?php echo xlt('Subscriber Address'); ?>: </span>
760 <input type=entry class='form-control' size=25 name=i<?php echo $i?>subscriber_street
761 value="<?php echo attr($result3{"subscriber_street"}); ?>"
762 onchange="capitalizeMe(this);" /><br>
763 <span class=required><?php echo xlt('City'); ?>: </span>
764 <input type=entry class='form-control' size=15 name=i<?php echo $i?>subscriber_city
765 value="<?php echo attr($result3{"subscriber_city"}); ?>"
766 onchange="capitalizeMe(this);" />
767 <span class=required><?php echo ($GLOBALS['phone_country_code'] == '1') ? xlt('State') : xlt('Locality') ?>: </span>
768 <?php
769 // Modified 7/2009 by BM to incorporate data types
770 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']);
772 <br />
773 <span class=required><?php echo ($GLOBALS['phone_country_code'] == '1') ? xlt('Zip Code') : xlt('Postal Code') ?>: </span>
774 <input type=entry class='form-control' size=10 name=i<?php echo $i?>subscriber_postal_code value="<?php echo attr($result3{"subscriber_postal_code"}); ?>">
775 <span class='required'<?php echo ($GLOBALS['omit_employers']) ? " style='display:none'" : ""; ?>>
776 <?php echo xlt('Country'); ?>: </span>
777 <?php
778 // Modified 7/2009 by BM to incorporate data types
779 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']);
781 <br />
782 <span class=bold><?php echo xlt('Subscriber Phone'); ?>:
783 <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)' />
784 </span><br />
785 <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"}); ?>">
786 </span><br />
787 <span class='required'><?php echo xlt('Accept Assignment'); ?>: </span>
788 <select class='form-control' name=i<?php echo $i?>accept_assignment>
789 <option value="TRUE" <?php echo (strtoupper($result3{"accept_assignment"}) == "TRUE") ? "selected" : ""; ?>><?php echo xlt('YES'); ?></option>
790 <option value="FALSE" <?php echo (strtoupper($result3{"accept_assignment"}) == "FALSE") ? "selected" : ""; ?>><?php echo xlt('NO'); ?></option>
791 </select>
792 </td>
793 </tr>
795 </table>
796 <hr />
797 <?php
800 echo "</div>\n";
801 } // end of "if not simplified_demographics"
804 <?php if ($SHORT_FORM) {
805 echo " </center>\n";
806 } ?>
808 </td>
809 <td align='right' valign='top' width='1%' nowrap>
810 <!-- Image upload stuff was here but got moved. -->
811 </td>
812 </tr>
813 </table>
815 </form>
817 <!-- include support for the list-add selectbox feature -->
818 <?php include($GLOBALS['fileroot']."/library/options_listadd.inc"); ?>
820 </body>
822 <script language="JavaScript">
824 // hard code validation for old validation, in the new validation possible to add match rules
825 <?php if ($GLOBALS['new_validate'] == 0) { ?>
827 // fix inconsistently formatted phone numbers from the database
828 var f = document.forms[0];
829 if (f.form_phone_contact) phonekeyup(f.form_phone_contact,mypcc);
830 if (f.form_phone_home ) phonekeyup(f.form_phone_home ,mypcc);
831 if (f.form_phone_biz ) phonekeyup(f.form_phone_biz ,mypcc);
832 if (f.form_phone_cell ) phonekeyup(f.form_phone_cell ,mypcc);
834 <?php }?>
836 <?php echo $date_init; ?>
838 // -=- jQuery makes life easier -=-
840 // var matches = 0; // number of patients that match the demographic information being entered
841 // var override = false; // flag that overrides the duplication warning
843 $(document).ready(function() {
844 enable_modals();
845 $(".medium_modal").fancybox( {
846 'overlayOpacity' : 0.0,
847 'showCloseButton' : true,
848 'frameHeight' : 460,
849 'frameWidth' : 650
851 // added to integrate insurance stuff
852 <?php for ($i=1; $i<=3; $i++) { ?>
853 $("#form_i<?php echo $i?>subscriber_relationship").change(function() { auto_populate_employer_address<?php echo $i?>(); });
854 <?php } ?>
856 $('#search').click(function() { searchme(); });
857 $('#create').click(function() { check()});
859 var check = function(e) {
860 <?php if ($GLOBALS['new_validate']) {?>
861 var valid = submitme(<?php echo $GLOBALS['new_validate'] ? 1 : 0;?>,e,"DEM",constraints);
862 <?php } else {?>
863 top.restoreSession();
864 var f = document.forms[0];
865 var valid = validate(f);
866 <?php }?>
867 if (valid) {
868 if (force_submit) {
869 // In this case dups were shown already and Save should just save.
870 top.restoreSession();
871 f.submit();
872 return;
875 <?php
876 // D in edit_options indicates the field is used in duplication checking.
877 // This constructs a list of the names of those fields.
878 $mflist = "";
879 $mfres = sqlStatement("SELECT * FROM layout_options " .
880 "WHERE form_id = 'DEM' AND uor > 0 AND field_id != '' AND " .
881 "(edit_options LIKE '%D%' OR edit_options LIKE '%W%' )" .
882 "ORDER BY group_name, seq");
883 while ($mfrow = sqlFetchArray($mfres)) {
884 $field_id = $mfrow['field_id'];
885 if (strpos($field_id, 'em_') === 0) {
886 continue;
889 if (!empty($mflist)) {
890 $mflist .= ",";
893 $mflist .= "'" . htmlentities($field_id) . "'";
896 <?php if (($GLOBALS['full_new_patient_form'] == '4') && (checkIfPatientValidationHookIsActive())) :?>
897 // Use zend module patient validation hook to open the controller and send the dup-checker fields.
898 var url ='<?php echo $GLOBALS['web_root']."/interface/modules/zend_modules/public/patientvalidation";?>';
899 <?php else :?>
900 // Build and invoke the URL to create the dup-checker dialog.
901 var url = 'new_search_popup.php';
902 <?php endif;?>
904 var flds = new Array(<?php echo $mflist; ?>);
905 var separator = '?';
906 for (var i = 0; i < flds.length; ++i) {
907 var fval = $('#form_' + flds[i]).val();
908 if (fval && fval != '') {
909 url += separator;
910 separator = '&';
911 url += 'mf_' + flds[i] + '=' + encodeURIComponent(fval);
914 url+="&close"
915 dlgopen(url, '_blank', 700, 500);
916 } // end function
917 } // end function
920 // Set onclick/onfocus handlers for toggling background color.
921 <?php
922 $lres = getLayoutRes();
923 while ($lrow = sqlFetchArray($lres)) {
924 $field_id = $lrow['field_id'];
925 if (strpos($field_id, 'em_') === 0) {
926 continue;
929 switch (getSearchClass($lrow['data_type'])) {
930 case 1:
931 echo " \$('#form_$field_id').click(function() { toggleSearch(this); });\n";
932 break;
933 case 2:
934 echo " \$('#form_$field_id').click(function() { selClick(this); });\n";
935 echo " \$('#form_$field_id').blur(function() { selBlur(this); });\n";
936 break;
941 $('.datepicker').datetimepicker({
942 <?php $datetimepicker_timepicker = false; ?>
943 <?php $datetimepicker_showseconds = false; ?>
944 <?php $datetimepicker_formatInput = false; ?>
945 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
946 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
948 $('.datetimepicker').datetimepicker({
949 <?php $datetimepicker_timepicker = true; ?>
950 <?php $datetimepicker_showseconds = false; ?>
951 <?php $datetimepicker_formatInput = false; ?>
952 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
953 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
956 }); // end document.ready
958 </script>
959 <?php /*Include the validation script and rules for this form*/
960 $form_id="DEM";
963 <?php
964 //LBF forms use the new validation depending on the global value
965 $use_validate_js=$GLOBALS['new_validate'];
966 include_once("$srcdir/validation/validation_script.js.php");?>
967 <script language='JavaScript'>
968 // Array of skip conditions for the checkSkipConditions() function.
969 var skipArray = [
970 <?php echo $condition_str; ?>
972 checkSkipConditions();
973 $("input").change(function() {
974 checkSkipConditions();
976 $("select").change(function() {
977 checkSkipConditions();
979 </script>
981 </html>