Patient validation Zend module.
[openemr.git] / interface / new / new_comprehensive.php
blobefc59f4a1858a28254e64761ca5fd54c2fc70cc6
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' || $GLOBALS['full_new_patient_form'] == '4');
27 $SHORT_FORM = ($GLOBALS['full_new_patient_form'] == '2' || $GLOBALS['full_new_patient_form'] == '3' );
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"></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="../../library/js/jquery-1.9.1.min.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 wname.setRadio(fname, "new");
109 }//Visolve - sync the radio buttons - End
111 var mypcc = '<?php echo $GLOBALS['phone_country_code'] ?>';
113 // This may be changed to true by the AJAX search script.
114 var force_submit = false;
116 //code used from http://tech.irt.org/articles/js037/
117 function replace(string,text,by) {
118 // Replaces text with by in string
119 var strLength = string.length, txtLength = text.length;
120 if ((strLength == 0) || (txtLength == 0)) return string;
122 var i = string.indexOf(text);
123 if ((!i) && (text != string.substring(0,txtLength))) return string;
124 if (i == -1) return string;
126 var newstr = string.substring(0,i) + by;
128 if (i+txtLength < strLength)
129 newstr += replace(string.substring(i+txtLength,strLength),text,by);
131 return newstr;
134 <?php for ($i=1;$i<=3;$i++) { ?>
135 function auto_populate_employer_address<?php echo $i ?>(){
136 var f = document.demographics_form;
137 if (f.form_i<?php echo $i?>subscriber_relationship.options[f.form_i<?php echo $i?>subscriber_relationship.selectedIndex].value == "self") {
138 f.i<?php echo $i?>subscriber_fname.value=f.form_fname.value;
139 f.i<?php echo $i?>subscriber_mname.value=f.form_mname.value;
140 f.i<?php echo $i?>subscriber_lname.value=f.form_lname.value;
141 f.i<?php echo $i?>subscriber_street.value=f.form_street.value;
142 f.i<?php echo $i?>subscriber_city.value=f.form_city.value;
143 f.form_i<?php echo $i?>subscriber_state.value=f.form_state.value;
144 f.i<?php echo $i?>subscriber_postal_code.value=f.form_postal_code.value;
145 if (f.form_country_code)
146 f.form_i<?php echo $i?>subscriber_country.value=f.form_country_code.value;
147 f.i<?php echo $i?>subscriber_phone.value=f.form_phone_home.value;
148 f.i<?php echo $i?>subscriber_DOB.value=f.form_DOB.value;
149 f.i<?php echo $i?>subscriber_ss.value=f.form_ss.value;
150 f.form_i<?php echo $i?>subscriber_sex.value = f.form_sex.value;
151 f.i<?php echo $i?>subscriber_employer.value=f.form_em_name.value;
152 f.i<?php echo $i?>subscriber_employer_street.value=f.form_em_street.value;
153 f.i<?php echo $i?>subscriber_employer_city.value=f.form_em_city.value;
154 f.form_i<?php echo $i?>subscriber_employer_state.value=f.form_em_state.value;
155 f.i<?php echo $i?>subscriber_employer_postal_code.value=f.form_em_postal_code.value;
156 if (f.form_em_country)
157 f.form_i<?php echo $i?>subscriber_employer_country.value=f.form_em_country.value;
161 <?php } ?>
163 function upperFirst(string,text) {
164 return replace(string,text,text.charAt(0).toUpperCase() + text.substring(1,text.length));
167 // The ins_search.php window calls this to set the selected insurance.
168 function set_insurance(ins_id, ins_name) {
169 var thesel = document.forms[0]['i' + insurance_index + 'provider'];
170 var theopts = thesel.options; // the array of Option objects
171 var i = 0;
172 for (; i < theopts.length; ++i) {
173 if (theopts[i].value == ins_id) {
174 theopts[i].selected = true;
175 return;
178 // no matching option was found so create one, append it to the
179 // end of the list, and select it.
180 theopts[i] = new Option(ins_name, ins_id, false, true);
183 // Indicates which insurance slot is being updated.
184 var insurance_index = 0;
186 // The OnClick handler for searching/adding the insurance company.
187 function ins_search(ins) {
188 insurance_index = ins;
189 return false;
192 function checkNum () {
193 var re= new RegExp();
194 re = /^\d*\.?\d*$/;
195 str=document.forms[0].monthly_income.value;
196 if(re.exec(str))
198 }else{
199 alert("Please enter a dollar amount using only numbers and a decimal point.");
203 // This capitalizes the first letter of each word in the passed input
204 // element. It also strips out extraneous spaces.
205 function capitalizeMe(elem) {
206 var a = elem.value.split(' ');
207 var s = '';
208 for(var i = 0; i < a.length; ++i) {
209 if (a[i].length > 0) {
210 if (s.length > 0) s += ' ';
211 s += a[i].charAt(0).toUpperCase() + a[i].substring(1);
214 elem.value = s;
217 // Onkeyup handler for policy number. Allows only A-Z and 0-9.
218 function policykeyup(e) {
219 var v = e.value.toUpperCase();
220 var filteredString="";
221 for (var i = 0; i < v.length; ++i) {
222 var c = v.charAt(i);
223 if ((c >= '0' && c <= '9') ||
224 (c >= 'A' && c <= 'Z') ||
225 (c == '*') ||
226 (c == '-') ||
227 (c == '_') ||
228 (c == '(') ||
229 (c == ')') ||
230 (c == '#'))
232 filteredString+=c;
235 e.value = filteredString;
236 return;
239 function divclick(cb, divid) {
240 var divstyle = document.getElementById(divid).style;
241 if (cb.checked) {
242 divstyle.display = 'block';
243 } else {
244 divstyle.display = 'none';
246 return true;
249 // Compute the length of a string without leading and trailing spaces.
250 function trimlen(s) {
251 var i = 0;
252 var j = s.length - 1;
253 for (; i <= j && s.charAt(i) == ' '; ++i);
254 for (; i <= j && s.charAt(j) == ' '; --j);
255 if (i > j) return 0;
256 return j + 1 - i;
259 function validate(f) {
260 var errMsgs = new Array();
261 <?php generate_layout_validation('DEM'); ?>
262 <?php if($GLOBALS['erx_enable']){ ?>
263 alertMsg='';
264 for(i=0;i<f.length;i++){
265 if(f[i].type=='text' && f[i].value)
267 if(f[i].name == 'form_fname' || f[i].name == 'form_mname' || f[i].name == 'form_lname')
269 alertMsg += checkLength(f[i].name,f[i].value,35);
270 alertMsg += checkUsername(f[i].name,f[i].value);
272 else if(f[i].name == 'form_street' || f[i].name == 'form_city')
274 alertMsg += checkLength(f[i].name,f[i].value,35);
275 alertMsg += checkAlphaNumericExtended(f[i].name,f[i].value);
277 else if(f[i].name == 'form_phone_home')
279 alertMsg += checkPhone(f[i].name,f[i].value);
283 if(alertMsg)
285 alert(alertMsg);
286 return false;
288 <?php } ?>
289 var msg = "";
290 msg += "<?php echo htmlspecialchars(xl('The following fields are required'),ENT_QUOTES); ?>:\n\n";
291 for ( var i = 0; i < errMsgs.length; i++ ) {
292 msg += errMsgs[i] + "\n";
294 msg += "\n<?php echo htmlspecialchars(xl('Please fill them in before continuing.'),ENT_QUOTES); ?>";
297 //Misc Deceased Date Validation for Future Date
298 var dateVal = document.getElementById("form_deceased_date").value;
299 var currentDate;
300 var d = new Date();
301 month = '' + (d.getMonth() + 1),
302 day = '' + d.getDate(),
303 year = d.getFullYear();
304 if (month.length < 2) month = '0' + month;
305 if (day.length < 2) day = '0' + day;
306 currentDate = year+'-'+month+'-'+day;
307 if(errMsgs.length > 0 || dateVal > currentDate)
309 if(errMsgs.length > 0)
310 alert(msg);
311 if(dateVal > currentDate)
312 alert ('<?php echo xls("Deceased Date should not be greater than Today"); ?>');
313 return false;
315 return true;
318 function toggleSearch(elem) {
319 var f = document.forms[0];
320 <?php if ($WITH_SEARCH) { ?>
321 // Toggle background color.
322 if (elem.style.backgroundColor == '')
323 elem.style.backgroundColor = '<?php echo $searchcolor; ?>';
324 else
325 elem.style.backgroundColor = '';
326 <?php } ?>
327 if (force_submit) {
328 force_submit = false;
329 f.create.value = '<?php xl('Create New Patient','e'); ?>';
331 return true;
334 // If a <select> list is dropped down, this is its name.
335 var open_sel_name = '';
337 function selClick(elem) {
338 if (open_sel_name == elem.name) {
339 open_sel_name = '';
341 else {
342 open_sel_name = elem.name;
343 toggleSearch(elem);
345 return true;
348 function selBlur(elem) {
349 if (open_sel_name == elem.name) {
350 open_sel_name = '';
352 return true;
355 // This invokes the patient search dialog.
356 function searchme() {
357 var f = document.forms[0];
358 var url = '../main/finder/patient_select.php?popup=1';
360 <?php
361 $lres = getLayoutRes();
363 while ($lrow = sqlFetchArray($lres)) {
364 $field_id = $lrow['field_id'];
365 if (strpos($field_id, 'em_') === 0) continue;
366 $data_type = $lrow['data_type'];
367 $fldname = "form_$field_id";
368 switch(getSearchClass($data_type)) {
369 case 1:
370 echo
371 " if (f.$fldname.style.backgroundColor != '' && trimlen(f.$fldname.value) > 0) {\n" .
372 " url += '&$field_id=' + encodeURIComponent(f.$fldname.value);\n" .
373 " }\n";
374 break;
375 case 2:
376 echo
377 " if (f.$fldname.style.backgroundColor != '' && f.$fldname.selectedIndex > 0) {\n" .
378 " url += '&$field_id=' + encodeURIComponent(f.$fldname.options[f.$fldname.selectedIndex].value);\n" .
379 " }\n";
380 break;
385 dlgopen(url, '_blank', 700, 500);
388 //-->
390 </script>
391 </head>
393 <body class="body_top">
395 <?php
396 /*Get the constraint from the DB-> LBF forms accordinf the form_id*/
397 $constraints = LBF_Validation::generate_validate_constraints("DEM");
399 <script> var constraints = <?php echo $constraints;?>; </script>
401 <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)'>
403 <span class='title'><?php xl('Search or Add Patient','e'); ?></span>
405 <table width='100%' cellpadding='0' cellspacing='8'>
406 <tr>
407 <td align='left' valign='top'>
408 <?php if ($SHORT_FORM) echo " <center>\n"; ?>
409 <?php
411 function end_cell() {
412 global $item_count, $cell_count;
413 if ($item_count > 0) {
414 echo "</td>";
415 $item_count = 0;
419 function end_row() {
420 global $cell_count, $CPR;
421 end_cell();
422 if ($cell_count > 0) {
423 for (; $cell_count < $CPR; ++$cell_count) echo "<td></td>";
424 echo "</tr>\n";
425 $cell_count = 0;
429 function end_group() {
430 global $last_group, $SHORT_FORM;
431 if (strlen($last_group) > 0) {
432 end_row();
433 echo " </table>\n";
434 if (!$SHORT_FORM) echo "</div>\n";
438 $last_group = '';
439 $cell_count = 0;
440 $item_count = 0;
441 $display_style = 'block';
442 $group_seq = 0; // this gives the DIV blocks unique IDs
444 while ($frow = sqlFetchArray($fres)) {
445 $this_group = $frow['group_name'];
446 $titlecols = $frow['titlecols'];
447 $datacols = $frow['datacols'];
448 $data_type = $frow['data_type'];
449 $field_id = $frow['field_id'];
450 $list_id = $frow['list_id'];
451 $currvalue = '';
452 $condition_str = get_conditions_str($condition_str,$group_fields);
454 if (strpos($field_id, 'em_') === 0) {
455 $tmp = substr($field_id, 3);
456 if (isset($result2[$tmp])) $currvalue = $result2[$tmp];
458 else {
459 if (isset($result[$field_id])) $currvalue = $result[$field_id];
462 // Handle a data category (group) change.
463 if (strcmp($this_group, $last_group) != 0) {
464 if (!$SHORT_FORM) {
465 end_group();
466 $group_seq++; // ID for DIV tags
467 $group_name = substr($this_group, 1);
468 if (strlen($last_group) > 0) echo "<br />";
469 echo "<span class='bold'><input type='checkbox' name='form_cb_$group_seq' id='form_cb_$group_seq' value='1' " .
470 "onclick='return divclick(this,\"div_$group_seq\");'";
471 if ($display_style == 'block') echo " checked";
473 // Modified 6-09 by BM - Translate if applicable
474 echo " /><b>" . xl_layout_label($group_name) . "</b></span>\n";
476 echo "<div id='div_$group_seq' class='section' style='display:$display_style;'>\n";
477 echo " <table border='0' cellpadding='0'>\n";
478 $display_style = 'none';
480 else if (strlen($last_group) == 0) {
481 echo " <table border='0' cellpadding='0'>\n";
483 $last_group = $this_group;
486 // Handle starting of a new row.
487 if (($titlecols > 0 && $cell_count >= $CPR) || $cell_count == 0) {
488 end_row();
489 echo " <tr>";
492 if ($item_count == 0 && $titlecols == 0) $titlecols = 1;
493 $field_id_label='label_'.$frow['field_id'];
494 // Handle starting of a new label cell.
495 if ($titlecols > 0) {
496 end_cell();
497 echo "<td colspan='$titlecols' id='$field_id_label'";
498 echo ($frow['uor'] == 2) ? " class='required'" : " class='bold'";
499 if ($cell_count == 2) echo " style='padding-left:10pt'";
500 echo ">";
501 $cell_count += $titlecols;
503 ++$item_count;
505 echo "<b>";
507 // Modified 6-09 by BM - Translate if applicable
508 if ($frow['title']) echo (xl_layout_label($frow['title']).":"); else echo "&nbsp;";
510 echo "</b>";
512 // Handle starting of a new data cell.
513 if ($datacols > 0) {
514 $id_field_text = "text_".$frow['field_id'];
515 end_cell();
516 echo "<td colspan='$datacols' class='text data'";
517 if ($cell_count > 0) echo " style='padding-left:5pt'". " id='".$id_field_text."'";
518 echo ">";
519 $cell_count += $datacols;
522 ++$item_count;
523 generate_form_field($frow, $currvalue);
526 end_group();
529 <?php
530 if (! $GLOBALS['simplified_demographics']) {
531 $insurancei = getInsuranceProviders();
532 $pid = 0;
533 $insurance_headings = array(xl("Primary Insurance Provider"), xl("Secondary Insurance Provider"), xl("Tertiary Insurance provider"));
534 $insurance_info = array();
535 $insurance_info[1] = getInsuranceData($pid,"primary");
536 $insurance_info[2] = getInsuranceData($pid,"secondary");
537 $insurance_info[3] = getInsuranceData($pid,"tertiary");
539 echo "<br /><span class='bold'><input type='checkbox' name='form_cb_ins' value='1' " .
540 "onclick='return divclick(this,\"div_ins\");'";
541 if ($display_style == 'block') echo " checked";
542 echo " /><b>" . xl('Insurance') . "</b></span>\n";
543 echo "<div id='div_ins' class='section' style='display:$display_style;'>\n";
545 for($i=1;$i<=3;$i++) {
546 $result3 = $insurance_info[$i];
548 <table border="0">
549 <tr>
550 <td valign='top' colspan='2'>
551 <span class='required'><?php echo $insurance_headings[$i -1].":"?></span>
552 <select name="i<?php echo $i?>provider">
553 <option value=""><?php xl('Unassigned','e'); ?></option>
554 <?php
555 foreach ($insurancei as $iid => $iname) {
556 echo "<option value='" . $iid . "'";
557 if (strtolower($iid) == strtolower($result3{"provider"}))
558 echo " selected";
559 echo ">" . $iname . "</option>\n";
562 </select>&nbsp;<a class='iframe medium_modal' href='../practice/ins_search.php' onclick='ins_search(<?php echo $i?>)'>
563 <span> <?php xl('Search/Add Insurer','e'); ?></span></a>
564 </td>
565 </tr>
566 <tr>
567 <td valign=top>
568 <table border="0">
570 <tr>
571 <td>
572 <span class='required'><?php xl('Plan Name','e'); ?>: </span>
573 </td>
574 <td>
575 <input type='entry' size='20' name='i<?php echo $i?>plan_name' value="<?php echo $result3{"plan_name"} ?>"
576 onchange="capitalizeMe(this);" />&nbsp;&nbsp;
577 </td>
578 </tr>
580 <tr>
581 <td>
582 <span class='required'><?php xl('Effective Date','e'); ?>: </span>
583 </td>
584 <td>
585 <input type='entry' size='11' name='i<?php echo $i ?>effective_date'
586 id='i<?php echo $i ?>effective_date'
587 value='<?php echo $result3['date'] ?>'
588 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)'
589 title='yyyy-mm-dd' />
591 <img src='../../interface/pic/show_calendar.gif' align='absbottom' width='24' height='22'
592 id='img_i<?php echo $i ?>effective_date' border='0' alt='[?]' style='cursor:pointer'
593 title='<?php xl('Click here to choose a date','e'); ?>'>
595 <script LANGUAGE="JavaScript">
596 Calendar.setup({inputField:"i<?php echo $i ?>effective_date", ifFormat:"%Y-%m-%d", button:"img_i<?php echo $i; ?>effective_date"});
597 </script>
600 </td>
601 </tr>
603 <tr>
604 <td><span class=required><?php xl('Policy Number','e'); ?>: </span></td>
605 <td><input type='entry' size='16' name='i<?php echo $i?>policy_number' value="<?php echo $result3{"policy_number"}?>"
606 onkeyup='policykeyup(this)'></td>
607 </tr>
609 <tr>
610 <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>
611 </tr>
613 <tr<?php if ($GLOBALS['omit_employers']) echo " style='display:none'"; ?>>
614 <td class='required'><?php xl('Subscriber Employer (SE)','e'); ?><br><span style='font-weight:normal'>
615 (<?php xl('if unemployed enter Student','e'); ?>,<br><?php xl('PT Student, or leave blank','e'); ?>): </span></td>
616 <td><input type=entry size=25 name=i<?php echo $i?>subscriber_employer
617 value="<?php echo $result3{"subscriber_employer"}?>"
618 onchange="capitalizeMe(this);" /></td>
619 </tr>
621 <tr<?php if ($GLOBALS['omit_employers']) echo " style='display:none'"; ?>>
622 <td><span class=required><?php xl('SE Address','e'); ?>: </span></td>
623 <td><input type=entry size=25 name=i<?php echo $i?>subscriber_employer_street
624 value="<?php echo $result3{"subscriber_employer_street"}?>"
625 onchange="capitalizeMe(this);" /></td>
626 </tr>
628 <tr<?php if ($GLOBALS['omit_employers']) echo " style='display:none'"; ?>>
629 <td colspan="2">
630 <table>
631 <tr>
632 <td><span class=required><?php xl('SE City','e'); ?>: </span></td>
633 <td><input type=entry size=15 name=i<?php echo $i?>subscriber_employer_city
634 value="<?php echo $result3{"subscriber_employer_city"}?>"
635 onchange="capitalizeMe(this);" /></td>
636 <td><span class=required><?php echo ($GLOBALS['phone_country_code'] == '1') ? xl('SE State','e') : xl('SE Locality','e') ?>: </span></td>
637 <td>
638 <?php
639 // Modified 7/2009 by BM to incorporate data types
640 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']);
642 </td>
643 </tr>
644 <tr>
645 <td><span class=required><?php echo ($GLOBALS['phone_country_code'] == '1') ? xl('SE Zip Code','e') : xl('SE Postal Code','e') ?>: </span></td>
646 <td><input type=entry size=10 name=i<?php echo $i?>subscriber_employer_postal_code value="<?php echo $result3{"subscriber_employer_postal_code"}?>"></td>
647 <td><span class=required><?php xl('SE Country','e'); ?>: </span></td>
648 <td>
649 <?php
650 // Modified 7/2009 by BM to incorporate data types
651 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']);
653 </td>
654 </tr>
655 </table>
656 </td>
657 </tr>
659 </table>
660 </td>
662 <td valign=top>
663 <span class=required><?php xl('Subscriber','e'); ?>: </span>
664 <input type=entry size=10 name=i<?php echo $i?>subscriber_fname
665 value="<?php echo $result3{"subscriber_fname"}?>"
666 onchange="capitalizeMe(this);" />
667 <input type=entry size=3 name=i<?php echo $i?>subscriber_mname
668 value="<?php echo $result3{"subscriber_mname"}?>"
669 onchange="capitalizeMe(this);" />
670 <input type=entry size=10 name=i<?php echo $i?>subscriber_lname
671 value="<?php echo $result3{"subscriber_lname"}?>"
672 onchange="capitalizeMe(this);" />
673 <br>
674 <span class=required><?php xl('Relationship','e'); ?>: </span>
675 <?php
676 // Modified 6/2009 by BM to use list_options and function
677 generate_form_field(array('data_type'=>1,'field_id'=>('i'.$i.'subscriber_relationship'),'list_id'=>'sub_relation','empty_title'=>' '), $result3['subscriber_relationship']);
679 <a href="javascript:popUp('../../interface/patient_file/summary/browse.php?browsenum=<?php echo $i?>')" class=text>(<?php xl('Browse','e'); ?>)</a><br />
681 <span class=bold><?php xl('D.O.B.','e'); ?>: </span>
682 <input type='entry' size='11' name='i<?php echo $i?>subscriber_DOB'
683 id='i<?php echo $i?>subscriber_DOB'
684 value='<?php echo $result3['subscriber_DOB'] ?>'
685 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)'
686 title='yyyy-mm-dd' />
688 <img src='../../interface/pic/show_calendar.gif' align='absbottom' width='24' height='22'
689 id='img_i<?php echo $i; ?>dob_date' border='0' alt='[?]' style='cursor:pointer'
690 title='<?php xl('Click here to choose a date','e'); ?>'>
692 <script LANGUAGE="JavaScript">
693 Calendar.setup({inputField:"i<?php echo $i?>subscriber_DOB", ifFormat:"%Y-%m-%d", button:"img_i<?php echo $i; ?>dob_date"});
694 </script>
697 <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;
698 <span class=bold><?php xl('Sex','e'); ?>: </span>
699 <?php
700 // Modified 6/2009 by BM to use list_options and function
701 generate_form_field(array('data_type'=>1,'field_id'=>('i'.$i.'subscriber_sex'),'list_id'=>'sex'), $result3['subscriber_sex']);
703 <br>
704 <span class=required><?php xl('Subscriber Address','e'); ?>: </span>
705 <input type=entry size=25 name=i<?php echo $i?>subscriber_street
706 value="<?php echo $result3{"subscriber_street"}?>"
707 onchange="capitalizeMe(this);" /><br>
708 <span class=required><?php xl('City','e'); ?>: </span>
709 <input type=entry size=15 name=i<?php echo $i?>subscriber_city
710 value="<?php echo $result3{"subscriber_city"}?>"
711 onchange="capitalizeMe(this);" />
712 <span class=required><?php echo ($GLOBALS['phone_country_code'] == '1') ? xl('State','e') : xl('Locality','e') ?>: </span>
713 <?php
714 // Modified 7/2009 by BM to incorporate data types
715 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']);
717 <br />
718 <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"}?>">
719 <span class='required'<?php if ($GLOBALS['omit_employers']) echo " style='display:none'"; ?>>
720 <?php xl('Country','e'); ?>: </span>
721 <?php
722 // Modified 7/2009 by BM to incorporate data types
723 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']);
725 <br />
726 <span class=bold><?php xl('Subscriber Phone','e'); ?>:
727 <input type='text' size='20' name='i<?php echo $i?>subscriber_phone' value='<?php echo $result3["subscriber_phone"] ?>' onkeyup='phonekeyup(this,mypcc)' />
728 </span><br />
729 <span class=bold><?php xl('CoPay','e'); ?>: <input type=text size="6" name=i<?php echo $i?>copay value="<?php echo $result3{"copay"}?>">
730 </span><br />
731 <span class='required'><?php xl('Accept Assignment','e'); ?>: </span>
732 <select name=i<?php echo $i?>accept_assignment>
733 <option value="TRUE" <?php if (strtoupper($result3{"accept_assignment"}) == "TRUE") echo "selected"?>><?php xl('YES','e'); ?></option>
734 <option value="FALSE" <?php if (strtoupper($result3{"accept_assignment"}) == "FALSE") echo "selected"?>><?php xl('NO','e'); ?></option>
735 </select>
736 </td>
737 </tr>
739 </table>
740 <hr />
741 <?php
743 echo "</div>\n";
744 } // end of "if not simplified_demographics"
747 <?php if (!$SHORT_FORM) echo " <center>\n"; ?>
748 <br />
749 <?php if ($WITH_SEARCH) { ?>
750 <input type="button" id="search" value=<?php xl('Search','e','\'','\''); ?>
751 style='background-color:<?php echo $searchcolor; ?>' />
752 &nbsp;&nbsp;
753 <?php } ?>
754 <input type="button" name='create' id="create" value=<?php xl('Create New Patient','e','\'','\''); ?> />
756 </center>
758 </td>
759 <td align='right' valign='top' width='1%' nowrap>
760 <!-- Image upload stuff was here but got moved. -->
761 </td>
762 </tr>
763 </table>
765 </form>
767 <!-- include support for the list-add selectbox feature -->
768 <?php include($GLOBALS['fileroot']."/library/options_listadd.inc"); ?>
770 </body>
772 <script language="JavaScript">
774 // hard code validation for old validation, in the new validation possible to add match rules
775 <?php if($GLOBALS['new_validate'] == 0) { ?>
777 // fix inconsistently formatted phone numbers from the database
778 var f = document.forms[0];
779 if (f.form_phone_contact) phonekeyup(f.form_phone_contact,mypcc);
780 if (f.form_phone_home ) phonekeyup(f.form_phone_home ,mypcc);
781 if (f.form_phone_biz ) phonekeyup(f.form_phone_biz ,mypcc);
782 if (f.form_phone_cell ) phonekeyup(f.form_phone_cell ,mypcc);
784 <?php }?>
786 <?php echo $date_init; ?>
788 // -=- jQuery makes life easier -=-
790 // var matches = 0; // number of patients that match the demographic information being entered
791 // var override = false; // flag that overrides the duplication warning
793 $(document).ready(function() {
794 enable_modals();
795 $(".medium_modal").fancybox( {
796 'overlayOpacity' : 0.0,
797 'showCloseButton' : true,
798 'frameHeight' : 460,
799 'frameWidth' : 650
801 // added to integrate insurance stuff
802 <?php for ($i=1;$i<=3;$i++) { ?>
803 $("#form_i<?php echo $i?>subscriber_relationship").change(function() { auto_populate_employer_address<?php echo $i?>(); });
804 <?php } ?>
806 $('#search').click(function() { searchme(); });
807 $('#create').click(function() { check()});
809 var check = function(e) {
810 <?php if($GLOBALS['new_validate']){?>
811 var valid = submitme(<?php echo $GLOBALS['new_validate'] ? 1 : 0;?>,e,"DEM",constraints);
812 <?php }else{?>
813 top.restoreSession();
814 var f = document.forms[0];
815 var valid = validate(f);
816 <?php }?>
817 if (valid) {
818 if (force_submit) {
819 // In this case dups were shown already and Save should just save.
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?close";?>';
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);
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 include_once("$srcdir/validation/validation_script.js.php");?>
889 <script language='JavaScript'>
890 // Array of skip conditions for the checkSkipConditions() function.
891 var skipArray = [
892 <?php echo $condition_str; ?>
894 checkSkipConditions();
895 $("input").change(function() {
896 checkSkipConditions();
898 $("select").change(function() {
899 checkSkipConditions();
901 </script>
903 </html>