Mangled path fax send (#7515)
[openemr.git] / interface / new / new_comprehensive.php
blob4a2c4f0803e54b79e128b33c52ff3b761d80c9df
1 <?php
3 /**
4 * New patient or search patient.
6 * @package OpenEMR
7 * @link http://www.open-emr.org
8 * @author Rod Roark <rod@sunsetsystems.com>
9 * @author Brady Miller <brady.g.miller@gmail.com>
10 * @author Tyler Wrenn <tyler@tylerwrenn.com>
11 * @copyright Copyright (c) 2009-2021 Rod Roark <rod@sunsetsystems.com>
12 * @copyright Copyright (c) 2017-2019 Brady Miller <brady.g.miller@gmail.com>
13 * @copyright Copyright (c) 2020 Tyler Wrenn <tyler@tylerwrenn.com>
14 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
17 require_once("../globals.php");
18 require_once("$srcdir/options.inc.php");
19 require_once("$srcdir/patient.inc.php");
20 require_once("$srcdir/validation/LBF_Validation.php");
21 require_once("$srcdir/patientvalidation.inc.php");
23 use OpenEMR\Common\Acl\AclMain;
24 use OpenEMR\Common\Csrf\CsrfUtils;
25 use OpenEMR\Common\Twig\TwigContainer;
26 use OpenEMR\Core\Header;
28 // Check authorization.
29 if (!AclMain::aclCheckCore('patients', 'demo', '', array('write','addonly'))) {
30 echo (new TwigContainer(null, $GLOBALS['kernel']))->getTwig()->render('core/unauthorized.html.twig', ['pageTitle' => xl("Search or Add Patient")]);
31 exit;
34 $CPR = 4; // cells per row
36 $searchcolor = empty($GLOBALS['layout_search_color']) ?
37 'var(--yellow)' : $GLOBALS['layout_search_color'];
39 $WITH_SEARCH = ($GLOBALS['full_new_patient_form'] == '1' || $GLOBALS['full_new_patient_form'] == '2' );
40 $SHORT_FORM = ($GLOBALS['full_new_patient_form'] == '2' || $GLOBALS['full_new_patient_form'] == '3' || $GLOBALS['full_new_patient_form'] == '4');
42 $grparr = array();
43 getLayoutProperties('DEM', $grparr, '*');
45 $TOPCPR = empty($grparr['']['grp_columns']) ? 4 : $grparr['']['grp_columns'];
47 function getLayoutRes()
49 global $SHORT_FORM;
50 return sqlStatement("SELECT * FROM layout_options " .
51 "WHERE form_id = 'DEM' AND uor > 0 AND field_id != '' " .
52 ($SHORT_FORM ? "AND ( uor > 1 OR edit_options LIKE '%N%' ) " : "") .
53 "ORDER BY group_id, seq");
56 // Determine layout field search treatment from its data type:
57 // 1 = text field
58 // 2 = select list
59 // 0 = not searchable
61 function getSearchClass($data_type)
63 switch ($data_type) {
64 case 1: // single-selection list
65 case 10: // local provider list
66 case 11: // provider list
67 case 12: // pharmacy list
68 case 13: // squads
69 case 14: // address book list
70 case 26: // single-selection list with add
71 case 35: // facilities
72 return 2;
73 case 2: // text field
74 case 3: // textarea
75 case 4: // date
76 return 1;
79 return 0;
82 $fres = getLayoutRes();
84 <!DOCTYPE html>
85 <html>
86 <head>
87 <?php Header::setupHeader(['common','datetime-picker','select2', 'erx']); ?>
88 <title><?php echo xlt("Search or Add Patient"); ?></title>
89 <style>
90 .form-group {
91 margin-bottom: 0.25rem;
93 </style>
95 <?php include_once("{$GLOBALS['srcdir']}/options.js.php"); ?>
97 <script><!--
98 //Visolve - sync the radio buttons - Start
99 if((top.window.parent) && (parent.window)){
100 var wname = top.window.parent.left_nav;
101 fname = (parent.window.name)?parent.window.name:window.name;
102 wname.syncRadios();
103 }//Visolve - sync the radio buttons - End
105 var mypcc = <?php echo js_escape($GLOBALS['phone_country_code']); ?>;
107 // This may be changed to true by the AJAX search script.
108 var force_submit = false;
110 //code used from http://tech.irt.org/articles/js037/
111 function replace(string,text,by) {
112 // Replaces text with by in string
113 var strLength = string.length, txtLength = text.length;
114 if ((strLength == 0) || (txtLength == 0)) return string;
116 var i = string.indexOf(text);
117 if ((!i) && (text != string.substring(0,txtLength))) return string;
118 if (i == -1) return string;
120 var newstr = string.substring(0,i) + by;
122 if (i+txtLength < strLength)
123 newstr += replace(string.substring(i+txtLength,strLength),text,by);
125 return newstr;
128 <?php for ($i = 1; $i <= 3; $i++) { ?>
129 function auto_populate_employer_address<?php echo $i ?>(){
130 var f = document.demographics_form;
131 if (f.form_i<?php echo $i?>subscriber_relationship.options[f.form_i<?php echo $i?>subscriber_relationship.selectedIndex].value == "self") {
132 f.i<?php echo $i?>subscriber_fname.value=f.form_fname.value;
133 f.i<?php echo $i?>subscriber_mname.value=f.form_mname.value;
134 f.i<?php echo $i?>subscriber_lname.value=f.form_lname.value;
135 f.i<?php echo $i?>subscriber_street.value=f.form_street.value;
136 f.i<?php echo $i?>subscriber_street_line_2.value=f.form_street_line_2.value;
137 f.i<?php echo $i?>subscriber_city.value=f.form_city.value;
138 f.form_i<?php echo $i?>subscriber_state.value=f.form_state.value;
139 f.i<?php echo $i?>subscriber_postal_code.value=f.form_postal_code.value;
140 if (f.form_country_code)
141 f.form_i<?php echo $i?>subscriber_country.value=f.form_country_code.value;
142 f.i<?php echo $i?>subscriber_phone.value=f.form_phone_home.value;
143 f.i<?php echo $i?>subscriber_DOB.value=f.form_DOB.value;
144 f.i<?php echo $i?>subscriber_ss.value=f.form_ss.value;
145 f.form_i<?php echo $i?>subscriber_sex.value = f.form_sex.value;
146 f.i<?php echo $i?>subscriber_employer.value=f.form_em_name.value;
147 f.i<?php echo $i?>subscriber_employer_street.value=f.form_em_street.value;
148 f.i<?php echo $i?>subscriber_employer_city.value=f.form_em_city.value;
149 f.form_i<?php echo $i?>subscriber_employer_state.value=f.form_em_state.value;
150 f.i<?php echo $i?>subscriber_employer_postal_code.value=f.form_em_postal_code.value;
151 if (f.form_em_country)
152 f.form_i<?php echo $i?>subscriber_employer_country.value=f.form_em_country.value;
156 <?php } ?>
158 function upperFirst(string,text) {
159 return replace(string,text,text.charAt(0).toUpperCase() + text.substring(1,text.length));
162 // The ins_search.php window calls this to set the selected insurance.
163 function set_insurance(ins_id, ins_name) {
164 var thesel = document.forms[0]['i' + insurance_index + 'provider'];
165 var theopts = thesel.options; // the array of Option objects
166 var i = 0;
167 for (; i < theopts.length; ++i) {
168 if (theopts[i].value == ins_id) {
169 theopts[i].selected = true;
170 return;
173 // no matching option was found so create one, append it to the
174 // end of the list, and select it.
175 theopts[i] = new Option(ins_name, ins_id, false, true);
178 // Indicates which insurance slot is being updated.
179 var insurance_index = 0;
181 // The OnClick handler for searching/adding the insurance company.
182 function ins_search(ins) {
183 insurance_index = ins;
184 return false;
187 function checkNum () {
188 var re= new RegExp();
189 re = /^\d*\.?\d*$/;
190 str=document.forms[0].monthly_income.value;
191 if(re.exec(str))
193 }else{
194 alert(<?php echo xlj("Please enter a dollar amount using only numbers and a decimal point."); ?>);
198 // This capitalizes the first letter of each word in the passed input
199 // element. It also strips out extraneous spaces.
200 function capitalizeMe(elem) {
201 var a = elem.value.split(' ');
202 var s = '';
203 for(var i = 0; i < a.length; ++i) {
204 if (a[i].length > 0) {
205 if (s.length > 0) s += ' ';
206 s += a[i].charAt(0).toUpperCase() + a[i].substring(1);
209 elem.value = s;
212 function divclick(cb, divid) {
213 var divstyle = document.getElementById(divid).style;
214 if (cb.checked) {
215 divstyle.display = 'block';
216 } else {
217 divstyle.display = 'none';
219 return true;
222 // Compute the length of a string without leading and trailing spaces.
223 function trimlen(s) {
224 var i = 0;
225 var j = s.length - 1;
226 for (; i <= j && s.charAt(i) == ' '; ++i);
227 for (; i <= j && s.charAt(j) == ' '; --j);
228 if (i > j) return 0;
229 return j + 1 - i;
232 function validate(f) {
233 var errMsgs = new Array();
234 <?php generate_layout_validation('DEM'); ?>
235 <?php if ($GLOBALS['erx_enable']) { ?>
236 alertMsg='';
237 for(i=0;i<f.length;i++){
238 if(f[i].type=='text' && f[i].value)
240 if(f[i].name == 'form_fname' || f[i].name == 'form_mname' || f[i].name == 'form_lname')
242 alertMsg += checkLength(f[i].name,f[i].value,35);
243 alertMsg += checkUsername(f[i].name,f[i].value);
245 else if(f[i].name == 'form_street' || f[i].name == 'form_city')
247 alertMsg += checkLength(f[i].name,f[i].value,35);
248 alertMsg += checkAlphaNumericExtended(f[i].name,f[i].value);
250 else if(f[i].name == 'form_phone_home')
252 alertMsg += checkPhone(f[i].name,f[i].value);
256 if(alertMsg)
258 alert(alertMsg);
259 return false;
261 <?php } ?>
262 var msg = "";
263 msg += <?php echo xlj('The following fields are required'); ?> + ":\n\n";
264 for ( var i = 0; i < errMsgs.length; i++ ) {
265 msg += errMsgs[i] + "\n";
267 msg += "\n" + <?php echo xlj('Please fill them in before continuing.'); ?>;
270 //Misc Deceased Date Validation for Future Date
271 var dateVal = document.getElementById("form_deceased_date").value;
272 var currentDate;
273 var d = new Date();
274 month = '' + (d.getMonth() + 1),
275 day = '' + d.getDate(),
276 year = d.getFullYear();
277 if (month.length < 2) month = '0' + month;
278 if (day.length < 2) day = '0' + day;
279 currentDate = year+'-'+month+'-'+day;
280 if(errMsgs.length > 0 || dateVal > currentDate) {
281 if(errMsgs.length > 0) {
282 alert(msg);
284 if(dateVal > currentDate) {
285 alert(<?php echo xlj("Deceased Date should not be greater than Today"); ?>);
286 return false;
289 return true;
292 function toggleSearch(elem) {
293 var f = document.forms[0];
294 <?php if ($WITH_SEARCH) { ?>
295 // Toggle background color.
296 if (elem.style.backgroundColor == '')
297 elem.style.backgroundColor = <?php echo js_escape($searchcolor); ?>;
298 else
299 elem.style.backgroundColor = '';
301 if (!elem.classList.contains("is-invalid") && $.trim($(elem).val()) == '') {
302 elem.classList.add("is-invalid");
303 } else {
304 if($.trim($(elem).val()) != '') {
305 elem.classList.remove("is-invalid");
306 elem.classList.remove("is-valid");
309 <?php } ?>
310 if (force_submit) {
311 force_submit = false;
312 f.create.value = <?php echo xlj('Create New Patient'); ?>;
314 return true;
317 // If a <select> list is dropped down, this is its name.
318 var open_sel_name = '';
320 function selClick(elem) {
321 if (open_sel_name == elem.name) {
322 open_sel_name = '';
324 else {
325 open_sel_name = elem.name;
326 toggleSearch(elem);
328 return true;
331 function selBlur(elem) {
332 if (open_sel_name == elem.name) {
333 open_sel_name = '';
335 return true;
338 // This invokes the patient search dialog.
339 function searchme() {
340 var f = document.forms[0];
341 var url = '../main/finder/patient_select.php?popup=1&csrf_token_form=<?php echo attr_url(CsrfUtils::collectCsrfToken()); ?>';
343 <?php
344 $lres = getLayoutRes();
346 while ($lrow = sqlFetchArray($lres)) {
347 $field_id = $lrow['field_id'];
348 if (strpos($field_id, 'em_') === 0) {
349 continue;
352 $data_type = $lrow['data_type'];
353 $fldname = "form_$field_id";
354 switch (getSearchClass($data_type)) {
355 case 1:
356 echo
357 " if (f." . attr($fldname) . ".style.backgroundColor != '' && trimlen(f." . attr($fldname) . ".value) > 0) {\n" .
358 " url += '&" . attr($field_id) . "=' + encodeURIComponent(f." . attr($fldname) . ".value);\n" .
359 " }\n";
360 break;
361 case 2:
362 echo
363 " if (f." . attr($fldname) . ".style.backgroundColor != '' && f." . attr($fldname) . ".selectedIndex > 0) {\n" .
364 " url += '&" . attr($field_id) . "=' + encodeURIComponent(f." . attr($fldname) . ".options[f." . attr($fldname) . ".selectedIndex].value);\n" .
365 " }\n";
366 break;
371 dlgopen(url, '_blank', 700, 500);
373 function srchDone(pid){
374 top.restoreSession();
375 document.location.href = "./../../patient_file/summary/demographics.php?set_pid=" + encodeURIComponent(pid);
377 //-->
379 </script>
380 </head>
382 <body class="body_top">
384 <?php
385 /*Get the constraint from the DB-> LBF forms accordinf the form_id*/
386 $constraints = LBF_Validation::generate_validate_constraints("DEM");
388 <script> var constraints = <?php echo $constraints; ?>; </script>
389 <div class="container-xl">
390 <div class="row">
391 <div class="col-md-12">
392 <h2><?php echo xlt('Search or Add Patient');?></h2>
393 </div>
394 </div>
395 <div class="row">
396 <div class="<?php echo $BS_COL_CLASS; ?>-12">
397 <div class="accordion" id="dem_according">
398 <form action='new_comprehensive_save.php' name='demographics_form' id='DEM'
399 method='post'
400 onsubmit='return submitme(<?php echo $GLOBALS['new_validate'] ? 1 : 0;?>,event,"DEM",constraints)'>
401 <!-- Was: class='form-inline' -->
402 <input type="hidden" name="csrf_token_form" value="<?php echo attr(CsrfUtils::collectCsrfToken()); ?>" />
404 <table class='table table-sm w-100' cellspacing='8'>
405 <tr>
406 <td class="text-left align-top">
407 <?php
408 if ($SHORT_FORM) {
409 echo "<div class='mx-auto'>";
410 } ?>
411 <?php
413 function end_cell()
415 global $item_count;
416 if ($item_count > 0) {
417 echo "</div>"; // end BS column
418 $item_count = 0;
422 function end_row()
424 global $cell_count, $CPR, $BS_COL_CLASS;
425 end_cell();
426 if ($cell_count > 0 && $cell_count < $CPR) {
427 // Create a cell occupying the remaining bootstrap columns.
428 // BS columns will be less than 12 if $CPR is not 2, 3, 4, 6 or 12.
429 $bs_cols_remaining = ($CPR - $cell_count) * intval(12 / $CPR);
430 echo "<div class='$BS_COL_CLASS-$bs_cols_remaining'></div>";
432 if ($cell_count > 0) {
433 echo "</div><!-- End BS row -->\n";
435 $cell_count = 0;
438 function end_group()
440 global $last_group, $SHORT_FORM;
441 if (strlen($last_group) > 0) {
442 end_row();
443 echo "</div>\n"; // end BS container
444 if (!$SHORT_FORM) {
445 echo "</div>\n";
448 echo "</div>";
451 $last_group = '';
452 $cell_count = 0;
453 $item_count = 0;
454 $display_style = 'block';
455 $group_seq = 0; // this gives the DIV blocks unique IDs
456 $condition_str = '';
458 while ($frow = sqlFetchArray($fres)) {
459 $this_group = $frow['group_id'];
460 $titlecols = $frow['titlecols'];
461 $datacols = $frow['datacols'];
462 $data_type = $frow['data_type'];
463 $field_id = $frow['field_id'];
464 $list_id = $frow['list_id'];
465 $currvalue = '';
467 // Accumulate action conditions into a JSON expression for the browser side.
468 accumActionConditions($frow, $condition_str);
470 if (strpos($field_id, 'em_') === 0) {
471 $tmp = substr($field_id, 3);
472 if (isset($result2[$tmp])) {
473 $currvalue = $result2[$tmp];
475 } else {
476 if (isset($result[$field_id])) {
477 $currvalue = $result[$field_id];
481 // Handle a data category (group) change.
482 if (strcmp($this_group, $last_group) != 0) {
483 if (!$SHORT_FORM) {
484 end_group();
485 $group_seq++; // ID for DIV tags
486 $group_name = $grparr[$this_group]['grp_title'];
488 $group_seq_attr = attr($group_seq);
489 $checked = ($display_style == 'block') ? "show" : "";
490 $group_name_xl = text(xl_layout_label($group_name));
491 $onclick = attr_js("div_" . $group_seq);
492 $init_open = $grparr[$this_group]['grp_init_open'];
493 if ($checked != "show") {
494 $checked = ($init_open == 1) ? $checked . " show" : $checked;
496 echo <<<HTML
497 <div class="card">
498 <div class="card-header p-0 bg-secondary" id="header_{$group_seq_attr}">
499 <h2 class="mb-0">
500 <button class="btn btn-link btn-block text-light text-left" type="button" data-toggle="collapse" data-target="#div_{$group_seq_attr}" aria-expanded="true" aria-controls="{$group_seq_attr}">$group_name_xl</button>
501 </h2>
502 </div>
503 <div id="div_{$group_seq_attr}" class="bg-light collapse {$checked}" aria-labelledby="header_{$group_seq_attr}" >
504 <div class="container-xl card-body">
505 HTML;
506 $display_style = 'none';
507 } elseif (strlen($last_group) == 0) {
508 echo " <div class='container-xl'>\n";
510 $CPR = empty($grparr[$this_group]['grp_columns']) ? $TOPCPR : $grparr[$this_group]['grp_columns'];
511 $last_group = $this_group;
514 // Handle starting of a new row.
515 if (($titlecols > 0 && $cell_count >= $CPR) || $cell_count == 0) {
516 end_row();
517 echo "<div class='form-group row'>";
520 if ($item_count == 0 && $titlecols == 0) {
521 $titlecols = 1;
524 $field_id_label = 'label_' . $frow['field_id'];
526 // Handle starting of a new label cell.
527 if ($titlecols > 0) {
528 end_cell();
529 $bs_cols = $titlecols * intval(12 / $CPR);
530 echo "<div class='$BS_COL_CLASS-$bs_cols ";
531 echo ($frow['uor'] == 2) ? "required" : "";
532 echo "' id='" . attr($field_id_label) . "'";
533 echo ">";
534 $cell_count += $titlecols;
537 // $item_count is the number of title and data items in the current cell.
538 ++$item_count;
540 if ($datacols == 0) {
541 // Data will be in the same cell, so prevent wrapping between title and data.
542 echo "<span class='text-nowrap mr-2'>"; // mb-2 doesn't work here
546 // Modified 6-09 by BM - Translate if applicable
547 if ($frow['title']) {
548 echo (text(xl_layout_label($frow['title'])) . ":");
551 // Handle starting of a new data cell.
552 if ($datacols > 0) {
553 $id_field_text = "text_" . $frow['field_id'];
554 end_cell();
555 $bs_cols = $datacols * intval(12 / $CPR);
556 echo "<div class='$BS_COL_CLASS-$bs_cols'";
557 echo " id='" . attr($id_field_text) . "'";
558 echo ">";
559 $cell_count += $datacols;
562 ++$item_count;
564 if ($item_count > 1) {
565 echo "&nbsp;";
568 // 'smallform' can be used to add arbitrary CSS classes. Note the leading space.
569 $frow['smallform'] = ' form-control-sm mw-100' . ($datacols ? '' : ' mb-1');
571 // set flag so we don't bring in session pid data for a new pt form
572 $frow['blank_form'] = false;
573 if (
574 $frow['data_type'] == "52"
575 || $frow['data_type'] == "53"
576 || $frow['data_type'] == "54"
578 $frow['blank_form'] = true;
580 generate_form_field($frow, $currvalue);
582 if ($datacols == 0) {
583 // End nowrap
584 echo "</span> "; // space to allow wrap between spans
588 end_group();
591 <?php
592 if (!$GLOBALS['simplified_demographics']) {
593 $insurancei = getInsuranceProviders();
594 $pid = 0;
595 if ($GLOBALS['insurance_only_one']) {
596 $insurance_headings = array(xl("Primary Insurance Provider"));
597 $insurance_info = array();
598 $insurance_info[1] = getInsuranceData($pid, "primary");
599 } else {
600 $insurance_headings = array(xl("Primary Insurance Provider"), xl("Secondary Insurance Provider"), xl("Tertiary Insurance provider"));
601 $insurance_info = array();
602 $insurance_info[1] = getInsuranceData($pid, "primary");
603 $insurance_info[2] = getInsuranceData($pid, "secondary");
604 $insurance_info[3] = getInsuranceData($pid, "tertiary");
606 $insuranceTitle = xlt("Insurance");
607 echo <<<HTML
608 <div class="card">
609 <div class="card-header p-0 bg-secondary" id="header_ins">
610 <h2 class="mb-0">
611 <button class="btn btn-link btn-block text-light text-left" type="button" data-toggle="collapse" data-target="#div_ins" aria-expanded="true" aria-controls="ins">$insuranceTitle</button>
612 </h2>
613 </div>
614 <div id="div_ins" class="bg-light collapse" aria-labelledby="header_ins" >
615 <div class="container-xl card-body">
616 HTML;
618 for ($i = 1; $i <= sizeof($insurance_info); $i++) {
619 $result3 = $insurance_info[$i];
621 <div class="row p-3">
622 <div class="col-md-12 mb-2">
623 <div class="input-group">
624 <label class='col-form-label mr-2 required'><?php echo text($insurance_headings[$i - 1]) . ":"?></label>
625 <select name="i<?php echo attr($i); ?>provider" class="form-control">
626 <option value=""><?php echo xlt('Unassigned'); ?></option>
627 <?php
628 foreach ($insurancei as $iid => $iname) {
629 echo "<option value='" . attr($iid) . "'";
630 if (!empty($result3["provider"]) && (strtolower($iid) == strtolower($result3["provider"]))) {
631 echo " selected";
633 echo ">" . text($iname) . "</option>\n";
636 </select>
637 <div class="input-group-append">
638 <a class='btn btn-primary text-white medium_modal' href='../practice/ins_search.php' onclick='ins_search(<?php echo attr_js($i); ?>)'><?php echo xlt('Search/Add Insurer'); ?></a>
639 </div>
640 </div>
641 </div>
642 <label class='col-form-label col-md-1 mb-2 required'><?php echo xlt('Plan Name'); ?>:</label>
643 <div class="col-md-5 mb-2">
644 <input type='entry' class='form-control' size='20' name='i<?php echo attr($i); ?>plan_name' value="<?php echo attr($result3["plan_name"] ?? ''); ?>" onchange="capitalizeMe(this);" />
645 </div>
646 <label class='col-form-label col-md-1 mb-2 required'><?php echo xlt('Subscriber'); ?>:</label>
647 <div class="col-md-5 mb-2 form-inline">
648 <input type='entry' class='form-control' size='10' name='i<?php echo attr($i); ?>subscriber_fname' value="<?php echo attr($result3["subscriber_fname"] ?? ''); ?>" onchange="capitalizeMe(this);" />
649 <input type='entry' class='form-control' size='3' name='i<?php echo attr($i); ?>subscriber_mname' value="<?php echo attr($result3["subscriber_mname"] ?? ''); ?>" onchange="capitalizeMe(this);" />
650 <input type='entry' class='form-control' size='10' name='i<?php echo attr($i); ?>subscriber_lname' value="<?php echo attr($result3["subscriber_lname"] ?? ''); ?>" onchange="capitalizeMe(this);" />
651 </div>
652 <label class='col-form-label col-md-1 mb-2 required'><?php echo xlt('Effective Date'); ?>: </label>
653 <div class="col-md-5 mb-2">
654 <input type='entry' size='11' class='datepicker form-control' name='i<?php echo attr($i); ?>effective_date' id='i<?php echo attr($i); ?>effective_date' value='<?php echo attr($result3['date'] ?? ''); ?>' />
655 </div>
656 <label class='col-form-label col-md-1 mb-2 required'><?php echo xlt('Relationship'); ?>:</label>
657 <div class="col-md-5 mb-2">
658 <?php
659 generate_form_field(array('data_type' => 1,'field_id' => ('i' . $i . 'subscriber_relationship'),'list_id' => 'sub_relation','empty_title' => ' ', 'smallform' => 'true'), ($result3['subscriber_relationship'] ?? ''));
661 <a href="javascript:popUp('../../interface/patient_file/summary/browse.php?browsenum=<?php echo attr_url($i); ?>')" class='text'>(<?php echo xlt('Browse'); ?>)</a>
662 </div>
663 <label class='col-form-label col-md-1 mb-2 required'><?php echo xlt('Policy Number'); ?>:</label>
664 <div class="col-md-5 mb-2">
665 <input type='entry' class='form-control' size='16' name='i<?php echo attr($i); ?>policy_number' value="<?php echo attr($result3["policy_number"] ?? ''); ?>" onkeyup='policykeyup(this)' />
666 </div>
667 <label class='col-form-label col-md-1 mb-2'><?php echo xlt('D.O.B.'); ?>:</label>
668 <div class="col-md-5 mb-2">
669 <input type='entry' size='11' class='datepicker-past form-control' name='i<?php echo attr($i); ?>subscriber_DOB' id='i<?php echo attr($i); ?>subscriber_DOB' value='<?php echo attr($result3['subscriber_DOB'] ?? ''); ?>' />
670 </div>
671 <label class='col-form-label col-md-1 required'><?php echo xlt('Group Number'); ?>:</label>
672 <div class="col-md-5 mb-2">
673 <input type='entry' class='form-control' size='16' name='i<?php echo attr($i); ?>group_number' value="<?php echo attr($result3["group_number"] ?? ''); ?>" onkeyup='policykeyup(this)' />
674 </div>
675 <label class='col-form-label col-md-1 mb-2'><?php echo xlt('S.S.'); ?>:</label>
676 <div class="col-md-5 mb-2">
677 <input type='entry' class='form-control' size='11' name='i<?php echo attr($i); ?>subscriber_ss' value="<?php echo attr($result3["subscriber_ss"] ?? ''); ?>" />
678 </div>
679 <?php echo ($GLOBALS['omit_employers']) ? "<div class='d-none'>" : ""; ?>
680 <label class="col-form-label col-md-1 mb-2 required"><?php echo xlt('Subscriber Employer (SE)'); ?>:</label>
681 <div class="col-md-5 mb-2">
682 <input type='entry' class='form-control' aria-describedby="seHelpBlock" size='25' name='i<?php echo attr($i); ?>subscriber_employer' value="<?php echo attr($result3["subscriber_employer"] ?? ''); ?>" onchange="capitalizeMe(this);" />
683 <small id="seHelpBlock" class="form-text text-muted">
684 <?php echo xlt('if unemployed enter Student'); ?>, <?php echo xlt('PT Student, or leave blank'); ?>.
685 </small>
686 </div>
687 <?php echo ($GLOBALS['omit_employers']) ? "</div>" : ""; ?>
688 <label class='col-form-label col-md-1 mb-2'><?php echo xlt('Sex'); ?>:</label>
689 <div class="col-md-5 mb-2">
690 <?php
691 generate_form_field(array('data_type' => 1,'field_id' => ('i' . $i . 'subscriber_sex'),'list_id' => 'sex', 'smallform' => 'true'), $result3['subscriber_sex'] ?? '');
693 </div>
694 <?php echo ($GLOBALS['omit_employers']) ? "<div class='d-none'>" : ""; ?>
695 <label class='col-form-label col-md-1 mb-2 required'><?php echo xlt('SE Address'); ?>:</label>
696 <div class="col-md-5 mb-2">
697 <input type='entry' class='form-control' size='25' name='i<?php echo attr($i); ?>subscriber_employer_street' value="<?php echo attr($result3["subscriber_employer_street"] ?? ''); ?>" onchange="capitalizeMe(this);" />
698 </div>
699 <?php echo ($GLOBALS['omit_employers']) ? "</div>" : ""; ?>
700 <label class='col-form-label col-md-1 mb-2 required'><?php echo xlt('Subscriber Address Line 1'); ?>:</label>
701 <div class="col-md-5 mb-2">
702 <input type='entry' class='form-control' size='25' name='i<?php echo attr($i); ?>subscriber_street' value="<?php echo attr($result3["subscriber_street"] ?? ''); ?>" onchange="capitalizeMe(this);" />
703 </div>
704 <label class='col-form-label col-md-1 mb-2 required'><?php echo xlt('Subscriber Address Line 2'); ?>:</label>
705 <div class="col-md-5 mb-2">
706 <input type='entry' class='form-control' size='25' name='i<?php echo attr($i); ?>subscriber_street_line_2' value="<?php echo attr($result3["subscriber_street_line_2"] ?? ''); ?>" onchange="capitalizeMe(this);" />
707 </div>
708 <?php echo ($GLOBALS['omit_employers']) ? "<div class='d-none'>" : ""; ?>
709 <label class='col-form-label col-md-1 mb-2 required'><?php echo xlt('SE City'); ?>:</label>
710 <div class="col-md-5 mb-2">
711 <input type='entry' class='form-control' size='15' name='i<?php echo attr($i); ?>subscriber_employer_city' value="<?php echo attr($result3["subscriber_employer_city"] ?? ''); ?>" onchange="capitalizeMe(this);" />
712 </div>
713 <?php echo ($GLOBALS['omit_employers']) ? "</div>" : ""; ?>
714 <label class='col-form-label col-md-1 mb-2 required'><?php echo xlt('City'); ?>:</label>
715 <div class="col-md-5 mb-2">
716 <input type='entry' class='form-control' size='15' name='i<?php echo attr($i); ?>subscriber_city' value="<?php echo attr($result3["subscriber_city"] ?? ''); ?>" onchange="capitalizeMe(this);" />
717 </div>
718 <?php echo ($GLOBALS['omit_employers']) ? "<div class='d-none'>" : ""; ?>
719 <label class='col-form-label col-md-1 mb-2 required'><?php echo ($GLOBALS['phone_country_code'] == '1') ? xlt('SE State') : xlt('SE Locality') ?>:</label>
720 <div class="col-md-5 mb-2">
721 <?php
722 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', 'smallform' => 'true'), ($result3['subscriber_employer_state'] ?? ''));
724 </div>
725 <?php echo ($GLOBALS['omit_employers']) ? "</div>" : ""; ?>
726 <label class='col-form-label col-md-1 mb-2 required'><?php echo ($GLOBALS['phone_country_code'] == '1') ? xlt('State') : xlt('Locality') ?>:</label>
727 <div class="col-md-5 mb-2">
728 <?php
729 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', 'smallform' => 'true'), ($result3['subscriber_state'] ?? ''));
731 </div>
732 <?php echo ($GLOBALS['omit_employers']) ? "<div class='d-none'>" : ""; ?>
733 <label class='col-form-label col-md-1 mb-2 required'><?php echo ($GLOBALS['phone_country_code'] == '1') ? xlt('SE Zip Code') : xlt('SE Postal Code') ?>: </label>
734 <div class="col-md-5 mb-2">
735 <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"] ?? ''); ?>" />
736 </div>
737 <?php echo ($GLOBALS['omit_employers']) ? "</div>" : ""; ?>
738 <label class='col-form-label col-md-1 mb-2 required'><?php echo ($GLOBALS['phone_country_code'] == '1') ? xlt('Zip Code') : xlt('Postal Code') ?>: </label>
739 <div class="col-md-5 mb-2">
740 <input type='entry' class='form-control' size='10' name='i<?php echo attr($i); ?>subscriber_postal_code' value="<?php echo attr($result3["subscriber_postal_code"] ?? ''); ?>" />
741 </div>
742 <?php echo ($GLOBALS['omit_employers']) ? "<div class='d-none'>" : ""; ?>
743 <label class='col-form-label col-md-1 mb-2 required'><?php echo xlt('SE Country'); ?>:</label>
744 <div class="col-md-5 mb-2">
745 <?php
746 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', 'smallform' => 'true'), ($result3['subscriber_employer_country'] ?? ''));
748 </div>
749 <label class='col-form-label col-md-1 mb-2 required'><?php echo xlt('Country'); ?>:</label>
750 <div class="col-md-5 mb-2">
751 <?php
752 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', 'smallform' => 'true'), ($result3['subscriber_country'] ?? ''));
754 </div>
755 <?php echo ($GLOBALS['omit_employers']) ? "</div>" : ""; ?>
756 <label class='col-form-label col-md-1 mb-2'><?php echo xlt('Subscriber Phone'); ?>:</label>
757 <div class="col-md-5 mb-2">
758 <input type='text' class='form-control' size='20' name='i<?php echo attr($i); ?>subscriber_phone' value='<?php echo attr($result3["subscriber_phone"] ?? ''); ?>' onkeyup='phonekeyup(this,mypcc)' />
759 </div>
760 <label class='col-form-label col-md-1 mb-2'><?php echo xlt('Co-Pay'); ?>:</label>
761 <div class="col-md-5 mb-2">
762 <input type='text' class='form-control' size="6" name='i<?php echo attr($i); ?>copay' value="<?php echo attr($result3["copay"] ?? ''); ?>" />
763 </div>
764 <label class='col-form-label col-md-1 mb-2 required'><?php echo xlt('Accept Assignment'); ?>:</label>
765 <div class="col-md-5 mb-2">
766 <select class='form-control' name='i<?php echo attr($i); ?>accept_assignment'>
767 <option value="TRUE" <?php echo (strtoupper($result3["accept_assignment"] ?? '') == "TRUE") ? "selected" : ""; ?>><?php echo xlt('YES'); ?></option>
768 <option value="FALSE" <?php echo (strtoupper($result3["accept_assignment"] ?? '') == "FALSE") ? "selected" : ""; ?>><?php echo xlt('NO'); ?></option>
769 </select>
770 </div>
771 </div>
772 <hr />
773 <?php
776 echo "</div>\n";
777 } // end of "if not simplified_demographics"
780 <?php
781 if ($SHORT_FORM) {
782 echo " </div>\n";
783 } ?>
785 </td>
786 <td class="text-right align-top text-nowrap" width='1%'>
787 <!-- Image upload stuff was here but got moved. -->
788 </td>
789 </tr>
790 </table>
791 </form>
792 </div>
793 </div>
794 </div>
795 <div class="row">
796 <div class="col-md-12">
797 <div class="btn-group">
798 <?php if ($WITH_SEARCH) { ?>
799 <button type="button" class="btn btn-secondary btn-search" id="search" value="<?php echo xla('Search'); ?>">
800 <?php echo xlt('Search'); ?>
801 </button>
802 <?php } ?>
803 <button type="button" class="btn btn-primary btn-save" name='create' id="create" value="<?php echo xla('Create New Patient'); ?>">
804 <?php echo xlt('Create New Patient'); ?>
805 </button>
806 </div>
807 </div>
808 </div>
809 </div> <!--end of container div -->
810 <!-- include support for the list-add selectbox feature -->
811 <?php require($GLOBALS['fileroot'] . "/library/options_listadd.inc.php"); ?>
812 <script>
814 // hard code validation for old validation, in the new validation possible to add match rules
815 <?php if ($GLOBALS['new_validate'] == 0) { ?>
816 // fix inconsistently formatted phone numbers from the database
817 var f = document.forms[0];
818 if (f.form_phone_contact) phonekeyup(f.form_phone_contact,mypcc);
819 if (f.form_phone_home ) phonekeyup(f.form_phone_home ,mypcc);
820 if (f.form_phone_biz ) phonekeyup(f.form_phone_biz ,mypcc);
821 if (f.form_phone_cell ) phonekeyup(f.form_phone_cell ,mypcc);
823 <?php }?>
825 <?php echo $date_init; ?>
827 // -=- jQuery makes life easier -=-
829 // var matches = 0; // number of patients that match the demographic information being entered
830 // var override = false; // flag that overrides the duplication warning
832 $(function () {
833 $(".medium_modal").on('click', function(e) {
834 e.preventDefault();e.stopPropagation();
835 dlgopen('', '', 650, 460, '', '', {
836 buttons: [
837 {text: <?php echo xlj('Close'); ?>, close: true, style: 'default btn-sm'}
839 //onClosed: 'refreshme',
840 allowResize: false,
841 allowDrag: true,
842 dialogId: '',
843 type: 'iframe',
844 url: $(this).attr('href')
847 // added to integrate insurance stuff
848 <?php for ($i = 1; $i <= 3; $i++) { ?>
849 $("#form_i<?php echo $i?>subscriber_relationship").change(function() { auto_populate_employer_address<?php echo $i?>(); });
850 <?php } ?>
852 $('#search').click(function() { searchme(); });
853 $('#create').click(function() { check()});
855 var check = function(e) {
856 var f = document.forms[0];
857 <?php if ($GLOBALS['new_validate']) {?>
858 var valid = submitme(<?php echo $GLOBALS['new_validate'] ? 1 : 0;?>, e, "DEM", constraints);
859 <?php } else {?>
860 top.restoreSession();
861 var valid = validate(f);
862 <?php }?>
863 if (valid) {
864 if (force_submit) {
865 // In this case dups were shown already and Save should just save.
866 top.restoreSession();
867 f.submit();
868 return;
871 <?php
872 // D in edit_options indicates the field is used in duplication checking.
873 // This constructs a list of the names of those fields.
874 $mflist = "";
875 $mfres = sqlStatement("SELECT * FROM layout_options " .
876 "WHERE form_id = 'DEM' AND uor > 0 AND field_id != '' AND " .
877 "(edit_options LIKE '%D%' OR edit_options LIKE '%W%' )" .
878 "ORDER BY group_id, seq");
879 while ($mfrow = sqlFetchArray($mfres)) {
880 $field_id = $mfrow['field_id'];
881 if (strpos($field_id, 'em_') === 0) {
882 continue;
885 if (!empty($mflist)) {
886 $mflist .= ",";
889 $mflist .= js_escape($field_id);
892 <?php if (($GLOBALS['full_new_patient_form'] == '4') && (checkIfPatientValidationHookIsActive())) :?>
893 // Use zend module patient validation hook to open the controller and send the dup-checker fields.
894 var url ='<?php echo $GLOBALS['web_root'] . "/interface/modules/zend_modules/public/patientvalidation"; ?>';
895 <?php else :?>
896 // Build and invoke the URL to create the dup-checker dialog.
897 var url = 'new_search_popup.php';
898 <?php endif;?>
900 var flds = new Array(<?php echo $mflist; ?>);
901 var separator = '?';
902 for (var i = 0; i < flds.length; ++i) {
903 var fval = $('#form_' + flds[i]).val();
904 if (fval && fval != '') {
905 url += separator;
906 separator = '&';
907 url += 'mf_' + flds[i] + '=' + encodeURIComponent(fval);
910 if (flds == '') {
911 url += "?close";
912 } else {
913 url+="&close";
915 dlgopen(url, '_blank', 875, 500);
916 } // end function
917 } // end function
919 // Set onclick/onfocus handlers for toggling background color.
920 <?php
921 $lres = getLayoutRes();
922 while ($lrow = sqlFetchArray($lres)) {
923 $field_id = $lrow['field_id'];
924 if (strpos($field_id, 'em_') === 0) {
925 continue;
928 switch (getSearchClass($lrow['data_type'])) {
929 case 1:
930 echo " \$(" . js_escape("#form_" . $field_id) . ").click(function() { toggleSearch(this); });\n";
931 break;
932 case 2:
933 echo " \$(" . js_escape("#form_" . $field_id) . ").click(function() { selClick(this); });\n";
934 echo " \$(" . js_escape("#form_" . $field_id) . ").blur(function() { selBlur(this); });\n";
935 break;
940 $(".select-dropdown").select2({
941 theme: "bootstrap4",
942 dropdownAutoWidth: true,
943 width: 'resolve',
944 <?php require($GLOBALS['srcdir'] . '/js/xl/select2.js.php'); ?>
946 if (typeof error !== 'undefined') {
947 if (error) {
948 alertMsg(error);
952 $('.datepicker').datetimepicker({
953 <?php $datetimepicker_timepicker = false; ?>
954 <?php $datetimepicker_showseconds = false; ?>
955 <?php $datetimepicker_formatInput = true; ?>
956 <?php $datetimepicker_minDate = false; ?>
957 <?php $datetimepicker_maxDate = false; ?>
958 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
959 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
961 $('.datetimepicker').datetimepicker({
962 <?php $datetimepicker_timepicker = true; ?>
963 <?php $datetimepicker_showseconds = false; ?>
964 <?php $datetimepicker_formatInput = true; ?>
965 <?php $datetimepicker_minDate = false; ?>
966 <?php $datetimepicker_maxDate = false; ?>
967 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
968 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
970 $('.datepicker-past').datetimepicker({
971 <?php $datetimepicker_timepicker = false; ?>
972 <?php $datetimepicker_showseconds = false; ?>
973 <?php $datetimepicker_formatInput = true; ?>
974 <?php $datetimepicker_minDate = false; ?>
975 <?php $datetimepicker_maxDate = '+1970/01/01'; ?>
976 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
977 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
979 $('.datetimepicker-past').datetimepicker({
980 <?php $datetimepicker_timepicker = true; ?>
981 <?php $datetimepicker_showseconds = false; ?>
982 <?php $datetimepicker_formatInput = true; ?>
983 <?php $datetimepicker_minDate = false; ?>
984 <?php $datetimepicker_maxDate = '+1970/01/01'; ?>
985 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
986 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
988 $('.datepicker-future').datetimepicker({
989 <?php $datetimepicker_timepicker = false; ?>
990 <?php $datetimepicker_showseconds = false; ?>
991 <?php $datetimepicker_formatInput = true; ?>
992 <?php $datetimepicker_minDate = '-1970/01/01'; ?>
993 <?php $datetimepicker_maxDate = false; ?>
994 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
995 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
997 $('.datetimepicker-future').datetimepicker({
998 <?php $datetimepicker_timepicker = true; ?>
999 <?php $datetimepicker_showseconds = false; ?>
1000 <?php $datetimepicker_formatInput = true; ?>
1001 <?php $datetimepicker_minDate = '-1970/01/01'; ?>
1002 <?php $datetimepicker_maxDate = false; ?>
1003 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
1004 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
1008 }); // end document.ready
1010 // callback for new patient save confirm from new_search_popup.php
1011 // note that dlgclose() callbacks mostly need to init outside dom.
1012 function srcConfirmSave() {
1013 document.forms[0].submit();
1016 </script>
1017 <?php /*Include the validation script and rules for this form*/
1018 $form_id = "DEM";
1021 <?php
1022 //LBF forms use the new validation depending on the global value
1023 $use_validate_js = $GLOBALS['new_validate'];
1024 include_once("$srcdir/validation/validation_script.js.php");?>
1025 <script>
1026 // Array of skip conditions for the checkSkipConditions() function.
1027 var skipArray = [
1028 <?php echo $condition_str; ?>
1030 checkSkipConditions();
1031 $("input").change(function() {
1032 checkSkipConditions();
1034 $("select").change(function() {
1035 checkSkipConditions();
1037 </script>
1038 </body>
1039 </html>