Fix bug with javascript validation of policy and group numbers.
[openemr.git] / interface / new / new_comprehensive.php
blob9b43b1083b9b196878d4df05376c3f4f009ddea5
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");
15 // Check authorization.
16 if (!acl_check('patients','demo','',array('write','addonly') ))
17 die("Adding demographics is not authorized.");
19 $CPR = 4; // cells per row
21 $searchcolor = empty($GLOBALS['layout_search_color']) ?
22 '#ffff55' : $GLOBALS['layout_search_color'];
24 $WITH_SEARCH = ($GLOBALS['full_new_patient_form'] == '1' || $GLOBALS['full_new_patient_form'] == '2');
25 $SHORT_FORM = ($GLOBALS['full_new_patient_form'] == '2' || $GLOBALS['full_new_patient_form'] == '3');
27 function getLayoutRes() {
28 global $SHORT_FORM;
29 return sqlStatement("SELECT * FROM layout_options " .
30 "WHERE form_id = 'DEM' AND uor > 0 AND field_id != '' " .
31 ($SHORT_FORM ? "AND ( uor > 1 OR edit_options LIKE '%N%' ) " : "") .
32 "ORDER BY group_name, seq");
35 // Determine layout field search treatment from its data type:
36 // 1 = text field
37 // 2 = select list
38 // 0 = not searchable
40 function getSearchClass($data_type) {
41 switch($data_type) {
42 case 1: // single-selection list
43 case 10: // local provider list
44 case 11: // provider list
45 case 12: // pharmacy list
46 case 13: // squads
47 case 14: // address book list
48 case 26: // single-selection list with add
49 case 35: // facilities
50 return 2;
51 case 2: // text field
52 case 3: // textarea
53 case 4: // date
54 return 1;
56 return 0;
59 $fres = getLayoutRes();
61 <html>
62 <head>
63 <?php html_header_show(); ?>
65 <link rel="stylesheet" href="<?php echo $css_header; ?>" type="text/css">
67 <style>
68 body, td, input, select, textarea {
69 font-family: Arial, Helvetica, sans-serif;
70 font-size: 10pt;
73 body {
74 padding: 5pt 5pt 5pt 5pt;
77 div.section {
78 border: solid;
79 border-width: 1px;
80 border-color: #0000ff;
81 margin: 0 0 0 10pt;
82 padding: 5pt;
85 </style>
87 <style type="text/css">@import url(../../library/dynarch_calendar.css);</style>
89 <script type="text/javascript" src="../../library/dialog.js"></script>
90 <script type="text/javascript" src="../../library/textformat.js"></script>
91 <script type="text/javascript" src="../../library/dynarch_calendar.js"></script>
92 <?php include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?>
93 <script type="text/javascript" src="../../library/dynarch_calendar_setup.js"></script>
94 <script type="text/javascript" src="<?php echo $GLOBALS['webroot']; ?>/library/js/jquery.js"></script>
96 <SCRIPT LANGUAGE="JavaScript"><!--
97 //Visolve - sync the radio buttons - Start
98 if((top.window.parent) && (parent.window)){
99 var wname = top.window.parent.left_nav;
100 fname = (parent.window.name)?parent.window.name:window.name;
101 wname.syncRadios();
102 wname.setRadio(fname, "new");
103 }//Visolve - sync the radio buttons - End
105 var mypcc = '<?php echo $GLOBALS['phone_country_code'] ?>';
107 // This may be changed to true by the AJAX search script.
108 var force_submit = false;
110 //code used from http://tech.irt.org/articles/js037/
111 function replace(string,text,by) {
112 // Replaces text with by in string
113 var strLength = string.length, txtLength = text.length;
114 if ((strLength == 0) || (txtLength == 0)) return string;
116 var i = string.indexOf(text);
117 if ((!i) && (text != string.substring(0,txtLength))) return string;
118 if (i == -1) return string;
120 var newstr = string.substring(0,i) + by;
122 if (i+txtLength < strLength)
123 newstr += replace(string.substring(i+txtLength,strLength),text,by);
125 return newstr;
128 <?php for ($i=1;$i<=3;$i++) { ?>
129 function auto_populate_employer_address<?php echo $i ?>(){
130 var f = document.demographics_form;
131 if (f.form_i<?php echo $i?>subscriber_relationship.options[f.form_i<?php echo $i?>subscriber_relationship.selectedIndex].value == "self") {
132 f.i<?php echo $i?>subscriber_fname.value=f.form_fname.value;
133 f.i<?php echo $i?>subscriber_mname.value=f.form_mname.value;
134 f.i<?php echo $i?>subscriber_lname.value=f.form_lname.value;
135 f.i<?php echo $i?>subscriber_street.value=f.form_street.value;
136 f.i<?php echo $i?>subscriber_city.value=f.form_city.value;
137 f.form_i<?php echo $i?>subscriber_state.value=f.form_state.value;
138 f.i<?php echo $i?>subscriber_postal_code.value=f.form_postal_code.value;
139 if (f.form_country_code)
140 f.form_i<?php echo $i?>subscriber_country.value=f.form_country_code.value;
141 f.i<?php echo $i?>subscriber_phone.value=f.form_phone_home.value;
142 f.i<?php echo $i?>subscriber_DOB.value=f.form_DOB.value;
143 f.i<?php echo $i?>subscriber_ss.value=f.form_ss.value;
144 f.form_i<?php echo $i?>subscriber_sex.value = f.form_sex.value;
145 f.i<?php echo $i?>subscriber_employer.value=f.form_em_name.value;
146 f.i<?php echo $i?>subscriber_employer_street.value=f.form_em_street.value;
147 f.i<?php echo $i?>subscriber_employer_city.value=f.form_em_city.value;
148 f.form_i<?php echo $i?>subscriber_employer_state.value=f.form_em_state.value;
149 f.i<?php echo $i?>subscriber_employer_postal_code.value=f.form_em_postal_code.value;
150 if (f.form_em_country)
151 f.form_i<?php echo $i?>subscriber_employer_country.value=f.form_em_country.value;
155 <?php } ?>
157 function upperFirst(string,text) {
158 return replace(string,text,text.charAt(0).toUpperCase() + text.substring(1,text.length));
161 // The ins_search.php window calls this to set the selected insurance.
162 function set_insurance(ins_id, ins_name) {
163 var thesel = document.forms[0]['i' + insurance_index + 'provider'];
164 var theopts = thesel.options; // the array of Option objects
165 var i = 0;
166 for (; i < theopts.length; ++i) {
167 if (theopts[i].value == ins_id) {
168 theopts[i].selected = true;
169 return;
172 // no matching option was found so create one, append it to the
173 // end of the list, and select it.
174 theopts[i] = new Option(ins_name, ins_id, false, true);
177 // Indicates which insurance slot is being updated.
178 var insurance_index = 0;
180 // The OnClick handler for searching/adding the insurance company.
181 function ins_search(ins) {
182 insurance_index = ins;
183 dlgopen('../../interface/practice/ins_search.php', '_blank', 550, 400);
184 return false;
187 function checkNum () {
188 var re= new RegExp();
189 re = /^\d*\.?\d*$/;
190 str=document.forms[0].monthly_income.value;
191 if(re.exec(str))
193 }else{
194 alert("Please enter a dollar amount using only numbers and a decimal point.");
198 // This capitalizes the first letter of each word in the passed input
199 // element. It also strips out extraneous spaces.
200 function capitalizeMe(elem) {
201 var a = elem.value.split(' ');
202 var s = '';
203 for(var i = 0; i < a.length; ++i) {
204 if (a[i].length > 0) {
205 if (s.length > 0) s += ' ';
206 s += a[i].charAt(0).toUpperCase() + a[i].substring(1);
209 elem.value = s;
212 // Onkeyup handler for policy number. Allows only A-Z and 0-9.
213 function policykeyup(e) {
214 var v = e.value.toUpperCase();
215 var filteredString="";
216 for (var i = 0; i < v.length; ++i) {
217 var c = v.charAt(i);
218 if ((c >= '0' && c <= '9') ||
219 (c >= 'A' && c <= 'Z') ||
220 (c == '*') ||
221 (c == '-') ||
222 (c == '_') ||
223 (c == '(') ||
224 (c == ')') ||
225 (c == '#'))
227 filteredString+=c;
230 e.value = filteredString;
231 return;
234 function divclick(cb, divid) {
235 var divstyle = document.getElementById(divid).style;
236 if (cb.checked) {
237 divstyle.display = 'block';
238 } else {
239 divstyle.display = 'none';
241 return true;
244 // Compute the length of a string without leading and trailing spaces.
245 function trimlen(s) {
246 var i = 0;
247 var j = s.length - 1;
248 for (; i <= j && s.charAt(i) == ' '; ++i);
249 for (; i <= j && s.charAt(j) == ' '; --j);
250 if (i > j) return 0;
251 return j + 1 - i;
254 function validate(f) {
255 var errMsgs = new Array();
256 <?php generate_layout_validation('DEM'); ?>
257 <?php if($GLOBALS['erx_enable']){ ?>
258 alertMsg='';
259 for(i=0;i<f.length;i++){
260 if(f[i].type=='text' && f[i].value)
262 if(f[i].name == 'form_fname' || f[i].name == 'form_mname' || f[i].name == 'form_lname')
264 alertMsg += checkLength(f[i].name,f[i].value,35);
265 alertMsg += checkUsername(f[i].name,f[i].value);
267 else if(f[i].name == 'form_street' || f[i].name == 'form_city')
269 alertMsg += checkLength(f[i].name,f[i].value,35);
270 alertMsg += checkAlphaNumericExtended(f[i].name,f[i].value);
272 else if(f[i].name == 'form_phone_home')
274 alertMsg += checkPhone(f[i].name,f[i].value);
278 if(alertMsg)
280 alert(alertMsg);
281 return false;
283 <?php } ?>
284 var msg = "";
285 msg += "<?php echo htmlspecialchars(xl('The following fields are required'),ENT_QUOTES); ?>:\n\n";
286 for ( var i = 0; i < errMsgs.length; i++ ) {
287 msg += errMsgs[i] + "\n";
289 msg += "\n<?php echo htmlspecialchars(xl('Please fill them in before continuing.'),ENT_QUOTES); ?>";
291 if ( errMsgs.length > 0 ) {
292 alert(msg);
293 return false;
295 return true;
298 function toggleSearch(elem) {
299 var f = document.forms[0];
300 <?php if ($WITH_SEARCH) { ?>
301 // Toggle background color.
302 if (elem.style.backgroundColor == '')
303 elem.style.backgroundColor = '<?php echo $searchcolor; ?>';
304 else
305 elem.style.backgroundColor = '';
306 <?php } ?>
307 if (force_submit) {
308 force_submit = false;
309 f.create.value = '<?php xl('Create New Patient','e'); ?>';
311 return true;
314 // If a <select> list is dropped down, this is its name.
315 var open_sel_name = '';
317 function selClick(elem) {
318 if (open_sel_name == elem.name) {
319 open_sel_name = '';
321 else {
322 open_sel_name = elem.name;
323 toggleSearch(elem);
325 return true;
328 function selBlur(elem) {
329 if (open_sel_name == elem.name) {
330 open_sel_name = '';
332 return true;
335 // This invokes the patient search dialog.
336 function searchme() {
337 var f = document.forms[0];
338 var url = '../main/finder/patient_select.php?popup=1';
340 <?php
341 $lres = getLayoutRes();
343 while ($lrow = sqlFetchArray($lres)) {
344 $field_id = $lrow['field_id'];
345 if (strpos($field_id, 'em_') === 0) continue;
346 $data_type = $lrow['data_type'];
347 $fldname = "form_$field_id";
348 switch(getSearchClass($data_type)) {
349 case 1:
350 echo
351 " if (f.$fldname.style.backgroundColor != '' && trimlen(f.$fldname.value) > 0) {\n" .
352 " url += '&$field_id=' + encodeURIComponent(f.$fldname.value);\n" .
353 " }\n";
354 break;
355 case 2:
356 echo
357 " if (f.$fldname.style.backgroundColor != '' && f.$fldname.selectedIndex > 0) {\n" .
358 " url += '&$field_id=' + encodeURIComponent(f.$fldname.options[f.$fldname.selectedIndex].value);\n" .
359 " }\n";
360 break;
365 dlgopen(url, '_blank', 700, 500);
368 //-->
370 </script>
371 </head>
373 <body class="body_top">
375 <form action='new_comprehensive_save.php' name='demographics_form' method='post' onsubmit='return validate(this)'>
377 <span class='title'><?php xl('Search or Add Patient','e'); ?></span>
379 <table width='100%' cellpadding='0' cellspacing='8'>
380 <tr>
381 <td align='left' valign='top'>
382 <?php if ($SHORT_FORM) echo " <center>\n"; ?>
383 <?php
385 function end_cell() {
386 global $item_count, $cell_count;
387 if ($item_count > 0) {
388 echo "</td>";
389 $item_count = 0;
393 function end_row() {
394 global $cell_count, $CPR;
395 end_cell();
396 if ($cell_count > 0) {
397 for (; $cell_count < $CPR; ++$cell_count) echo "<td></td>";
398 echo "</tr>\n";
399 $cell_count = 0;
403 function end_group() {
404 global $last_group, $SHORT_FORM;
405 if (strlen($last_group) > 0) {
406 end_row();
407 echo " </table>\n";
408 if (!$SHORT_FORM) echo "</div>\n";
412 $last_group = '';
413 $cell_count = 0;
414 $item_count = 0;
415 $display_style = 'block';
416 $group_seq = 0; // this gives the DIV blocks unique IDs
418 while ($frow = sqlFetchArray($fres)) {
419 $this_group = $frow['group_name'];
420 $titlecols = $frow['titlecols'];
421 $datacols = $frow['datacols'];
422 $data_type = $frow['data_type'];
423 $field_id = $frow['field_id'];
424 $list_id = $frow['list_id'];
425 $currvalue = '';
427 if (strpos($field_id, 'em_') === 0) {
428 $tmp = substr($field_id, 3);
429 if (isset($result2[$tmp])) $currvalue = $result2[$tmp];
431 else {
432 if (isset($result[$field_id])) $currvalue = $result[$field_id];
435 // Handle a data category (group) change.
436 if (strcmp($this_group, $last_group) != 0) {
437 if (!$SHORT_FORM) {
438 end_group();
439 $group_seq++; // ID for DIV tags
440 $group_name = substr($this_group, 1);
441 if (strlen($last_group) > 0) echo "<br />";
442 echo "<span class='bold'><input type='checkbox' name='form_cb_$group_seq' id='form_cb_$group_seq' value='1' " .
443 "onclick='return divclick(this,\"div_$group_seq\");'";
444 if ($display_style == 'block') echo " checked";
446 // Modified 6-09 by BM - Translate if applicable
447 echo " /><b>" . xl_layout_label($group_name) . "</b></span>\n";
449 echo "<div id='div_$group_seq' class='section' style='display:$display_style;'>\n";
450 echo " <table border='0' cellpadding='0'>\n";
451 $display_style = 'none';
453 else if (strlen($last_group) == 0) {
454 echo " <table border='0' cellpadding='0'>\n";
456 $last_group = $this_group;
459 // Handle starting of a new row.
460 if (($titlecols > 0 && $cell_count >= $CPR) || $cell_count == 0) {
461 end_row();
462 echo " <tr>";
465 if ($item_count == 0 && $titlecols == 0) $titlecols = 1;
467 // Handle starting of a new label cell.
468 if ($titlecols > 0) {
469 end_cell();
470 echo "<td colspan='$titlecols'";
471 echo ($frow['uor'] == 2) ? " class='required'" : " class='bold'";
472 if ($cell_count == 2) echo " style='padding-left:10pt'";
473 echo ">";
474 $cell_count += $titlecols;
476 ++$item_count;
478 echo "<b>";
480 // Modified 6-09 by BM - Translate if applicable
481 if ($frow['title']) echo (xl_layout_label($frow['title']).":"); else echo "&nbsp;";
483 echo "</b>";
485 // Handle starting of a new data cell.
486 if ($datacols > 0) {
487 end_cell();
488 echo "<td colspan='$datacols' class='text'";
489 if ($cell_count > 0) echo " style='padding-left:5pt'";
490 echo ">";
491 $cell_count += $datacols;
494 ++$item_count;
495 generate_form_field($frow, $currvalue);
498 end_group();
501 <?php
502 if (! $GLOBALS['simplified_demographics']) {
503 $insurancei = getInsuranceProviders();
504 $pid = 0;
505 $insurance_headings = array(xl("Primary Insurance Provider"), xl("Secondary Insurance Provider"), xl("Tertiary Insurance provider"));
506 $insurance_info = array();
507 $insurance_info[1] = getInsuranceData($pid,"primary");
508 $insurance_info[2] = getInsuranceData($pid,"secondary");
509 $insurance_info[3] = getInsuranceData($pid,"tertiary");
511 echo "<br /><span class='bold'><input type='checkbox' name='form_cb_ins' value='1' " .
512 "onclick='return divclick(this,\"div_ins\");'";
513 if ($display_style == 'block') echo " checked";
514 echo " /><b>" . xl('Insurance') . "</b></span>\n";
515 echo "<div id='div_ins' class='section' style='display:$display_style;'>\n";
517 for($i=1;$i<=3;$i++) {
518 $result3 = $insurance_info[$i];
520 <table border="0">
521 <tr>
522 <td valign='top' colspan='2'>
523 <span class='required'><?php echo $insurance_headings[$i -1].":"?></span>
524 <select name="i<?php echo $i?>provider">
525 <option value=""><?php xl('Unassigned','e'); ?></option>
526 <?php
527 foreach ($insurancei as $iid => $iname) {
528 echo "<option value='" . $iid . "'";
529 if (strtolower($iid) == strtolower($result3{"provider"}))
530 echo " selected";
531 echo ">" . $iname . "</option>\n";
534 </select>&nbsp;<a href='' onclick='return ins_search(<?php echo $i?>)'>
535 <?php xl('Search/Add Insurer','e'); ?></a>
536 </td>
537 </tr>
538 <tr>
539 <td valign=top>
540 <table border="0">
542 <tr>
543 <td>
544 <span class='required'><?php xl('Plan Name','e'); ?>: </span>
545 </td>
546 <td>
547 <input type='entry' size='20' name='i<?php echo $i?>plan_name' value="<?php echo $result3{"plan_name"} ?>"
548 onchange="capitalizeMe(this);" />&nbsp;&nbsp;
549 </td>
550 </tr>
552 <tr>
553 <td>
554 <span class='required'><?php xl('Effective Date','e'); ?>: </span>
555 </td>
556 <td>
557 <input type='entry' size='11' name='i<?php echo $i ?>effective_date'
558 id='i<?php echo $i ?>effective_date'
559 value='<?php echo $result3['date'] ?>'
560 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)'
561 title='yyyy-mm-dd' />
563 <img src='../../interface/pic/show_calendar.gif' align='absbottom' width='24' height='22'
564 id='img_i<?php echo $i ?>effective_date' border='0' alt='[?]' style='cursor:pointer'
565 title='<?php xl('Click here to choose a date','e'); ?>'>
567 <script LANGUAGE="JavaScript">
568 Calendar.setup({inputField:"i<?php echo $i ?>effective_date", ifFormat:"%Y-%m-%d", button:"img_i<?php echo $i; ?>effective_date"});
569 </script>
572 </td>
573 </tr>
575 <tr>
576 <td><span class=required><?php xl('Policy Number','e'); ?>: </span></td>
577 <td><input type='entry' size='16' name='i<?php echo $i?>policy_number' value="<?php echo $result3{"policy_number"}?>"
578 onkeyup='policykeyup(this)'></td>
579 </tr>
581 <tr>
582 <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>
583 </tr>
585 <tr<?php if ($GLOBALS['omit_employers']) echo " style='display:none'"; ?>>
586 <td class='required'><?php xl('Subscriber Employer (SE)','e'); ?><br><span style='font-weight:normal'>
587 (<?php xl('if unemployed enter Student','e'); ?>,<br><?php xl('PT Student, or leave blank','e'); ?>): </span></td>
588 <td><input type=entry size=25 name=i<?php echo $i?>subscriber_employer
589 value="<?php echo $result3{"subscriber_employer"}?>"
590 onchange="capitalizeMe(this);" /></td>
591 </tr>
593 <tr<?php if ($GLOBALS['omit_employers']) echo " style='display:none'"; ?>>
594 <td><span class=required><?php xl('SE Address','e'); ?>: </span></td>
595 <td><input type=entry size=25 name=i<?php echo $i?>subscriber_employer_street
596 value="<?php echo $result3{"subscriber_employer_street"}?>"
597 onchange="capitalizeMe(this);" /></td>
598 </tr>
600 <tr<?php if ($GLOBALS['omit_employers']) echo " style='display:none'"; ?>>
601 <td colspan="2">
602 <table>
603 <tr>
604 <td><span class=required><?php xl('SE City','e'); ?>: </span></td>
605 <td><input type=entry size=15 name=i<?php echo $i?>subscriber_employer_city
606 value="<?php echo $result3{"subscriber_employer_city"}?>"
607 onchange="capitalizeMe(this);" /></td>
608 <td><span class=required><?php echo ($GLOBALS['phone_country_code'] == '1') ? xl('SE State','e') : xl('SE Locality','e') ?>: </span></td>
609 <td>
610 <?php
611 // Modified 7/2009 by BM to incorporate data types
612 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']);
614 </td>
615 </tr>
616 <tr>
617 <td><span class=required><?php echo ($GLOBALS['phone_country_code'] == '1') ? xl('SE Zip Code','e') : xl('SE Postal Code','e') ?>: </span></td>
618 <td><input type=entry size=10 name=i<?php echo $i?>subscriber_employer_postal_code value="<?php echo $result3{"subscriber_employer_postal_code"}?>"></td>
619 <td><span class=required><?php xl('SE Country','e'); ?>: </span></td>
620 <td>
621 <?php
622 // Modified 7/2009 by BM to incorporate data types
623 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']);
625 </td>
626 </tr>
627 </table>
628 </td>
629 </tr>
631 </table>
632 </td>
634 <td valign=top>
635 <span class=required><?php xl('Subscriber','e'); ?>: </span>
636 <input type=entry size=10 name=i<?php echo $i?>subscriber_fname
637 value="<?php echo $result3{"subscriber_fname"}?>"
638 onchange="capitalizeMe(this);" />
639 <input type=entry size=3 name=i<?php echo $i?>subscriber_mname
640 value="<?php echo $result3{"subscriber_mname"}?>"
641 onchange="capitalizeMe(this);" />
642 <input type=entry size=10 name=i<?php echo $i?>subscriber_lname
643 value="<?php echo $result3{"subscriber_lname"}?>"
644 onchange="capitalizeMe(this);" />
645 <br>
646 <span class=required><?php xl('Relationship','e'); ?>: </span>
647 <?php
648 // Modified 6/2009 by BM to use list_options and function
649 generate_form_field(array('data_type'=>1,'field_id'=>('i'.$i.'subscriber_relationship'),'list_id'=>'sub_relation','empty_title'=>' '), $result3['subscriber_relationship']);
651 <a href="javascript:popUp('../../interface/patient_file/summary/browse.php?browsenum=<?php echo $i?>')" class=text>(<?php xl('Browse','e'); ?>)</a><br />
653 <span class=bold><?php xl('D.O.B.','e'); ?>: </span>
654 <input type='entry' size='11' name='i<?php echo $i?>subscriber_DOB'
655 id='i<?php echo $i?>subscriber_DOB'
656 value='<?php echo $result3['subscriber_DOB'] ?>'
657 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)'
658 title='yyyy-mm-dd' />
660 <img src='../../interface/pic/show_calendar.gif' align='absbottom' width='24' height='22'
661 id='img_i<?php echo $i; ?>dob_date' border='0' alt='[?]' style='cursor:pointer'
662 title='<?php xl('Click here to choose a date','e'); ?>'>
664 <script LANGUAGE="JavaScript">
665 Calendar.setup({inputField:"i<?php echo $i?>subscriber_DOB", ifFormat:"%Y-%m-%d", button:"img_i<?php echo $i; ?>dob_date"});
666 </script>
669 <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;
670 <span class=bold><?php xl('Sex','e'); ?>: </span>
671 <?php
672 // Modified 6/2009 by BM to use list_options and function
673 generate_form_field(array('data_type'=>1,'field_id'=>('i'.$i.'subscriber_sex'),'list_id'=>'sex'), $result3['subscriber_sex']);
675 <br>
676 <span class=required><?php xl('Subscriber Address','e'); ?>: </span>
677 <input type=entry size=25 name=i<?php echo $i?>subscriber_street
678 value="<?php echo $result3{"subscriber_street"}?>"
679 onchange="capitalizeMe(this);" /><br>
680 <span class=required><?php xl('City','e'); ?>: </span>
681 <input type=entry size=15 name=i<?php echo $i?>subscriber_city
682 value="<?php echo $result3{"subscriber_city"}?>"
683 onchange="capitalizeMe(this);" />
684 <span class=required><?php echo ($GLOBALS['phone_country_code'] == '1') ? xl('State','e') : xl('Locality','e') ?>: </span>
685 <?php
686 // Modified 7/2009 by BM to incorporate data types
687 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']);
689 <br />
690 <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"}?>">
691 <span class='required'<?php if ($GLOBALS['omit_employers']) echo " style='display:none'"; ?>>
692 <?php xl('Country','e'); ?>: </span>
693 <?php
694 // Modified 7/2009 by BM to incorporate data types
695 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']);
697 <br />
698 <span class=bold><?php xl('Subscriber Phone','e'); ?>:
699 <input type='text' size='20' name='i<?php echo $i?>subscriber_phone' value='<?php echo $result3["subscriber_phone"] ?>' onkeyup='phonekeyup(this,mypcc)' />
700 </span><br />
701 <span class=bold><?php xl('CoPay','e'); ?>: <input type=text size="6" name=i<?php echo $i?>copay value="<?php echo $result3{"copay"}?>">
702 </span><br />
703 <span class='required'><?php xl('Accept Assignment','e'); ?>: </span>
704 <select name=i<?php echo $i?>accept_assignment>
705 <option value="TRUE" <?php if (strtoupper($result3{"accept_assignment"}) == "TRUE") echo "selected"?>><?php xl('YES','e'); ?></option>
706 <option value="FALSE" <?php if (strtoupper($result3{"accept_assignment"}) == "FALSE") echo "selected"?>><?php xl('NO','e'); ?></option>
707 </select>
708 </td>
709 </tr>
711 </table>
712 <hr />
713 <?php
715 echo "</div>\n";
716 } // end of "if not simplified_demographics"
719 <?php if (!$SHORT_FORM) echo " <center>\n"; ?>
720 <br />
721 <?php if ($WITH_SEARCH) { ?>
722 <input type="button" id="search" value=<?php xl('Search','e','\'','\''); ?>
723 style='background-color:<?php echo $searchcolor; ?>' />
724 &nbsp;&nbsp;
725 <?php } ?>
726 <input type="button" name='create' id="create" value=<?php xl('Create New Patient','e','\'','\''); ?> />
728 </center>
730 </td>
731 <td align='right' valign='top' width='1%' nowrap>
732 <!-- Image upload stuff was here but got moved. -->
733 </td>
734 </tr>
735 </table>
737 </form>
739 <!-- include support for the list-add selectbox feature -->
740 <?php include($GLOBALS['fileroot']."/library/options_listadd.inc"); ?>
742 </body>
744 <script language="JavaScript">
746 // fix inconsistently formatted phone numbers from the database
747 var f = document.forms[0];
748 if (f.form_phone_contact) phonekeyup(f.form_phone_contact,mypcc);
749 if (f.form_phone_home ) phonekeyup(f.form_phone_home ,mypcc);
750 if (f.form_phone_biz ) phonekeyup(f.form_phone_biz ,mypcc);
751 if (f.form_phone_cell ) phonekeyup(f.form_phone_cell ,mypcc);
753 <?php echo $date_init; ?>
755 // -=- jQuery makes life easier -=-
757 // var matches = 0; // number of patients that match the demographic information being entered
758 // var override = false; // flag that overrides the duplication warning
760 $(document).ready(function() {
762 // added to integrate insurance stuff
763 <?php for ($i=1;$i<=3;$i++) { ?>
764 $("#form_i<?php echo $i?>subscriber_relationship").change(function() { auto_populate_employer_address<?php echo $i?>(); });
765 <?php } ?>
767 $('#search').click(function() { searchme(); });
768 $('#create').click(function() { submitme(); });
770 var submitme = function() {
771 top.restoreSession();
772 var f = document.forms[0];
774 if (validate(f)) {
775 if (force_submit) {
776 // In this case dups were shown already and Save should just save.
777 f.submit();
778 return;
780 <?php
781 // D in edit_options indicates the field is used in duplication checking.
782 // This constructs a list of the names of those fields.
783 $mflist = "";
784 $mfres = sqlStatement("SELECT * FROM layout_options " .
785 "WHERE form_id = 'DEM' AND uor > 0 AND field_id != '' AND " .
786 "edit_options LIKE '%D%' " .
787 "ORDER BY group_name, seq");
788 while ($mfrow = sqlFetchArray($mfres)) {
789 $field_id = $mfrow['field_id'];
790 if (strpos($field_id, 'em_') === 0) continue;
791 if (!empty($mflist)) $mflist .= ",";
792 $mflist .= "'" . htmlentities($field_id) . "'";
795 // Build and invoke the URL to create the dup-checker dialog.
796 var url = 'new_search_popup.php';
797 var flds = new Array(<?php echo $mflist; ?>);
798 var separator = '?';
799 for (var i = 0; i < flds.length; ++i) {
800 var fval = $('#form_' + flds[i]).val();
801 if (fval && fval != '') {
802 url += separator;
803 separator = '&';
804 url += 'mf_' + flds[i] + '=' + encodeURIComponent(fval);
807 dlgopen(url, '_blank', 700, 500);
809 } // end if validate
810 } // end function
812 // Set onclick/onfocus handlers for toggling background color.
813 <?php
814 $lres = getLayoutRes();
815 while ($lrow = sqlFetchArray($lres)) {
816 $field_id = $lrow['field_id'];
817 if (strpos($field_id, 'em_') === 0) continue;
818 switch(getSearchClass($lrow['data_type'])) {
819 case 1:
820 echo " \$('#form_$field_id').click(function() { toggleSearch(this); });\n";
821 break;
822 case 2:
823 echo " \$('#form_$field_id').click(function() { selClick(this); });\n";
824 echo " \$('#form_$field_id').blur(function() { selBlur(this); });\n";
825 break;
830 }); // end document.ready
832 </script>
834 </html>