Highway to PSR2
[openemr.git] / interface / new / new_comprehensive.php
blob42884c174b69f7d8f5894bb3381522136fac81d1
1 <?php
2 /**
4 * Copyright (C) 2009-2010 Rod Roark <rod@sunsetsystems.com>
5 * Copyright (C) 2017 Brady Miller <brady.g.miller@gmail.com>
7 * LICENSE: This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 3
10 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>.
18 * @package OpenEMR
19 * @author Rod Roark <rod@sunsetsystems.com>
20 * @author Brady Miller <brady.g.miller@gmail.com>
21 * @link http://www.open-emr.org
25 require_once("../globals.php");
26 require_once("$srcdir/acl.inc");
27 require_once("$srcdir/options.inc.php");
28 require_once("$srcdir/patient.inc");
29 require_once("$srcdir/erx_javascript.inc.php");
30 require_once("$srcdir/validation/LBF_Validation.php");
31 require_once("$srcdir/patientvalidation.inc.php");
33 // Check authorization.
34 if (!acl_check('patients', 'demo', '', array('write','addonly'))) {
35 die("Adding demographics is not authorized.");
38 $CPR = 4; // cells per row
40 $searchcolor = empty($GLOBALS['layout_search_color']) ?
41 '#ffff55' : $GLOBALS['layout_search_color'];
43 $WITH_SEARCH = ($GLOBALS['full_new_patient_form'] == '1' || $GLOBALS['full_new_patient_form'] == '2' );
44 $SHORT_FORM = ($GLOBALS['full_new_patient_form'] == '2' || $GLOBALS['full_new_patient_form'] == '3' || $GLOBALS['full_new_patient_form'] == '4');
46 function getLayoutRes()
48 global $SHORT_FORM;
49 return sqlStatement("SELECT * FROM layout_options " .
50 "WHERE form_id = 'DEM' AND uor > 0 AND field_id != '' " .
51 ($SHORT_FORM ? "AND ( uor > 1 OR edit_options LIKE '%N%' ) " : "") .
52 "ORDER BY group_name, seq");
55 // Determine layout field search treatment from its data type:
56 // 1 = text field
57 // 2 = select list
58 // 0 = not searchable
60 function getSearchClass($data_type)
62 switch ($data_type) {
63 case 1: // single-selection list
64 case 10: // local provider list
65 case 11: // provider list
66 case 12: // pharmacy list
67 case 13: // squads
68 case 14: // address book list
69 case 26: // single-selection list with add
70 case 35: // facilities
71 return 2;
72 case 2: // text field
73 case 3: // textarea
74 case 4: // date
75 return 1;
78 return 0;
81 $fres = getLayoutRes();
83 <html>
84 <head>
85 <?php html_header_show(); ?>
87 <link rel="stylesheet" href="<?php echo $css_header; ?>" type="text/css">
88 <link rel="stylesheet" href="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker-2-5-4/build/jquery.datetimepicker.min.css">
89 <link rel="stylesheet" type="text/css" href="../../library/js/fancybox/jquery.fancybox-1.2.6.css" media="screen" />
91 <style>
92 body, td, input, select, textarea {
93 font-family: Arial, Helvetica, sans-serif;
94 font-size: 10pt;
97 body {
98 padding: 5pt 5pt 5pt 5pt;
101 div.section {
102 border: solid;
103 border-width: 1px;
104 border-color: #0000ff;
105 margin: 0 0 0 10pt;
106 padding: 5pt;
109 </style>
111 <script type="text/javascript" src="../../library/dialog.js?v=<?php echo $v_js_includes; ?>"></script>
112 <script type="text/javascript" src="../../library/textformat.js?v=<?php echo $v_js_includes; ?>"></script>
113 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-9-1/index.js"></script>
114 <script type="text/javascript" src="../../library/js/common.js?v=<?php echo $v_js_includes; ?>"></script>
115 <script type="text/javascript" src="../../library/js/fancybox/jquery.fancybox-1.2.6.js"></script>
116 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker-2-5-4/build/jquery.datetimepicker.full.min.js"></script>
118 <?php include_once("{$GLOBALS['srcdir']}/options.js.php"); ?>
120 <SCRIPT LANGUAGE="JavaScript"><!--
121 //Visolve - sync the radio buttons - Start
122 if((top.window.parent) && (parent.window)){
123 var wname = top.window.parent.left_nav;
124 fname = (parent.window.name)?parent.window.name:window.name;
125 wname.syncRadios();
126 }//Visolve - sync the radio buttons - End
128 var mypcc = '<?php echo $GLOBALS['phone_country_code'] ?>';
130 // This may be changed to true by the AJAX search script.
131 var force_submit = false;
133 //code used from http://tech.irt.org/articles/js037/
134 function replace(string,text,by) {
135 // Replaces text with by in string
136 var strLength = string.length, txtLength = text.length;
137 if ((strLength == 0) || (txtLength == 0)) return string;
139 var i = string.indexOf(text);
140 if ((!i) && (text != string.substring(0,txtLength))) return string;
141 if (i == -1) return string;
143 var newstr = string.substring(0,i) + by;
145 if (i+txtLength < strLength)
146 newstr += replace(string.substring(i+txtLength,strLength),text,by);
148 return newstr;
151 <?php for ($i=1; $i<=3; $i++) { ?>
152 function auto_populate_employer_address<?php echo $i ?>(){
153 var f = document.demographics_form;
154 if (f.form_i<?php echo $i?>subscriber_relationship.options[f.form_i<?php echo $i?>subscriber_relationship.selectedIndex].value == "self") {
155 f.i<?php echo $i?>subscriber_fname.value=f.form_fname.value;
156 f.i<?php echo $i?>subscriber_mname.value=f.form_mname.value;
157 f.i<?php echo $i?>subscriber_lname.value=f.form_lname.value;
158 f.i<?php echo $i?>subscriber_street.value=f.form_street.value;
159 f.i<?php echo $i?>subscriber_city.value=f.form_city.value;
160 f.form_i<?php echo $i?>subscriber_state.value=f.form_state.value;
161 f.i<?php echo $i?>subscriber_postal_code.value=f.form_postal_code.value;
162 if (f.form_country_code)
163 f.form_i<?php echo $i?>subscriber_country.value=f.form_country_code.value;
164 f.i<?php echo $i?>subscriber_phone.value=f.form_phone_home.value;
165 f.i<?php echo $i?>subscriber_DOB.value=f.form_DOB.value;
166 f.i<?php echo $i?>subscriber_ss.value=f.form_ss.value;
167 f.form_i<?php echo $i?>subscriber_sex.value = f.form_sex.value;
168 f.i<?php echo $i?>subscriber_employer.value=f.form_em_name.value;
169 f.i<?php echo $i?>subscriber_employer_street.value=f.form_em_street.value;
170 f.i<?php echo $i?>subscriber_employer_city.value=f.form_em_city.value;
171 f.form_i<?php echo $i?>subscriber_employer_state.value=f.form_em_state.value;
172 f.i<?php echo $i?>subscriber_employer_postal_code.value=f.form_em_postal_code.value;
173 if (f.form_em_country)
174 f.form_i<?php echo $i?>subscriber_employer_country.value=f.form_em_country.value;
178 <?php } ?>
180 function upperFirst(string,text) {
181 return replace(string,text,text.charAt(0).toUpperCase() + text.substring(1,text.length));
184 // The ins_search.php window calls this to set the selected insurance.
185 function set_insurance(ins_id, ins_name) {
186 var thesel = document.forms[0]['i' + insurance_index + 'provider'];
187 var theopts = thesel.options; // the array of Option objects
188 var i = 0;
189 for (; i < theopts.length; ++i) {
190 if (theopts[i].value == ins_id) {
191 theopts[i].selected = true;
192 return;
195 // no matching option was found so create one, append it to the
196 // end of the list, and select it.
197 theopts[i] = new Option(ins_name, ins_id, false, true);
200 // Indicates which insurance slot is being updated.
201 var insurance_index = 0;
203 // The OnClick handler for searching/adding the insurance company.
204 function ins_search(ins) {
205 insurance_index = ins;
206 return false;
209 function checkNum () {
210 var re= new RegExp();
211 re = /^\d*\.?\d*$/;
212 str=document.forms[0].monthly_income.value;
213 if(re.exec(str))
215 }else{
216 alert("Please enter a dollar amount using only numbers and a decimal point.");
220 // This capitalizes the first letter of each word in the passed input
221 // element. It also strips out extraneous spaces.
222 function capitalizeMe(elem) {
223 var a = elem.value.split(' ');
224 var s = '';
225 for(var i = 0; i < a.length; ++i) {
226 if (a[i].length > 0) {
227 if (s.length > 0) s += ' ';
228 s += a[i].charAt(0).toUpperCase() + a[i].substring(1);
231 elem.value = s;
234 // Onkeyup handler for policy number. Allows only A-Z and 0-9.
235 function policykeyup(e) {
236 var v = e.value.toUpperCase();
237 var filteredString="";
238 for (var i = 0; i < v.length; ++i) {
239 var c = v.charAt(i);
240 if ((c >= '0' && c <= '9') ||
241 (c >= 'A' && c <= 'Z') ||
242 (c == '*') ||
243 (c == '-') ||
244 (c == '_') ||
245 (c == '(') ||
246 (c == ')') ||
247 (c == '#'))
249 filteredString+=c;
252 e.value = filteredString;
253 return;
256 function divclick(cb, divid) {
257 var divstyle = document.getElementById(divid).style;
258 if (cb.checked) {
259 divstyle.display = 'block';
260 } else {
261 divstyle.display = 'none';
263 return true;
266 // Compute the length of a string without leading and trailing spaces.
267 function trimlen(s) {
268 var i = 0;
269 var j = s.length - 1;
270 for (; i <= j && s.charAt(i) == ' '; ++i);
271 for (; i <= j && s.charAt(j) == ' '; --j);
272 if (i > j) return 0;
273 return j + 1 - i;
276 function validate(f) {
277 var errMsgs = new Array();
278 <?php generate_layout_validation('DEM'); ?>
279 <?php if ($GLOBALS['erx_enable']) { ?>
280 alertMsg='';
281 for(i=0;i<f.length;i++){
282 if(f[i].type=='text' && f[i].value)
284 if(f[i].name == 'form_fname' || f[i].name == 'form_mname' || f[i].name == 'form_lname')
286 alertMsg += checkLength(f[i].name,f[i].value,35);
287 alertMsg += checkUsername(f[i].name,f[i].value);
289 else if(f[i].name == 'form_street' || f[i].name == 'form_city')
291 alertMsg += checkLength(f[i].name,f[i].value,35);
292 alertMsg += checkAlphaNumericExtended(f[i].name,f[i].value);
294 else if(f[i].name == 'form_phone_home')
296 alertMsg += checkPhone(f[i].name,f[i].value);
300 if(alertMsg)
302 alert(alertMsg);
303 return false;
305 <?php } ?>
306 var msg = "";
307 msg += "<?php echo htmlspecialchars(xl('The following fields are required'), ENT_QUOTES); ?>:\n\n";
308 for ( var i = 0; i < errMsgs.length; i++ ) {
309 msg += errMsgs[i] + "\n";
311 msg += "\n<?php echo htmlspecialchars(xl('Please fill them in before continuing.'), ENT_QUOTES); ?>";
314 //Misc Deceased Date Validation for Future Date
315 var dateVal = document.getElementById("form_deceased_date").value;
316 var currentDate;
317 var d = new Date();
318 month = '' + (d.getMonth() + 1),
319 day = '' + d.getDate(),
320 year = d.getFullYear();
321 if (month.length < 2) month = '0' + month;
322 if (day.length < 2) day = '0' + day;
323 currentDate = year+'-'+month+'-'+day;
324 if(errMsgs.length > 0 || dateVal > currentDate)
326 if(errMsgs.length > 0)
327 alert(msg);
328 if(dateVal > currentDate)
329 alert ('<?php echo xls("Deceased Date should not be greater than Today"); ?>');
330 return false;
332 return true;
335 function toggleSearch(elem) {
336 var f = document.forms[0];
337 <?php if ($WITH_SEARCH) { ?>
338 // Toggle background color.
339 if (elem.style.backgroundColor == '')
340 elem.style.backgroundColor = '<?php echo $searchcolor; ?>';
341 else
342 elem.style.backgroundColor = '';
343 <?php } ?>
344 if (force_submit) {
345 force_submit = false;
346 f.create.value = '<?php xl('Create New Patient', 'e'); ?>';
348 return true;
351 // If a <select> list is dropped down, this is its name.
352 var open_sel_name = '';
354 function selClick(elem) {
355 if (open_sel_name == elem.name) {
356 open_sel_name = '';
358 else {
359 open_sel_name = elem.name;
360 toggleSearch(elem);
362 return true;
365 function selBlur(elem) {
366 if (open_sel_name == elem.name) {
367 open_sel_name = '';
369 return true;
372 // This invokes the patient search dialog.
373 function searchme() {
374 var f = document.forms[0];
375 var url = '../main/finder/patient_select.php?popup=1';
377 <?php
378 $lres = getLayoutRes();
380 while ($lrow = sqlFetchArray($lres)) {
381 $field_id = $lrow['field_id'];
382 if (strpos($field_id, 'em_') === 0) {
383 continue;
386 $data_type = $lrow['data_type'];
387 $fldname = "form_$field_id";
388 switch (getSearchClass($data_type)) {
389 case 1:
390 echo
391 " if (f.$fldname.style.backgroundColor != '' && trimlen(f.$fldname.value) > 0) {\n" .
392 " url += '&$field_id=' + encodeURIComponent(f.$fldname.value);\n" .
393 " }\n";
394 break;
395 case 2:
396 echo
397 " if (f.$fldname.style.backgroundColor != '' && f.$fldname.selectedIndex > 0) {\n" .
398 " url += '&$field_id=' + encodeURIComponent(f.$fldname.options[f.$fldname.selectedIndex].value);\n" .
399 " }\n";
400 break;
405 dlgopen(url, '_blank', 700, 500);
408 //-->
410 </script>
411 </head>
413 <body class="body_top">
415 <?php
416 /*Get the constraint from the DB-> LBF forms accordinf the form_id*/
417 $constraints = LBF_Validation::generate_validate_constraints("DEM");
419 <script> var constraints = <?php echo $constraints;?>; </script>
421 <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)'>
423 <span class='title'><?php xl('Search or Add Patient', 'e'); ?></span>
425 <table width='100%' cellpadding='0' cellspacing='8'>
426 <tr>
427 <td align='left' valign='top'>
428 <?php if ($SHORT_FORM) {
429 echo " <center>\n";
430 } ?>
431 <?php
433 function end_cell()
435 global $item_count, $cell_count;
436 if ($item_count > 0) {
437 echo "</td>";
438 $item_count = 0;
442 function end_row()
444 global $cell_count, $CPR;
445 end_cell();
446 if ($cell_count > 0) {
447 for (; $cell_count < $CPR;
448 ++$cell_count) {
449 echo "<td></td>";
452 echo "</tr>\n";
453 $cell_count = 0;
457 function end_group()
459 global $last_group, $SHORT_FORM;
460 if (strlen($last_group) > 0) {
461 end_row();
462 echo " </table>\n";
463 if (!$SHORT_FORM) {
464 echo "</div>\n";
469 $last_group = '';
470 $cell_count = 0;
471 $item_count = 0;
472 $display_style = 'block';
473 $group_seq = 0; // this gives the DIV blocks unique IDs
475 while ($frow = sqlFetchArray($fres)) {
476 $this_group = $frow['group_name'];
477 $titlecols = $frow['titlecols'];
478 $datacols = $frow['datacols'];
479 $data_type = $frow['data_type'];
480 $field_id = $frow['field_id'];
481 $list_id = $frow['list_id'];
482 $currvalue = '';
483 $condition_str = get_conditions_str($condition_str, $group_fields);
485 if (strpos($field_id, 'em_') === 0) {
486 $tmp = substr($field_id, 3);
487 if (isset($result2[$tmp])) {
488 $currvalue = $result2[$tmp];
490 } else {
491 if (isset($result[$field_id])) {
492 $currvalue = $result[$field_id];
496 // Handle a data category (group) change.
497 if (strcmp($this_group, $last_group) != 0) {
498 if (!$SHORT_FORM) {
499 end_group();
500 $group_seq++; // ID for DIV tags
501 $group_name = substr($this_group, 1);
502 if (strlen($last_group) > 0) {
503 echo "<br />";
506 echo "<span class='bold'><input type='checkbox' name='form_cb_$group_seq' id='form_cb_$group_seq' value='1' " .
507 "onclick='return divclick(this,\"div_$group_seq\");'";
508 if ($display_style == 'block') {
509 echo " checked";
512 // Modified 6-09 by BM - Translate if applicable
513 echo " /><b>" . xl_layout_label($group_name) . "</b></span>\n";
515 echo "<div id='div_$group_seq' class='section' style='display:$display_style;'>\n";
516 echo " <table border='0' cellpadding='0'>\n";
517 $display_style = 'none';
518 } else if (strlen($last_group) == 0) {
519 echo " <table border='0' cellpadding='0'>\n";
522 $last_group = $this_group;
525 // Handle starting of a new row.
526 if (($titlecols > 0 && $cell_count >= $CPR) || $cell_count == 0) {
527 end_row();
528 echo " <tr>";
531 if ($item_count == 0 && $titlecols == 0) {
532 $titlecols = 1;
535 $field_id_label='label_'.$frow['field_id'];
536 // Handle starting of a new label cell.
537 if ($titlecols > 0) {
538 end_cell();
539 echo "<td colspan='$titlecols' id='$field_id_label'";
540 echo ($frow['uor'] == 2) ? " class='required'" : " class='bold'";
541 if ($cell_count == 2) {
542 echo " style='padding-left:10pt'";
545 echo ">";
546 $cell_count += $titlecols;
549 ++$item_count;
551 echo "<b>";
553 // Modified 6-09 by BM - Translate if applicable
554 if ($frow['title']) {
555 echo (xl_layout_label($frow['title']).":");
556 } else {
557 echo "&nbsp;";
560 echo "</b>";
562 // Handle starting of a new data cell.
563 if ($datacols > 0) {
564 $id_field_text = "text_".$frow['field_id'];
565 end_cell();
566 echo "<td colspan='$datacols' class='text data'";
567 if ($cell_count > 0) {
568 echo " style='padding-left:5pt'". " id='".$id_field_text."'";
571 echo ">";
572 $cell_count += $datacols;
575 ++$item_count;
576 generate_form_field($frow, $currvalue);
579 end_group();
582 <?php
583 if (! $GLOBALS['simplified_demographics']) {
584 $insurancei = getInsuranceProviders();
585 $pid = 0;
586 $insurance_headings = array(xl("Primary Insurance Provider"), xl("Secondary Insurance Provider"), xl("Tertiary Insurance provider"));
587 $insurance_info = array();
588 $insurance_info[1] = getInsuranceData($pid, "primary");
589 $insurance_info[2] = getInsuranceData($pid, "secondary");
590 $insurance_info[3] = getInsuranceData($pid, "tertiary");
592 echo "<br /><span class='bold'><input type='checkbox' name='form_cb_ins' value='1' " .
593 "onclick='return divclick(this,\"div_ins\");'";
594 if ($display_style == 'block') {
595 echo " checked";
598 echo " /><b>" . xl('Insurance') . "</b></span>\n";
599 echo "<div id='div_ins' class='section' style='display:$display_style;'>\n";
601 for ($i=1; $i<=3; $i++) {
602 $result3 = $insurance_info[$i];
604 <table border="0">
605 <tr>
606 <td valign='top' colspan='2'>
607 <span class='required'><?php echo $insurance_headings[$i -1].":"?></span>
608 <select name="i<?php echo $i?>provider">
609 <option value=""><?php xl('Unassigned', 'e'); ?></option>
610 <?php
611 foreach ($insurancei as $iid => $iname) {
612 echo "<option value='" . $iid . "'";
613 if (strtolower($iid) == strtolower($result3{"provider"})) {
614 echo " selected";
617 echo ">" . $iname . "</option>\n";
620 </select>&nbsp;<a class='iframe medium_modal' href='../practice/ins_search.php' onclick='ins_search(<?php echo $i?>)'>
621 <span> <?php xl('Search/Add Insurer', 'e'); ?></span></a>
622 </td>
623 </tr>
624 <tr>
625 <td valign=top>
626 <table border="0">
628 <tr>
629 <td>
630 <span class='required'><?php xl('Plan Name', 'e'); ?>: </span>
631 </td>
632 <td>
633 <input type='entry' size='20' name='i<?php echo $i?>plan_name' value="<?php echo $result3{"plan_name"} ?>"
634 onchange="capitalizeMe(this);" />&nbsp;&nbsp;
635 </td>
636 </tr>
638 <tr>
639 <td>
640 <span class='required'><?php xl('Effective Date', 'e'); ?>: </span>
641 </td>
642 <td>
643 <input type='entry' size='11' class='datepicker' name='i<?php echo $i ?>effective_date'
644 id='i<?php echo $i ?>effective_date'
645 value='<?php echo $result3['date'] ?>'
646 title='yyyy-mm-dd' />
647 </td>
648 </tr>
650 <tr>
651 <td><span class=required><?php xl('Policy Number', 'e'); ?>: </span></td>
652 <td><input type='entry' size='16' name='i<?php echo $i?>policy_number' value="<?php echo $result3{"policy_number"}?>"
653 onkeyup='policykeyup(this)'></td>
654 </tr>
656 <tr>
657 <td><span class=required><?php xl('Group Number', 'e'); ?>: </span></td><td><input type=entry size=16 name=i<?php echo $i?>group_number value="<?php echo $result3{"group_number"}?>" onkeyup='policykeyup(this)'></td>
658 </tr>
660 <tr<?php if ($GLOBALS['omit_employers']) {
661 echo " style='display:none'";
662 } ?>>
663 <td class='required'><?php xl('Subscriber Employer (SE)', 'e'); ?><br><span style='font-weight:normal'>
664 (<?php xl('if unemployed enter Student', 'e'); ?>,<br><?php xl('PT Student, or leave blank', 'e'); ?>): </span></td>
665 <td><input type=entry size=25 name=i<?php echo $i?>subscriber_employer
666 value="<?php echo $result3{"subscriber_employer"}?>"
667 onchange="capitalizeMe(this);" /></td>
668 </tr>
670 <tr<?php if ($GLOBALS['omit_employers']) {
671 echo " style='display:none'";
672 } ?>>
673 <td><span class=required><?php xl('SE Address', 'e'); ?>: </span></td>
674 <td><input type=entry size=25 name=i<?php echo $i?>subscriber_employer_street
675 value="<?php echo $result3{"subscriber_employer_street"}?>"
676 onchange="capitalizeMe(this);" /></td>
677 </tr>
679 <tr<?php if ($GLOBALS['omit_employers']) {
680 echo " style='display:none'";
681 } ?>>
682 <td colspan="2">
683 <table>
684 <tr>
685 <td><span class=required><?php xl('SE City', 'e'); ?>: </span></td>
686 <td><input type=entry size=15 name=i<?php echo $i?>subscriber_employer_city
687 value="<?php echo $result3{"subscriber_employer_city"}?>"
688 onchange="capitalizeMe(this);" /></td>
689 <td><span class=required><?php echo ($GLOBALS['phone_country_code'] == '1') ? xl('SE State', 'e') : xl('SE Locality', 'e') ?>: </span></td>
690 <td>
691 <?php
692 // Modified 7/2009 by BM to incorporate data types
693 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']);
695 </td>
696 </tr>
697 <tr>
698 <td><span class=required><?php echo ($GLOBALS['phone_country_code'] == '1') ? xl('SE Zip Code', 'e') : xl('SE Postal Code', 'e') ?>: </span></td>
699 <td><input type=entry size=10 name=i<?php echo $i?>subscriber_employer_postal_code value="<?php echo $result3{"subscriber_employer_postal_code"}?>"></td>
700 <td><span class=required><?php xl('SE Country', 'e'); ?>: </span></td>
701 <td>
702 <?php
703 // Modified 7/2009 by BM to incorporate data types
704 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']);
706 </td>
707 </tr>
708 </table>
709 </td>
710 </tr>
712 </table>
713 </td>
715 <td valign=top>
716 <span class=required><?php xl('Subscriber', 'e'); ?>: </span>
717 <input type=entry size=10 name=i<?php echo $i?>subscriber_fname
718 value="<?php echo $result3{"subscriber_fname"}?>"
719 onchange="capitalizeMe(this);" />
720 <input type=entry size=3 name=i<?php echo $i?>subscriber_mname
721 value="<?php echo $result3{"subscriber_mname"}?>"
722 onchange="capitalizeMe(this);" />
723 <input type=entry size=10 name=i<?php echo $i?>subscriber_lname
724 value="<?php echo $result3{"subscriber_lname"}?>"
725 onchange="capitalizeMe(this);" />
726 <br>
727 <span class=required><?php xl('Relationship', 'e'); ?>: </span>
728 <?php
729 // Modified 6/2009 by BM to use list_options and function
730 generate_form_field(array('data_type'=>1,'field_id'=>('i'.$i.'subscriber_relationship'),'list_id'=>'sub_relation','empty_title'=>' '), $result3['subscriber_relationship']);
732 <a href="javascript:popUp('../../interface/patient_file/summary/browse.php?browsenum=<?php echo $i?>')" class=text>(<?php xl('Browse', 'e'); ?>)</a><br />
734 <span class=bold><?php xl('D.O.B.', 'e'); ?>: </span>
735 <input type='entry' size='11' class='datepicker' name='i<?php echo $i?>subscriber_DOB'
736 id='i<?php echo $i?>subscriber_DOB'
737 value='<?php echo $result3['subscriber_DOB'] ?>'
738 title='yyyy-mm-dd' />
740 <span class=bold><?php xl('S.S.', 'e'); ?>: </span><input type=entry size=11 name=i<?php echo $i?>subscriber_ss value="<?php echo $result3{"subscriber_ss"}?>">&nbsp;
741 <span class=bold><?php xl('Sex', 'e'); ?>: </span>
742 <?php
743 // Modified 6/2009 by BM to use list_options and function
744 generate_form_field(array('data_type'=>1,'field_id'=>('i'.$i.'subscriber_sex'),'list_id'=>'sex'), $result3['subscriber_sex']);
746 <br>
747 <span class=required><?php xl('Subscriber Address', 'e'); ?>: </span>
748 <input type=entry size=25 name=i<?php echo $i?>subscriber_street
749 value="<?php echo $result3{"subscriber_street"}?>"
750 onchange="capitalizeMe(this);" /><br>
751 <span class=required><?php xl('City', 'e'); ?>: </span>
752 <input type=entry size=15 name=i<?php echo $i?>subscriber_city
753 value="<?php echo $result3{"subscriber_city"}?>"
754 onchange="capitalizeMe(this);" />
755 <span class=required><?php echo ($GLOBALS['phone_country_code'] == '1') ? xl('State', 'e') : xl('Locality', 'e') ?>: </span>
756 <?php
757 // Modified 7/2009 by BM to incorporate data types
758 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']);
760 <br />
761 <span class=required><?php echo ($GLOBALS['phone_country_code'] == '1') ? xl('Zip Code', 'e') : xl('Postal Code', 'e') ?>: </span><input type=entry size=10 name=i<?php echo $i?>subscriber_postal_code value="<?php echo $result3{"subscriber_postal_code"}?>">
762 <span class='required'<?php if ($GLOBALS['omit_employers']) {
763 echo " style='display:none'";
764 } ?>>
765 <?php xl('Country', 'e'); ?>: </span>
766 <?php
767 // Modified 7/2009 by BM to incorporate data types
768 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']);
770 <br />
771 <span class=bold><?php xl('Subscriber Phone', 'e'); ?>:
772 <input type='text' size='20' name='i<?php echo $i?>subscriber_phone' value='<?php echo $result3["subscriber_phone"] ?>' onkeyup='phonekeyup(this,mypcc)' />
773 </span><br />
774 <span class=bold><?php xl('CoPay', 'e'); ?>: <input type=text size="6" name=i<?php echo $i?>copay value="<?php echo $result3{"copay"}?>">
775 </span><br />
776 <span class='required'><?php xl('Accept Assignment', 'e'); ?>: </span>
777 <select name=i<?php echo $i?>accept_assignment>
778 <option value="TRUE" <?php if (strtoupper($result3{"accept_assignment"}) == "TRUE") {
779 echo "selected";
780 }?>><?php xl('YES', 'e'); ?></option>
781 <option value="FALSE" <?php if (strtoupper($result3{"accept_assignment"}) == "FALSE") {
782 echo "selected";
783 }?>><?php xl('NO', 'e'); ?></option>
784 </select>
785 </td>
786 </tr>
788 </table>
789 <hr />
790 <?php
793 echo "</div>\n";
794 } // end of "if not simplified_demographics"
797 <?php if (!$SHORT_FORM) {
798 echo " <center>\n";
799 } ?>
800 <br />
801 <?php if ($WITH_SEARCH) { ?>
802 <input type="button" id="search" value=<?php xl('Search', 'e', '\'', '\''); ?>
803 style='background-color:<?php echo $searchcolor; ?>' />
804 &nbsp;&nbsp;
805 <?php } ?>
806 <input type="button" name='create' id="create" value=<?php xl('Create New Patient', 'e', '\'', '\''); ?> />
808 </center>
810 </td>
811 <td align='right' valign='top' width='1%' nowrap>
812 <!-- Image upload stuff was here but got moved. -->
813 </td>
814 </tr>
815 </table>
817 </form>
819 <!-- include support for the list-add selectbox feature -->
820 <?php include($GLOBALS['fileroot']."/library/options_listadd.inc"); ?>
822 </body>
824 <script language="JavaScript">
826 // hard code validation for old validation, in the new validation possible to add match rules
827 <?php if ($GLOBALS['new_validate'] == 0) { ?>
829 // fix inconsistently formatted phone numbers from the database
830 var f = document.forms[0];
831 if (f.form_phone_contact) phonekeyup(f.form_phone_contact,mypcc);
832 if (f.form_phone_home ) phonekeyup(f.form_phone_home ,mypcc);
833 if (f.form_phone_biz ) phonekeyup(f.form_phone_biz ,mypcc);
834 if (f.form_phone_cell ) phonekeyup(f.form_phone_cell ,mypcc);
836 <?php }?>
838 <?php echo $date_init; ?>
840 // -=- jQuery makes life easier -=-
842 // var matches = 0; // number of patients that match the demographic information being entered
843 // var override = false; // flag that overrides the duplication warning
845 $(document).ready(function() {
846 enable_modals();
847 $(".medium_modal").fancybox( {
848 'overlayOpacity' : 0.0,
849 'showCloseButton' : true,
850 'frameHeight' : 460,
851 'frameWidth' : 650
853 // added to integrate insurance stuff
854 <?php for ($i=1; $i<=3; $i++) { ?>
855 $("#form_i<?php echo $i?>subscriber_relationship").change(function() { auto_populate_employer_address<?php echo $i?>(); });
856 <?php } ?>
858 $('#search').click(function() { searchme(); });
859 $('#create').click(function() { check()});
861 var check = function(e) {
862 <?php if ($GLOBALS['new_validate']) {?>
863 var valid = submitme(<?php echo $GLOBALS['new_validate'] ? 1 : 0;?>,e,"DEM",constraints);
864 <?php } else {?>
865 top.restoreSession();
866 var f = document.forms[0];
867 var valid = validate(f);
868 <?php }?>
869 if (valid) {
870 if (force_submit) {
871 // In this case dups were shown already and Save should just save.
872 top.restoreSession();
873 f.submit();
874 return;
877 <?php
878 // D in edit_options indicates the field is used in duplication checking.
879 // This constructs a list of the names of those fields.
880 $mflist = "";
881 $mfres = sqlStatement("SELECT * FROM layout_options " .
882 "WHERE form_id = 'DEM' AND uor > 0 AND field_id != '' AND " .
883 "(edit_options LIKE '%D%' OR edit_options LIKE '%W%' )" .
884 "ORDER BY group_name, seq");
885 while ($mfrow = sqlFetchArray($mfres)) {
886 $field_id = $mfrow['field_id'];
887 if (strpos($field_id, 'em_') === 0) {
888 continue;
891 if (!empty($mflist)) {
892 $mflist .= ",";
895 $mflist .= "'" . htmlentities($field_id) . "'";
898 <?php if (($GLOBALS['full_new_patient_form'] == '4') && (checkIfPatientValidationHookIsActive())) :?>
899 // Use zend module patient validation hook to open the controller and send the dup-checker fields.
900 var url ='<?php echo $GLOBALS['web_root']."/interface/modules/zend_modules/public/patientvalidation";?>';
901 <?php else :?>
902 // Build and invoke the URL to create the dup-checker dialog.
903 var url = 'new_search_popup.php';
904 <?php endif;?>
906 var flds = new Array(<?php echo $mflist; ?>);
907 var separator = '?';
908 for (var i = 0; i < flds.length; ++i) {
909 var fval = $('#form_' + flds[i]).val();
910 if (fval && fval != '') {
911 url += separator;
912 separator = '&';
913 url += 'mf_' + flds[i] + '=' + encodeURIComponent(fval);
916 url+="&close"
917 dlgopen(url, '_blank', 700, 500);
918 } // end function
919 } // end function
922 // Set onclick/onfocus handlers for toggling background color.
923 <?php
924 $lres = getLayoutRes();
925 while ($lrow = sqlFetchArray($lres)) {
926 $field_id = $lrow['field_id'];
927 if (strpos($field_id, 'em_') === 0) {
928 continue;
931 switch (getSearchClass($lrow['data_type'])) {
932 case 1:
933 echo " \$('#form_$field_id').click(function() { toggleSearch(this); });\n";
934 break;
935 case 2:
936 echo " \$('#form_$field_id').click(function() { selClick(this); });\n";
937 echo " \$('#form_$field_id').blur(function() { selBlur(this); });\n";
938 break;
943 $('.datepicker').datetimepicker({
944 <?php $datetimepicker_timepicker = false; ?>
945 <?php $datetimepicker_showseconds = false; ?>
946 <?php $datetimepicker_formatInput = false; ?>
947 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
948 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
950 $('.datetimepicker').datetimepicker({
951 <?php $datetimepicker_timepicker = true; ?>
952 <?php $datetimepicker_showseconds = false; ?>
953 <?php $datetimepicker_formatInput = false; ?>
954 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
955 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
958 }); // end document.ready
960 </script>
961 <?php /*Include the validation script and rules for this form*/
962 $form_id="DEM";
965 <?php
966 //LBF forms use the new validation depending on the global value
967 $use_validate_js=$GLOBALS['new_validate'];
968 include_once("$srcdir/validation/validation_script.js.php");?>
969 <script language='JavaScript'>
970 // Array of skip conditions for the checkSkipConditions() function.
971 var skipArray = [
972 <?php echo $condition_str; ?>
974 checkSkipConditions();
975 $("input").change(function() {
976 checkSkipConditions();
978 $("select").change(function() {
979 checkSkipConditions();
981 </script>
983 </html>