Missing quotes in acl check in new_comprehensive.php
[openemr.git] / interface / new / new_comprehensive.php
blob6276e517a08f420f7afafb09d3b45835cc7c1c02
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 for (var i = 0; i < v.length; ++i) {
216 var c = v.charAt(i);
217 if (c >= '0' && c <= '9') continue;
218 if (c >= 'A' && c <= 'Z') continue;
219 if (c == '*') continue;
220 if (c == '-') continue;
221 if (c == '_') continue;
222 if (c == '(') continue;
223 if (c == ')') continue;
224 if (c == '#') continue;
225 v = v.substring(0, i) + v.substring(i + i);
226 --i;
228 e.value = v;
229 return;
232 function divclick(cb, divid) {
233 var divstyle = document.getElementById(divid).style;
234 if (cb.checked) {
235 divstyle.display = 'block';
236 } else {
237 divstyle.display = 'none';
239 return true;
242 // Compute the length of a string without leading and trailing spaces.
243 function trimlen(s) {
244 var i = 0;
245 var j = s.length - 1;
246 for (; i <= j && s.charAt(i) == ' '; ++i);
247 for (; i <= j && s.charAt(j) == ' '; --j);
248 if (i > j) return 0;
249 return j + 1 - i;
252 function validate(f) {
253 var errMsgs = new Array();
254 <?php generate_layout_validation('DEM'); ?>
255 <?php if($GLOBALS['erx_enable']){ ?>
256 alertMsg='';
257 for(i=0;i<f.length;i++){
258 if(f[i].type=='text' && f[i].value)
260 if(f[i].name == 'form_fname' || f[i].name == 'form_mname' || f[i].name == 'form_lname')
262 alertMsg += checkLength(f[i].name,f[i].value,35);
263 alertMsg += checkUsername(f[i].name,f[i].value);
265 else if(f[i].name == 'form_street' || f[i].name == 'form_city')
267 alertMsg += checkLength(f[i].name,f[i].value,35);
268 alertMsg += checkAlphaNumericExtended(f[i].name,f[i].value);
270 else if(f[i].name == 'form_phone_home')
272 alertMsg += checkPhone(f[i].name,f[i].value);
276 if(alertMsg)
278 alert(alertMsg);
279 return false;
281 <?php } ?>
282 var msg = "";
283 msg += "<?php echo htmlspecialchars(xl('The following fields are required'),ENT_QUOTES); ?>:\n\n";
284 for ( var i = 0; i < errMsgs.length; i++ ) {
285 msg += errMsgs[i] + "\n";
287 msg += "\n<?php echo htmlspecialchars(xl('Please fill them in before continuing.'),ENT_QUOTES); ?>";
289 if ( errMsgs.length > 0 ) {
290 alert(msg);
291 return false;
293 return true;
296 function toggleSearch(elem) {
297 var f = document.forms[0];
298 <?php if ($WITH_SEARCH) { ?>
299 // Toggle background color.
300 if (elem.style.backgroundColor == '')
301 elem.style.backgroundColor = '<?php echo $searchcolor; ?>';
302 else
303 elem.style.backgroundColor = '';
304 <?php } ?>
305 if (force_submit) {
306 force_submit = false;
307 f.create.value = '<?php xl('Create New Patient','e'); ?>';
309 return true;
312 // If a <select> list is dropped down, this is its name.
313 var open_sel_name = '';
315 function selClick(elem) {
316 if (open_sel_name == elem.name) {
317 open_sel_name = '';
319 else {
320 open_sel_name = elem.name;
321 toggleSearch(elem);
323 return true;
326 function selBlur(elem) {
327 if (open_sel_name == elem.name) {
328 open_sel_name = '';
330 return true;
333 // This invokes the patient search dialog.
334 function searchme() {
335 var f = document.forms[0];
336 var url = '../main/finder/patient_select.php?popup=1';
338 <?php
339 $lres = getLayoutRes();
341 while ($lrow = sqlFetchArray($lres)) {
342 $field_id = $lrow['field_id'];
343 if (strpos($field_id, 'em_') === 0) continue;
344 $data_type = $lrow['data_type'];
345 $fldname = "form_$field_id";
346 switch(getSearchClass($data_type)) {
347 case 1:
348 echo
349 " if (f.$fldname.style.backgroundColor != '' && trimlen(f.$fldname.value) > 0) {\n" .
350 " url += '&$field_id=' + encodeURIComponent(f.$fldname.value);\n" .
351 " }\n";
352 break;
353 case 2:
354 echo
355 " if (f.$fldname.style.backgroundColor != '' && f.$fldname.selectedIndex > 0) {\n" .
356 " url += '&$field_id=' + encodeURIComponent(f.$fldname.options[f.$fldname.selectedIndex].value);\n" .
357 " }\n";
358 break;
363 dlgopen(url, '_blank', 700, 500);
366 //-->
368 </script>
369 </head>
371 <body class="body_top">
373 <form action='new_comprehensive_save.php' name='demographics_form' method='post' onsubmit='return validate(this)'>
375 <span class='title'><?php xl('Search or Add Patient','e'); ?></span>
377 <table width='100%' cellpadding='0' cellspacing='8'>
378 <tr>
379 <td align='left' valign='top'>
380 <?php if ($SHORT_FORM) echo " <center>\n"; ?>
381 <?php
383 function end_cell() {
384 global $item_count, $cell_count;
385 if ($item_count > 0) {
386 echo "</td>";
387 $item_count = 0;
391 function end_row() {
392 global $cell_count, $CPR;
393 end_cell();
394 if ($cell_count > 0) {
395 for (; $cell_count < $CPR; ++$cell_count) echo "<td></td>";
396 echo "</tr>\n";
397 $cell_count = 0;
401 function end_group() {
402 global $last_group, $SHORT_FORM;
403 if (strlen($last_group) > 0) {
404 end_row();
405 echo " </table>\n";
406 if (!$SHORT_FORM) echo "</div>\n";
410 $last_group = '';
411 $cell_count = 0;
412 $item_count = 0;
413 $display_style = 'block';
414 $group_seq = 0; // this gives the DIV blocks unique IDs
416 while ($frow = sqlFetchArray($fres)) {
417 $this_group = $frow['group_name'];
418 $titlecols = $frow['titlecols'];
419 $datacols = $frow['datacols'];
420 $data_type = $frow['data_type'];
421 $field_id = $frow['field_id'];
422 $list_id = $frow['list_id'];
423 $currvalue = '';
425 if (strpos($field_id, 'em_') === 0) {
426 $tmp = substr($field_id, 3);
427 if (isset($result2[$tmp])) $currvalue = $result2[$tmp];
429 else {
430 if (isset($result[$field_id])) $currvalue = $result[$field_id];
433 // Handle a data category (group) change.
434 if (strcmp($this_group, $last_group) != 0) {
435 if (!$SHORT_FORM) {
436 end_group();
437 $group_seq++; // ID for DIV tags
438 $group_name = substr($this_group, 1);
439 if (strlen($last_group) > 0) echo "<br />";
440 echo "<span class='bold'><input type='checkbox' name='form_cb_$group_seq' id='form_cb_$group_seq' value='1' " .
441 "onclick='return divclick(this,\"div_$group_seq\");'";
442 if ($display_style == 'block') echo " checked";
444 // Modified 6-09 by BM - Translate if applicable
445 echo " /><b>" . xl_layout_label($group_name) . "</b></span>\n";
447 echo "<div id='div_$group_seq' class='section' style='display:$display_style;'>\n";
448 echo " <table border='0' cellpadding='0'>\n";
449 $display_style = 'none';
451 else if (strlen($last_group) == 0) {
452 echo " <table border='0' cellpadding='0'>\n";
454 $last_group = $this_group;
457 // Handle starting of a new row.
458 if (($titlecols > 0 && $cell_count >= $CPR) || $cell_count == 0) {
459 end_row();
460 echo " <tr>";
463 if ($item_count == 0 && $titlecols == 0) $titlecols = 1;
465 // Handle starting of a new label cell.
466 if ($titlecols > 0) {
467 end_cell();
468 echo "<td colspan='$titlecols'";
469 echo ($frow['uor'] == 2) ? " class='required'" : " class='bold'";
470 if ($cell_count == 2) echo " style='padding-left:10pt'";
471 echo ">";
472 $cell_count += $titlecols;
474 ++$item_count;
476 echo "<b>";
478 // Modified 6-09 by BM - Translate if applicable
479 if ($frow['title']) echo (xl_layout_label($frow['title']).":"); else echo "&nbsp;";
481 echo "</b>";
483 // Handle starting of a new data cell.
484 if ($datacols > 0) {
485 end_cell();
486 echo "<td colspan='$datacols' class='text'";
487 if ($cell_count > 0) echo " style='padding-left:5pt'";
488 echo ">";
489 $cell_count += $datacols;
492 ++$item_count;
493 generate_form_field($frow, $currvalue);
496 end_group();
499 <?php
500 if (! $GLOBALS['simplified_demographics']) {
501 $insurancei = getInsuranceProviders();
502 $pid = 0;
503 $insurance_headings = array(xl("Primary Insurance Provider"), xl("Secondary Insurance Provider"), xl("Tertiary Insurance provider"));
504 $insurance_info = array();
505 $insurance_info[1] = getInsuranceData($pid,"primary");
506 $insurance_info[2] = getInsuranceData($pid,"secondary");
507 $insurance_info[3] = getInsuranceData($pid,"tertiary");
509 echo "<br /><span class='bold'><input type='checkbox' name='form_cb_ins' value='1' " .
510 "onclick='return divclick(this,\"div_ins\");'";
511 if ($display_style == 'block') echo " checked";
512 echo " /><b>" . xl('Insurance') . "</b></span>\n";
513 echo "<div id='div_ins' class='section' style='display:$display_style;'>\n";
515 for($i=1;$i<=3;$i++) {
516 $result3 = $insurance_info[$i];
518 <table border="0">
519 <tr>
520 <td valign='top' colspan='2'>
521 <span class='required'><?php echo $insurance_headings[$i -1].":"?></span>
522 <select name="i<?php echo $i?>provider">
523 <option value=""><?php xl('Unassigned','e'); ?></option>
524 <?php
525 foreach ($insurancei as $iid => $iname) {
526 echo "<option value='" . $iid . "'";
527 if (strtolower($iid) == strtolower($result3{"provider"}))
528 echo " selected";
529 echo ">" . $iname . "</option>\n";
532 </select>&nbsp;<a href='' onclick='return ins_search(<?php echo $i?>)'>
533 <?php xl('Search/Add Insurer','e'); ?></a>
534 </td>
535 </tr>
536 <tr>
537 <td valign=top>
538 <table border="0">
540 <tr>
541 <td>
542 <span class='required'><?php xl('Plan Name','e'); ?>: </span>
543 </td>
544 <td>
545 <input type='entry' size='20' name='i<?php echo $i?>plan_name' value="<?php echo $result3{"plan_name"} ?>"
546 onchange="capitalizeMe(this);" />&nbsp;&nbsp;
547 </td>
548 </tr>
550 <tr>
551 <td>
552 <span class='required'><?php xl('Effective Date','e'); ?>: </span>
553 </td>
554 <td>
555 <input type='entry' size='11' name='i<?php echo $i ?>effective_date'
556 id='i<?php echo $i ?>effective_date'
557 value='<?php echo $result3['date'] ?>'
558 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)'
559 title='yyyy-mm-dd' />
561 <img src='../../interface/pic/show_calendar.gif' align='absbottom' width='24' height='22'
562 id='img_i<?php echo $i ?>effective_date' border='0' alt='[?]' style='cursor:pointer'
563 title='<?php xl('Click here to choose a date','e'); ?>'>
565 <script LANGUAGE="JavaScript">
566 Calendar.setup({inputField:"i<?php echo $i ?>effective_date", ifFormat:"%Y-%m-%d", button:"img_i<?php echo $i; ?>effective_date"});
567 </script>
570 </td>
571 </tr>
573 <tr>
574 <td><span class=required><?php xl('Policy Number','e'); ?>: </span></td>
575 <td><input type='entry' size='16' name='i<?php echo $i?>policy_number' value="<?php echo $result3{"policy_number"}?>"
576 onkeyup='policykeyup(this)'></td>
577 </tr>
579 <tr>
580 <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>
581 </tr>
583 <tr<?php if ($GLOBALS['omit_employers']) echo " style='display:none'"; ?>>
584 <td class='required'><?php xl('Subscriber Employer (SE)','e'); ?><br><span style='font-weight:normal'>
585 (<?php xl('if unemployed enter Student','e'); ?>,<br><?php xl('PT Student, or leave blank','e'); ?>): </span></td>
586 <td><input type=entry size=25 name=i<?php echo $i?>subscriber_employer
587 value="<?php echo $result3{"subscriber_employer"}?>"
588 onchange="capitalizeMe(this);" /></td>
589 </tr>
591 <tr<?php if ($GLOBALS['omit_employers']) echo " style='display:none'"; ?>>
592 <td><span class=required><?php xl('SE Address','e'); ?>: </span></td>
593 <td><input type=entry size=25 name=i<?php echo $i?>subscriber_employer_street
594 value="<?php echo $result3{"subscriber_employer_street"}?>"
595 onchange="capitalizeMe(this);" /></td>
596 </tr>
598 <tr<?php if ($GLOBALS['omit_employers']) echo " style='display:none'"; ?>>
599 <td colspan="2">
600 <table>
601 <tr>
602 <td><span class=required><?php xl('SE City','e'); ?>: </span></td>
603 <td><input type=entry size=15 name=i<?php echo $i?>subscriber_employer_city
604 value="<?php echo $result3{"subscriber_employer_city"}?>"
605 onchange="capitalizeMe(this);" /></td>
606 <td><span class=required><?php echo ($GLOBALS['phone_country_code'] == '1') ? xl('SE State','e') : xl('SE Locality','e') ?>: </span></td>
607 <td>
608 <?php
609 // Modified 7/2009 by BM to incorporate data types
610 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']);
612 </td>
613 </tr>
614 <tr>
615 <td><span class=required><?php echo ($GLOBALS['phone_country_code'] == '1') ? xl('SE Zip Code','e') : xl('SE Postal Code','e') ?>: </span></td>
616 <td><input type=entry size=10 name=i<?php echo $i?>subscriber_employer_postal_code value="<?php echo $result3{"subscriber_employer_postal_code"}?>"></td>
617 <td><span class=required><?php xl('SE Country','e'); ?>: </span></td>
618 <td>
619 <?php
620 // Modified 7/2009 by BM to incorporate data types
621 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']);
623 </td>
624 </tr>
625 </table>
626 </td>
627 </tr>
629 </table>
630 </td>
632 <td valign=top>
633 <span class=required><?php xl('Subscriber','e'); ?>: </span>
634 <input type=entry size=10 name=i<?php echo $i?>subscriber_fname
635 value="<?php echo $result3{"subscriber_fname"}?>"
636 onchange="capitalizeMe(this);" />
637 <input type=entry size=3 name=i<?php echo $i?>subscriber_mname
638 value="<?php echo $result3{"subscriber_mname"}?>"
639 onchange="capitalizeMe(this);" />
640 <input type=entry size=10 name=i<?php echo $i?>subscriber_lname
641 value="<?php echo $result3{"subscriber_lname"}?>"
642 onchange="capitalizeMe(this);" />
643 <br>
644 <span class=required><?php xl('Relationship','e'); ?>: </span>
645 <?php
646 // Modified 6/2009 by BM to use list_options and function
647 generate_form_field(array('data_type'=>1,'field_id'=>('i'.$i.'subscriber_relationship'),'list_id'=>'sub_relation','empty_title'=>' '), $result3['subscriber_relationship']);
649 <a href="javascript:popUp('../../interface/patient_file/summary/browse.php?browsenum=<?php echo $i?>')" class=text>(<?php xl('Browse','e'); ?>)</a><br />
651 <span class=bold><?php xl('D.O.B.','e'); ?>: </span>
652 <input type='entry' size='11' name='i<?php echo $i?>subscriber_DOB'
653 id='i<?php echo $i?>subscriber_DOB'
654 value='<?php echo $result3['subscriber_DOB'] ?>'
655 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)'
656 title='yyyy-mm-dd' />
658 <img src='../../interface/pic/show_calendar.gif' align='absbottom' width='24' height='22'
659 id='img_i<?php echo $i; ?>dob_date' border='0' alt='[?]' style='cursor:pointer'
660 title='<?php xl('Click here to choose a date','e'); ?>'>
662 <script LANGUAGE="JavaScript">
663 Calendar.setup({inputField:"i<?php echo $i?>subscriber_DOB", ifFormat:"%Y-%m-%d", button:"img_i<?php echo $i; ?>dob_date"});
664 </script>
667 <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;
668 <span class=bold><?php xl('Sex','e'); ?>: </span>
669 <?php
670 // Modified 6/2009 by BM to use list_options and function
671 generate_form_field(array('data_type'=>1,'field_id'=>('i'.$i.'subscriber_sex'),'list_id'=>'sex'), $result3['subscriber_sex']);
673 <br>
674 <span class=required><?php xl('Subscriber Address','e'); ?>: </span>
675 <input type=entry size=25 name=i<?php echo $i?>subscriber_street
676 value="<?php echo $result3{"subscriber_street"}?>"
677 onchange="capitalizeMe(this);" /><br>
678 <span class=required><?php xl('City','e'); ?>: </span>
679 <input type=entry size=15 name=i<?php echo $i?>subscriber_city
680 value="<?php echo $result3{"subscriber_city"}?>"
681 onchange="capitalizeMe(this);" />
682 <span class=required><?php echo ($GLOBALS['phone_country_code'] == '1') ? xl('State','e') : xl('Locality','e') ?>: </span>
683 <?php
684 // Modified 7/2009 by BM to incorporate data types
685 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']);
687 <br />
688 <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"}?>">
689 <span class='required'<?php if ($GLOBALS['omit_employers']) echo " style='display:none'"; ?>>
690 <?php xl('Country','e'); ?>: </span>
691 <?php
692 // Modified 7/2009 by BM to incorporate data types
693 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']);
695 <br />
696 <span class=bold><?php xl('Subscriber Phone','e'); ?>:
697 <input type='text' size='20' name='i<?php echo $i?>subscriber_phone' value='<?php echo $result3["subscriber_phone"] ?>' onkeyup='phonekeyup(this,mypcc)' />
698 </span><br />
699 <span class=bold><?php xl('CoPay','e'); ?>: <input type=text size="6" name=i<?php echo $i?>copay value="<?php echo $result3{"copay"}?>">
700 </span><br />
701 <span class='required'><?php xl('Accept Assignment','e'); ?>: </span>
702 <select name=i<?php echo $i?>accept_assignment>
703 <option value="TRUE" <?php if (strtoupper($result3{"accept_assignment"}) == "TRUE") echo "selected"?>><?php xl('YES','e'); ?></option>
704 <option value="FALSE" <?php if (strtoupper($result3{"accept_assignment"}) == "FALSE") echo "selected"?>><?php xl('NO','e'); ?></option>
705 </select>
706 </td>
707 </tr>
709 </table>
710 <hr />
711 <?php
713 echo "</div>\n";
714 } // end of "if not simplified_demographics"
717 <?php if (!$SHORT_FORM) echo " <center>\n"; ?>
718 <br />
719 <?php if ($WITH_SEARCH) { ?>
720 <input type="button" id="search" value=<?php xl('Search','e','\'','\''); ?>
721 style='background-color:<?php echo $searchcolor; ?>' />
722 &nbsp;&nbsp;
723 <?php } ?>
724 <input type="button" name='create' id="create" value=<?php xl('Create New Patient','e','\'','\''); ?> />
726 </center>
728 </td>
729 <td align='right' valign='top' width='1%' nowrap>
730 <!-- Image upload stuff was here but got moved. -->
731 </td>
732 </tr>
733 </table>
735 </form>
737 <!-- include support for the list-add selectbox feature -->
738 <?php include($GLOBALS['fileroot']."/library/options_listadd.inc"); ?>
740 </body>
742 <script language="JavaScript">
744 // fix inconsistently formatted phone numbers from the database
745 var f = document.forms[0];
746 if (f.form_phone_contact) phonekeyup(f.form_phone_contact,mypcc);
747 if (f.form_phone_home ) phonekeyup(f.form_phone_home ,mypcc);
748 if (f.form_phone_biz ) phonekeyup(f.form_phone_biz ,mypcc);
749 if (f.form_phone_cell ) phonekeyup(f.form_phone_cell ,mypcc);
751 <?php echo $date_init; ?>
753 // -=- jQuery makes life easier -=-
755 // var matches = 0; // number of patients that match the demographic information being entered
756 // var override = false; // flag that overrides the duplication warning
758 $(document).ready(function() {
760 // added to integrate insurance stuff
761 <?php for ($i=1;$i<=3;$i++) { ?>
762 $("#form_i<?php echo $i?>subscriber_relationship").change(function() { auto_populate_employer_address<?php echo $i?>(); });
763 <?php } ?>
765 $('#search').click(function() { searchme(); });
766 $('#create').click(function() { submitme(); });
768 var submitme = function() {
769 top.restoreSession();
770 var f = document.forms[0];
772 if (validate(f)) {
773 if (force_submit) {
774 // In this case dups were shown already and Save should just save.
775 f.submit();
776 return;
778 <?php
779 // D in edit_options indicates the field is used in duplication checking.
780 // This constructs a list of the names of those fields.
781 $mflist = "";
782 $mfres = sqlStatement("SELECT * FROM layout_options " .
783 "WHERE form_id = 'DEM' AND uor > 0 AND field_id != '' AND " .
784 "edit_options LIKE '%D%' " .
785 "ORDER BY group_name, seq");
786 while ($mfrow = sqlFetchArray($mfres)) {
787 $field_id = $mfrow['field_id'];
788 if (strpos($field_id, 'em_') === 0) continue;
789 if (!empty($mflist)) $mflist .= ",";
790 $mflist .= "'" . htmlentities($field_id) . "'";
793 // Build and invoke the URL to create the dup-checker dialog.
794 var url = 'new_search_popup.php';
795 var flds = new Array(<?php echo $mflist; ?>);
796 var separator = '?';
797 for (var i = 0; i < flds.length; ++i) {
798 var fval = $('#form_' + flds[i]).val();
799 if (fval && fval != '') {
800 url += separator;
801 separator = '&';
802 url += 'mf_' + flds[i] + '=' + encodeURIComponent(fval);
805 dlgopen(url, '_blank', 700, 500);
807 } // end if validate
808 } // end function
810 // Set onclick/onfocus handlers for toggling background color.
811 <?php
812 $lres = getLayoutRes();
813 while ($lrow = sqlFetchArray($lres)) {
814 $field_id = $lrow['field_id'];
815 if (strpos($field_id, 'em_') === 0) continue;
816 switch(getSearchClass($lrow['data_type'])) {
817 case 1:
818 echo " \$('#form_$field_id').click(function() { toggleSearch(this); });\n";
819 break;
820 case 2:
821 echo " \$('#form_$field_id').click(function() { selClick(this); });\n";
822 echo " \$('#form_$field_id').blur(function() { selBlur(this); });\n";
823 break;
828 }); // end document.ready
830 </script>
832 </html>