bug fix march continued (#1921)
[openemr.git] / interface / new / new_comprehensive.php
blobba0456215c9ec9c3217df8609627f90ac82c8372
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 use OpenEMR\Core\Header;
24 // Check authorization.
25 if (!acl_check('patients', 'demo', '', array('write','addonly'))) {
26 die(xlt("Adding demographics is not authorized."));
29 $CPR = 4; // cells per row
31 $searchcolor = empty($GLOBALS['layout_search_color']) ?
32 '#ffff55' : $GLOBALS['layout_search_color'];
34 $WITH_SEARCH = ($GLOBALS['full_new_patient_form'] == '1' || $GLOBALS['full_new_patient_form'] == '2' );
35 $SHORT_FORM = ($GLOBALS['full_new_patient_form'] == '2' || $GLOBALS['full_new_patient_form'] == '3' || $GLOBALS['full_new_patient_form'] == '4');
37 $grparr = array();
38 getLayoutProperties('DEM', $grparr);
40 function getLayoutRes()
42 global $SHORT_FORM;
43 return sqlStatement("SELECT * FROM layout_options " .
44 "WHERE form_id = 'DEM' AND uor > 0 AND field_id != '' " .
45 ($SHORT_FORM ? "AND ( uor > 1 OR edit_options LIKE '%N%' ) " : "") .
46 "ORDER BY group_id, seq");
49 // Determine layout field search treatment from its data type:
50 // 1 = text field
51 // 2 = select list
52 // 0 = not searchable
54 function getSearchClass($data_type)
56 switch ($data_type) {
57 case 1: // single-selection list
58 case 10: // local provider list
59 case 11: // provider list
60 case 12: // pharmacy list
61 case 13: // squads
62 case 14: // address book list
63 case 26: // single-selection list with add
64 case 35: // facilities
65 return 2;
66 case 2: // text field
67 case 3: // textarea
68 case 4: // date
69 return 1;
72 return 0;
75 $fres = getLayoutRes();
77 <html>
78 <head>
79 <?php Header::setupHeader(['common','datetime-picker', 'jquery-ui']); ?>
80 <title><?php echo xlt("Search or Add Patient"); ?></title>
82 <style>
83 body {
84 padding: 5pt 5pt 5pt 5pt;
87 div.section {
88 border: solid;
89 border-width: 1px;
90 border-color: #0000ff;
91 margin: 0 0 0 10pt;
92 padding: 5pt;
95 .form-control {
96 width: auto;
97 display: inline;
98 height: auto;
100 </style>
102 <?php include_once("{$GLOBALS['srcdir']}/options.js.php"); ?>
104 <SCRIPT LANGUAGE="JavaScript"><!--
105 //Visolve - sync the radio buttons - Start
106 if((top.window.parent) && (parent.window)){
107 var wname = top.window.parent.left_nav;
108 fname = (parent.window.name)?parent.window.name:window.name;
109 wname.syncRadios();
110 }//Visolve - sync the radio buttons - End
112 var mypcc = '<?php echo $GLOBALS['phone_country_code'] ?>';
114 // This may be changed to true by the AJAX search script.
115 var force_submit = false;
117 //code used from http://tech.irt.org/articles/js037/
118 function replace(string,text,by) {
119 // Replaces text with by in string
120 var strLength = string.length, txtLength = text.length;
121 if ((strLength == 0) || (txtLength == 0)) return string;
123 var i = string.indexOf(text);
124 if ((!i) && (text != string.substring(0,txtLength))) return string;
125 if (i == -1) return string;
127 var newstr = string.substring(0,i) + by;
129 if (i+txtLength < strLength)
130 newstr += replace(string.substring(i+txtLength,strLength),text,by);
132 return newstr;
135 <?php for ($i=1; $i<=3; $i++) { ?>
136 function auto_populate_employer_address<?php echo $i ?>(){
137 var f = document.demographics_form;
138 if (f.form_i<?php echo $i?>subscriber_relationship.options[f.form_i<?php echo $i?>subscriber_relationship.selectedIndex].value == "self") {
139 f.i<?php echo $i?>subscriber_fname.value=f.form_fname.value;
140 f.i<?php echo $i?>subscriber_mname.value=f.form_mname.value;
141 f.i<?php echo $i?>subscriber_lname.value=f.form_lname.value;
142 f.i<?php echo $i?>subscriber_street.value=f.form_street.value;
143 f.i<?php echo $i?>subscriber_city.value=f.form_city.value;
144 f.form_i<?php echo $i?>subscriber_state.value=f.form_state.value;
145 f.i<?php echo $i?>subscriber_postal_code.value=f.form_postal_code.value;
146 if (f.form_country_code)
147 f.form_i<?php echo $i?>subscriber_country.value=f.form_country_code.value;
148 f.i<?php echo $i?>subscriber_phone.value=f.form_phone_home.value;
149 f.i<?php echo $i?>subscriber_DOB.value=f.form_DOB.value;
150 f.i<?php echo $i?>subscriber_ss.value=f.form_ss.value;
151 f.form_i<?php echo $i?>subscriber_sex.value = f.form_sex.value;
152 f.i<?php echo $i?>subscriber_employer.value=f.form_em_name.value;
153 f.i<?php echo $i?>subscriber_employer_street.value=f.form_em_street.value;
154 f.i<?php echo $i?>subscriber_employer_city.value=f.form_em_city.value;
155 f.form_i<?php echo $i?>subscriber_employer_state.value=f.form_em_state.value;
156 f.i<?php echo $i?>subscriber_employer_postal_code.value=f.form_em_postal_code.value;
157 if (f.form_em_country)
158 f.form_i<?php echo $i?>subscriber_employer_country.value=f.form_em_country.value;
162 <?php } ?>
164 function upperFirst(string,text) {
165 return replace(string,text,text.charAt(0).toUpperCase() + text.substring(1,text.length));
168 // The ins_search.php window calls this to set the selected insurance.
169 function set_insurance(ins_id, ins_name) {
170 var thesel = document.forms[0]['i' + insurance_index + 'provider'];
171 var theopts = thesel.options; // the array of Option objects
172 var i = 0;
173 for (; i < theopts.length; ++i) {
174 if (theopts[i].value == ins_id) {
175 theopts[i].selected = true;
176 return;
179 // no matching option was found so create one, append it to the
180 // end of the list, and select it.
181 theopts[i] = new Option(ins_name, ins_id, false, true);
184 // Indicates which insurance slot is being updated.
185 var insurance_index = 0;
187 // The OnClick handler for searching/adding the insurance company.
188 function ins_search(ins) {
189 insurance_index = ins;
190 return false;
193 function checkNum () {
194 var re= new RegExp();
195 re = /^\d*\.?\d*$/;
196 str=document.forms[0].monthly_income.value;
197 if(re.exec(str))
199 }else{
200 alert("<?php echo xls("Please enter a dollar amount using only numbers and a decimal point."); ?>");
204 // This capitalizes the first letter of each word in the passed input
205 // element. It also strips out extraneous spaces.
206 function capitalizeMe(elem) {
207 var a = elem.value.split(' ');
208 var s = '';
209 for(var i = 0; i < a.length; ++i) {
210 if (a[i].length > 0) {
211 if (s.length > 0) s += ' ';
212 s += a[i].charAt(0).toUpperCase() + a[i].substring(1);
215 elem.value = s;
218 // Onkeyup handler for policy number. Allows only A-Z and 0-9.
219 function policykeyup(e) {
220 var v = e.value.toUpperCase();
221 var filteredString="";
222 for (var i = 0; i < v.length; ++i) {
223 var c = v.charAt(i);
224 if ((c >= '0' && c <= '9') ||
225 (c >= 'A' && c <= 'Z') ||
226 (c == '*') ||
227 (c == '-') ||
228 (c == '_') ||
229 (c == '(') ||
230 (c == ')') ||
231 (c == '#'))
233 filteredString+=c;
236 e.value = filteredString;
237 return;
240 function divclick(cb, divid) {
241 var divstyle = document.getElementById(divid).style;
242 if (cb.checked) {
243 divstyle.display = 'block';
244 } else {
245 divstyle.display = 'none';
247 return true;
250 // Compute the length of a string without leading and trailing spaces.
251 function trimlen(s) {
252 var i = 0;
253 var j = s.length - 1;
254 for (; i <= j && s.charAt(i) == ' '; ++i);
255 for (; i <= j && s.charAt(j) == ' '; --j);
256 if (i > j) return 0;
257 return j + 1 - i;
260 function validate(f) {
261 var errMsgs = new Array();
262 <?php generate_layout_validation('DEM'); ?>
263 <?php if ($GLOBALS['erx_enable']) { ?>
264 alertMsg='';
265 for(i=0;i<f.length;i++){
266 if(f[i].type=='text' && f[i].value)
268 if(f[i].name == 'form_fname' || f[i].name == 'form_mname' || f[i].name == 'form_lname')
270 alertMsg += checkLength(f[i].name,f[i].value,35);
271 alertMsg += checkUsername(f[i].name,f[i].value);
273 else if(f[i].name == 'form_street' || f[i].name == 'form_city')
275 alertMsg += checkLength(f[i].name,f[i].value,35);
276 alertMsg += checkAlphaNumericExtended(f[i].name,f[i].value);
278 else if(f[i].name == 'form_phone_home')
280 alertMsg += checkPhone(f[i].name,f[i].value);
284 if(alertMsg)
286 alert(alertMsg);
287 return false;
289 <?php } ?>
290 var msg = "";
291 msg += "<?php echo xla('The following fields are required'); ?>:\n\n";
292 for ( var i = 0; i < errMsgs.length; i++ ) {
293 msg += errMsgs[i] + "\n";
295 msg += "\n<?php echo xla('Please fill them in before continuing.'); ?>";
298 //Misc Deceased Date Validation for Future Date
299 var dateVal = document.getElementById("form_deceased_date").value;
300 var currentDate;
301 var d = new Date();
302 month = '' + (d.getMonth() + 1),
303 day = '' + d.getDate(),
304 year = d.getFullYear();
305 if (month.length < 2) month = '0' + month;
306 if (day.length < 2) day = '0' + day;
307 currentDate = year+'-'+month+'-'+day;
308 if(errMsgs.length > 0 || dateVal > currentDate)
310 if(errMsgs.length > 0)
311 alert(msg);
312 if(dateVal > currentDate)
313 alert ('<?php echo xls("Deceased Date should not be greater than Today"); ?>');
314 return false;
316 return true;
319 function toggleSearch(elem) {
320 var f = document.forms[0];
321 <?php if ($WITH_SEARCH) { ?>
322 // Toggle background color.
323 if (elem.style.backgroundColor == '')
324 elem.style.backgroundColor = '<?php echo $searchcolor; ?>';
325 else
326 elem.style.backgroundColor = '';
327 <?php } ?>
328 if (force_submit) {
329 force_submit = false;
330 f.create.value = '<?php echo xla('Create New Patient'); ?>';
332 return true;
335 // If a <select> list is dropped down, this is its name.
336 var open_sel_name = '';
338 function selClick(elem) {
339 if (open_sel_name == elem.name) {
340 open_sel_name = '';
342 else {
343 open_sel_name = elem.name;
344 toggleSearch(elem);
346 return true;
349 function selBlur(elem) {
350 if (open_sel_name == elem.name) {
351 open_sel_name = '';
353 return true;
356 // This invokes the patient search dialog.
357 function searchme() {
358 var f = document.forms[0];
359 var url = '../main/finder/patient_select.php?popup=1&csrf_token_form=<?php echo attr(urlencode(collectCsrfToken())); ?>';
361 <?php
362 $lres = getLayoutRes();
364 while ($lrow = sqlFetchArray($lres)) {
365 $field_id = $lrow['field_id'];
366 if (strpos($field_id, 'em_') === 0) {
367 continue;
370 $data_type = $lrow['data_type'];
371 $fldname = "form_$field_id";
372 switch (getSearchClass($data_type)) {
373 case 1:
374 echo
375 " if (f.$fldname.style.backgroundColor != '' && trimlen(f.$fldname.value) > 0) {\n" .
376 " url += '&$field_id=' + encodeURIComponent(f.$fldname.value);\n" .
377 " }\n";
378 break;
379 case 2:
380 echo
381 " if (f.$fldname.style.backgroundColor != '' && f.$fldname.selectedIndex > 0) {\n" .
382 " url += '&$field_id=' + encodeURIComponent(f.$fldname.options[f.$fldname.selectedIndex].value);\n" .
383 " }\n";
384 break;
389 dlgopen(url, '_blank', 700, 500);
391 function srchDone(pid){
392 top.restoreSession();
393 document.location.href = "./../../patient_file/summary/demographics.php?set_pid=" + pid;
395 //-->
397 </script>
398 </head>
400 <body class="body_top">
402 <?php
403 /*Get the constraint from the DB-> LBF forms accordinf the form_id*/
404 $constraints = LBF_Validation::generate_validate_constraints("DEM");
406 <script> var constraints = <?php echo $constraints;?>; </script>
408 <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)'>
410 <div class="container-fluid">
411 <div class="row">
412 <div class="col-xs-12">
413 <div class="page-header">
414 <h2><?php echo xlt('Search or Add Patient');?></h2>
415 </div>
416 </div>
417 <div class="col-xs-12">
418 <div class="btn-group">
419 <?php if ($WITH_SEARCH) { ?>
420 <button type="button" class="btn btn-default btn-search" id="search" value="<?php echo xla('Search'); ?>">
421 <?php echo xlt('Search'); ?>
422 </button>
423 <?php } ?>
424 <button type="button" class="btn btn-default btn-save" name='create' id="create" value="<?php echo xla('Create New Patient'); ?>">
425 <?php echo xlt('Create New Patient'); ?>
426 </button>
427 </div>
428 <hr>
429 </div>
430 </div>
431 </div>
433 <table width='100%' cellpadding='0' cellspacing='8'>
434 <tr>
435 <td align='left' valign='top'>
436 <?php if ($SHORT_FORM) {
437 echo " <center>\n";
438 } ?>
439 <?php
441 function end_cell()
443 global $item_count, $cell_count;
444 if ($item_count > 0) {
445 echo "</td>";
446 $item_count = 0;
450 function end_row()
452 global $cell_count, $CPR;
453 end_cell();
454 if ($cell_count > 0) {
455 for (; $cell_count < $CPR;
456 ++$cell_count) {
457 echo "<td></td>";
460 echo "</tr>\n";
461 $cell_count = 0;
465 function end_group()
467 global $last_group, $SHORT_FORM;
468 if (strlen($last_group) > 0) {
469 end_row();
470 echo " </table>\n";
471 if (!$SHORT_FORM) {
472 echo "</div>\n";
477 $last_group = '';
478 $cell_count = 0;
479 $item_count = 0;
480 $display_style = 'block';
481 $group_seq = 0; // this gives the DIV blocks unique IDs
483 $condition_str = '';
485 while ($frow = sqlFetchArray($fres)) {
486 $this_group = $frow['group_id'];
487 $titlecols = $frow['titlecols'];
488 $datacols = $frow['datacols'];
489 $data_type = $frow['data_type'];
490 $field_id = $frow['field_id'];
491 $list_id = $frow['list_id'];
492 $currvalue = '';
494 // Accumulate action conditions into a JSON expression for the browser side.
495 accumActionConditions($field_id, $condition_str, $frow['conditions']);
497 if (strpos($field_id, 'em_') === 0) {
498 $tmp = substr($field_id, 3);
499 if (isset($result2[$tmp])) {
500 $currvalue = $result2[$tmp];
502 } else {
503 if (isset($result[$field_id])) {
504 $currvalue = $result[$field_id];
508 // Handle a data category (group) change.
509 if (strcmp($this_group, $last_group) != 0) {
510 if (!$SHORT_FORM) {
511 end_group();
512 $group_seq++; // ID for DIV tags
513 $group_name = $grparr[$this_group]['grp_title'];
515 if (strlen($last_group) > 0) {
516 echo "<br />";
519 echo "<span class='bold'><input type='checkbox' name='form_cb_$group_seq' id='form_cb_$group_seq' value='1' " .
520 "onclick='return divclick(this,\"div_$group_seq\");'";
521 if ($display_style == 'block') {
522 echo " checked";
525 // Modified 6-09 by BM - Translate if applicable
526 echo " /><b>" . xl_layout_label($group_name) . "</b></span>\n";
528 echo "<div id='div_$group_seq' class='section' style='display:$display_style;'>\n";
529 echo " <table border='0' cellpadding='0'>\n";
530 $display_style = 'none';
531 } else if (strlen($last_group) == 0) {
532 echo " <table border='0' cellpadding='0'>\n";
535 $last_group = $this_group;
538 // Handle starting of a new row.
539 if (($titlecols > 0 && $cell_count >= $CPR) || $cell_count == 0) {
540 end_row();
541 echo " <tr>";
544 if ($item_count == 0 && $titlecols == 0) {
545 $titlecols = 1;
548 $field_id_label='label_'.$frow['field_id'];
549 // Handle starting of a new label cell.
550 if ($titlecols > 0) {
551 end_cell();
552 echo "<td colspan='$titlecols' id='$field_id_label'";
553 echo ($frow['uor'] == 2) ? " class='required'" : " class='bold'";
554 if ($cell_count == 2) {
555 echo " style='padding-left:10pt'";
558 echo ">";
559 $cell_count += $titlecols;
562 ++$item_count;
564 echo "<b>";
566 // Modified 6-09 by BM - Translate if applicable
567 if ($frow['title']) {
568 echo (xl_layout_label($frow['title']).":");
569 } else {
570 echo "&nbsp;";
573 echo "</b>";
575 // Handle starting of a new data cell.
576 if ($datacols > 0) {
577 $id_field_text = "text_".$frow['field_id'];
578 end_cell();
579 echo "<td colspan='$datacols' class='text data'";
580 if ($cell_count > 0) {
581 echo " style='padding-left:5pt'". " id='".$id_field_text."'";
584 echo ">";
585 $cell_count += $datacols;
588 ++$item_count;
589 generate_form_field($frow, $currvalue);
592 end_group();
595 <?php
596 if (! $GLOBALS['simplified_demographics']) {
597 $insurancei = getInsuranceProviders();
598 $pid = 0;
599 $insurance_headings = array(xl("Primary Insurance Provider"), xl("Secondary Insurance Provider"), xl("Tertiary Insurance provider"));
600 $insurance_info = array();
601 $insurance_info[1] = getInsuranceData($pid, "primary");
602 $insurance_info[2] = getInsuranceData($pid, "secondary");
603 $insurance_info[3] = getInsuranceData($pid, "tertiary");
605 echo "<br /><span class='bold'><input type='checkbox' name='form_cb_ins' value='1' " .
606 "onclick='return divclick(this,\"div_ins\");'";
607 if ($display_style == 'block') {
608 echo " checked";
611 echo " /><b>" . xlt('Insurance') . "</b></span>\n";
612 echo "<div id='div_ins' class='section' style='display:$display_style;'>\n";
614 for ($i=1; $i<=3; $i++) {
615 $result3 = $insurance_info[$i];
617 <table border="0">
618 <tr>
619 <td valign='top' colspan='2'>
620 <span class='required'><?php echo text($insurance_headings[$i -1]).":"?></span>
621 <select name="i<?php echo $i?>provider" class="form-control">
622 <option value=""><?php echo xlt('Unassigned'); ?></option>
623 <?php
624 foreach ($insurancei as $iid => $iname) {
625 echo "<option value='" . attr($iid) . "'";
626 if (strtolower($iid) == strtolower($result3{"provider"})) {
627 echo " selected";
630 echo ">" . text($iname) . "</option>\n";
633 </select>&nbsp;<a class='medium_modal' href='../practice/ins_search.php' onclick='ins_search(<?php echo $i?>)'>
634 <span> <?php echo xlt('Search/Add Insurer'); ?></span></a>
635 </td>
636 </tr>
637 <tr>
638 <td valign=top>
639 <table border="0">
641 <tr>
642 <td>
643 <span class='required'><?php echo xlt('Plan Name'); ?>: </span>
644 </td>
645 <td>
646 <input type='entry' class='form-control' size='20' name='i<?php echo $i?>plan_name' value="<?php echo attr($result3{"plan_name"}); ?>"
647 onchange="capitalizeMe(this);" />&nbsp;&nbsp;
648 </td>
649 </tr>
651 <tr>
652 <td>
653 <span class='required'><?php echo xlt('Effective Date'); ?>: </span>
654 </td>
655 <td>
656 <input type='entry' size='11' class='datepicker form-control' name='i<?php echo $i ?>effective_date'
657 id='i<?php echo $i ?>effective_date'
658 value='<?php echo attr($result3['date']); ?>'
659 title='yyyy-mm-dd' />
660 </td>
661 </tr>
663 <tr>
664 <td><span class=required><?php echo xlt('Policy Number'); ?>: </span></td>
665 <td><input type='entry' class='form-control' size='16' name='i<?php echo $i?>policy_number' value="<?php echo attr($result3{"policy_number"}); ?>"
666 onkeyup='policykeyup(this)'></td>
667 </tr>
669 <tr>
670 <td><span class=required><?php echo xlt('Group Number'); ?>: </span></td>
671 <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>
672 </tr>
674 <tr<?php echo ($GLOBALS['omit_employers']) ? " style='display:none'" : ""; ?>>
675 <td class='required'><?php echo xlt('Subscriber Employer (SE)'); ?><br><span style='font-weight:normal'>
676 (<?php echo xlt('if unemployed enter Student'); ?>,<br><?php echo xlt('PT Student, or leave blank'); ?>): </span></td>
677 <td><input type=entry class='form-control' size=25 name=i<?php echo $i?>subscriber_employer
678 value="<?php echo attr($result3{"subscriber_employer"}); ?>"
679 onchange="capitalizeMe(this);" /></td>
680 </tr>
682 <tr<?php echo ($GLOBALS['omit_employers']) ? " style='display:none'" : ""; ?>>
683 <td><span class=required><?php echo xlt('SE Address'); ?>: </span></td>
684 <td><input type=entry class='form-control' size=25 name=i<?php echo $i?>subscriber_employer_street
685 value="<?php echo attr($result3{"subscriber_employer_street"}); ?>"
686 onchange="capitalizeMe(this);" /></td>
687 </tr>
689 <tr<?php echo ($GLOBALS['omit_employers']) ? " style='display:none'" : ""; ?>>
690 <td colspan="2">
691 <table>
692 <tr>
693 <td><span class=required><?php echo xlt('SE City'); ?>: </span></td>
694 <td><input type=entry class='form-control' size=15 name=i<?php echo $i?>subscriber_employer_city
695 value="<?php echo attr($result3{"subscriber_employer_city"}); ?>"
696 onchange="capitalizeMe(this);" /></td>
697 <td><span class=required><?php echo ($GLOBALS['phone_country_code'] == '1') ? xlt('SE State') : xlt('SE Locality') ?>: </span></td>
698 <td>
699 <?php
700 // Modified 7/2009 by BM to incorporate data types
701 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']);
703 </td>
704 </tr>
705 <tr>
706 <td><span class=required><?php echo ($GLOBALS['phone_country_code'] == '1') ? xlt('SE Zip Code') : xlt('SE Postal Code') ?>: </span></td>
707 <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>
708 <td><span class=required><?php xl('SE Country', 'e'); ?>: </span></td>
709 <td>
710 <?php
711 // Modified 7/2009 by BM to incorporate data types
712 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']);
714 </td>
715 </tr>
716 </table>
717 </td>
718 </tr>
720 </table>
721 </td>
723 <td valign=top>
724 <span class=required><?php echo xlt('Subscriber'); ?>: </span>
725 <input type=entry class='form-control' size=10 name=i<?php echo $i?>subscriber_fname
726 value="<?php echo attr($result3{"subscriber_fname"}); ?>"
727 onchange="capitalizeMe(this);" />
728 <input type=entry class='form-control' size=3 name=i<?php echo $i?>subscriber_mname
729 value="<?php echo attr($result3{"subscriber_mname"}); ?>"
730 onchange="capitalizeMe(this);" />
731 <input type=entry class='form-control' size=10 name=i<?php echo $i?>subscriber_lname
732 value="<?php echo attr($result3{"subscriber_lname"}); ?>"
733 onchange="capitalizeMe(this);" />
734 <br>
735 <span class=required><?php echo xlt('Relationship'); ?>: </span>
736 <?php
737 // Modified 6/2009 by BM to use list_options and function
738 generate_form_field(array('data_type'=>1,'field_id'=>('i'.$i.'subscriber_relationship'),'list_id'=>'sub_relation','empty_title'=>' '), $result3['subscriber_relationship']);
740 <a href="javascript:popUp('../../interface/patient_file/summary/browse.php?browsenum=<?php echo $i?>')" class=text>(<?php echo xla('Browse'); ?>)</a><br />
742 <span class=bold><?php echo xlt('D.O.B.'); ?>: </span>
743 <input type='entry' size='11' class='datepicker form-control' name='i<?php echo $i?>subscriber_DOB'
744 id='i<?php echo $i?>subscriber_DOB'
745 value='<?php echo attr($result3['subscriber_DOB']); ?>'
746 title='yyyy-mm-dd' />
748 <span class=bold><?php echo xlt('S.S.'); ?>: </span>
749 <input type=entry class='form-control' size=11 name=i<?php echo $i?>subscriber_ss value="<?php echo attr($result3{"subscriber_ss"}); ?>">&nbsp;
750 <span class=bold><?php echo xlt('Sex'); ?>: </span>
751 <?php
752 // Modified 6/2009 by BM to use list_options and function
753 generate_form_field(array('data_type'=>1,'field_id'=>('i'.$i.'subscriber_sex'),'list_id'=>'sex'), $result3['subscriber_sex']);
755 <br>
756 <span class=required><?php echo xlt('Subscriber Address'); ?>: </span>
757 <input type=entry class='form-control' size=25 name=i<?php echo $i?>subscriber_street
758 value="<?php echo attr($result3{"subscriber_street"}); ?>"
759 onchange="capitalizeMe(this);" /><br>
760 <span class=required><?php echo xlt('City'); ?>: </span>
761 <input type=entry class='form-control' size=15 name=i<?php echo $i?>subscriber_city
762 value="<?php echo attr($result3{"subscriber_city"}); ?>"
763 onchange="capitalizeMe(this);" />
764 <span class=required><?php echo ($GLOBALS['phone_country_code'] == '1') ? xlt('State') : xlt('Locality') ?>: </span>
765 <?php
766 // Modified 7/2009 by BM to incorporate data types
767 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']);
769 <br />
770 <span class=required><?php echo ($GLOBALS['phone_country_code'] == '1') ? xlt('Zip Code') : xlt('Postal Code') ?>: </span>
771 <input type=entry class='form-control' size=10 name=i<?php echo $i?>subscriber_postal_code value="<?php echo attr($result3{"subscriber_postal_code"}); ?>">
772 <span class='required'<?php echo ($GLOBALS['omit_employers']) ? " style='display:none'" : ""; ?>>
773 <?php echo xlt('Country'); ?>: </span>
774 <?php
775 // Modified 7/2009 by BM to incorporate data types
776 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']);
778 <br />
779 <span class=bold><?php echo xlt('Subscriber Phone'); ?>:
780 <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)' />
781 </span><br />
782 <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"}); ?>">
783 </span><br />
784 <span class='required'><?php echo xlt('Accept Assignment'); ?>: </span>
785 <select class='form-control' name=i<?php echo $i?>accept_assignment>
786 <option value="TRUE" <?php echo (strtoupper($result3{"accept_assignment"}) == "TRUE") ? "selected" : ""; ?>><?php echo xlt('YES'); ?></option>
787 <option value="FALSE" <?php echo (strtoupper($result3{"accept_assignment"}) == "FALSE") ? "selected" : ""; ?>><?php echo xlt('NO'); ?></option>
788 </select>
789 </td>
790 </tr>
792 </table>
793 <hr />
794 <?php
797 echo "</div>\n";
798 } // end of "if not simplified_demographics"
801 <?php if ($SHORT_FORM) {
802 echo " </center>\n";
803 } ?>
805 </td>
806 <td align='right' valign='top' width='1%' nowrap>
807 <!-- Image upload stuff was here but got moved. -->
808 </td>
809 </tr>
810 </table>
812 </form>
814 <!-- include support for the list-add selectbox feature -->
815 <?php include($GLOBALS['fileroot']."/library/options_listadd.inc"); ?>
817 </body>
819 <script language="JavaScript">
821 // hard code validation for old validation, in the new validation possible to add match rules
822 <?php if ($GLOBALS['new_validate'] == 0) { ?>
824 // fix inconsistently formatted phone numbers from the database
825 var f = document.forms[0];
826 if (f.form_phone_contact) phonekeyup(f.form_phone_contact,mypcc);
827 if (f.form_phone_home ) phonekeyup(f.form_phone_home ,mypcc);
828 if (f.form_phone_biz ) phonekeyup(f.form_phone_biz ,mypcc);
829 if (f.form_phone_cell ) phonekeyup(f.form_phone_cell ,mypcc);
831 <?php }?>
833 <?php echo $date_init; ?>
835 // -=- jQuery makes life easier -=-
837 // var matches = 0; // number of patients that match the demographic information being entered
838 // var override = false; // flag that overrides the duplication warning
840 $(document).ready(function() {
841 $(".medium_modal").on('click', function(e) {
842 e.preventDefault();e.stopPropagation();
843 dlgopen('', '', 650, 460, '', '', {
844 buttons: [
845 {text: '<?php echo xla('Close'); ?>', close: true, style: 'default btn-sm'}
847 //onClosed: 'refreshme',
848 allowResize: false,
849 allowDrag: true,
850 dialogId: '',
851 type: 'iframe',
852 url: $(this).attr('href')
855 // added to integrate insurance stuff
856 <?php for ($i=1; $i<=3; $i++) { ?>
857 $("#form_i<?php echo $i?>subscriber_relationship").change(function() { auto_populate_employer_address<?php echo $i?>(); });
858 <?php } ?>
860 $('#search').click(function() { searchme(); });
861 $('#create').click(function() { check()});
863 var check = function(e) {
864 <?php if ($GLOBALS['new_validate']) {?>
865 var valid = submitme(<?php echo $GLOBALS['new_validate'] ? 1 : 0;?>,e,"DEM",constraints);
866 <?php } else {?>
867 top.restoreSession();
868 var f = document.forms[0];
869 var valid = validate(f);
870 <?php }?>
871 if (valid) {
872 if (force_submit) {
873 // In this case dups were shown already and Save should just save.
874 top.restoreSession();
875 f.submit();
876 return;
879 <?php
880 // D in edit_options indicates the field is used in duplication checking.
881 // This constructs a list of the names of those fields.
882 $mflist = "";
883 $mfres = sqlStatement("SELECT * FROM layout_options " .
884 "WHERE form_id = 'DEM' AND uor > 0 AND field_id != '' AND " .
885 "(edit_options LIKE '%D%' OR edit_options LIKE '%W%' )" .
886 "ORDER BY group_id, seq");
887 while ($mfrow = sqlFetchArray($mfres)) {
888 $field_id = $mfrow['field_id'];
889 if (strpos($field_id, 'em_') === 0) {
890 continue;
893 if (!empty($mflist)) {
894 $mflist .= ",";
897 $mflist .= "'" . htmlentities($field_id) . "'";
900 <?php if (($GLOBALS['full_new_patient_form'] == '4') && (checkIfPatientValidationHookIsActive())) :?>
901 // Use zend module patient validation hook to open the controller and send the dup-checker fields.
902 var url ='<?php echo $GLOBALS['web_root']."/interface/modules/zend_modules/public/patientvalidation";?>';
903 <?php else :?>
904 // Build and invoke the URL to create the dup-checker dialog.
905 var url = 'new_search_popup.php';
906 <?php endif;?>
908 var flds = new Array(<?php echo $mflist; ?>);
909 var separator = '?';
910 for (var i = 0; i < flds.length; ++i) {
911 var fval = $('#form_' + flds[i]).val();
912 if (fval && fval != '') {
913 url += separator;
914 separator = '&';
915 url += 'mf_' + flds[i] + '=' + encodeURIComponent(fval);
918 url+="&close"
919 dlgopen(url, '_blank', 700, 500);
920 } // end function
921 } // end function
923 // Set onclick/onfocus handlers for toggling background color.
924 <?php
925 $lres = getLayoutRes();
926 while ($lrow = sqlFetchArray($lres)) {
927 $field_id = $lrow['field_id'];
928 if (strpos($field_id, 'em_') === 0) {
929 continue;
932 switch (getSearchClass($lrow['data_type'])) {
933 case 1:
934 echo " \$('#form_$field_id').click(function() { toggleSearch(this); });\n";
935 break;
936 case 2:
937 echo " \$('#form_$field_id').click(function() { selClick(this); });\n";
938 echo " \$('#form_$field_id').blur(function() { selBlur(this); });\n";
939 break;
944 $('.datepicker').datetimepicker({
945 <?php $datetimepicker_timepicker = false; ?>
946 <?php $datetimepicker_showseconds = false; ?>
947 <?php $datetimepicker_formatInput = true; ?>
948 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
949 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
951 $('.datetimepicker').datetimepicker({
952 <?php $datetimepicker_timepicker = true; ?>
953 <?php $datetimepicker_showseconds = false; ?>
954 <?php $datetimepicker_formatInput = true; ?>
955 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
956 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
959 }); // end document.ready
961 // callback for new patient save confirm from new_search_popup.php
962 // note that dlgclose() callbacks mostly need to init outside dom.
963 function srcConfirmSave() {
964 document.forms[0].submit();
967 </script>
968 <?php /*Include the validation script and rules for this form*/
969 $form_id="DEM";
972 <?php
973 //LBF forms use the new validation depending on the global value
974 $use_validate_js=$GLOBALS['new_validate'];
975 include_once("$srcdir/validation/validation_script.js.php");?>
976 <script language='JavaScript'>
977 // Array of skip conditions for the checkSkipConditions() function.
978 var skipArray = [
979 <?php echo $condition_str; ?>
981 checkSkipConditions();
982 $("input").change(function() {
983 checkSkipConditions();
985 $("select").change(function() {
986 checkSkipConditions();
988 </script>
990 </html>