CAMOS bug fix continued. See previous commit message for details.
[openemr.git] / interface / new / new_comprehensive.php
blobd5783fe26d2ef040a7ba4ad5c3e4ba752bdb4b3f
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");
14 // Check authorization.
15 $thisauth = acl_check('patients', 'demo');
16 if ($thisauth != 'write' && $thisauth != '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 return 2;
50 case 2: // text field
51 case 3: // textarea
52 case 4: // date
53 return 1;
55 return 0;
58 $fres = getLayoutRes();
60 <html>
61 <head>
62 <?php html_header_show(); ?>
64 <link rel="stylesheet" href="<?php echo $css_header; ?>" type="text/css">
66 <style>
67 body, td, input, select, textarea {
68 font-family: Arial, Helvetica, sans-serif;
69 font-size: 10pt;
72 body {
73 padding: 5pt 5pt 5pt 5pt;
76 div.section {
77 border: solid;
78 border-width: 1px;
79 border-color: #0000ff;
80 margin: 0 0 0 10pt;
81 padding: 5pt;
84 </style>
86 <style type="text/css">@import url(../../library/dynarch_calendar.css);</style>
88 <script type="text/javascript" src="../../library/dialog.js"></script>
89 <script type="text/javascript" src="../../library/textformat.js"></script>
90 <script type="text/javascript" src="../../library/dynarch_calendar.js"></script>
91 <?php include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?>
92 <script type="text/javascript" src="../../library/dynarch_calendar_setup.js"></script>
93 <script type="text/javascript" src="<?php echo $GLOBALS['webroot']; ?>/library/js/jquery.js"></script>
95 <SCRIPT LANGUAGE="JavaScript"><!--
96 //Visolve - sync the radio buttons - Start
97 if((top.window.parent) && (parent.window)){
98 var wname = top.window.parent.left_nav;
99 fname = (parent.window.name)?parent.window.name:window.name;
100 wname.syncRadios();
101 wname.setRadio(fname, "new");
102 }//Visolve - sync the radio buttons - End
104 var mypcc = '<?php echo $GLOBALS['phone_country_code'] ?>';
106 // This may be changed to true by the AJAX search script.
107 var force_submit = false;
109 //code used from http://tech.irt.org/articles/js037/
110 function replace(string,text,by) {
111 // Replaces text with by in string
112 var strLength = string.length, txtLength = text.length;
113 if ((strLength == 0) || (txtLength == 0)) return string;
115 var i = string.indexOf(text);
116 if ((!i) && (text != string.substring(0,txtLength))) return string;
117 if (i == -1) return string;
119 var newstr = string.substring(0,i) + by;
121 if (i+txtLength < strLength)
122 newstr += replace(string.substring(i+txtLength,strLength),text,by);
124 return newstr;
127 <?php for ($i=1;$i<=3;$i++) { ?>
128 function auto_populate_employer_address<?php echo $i ?>(){
129 var f = document.demographics_form;
130 if (f.form_i<?php echo $i?>subscriber_relationship.options[f.form_i<?php echo $i?>subscriber_relationship.selectedIndex].value == "self") {
131 f.i<?php echo $i?>subscriber_fname.value=f.form_fname.value;
132 f.i<?php echo $i?>subscriber_mname.value=f.form_mname.value;
133 f.i<?php echo $i?>subscriber_lname.value=f.form_lname.value;
134 f.i<?php echo $i?>subscriber_street.value=f.form_street.value;
135 f.i<?php echo $i?>subscriber_city.value=f.form_city.value;
136 f.form_i<?php echo $i?>subscriber_state.value=f.form_state.value;
137 f.i<?php echo $i?>subscriber_postal_code.value=f.form_postal_code.value;
138 if (f.form_country_code)
139 f.form_i<?php echo $i?>subscriber_country.value=f.form_country_code.value;
140 f.i<?php echo $i?>subscriber_phone.value=f.form_phone_home.value;
141 f.i<?php echo $i?>subscriber_DOB.value=f.form_DOB.value;
142 f.i<?php echo $i?>subscriber_ss.value=f.form_ss.value;
143 f.form_i<?php echo $i?>subscriber_sex.value = f.form_sex.value;
144 f.i<?php echo $i?>subscriber_employer.value=f.form_em_name.value;
145 f.i<?php echo $i?>subscriber_employer_street.value=f.form_em_street.value;
146 f.i<?php echo $i?>subscriber_employer_city.value=f.form_em_city.value;
147 f.form_i<?php echo $i?>subscriber_employer_state.value=f.form_em_state.value;
148 f.i<?php echo $i?>subscriber_employer_postal_code.value=f.form_em_postal_code.value;
149 if (f.form_em_country)
150 f.form_i<?php echo $i?>subscriber_employer_country.value=f.form_em_country.value;
154 <?php } ?>
156 function upperFirst(string,text) {
157 return replace(string,text,text.charAt(0).toUpperCase() + text.substring(1,text.length));
160 // The ins_search.php window calls this to set the selected insurance.
161 function set_insurance(ins_id, ins_name) {
162 var thesel = document.forms[0]['i' + insurance_index + 'provider'];
163 var theopts = thesel.options; // the array of Option objects
164 var i = 0;
165 for (; i < theopts.length; ++i) {
166 if (theopts[i].value == ins_id) {
167 theopts[i].selected = true;
168 return;
171 // no matching option was found so create one, append it to the
172 // end of the list, and select it.
173 theopts[i] = new Option(ins_name, ins_id, false, true);
176 // Indicates which insurance slot is being updated.
177 var insurance_index = 0;
179 // The OnClick handler for searching/adding the insurance company.
180 function ins_search(ins) {
181 insurance_index = ins;
182 dlgopen('../../interface/practice/ins_search.php', '_blank', 550, 400);
183 return false;
186 function checkNum () {
187 var re= new RegExp();
188 re = /^\d*\.?\d*$/;
189 str=document.forms[0].monthly_income.value;
190 if(re.exec(str))
192 }else{
193 alert("Please enter a dollar amount using only numbers and a decimal point.");
197 // This capitalizes the first letter of each word in the passed input
198 // element. It also strips out extraneous spaces.
199 function capitalizeMe(elem) {
200 var a = elem.value.split(' ');
201 var s = '';
202 for(var i = 0; i < a.length; ++i) {
203 if (a[i].length > 0) {
204 if (s.length > 0) s += ' ';
205 s += a[i].charAt(0).toUpperCase() + a[i].substring(1);
208 elem.value = s;
211 function divclick(cb, divid) {
212 var divstyle = document.getElementById(divid).style;
213 if (cb.checked) {
214 divstyle.display = 'block';
215 } else {
216 divstyle.display = 'none';
218 return true;
221 // Compute the length of a string without leading and trailing spaces.
222 function trimlen(s) {
223 var i = 0;
224 var j = s.length - 1;
225 for (; i <= j && s.charAt(i) == ' '; ++i);
226 for (; i <= j && s.charAt(j) == ' '; --j);
227 if (i > j) return 0;
228 return j + 1 - i;
231 function validate(f) {
232 <?php generate_layout_validation('DEM'); ?>
233 return true;
236 function toggleSearch(elem) {
237 var f = document.forms[0];
238 <?php if ($WITH_SEARCH) { ?>
239 // Toggle background color.
240 if (elem.style.backgroundColor == '')
241 elem.style.backgroundColor = '<?php echo $searchcolor; ?>';
242 else
243 elem.style.backgroundColor = '';
244 <?php } ?>
245 if (force_submit) {
246 force_submit = false;
247 f.create.value = '<?php xl('Create New Patient','e'); ?>';
249 return true;
252 // If a <select> list is dropped down, this is its name.
253 var open_sel_name = '';
255 function selClick(elem) {
256 if (open_sel_name == elem.name) {
257 open_sel_name = '';
259 else {
260 open_sel_name = elem.name;
261 toggleSearch(elem);
263 return true;
266 function selBlur(elem) {
267 if (open_sel_name == elem.name) {
268 open_sel_name = '';
270 return true;
273 // This invokes the patient search dialog.
274 function searchme() {
275 var f = document.forms[0];
276 var url = '../main/finder/patient_select.php?popup=1';
278 <?php
279 $lres = getLayoutRes();
281 while ($lrow = sqlFetchArray($lres)) {
282 $field_id = $lrow['field_id'];
283 if (strpos($field_id, 'em_') === 0) continue;
284 $data_type = $lrow['data_type'];
285 $fldname = "form_$field_id";
286 switch(getSearchClass($data_type)) {
287 case 1:
288 echo
289 " if (f.$fldname.style.backgroundColor != '' && trimlen(f.$fldname.value) > 0) {\n" .
290 " url += '&$field_id=' + encodeURIComponent(f.$fldname.value);\n" .
291 " }\n";
292 break;
293 case 2:
294 echo
295 " if (f.$fldname.style.backgroundColor != '' && f.$fldname.selectedIndex > 0) {\n" .
296 " url += '&$field_id=' + encodeURIComponent(f.$fldname.options[f.$fldname.selectedIndex].value);\n" .
297 " }\n";
298 break;
303 dlgopen(url, '_blank', 700, 500);
306 //-->
308 </script>
309 </head>
311 <body class="body_top">
313 <form action='new_comprehensive_save.php' name='demographics_form' method='post' onsubmit='return validate(this)'>
315 <span class='title'><?php xl('Search or Add Patient','e'); ?></span>
317 <table width='100%' cellpadding='0' cellspacing='8'>
318 <tr>
319 <td align='left' valign='top'>
320 <?php if ($SHORT_FORM) echo " <center>\n"; ?>
321 <?php
323 function end_cell() {
324 global $item_count, $cell_count;
325 if ($item_count > 0) {
326 echo "</td>";
327 $item_count = 0;
331 function end_row() {
332 global $cell_count, $CPR;
333 end_cell();
334 if ($cell_count > 0) {
335 for (; $cell_count < $CPR; ++$cell_count) echo "<td></td>";
336 echo "</tr>\n";
337 $cell_count = 0;
341 function end_group() {
342 global $last_group, $SHORT_FORM;
343 if (strlen($last_group) > 0) {
344 end_row();
345 echo " </table>\n";
346 if (!$SHORT_FORM) echo "</div>\n";
350 $last_group = '';
351 $cell_count = 0;
352 $item_count = 0;
353 $display_style = 'block';
354 $group_seq = 0; // this gives the DIV blocks unique IDs
356 while ($frow = sqlFetchArray($fres)) {
357 $this_group = $frow['group_name'];
358 $titlecols = $frow['titlecols'];
359 $datacols = $frow['datacols'];
360 $data_type = $frow['data_type'];
361 $field_id = $frow['field_id'];
362 $list_id = $frow['list_id'];
363 $currvalue = '';
365 if (strpos($field_id, 'em_') === 0) {
366 $tmp = substr($field_id, 3);
367 if (isset($result2[$tmp])) $currvalue = $result2[$tmp];
369 else {
370 if (isset($result[$field_id])) $currvalue = $result[$field_id];
373 // Handle a data category (group) change.
374 if (strcmp($this_group, $last_group) != 0) {
375 if (!$SHORT_FORM) {
376 end_group();
377 $group_seq++; // ID for DIV tags
378 $group_name = substr($this_group, 1);
379 if (strlen($last_group) > 0) echo "<br />";
380 echo "<span class='bold'><input type='checkbox' name='form_cb_$group_seq' id='form_cb_$group_seq' value='1' " .
381 "onclick='return divclick(this,\"div_$group_seq\");'";
382 if ($display_style == 'block') echo " checked";
384 // Modified 6-09 by BM - Translate if applicable
385 echo " /><b>" . xl_layout_label($group_name) . "</b></span>\n";
387 echo "<div id='div_$group_seq' class='section' style='display:$display_style;'>\n";
388 echo " <table border='0' cellpadding='0'>\n";
389 $display_style = 'none';
391 else if (strlen($last_group) == 0) {
392 echo " <table border='0' cellpadding='0'>\n";
394 $last_group = $this_group;
397 // Handle starting of a new row.
398 if (($titlecols > 0 && $cell_count >= $CPR) || $cell_count == 0) {
399 end_row();
400 echo " <tr>";
403 if ($item_count == 0 && $titlecols == 0) $titlecols = 1;
405 // Handle starting of a new label cell.
406 if ($titlecols > 0) {
407 end_cell();
408 echo "<td colspan='$titlecols'";
409 echo ($frow['uor'] == 2) ? " class='required'" : " class='bold'";
410 if ($cell_count == 2) echo " style='padding-left:10pt'";
411 echo ">";
412 $cell_count += $titlecols;
414 ++$item_count;
416 echo "<b>";
418 // Modified 6-09 by BM - Translate if applicable
419 if ($frow['title']) echo (xl_layout_label($frow['title']).":"); else echo "&nbsp;";
421 echo "</b>";
423 // Handle starting of a new data cell.
424 if ($datacols > 0) {
425 end_cell();
426 echo "<td colspan='$datacols' class='text'";
427 if ($cell_count > 0) echo " style='padding-left:5pt'";
428 echo ">";
429 $cell_count += $datacols;
432 ++$item_count;
433 generate_form_field($frow, $currvalue);
436 end_group();
439 <?php
440 if (! $GLOBALS['simplified_demographics']) {
441 $insurancei = getInsuranceProviders();
442 $pid = 0;
443 $insurance_headings = array(xl("Primary Insurance Provider"), xl("Secondary Insurance Provider"), xl("Tertiary Insurance provider"));
444 $insurance_info = array();
445 $insurance_info[1] = getInsuranceData($pid,"primary");
446 $insurance_info[2] = getInsuranceData($pid,"secondary");
447 $insurance_info[3] = getInsuranceData($pid,"tertiary");
449 echo "<br /><span class='bold'><input type='checkbox' name='form_cb_ins' value='1' " .
450 "onclick='return divclick(this,\"div_ins\");'";
451 if ($display_style == 'block') echo " checked";
452 echo " /><b>" . xl('Insurance') . "</b></span>\n";
453 echo "<div id='div_ins' class='section' style='display:$display_style;'>\n";
455 for($i=1;$i<=3;$i++) {
456 $result3 = $insurance_info[$i];
458 <table border="0">
459 <tr>
460 <td valign='top' colspan='2'>
461 <span class='required'><?php echo $insurance_headings[$i -1].":"?></span>
462 <select name="i<?php echo $i?>provider">
463 <option value=""><?php xl('Unassigned','e'); ?></option>
464 <?php
465 foreach ($insurancei as $iid => $iname) {
466 echo "<option value='" . $iid . "'";
467 if (strtolower($iid) == strtolower($result3{"provider"}))
468 echo " selected";
469 echo ">" . $iname . "</option>\n";
472 </select>&nbsp;<a href='' onclick='return ins_search(<?php echo $i?>)'>
473 <?php xl('Search/Add Insurer','e'); ?></a>
474 </td>
475 </tr>
476 <tr>
477 <td valign=top>
478 <table border="0">
480 <tr>
481 <td>
482 <span class='required'><?php xl('Plan Name','e'); ?>: </span>
483 </td>
484 <td>
485 <input type='entry' size='20' name='i<?php echo $i?>plan_name' value="<?php echo $result3{"plan_name"} ?>"
486 onchange="capitalizeMe(this);" />&nbsp;&nbsp;
487 </td>
488 </tr>
490 <tr>
491 <td>
492 <span class='required'><?php xl('Effective Date','e'); ?>: </span>
493 </td>
494 <td>
495 <input type='entry' size='11' name='i<?php echo $i ?>effective_date'
496 id='i<?php echo $i ?>effective_date'
497 value='<?php echo $result3['date'] ?>'
498 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)'
499 title='yyyy-mm-dd' />
501 <img src='../../interface/pic/show_calendar.gif' align='absbottom' width='24' height='22'
502 id='img_i<?php echo $i ?>effective_date' border='0' alt='[?]' style='cursor:pointer'
503 title='<?php xl('Click here to choose a date','e'); ?>'>
505 <script LANGUAGE="JavaScript">
506 Calendar.setup({inputField:"i<?php echo $i ?>effective_date", ifFormat:"%Y-%m-%d", button:"img_i<?php echo $i; ?>effective_date"});
507 </script>
510 </td>
511 </tr>
513 <tr>
514 <td><span class=required><?php xl('Policy Number','e'); ?>: </span></td>
515 <td><input type='entry' size='16' name='i<?php echo $i?>policy_number' value="<?php echo $result3{"policy_number"}?>"
516 onkeyup='policykeyup(this)'></td>
517 </tr>
519 <tr>
520 <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"}?>"></td>
521 </tr>
523 <tr<?php if ($GLOBALS['omit_employers']) echo " style='display:none'"; ?>>
524 <td class='required'><?php xl('Subscriber Employer (SE)','e'); ?><br><span style='font-weight:normal'>
525 (<?php xl('if unemployed enter Student','e'); ?>,<br><?php xl('PT Student, or leave blank','e'); ?>): </span></td>
526 <td><input type=entry size=25 name=i<?php echo $i?>subscriber_employer
527 value="<?php echo $result3{"subscriber_employer"}?>"
528 onchange="capitalizeMe(this);" /></td>
529 </tr>
531 <tr<?php if ($GLOBALS['omit_employers']) echo " style='display:none'"; ?>>
532 <td><span class=required><?php xl('SE Address','e'); ?>: </span></td>
533 <td><input type=entry size=25 name=i<?php echo $i?>subscriber_employer_street
534 value="<?php echo $result3{"subscriber_employer_street"}?>"
535 onchange="capitalizeMe(this);" /></td>
536 </tr>
538 <tr<?php if ($GLOBALS['omit_employers']) echo " style='display:none'"; ?>>
539 <td colspan="2">
540 <table>
541 <tr>
542 <td><span class=required><?php xl('SE City','e'); ?>: </span></td>
543 <td><input type=entry size=15 name=i<?php echo $i?>subscriber_employer_city
544 value="<?php echo $result3{"subscriber_employer_city"}?>"
545 onchange="capitalizeMe(this);" /></td>
546 <td><span class=required><?php echo ($GLOBALS['phone_country_code'] == '1') ? xl('SE State','e') : xl('SE Locality','e') ?>: </span></td>
547 <td>
548 <?php
549 // Modified 7/2009 by BM to incorporate data types
550 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']);
552 </td>
553 </tr>
554 <tr>
555 <td><span class=required><?php echo ($GLOBALS['phone_country_code'] == '1') ? xl('SE Zip Code','e') : xl('SE Postal Code','e') ?>: </span></td>
556 <td><input type=entry size=10 name=i<?php echo $i?>subscriber_employer_postal_code value="<?php echo $result3{"subscriber_employer_postal_code"}?>"></td>
557 <td><span class=required><?php xl('SE Country','e'); ?>: </span></td>
558 <td>
559 <?php
560 // Modified 7/2009 by BM to incorporate data types
561 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']);
563 </td>
564 </tr>
565 </table>
566 </td>
567 </tr>
569 </table>
570 </td>
572 <td valign=top>
573 <span class=required><?php xl('Subscriber','e'); ?>: </span>
574 <input type=entry size=10 name=i<?php echo $i?>subscriber_fname
575 value="<?php echo $result3{"subscriber_fname"}?>"
576 onchange="capitalizeMe(this);" />
577 <input type=entry size=3 name=i<?php echo $i?>subscriber_mname
578 value="<?php echo $result3{"subscriber_mname"}?>"
579 onchange="capitalizeMe(this);" />
580 <input type=entry size=10 name=i<?php echo $i?>subscriber_lname
581 value="<?php echo $result3{"subscriber_lname"}?>"
582 onchange="capitalizeMe(this);" />
583 <br>
584 <span class=required><?php xl('Relationship','e'); ?>: </span>
585 <?php
586 // Modified 6/2009 by BM to use list_options and function
587 generate_form_field(array('data_type'=>1,'field_id'=>('i'.$i.'subscriber_relationship'),'list_id'=>'sub_relation','empty_title'=>' '), $result3['subscriber_relationship']);
589 <a href="javascript:popUp('../../interface/patient_file/summary/browse.php?browsenum=<?php echo $i?>')" class=text>(<?php xl('Browse','e'); ?>)</a><br />
591 <span class=bold><?php xl('D.O.B.','e'); ?>: </span>
592 <input type='entry' size='11' name='i<?php echo $i?>subscriber_DOB'
593 id='i<?php echo $i?>subscriber_DOB'
594 value='<?php echo $result3['subscriber_DOB'] ?>'
595 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)'
596 title='yyyy-mm-dd' />
598 <img src='../../interface/pic/show_calendar.gif' align='absbottom' width='24' height='22'
599 id='img_i<?php echo $i; ?>dob_date' border='0' alt='[?]' style='cursor:pointer'
600 title='<?php xl('Click here to choose a date','e'); ?>'>
602 <script LANGUAGE="JavaScript">
603 Calendar.setup({inputField:"i<?php echo $i?>subscriber_DOB", ifFormat:"%Y-%m-%d", button:"img_i<?php echo $i; ?>dob_date"});
604 </script>
607 <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;
608 <span class=bold><?php xl('Sex','e'); ?>: </span>
609 <?php
610 // Modified 6/2009 by BM to use list_options and function
611 generate_form_field(array('data_type'=>1,'field_id'=>('i'.$i.'subscriber_sex'),'list_id'=>'sex'), $result3['subscriber_sex']);
613 <br>
614 <span class=required><?php xl('Subscriber Address','e'); ?>: </span>
615 <input type=entry size=25 name=i<?php echo $i?>subscriber_street
616 value="<?php echo $result3{"subscriber_street"}?>"
617 onchange="capitalizeMe(this);" /><br>
618 <span class=required><?php xl('City','e'); ?>: </span>
619 <input type=entry size=15 name=i<?php echo $i?>subscriber_city
620 value="<?php echo $result3{"subscriber_city"}?>"
621 onchange="capitalizeMe(this);" />
622 <span class=required><?php echo ($GLOBALS['phone_country_code'] == '1') ? xl('State','e') : xl('Locality','e') ?>: </span>
623 <?php
624 // Modified 7/2009 by BM to incorporate data types
625 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']);
627 <br />
628 <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"}?>">
629 <span class='required'<?php if ($GLOBALS['omit_employers']) echo " style='display:none'"; ?>>
630 <?php xl('Country','e'); ?>: </span>
631 <?php
632 // Modified 7/2009 by BM to incorporate data types
633 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']);
635 <br />
636 <span class=bold><?php xl('Subscriber Phone','e'); ?>:
637 <input type='text' size='20' name='i<?php echo $i?>subscriber_phone' value='<?php echo $result3["subscriber_phone"] ?>' onkeyup='phonekeyup(this,mypcc)' />
638 </span><br />
639 <span class=bold><?php xl('CoPay','e'); ?>: <input type=text size="6" name=i<?php echo $i?>copay value="<?php echo $result3{"copay"}?>">
640 </span><br />
641 <span class='required'><?php xl('Accept Assignment','e'); ?>: </span>
642 <select name=i<?php echo $i?>accept_assignment>
643 <option value="TRUE" <?php if (strtoupper($result3{"accept_assignment"}) == "TRUE") echo "selected"?>><?php xl('YES','e'); ?></option>
644 <option value="FALSE" <?php if (strtoupper($result3{"accept_assignment"}) == "FALSE") echo "selected"?>><?php xl('NO','e'); ?></option>
645 </select>
646 </td>
647 </tr>
649 </table>
650 <hr />
651 <?php
653 echo "</div>\n";
654 } // end of "if not simplified_demographics"
657 <?php if (!$SHORT_FORM) echo " <center>\n"; ?>
658 <br />
659 <?php if ($WITH_SEARCH) { ?>
660 <input type="button" id="search" value=<?php xl('Search','e','\'','\''); ?>
661 style='background-color:<?php echo $searchcolor; ?>' />
662 &nbsp;&nbsp;
663 <?php } ?>
664 <input type="button" name='create' id="create" value=<?php xl('Create New Patient','e','\'','\''); ?> />
666 </center>
668 </td>
669 <td align='right' valign='top' width='1%' nowrap>
670 <!-- Image upload stuff was here but got moved. -->
671 </td>
672 </tr>
673 </table>
675 </form>
677 <!-- include support for the list-add selectbox feature -->
678 <?php include($GLOBALS['fileroot']."/library/options_listadd.inc"); ?>
680 </body>
682 <script language="JavaScript">
684 // fix inconsistently formatted phone numbers from the database
685 var f = document.forms[0];
686 if (f.form_phone_contact) phonekeyup(f.form_phone_contact,mypcc);
687 if (f.form_phone_home ) phonekeyup(f.form_phone_home ,mypcc);
688 if (f.form_phone_biz ) phonekeyup(f.form_phone_biz ,mypcc);
689 if (f.form_phone_cell ) phonekeyup(f.form_phone_cell ,mypcc);
691 <?php echo $date_init; ?>
693 // -=- jQuery makes life easier -=-
695 // var matches = 0; // number of patients that match the demographic information being entered
696 // var override = false; // flag that overrides the duplication warning
698 $(document).ready(function() {
700 // added to integrate insurance stuff
701 <?php for ($i=1;$i<=3;$i++) { ?>
702 $("#form_i<?php echo $i?>subscriber_relationship").change(function() { auto_populate_employer_address<?php echo $i?>(); });
703 <?php } ?>
705 $('#search').click(function() { searchme(); });
706 $('#create').click(function() { submitme(); });
708 var submitme = function() {
709 top.restoreSession();
710 var f = document.forms[0];
712 if (validate(f)) {
713 if (force_submit) {
714 // In this case dups were shown already and Save should just save.
715 f.submit();
716 return;
718 <?php
719 // D in edit_options indicates the field is used in duplication checking.
720 // This constructs a list of the names of those fields.
721 $mflist = "";
722 $mfres = sqlStatement("SELECT * FROM layout_options " .
723 "WHERE form_id = 'DEM' AND uor > 0 AND field_id != '' AND " .
724 "edit_options LIKE '%D%' " .
725 "ORDER BY group_name, seq");
726 while ($mfrow = sqlFetchArray($mfres)) {
727 $field_id = $mfrow['field_id'];
728 if (strpos($field_id, 'em_') === 0) continue;
729 if (!empty($mflist)) $mflist .= ",";
730 $mflist .= "'" . htmlentities($field_id) . "'";
733 // Build and invoke the URL to create the dup-checker dialog.
734 var url = 'new_search_popup.php';
735 var flds = new Array(<?php echo $mflist; ?>);
736 var separator = '?';
737 for (var i = 0; i < flds.length; ++i) {
738 var fval = $('#form_' + flds[i]).val();
739 if (fval && fval != '') {
740 url += separator;
741 separator = '&';
742 url += 'mf_' + flds[i] + '=' + encodeURIComponent(fval);
745 dlgopen(url, '_blank', 700, 500);
747 } // end if validate
748 } // end function
750 // Set onclick/onfocus handlers for toggling background color.
751 <?php
752 $lres = getLayoutRes();
753 while ($lrow = sqlFetchArray($lres)) {
754 $field_id = $lrow['field_id'];
755 if (strpos($field_id, 'em_') === 0) continue;
756 switch(getSearchClass($lrow['data_type'])) {
757 case 1:
758 echo " \$('#form_$field_id').click(function() { toggleSearch(this); });\n";
759 break;
760 case 2:
761 echo " \$('#form_$field_id').click(function() { selClick(this); });\n";
762 echo " \$('#form_$field_id').blur(function() { selBlur(this); });\n";
763 break;
768 }); // end document.ready
770 </script>
772 </html>