Fully responsive globals.php with vertical menu (#2460)
[openemr.git] / interface / new / new_comprehensive.php
blobb356bfec3fa2c18b0072461c784c80a4e9fd739e
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-2018 Brady Miller <brady.g.miller@gmail.com>
11 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
15 require_once("../globals.php");
16 require_once("$srcdir/acl.inc");
17 require_once("$srcdir/options.inc.php");
18 require_once("$srcdir/patient.inc");
19 require_once("$srcdir/erx_javascript.inc.php");
20 require_once("$srcdir/validation/LBF_Validation.php");
21 require_once("$srcdir/patientvalidation.inc.php");
23 use OpenEMR\Core\Header;
25 // Check authorization.
26 if (!acl_check('patients', 'demo', '', array('write','addonly'))) {
27 die(xlt("Adding demographics is not authorized."));
30 $CPR = 4; // cells per row
32 $searchcolor = empty($GLOBALS['layout_search_color']) ?
33 '#ffff55' : $GLOBALS['layout_search_color'];
35 $WITH_SEARCH = ($GLOBALS['full_new_patient_form'] == '1' || $GLOBALS['full_new_patient_form'] == '2' );
36 $SHORT_FORM = ($GLOBALS['full_new_patient_form'] == '2' || $GLOBALS['full_new_patient_form'] == '3' || $GLOBALS['full_new_patient_form'] == '4');
38 $grparr = array();
39 getLayoutProperties('DEM', $grparr);
41 function getLayoutRes()
43 global $SHORT_FORM;
44 return sqlStatement("SELECT * FROM layout_options " .
45 "WHERE form_id = 'DEM' AND uor > 0 AND field_id != '' " .
46 ($SHORT_FORM ? "AND ( uor > 1 OR edit_options LIKE '%N%' ) " : "") .
47 "ORDER BY group_id, seq");
50 // Determine layout field search treatment from its data type:
51 // 1 = text field
52 // 2 = select list
53 // 0 = not searchable
55 function getSearchClass($data_type)
57 switch ($data_type) {
58 case 1: // single-selection list
59 case 10: // local provider list
60 case 11: // provider list
61 case 12: // pharmacy list
62 case 13: // squads
63 case 14: // address book list
64 case 26: // single-selection list with add
65 case 35: // facilities
66 return 2;
67 case 2: // text field
68 case 3: // textarea
69 case 4: // date
70 return 1;
73 return 0;
76 $fres = getLayoutRes();
78 <html>
79 <head>
80 <?php Header::setupHeader(['common','datetime-picker', 'jquery-ui']); ?>
81 <title><?php echo xlt("Search or Add Patient"); ?></title>
83 <style>
84 body {
85 padding: 5pt 5pt 5pt 5pt;
88 div.section {
89 border: solid;
90 border-width: 1px;
91 border-color: #0000ff;
92 margin: 0 0 0 10pt;
93 padding: 5pt;
96 .form-control {
97 width: auto;
98 display: inline;
99 height: auto;
101 </style>
103 <?php include_once("{$GLOBALS['srcdir']}/options.js.php"); ?>
105 <SCRIPT LANGUAGE="JavaScript"><!--
106 //Visolve - sync the radio buttons - Start
107 if((top.window.parent) && (parent.window)){
108 var wname = top.window.parent.left_nav;
109 fname = (parent.window.name)?parent.window.name:window.name;
110 wname.syncRadios();
111 }//Visolve - sync the radio buttons - End
113 var mypcc = <?php echo js_escape($GLOBALS['phone_country_code']); ?>;
115 // This may be changed to true by the AJAX search script.
116 var force_submit = false;
118 //code used from http://tech.irt.org/articles/js037/
119 function replace(string,text,by) {
120 // Replaces text with by in string
121 var strLength = string.length, txtLength = text.length;
122 if ((strLength == 0) || (txtLength == 0)) return string;
124 var i = string.indexOf(text);
125 if ((!i) && (text != string.substring(0,txtLength))) return string;
126 if (i == -1) return string;
128 var newstr = string.substring(0,i) + by;
130 if (i+txtLength < strLength)
131 newstr += replace(string.substring(i+txtLength,strLength),text,by);
133 return newstr;
136 <?php for ($i=1; $i<=3; $i++) { ?>
137 function auto_populate_employer_address<?php echo $i ?>(){
138 var f = document.demographics_form;
139 if (f.form_i<?php echo $i?>subscriber_relationship.options[f.form_i<?php echo $i?>subscriber_relationship.selectedIndex].value == "self") {
140 f.i<?php echo $i?>subscriber_fname.value=f.form_fname.value;
141 f.i<?php echo $i?>subscriber_mname.value=f.form_mname.value;
142 f.i<?php echo $i?>subscriber_lname.value=f.form_lname.value;
143 f.i<?php echo $i?>subscriber_street.value=f.form_street.value;
144 f.i<?php echo $i?>subscriber_city.value=f.form_city.value;
145 f.form_i<?php echo $i?>subscriber_state.value=f.form_state.value;
146 f.i<?php echo $i?>subscriber_postal_code.value=f.form_postal_code.value;
147 if (f.form_country_code)
148 f.form_i<?php echo $i?>subscriber_country.value=f.form_country_code.value;
149 f.i<?php echo $i?>subscriber_phone.value=f.form_phone_home.value;
150 f.i<?php echo $i?>subscriber_DOB.value=f.form_DOB.value;
151 f.i<?php echo $i?>subscriber_ss.value=f.form_ss.value;
152 f.form_i<?php echo $i?>subscriber_sex.value = f.form_sex.value;
153 f.i<?php echo $i?>subscriber_employer.value=f.form_em_name.value;
154 f.i<?php echo $i?>subscriber_employer_street.value=f.form_em_street.value;
155 f.i<?php echo $i?>subscriber_employer_city.value=f.form_em_city.value;
156 f.form_i<?php echo $i?>subscriber_employer_state.value=f.form_em_state.value;
157 f.i<?php echo $i?>subscriber_employer_postal_code.value=f.form_em_postal_code.value;
158 if (f.form_em_country)
159 f.form_i<?php echo $i?>subscriber_employer_country.value=f.form_em_country.value;
163 <?php } ?>
165 function upperFirst(string,text) {
166 return replace(string,text,text.charAt(0).toUpperCase() + text.substring(1,text.length));
169 // The ins_search.php window calls this to set the selected insurance.
170 function set_insurance(ins_id, ins_name) {
171 var thesel = document.forms[0]['i' + insurance_index + 'provider'];
172 var theopts = thesel.options; // the array of Option objects
173 var i = 0;
174 for (; i < theopts.length; ++i) {
175 if (theopts[i].value == ins_id) {
176 theopts[i].selected = true;
177 return;
180 // no matching option was found so create one, append it to the
181 // end of the list, and select it.
182 theopts[i] = new Option(ins_name, ins_id, false, true);
185 // Indicates which insurance slot is being updated.
186 var insurance_index = 0;
188 // The OnClick handler for searching/adding the insurance company.
189 function ins_search(ins) {
190 insurance_index = ins;
191 return false;
194 function checkNum () {
195 var re= new RegExp();
196 re = /^\d*\.?\d*$/;
197 str=document.forms[0].monthly_income.value;
198 if(re.exec(str))
200 }else{
201 alert(<?php echo xlj("Please enter a dollar amount using only numbers and a decimal point."); ?>);
205 // This capitalizes the first letter of each word in the passed input
206 // element. It also strips out extraneous spaces.
207 function capitalizeMe(elem) {
208 var a = elem.value.split(' ');
209 var s = '';
210 for(var i = 0; i < a.length; ++i) {
211 if (a[i].length > 0) {
212 if (s.length > 0) s += ' ';
213 s += a[i].charAt(0).toUpperCase() + a[i].substring(1);
216 elem.value = s;
219 // Onkeyup handler for policy number. Allows only A-Z and 0-9.
220 function policykeyup(e) {
221 var v = e.value.toUpperCase();
222 var filteredString="";
223 for (var i = 0; i < v.length; ++i) {
224 var c = v.charAt(i);
225 if ((c >= '0' && c <= '9') ||
226 (c >= 'A' && c <= 'Z') ||
227 (c == '*') ||
228 (c == '-') ||
229 (c == '_') ||
230 (c == '(') ||
231 (c == ')') ||
232 (c == '#'))
234 filteredString+=c;
237 e.value = filteredString;
238 return;
241 function divclick(cb, divid) {
242 var divstyle = document.getElementById(divid).style;
243 if (cb.checked) {
244 divstyle.display = 'block';
245 } else {
246 divstyle.display = 'none';
248 return true;
251 // Compute the length of a string without leading and trailing spaces.
252 function trimlen(s) {
253 var i = 0;
254 var j = s.length - 1;
255 for (; i <= j && s.charAt(i) == ' '; ++i);
256 for (; i <= j && s.charAt(j) == ' '; --j);
257 if (i > j) return 0;
258 return j + 1 - i;
261 function validate(f) {
262 var errMsgs = new Array();
263 <?php generate_layout_validation('DEM'); ?>
264 <?php if ($GLOBALS['erx_enable']) { ?>
265 alertMsg='';
266 for(i=0;i<f.length;i++){
267 if(f[i].type=='text' && f[i].value)
269 if(f[i].name == 'form_fname' || f[i].name == 'form_mname' || f[i].name == 'form_lname')
271 alertMsg += checkLength(f[i].name,f[i].value,35);
272 alertMsg += checkUsername(f[i].name,f[i].value);
274 else if(f[i].name == 'form_street' || f[i].name == 'form_city')
276 alertMsg += checkLength(f[i].name,f[i].value,35);
277 alertMsg += checkAlphaNumericExtended(f[i].name,f[i].value);
279 else if(f[i].name == 'form_phone_home')
281 alertMsg += checkPhone(f[i].name,f[i].value);
285 if(alertMsg)
287 alert(alertMsg);
288 return false;
290 <?php } ?>
291 var msg = "";
292 msg += <?php echo xlj('The following fields are required'); ?> + ":\n\n";
293 for ( var i = 0; i < errMsgs.length; i++ ) {
294 msg += errMsgs[i] + "\n";
296 msg += "\n" + <?php echo xlj('Please fill them in before continuing.'); ?>;
299 //Misc Deceased Date Validation for Future Date
300 var dateVal = document.getElementById("form_deceased_date").value;
301 var currentDate;
302 var d = new Date();
303 month = '' + (d.getMonth() + 1),
304 day = '' + d.getDate(),
305 year = d.getFullYear();
306 if (month.length < 2) month = '0' + month;
307 if (day.length < 2) day = '0' + day;
308 currentDate = year+'-'+month+'-'+day;
309 if(errMsgs.length > 0 || dateVal > currentDate)
311 if(errMsgs.length > 0)
312 alert(msg);
313 if(dateVal > currentDate)
314 alert (<?php echo xlj("Deceased Date should not be greater than Today"); ?>);
315 return false;
317 return true;
320 function toggleSearch(elem) {
321 var f = document.forms[0];
322 <?php if ($WITH_SEARCH) { ?>
323 // Toggle background color.
324 if (elem.style.backgroundColor == '')
325 elem.style.backgroundColor = <?php echo js_escape($searchcolor); ?>;
326 else
327 elem.style.backgroundColor = '';
328 <?php } ?>
329 if (force_submit) {
330 force_submit = false;
331 f.create.value = <?php echo xlj('Create New Patient'); ?>;
333 return true;
336 // If a <select> list is dropped down, this is its name.
337 var open_sel_name = '';
339 function selClick(elem) {
340 if (open_sel_name == elem.name) {
341 open_sel_name = '';
343 else {
344 open_sel_name = elem.name;
345 toggleSearch(elem);
347 return true;
350 function selBlur(elem) {
351 if (open_sel_name == elem.name) {
352 open_sel_name = '';
354 return true;
357 // This invokes the patient search dialog.
358 function searchme() {
359 var f = document.forms[0];
360 var url = '../main/finder/patient_select.php?popup=1&csrf_token_form=<?php echo attr_url(collectCsrfToken()); ?>';
362 <?php
363 $lres = getLayoutRes();
365 while ($lrow = sqlFetchArray($lres)) {
366 $field_id = $lrow['field_id'];
367 if (strpos($field_id, 'em_') === 0) {
368 continue;
371 $data_type = $lrow['data_type'];
372 $fldname = "form_$field_id";
373 switch (getSearchClass($data_type)) {
374 case 1:
375 echo
376 " if (f." . attr($fldname) . ".style.backgroundColor != '' && trimlen(f." . attr($fldname) . ".value) > 0) {\n" .
377 " url += '&" . attr($field_id) . "=' + encodeURIComponent(f." . attr($fldname) . ".value);\n" .
378 " }\n";
379 break;
380 case 2:
381 echo
382 " if (f." . attr($fldname) . ".style.backgroundColor != '' && f." . attr($fldname) . ".selectedIndex > 0) {\n" .
383 " url += '&" . attr($field_id) . "=' + encodeURIComponent(f." . attr($fldname) . ".options[f." . attr($fldname) . ".selectedIndex].value);\n" .
384 " }\n";
385 break;
390 dlgopen(url, '_blank', 700, 500);
392 function srchDone(pid){
393 top.restoreSession();
394 document.location.href = "./../../patient_file/summary/demographics.php?set_pid=" + encodeURIComponent(pid);
396 //-->
398 </script>
399 </head>
401 <body class="body_top">
403 <?php
404 /*Get the constraint from the DB-> LBF forms accordinf the form_id*/
405 $constraints = LBF_Validation::generate_validate_constraints("DEM");
407 <script> var constraints = <?php echo $constraints;?>; </script>
408 <div class="container">
409 <div class="row">
410 <div class="col-xs-12">
411 <div class="page-header">
412 <h2><?php echo xlt('Search or Add Patient');?></h2>
413 </div>
414 </div>
415 </div>
416 <div class="row">
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 </div>
429 </div>
430 <br>
431 <div class="row">
432 <div class="col-sm-12">
433 <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)'>
434 <input type="hidden" name="csrf_token_form" value="<?php echo attr(collectCsrfToken()); ?>" />
435 <table width='100%' cellpadding='0' cellspacing='8'>
436 <tr>
437 <td align='left' valign='top'>
438 <?php
439 if ($SHORT_FORM) {
440 echo " <center>\n";
441 } ?>
442 <?php
444 function end_cell()
446 global $item_count, $cell_count;
447 if ($item_count > 0) {
448 echo "</td>";
449 $item_count = 0;
453 function end_row()
455 global $cell_count, $CPR;
456 end_cell();
457 if ($cell_count > 0) {
458 for (; $cell_count < $CPR;
459 ++$cell_count) {
460 echo "<td></td>";
463 echo "</tr>\n";
464 $cell_count = 0;
468 function end_group()
470 global $last_group, $SHORT_FORM;
471 if (strlen($last_group) > 0) {
472 end_row();
473 echo " </table>\n";
474 if (!$SHORT_FORM) {
475 echo "</div>\n";
480 $last_group = '';
481 $cell_count = 0;
482 $item_count = 0;
483 $display_style = 'block';
484 $group_seq = 0; // this gives the DIV blocks unique IDs
486 $condition_str = '';
488 while ($frow = sqlFetchArray($fres)) {
489 $this_group = $frow['group_id'];
490 $titlecols = $frow['titlecols'];
491 $datacols = $frow['datacols'];
492 $data_type = $frow['data_type'];
493 $field_id = $frow['field_id'];
494 $list_id = $frow['list_id'];
495 $currvalue = '';
497 // Accumulate action conditions into a JSON expression for the browser side.
498 accumActionConditions($field_id, $condition_str, $frow['conditions']);
500 if (strpos($field_id, 'em_') === 0) {
501 $tmp = substr($field_id, 3);
502 if (isset($result2[$tmp])) {
503 $currvalue = $result2[$tmp];
505 } else {
506 if (isset($result[$field_id])) {
507 $currvalue = $result[$field_id];
511 // Handle a data category (group) change.
512 if (strcmp($this_group, $last_group) != 0) {
513 if (!$SHORT_FORM) {
514 end_group();
515 $group_seq++; // ID for DIV tags
516 $group_name = $grparr[$this_group]['grp_title'];
518 if (strlen($last_group) > 0) {
519 echo "<br />";
522 echo "<span class='bold'><input type='checkbox' name='form_cb_" . attr($group_seq) . "' id='form_cb_" . attr($group_seq) . "' value='1' " .
523 "onclick='return divclick(this," . attr_js("div_" . $group_seq) . ");'";
524 if ($display_style == 'block') {
525 echo " checked";
528 // Modified 6-09 by BM - Translate if applicable
529 echo " /><b>" . text(xl_layout_label($group_name)) . "</b></span>\n";
531 echo "<div id='div_" . attr($group_seq) . "' class='section' style='display:$display_style;'>\n";
532 echo " <table border='0' cellpadding='0'>\n";
533 $display_style = 'none';
534 } elseif (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='" . attr($titlecols) . "' id='" . attr($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 (text(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='" . attr($datacols) . "' class='text data'";
583 if ($cell_count > 0) {
584 echo " style='padding-left:5pt'". " id='" . attr($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 attr($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";
632 echo ">" . text($iname) . "</option>\n";
635 </select>&nbsp;<a class='medium_modal' href='../practice/ins_search.php' onclick='ins_search(<?php echo attr($i); ?>)'>
636 <span> <?php echo xlt('Search/Add Insurer'); ?></span></a>
637 </td>
638 </tr>
639 <tr>
640 <td valign=top>
641 <table border="0">
642 <tr>
643 <td>
644 <span class='required'><?php echo xlt('Plan Name'); ?>: </span>
645 </td>
646 <td>
647 <input type='entry' class='form-control' size='20' name='i<?php echo attr($i); ?>plan_name' value="<?php echo attr($result3{"plan_name"}); ?>"
648 onchange="capitalizeMe(this);" />&nbsp;&nbsp;
649 </td>
650 </tr>
652 <tr>
653 <td>
654 <span class='required'><?php echo xlt('Effective Date'); ?>: </span>
655 </td>
656 <td>
657 <input type='entry' size='11' class='datepicker form-control' name='i<?php echo attr($i); ?>effective_date'
658 id='i<?php echo attr($i); ?>effective_date'
659 value='<?php echo attr($result3['date']); ?>' />
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 attr($i); ?>policy_number' value="<?php echo attr($result3{"policy_number"}); ?>"
666 onkeyup='policykeyup(this)'>
667 </td>
668 </tr>
670 <tr>
671 <td><span class=required><?php echo xlt('Group Number'); ?>: </span></td>
672 <td><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)'></td>
673 </tr>
675 <tr <?php echo ($GLOBALS['omit_employers']) ? " style='display:none'" : ""; ?>>
676 <td class='required'><?php echo xlt('Subscriber Employer (SE)'); ?><br><span style='font-weight:normal'>
677 (<?php echo xlt('if unemployed enter Student'); ?>,<br><?php echo xlt('PT Student, or leave blank'); ?>): </span>
678 </td>
679 <td><input type=entry class='form-control' size=25 name=i<?php echo attr($i); ?>subscriber_employer
680 value="<?php echo attr($result3{"subscriber_employer"}); ?>"
681 onchange="capitalizeMe(this);" />
682 </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 attr($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 attr($i); ?>subscriber_employer_city
698 value="<?php echo attr($result3{"subscriber_employer_city"}); ?>"
699 onchange="capitalizeMe(this);" />
700 </td>
701 <td><span class=required><?php echo ($GLOBALS['phone_country_code'] == '1') ? xlt('SE State') : xlt('SE Locality') ?>: </span></td>
702 <td>
703 <?php
704 // Modified 7/2009 by BM to incorporate data types
705 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']);
707 </td>
708 </tr>
709 <tr>
710 <td><span class=required><?php echo ($GLOBALS['phone_country_code'] == '1') ? xlt('SE Zip Code') : xlt('SE Postal Code') ?>: </span></td>
711 <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>
712 <td><span class=required><?php echo xlt('SE Country'); ?>: </span></td>
713 <td>
714 <?php
715 // Modified 7/2009 by BM to incorporate data types
716 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']);
718 </td>
719 </tr>
720 </table>
721 </td>
722 </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 attr($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 attr($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 attr($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 attr_url($i); ?>')" class=text>(<?php echo xlt('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 attr($i); ?>subscriber_DOB'
747 id='i<?php echo attr($i); ?>subscriber_DOB'
748 value='<?php echo attr($result3['subscriber_DOB']); ?>' />
750 <span class=bold><?php echo xlt('S.S.'); ?>: </span>
751 <input type=entry class='form-control' size=11 name=i<?php echo attr($i); ?>subscriber_ss value="<?php echo attr($result3{"subscriber_ss"}); ?>">&nbsp;
752 <span class=bold><?php echo xlt('Sex'); ?>: </span>
753 <?php
754 // Modified 6/2009 by BM to use list_options and function
755 generate_form_field(array('data_type'=>1,'field_id'=>('i'.$i.'subscriber_sex'),'list_id'=>'sex'), $result3['subscriber_sex']);
757 <br>
758 <span class=required><?php echo xlt('Subscriber Address'); ?>: </span>
759 <input type=entry class='form-control' size=25 name=i<?php echo attr($i); ?>subscriber_street
760 value="<?php echo attr($result3{"subscriber_street"}); ?>"
761 onchange="capitalizeMe(this);" /><br>
762 <span class=required><?php echo xlt('City'); ?>: </span>
763 <input type=entry class='form-control' size=15 name=i<?php echo attr($i); ?>subscriber_city
764 value="<?php echo attr($result3{"subscriber_city"}); ?>"
765 onchange="capitalizeMe(this);" />
766 <span class=required><?php echo ($GLOBALS['phone_country_code'] == '1') ? xlt('State') : xlt('Locality') ?>: </span>
767 <?php
768 // Modified 7/2009 by BM to incorporate data types
769 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']);
771 <br />
772 <span class=required><?php echo ($GLOBALS['phone_country_code'] == '1') ? xlt('Zip Code') : xlt('Postal Code') ?>: </span>
773 <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"}); ?>">
774 <span class='required'<?php echo ($GLOBALS['omit_employers']) ? " style='display:none'" : ""; ?>>
775 <?php echo xlt('Country'); ?>: </span>
776 <?php
777 // Modified 7/2009 by BM to incorporate data types
778 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']);
780 <br />
781 <span class=bold><?php echo xlt('Subscriber Phone'); ?>:
782 <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)' />
783 </span><br />
784 <span class=bold><?php echo xlt('CoPay'); ?>: <input type=text class='form-control' size="6" name=i<?php echo attr($i); ?>copay value="<?php echo attr($result3{"copay"}); ?>">
785 </span><br />
786 <span class='required'><?php echo xlt('Accept Assignment'); ?>: </span>
787 <select class='form-control' name=i<?php echo attr($i); ?>accept_assignment>
788 <option value="TRUE" <?php echo (strtoupper($result3{"accept_assignment"}) == "TRUE") ? "selected" : ""; ?>><?php echo xlt('YES'); ?></option>
789 <option value="FALSE" <?php echo (strtoupper($result3{"accept_assignment"}) == "FALSE") ? "selected" : ""; ?>><?php echo xlt('NO'); ?></option>
790 </select>
791 </td>
792 </tr>
793 </table>
794 <hr />
795 <?php
798 echo "</div>\n";
799 } // end of "if not simplified_demographics"
802 <?php
803 if ($SHORT_FORM) {
804 echo " </center>\n";
805 } ?>
807 </td>
808 <td align='right' valign='top' width='1%' nowrap>
809 <!-- Image upload stuff was here but got moved. -->
810 </td>
811 </tr>
812 </table>
813 </form>
814 </div>
815 </div>
816 </div> <!--end of container div -->
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 $(function () {
844 $(".medium_modal").on('click', function(e) {
845 e.preventDefault();e.stopPropagation();
846 dlgopen('', '', 650, 460, '', '', {
847 buttons: [
848 {text: <?php echo xlj('Close'); ?>, close: true, style: 'default btn-sm'}
850 //onClosed: 'refreshme',
851 allowResize: false,
852 allowDrag: true,
853 dialogId: '',
854 type: 'iframe',
855 url: $(this).attr('href')
858 // added to integrate insurance stuff
859 <?php for ($i=1; $i<=3; $i++) { ?>
860 $("#form_i<?php echo $i?>subscriber_relationship").change(function() { auto_populate_employer_address<?php echo $i?>(); });
861 <?php } ?>
863 $('#search').click(function() { searchme(); });
864 $('#create').click(function() { check()});
866 var check = function(e) {
867 <?php if ($GLOBALS['new_validate']) {?>
868 var valid = submitme(<?php echo $GLOBALS['new_validate'] ? 1 : 0;?>,e,"DEM",constraints);
869 <?php } else {?>
870 top.restoreSession();
871 var f = document.forms[0];
872 var valid = validate(f);
873 <?php }?>
874 if (valid) {
875 if (force_submit) {
876 // In this case dups were shown already and Save should just save.
877 top.restoreSession();
878 f.submit();
879 return;
882 <?php
883 // D in edit_options indicates the field is used in duplication checking.
884 // This constructs a list of the names of those fields.
885 $mflist = "";
886 $mfres = sqlStatement("SELECT * FROM layout_options " .
887 "WHERE form_id = 'DEM' AND uor > 0 AND field_id != '' AND " .
888 "(edit_options LIKE '%D%' OR edit_options LIKE '%W%' )" .
889 "ORDER BY group_id, seq");
890 while ($mfrow = sqlFetchArray($mfres)) {
891 $field_id = $mfrow['field_id'];
892 if (strpos($field_id, 'em_') === 0) {
893 continue;
896 if (!empty($mflist)) {
897 $mflist .= ",";
900 $mflist .= js_escape($field_id);
903 <?php if (($GLOBALS['full_new_patient_form'] == '4') && (checkIfPatientValidationHookIsActive())) :?>
904 // Use zend module patient validation hook to open the controller and send the dup-checker fields.
905 var url ='<?php echo $GLOBALS['web_root']."/interface/modules/zend_modules/public/patientvalidation"; ?>';
906 <?php else :?>
907 // Build and invoke the URL to create the dup-checker dialog.
908 var url = 'new_search_popup.php';
909 <?php endif;?>
911 var flds = new Array(<?php echo $mflist; ?>);
912 var separator = '?';
913 for (var i = 0; i < flds.length; ++i) {
914 var fval = $('#form_' + flds[i]).val();
915 if (fval && fval != '') {
916 url += separator;
917 separator = '&';
918 url += 'mf_' + flds[i] + '=' + encodeURIComponent(fval);
921 url+="&close"
922 dlgopen(url, '_blank', 700, 500);
923 } // end function
924 } // end function
926 // Set onclick/onfocus handlers for toggling background color.
927 <?php
928 $lres = getLayoutRes();
929 while ($lrow = sqlFetchArray($lres)) {
930 $field_id = $lrow['field_id'];
931 if (strpos($field_id, 'em_') === 0) {
932 continue;
935 switch (getSearchClass($lrow['data_type'])) {
936 case 1:
937 echo " \$(" . js_escape("#form_".$field_id) . ").click(function() { toggleSearch(this); });\n";
938 break;
939 case 2:
940 echo " \$(" . js_escape("#form_".$field_id) . ").click(function() { selClick(this); });\n";
941 echo " \$(" . js_escape("#form_".$field_id) . ").blur(function() { selBlur(this); });\n";
942 break;
947 $('.datepicker').datetimepicker({
948 <?php $datetimepicker_timepicker = false; ?>
949 <?php $datetimepicker_showseconds = false; ?>
950 <?php $datetimepicker_formatInput = true; ?>
951 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
952 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
954 $('.datetimepicker').datetimepicker({
955 <?php $datetimepicker_timepicker = true; ?>
956 <?php $datetimepicker_showseconds = false; ?>
957 <?php $datetimepicker_formatInput = true; ?>
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 ?>
962 }); // end document.ready
964 // callback for new patient save confirm from new_search_popup.php
965 // note that dlgclose() callbacks mostly need to init outside dom.
966 function srcConfirmSave() {
967 document.forms[0].submit();
970 </script>
971 <?php /*Include the validation script and rules for this form*/
972 $form_id="DEM";
975 <?php
976 //LBF forms use the new validation depending on the global value
977 $use_validate_js=$GLOBALS['new_validate'];
978 include_once("$srcdir/validation/validation_script.js.php");?>
979 <script language='JavaScript'>
980 // Array of skip conditions for the checkSkipConditions() function.
981 var skipArray = [
982 <?php echo $condition_str; ?>
984 checkSkipConditions();
985 $("input").change(function() {
986 checkSkipConditions();
988 $("select").change(function() {
989 checkSkipConditions();
991 </script>
993 </html>