Fix condition logic for multiple selection controls in LBF.
[openemr.git] / interface / new / new_comprehensive.php
blob562717c7e3e247ce72737a5cc232960c742c0799
1 <?php
2 // Copyright (C) 2009-2010 Rod Roark <rod@sunsetsystems.com>
3 //
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
9 require_once("../globals.php");
10 require_once("$srcdir/acl.inc");
11 require_once("$srcdir/options.inc.php");
12 require_once("$srcdir/patient.inc");
13 require_once("$srcdir/erx_javascript.inc.php");
14 require_once("$srcdir/validation/LBF_Validation.php");
16 // Check authorization.
17 if (!acl_check('patients','demo','',array('write','addonly') ))
18 die("Adding demographics is not authorized.");
20 $CPR = 4; // cells per row
22 $searchcolor = empty($GLOBALS['layout_search_color']) ?
23 '#ffff55' : $GLOBALS['layout_search_color'];
25 $WITH_SEARCH = ($GLOBALS['full_new_patient_form'] == '1' || $GLOBALS['full_new_patient_form'] == '2');
26 $SHORT_FORM = ($GLOBALS['full_new_patient_form'] == '2' || $GLOBALS['full_new_patient_form'] == '3');
28 function getLayoutRes() {
29 global $SHORT_FORM;
30 return sqlStatement("SELECT * FROM layout_options " .
31 "WHERE form_id = 'DEM' AND uor > 0 AND field_id != '' " .
32 ($SHORT_FORM ? "AND ( uor > 1 OR edit_options LIKE '%N%' ) " : "") .
33 "ORDER BY group_name, seq");
36 // Determine layout field search treatment from its data type:
37 // 1 = text field
38 // 2 = select list
39 // 0 = not searchable
41 function getSearchClass($data_type) {
42 switch($data_type) {
43 case 1: // single-selection list
44 case 10: // local provider list
45 case 11: // provider list
46 case 12: // pharmacy list
47 case 13: // squads
48 case 14: // address book list
49 case 26: // single-selection list with add
50 case 35: // facilities
51 return 2;
52 case 2: // text field
53 case 3: // textarea
54 case 4: // date
55 return 1;
57 return 0;
60 $fres = getLayoutRes();
62 <html>
63 <head>
64 <?php html_header_show(); ?>
66 <link rel="stylesheet" href="<?php echo $css_header; ?>" type="text/css">
68 <style>
69 body, td, input, select, textarea {
70 font-family: Arial, Helvetica, sans-serif;
71 font-size: 10pt;
74 body {
75 padding: 5pt 5pt 5pt 5pt;
78 div.section {
79 border: solid;
80 border-width: 1px;
81 border-color: #0000ff;
82 margin: 0 0 0 10pt;
83 padding: 5pt;
86 </style>
88 <style type="text/css">@import url(../../library/dynarch_calendar.css);</style>
90 <script type="text/javascript" src="../../library/dialog.js"></script>
91 <script type="text/javascript" src="../../library/textformat.js"></script>
92 <script type="text/javascript" src="../../library/dynarch_calendar.js"></script>
93 <?php include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?>
94 <script type="text/javascript" src="../../library/dynarch_calendar_setup.js"></script>
95 <script type="text/javascript" src="../../library/js/jquery-1.9.1.min.js"></script>
96 <script type="text/javascript" src="../../library/js/common.js"></script>
97 <script type="text/javascript" src="../../library/js/fancybox/jquery.fancybox-1.2.6.js"></script>
98 <?php include_once("{$GLOBALS['srcdir']}/options.js.php"); ?>
99 <link rel="stylesheet" type="text/css" href="../../library/js/fancybox/jquery.fancybox-1.2.6.css" media="screen" />
101 <SCRIPT LANGUAGE="JavaScript"><!--
102 //Visolve - sync the radio buttons - Start
103 if((top.window.parent) && (parent.window)){
104 var wname = top.window.parent.left_nav;
105 fname = (parent.window.name)?parent.window.name:window.name;
106 wname.syncRadios();
107 wname.setRadio(fname, "new");
108 }//Visolve - sync the radio buttons - End
110 var mypcc = '<?php echo $GLOBALS['phone_country_code'] ?>';
112 // This may be changed to true by the AJAX search script.
113 var force_submit = false;
115 //code used from http://tech.irt.org/articles/js037/
116 function replace(string,text,by) {
117 // Replaces text with by in string
118 var strLength = string.length, txtLength = text.length;
119 if ((strLength == 0) || (txtLength == 0)) return string;
121 var i = string.indexOf(text);
122 if ((!i) && (text != string.substring(0,txtLength))) return string;
123 if (i == -1) return string;
125 var newstr = string.substring(0,i) + by;
127 if (i+txtLength < strLength)
128 newstr += replace(string.substring(i+txtLength,strLength),text,by);
130 return newstr;
133 <?php for ($i=1;$i<=3;$i++) { ?>
134 function auto_populate_employer_address<?php echo $i ?>(){
135 var f = document.demographics_form;
136 if (f.form_i<?php echo $i?>subscriber_relationship.options[f.form_i<?php echo $i?>subscriber_relationship.selectedIndex].value == "self") {
137 f.i<?php echo $i?>subscriber_fname.value=f.form_fname.value;
138 f.i<?php echo $i?>subscriber_mname.value=f.form_mname.value;
139 f.i<?php echo $i?>subscriber_lname.value=f.form_lname.value;
140 f.i<?php echo $i?>subscriber_street.value=f.form_street.value;
141 f.i<?php echo $i?>subscriber_city.value=f.form_city.value;
142 f.form_i<?php echo $i?>subscriber_state.value=f.form_state.value;
143 f.i<?php echo $i?>subscriber_postal_code.value=f.form_postal_code.value;
144 if (f.form_country_code)
145 f.form_i<?php echo $i?>subscriber_country.value=f.form_country_code.value;
146 f.i<?php echo $i?>subscriber_phone.value=f.form_phone_home.value;
147 f.i<?php echo $i?>subscriber_DOB.value=f.form_DOB.value;
148 f.i<?php echo $i?>subscriber_ss.value=f.form_ss.value;
149 f.form_i<?php echo $i?>subscriber_sex.value = f.form_sex.value;
150 f.i<?php echo $i?>subscriber_employer.value=f.form_em_name.value;
151 f.i<?php echo $i?>subscriber_employer_street.value=f.form_em_street.value;
152 f.i<?php echo $i?>subscriber_employer_city.value=f.form_em_city.value;
153 f.form_i<?php echo $i?>subscriber_employer_state.value=f.form_em_state.value;
154 f.i<?php echo $i?>subscriber_employer_postal_code.value=f.form_em_postal_code.value;
155 if (f.form_em_country)
156 f.form_i<?php echo $i?>subscriber_employer_country.value=f.form_em_country.value;
160 <?php } ?>
162 function upperFirst(string,text) {
163 return replace(string,text,text.charAt(0).toUpperCase() + text.substring(1,text.length));
166 // The ins_search.php window calls this to set the selected insurance.
167 function set_insurance(ins_id, ins_name) {
168 var thesel = document.forms[0]['i' + insurance_index + 'provider'];
169 var theopts = thesel.options; // the array of Option objects
170 var i = 0;
171 for (; i < theopts.length; ++i) {
172 if (theopts[i].value == ins_id) {
173 theopts[i].selected = true;
174 return;
177 // no matching option was found so create one, append it to the
178 // end of the list, and select it.
179 theopts[i] = new Option(ins_name, ins_id, false, true);
182 // Indicates which insurance slot is being updated.
183 var insurance_index = 0;
185 // The OnClick handler for searching/adding the insurance company.
186 function ins_search(ins) {
187 insurance_index = ins;
188 return false;
191 function checkNum () {
192 var re= new RegExp();
193 re = /^\d*\.?\d*$/;
194 str=document.forms[0].monthly_income.value;
195 if(re.exec(str))
197 }else{
198 alert("Please enter a dollar amount using only numbers and a decimal point.");
202 // This capitalizes the first letter of each word in the passed input
203 // element. It also strips out extraneous spaces.
204 function capitalizeMe(elem) {
205 var a = elem.value.split(' ');
206 var s = '';
207 for(var i = 0; i < a.length; ++i) {
208 if (a[i].length > 0) {
209 if (s.length > 0) s += ' ';
210 s += a[i].charAt(0).toUpperCase() + a[i].substring(1);
213 elem.value = s;
216 // Onkeyup handler for policy number. Allows only A-Z and 0-9.
217 function policykeyup(e) {
218 var v = e.value.toUpperCase();
219 var filteredString="";
220 for (var i = 0; i < v.length; ++i) {
221 var c = v.charAt(i);
222 if ((c >= '0' && c <= '9') ||
223 (c >= 'A' && c <= 'Z') ||
224 (c == '*') ||
225 (c == '-') ||
226 (c == '_') ||
227 (c == '(') ||
228 (c == ')') ||
229 (c == '#'))
231 filteredString+=c;
234 e.value = filteredString;
235 return;
238 function divclick(cb, divid) {
239 var divstyle = document.getElementById(divid).style;
240 if (cb.checked) {
241 divstyle.display = 'block';
242 } else {
243 divstyle.display = 'none';
245 return true;
248 // Compute the length of a string without leading and trailing spaces.
249 function trimlen(s) {
250 var i = 0;
251 var j = s.length - 1;
252 for (; i <= j && s.charAt(i) == ' '; ++i);
253 for (; i <= j && s.charAt(j) == ' '; --j);
254 if (i > j) return 0;
255 return j + 1 - i;
258 function validate(f) {
259 var errMsgs = new Array();
260 <?php generate_layout_validation('DEM'); ?>
261 <?php if($GLOBALS['erx_enable']){ ?>
262 alertMsg='';
263 for(i=0;i<f.length;i++){
264 if(f[i].type=='text' && f[i].value)
266 if(f[i].name == 'form_fname' || f[i].name == 'form_mname' || f[i].name == 'form_lname')
268 alertMsg += checkLength(f[i].name,f[i].value,35);
269 alertMsg += checkUsername(f[i].name,f[i].value);
271 else if(f[i].name == 'form_street' || f[i].name == 'form_city')
273 alertMsg += checkLength(f[i].name,f[i].value,35);
274 alertMsg += checkAlphaNumericExtended(f[i].name,f[i].value);
276 else if(f[i].name == 'form_phone_home')
278 alertMsg += checkPhone(f[i].name,f[i].value);
282 if(alertMsg)
284 alert(alertMsg);
285 return false;
287 <?php } ?>
288 var msg = "";
289 msg += "<?php echo htmlspecialchars(xl('The following fields are required'),ENT_QUOTES); ?>:\n\n";
290 for ( var i = 0; i < errMsgs.length; i++ ) {
291 msg += errMsgs[i] + "\n";
293 msg += "\n<?php echo htmlspecialchars(xl('Please fill them in before continuing.'),ENT_QUOTES); ?>";
296 //Misc Deceased Date Validation for Future Date
297 var dateVal = document.getElementById("form_deceased_date").value;
298 var currentDate;
299 var d = new Date();
300 month = '' + (d.getMonth() + 1),
301 day = '' + d.getDate(),
302 year = d.getFullYear();
303 if (month.length < 2) month = '0' + month;
304 if (day.length < 2) day = '0' + day;
305 currentDate = year+'-'+month+'-'+day;
306 if(errMsgs.length > 0 || dateVal > currentDate)
308 if(errMsgs.length > 0)
309 alert(msg);
310 if(dateVal > currentDate)
311 alert ('<?php echo xls("Deceased Date should not be greater than Today"); ?>');
312 return false;
314 return true;
317 function toggleSearch(elem) {
318 var f = document.forms[0];
319 <?php if ($WITH_SEARCH) { ?>
320 // Toggle background color.
321 if (elem.style.backgroundColor == '')
322 elem.style.backgroundColor = '<?php echo $searchcolor; ?>';
323 else
324 elem.style.backgroundColor = '';
325 <?php } ?>
326 if (force_submit) {
327 force_submit = false;
328 f.create.value = '<?php xl('Create New Patient','e'); ?>';
330 return true;
333 // If a <select> list is dropped down, this is its name.
334 var open_sel_name = '';
336 function selClick(elem) {
337 if (open_sel_name == elem.name) {
338 open_sel_name = '';
340 else {
341 open_sel_name = elem.name;
342 toggleSearch(elem);
344 return true;
347 function selBlur(elem) {
348 if (open_sel_name == elem.name) {
349 open_sel_name = '';
351 return true;
354 // This invokes the patient search dialog.
355 function searchme() {
356 var f = document.forms[0];
357 var url = '../main/finder/patient_select.php?popup=1';
359 <?php
360 $lres = getLayoutRes();
362 while ($lrow = sqlFetchArray($lres)) {
363 $field_id = $lrow['field_id'];
364 if (strpos($field_id, 'em_') === 0) continue;
365 $data_type = $lrow['data_type'];
366 $fldname = "form_$field_id";
367 switch(getSearchClass($data_type)) {
368 case 1:
369 echo
370 " if (f.$fldname.style.backgroundColor != '' && trimlen(f.$fldname.value) > 0) {\n" .
371 " url += '&$field_id=' + encodeURIComponent(f.$fldname.value);\n" .
372 " }\n";
373 break;
374 case 2:
375 echo
376 " if (f.$fldname.style.backgroundColor != '' && f.$fldname.selectedIndex > 0) {\n" .
377 " url += '&$field_id=' + encodeURIComponent(f.$fldname.options[f.$fldname.selectedIndex].value);\n" .
378 " }\n";
379 break;
384 dlgopen(url, '_blank', 700, 500);
387 //-->
389 </script>
390 </head>
392 <body class="body_top">
394 <form action='new_comprehensive_save.php' name='demographics_form' id="DEM" method='post' onsubmit='return submitme(<?php echo $GLOBALS['new_validate'] ? 1 : 0;?>,event,"DEM")'>
396 <span class='title'><?php xl('Search or Add Patient','e'); ?></span>
398 <table width='100%' cellpadding='0' cellspacing='8'>
399 <tr>
400 <td align='left' valign='top'>
401 <?php if ($SHORT_FORM) echo " <center>\n"; ?>
402 <?php
404 function end_cell() {
405 global $item_count, $cell_count;
406 if ($item_count > 0) {
407 echo "</td>";
408 $item_count = 0;
412 function end_row() {
413 global $cell_count, $CPR;
414 end_cell();
415 if ($cell_count > 0) {
416 for (; $cell_count < $CPR; ++$cell_count) echo "<td></td>";
417 echo "</tr>\n";
418 $cell_count = 0;
422 function end_group() {
423 global $last_group, $SHORT_FORM;
424 if (strlen($last_group) > 0) {
425 end_row();
426 echo " </table>\n";
427 if (!$SHORT_FORM) echo "</div>\n";
431 $last_group = '';
432 $cell_count = 0;
433 $item_count = 0;
434 $display_style = 'block';
435 $group_seq = 0; // this gives the DIV blocks unique IDs
437 while ($frow = sqlFetchArray($fres)) {
438 $this_group = $frow['group_name'];
439 $titlecols = $frow['titlecols'];
440 $datacols = $frow['datacols'];
441 $data_type = $frow['data_type'];
442 $field_id = $frow['field_id'];
443 $list_id = $frow['list_id'];
444 $currvalue = '';
445 $condition_str = get_conditions_str($condition_str,$group_fields);
447 if (strpos($field_id, 'em_') === 0) {
448 $tmp = substr($field_id, 3);
449 if (isset($result2[$tmp])) $currvalue = $result2[$tmp];
451 else {
452 if (isset($result[$field_id])) $currvalue = $result[$field_id];
455 // Handle a data category (group) change.
456 if (strcmp($this_group, $last_group) != 0) {
457 if (!$SHORT_FORM) {
458 end_group();
459 $group_seq++; // ID for DIV tags
460 $group_name = substr($this_group, 1);
461 if (strlen($last_group) > 0) echo "<br />";
462 echo "<span class='bold'><input type='checkbox' name='form_cb_$group_seq' id='form_cb_$group_seq' value='1' " .
463 "onclick='return divclick(this,\"div_$group_seq\");'";
464 if ($display_style == 'block') echo " checked";
466 // Modified 6-09 by BM - Translate if applicable
467 echo " /><b>" . xl_layout_label($group_name) . "</b></span>\n";
469 echo "<div id='div_$group_seq' class='section' style='display:$display_style;'>\n";
470 echo " <table border='0' cellpadding='0'>\n";
471 $display_style = 'none';
473 else if (strlen($last_group) == 0) {
474 echo " <table border='0' cellpadding='0'>\n";
476 $last_group = $this_group;
479 // Handle starting of a new row.
480 if (($titlecols > 0 && $cell_count >= $CPR) || $cell_count == 0) {
481 end_row();
482 echo " <tr>";
485 if ($item_count == 0 && $titlecols == 0) $titlecols = 1;
486 $field_id_label='label_'.$frow['field_id'];
487 // Handle starting of a new label cell.
488 if ($titlecols > 0) {
489 end_cell();
490 echo "<td colspan='$titlecols' id='$field_id_label'";
491 echo ($frow['uor'] == 2) ? " class='required'" : " class='bold'";
492 if ($cell_count == 2) echo " style='padding-left:10pt'";
493 echo ">";
494 $cell_count += $titlecols;
496 ++$item_count;
498 echo "<b>";
500 // Modified 6-09 by BM - Translate if applicable
501 if ($frow['title']) echo (xl_layout_label($frow['title']).":"); else echo "&nbsp;";
503 echo "</b>";
505 // Handle starting of a new data cell.
506 if ($datacols > 0) {
507 $id_field_text = "text_".$frow['field_id'];
508 end_cell();
509 echo "<td colspan='$datacols' class='text data'";
510 if ($cell_count > 0) echo " style='padding-left:5pt'". " id='".$id_field_text."'";
511 echo ">";
512 $cell_count += $datacols;
515 ++$item_count;
516 generate_form_field($frow, $currvalue);
519 end_group();
522 <?php
523 if (! $GLOBALS['simplified_demographics']) {
524 $insurancei = getInsuranceProviders();
525 $pid = 0;
526 $insurance_headings = array(xl("Primary Insurance Provider"), xl("Secondary Insurance Provider"), xl("Tertiary Insurance provider"));
527 $insurance_info = array();
528 $insurance_info[1] = getInsuranceData($pid,"primary");
529 $insurance_info[2] = getInsuranceData($pid,"secondary");
530 $insurance_info[3] = getInsuranceData($pid,"tertiary");
532 echo "<br /><span class='bold'><input type='checkbox' name='form_cb_ins' value='1' " .
533 "onclick='return divclick(this,\"div_ins\");'";
534 if ($display_style == 'block') echo " checked";
535 echo " /><b>" . xl('Insurance') . "</b></span>\n";
536 echo "<div id='div_ins' class='section' style='display:$display_style;'>\n";
538 for($i=1;$i<=3;$i++) {
539 $result3 = $insurance_info[$i];
541 <table border="0">
542 <tr>
543 <td valign='top' colspan='2'>
544 <span class='required'><?php echo $insurance_headings[$i -1].":"?></span>
545 <select name="i<?php echo $i?>provider">
546 <option value=""><?php xl('Unassigned','e'); ?></option>
547 <?php
548 foreach ($insurancei as $iid => $iname) {
549 echo "<option value='" . $iid . "'";
550 if (strtolower($iid) == strtolower($result3{"provider"}))
551 echo " selected";
552 echo ">" . $iname . "</option>\n";
555 </select>&nbsp;<a class='iframe medium_modal' href='../practice/ins_search.php' onclick='ins_search(<?php echo $i?>)'>
556 <span> <?php xl('Search/Add Insurer','e'); ?></span></a>
557 </td>
558 </tr>
559 <tr>
560 <td valign=top>
561 <table border="0">
563 <tr>
564 <td>
565 <span class='required'><?php xl('Plan Name','e'); ?>: </span>
566 </td>
567 <td>
568 <input type='entry' size='20' name='i<?php echo $i?>plan_name' value="<?php echo $result3{"plan_name"} ?>"
569 onchange="capitalizeMe(this);" />&nbsp;&nbsp;
570 </td>
571 </tr>
573 <tr>
574 <td>
575 <span class='required'><?php xl('Effective Date','e'); ?>: </span>
576 </td>
577 <td>
578 <input type='entry' size='11' name='i<?php echo $i ?>effective_date'
579 id='i<?php echo $i ?>effective_date'
580 value='<?php echo $result3['date'] ?>'
581 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)'
582 title='yyyy-mm-dd' />
584 <img src='../../interface/pic/show_calendar.gif' align='absbottom' width='24' height='22'
585 id='img_i<?php echo $i ?>effective_date' border='0' alt='[?]' style='cursor:pointer'
586 title='<?php xl('Click here to choose a date','e'); ?>'>
588 <script LANGUAGE="JavaScript">
589 Calendar.setup({inputField:"i<?php echo $i ?>effective_date", ifFormat:"%Y-%m-%d", button:"img_i<?php echo $i; ?>effective_date"});
590 </script>
593 </td>
594 </tr>
596 <tr>
597 <td><span class=required><?php xl('Policy Number','e'); ?>: </span></td>
598 <td><input type='entry' size='16' name='i<?php echo $i?>policy_number' value="<?php echo $result3{"policy_number"}?>"
599 onkeyup='policykeyup(this)'></td>
600 </tr>
602 <tr>
603 <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>
604 </tr>
606 <tr<?php if ($GLOBALS['omit_employers']) echo " style='display:none'"; ?>>
607 <td class='required'><?php xl('Subscriber Employer (SE)','e'); ?><br><span style='font-weight:normal'>
608 (<?php xl('if unemployed enter Student','e'); ?>,<br><?php xl('PT Student, or leave blank','e'); ?>): </span></td>
609 <td><input type=entry size=25 name=i<?php echo $i?>subscriber_employer
610 value="<?php echo $result3{"subscriber_employer"}?>"
611 onchange="capitalizeMe(this);" /></td>
612 </tr>
614 <tr<?php if ($GLOBALS['omit_employers']) echo " style='display:none'"; ?>>
615 <td><span class=required><?php xl('SE Address','e'); ?>: </span></td>
616 <td><input type=entry size=25 name=i<?php echo $i?>subscriber_employer_street
617 value="<?php echo $result3{"subscriber_employer_street"}?>"
618 onchange="capitalizeMe(this);" /></td>
619 </tr>
621 <tr<?php if ($GLOBALS['omit_employers']) echo " style='display:none'"; ?>>
622 <td colspan="2">
623 <table>
624 <tr>
625 <td><span class=required><?php xl('SE City','e'); ?>: </span></td>
626 <td><input type=entry size=15 name=i<?php echo $i?>subscriber_employer_city
627 value="<?php echo $result3{"subscriber_employer_city"}?>"
628 onchange="capitalizeMe(this);" /></td>
629 <td><span class=required><?php echo ($GLOBALS['phone_country_code'] == '1') ? xl('SE State','e') : xl('SE Locality','e') ?>: </span></td>
630 <td>
631 <?php
632 // Modified 7/2009 by BM to incorporate data types
633 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']);
635 </td>
636 </tr>
637 <tr>
638 <td><span class=required><?php echo ($GLOBALS['phone_country_code'] == '1') ? xl('SE Zip Code','e') : xl('SE Postal Code','e') ?>: </span></td>
639 <td><input type=entry size=10 name=i<?php echo $i?>subscriber_employer_postal_code value="<?php echo $result3{"subscriber_employer_postal_code"}?>"></td>
640 <td><span class=required><?php xl('SE Country','e'); ?>: </span></td>
641 <td>
642 <?php
643 // Modified 7/2009 by BM to incorporate data types
644 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']);
646 </td>
647 </tr>
648 </table>
649 </td>
650 </tr>
652 </table>
653 </td>
655 <td valign=top>
656 <span class=required><?php xl('Subscriber','e'); ?>: </span>
657 <input type=entry size=10 name=i<?php echo $i?>subscriber_fname
658 value="<?php echo $result3{"subscriber_fname"}?>"
659 onchange="capitalizeMe(this);" />
660 <input type=entry size=3 name=i<?php echo $i?>subscriber_mname
661 value="<?php echo $result3{"subscriber_mname"}?>"
662 onchange="capitalizeMe(this);" />
663 <input type=entry size=10 name=i<?php echo $i?>subscriber_lname
664 value="<?php echo $result3{"subscriber_lname"}?>"
665 onchange="capitalizeMe(this);" />
666 <br>
667 <span class=required><?php xl('Relationship','e'); ?>: </span>
668 <?php
669 // Modified 6/2009 by BM to use list_options and function
670 generate_form_field(array('data_type'=>1,'field_id'=>('i'.$i.'subscriber_relationship'),'list_id'=>'sub_relation','empty_title'=>' '), $result3['subscriber_relationship']);
672 <a href="javascript:popUp('../../interface/patient_file/summary/browse.php?browsenum=<?php echo $i?>')" class=text>(<?php xl('Browse','e'); ?>)</a><br />
674 <span class=bold><?php xl('D.O.B.','e'); ?>: </span>
675 <input type='entry' size='11' name='i<?php echo $i?>subscriber_DOB'
676 id='i<?php echo $i?>subscriber_DOB'
677 value='<?php echo $result3['subscriber_DOB'] ?>'
678 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)'
679 title='yyyy-mm-dd' />
681 <img src='../../interface/pic/show_calendar.gif' align='absbottom' width='24' height='22'
682 id='img_i<?php echo $i; ?>dob_date' border='0' alt='[?]' style='cursor:pointer'
683 title='<?php xl('Click here to choose a date','e'); ?>'>
685 <script LANGUAGE="JavaScript">
686 Calendar.setup({inputField:"i<?php echo $i?>subscriber_DOB", ifFormat:"%Y-%m-%d", button:"img_i<?php echo $i; ?>dob_date"});
687 </script>
690 <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;
691 <span class=bold><?php xl('Sex','e'); ?>: </span>
692 <?php
693 // Modified 6/2009 by BM to use list_options and function
694 generate_form_field(array('data_type'=>1,'field_id'=>('i'.$i.'subscriber_sex'),'list_id'=>'sex'), $result3['subscriber_sex']);
696 <br>
697 <span class=required><?php xl('Subscriber Address','e'); ?>: </span>
698 <input type=entry size=25 name=i<?php echo $i?>subscriber_street
699 value="<?php echo $result3{"subscriber_street"}?>"
700 onchange="capitalizeMe(this);" /><br>
701 <span class=required><?php xl('City','e'); ?>: </span>
702 <input type=entry size=15 name=i<?php echo $i?>subscriber_city
703 value="<?php echo $result3{"subscriber_city"}?>"
704 onchange="capitalizeMe(this);" />
705 <span class=required><?php echo ($GLOBALS['phone_country_code'] == '1') ? xl('State','e') : xl('Locality','e') ?>: </span>
706 <?php
707 // Modified 7/2009 by BM to incorporate data types
708 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']);
710 <br />
711 <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"}?>">
712 <span class='required'<?php if ($GLOBALS['omit_employers']) echo " style='display:none'"; ?>>
713 <?php xl('Country','e'); ?>: </span>
714 <?php
715 // Modified 7/2009 by BM to incorporate data types
716 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']);
718 <br />
719 <span class=bold><?php xl('Subscriber Phone','e'); ?>:
720 <input type='text' size='20' name='i<?php echo $i?>subscriber_phone' value='<?php echo $result3["subscriber_phone"] ?>' onkeyup='phonekeyup(this,mypcc)' />
721 </span><br />
722 <span class=bold><?php xl('CoPay','e'); ?>: <input type=text size="6" name=i<?php echo $i?>copay value="<?php echo $result3{"copay"}?>">
723 </span><br />
724 <span class='required'><?php xl('Accept Assignment','e'); ?>: </span>
725 <select name=i<?php echo $i?>accept_assignment>
726 <option value="TRUE" <?php if (strtoupper($result3{"accept_assignment"}) == "TRUE") echo "selected"?>><?php xl('YES','e'); ?></option>
727 <option value="FALSE" <?php if (strtoupper($result3{"accept_assignment"}) == "FALSE") echo "selected"?>><?php xl('NO','e'); ?></option>
728 </select>
729 </td>
730 </tr>
732 </table>
733 <hr />
734 <?php
736 echo "</div>\n";
737 } // end of "if not simplified_demographics"
740 <?php if (!$SHORT_FORM) echo " <center>\n"; ?>
741 <br />
742 <?php if ($WITH_SEARCH) { ?>
743 <input type="button" id="search" value=<?php xl('Search','e','\'','\''); ?>
744 style='background-color:<?php echo $searchcolor; ?>' />
745 &nbsp;&nbsp;
746 <?php } ?>
747 <input type="button" name='create' id="create" value=<?php xl('Create New Patient','e','\'','\''); ?> />
749 </center>
751 </td>
752 <td align='right' valign='top' width='1%' nowrap>
753 <!-- Image upload stuff was here but got moved. -->
754 </td>
755 </tr>
756 </table>
758 </form>
760 <!-- include support for the list-add selectbox feature -->
761 <?php include($GLOBALS['fileroot']."/library/options_listadd.inc"); ?>
763 </body>
765 <script language="JavaScript">
767 // hard code validation for old validation, in the new validation possible to add match rules
768 <?php if($GLOBALS['new_validate'] == 0) { ?>
770 // fix inconsistently formatted phone numbers from the database
771 var f = document.forms[0];
772 if (f.form_phone_contact) phonekeyup(f.form_phone_contact,mypcc);
773 if (f.form_phone_home ) phonekeyup(f.form_phone_home ,mypcc);
774 if (f.form_phone_biz ) phonekeyup(f.form_phone_biz ,mypcc);
775 if (f.form_phone_cell ) phonekeyup(f.form_phone_cell ,mypcc);
777 <?php }?>
779 <?php echo $date_init; ?>
781 // -=- jQuery makes life easier -=-
783 // var matches = 0; // number of patients that match the demographic information being entered
784 // var override = false; // flag that overrides the duplication warning
786 $(document).ready(function() {
787 enable_modals();
788 $(".medium_modal").fancybox( {
789 'overlayOpacity' : 0.0,
790 'showCloseButton' : true,
791 'frameHeight' : 460,
792 'frameWidth' : 650
794 // added to integrate insurance stuff
795 <?php for ($i=1;$i<=3;$i++) { ?>
796 $("#form_i<?php echo $i?>subscriber_relationship").change(function() { auto_populate_employer_address<?php echo $i?>(); });
797 <?php } ?>
799 $('#search').click(function() { searchme(); });
800 $('#create').click(function() { check()});
802 var check = function(e) {
803 <?php if($GLOBALS['new_validate']){?>
804 var valid = submitme(<?php echo $GLOBALS['new_validate'] ? 1 : 0;?>,e,"DEM");
805 <?php }else{?>
806 top.restoreSession();
807 var f = document.forms[0];
808 var valid = validate(f);
809 <?php }?>
810 if (valid) {
811 if (force_submit) {
812 // In this case dups were shown already and Save should just save.
813 f.submit();
814 return;
817 <?php
818 // D in edit_options indicates the field is used in duplication checking.
819 // This constructs a list of the names of those fields.
820 $mflist = "";
821 $mfres = sqlStatement("SELECT * FROM layout_options " .
822 "WHERE form_id = 'DEM' AND uor > 0 AND field_id != '' AND " .
823 "edit_options LIKE '%D%' " .
824 "ORDER BY group_name, seq");
825 while ($mfrow = sqlFetchArray($mfres)) {
826 $field_id = $mfrow['field_id'];
827 if (strpos($field_id, 'em_') === 0) continue;
828 if (!empty($mflist)) $mflist .= ",";
829 $mflist .= "'" . htmlentities($field_id) . "'";
832 // Build and invoke the URL to create the dup-checker dialog.
833 var url = 'new_search_popup.php';
834 var flds = new Array(<?php echo $mflist; ?>);
835 var separator = '?';
836 for (var i = 0; i < flds.length; ++i) {
837 var fval = $('#form_' + flds[i]).val();
838 if (fval && fval != '') {
839 url += separator;
840 separator = '&';
841 url += 'mf_' + flds[i] + '=' + encodeURIComponent(fval);
844 dlgopen(url, '_blank', 700, 500);
845 } // end function
846 } // end function
849 // Set onclick/onfocus handlers for toggling background color.
850 <?php
851 $lres = getLayoutRes();
852 while ($lrow = sqlFetchArray($lres)) {
853 $field_id = $lrow['field_id'];
854 if (strpos($field_id, 'em_') === 0) continue;
855 switch(getSearchClass($lrow['data_type'])) {
856 case 1:
857 echo " \$('#form_$field_id').click(function() { toggleSearch(this); });\n";
858 break;
859 case 2:
860 echo " \$('#form_$field_id').click(function() { selClick(this); });\n";
861 echo " \$('#form_$field_id').blur(function() { selBlur(this); });\n";
862 break;
867 }); // end document.ready
869 </script>
870 <?php /*Include the validation script and rules for this form*/
871 $form_id="DEM";
874 <?php include_once("$srcdir/validation/validation_script.js.php");?>
875 <script language='JavaScript'>
876 // Array of skip conditions for the checkSkipConditions() function.
877 var skipArray = [
878 <?php echo $condition_str; ?>
880 checkSkipConditions();
881 $("input").change(function() {
882 checkSkipConditions();
884 $("select").change(function() {
885 checkSkipConditions();
887 </script>
889 </html>