cd7f069a8a3b07dd8f92442c01f9e105580f6958
[openemr.git] / interface / new / new_comprehensive.php
blobcd7f069a8a3b07dd8f92442c01f9e105580f6958
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 <?php generate_layout_validation('DEM'); ?>
254 <?php if($GLOBALS['erx_enable']){ ?>
255 alertMsg='';
256 for(i=0;i<f.length;i++){
257 if(f[i].type=='text' && f[i].value)
259 if(f[i].name == 'form_fname' || f[i].name == 'form_mname' || f[i].name == 'form_lname')
261 alertMsg += checkLength(f[i].name,f[i].value,35);
262 alertMsg += checkUsername(f[i].name,f[i].value);
264 else if(f[i].name == 'form_street' || f[i].name == 'form_city')
266 alertMsg += checkLength(f[i].name,f[i].value,35);
267 alertMsg += checkAlphaNumericExtended(f[i].name,f[i].value);
269 else if(f[i].name == 'form_phone_home')
271 alertMsg += checkPhone(f[i].name,f[i].value);
275 if(alertMsg)
277 alert(alertMsg);
278 return false;
280 <?php } ?>
281 return true;
284 function toggleSearch(elem) {
285 var f = document.forms[0];
286 <?php if ($WITH_SEARCH) { ?>
287 // Toggle background color.
288 if (elem.style.backgroundColor == '')
289 elem.style.backgroundColor = '<?php echo $searchcolor; ?>';
290 else
291 elem.style.backgroundColor = '';
292 <?php } ?>
293 if (force_submit) {
294 force_submit = false;
295 f.create.value = '<?php xl('Create New Patient','e'); ?>';
297 return true;
300 // If a <select> list is dropped down, this is its name.
301 var open_sel_name = '';
303 function selClick(elem) {
304 if (open_sel_name == elem.name) {
305 open_sel_name = '';
307 else {
308 open_sel_name = elem.name;
309 toggleSearch(elem);
311 return true;
314 function selBlur(elem) {
315 if (open_sel_name == elem.name) {
316 open_sel_name = '';
318 return true;
321 // This invokes the patient search dialog.
322 function searchme() {
323 var f = document.forms[0];
324 var url = '../main/finder/patient_select.php?popup=1';
326 <?php
327 $lres = getLayoutRes();
329 while ($lrow = sqlFetchArray($lres)) {
330 $field_id = $lrow['field_id'];
331 if (strpos($field_id, 'em_') === 0) continue;
332 $data_type = $lrow['data_type'];
333 $fldname = "form_$field_id";
334 switch(getSearchClass($data_type)) {
335 case 1:
336 echo
337 " if (f.$fldname.style.backgroundColor != '' && trimlen(f.$fldname.value) > 0) {\n" .
338 " url += '&$field_id=' + encodeURIComponent(f.$fldname.value);\n" .
339 " }\n";
340 break;
341 case 2:
342 echo
343 " if (f.$fldname.style.backgroundColor != '' && f.$fldname.selectedIndex > 0) {\n" .
344 " url += '&$field_id=' + encodeURIComponent(f.$fldname.options[f.$fldname.selectedIndex].value);\n" .
345 " }\n";
346 break;
351 dlgopen(url, '_blank', 700, 500);
354 //-->
356 </script>
357 </head>
359 <body class="body_top">
361 <form action='new_comprehensive_save.php' name='demographics_form' method='post' onsubmit='return validate(this)'>
363 <span class='title'><?php xl('Search or Add Patient','e'); ?></span>
365 <table width='100%' cellpadding='0' cellspacing='8'>
366 <tr>
367 <td align='left' valign='top'>
368 <?php if ($SHORT_FORM) echo " <center>\n"; ?>
369 <?php
371 function end_cell() {
372 global $item_count, $cell_count;
373 if ($item_count > 0) {
374 echo "</td>";
375 $item_count = 0;
379 function end_row() {
380 global $cell_count, $CPR;
381 end_cell();
382 if ($cell_count > 0) {
383 for (; $cell_count < $CPR; ++$cell_count) echo "<td></td>";
384 echo "</tr>\n";
385 $cell_count = 0;
389 function end_group() {
390 global $last_group, $SHORT_FORM;
391 if (strlen($last_group) > 0) {
392 end_row();
393 echo " </table>\n";
394 if (!$SHORT_FORM) echo "</div>\n";
398 $last_group = '';
399 $cell_count = 0;
400 $item_count = 0;
401 $display_style = 'block';
402 $group_seq = 0; // this gives the DIV blocks unique IDs
404 while ($frow = sqlFetchArray($fres)) {
405 $this_group = $frow['group_name'];
406 $titlecols = $frow['titlecols'];
407 $datacols = $frow['datacols'];
408 $data_type = $frow['data_type'];
409 $field_id = $frow['field_id'];
410 $list_id = $frow['list_id'];
411 $currvalue = '';
413 if (strpos($field_id, 'em_') === 0) {
414 $tmp = substr($field_id, 3);
415 if (isset($result2[$tmp])) $currvalue = $result2[$tmp];
417 else {
418 if (isset($result[$field_id])) $currvalue = $result[$field_id];
421 // Handle a data category (group) change.
422 if (strcmp($this_group, $last_group) != 0) {
423 if (!$SHORT_FORM) {
424 end_group();
425 $group_seq++; // ID for DIV tags
426 $group_name = substr($this_group, 1);
427 if (strlen($last_group) > 0) echo "<br />";
428 echo "<span class='bold'><input type='checkbox' name='form_cb_$group_seq' id='form_cb_$group_seq' value='1' " .
429 "onclick='return divclick(this,\"div_$group_seq\");'";
430 if ($display_style == 'block') echo " checked";
432 // Modified 6-09 by BM - Translate if applicable
433 echo " /><b>" . xl_layout_label($group_name) . "</b></span>\n";
435 echo "<div id='div_$group_seq' class='section' style='display:$display_style;'>\n";
436 echo " <table border='0' cellpadding='0'>\n";
437 $display_style = 'none';
439 else if (strlen($last_group) == 0) {
440 echo " <table border='0' cellpadding='0'>\n";
442 $last_group = $this_group;
445 // Handle starting of a new row.
446 if (($titlecols > 0 && $cell_count >= $CPR) || $cell_count == 0) {
447 end_row();
448 echo " <tr>";
451 if ($item_count == 0 && $titlecols == 0) $titlecols = 1;
453 // Handle starting of a new label cell.
454 if ($titlecols > 0) {
455 end_cell();
456 echo "<td colspan='$titlecols'";
457 echo ($frow['uor'] == 2) ? " class='required'" : " class='bold'";
458 if ($cell_count == 2) echo " style='padding-left:10pt'";
459 echo ">";
460 $cell_count += $titlecols;
462 ++$item_count;
464 echo "<b>";
466 // Modified 6-09 by BM - Translate if applicable
467 if ($frow['title']) echo (xl_layout_label($frow['title']).":"); else echo "&nbsp;";
469 echo "</b>";
471 // Handle starting of a new data cell.
472 if ($datacols > 0) {
473 end_cell();
474 echo "<td colspan='$datacols' class='text'";
475 if ($cell_count > 0) echo " style='padding-left:5pt'";
476 echo ">";
477 $cell_count += $datacols;
480 ++$item_count;
481 generate_form_field($frow, $currvalue);
484 end_group();
487 <?php
488 if (! $GLOBALS['simplified_demographics']) {
489 $insurancei = getInsuranceProviders();
490 $pid = 0;
491 $insurance_headings = array(xl("Primary Insurance Provider"), xl("Secondary Insurance Provider"), xl("Tertiary Insurance provider"));
492 $insurance_info = array();
493 $insurance_info[1] = getInsuranceData($pid,"primary");
494 $insurance_info[2] = getInsuranceData($pid,"secondary");
495 $insurance_info[3] = getInsuranceData($pid,"tertiary");
497 echo "<br /><span class='bold'><input type='checkbox' name='form_cb_ins' value='1' " .
498 "onclick='return divclick(this,\"div_ins\");'";
499 if ($display_style == 'block') echo " checked";
500 echo " /><b>" . xl('Insurance') . "</b></span>\n";
501 echo "<div id='div_ins' class='section' style='display:$display_style;'>\n";
503 for($i=1;$i<=3;$i++) {
504 $result3 = $insurance_info[$i];
506 <table border="0">
507 <tr>
508 <td valign='top' colspan='2'>
509 <span class='required'><?php echo $insurance_headings[$i -1].":"?></span>
510 <select name="i<?php echo $i?>provider">
511 <option value=""><?php xl('Unassigned','e'); ?></option>
512 <?php
513 foreach ($insurancei as $iid => $iname) {
514 echo "<option value='" . $iid . "'";
515 if (strtolower($iid) == strtolower($result3{"provider"}))
516 echo " selected";
517 echo ">" . $iname . "</option>\n";
520 </select>&nbsp;<a href='' onclick='return ins_search(<?php echo $i?>)'>
521 <?php xl('Search/Add Insurer','e'); ?></a>
522 </td>
523 </tr>
524 <tr>
525 <td valign=top>
526 <table border="0">
528 <tr>
529 <td>
530 <span class='required'><?php xl('Plan Name','e'); ?>: </span>
531 </td>
532 <td>
533 <input type='entry' size='20' name='i<?php echo $i?>plan_name' value="<?php echo $result3{"plan_name"} ?>"
534 onchange="capitalizeMe(this);" />&nbsp;&nbsp;
535 </td>
536 </tr>
538 <tr>
539 <td>
540 <span class='required'><?php xl('Effective Date','e'); ?>: </span>
541 </td>
542 <td>
543 <input type='entry' size='11' name='i<?php echo $i ?>effective_date'
544 id='i<?php echo $i ?>effective_date'
545 value='<?php echo $result3['date'] ?>'
546 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)'
547 title='yyyy-mm-dd' />
549 <img src='../../interface/pic/show_calendar.gif' align='absbottom' width='24' height='22'
550 id='img_i<?php echo $i ?>effective_date' border='0' alt='[?]' style='cursor:pointer'
551 title='<?php xl('Click here to choose a date','e'); ?>'>
553 <script LANGUAGE="JavaScript">
554 Calendar.setup({inputField:"i<?php echo $i ?>effective_date", ifFormat:"%Y-%m-%d", button:"img_i<?php echo $i; ?>effective_date"});
555 </script>
558 </td>
559 </tr>
561 <tr>
562 <td><span class=required><?php xl('Policy Number','e'); ?>: </span></td>
563 <td><input type='entry' size='16' name='i<?php echo $i?>policy_number' value="<?php echo $result3{"policy_number"}?>"
564 onkeyup='policykeyup(this)'></td>
565 </tr>
567 <tr>
568 <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>
569 </tr>
571 <tr<?php if ($GLOBALS['omit_employers']) echo " style='display:none'"; ?>>
572 <td class='required'><?php xl('Subscriber Employer (SE)','e'); ?><br><span style='font-weight:normal'>
573 (<?php xl('if unemployed enter Student','e'); ?>,<br><?php xl('PT Student, or leave blank','e'); ?>): </span></td>
574 <td><input type=entry size=25 name=i<?php echo $i?>subscriber_employer
575 value="<?php echo $result3{"subscriber_employer"}?>"
576 onchange="capitalizeMe(this);" /></td>
577 </tr>
579 <tr<?php if ($GLOBALS['omit_employers']) echo " style='display:none'"; ?>>
580 <td><span class=required><?php xl('SE Address','e'); ?>: </span></td>
581 <td><input type=entry size=25 name=i<?php echo $i?>subscriber_employer_street
582 value="<?php echo $result3{"subscriber_employer_street"}?>"
583 onchange="capitalizeMe(this);" /></td>
584 </tr>
586 <tr<?php if ($GLOBALS['omit_employers']) echo " style='display:none'"; ?>>
587 <td colspan="2">
588 <table>
589 <tr>
590 <td><span class=required><?php xl('SE City','e'); ?>: </span></td>
591 <td><input type=entry size=15 name=i<?php echo $i?>subscriber_employer_city
592 value="<?php echo $result3{"subscriber_employer_city"}?>"
593 onchange="capitalizeMe(this);" /></td>
594 <td><span class=required><?php echo ($GLOBALS['phone_country_code'] == '1') ? xl('SE State','e') : xl('SE Locality','e') ?>: </span></td>
595 <td>
596 <?php
597 // Modified 7/2009 by BM to incorporate data types
598 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']);
600 </td>
601 </tr>
602 <tr>
603 <td><span class=required><?php echo ($GLOBALS['phone_country_code'] == '1') ? xl('SE Zip Code','e') : xl('SE Postal Code','e') ?>: </span></td>
604 <td><input type=entry size=10 name=i<?php echo $i?>subscriber_employer_postal_code value="<?php echo $result3{"subscriber_employer_postal_code"}?>"></td>
605 <td><span class=required><?php xl('SE Country','e'); ?>: </span></td>
606 <td>
607 <?php
608 // Modified 7/2009 by BM to incorporate data types
609 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']);
611 </td>
612 </tr>
613 </table>
614 </td>
615 </tr>
617 </table>
618 </td>
620 <td valign=top>
621 <span class=required><?php xl('Subscriber','e'); ?>: </span>
622 <input type=entry size=10 name=i<?php echo $i?>subscriber_fname
623 value="<?php echo $result3{"subscriber_fname"}?>"
624 onchange="capitalizeMe(this);" />
625 <input type=entry size=3 name=i<?php echo $i?>subscriber_mname
626 value="<?php echo $result3{"subscriber_mname"}?>"
627 onchange="capitalizeMe(this);" />
628 <input type=entry size=10 name=i<?php echo $i?>subscriber_lname
629 value="<?php echo $result3{"subscriber_lname"}?>"
630 onchange="capitalizeMe(this);" />
631 <br>
632 <span class=required><?php xl('Relationship','e'); ?>: </span>
633 <?php
634 // Modified 6/2009 by BM to use list_options and function
635 generate_form_field(array('data_type'=>1,'field_id'=>('i'.$i.'subscriber_relationship'),'list_id'=>'sub_relation','empty_title'=>' '), $result3['subscriber_relationship']);
637 <a href="javascript:popUp('../../interface/patient_file/summary/browse.php?browsenum=<?php echo $i?>')" class=text>(<?php xl('Browse','e'); ?>)</a><br />
639 <span class=bold><?php xl('D.O.B.','e'); ?>: </span>
640 <input type='entry' size='11' name='i<?php echo $i?>subscriber_DOB'
641 id='i<?php echo $i?>subscriber_DOB'
642 value='<?php echo $result3['subscriber_DOB'] ?>'
643 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)'
644 title='yyyy-mm-dd' />
646 <img src='../../interface/pic/show_calendar.gif' align='absbottom' width='24' height='22'
647 id='img_i<?php echo $i; ?>dob_date' border='0' alt='[?]' style='cursor:pointer'
648 title='<?php xl('Click here to choose a date','e'); ?>'>
650 <script LANGUAGE="JavaScript">
651 Calendar.setup({inputField:"i<?php echo $i?>subscriber_DOB", ifFormat:"%Y-%m-%d", button:"img_i<?php echo $i; ?>dob_date"});
652 </script>
655 <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;
656 <span class=bold><?php xl('Sex','e'); ?>: </span>
657 <?php
658 // Modified 6/2009 by BM to use list_options and function
659 generate_form_field(array('data_type'=>1,'field_id'=>('i'.$i.'subscriber_sex'),'list_id'=>'sex'), $result3['subscriber_sex']);
661 <br>
662 <span class=required><?php xl('Subscriber Address','e'); ?>: </span>
663 <input type=entry size=25 name=i<?php echo $i?>subscriber_street
664 value="<?php echo $result3{"subscriber_street"}?>"
665 onchange="capitalizeMe(this);" /><br>
666 <span class=required><?php xl('City','e'); ?>: </span>
667 <input type=entry size=15 name=i<?php echo $i?>subscriber_city
668 value="<?php echo $result3{"subscriber_city"}?>"
669 onchange="capitalizeMe(this);" />
670 <span class=required><?php echo ($GLOBALS['phone_country_code'] == '1') ? xl('State','e') : xl('Locality','e') ?>: </span>
671 <?php
672 // Modified 7/2009 by BM to incorporate data types
673 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']);
675 <br />
676 <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"}?>">
677 <span class='required'<?php if ($GLOBALS['omit_employers']) echo " style='display:none'"; ?>>
678 <?php xl('Country','e'); ?>: </span>
679 <?php
680 // Modified 7/2009 by BM to incorporate data types
681 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']);
683 <br />
684 <span class=bold><?php xl('Subscriber Phone','e'); ?>:
685 <input type='text' size='20' name='i<?php echo $i?>subscriber_phone' value='<?php echo $result3["subscriber_phone"] ?>' onkeyup='phonekeyup(this,mypcc)' />
686 </span><br />
687 <span class=bold><?php xl('CoPay','e'); ?>: <input type=text size="6" name=i<?php echo $i?>copay value="<?php echo $result3{"copay"}?>">
688 </span><br />
689 <span class='required'><?php xl('Accept Assignment','e'); ?>: </span>
690 <select name=i<?php echo $i?>accept_assignment>
691 <option value="TRUE" <?php if (strtoupper($result3{"accept_assignment"}) == "TRUE") echo "selected"?>><?php xl('YES','e'); ?></option>
692 <option value="FALSE" <?php if (strtoupper($result3{"accept_assignment"}) == "FALSE") echo "selected"?>><?php xl('NO','e'); ?></option>
693 </select>
694 </td>
695 </tr>
697 </table>
698 <hr />
699 <?php
701 echo "</div>\n";
702 } // end of "if not simplified_demographics"
705 <?php if (!$SHORT_FORM) echo " <center>\n"; ?>
706 <br />
707 <?php if ($WITH_SEARCH) { ?>
708 <input type="button" id="search" value=<?php xl('Search','e','\'','\''); ?>
709 style='background-color:<?php echo $searchcolor; ?>' />
710 &nbsp;&nbsp;
711 <?php } ?>
712 <input type="button" name='create' id="create" value=<?php xl('Create New Patient','e','\'','\''); ?> />
714 </center>
716 </td>
717 <td align='right' valign='top' width='1%' nowrap>
718 <!-- Image upload stuff was here but got moved. -->
719 </td>
720 </tr>
721 </table>
723 </form>
725 <!-- include support for the list-add selectbox feature -->
726 <?php include($GLOBALS['fileroot']."/library/options_listadd.inc"); ?>
728 </body>
730 <script language="JavaScript">
732 // fix inconsistently formatted phone numbers from the database
733 var f = document.forms[0];
734 if (f.form_phone_contact) phonekeyup(f.form_phone_contact,mypcc);
735 if (f.form_phone_home ) phonekeyup(f.form_phone_home ,mypcc);
736 if (f.form_phone_biz ) phonekeyup(f.form_phone_biz ,mypcc);
737 if (f.form_phone_cell ) phonekeyup(f.form_phone_cell ,mypcc);
739 <?php echo $date_init; ?>
741 // -=- jQuery makes life easier -=-
743 // var matches = 0; // number of patients that match the demographic information being entered
744 // var override = false; // flag that overrides the duplication warning
746 $(document).ready(function() {
748 // added to integrate insurance stuff
749 <?php for ($i=1;$i<=3;$i++) { ?>
750 $("#form_i<?php echo $i?>subscriber_relationship").change(function() { auto_populate_employer_address<?php echo $i?>(); });
751 <?php } ?>
753 $('#search').click(function() { searchme(); });
754 $('#create').click(function() { submitme(); });
756 var submitme = function() {
757 top.restoreSession();
758 var f = document.forms[0];
760 if (validate(f)) {
761 if (force_submit) {
762 // In this case dups were shown already and Save should just save.
763 f.submit();
764 return;
766 <?php
767 // D in edit_options indicates the field is used in duplication checking.
768 // This constructs a list of the names of those fields.
769 $mflist = "";
770 $mfres = sqlStatement("SELECT * FROM layout_options " .
771 "WHERE form_id = 'DEM' AND uor > 0 AND field_id != '' AND " .
772 "edit_options LIKE '%D%' " .
773 "ORDER BY group_name, seq");
774 while ($mfrow = sqlFetchArray($mfres)) {
775 $field_id = $mfrow['field_id'];
776 if (strpos($field_id, 'em_') === 0) continue;
777 if (!empty($mflist)) $mflist .= ",";
778 $mflist .= "'" . htmlentities($field_id) . "'";
781 // Build and invoke the URL to create the dup-checker dialog.
782 var url = 'new_search_popup.php';
783 var flds = new Array(<?php echo $mflist; ?>);
784 var separator = '?';
785 for (var i = 0; i < flds.length; ++i) {
786 var fval = $('#form_' + flds[i]).val();
787 if (fval && fval != '') {
788 url += separator;
789 separator = '&';
790 url += 'mf_' + flds[i] + '=' + encodeURIComponent(fval);
793 dlgopen(url, '_blank', 700, 500);
795 } // end if validate
796 } // end function
798 // Set onclick/onfocus handlers for toggling background color.
799 <?php
800 $lres = getLayoutRes();
801 while ($lrow = sqlFetchArray($lres)) {
802 $field_id = $lrow['field_id'];
803 if (strpos($field_id, 'em_') === 0) continue;
804 switch(getSearchClass($lrow['data_type'])) {
805 case 1:
806 echo " \$('#form_$field_id').click(function() { toggleSearch(this); });\n";
807 break;
808 case 2:
809 echo " \$('#form_$field_id').click(function() { selClick(this); });\n";
810 echo " \$('#form_$field_id').blur(function() { selBlur(this); });\n";
811 break;
816 }); // end document.ready
818 </script>
820 </html>