several more top.restoreSession fixes
[openemr.git] / interface / new / new_comprehensive.php
blob8ef250132629e0c5892f21a727bb3e62b7ff40e5
1 <?php
2 // Copyright (C) 2009-2010 Rod Roark <rod@sunsetsystems.com>
3 //
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
9 require_once("../globals.php");
10 require_once("$srcdir/acl.inc");
11 require_once("$srcdir/options.inc.php");
12 require_once("$srcdir/patient.inc");
13 require_once("$srcdir/erx_javascript.inc.php");
14 require_once("$srcdir/validation/LBF_Validation.php");
15 require_once ("$srcdir/patientvalidation.inc.php");
17 // Check authorization.
18 if (!acl_check('patients','demo','',array('write','addonly') ))
19 die("Adding demographics is not authorized.");
21 $CPR = 4; // cells per row
23 $searchcolor = empty($GLOBALS['layout_search_color']) ?
24 '#ffff55' : $GLOBALS['layout_search_color'];
26 $WITH_SEARCH = ($GLOBALS['full_new_patient_form'] == '1' || $GLOBALS['full_new_patient_form'] == '2' );
27 $SHORT_FORM = ($GLOBALS['full_new_patient_form'] == '2' || $GLOBALS['full_new_patient_form'] == '3' || $GLOBALS['full_new_patient_form'] == '4');
29 function getLayoutRes() {
30 global $SHORT_FORM;
31 return sqlStatement("SELECT * FROM layout_options " .
32 "WHERE form_id = 'DEM' AND uor > 0 AND field_id != '' " .
33 ($SHORT_FORM ? "AND ( uor > 1 OR edit_options LIKE '%N%' ) " : "") .
34 "ORDER BY group_name, seq");
37 // Determine layout field search treatment from its data type:
38 // 1 = text field
39 // 2 = select list
40 // 0 = not searchable
42 function getSearchClass($data_type) {
43 switch($data_type) {
44 case 1: // single-selection list
45 case 10: // local provider list
46 case 11: // provider list
47 case 12: // pharmacy list
48 case 13: // squads
49 case 14: // address book list
50 case 26: // single-selection list with add
51 case 35: // facilities
52 return 2;
53 case 2: // text field
54 case 3: // textarea
55 case 4: // date
56 return 1;
58 return 0;
61 $fres = getLayoutRes();
63 <html>
64 <head>
65 <?php html_header_show(); ?>
67 <link rel="stylesheet" href="<?php echo $css_header; ?>" type="text/css">
69 <style>
70 body, td, input, select, textarea {
71 font-family: Arial, Helvetica, sans-serif;
72 font-size: 10pt;
75 body {
76 padding: 5pt 5pt 5pt 5pt;
79 div.section {
80 border: solid;
81 border-width: 1px;
82 border-color: #0000ff;
83 margin: 0 0 0 10pt;
84 padding: 5pt;
87 </style>
89 <style type="text/css">@import url(../../library/dynarch_calendar.css);</style>
91 <script type="text/javascript" src="../../library/dialog.js?v=<?php echo $v_js_includes; ?>"></script>
92 <script type="text/javascript" src="../../library/textformat.js"></script>
93 <script type="text/javascript" src="../../library/dynarch_calendar.js"></script>
94 <?php include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?>
95 <script type="text/javascript" src="../../library/dynarch_calendar_setup.js"></script>
96 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-9-1/index.js"></script>
97 <script type="text/javascript" src="../../library/js/common.js"></script>
98 <script type="text/javascript" src="../../library/js/fancybox/jquery.fancybox-1.2.6.js"></script>
99 <?php include_once("{$GLOBALS['srcdir']}/options.js.php"); ?>
100 <link rel="stylesheet" type="text/css" href="../../library/js/fancybox/jquery.fancybox-1.2.6.css" media="screen" />
102 <SCRIPT LANGUAGE="JavaScript"><!--
103 //Visolve - sync the radio buttons - Start
104 if((top.window.parent) && (parent.window)){
105 var wname = top.window.parent.left_nav;
106 fname = (parent.window.name)?parent.window.name:window.name;
107 wname.syncRadios();
108 }//Visolve - sync the radio buttons - End
110 var mypcc = '<?php echo $GLOBALS['phone_country_code'] ?>';
112 // This may be changed to true by the AJAX search script.
113 var force_submit = false;
115 //code used from http://tech.irt.org/articles/js037/
116 function replace(string,text,by) {
117 // Replaces text with by in string
118 var strLength = string.length, txtLength = text.length;
119 if ((strLength == 0) || (txtLength == 0)) return string;
121 var i = string.indexOf(text);
122 if ((!i) && (text != string.substring(0,txtLength))) return string;
123 if (i == -1) return string;
125 var newstr = string.substring(0,i) + by;
127 if (i+txtLength < strLength)
128 newstr += replace(string.substring(i+txtLength,strLength),text,by);
130 return newstr;
133 <?php for ($i=1;$i<=3;$i++) { ?>
134 function auto_populate_employer_address<?php echo $i ?>(){
135 var f = document.demographics_form;
136 if (f.form_i<?php echo $i?>subscriber_relationship.options[f.form_i<?php echo $i?>subscriber_relationship.selectedIndex].value == "self") {
137 f.i<?php echo $i?>subscriber_fname.value=f.form_fname.value;
138 f.i<?php echo $i?>subscriber_mname.value=f.form_mname.value;
139 f.i<?php echo $i?>subscriber_lname.value=f.form_lname.value;
140 f.i<?php echo $i?>subscriber_street.value=f.form_street.value;
141 f.i<?php echo $i?>subscriber_city.value=f.form_city.value;
142 f.form_i<?php echo $i?>subscriber_state.value=f.form_state.value;
143 f.i<?php echo $i?>subscriber_postal_code.value=f.form_postal_code.value;
144 if (f.form_country_code)
145 f.form_i<?php echo $i?>subscriber_country.value=f.form_country_code.value;
146 f.i<?php echo $i?>subscriber_phone.value=f.form_phone_home.value;
147 f.i<?php echo $i?>subscriber_DOB.value=f.form_DOB.value;
148 f.i<?php echo $i?>subscriber_ss.value=f.form_ss.value;
149 f.form_i<?php echo $i?>subscriber_sex.value = f.form_sex.value;
150 f.i<?php echo $i?>subscriber_employer.value=f.form_em_name.value;
151 f.i<?php echo $i?>subscriber_employer_street.value=f.form_em_street.value;
152 f.i<?php echo $i?>subscriber_employer_city.value=f.form_em_city.value;
153 f.form_i<?php echo $i?>subscriber_employer_state.value=f.form_em_state.value;
154 f.i<?php echo $i?>subscriber_employer_postal_code.value=f.form_em_postal_code.value;
155 if (f.form_em_country)
156 f.form_i<?php echo $i?>subscriber_employer_country.value=f.form_em_country.value;
160 <?php } ?>
162 function upperFirst(string,text) {
163 return replace(string,text,text.charAt(0).toUpperCase() + text.substring(1,text.length));
166 // The ins_search.php window calls this to set the selected insurance.
167 function set_insurance(ins_id, ins_name) {
168 var thesel = document.forms[0]['i' + insurance_index + 'provider'];
169 var theopts = thesel.options; // the array of Option objects
170 var i = 0;
171 for (; i < theopts.length; ++i) {
172 if (theopts[i].value == ins_id) {
173 theopts[i].selected = true;
174 return;
177 // no matching option was found so create one, append it to the
178 // end of the list, and select it.
179 theopts[i] = new Option(ins_name, ins_id, false, true);
182 // Indicates which insurance slot is being updated.
183 var insurance_index = 0;
185 // The OnClick handler for searching/adding the insurance company.
186 function ins_search(ins) {
187 insurance_index = ins;
188 return false;
191 function checkNum () {
192 var re= new RegExp();
193 re = /^\d*\.?\d*$/;
194 str=document.forms[0].monthly_income.value;
195 if(re.exec(str))
197 }else{
198 alert("Please enter a dollar amount using only numbers and a decimal point.");
202 // This capitalizes the first letter of each word in the passed input
203 // element. It also strips out extraneous spaces.
204 function capitalizeMe(elem) {
205 var a = elem.value.split(' ');
206 var s = '';
207 for(var i = 0; i < a.length; ++i) {
208 if (a[i].length > 0) {
209 if (s.length > 0) s += ' ';
210 s += a[i].charAt(0).toUpperCase() + a[i].substring(1);
213 elem.value = s;
216 // Onkeyup handler for policy number. Allows only A-Z and 0-9.
217 function policykeyup(e) {
218 var v = e.value.toUpperCase();
219 var filteredString="";
220 for (var i = 0; i < v.length; ++i) {
221 var c = v.charAt(i);
222 if ((c >= '0' && c <= '9') ||
223 (c >= 'A' && c <= 'Z') ||
224 (c == '*') ||
225 (c == '-') ||
226 (c == '_') ||
227 (c == '(') ||
228 (c == ')') ||
229 (c == '#'))
231 filteredString+=c;
234 e.value = filteredString;
235 return;
238 function divclick(cb, divid) {
239 var divstyle = document.getElementById(divid).style;
240 if (cb.checked) {
241 divstyle.display = 'block';
242 } else {
243 divstyle.display = 'none';
245 return true;
248 // Compute the length of a string without leading and trailing spaces.
249 function trimlen(s) {
250 var i = 0;
251 var j = s.length - 1;
252 for (; i <= j && s.charAt(i) == ' '; ++i);
253 for (; i <= j && s.charAt(j) == ' '; --j);
254 if (i > j) return 0;
255 return j + 1 - i;
258 function validate(f) {
259 var errMsgs = new Array();
260 <?php generate_layout_validation('DEM'); ?>
261 <?php if($GLOBALS['erx_enable']){ ?>
262 alertMsg='';
263 for(i=0;i<f.length;i++){
264 if(f[i].type=='text' && f[i].value)
266 if(f[i].name == 'form_fname' || f[i].name == 'form_mname' || f[i].name == 'form_lname')
268 alertMsg += checkLength(f[i].name,f[i].value,35);
269 alertMsg += checkUsername(f[i].name,f[i].value);
271 else if(f[i].name == 'form_street' || f[i].name == 'form_city')
273 alertMsg += checkLength(f[i].name,f[i].value,35);
274 alertMsg += checkAlphaNumericExtended(f[i].name,f[i].value);
276 else if(f[i].name == 'form_phone_home')
278 alertMsg += checkPhone(f[i].name,f[i].value);
282 if(alertMsg)
284 alert(alertMsg);
285 return false;
287 <?php } ?>
288 var msg = "";
289 msg += "<?php echo htmlspecialchars(xl('The following fields are required'),ENT_QUOTES); ?>:\n\n";
290 for ( var i = 0; i < errMsgs.length; i++ ) {
291 msg += errMsgs[i] + "\n";
293 msg += "\n<?php echo htmlspecialchars(xl('Please fill them in before continuing.'),ENT_QUOTES); ?>";
296 //Misc Deceased Date Validation for Future Date
297 var dateVal = document.getElementById("form_deceased_date").value;
298 var currentDate;
299 var d = new Date();
300 month = '' + (d.getMonth() + 1),
301 day = '' + d.getDate(),
302 year = d.getFullYear();
303 if (month.length < 2) month = '0' + month;
304 if (day.length < 2) day = '0' + day;
305 currentDate = year+'-'+month+'-'+day;
306 if(errMsgs.length > 0 || dateVal > currentDate)
308 if(errMsgs.length > 0)
309 alert(msg);
310 if(dateVal > currentDate)
311 alert ('<?php echo xls("Deceased Date should not be greater than Today"); ?>');
312 return false;
314 return true;
317 function toggleSearch(elem) {
318 var f = document.forms[0];
319 <?php if ($WITH_SEARCH) { ?>
320 // Toggle background color.
321 if (elem.style.backgroundColor == '')
322 elem.style.backgroundColor = '<?php echo $searchcolor; ?>';
323 else
324 elem.style.backgroundColor = '';
325 <?php } ?>
326 if (force_submit) {
327 force_submit = false;
328 f.create.value = '<?php xl('Create New Patient','e'); ?>';
330 return true;
333 // If a <select> list is dropped down, this is its name.
334 var open_sel_name = '';
336 function selClick(elem) {
337 if (open_sel_name == elem.name) {
338 open_sel_name = '';
340 else {
341 open_sel_name = elem.name;
342 toggleSearch(elem);
344 return true;
347 function selBlur(elem) {
348 if (open_sel_name == elem.name) {
349 open_sel_name = '';
351 return true;
354 // This invokes the patient search dialog.
355 function searchme() {
356 var f = document.forms[0];
357 var url = '../main/finder/patient_select.php?popup=1';
359 <?php
360 $lres = getLayoutRes();
362 while ($lrow = sqlFetchArray($lres)) {
363 $field_id = $lrow['field_id'];
364 if (strpos($field_id, 'em_') === 0) continue;
365 $data_type = $lrow['data_type'];
366 $fldname = "form_$field_id";
367 switch(getSearchClass($data_type)) {
368 case 1:
369 echo
370 " if (f.$fldname.style.backgroundColor != '' && trimlen(f.$fldname.value) > 0) {\n" .
371 " url += '&$field_id=' + encodeURIComponent(f.$fldname.value);\n" .
372 " }\n";
373 break;
374 case 2:
375 echo
376 " if (f.$fldname.style.backgroundColor != '' && f.$fldname.selectedIndex > 0) {\n" .
377 " url += '&$field_id=' + encodeURIComponent(f.$fldname.options[f.$fldname.selectedIndex].value);\n" .
378 " }\n";
379 break;
384 dlgopen(url, '_blank', 700, 500);
387 //-->
389 </script>
390 </head>
392 <body class="body_top">
394 <?php
395 /*Get the constraint from the DB-> LBF forms accordinf the form_id*/
396 $constraints = LBF_Validation::generate_validate_constraints("DEM");
398 <script> var constraints = <?php echo $constraints;?>; </script>
400 <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)'>
402 <span class='title'><?php xl('Search or Add Patient','e'); ?></span>
404 <table width='100%' cellpadding='0' cellspacing='8'>
405 <tr>
406 <td align='left' valign='top'>
407 <?php if ($SHORT_FORM) echo " <center>\n"; ?>
408 <?php
410 function end_cell() {
411 global $item_count, $cell_count;
412 if ($item_count > 0) {
413 echo "</td>";
414 $item_count = 0;
418 function end_row() {
419 global $cell_count, $CPR;
420 end_cell();
421 if ($cell_count > 0) {
422 for (; $cell_count < $CPR; ++$cell_count) echo "<td></td>";
423 echo "</tr>\n";
424 $cell_count = 0;
428 function end_group() {
429 global $last_group, $SHORT_FORM;
430 if (strlen($last_group) > 0) {
431 end_row();
432 echo " </table>\n";
433 if (!$SHORT_FORM) echo "</div>\n";
437 $last_group = '';
438 $cell_count = 0;
439 $item_count = 0;
440 $display_style = 'block';
441 $group_seq = 0; // this gives the DIV blocks unique IDs
443 while ($frow = sqlFetchArray($fres)) {
444 $this_group = $frow['group_name'];
445 $titlecols = $frow['titlecols'];
446 $datacols = $frow['datacols'];
447 $data_type = $frow['data_type'];
448 $field_id = $frow['field_id'];
449 $list_id = $frow['list_id'];
450 $currvalue = '';
451 $condition_str = get_conditions_str($condition_str,$group_fields);
453 if (strpos($field_id, 'em_') === 0) {
454 $tmp = substr($field_id, 3);
455 if (isset($result2[$tmp])) $currvalue = $result2[$tmp];
457 else {
458 if (isset($result[$field_id])) $currvalue = $result[$field_id];
461 // Handle a data category (group) change.
462 if (strcmp($this_group, $last_group) != 0) {
463 if (!$SHORT_FORM) {
464 end_group();
465 $group_seq++; // ID for DIV tags
466 $group_name = substr($this_group, 1);
467 if (strlen($last_group) > 0) echo "<br />";
468 echo "<span class='bold'><input type='checkbox' name='form_cb_$group_seq' id='form_cb_$group_seq' value='1' " .
469 "onclick='return divclick(this,\"div_$group_seq\");'";
470 if ($display_style == 'block') echo " checked";
472 // Modified 6-09 by BM - Translate if applicable
473 echo " /><b>" . xl_layout_label($group_name) . "</b></span>\n";
475 echo "<div id='div_$group_seq' class='section' style='display:$display_style;'>\n";
476 echo " <table border='0' cellpadding='0'>\n";
477 $display_style = 'none';
479 else if (strlen($last_group) == 0) {
480 echo " <table border='0' cellpadding='0'>\n";
482 $last_group = $this_group;
485 // Handle starting of a new row.
486 if (($titlecols > 0 && $cell_count >= $CPR) || $cell_count == 0) {
487 end_row();
488 echo " <tr>";
491 if ($item_count == 0 && $titlecols == 0) $titlecols = 1;
492 $field_id_label='label_'.$frow['field_id'];
493 // Handle starting of a new label cell.
494 if ($titlecols > 0) {
495 end_cell();
496 echo "<td colspan='$titlecols' id='$field_id_label'";
497 echo ($frow['uor'] == 2) ? " class='required'" : " class='bold'";
498 if ($cell_count == 2) echo " style='padding-left:10pt'";
499 echo ">";
500 $cell_count += $titlecols;
502 ++$item_count;
504 echo "<b>";
506 // Modified 6-09 by BM - Translate if applicable
507 if ($frow['title']) echo (xl_layout_label($frow['title']).":"); else echo "&nbsp;";
509 echo "</b>";
511 // Handle starting of a new data cell.
512 if ($datacols > 0) {
513 $id_field_text = "text_".$frow['field_id'];
514 end_cell();
515 echo "<td colspan='$datacols' class='text data'";
516 if ($cell_count > 0) echo " style='padding-left:5pt'". " id='".$id_field_text."'";
517 echo ">";
518 $cell_count += $datacols;
521 ++$item_count;
522 generate_form_field($frow, $currvalue);
525 end_group();
528 <?php
529 if (! $GLOBALS['simplified_demographics']) {
530 $insurancei = getInsuranceProviders();
531 $pid = 0;
532 $insurance_headings = array(xl("Primary Insurance Provider"), xl("Secondary Insurance Provider"), xl("Tertiary Insurance provider"));
533 $insurance_info = array();
534 $insurance_info[1] = getInsuranceData($pid,"primary");
535 $insurance_info[2] = getInsuranceData($pid,"secondary");
536 $insurance_info[3] = getInsuranceData($pid,"tertiary");
538 echo "<br /><span class='bold'><input type='checkbox' name='form_cb_ins' value='1' " .
539 "onclick='return divclick(this,\"div_ins\");'";
540 if ($display_style == 'block') echo " checked";
541 echo " /><b>" . xl('Insurance') . "</b></span>\n";
542 echo "<div id='div_ins' class='section' style='display:$display_style;'>\n";
544 for($i=1;$i<=3;$i++) {
545 $result3 = $insurance_info[$i];
547 <table border="0">
548 <tr>
549 <td valign='top' colspan='2'>
550 <span class='required'><?php echo $insurance_headings[$i -1].":"?></span>
551 <select name="i<?php echo $i?>provider">
552 <option value=""><?php xl('Unassigned','e'); ?></option>
553 <?php
554 foreach ($insurancei as $iid => $iname) {
555 echo "<option value='" . $iid . "'";
556 if (strtolower($iid) == strtolower($result3{"provider"}))
557 echo " selected";
558 echo ">" . $iname . "</option>\n";
561 </select>&nbsp;<a class='iframe medium_modal' href='../practice/ins_search.php' onclick='ins_search(<?php echo $i?>)'>
562 <span> <?php xl('Search/Add Insurer','e'); ?></span></a>
563 </td>
564 </tr>
565 <tr>
566 <td valign=top>
567 <table border="0">
569 <tr>
570 <td>
571 <span class='required'><?php xl('Plan Name','e'); ?>: </span>
572 </td>
573 <td>
574 <input type='entry' size='20' name='i<?php echo $i?>plan_name' value="<?php echo $result3{"plan_name"} ?>"
575 onchange="capitalizeMe(this);" />&nbsp;&nbsp;
576 </td>
577 </tr>
579 <tr>
580 <td>
581 <span class='required'><?php xl('Effective Date','e'); ?>: </span>
582 </td>
583 <td>
584 <input type='entry' size='11' name='i<?php echo $i ?>effective_date'
585 id='i<?php echo $i ?>effective_date'
586 value='<?php echo $result3['date'] ?>'
587 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)'
588 title='yyyy-mm-dd' />
590 <img src='../../interface/pic/show_calendar.gif' align='absbottom' width='24' height='22'
591 id='img_i<?php echo $i ?>effective_date' border='0' alt='[?]' style='cursor:pointer'
592 title='<?php xl('Click here to choose a date','e'); ?>'>
594 <script LANGUAGE="JavaScript">
595 Calendar.setup({inputField:"i<?php echo $i ?>effective_date", ifFormat:"%Y-%m-%d", button:"img_i<?php echo $i; ?>effective_date"});
596 </script>
599 </td>
600 </tr>
602 <tr>
603 <td><span class=required><?php xl('Policy Number','e'); ?>: </span></td>
604 <td><input type='entry' size='16' name='i<?php echo $i?>policy_number' value="<?php echo $result3{"policy_number"}?>"
605 onkeyup='policykeyup(this)'></td>
606 </tr>
608 <tr>
609 <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>
610 </tr>
612 <tr<?php if ($GLOBALS['omit_employers']) echo " style='display:none'"; ?>>
613 <td class='required'><?php xl('Subscriber Employer (SE)','e'); ?><br><span style='font-weight:normal'>
614 (<?php xl('if unemployed enter Student','e'); ?>,<br><?php xl('PT Student, or leave blank','e'); ?>): </span></td>
615 <td><input type=entry size=25 name=i<?php echo $i?>subscriber_employer
616 value="<?php echo $result3{"subscriber_employer"}?>"
617 onchange="capitalizeMe(this);" /></td>
618 </tr>
620 <tr<?php if ($GLOBALS['omit_employers']) echo " style='display:none'"; ?>>
621 <td><span class=required><?php xl('SE Address','e'); ?>: </span></td>
622 <td><input type=entry size=25 name=i<?php echo $i?>subscriber_employer_street
623 value="<?php echo $result3{"subscriber_employer_street"}?>"
624 onchange="capitalizeMe(this);" /></td>
625 </tr>
627 <tr<?php if ($GLOBALS['omit_employers']) echo " style='display:none'"; ?>>
628 <td colspan="2">
629 <table>
630 <tr>
631 <td><span class=required><?php xl('SE City','e'); ?>: </span></td>
632 <td><input type=entry size=15 name=i<?php echo $i?>subscriber_employer_city
633 value="<?php echo $result3{"subscriber_employer_city"}?>"
634 onchange="capitalizeMe(this);" /></td>
635 <td><span class=required><?php echo ($GLOBALS['phone_country_code'] == '1') ? xl('SE State','e') : xl('SE Locality','e') ?>: </span></td>
636 <td>
637 <?php
638 // Modified 7/2009 by BM to incorporate data types
639 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']);
641 </td>
642 </tr>
643 <tr>
644 <td><span class=required><?php echo ($GLOBALS['phone_country_code'] == '1') ? xl('SE Zip Code','e') : xl('SE Postal Code','e') ?>: </span></td>
645 <td><input type=entry size=10 name=i<?php echo $i?>subscriber_employer_postal_code value="<?php echo $result3{"subscriber_employer_postal_code"}?>"></td>
646 <td><span class=required><?php xl('SE Country','e'); ?>: </span></td>
647 <td>
648 <?php
649 // Modified 7/2009 by BM to incorporate data types
650 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']);
652 </td>
653 </tr>
654 </table>
655 </td>
656 </tr>
658 </table>
659 </td>
661 <td valign=top>
662 <span class=required><?php xl('Subscriber','e'); ?>: </span>
663 <input type=entry size=10 name=i<?php echo $i?>subscriber_fname
664 value="<?php echo $result3{"subscriber_fname"}?>"
665 onchange="capitalizeMe(this);" />
666 <input type=entry size=3 name=i<?php echo $i?>subscriber_mname
667 value="<?php echo $result3{"subscriber_mname"}?>"
668 onchange="capitalizeMe(this);" />
669 <input type=entry size=10 name=i<?php echo $i?>subscriber_lname
670 value="<?php echo $result3{"subscriber_lname"}?>"
671 onchange="capitalizeMe(this);" />
672 <br>
673 <span class=required><?php xl('Relationship','e'); ?>: </span>
674 <?php
675 // Modified 6/2009 by BM to use list_options and function
676 generate_form_field(array('data_type'=>1,'field_id'=>('i'.$i.'subscriber_relationship'),'list_id'=>'sub_relation','empty_title'=>' '), $result3['subscriber_relationship']);
678 <a href="javascript:popUp('../../interface/patient_file/summary/browse.php?browsenum=<?php echo $i?>')" class=text>(<?php xl('Browse','e'); ?>)</a><br />
680 <span class=bold><?php xl('D.O.B.','e'); ?>: </span>
681 <input type='entry' size='11' name='i<?php echo $i?>subscriber_DOB'
682 id='i<?php echo $i?>subscriber_DOB'
683 value='<?php echo $result3['subscriber_DOB'] ?>'
684 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)'
685 title='yyyy-mm-dd' />
687 <img src='../../interface/pic/show_calendar.gif' align='absbottom' width='24' height='22'
688 id='img_i<?php echo $i; ?>dob_date' border='0' alt='[?]' style='cursor:pointer'
689 title='<?php xl('Click here to choose a date','e'); ?>'>
691 <script LANGUAGE="JavaScript">
692 Calendar.setup({inputField:"i<?php echo $i?>subscriber_DOB", ifFormat:"%Y-%m-%d", button:"img_i<?php echo $i; ?>dob_date"});
693 </script>
696 <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;
697 <span class=bold><?php xl('Sex','e'); ?>: </span>
698 <?php
699 // Modified 6/2009 by BM to use list_options and function
700 generate_form_field(array('data_type'=>1,'field_id'=>('i'.$i.'subscriber_sex'),'list_id'=>'sex'), $result3['subscriber_sex']);
702 <br>
703 <span class=required><?php xl('Subscriber Address','e'); ?>: </span>
704 <input type=entry size=25 name=i<?php echo $i?>subscriber_street
705 value="<?php echo $result3{"subscriber_street"}?>"
706 onchange="capitalizeMe(this);" /><br>
707 <span class=required><?php xl('City','e'); ?>: </span>
708 <input type=entry size=15 name=i<?php echo $i?>subscriber_city
709 value="<?php echo $result3{"subscriber_city"}?>"
710 onchange="capitalizeMe(this);" />
711 <span class=required><?php echo ($GLOBALS['phone_country_code'] == '1') ? xl('State','e') : xl('Locality','e') ?>: </span>
712 <?php
713 // Modified 7/2009 by BM to incorporate data types
714 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']);
716 <br />
717 <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"}?>">
718 <span class='required'<?php if ($GLOBALS['omit_employers']) echo " style='display:none'"; ?>>
719 <?php xl('Country','e'); ?>: </span>
720 <?php
721 // Modified 7/2009 by BM to incorporate data types
722 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']);
724 <br />
725 <span class=bold><?php xl('Subscriber Phone','e'); ?>:
726 <input type='text' size='20' name='i<?php echo $i?>subscriber_phone' value='<?php echo $result3["subscriber_phone"] ?>' onkeyup='phonekeyup(this,mypcc)' />
727 </span><br />
728 <span class=bold><?php xl('CoPay','e'); ?>: <input type=text size="6" name=i<?php echo $i?>copay value="<?php echo $result3{"copay"}?>">
729 </span><br />
730 <span class='required'><?php xl('Accept Assignment','e'); ?>: </span>
731 <select name=i<?php echo $i?>accept_assignment>
732 <option value="TRUE" <?php if (strtoupper($result3{"accept_assignment"}) == "TRUE") echo "selected"?>><?php xl('YES','e'); ?></option>
733 <option value="FALSE" <?php if (strtoupper($result3{"accept_assignment"}) == "FALSE") echo "selected"?>><?php xl('NO','e'); ?></option>
734 </select>
735 </td>
736 </tr>
738 </table>
739 <hr />
740 <?php
742 echo "</div>\n";
743 } // end of "if not simplified_demographics"
746 <?php if (!$SHORT_FORM) echo " <center>\n"; ?>
747 <br />
748 <?php if ($WITH_SEARCH) { ?>
749 <input type="button" id="search" value=<?php xl('Search','e','\'','\''); ?>
750 style='background-color:<?php echo $searchcolor; ?>' />
751 &nbsp;&nbsp;
752 <?php } ?>
753 <input type="button" name='create' id="create" value=<?php xl('Create New Patient','e','\'','\''); ?> />
755 </center>
757 </td>
758 <td align='right' valign='top' width='1%' nowrap>
759 <!-- Image upload stuff was here but got moved. -->
760 </td>
761 </tr>
762 </table>
764 </form>
766 <!-- include support for the list-add selectbox feature -->
767 <?php include($GLOBALS['fileroot']."/library/options_listadd.inc"); ?>
769 </body>
771 <script language="JavaScript">
773 // hard code validation for old validation, in the new validation possible to add match rules
774 <?php if($GLOBALS['new_validate'] == 0) { ?>
776 // fix inconsistently formatted phone numbers from the database
777 var f = document.forms[0];
778 if (f.form_phone_contact) phonekeyup(f.form_phone_contact,mypcc);
779 if (f.form_phone_home ) phonekeyup(f.form_phone_home ,mypcc);
780 if (f.form_phone_biz ) phonekeyup(f.form_phone_biz ,mypcc);
781 if (f.form_phone_cell ) phonekeyup(f.form_phone_cell ,mypcc);
783 <?php }?>
785 <?php echo $date_init; ?>
787 // -=- jQuery makes life easier -=-
789 // var matches = 0; // number of patients that match the demographic information being entered
790 // var override = false; // flag that overrides the duplication warning
792 $(document).ready(function() {
793 enable_modals();
794 $(".medium_modal").fancybox( {
795 'overlayOpacity' : 0.0,
796 'showCloseButton' : true,
797 'frameHeight' : 460,
798 'frameWidth' : 650
800 // added to integrate insurance stuff
801 <?php for ($i=1;$i<=3;$i++) { ?>
802 $("#form_i<?php echo $i?>subscriber_relationship").change(function() { auto_populate_employer_address<?php echo $i?>(); });
803 <?php } ?>
805 $('#search').click(function() { searchme(); });
806 $('#create').click(function() { check()});
808 var check = function(e) {
809 <?php if($GLOBALS['new_validate']){?>
810 var valid = submitme(<?php echo $GLOBALS['new_validate'] ? 1 : 0;?>,e,"DEM",constraints);
811 <?php }else{?>
812 top.restoreSession();
813 var f = document.forms[0];
814 var valid = validate(f);
815 <?php }?>
816 if (valid) {
817 if (force_submit) {
818 // In this case dups were shown already and Save should just save.
819 top.restoreSession();
820 f.submit();
821 return;
824 <?php
825 // D in edit_options indicates the field is used in duplication checking.
826 // This constructs a list of the names of those fields.
827 $mflist = "";
828 $mfres = sqlStatement("SELECT * FROM layout_options " .
829 "WHERE form_id = 'DEM' AND uor > 0 AND field_id != '' AND " .
830 "edit_options LIKE '%D%' " .
831 "ORDER BY group_name, seq");
832 while ($mfrow = sqlFetchArray($mfres)) {
833 $field_id = $mfrow['field_id'];
834 if (strpos($field_id, 'em_') === 0) continue;
835 if (!empty($mflist)) $mflist .= ",";
836 $mflist .= "'" . htmlentities($field_id) . "'";
839 <?php if ( ($GLOBALS['full_new_patient_form'] == '4') && (checkIfPatientValidationHookIsActive()) ):?>
840 // Use zend module patient validation hook to open the controller and send the dup-checker fields.
841 var url ='<?php echo $GLOBALS['web_root']."/interface/modules/zend_modules/public/patientvalidation";?>';
842 <?php else:?>
843 // Build and invoke the URL to create the dup-checker dialog.
844 var url = 'new_search_popup.php';
845 <?php endif;?>
847 var flds = new Array(<?php echo $mflist; ?>);
848 var separator = '?';
849 for (var i = 0; i < flds.length; ++i) {
850 var fval = $('#form_' + flds[i]).val();
851 if (fval && fval != '') {
852 url += separator;
853 separator = '&';
854 url += 'mf_' + flds[i] + '=' + encodeURIComponent(fval);
857 url+="&close"
858 dlgopen(url, '_blank', 700, 500);
859 } // end function
860 } // end function
863 // Set onclick/onfocus handlers for toggling background color.
864 <?php
865 $lres = getLayoutRes();
866 while ($lrow = sqlFetchArray($lres)) {
867 $field_id = $lrow['field_id'];
868 if (strpos($field_id, 'em_') === 0) continue;
869 switch(getSearchClass($lrow['data_type'])) {
870 case 1:
871 echo " \$('#form_$field_id').click(function() { toggleSearch(this); });\n";
872 break;
873 case 2:
874 echo " \$('#form_$field_id').click(function() { selClick(this); });\n";
875 echo " \$('#form_$field_id').blur(function() { selBlur(this); });\n";
876 break;
881 }); // end document.ready
883 </script>
884 <?php /*Include the validation script and rules for this form*/
885 $form_id="DEM";
888 <?php
889 //LBF forms use the new validation depending on the global value
890 $use_validate_js=$GLOBALS['new_validate'];
891 include_once("$srcdir/validation/validation_script.js.php");?>
892 <script language='JavaScript'>
893 // Array of skip conditions for the checkSkipConditions() function.
894 var skipArray = [
895 <?php echo $condition_str; ?>
897 checkSkipConditions();
898 $("input").change(function() {
899 checkSkipConditions();
901 $("select").change(function() {
902 checkSkipConditions();
904 </script>
906 </html>