6 * @link http://www.open-emr.org
7 * @author Brady Miller <brady.g.miller@gmail.com>
8 * @copyright Copyright (c) 2017 Brady Miller <brady.g.miller@gmail.com>
9 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
12 require_once("../../globals.php");
13 require_once("$srcdir/acl.inc");
14 require_once("$srcdir/options.inc.php");
15 require_once("$srcdir/erx_javascript.inc.php");
16 require_once("$srcdir/validation/LBF_Validation.php");
17 require_once("$srcdir/patientvalidation.inc.php");
18 require_once("$srcdir/pid.inc");
19 require_once("$srcdir/patient.inc");
21 use OpenEMR\Common\Csrf\CsrfUtils
;
22 use OpenEMR\Core\Header
;
23 use OpenEMR\Events\PatientDemographics\UpdateEvent
;
25 // Session pid must be right or bad things can happen when demographics are saved!
27 $set_pid = $_GET["set_pid"] ?
$_GET["set_pid"] : $_GET["pid"];
28 if ($set_pid && $set_pid != $_SESSION["pid"]) {
32 $result = getPatientData($pid, "*, DATE_FORMAT(DOB,'%Y-%m-%d') as DOB_YMD");
33 $result2 = getEmployerData($pid);
35 // Check authorization.
37 // Create and fire the patient demographics update event
38 $updateEvent = new UpdateEvent($pid);
39 $updateEvent = $GLOBALS["kernel"]->getEventDispatcher()->dispatch(UpdateEvent
::EVENT_HANDLE
, $updateEvent, 10);
41 if (!$updateEvent->authorized() ||
42 !acl_check('patients', 'demo', '', 'write')) {
43 die(xlt('Updating demographics is not authorized.'));
46 if ($result['squad'] && ! acl_check('squads', $result['squad'])) {
47 die(xlt('You are not authorized to access this squad.'));
50 if (!acl_check('patients', 'demo', '', array('write','addonly'))) {
51 die(xlt('Adding demographics is not authorized.'));
55 $CPR = 4; // cells per row
57 // $statii = array('married','single','divorced','widowed','separated','domestic partner');
58 // $langi = getLanguages();
59 // $ethnoraciali = getEthnoRacials();
60 // $provideri = getProviderInfo();
61 if ($GLOBALS['insurance_information'] != '0') {
62 $insurancei = getInsuranceProvidersExtra();
64 $insurancei = getInsuranceProviders();
67 $fres = sqlStatement("SELECT * FROM layout_options " .
68 "WHERE form_id = 'DEM' AND uor > 0 " .
69 "ORDER BY group_id, seq");
74 <title
><?php
echo xlt('Edit Current Patient'); ?
></title
>
76 <?php Header
::setupHeader(['datetime-picker','common','select2']); ?
>
86 <?php
include_once($GLOBALS['srcdir'] . "/options.js.php"); ?
>
88 <script type
="text/javascript">
90 // Support for beforeunload handler.
91 var somethingChanged
= false;
93 $
(document
).ready(function(){
96 $
(".medium_modal").on('click', function(e
) {
97 e
.preventDefault();e
.stopPropagation();
98 let title
= <?php
echo xlj('Insurance Search/Select/Add'); ?
>;
99 dlgopen('', '', 700, 460, '', title
, {
101 {text
: <?php
echo xlj('Close'); ?
>, close
: true, style
: 'default btn-sm'}
107 url
: $
(this
).attr('href')
111 $
('.datepicker').datetimepicker({
112 <?php
$datetimepicker_timepicker = false; ?
>
113 <?php
$datetimepicker_showseconds = false; ?
>
114 <?php
$datetimepicker_formatInput = true; ?
>
115 <?php
require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?
>
116 <?php
// can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
118 $
('.datetimepicker').datetimepicker({
119 <?php
$datetimepicker_timepicker = true; ?
>
120 <?php
$datetimepicker_showseconds = false; ?
>
121 <?php
$datetimepicker_formatInput = true; ?
>
122 <?php
require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?
>
123 <?php
// can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
126 // Support for beforeunload handler.
127 $
('.tab input, .tab select, .tab textarea').change(function() {
128 somethingChanged
= true;
130 window
.addEventListener("beforeunload", function (e
) {
131 if (somethingChanged
&& !top
.timed_out
) {
132 var msg
= <?php
echo xlj('You have unsaved changes.'); ?
>;
133 e
.returnValue
= msg
; // Gecko, Trident, Chrome 34+
134 return msg
; // Gecko, WebKit, Chrome <34
138 if (window
.checkSkipConditions
) {
139 checkSkipConditions();
143 var mypcc
= <?php
echo js_escape($GLOBALS['phone_country_code']); ?
>;
145 //code used from http://tech.irt.org/articles/js037/
146 function replace(string,text
,by
) {
147 // Replaces text with by in string
148 var strLength
= string.length
, txtLength
= text
.length
;
149 if ((strLength
== 0) ||
(txtLength
== 0)) return string;
151 var i
= string.indexOf(text
);
152 if ((!i
) && (text
!= string.substring(0,txtLength
))) return string;
153 if (i
== -1) return string;
155 var newstr
= string.substring(0,i
) + by
;
157 if (i+txtLength
< strLength
)
158 newstr +
= replace(string.substring(i+txtLength
,strLength
),text
,by
);
163 function upperFirst(string,text
) {
164 return replace(string,text
,text
.charAt(0).toUpperCase() + text
.substring(1,text
.length
));
167 <?php
for ($i=1; $i<=3; $i++
) { ?
>
168 function auto_populate_employer_address
<?php
echo attr($i); ?
>(){
169 var f
= document
.demographics_form
;
170 if (f
.form_i
<?php
echo attr($i); ?
>subscriber_relationship
.options
[f
.form_i
<?php
echo attr($i); ?
>subscriber_relationship
.selectedIndex
].value
== "self")
172 f
.i
<?php
echo attr($i); ?
>subscriber_fname
.value
=f
.form_fname
.value
;
173 f
.i
<?php
echo attr($i); ?
>subscriber_mname
.value
=f
.form_mname
.value
;
174 f
.i
<?php
echo attr($i); ?
>subscriber_lname
.value
=f
.form_lname
.value
;
175 f
.i
<?php
echo attr($i); ?
>subscriber_street
.value
=f
.form_street
.value
;
176 f
.i
<?php
echo attr($i); ?
>subscriber_city
.value
=f
.form_city
.value
;
177 f
.form_i
<?php
echo attr($i); ?
>subscriber_state
.value
=f
.form_state
.value
;
178 f
.i
<?php
echo attr($i); ?
>subscriber_postal_code
.value
=f
.form_postal_code
.value
;
179 if (f
.form_country_code
)
180 f
.form_i
<?php
echo attr($i); ?
>subscriber_country
.value
=f
.form_country_code
.value
;
181 f
.i
<?php
echo attr($i); ?
>subscriber_phone
.value
=f
.form_phone_home
.value
;
182 f
.i
<?php
echo attr($i); ?
>subscriber_DOB
.value
=f
.form_DOB
.value
;
183 if(typeof f
.form_ss
!="undefined")
185 f
.i
<?php
echo attr($i); ?
>subscriber_ss
.value
=f
.form_ss
.value
;
187 f
.form_i
<?php
echo attr($i); ?
>subscriber_sex
.value
= f
.form_sex
.value
;
188 f
.i
<?php
echo attr($i); ?
>subscriber_employer
.value
=f
.form_em_name
.value
;
189 f
.i
<?php
echo attr($i); ?
>subscriber_employer_street
.value
=f
.form_em_street
.value
;
190 f
.i
<?php
echo attr($i); ?
>subscriber_employer_city
.value
=f
.form_em_city
.value
;
191 f
.form_i
<?php
echo attr($i); ?
>subscriber_employer_state
.value
=f
.form_em_state
.value
;
192 f
.i
<?php
echo attr($i); ?
>subscriber_employer_postal_code
.value
=f
.form_em_postal_code
.value
;
193 if (f
.form_em_country
)
194 f
.form_i
<?php
echo attr($i); ?
>subscriber_employer_country
.value
=f
.form_em_country
.value
;
200 function popUp(URL
) {
203 top
.restoreSession();
204 eval("page" + id +
" = window.open(URL, '" + id +
"', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=400,height=300,left = 440,top = 362');");
207 function checkNum () {
208 var re
= new RegExp();
210 str
=document
.demographics_form
.monthly_income
.value
;
214 alert(<?php
echo xlj('Please enter a monetary amount using only numbers and a decimal point.'); ?
>);
218 // Indicates which insurance slot is being updated.
219 var insurance_index
= 0;
221 // The OnClick handler for searching/adding the insurance company.
222 function ins_search(ins
) {
223 insurance_index
= ins
;
226 function InsSaveClose() {
227 top
.restoreSession();
228 document
.location
.reload();
230 // The ins_search.php window calls this to set the selected insurance.
231 function set_insurance(ins_id
, ins_name
) {
232 var thesel
= document
.forms
[0]['i' + insurance_index +
'provider'];
233 var theopts
= thesel
.options
; // the array of Option objects
235 for (; i
< theopts
.length
; ++i
) {
236 if (theopts
[i
].value
== ins_id
) {
237 theopts
[i
].selected
= true;
241 // no matching option was found so create one, append it to the
242 // end of the list, and select it.
243 theopts
[i
] = new Option(ins_name
, ins_id
, false, true);
246 // This capitalizes the first letter of each word in the passed input
247 // element. It also strips out extraneous spaces.
248 function capitalizeMe(elem
) {
249 var a
= elem
.value
.split(' ');
251 for(var i
= 0; i
< a
.length
; ++i
) {
252 if (a
[i
].length
> 0) {
253 if (s
.length
> 0) s +
= ' ';
254 s +
= a
[i
].charAt(0).toUpperCase() + a
[i
].substring(1);
260 function divclick(cb
, divid
) {
261 var divstyle
= document
.getElementById(divid
).style
;
263 divstyle
.display
= 'block';
265 divstyle
.display
= 'none';
270 // Compute the length of a string without leading and trailing spaces.
271 function trimlen(s
) {
273 var j
= s
.length
- 1;
274 for (; i
<= j
&& s
.charAt(i
) == ' '; ++i
);
275 for (; i
<= j
&& s
.charAt(j
) == ' '; --j
);
280 function validate(f
) {
282 var errMsgs
= new Array();
283 <?php
generate_layout_validation('DEM'); ?
>
286 msg +
= <?php
echo xlj('The following fields are required'); ?
> +
":\n\n";
287 for ( var i
= 0; i
< errMsgs
.length
; i++
) {
288 msg +
= errMsgs
[i
] +
"\n";
290 msg +
= "\n" +
<?php
echo xlj('Please fill them in before continuing.'); ?
>;
292 if ( errMsgs
.length
> 0 ) {
296 //Misc Deceased Date Validation for Future Date
297 var dateVal
= document
.getElementById("form_deceased_date").value
;
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(dateVal
> currentDate
)
308 alert (<?php
echo xlj("Deceased Date should not be greater than Today"); ?
>);
312 //Patient Data validations
313 <?php
if ($GLOBALS['erx_enable']) { ?
>
315 for(i
=0;i
<f
.length
;i++
){
316 if(f
[i
].type
=='text' && f
[i
].value
)
318 if(f
[i
].name
== 'form_fname' || f
[i
].name
== 'form_mname' || f
[i
].name
== 'form_lname')
320 alertMsg +
= checkLength(f
[i
].name
,f
[i
].value
,35);
321 alertMsg +
= checkUsername(f
[i
].name
,f
[i
].value
);
323 else if(f
[i
].name
== 'form_street' || f
[i
].name
== 'form_city')
325 alertMsg +
= checkLength(f
[i
].name
,f
[i
].value
,35);
326 alertMsg +
= checkAlphaNumericExtended(f
[i
].name
,f
[i
].value
);
328 else if(f
[i
].name
== 'form_phone_home')
330 alertMsg +
= checkPhone(f
[i
].name
,f
[i
].value
);
342 // Some insurance validation.
343 for (var i
= 1; i
<= 3; ++i
) {
344 subprov
= 'i' + i +
'provider';
345 if (!f
[subprov
] || f
[subprov
].selectedIndex
<= 0) continue;
346 var subpfx
= 'i' + i +
'subscriber_';
347 var subrelat
= f
['form_' + subpfx +
'relationship'];
349 f
[subpfx +
'fname'].value
== f
.form_fname
.value
&&
350 f
[subpfx +
'mname'].value
== f
.form_mname
.value
&&
351 f
[subpfx +
'lname'].value
== f
.form_lname
.value
;
352 var ss_regexp
=/[0-9][0-9][0-9]-?
[0-9][0-9]-?
[0-9][0-9][0-9][0-9]/;
355 if(typeof f
.form_ss
!="undefined")
357 samess
= f
[subpfx +
'ss'].value
== f
.form_ss
.value
;
358 ss_valid
=ss_regexp
.test(f
[subpfx +
'ss'].value
) && ss_regexp
.test(f
.form_ss
.value
);
360 if (subrelat
.options
[subrelat
.selectedIndex
].value
== "self") {
362 if (!confirm(<?php
echo xlj('Subscriber relationship is self but name is different! Is this really OK?'); ?
>))
365 if (!samess
&& ss_valid
) {
366 if(!confirm(<?php
echo js_escape(xl('Subscriber relationship is self but SS number is different!')." ".xl("Is this really OK?")); ?
>))
372 if (!confirm(<?php
echo xlj('Subscriber relationship is not self but name is the same! Is this really OK?'); ?
>))
375 if (samess
&& ss_valid
) {
376 if(!confirm(<?php
echo js_escape(xl('Subscriber relationship is not self but SS number is the same!')." ".xl("Is this really OK?")); ?
>))
382 return errMsgs
.length
< 1;
387 // Onkeyup handler for policy number. Allows only A-Z and 0-9.
388 function policykeyup(e
) {
389 var v
= e
.value
.toUpperCase();
390 var filteredString
="";
391 for (var i
= 0; i
< v
.length
; ++i
) {
393 if ((c
>= '0' && c
<= '9') ||
394 (c
>= 'A' && c
<= 'Z') ||
405 e
.value
= filteredString
;
409 // Added 06/2009 by BM to make compatible with list_options table and functions - using jquery
412 <?php
for ($i=1; $i<=3; $i++
) { ?
>
413 $
("#form_i<?php echo attr($i); ?>subscriber_relationship").change(function() { auto_populate_employer_address
<?php
echo attr($i); ?
>(); });
422 /*Get the constraint from the DB-> LBF forms accordinf the form_id*/
423 $constraints = LBF_Validation
::generate_validate_constraints("DEM");
425 <script
> var constraints
= <?php
echo $constraints;?
>; </script
>
427 <body
class="body_top">
429 <form action
='demographics_save.php' name
='demographics_form' id
="DEM" method
='post' onsubmit
="submitme(<?php echo $GLOBALS['new_validate'] ? 1 : 0;?>,event,'DEM',constraints)">
430 <input type
="hidden" name
="csrf_token_form" value
="<?php echo attr(CsrfUtils::collectCsrfToken()); ?>" />
431 <input type
='hidden' name
='mode' value
='save' />
432 <input type
='hidden' name
='db_id' value
="<?php echo attr($result['id']); ?>" />
434 <div
class="container-fluid">
436 <div
class="col-xs-12">
437 <div
class="page-header">
438 <h2
><?php
echo xlt('Edit Current Patient');?
></h2
>
441 <div
class="col-xs-12">
442 <div
class="btn-group">
443 <button type
="submit" class="btn btn-default btn-save" id
="submit_btn" disabled
="disabled" value
="<?php echo xla('Save'); ?>">
444 <?php
echo xlt('Save'); ?
>
446 <a
class="btn btn-link btn-cancel" href
="demographics.php" onclick
="top.restoreSession()">
447 <?php
echo xlt('Cancel'); ?
>
458 global $item_count, $cell_count;
459 if ($item_count > 0) {
467 global $cell_count, $CPR;
469 if ($cell_count > 0) {
470 for (; $cell_count < $CPR; ++
$cell_count) {
482 if (strlen($last_group) > 0) {
492 $display_style = 'block';
494 $group_seq=0; // this gives the DIV blocks unique IDs
499 <div
class="section-header">
500 <span
class="text"><b
> <?php
echo xlt("Demographics")?
></b
></span
>
506 <?php
display_layout_tabs('DEM', $result, $result2); ?
>
509 <div
class="tabContainer">
510 <?php
display_layout_tabs_data_editable('DEM', $result, $result2); ?
>
519 if (! $GLOBALS['simplified_demographics']) {
520 $insurance_headings = array(xl("Primary Insurance Provider"), xl("Secondary Insurance Provider"), xl("Tertiary Insurance provider"));
521 $insurance_info = array();
522 $insurance_info[1] = getInsuranceData($pid, "primary");
523 $insurance_info[2] = getInsuranceData($pid, "secondary");
524 $insurance_info[3] = getInsuranceData($pid, "tertiary");
527 <div
class="section-header">
528 <span
class="text"><b
><?php
echo xlt("Insurance")?
></b
></span
>
530 <div id
="INSURANCE" >
533 foreach (array('primary','secondary','tertiary') as $instype) {
534 ?
><li
<?php
echo $instype == 'primary' ?
'class="current"' : '' ?
>><a href
="#"><?php
$CapInstype=ucfirst($instype);
535 echo xlt($CapInstype); ?
></a
></li
><?php
540 <div
class="tabContainer">
543 for ($i=1; $i<=3; $i++
) {
544 $result3 = $insurance_info[$i];
547 <div
class="tab <?php echo $i == 1 ? 'current': '' ?>" style
='height:auto;width:auto'> <!---display icky
, fix to auto
-->
550 <div
class="col-md-6">
555 <label
class='required'><?php
echo text($insurance_headings[$i -1])." "?
></label
>
557 <td
class='required'>:</td
>
559 <a href
="../../practice/ins_search.php" class="medium_modal css_button" onclick
="ins_search(<?php echo attr_js($i); ?>)">
560 <span
><?php
echo xlt('Search/Add') ?
></span
>
562 <select name
="i<?php echo attr($i); ?>provider" class="form-control sel2" style
="width: 300;">
563 <option value
=""><?php
echo xlt('Unassigned'); ?
></option
>
565 foreach ($insurancei as $iid => $iname) {
566 echo "<option value='" . attr($iid) . "'";
567 if (strtolower($iid) == strtolower($result3["provider"])) {
571 echo ">" . text($iname) . "</option>\n";
581 <label
class='required'><?php
echo xlt('Plan Name'); ?
> </label
>
583 <td
class='required'>:</td
>
585 <input type
='entry' class='form-control' size
='20' name
='i<?php echo attr($i); ?>plan_name' value
="<?php echo attr($result3["plan_name
"]); ?>"
586 onchange
="capitalizeMe(this);" /> 
; 
;
592 <label
class='required'><?php
echo xlt('Effective Date'); ?
></label
>
594 <td
class='required'>:</td
>
596 <input type
='entry' size
='16' class='datepicker form-control' id
='i<?php echo attr($i); ?>effective_date' name
='i<?php echo attr($i); ?>effective_date'
597 value
='<?php echo attr(oeFormatShortDate($result3['date
'])); ?>'
603 <td
><label
class=required
><?php
echo xlt('Policy Number'); ?
></label
></td
>
604 <td
class='required'>:</td
>
605 <td
><input type
='entry' class='form-control' size
='16' name
='i<?php echo attr($i); ?>policy_number' value
="<?php echo attr($result3["policy_number
"]); ?>"
606 onkeyup
='policykeyup(this)'></td
>
610 <td
><label
class=required
><?php
echo xlt('Group Number'); ?
></label
></td
>
611 <td
class='required'>:</td
>
612 <td
><input type
=entry
class='form-control' size
=16 name
=i
<?php
echo attr($i); ?
>group_number value
="<?php echo attr($result3["group_number
"]); ?>" onkeyup
='policykeyup(this)'></td
>
615 <tr
<?php
if ($GLOBALS['omit_employers']) {
616 echo " style='display:none'";
618 <td
class='required'><?php
echo xlt('Subscriber Employer (SE)'); ?
><br
><label style
='font-weight:normal'>
619 (<?php
echo xlt('if unemployed enter Student'); ?
>,<br
><?php
echo xlt('PT Student, or leave blank'); ?
>) </label
></td
>
620 <td
class='required'>:</td
>
621 <td
><input type
=entry
class='form-control' size
=25 name
=i
<?php
echo attr($i); ?
>subscriber_employer
622 value
="<?php echo attr($result3["subscriber_employer
"]); ?>"
623 onchange
="capitalizeMe(this);" /></td
>
626 <tr
<?php
if ($GLOBALS['omit_employers']) {
627 echo " style='display:none'";
629 <td
><label
class=required
><?php
echo xlt('SE Address'); ?
></label
></td
>
630 <td
class='required'>:</td
>
631 <td
><input type
=entry
class='form-control' size
=25 name
=i
<?php
echo attr($i); ?
>subscriber_employer_street
632 value
="<?php echo attr($result3["subscriber_employer_street
"]); ?>"
633 onchange
="capitalizeMe(this);" /></td
>
636 <tr
<?php
if ($GLOBALS['omit_employers']) {
637 echo " style='display:none'";
642 <td
><label
class=required
><?php
echo xlt('SE City'); ?
>: </label
></td
>
643 <td
><input type
=entry
class='form-control' size
=15 name
=i
<?php
echo attr($i); ?
>subscriber_employer_city
644 value
="<?php echo attr($result3["subscriber_employer_city
"]); ?>"
645 onchange
="capitalizeMe(this);" /></td
>
646 <td
><label
class=required
><?php
echo ($GLOBALS['phone_country_code'] == '1') ?
xlt('SE State') : xlt('SE Locality') ?
>: </label
></td
>
649 // Modified 7/2009 by BM to incorporate data types
650 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']);
655 <td
><label
class=required
><?php
echo ($GLOBALS['phone_country_code'] == '1') ?
xlt('SE Zip Code') : xlt('SE Postal Code') ?
>: </label
></td
>
656 <td
><input type
=entry
class='form-control' size
=15 name
=i
<?php
echo attr($i); ?
>subscriber_employer_postal_code value
="<?php echo attr($result3["subscriber_employer_postal_code
"]); ?>"></td
>
657 <td
><label
class=required
><?php
echo xlt('SE Country'); ?
>: </label
></td
>
660 // Modified 7/2009 by BM to incorporate data types
661 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']);
672 <div
class="col-md-6">
675 <td
><label
class=required
><?php
echo xlt('Relationship'); ?
></label
></td
>
676 <td
class=required
>:</td
>
678 // Modified 6/2009 by BM to use list_options and function
679 generate_form_field(array('data_type'=>1,'field_id'=>('i'.$i.'subscriber_relationship'),'list_id'=>'sub_relation','empty_title'=>' '), $result3['subscriber_relationship']);
682 <a href
="javascript:popUp('browse.php?browsenum=<?php echo attr_url($i); ?>')" class=text
>(<?php
echo xlt('Browse'); ?
>)</a
></td
>
683 <td
></td
><td
></td
><td
></td
><td
></td
>
686 <td width
=120><label
class=required
><?php
echo xlt('Subscriber'); ?
> </label
></td
>
687 <td
class=required
>:</td
>
688 <td colspan
=3><input type
=entry
class='form-control'size
=10 name
=i
<?php
echo attr($i); ?
>subscriber_fname value
="<?php echo attr($result3["subscriber_fname
"]); ?>" onchange
="capitalizeMe(this);" />
689 <input type
=entry
class='form-control' size
=3 name
=i
<?php
echo attr($i); ?
>subscriber_mname value
="<?php echo attr($result3["subscriber_mname
"]); ?>" onchange
="capitalizeMe(this);" />
690 <input type
=entry
class='form-control' size
=10 name
=i
<?php
echo attr($i); ?
>subscriber_lname value
="<?php echo attr($result3["subscriber_lname
"]); ?>" onchange
="capitalizeMe(this);" /></td
>
691 <td
></td
><td
></td
><td
></td
><td
></td
>
694 <td
><label
class=bold
><?php
echo xlt('D.O.B.'); ?
> </label
></td
>
695 <td
class=required
>:</td
>
696 <td
><input type
='entry' size
='11' class='datepicker form-control' id
='i<?php echo attr($i); ?>subscriber_DOB' name
='i<?php echo attr($i); ?>subscriber_DOB' value
='<?php echo attr(oeFormatShortDate($result3['subscriber_DOB
'])); ?>' />
698 <td
><label
class=bold
><?php
echo xlt('Sex'); ?
>: </label
></td
>
700 // Modified 6/2009 by BM to use list_options and function
701 generate_form_field(array('data_type'=>1,'field_id'=>('i'.$i.'subscriber_sex'),'list_id'=>'sex'), $result3['subscriber_sex']);
704 <td
></td
><td
></td
> <td
></td
><td
></td
>
707 <td
class=leftborder
><label
class=bold
><?php
echo xlt('S.S.'); ?
> </label
></td
>
708 <td
class=required
>:</td
>
709 <td
><input type
=entry
class='form-control' size
=11 name
=i
<?php
echo attr($i); ?
>subscriber_ss value
="<?php echo attr(trim($result3["subscriber_ss
"])); ?>"></td
>
713 <td
><label
class=required
><?php
echo xlt('Subscriber Address'); ?
> </label
></td
>
714 <td
class=required
>:</td
>
715 <td
><input type
=entry
class='form-control' size
=20 name
=i
<?php
echo attr($i); ?
>subscriber_street value
="<?php echo attr($result3["subscriber_street
"]); ?>" onchange
="capitalizeMe(this);" /></td
>
717 <td
><label
class=required
><?php
echo ($GLOBALS['phone_country_code'] == '1') ?
xlt('State') : xlt('Locality') ?
>: </label
></td
>
720 // Modified 7/2009 by BM to incorporate data types
721 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']);
726 <td
class=leftborder
><label
class=required
><?php
echo xlt('City'); ?
></label
></td
>
727 <td
class=required
>:</td
>
728 <td
><input type
=entry
class='form-control' size
=11 name
=i
<?php
echo attr($i); ?
>subscriber_city value
="<?php echo attr($result3["subscriber_city
"]); ?>" onchange
="capitalizeMe(this);" /></td
><td
class=leftborder
><label
class='required'<?php
if ($GLOBALS['omit_employers']) {
729 echo " style='display:none'";
730 } ?
>><?php
echo xlt('Country'); ?
>: </label
></td
><td
>
732 // Modified 7/2009 by BM to incorporate data types
733 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']);
738 <td
><label
class=required
><?php
echo ($GLOBALS['phone_country_code'] == '1') ?
xlt('Zip Code') : xlt('Postal Code') ?
> </label
></td
>
739 <td
class=required
>:</td
><td
><input type
=entry
class='form-control' size
=10 name
=i
<?php
echo attr($i); ?
>subscriber_postal_code value
="<?php echo attr($result3["subscriber_postal_code
"]); ?>"></td
>
745 <td
><label
class=bold
><?php
echo xlt('Subscriber Phone'); ?
></label
></td
>
746 <td
class=required
>:</td
>
747 <td
><input type
='text' class='form-control' size
='20' name
='i<?php echo attr($i); ?>subscriber_phone' value
='<?php echo attr($result3["subscriber_phone"]); ?>' onkeyup
='phonekeyup(this,mypcc)' /></td
>
748 <td colspan
=2><label
class=bold
><?php
echo xlt('CoPay'); ?
>: <input type
=text
class='form-control' size
="6" name
=i
<?php
echo attr($i); ?
>copay value
="<?php echo attr($result3["copay
"]); ?>"></label
></td
>
750 </td
><td
></td
><td
></td
>
753 <td colspan
=0><label
class='required'><?php
echo xlt('Accept Assignment'); ?
></label
></td
>
754 <td
class=required
>:</td
>
756 <select
class='form-control' name
=i
<?php
echo attr($i); ?
>accept_assignment
>
757 <option value
="TRUE" <?php
if (strtoupper($result3["accept_assignment"]) == "TRUE") {
759 }?
>><?php
echo xlt('YES'); ?
></option
>
760 <option value
="FALSE" <?php
if (strtoupper($result3["accept_assignment"]) == "FALSE") {
762 }?
>><?php
echo xlt('NO'); ?
></option
>
770 <td
><label
class='bold'><?php
echo xlt('Secondary Medicare Type'); ?
></label
></td
>
771 <td
class='bold'>:</td
>
773 <select
class='form-control sel2' name
=i
<?php
echo attr($i); ?
>policy_type
>
775 foreach ($policy_types as $key => $value) {
776 echo " <option value ='" . attr($key) . "'";
777 if ($key == $result3['policy_type']) {
781 echo ">" . text($value) . "</option>\n";
795 } //end insurer for loop ?>
800 <?php
} // end of "if not simplified_demographics" ?>
807 <script language
="JavaScript">
809 // Array of skip conditions for the checkSkipConditions() function.
811 <?php
echo $condition_str; ?
>
814 // hard code validation for old validation, in the new validation possible to add match rules
815 <?php
if ($GLOBALS['new_validate'] == 0) { ?
>
816 // fix inconsistently formatted phone numbers from the database
817 var f
= document
.forms
[0];
818 if (f
.form_phone_contact
) phonekeyup(f
.form_phone_contact
,mypcc
);
819 if (f
.form_phone_home
) phonekeyup(f
.form_phone_home
,mypcc
);
820 if (f
.form_phone_biz
) phonekeyup(f
.form_phone_biz
,mypcc
);
821 if (f
.form_phone_cell
) phonekeyup(f
.form_phone_cell
,mypcc
);
823 <?php
if (! $GLOBALS['simplified_demographics']) { ?
>
824 phonekeyup(f
.i1subscriber_phone
,mypcc
);
825 phonekeyup(f
.i2subscriber_phone
,mypcc
);
826 phonekeyup(f
.i3subscriber_phone
,mypcc
);
831 <?php
if ($set_pid) { ?
>
832 parent
.left_nav
.setPatient(<?php
echo js_escape($result['fname'] . " " . $result['lname']) . "," . js_escape($pid) . "," . js_escape($result['pubpid']) . ",''," . js_escape(" " . xl('DOB') . ": " . oeFormatShortDate($result['DOB_YMD']) . " " . xl('Age') . ": " . getPatientAgeDisplay($result['DOB_YMD'])); ?
>);
835 <?php
echo $date_init; ?
>
838 <!-- include support
for the
list-add selectbox feature
-->
839 <?php
include $GLOBALS['fileroot']."/library/options_listadd.inc"; ?
>
841 <?php
/*Include the validation script and rules for this form*/
843 //LBF forms use the new validation depending on the global value
844 $use_validate_js=$GLOBALS['new_validate'];
847 <?php
include_once("$srcdir/validation/validation_script.js.php");?
>
851 <script language
='JavaScript'>
852 var duplicateFieldsArray
=[];
854 //This code deals with demographics before save action -
855 <?php
if (($GLOBALS['gbl_edit_patient_form'] == '1') && (checkIfPatientValidationHookIsActive())) :?
>
856 //Use the Zend patient validation hook.
857 //TODO - get the edit part of patient validation hook to work smoothly and then
858 // remove the closeBeforeOpening=1 in the url below.
862 // Use hook to open the controller and get the new patient validation .
863 // when no params are sent this window will be closed from the zend controller.
864 var url
='<?php echo $GLOBALS['web_root
']."/interface/modules/zend_modules/public/patientvalidation";?>';
865 $
("#submit_btn").attr("name","btnSubmit");
866 $
("#submit_btn").attr("id","btnSubmit");
867 $
("#btnSubmit").click(function( event
) {
869 top
.restoreSession();
871 if(!submitme(<?php
echo $GLOBALS['new_validate'] ?
1 : 0;?
>,event
,'DEM',constraints
)){
872 event
.preventDefault();
875 somethingChanged
= false;
877 // D in edit_options indicates the field is used in duplication checking.
878 // This constructs a list of the names of those fields.
880 $mfres = sqlStatement("SELECT field_id FROM layout_options " .
881 "WHERE form_id = 'DEM' AND uor > 0 AND field_id != '' AND " .
882 "(edit_options LIKE '%D%' OR edit_options LIKE '%E%') " .
883 "ORDER BY group_id, seq");
884 while ($mfrow = sqlFetchArray($mfres)) {
885 $field_id = $mfrow['field_id'];
886 if (strpos($field_id, 'em_') === 0) {
890 if (!empty($mflist)) {
894 $mflist .= js_escape($field_id);
897 var flds
= new Array(<?php
echo $mflist; ?
>);
899 var valueIsChanged
=false;
900 for (var i
= 0; i
< flds
.length
; ++i
) {
901 var fval
= $
('#form_' + flds
[i
]).val();
902 if(duplicateFieldsArray
['#form_' + flds
[i
]]!=fval
) {
903 valueIsChanged
= true;
907 if (fval
&& fval
!= '') {
910 url +
= 'mf_' + flds
[i
] +
'=' +
encodeURIComponent(fval
);
915 //Only if check for duplicates values are changed open the popup hook screen
917 event
.preventDefault();
918 //("value has changed for duplicate check inputs");
919 url +
= '&page=edit&closeBeforeOpening=1&mf_id=' +
encodeURIComponent($
("[name='db_id']").val());
920 dlgopen(url
, '_blank', 700, 500);
922 else {//other wise submit me is a success just submit the form
929 $
(document
).ready(function(){
930 //When document is ready collect all the values Marked with D (check duplicate) stored in the db into array duplicateFieldsArray.
931 var flds
= new Array(<?php
echo $mflist; ?
>);
932 for (var i
= 0; i
< flds
.length
; ++i
) {
933 var fval
= $
('#form_' + flds
[i
]).val();
934 duplicateFieldsArray
['#form_' + flds
[i
]] = fval
;
937 <?php
require($GLOBALS['srcdir'] . '/js/xl/select2.js.php'); ?
>