fix: fix none mechanism in issues gui (#6860)
[openemr.git] / interface / patient_file / summary / demographics_full.php
blob1d97f5e6d8989babbd54c80d62043b55e645d877
1 <?php
3 /**
4 * Edit demographics.
6 * @package OpenEMR
7 * @link http://www.open-emr.org
8 * @author Brady Miller <brady.g.miller@gmail.com>
9 * @copyright Copyright (c) 2017 Brady Miller <brady.g.miller@gmail.com>
10 * @copyright Copyright (c) 2021 Rod Roark <rod@sunsetsystems.com>
11 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
14 require_once("../../globals.php");
15 require_once("$srcdir/options.inc.php");
16 require_once("$srcdir/validation/LBF_Validation.php");
17 require_once("$srcdir/patientvalidation.inc.php");
18 require_once("$srcdir/pid.inc.php");
19 require_once("$srcdir/patient.inc.php");
21 use OpenEMR\Common\Acl\AclMain;
22 use OpenEMR\Common\Csrf\CsrfUtils;
23 use OpenEMR\Core\Header;
24 use OpenEMR\Events\PatientDemographics\UpdateEvent;
26 // Session pid must be right or bad things can happen when demographics are saved!
28 $set_pid = $_GET["set_pid"] ?? ($_GET["pid"] ?? null);
29 if ($set_pid && $set_pid != $_SESSION["pid"]) {
30 setpid($set_pid);
33 $result = getPatientData($pid, "*, DATE_FORMAT(DOB,'%Y-%m-%d') as DOB_YMD");
34 $result2 = getEmployerData($pid);
36 // Check authorization.
37 if ($pid) {
38 // Create and fire the patient demographics update event
39 $updateEvent = new UpdateEvent($pid);
40 $updateEvent = $GLOBALS["kernel"]->getEventDispatcher()->dispatch($updateEvent, UpdateEvent::EVENT_HANDLE, 10);
42 if (
43 !$updateEvent->authorized() ||
44 !AclMain::aclCheckCore('patients', 'demo', '', 'write')
45 ) {
46 die(xlt('Updating demographics is not authorized.'));
49 if ($result['squad'] && ! AclMain::aclCheckCore('squads', $result['squad'])) {
50 die(xlt('You are not authorized to access this squad.'));
52 } else {
53 if (!AclMain::aclCheckCore('patients', 'demo', '', array('write','addonly'))) {
54 die(xlt('Adding demographics is not authorized.'));
58 $CPR = 4; // cells per row
60 // $statii = array('married','single','divorced','widowed','separated','domestic partner');
61 // $provideri = getProviderInfo();
62 if ($GLOBALS['insurance_information'] != '0') {
63 $insurancei = getInsuranceProvidersExtra();
64 } else {
65 $insurancei = getInsuranceProviders();
67 //Check to see if only one insurance is allowed
68 if ($GLOBALS['insurance_only_one']) {
69 $insurance_array = array('primary');
70 } else {
71 $insurance_array = array('primary', 'secondary', 'tertiary');
74 <!DOCTYPE html>
75 <html>
76 <head>
77 <?php Header::setupHeader(['datetime-picker','common','select2', 'erx']);
79 <title><?php echo xlt('Edit Current Patient'); ?></title>
81 <?php include_once($GLOBALS['srcdir'] . "/options.js.php"); ?>
83 <script>
85 // Support for beforeunload handler.
86 var somethingChanged = false;
88 $(function () {
89 tabbify();
91 $('.swapIns').hide();
93 $(".select-previous-names").select2({
94 theme: "bootstrap4",
95 dropdownAutoWidth: true,
96 width: 'resolve',
97 <?php require($GLOBALS['srcdir'] . '/js/xl/select2.js.php'); ?>
98 }).on("select2:unselecting", function (e) {
99 $(this).data('state', 'unselected');
100 var data = e.params.args.data;
101 const message = "<span>" + xl("Are You Sure you want to delete this name?") + "</span>";
102 const ele = opener.document.getElementById('form_name_history');
103 dialog.confirm(message).then(returned => {
104 if (returned !== true) {
105 if (data !== false) {
106 $(".select-previous-names > option").prop("selected", "selected").trigger("change");
108 return false;
110 // delete from table.
111 const url = top.webroot_url + '/library/ajax/specialty_form_ajax.php?delete=true';
112 let doData = new FormData();
113 doData.append('csrf_token_form', <?php echo js_escape(CsrfUtils::collectCsrfToken()); ?>);
114 doData.append('id', data.id);
115 doData.append('task_name_history', 'delete');
116 fetch(url, {
117 method: 'POST',
118 body: doData
119 }).then(rtn => rtn.json()).then((rtn) => {
120 dialog.alert(xl("Returned: " + rtn));
121 if (rtn === 'Success') {
122 $(".select-previous-names option[value=" + data.id + "]").remove();
126 }).on("select2:open", function (e) {
127 if ($(this).data('state') === 'unselected') {
128 $(this).removeData('state');
129 let self = $(this);
130 setTimeout(function () {
131 self.select2('close');
132 }, 1);
134 }).on('select2:opening select2:closing', function (event) {
135 let $search = $(this).parent().find('.select2-search__field');
136 $search.prop('disabled', true);
139 // careteam select2
140 $(".select-dropdown").select2({
141 theme: "bootstrap4",
142 dropdownAutoWidth: true,
143 width: 'resolve',
144 <?php require($GLOBALS['srcdir'] . '/js/xl/select2.js.php'); ?>
146 if (typeof error !== 'undefined') {
147 if (error) {
148 alertMsg(error);
152 $(".medium_modal").on('click', function(e) {
153 e.preventDefault();e.stopPropagation();
154 let title = <?php echo xlj('Insurance Search/Select/Add'); ?>;
155 let ins_url = $(this).attr('href') + encodeURIComponent(sendInsToSearch(insurance_index));
156 dlgopen('', '', 700, 600, '', title, {
157 buttons: [
158 {text: <?php echo xlj('Close'); ?>, close: true, style: 'default btn-sm'}
160 allowResize: true,
161 allowDrag: true,
162 dialogId: '',
163 type: 'iframe',
164 url: ins_url
168 $('.datepicker').datetimepicker({
169 <?php $datetimepicker_timepicker = false; ?>
170 <?php $datetimepicker_showseconds = false; ?>
171 <?php $datetimepicker_formatInput = true; ?>
172 <?php $datetimepicker_minDate = false; ?>
173 <?php $datetimepicker_maxDate = false; ?>
174 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
175 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
177 $('.datetimepicker').datetimepicker({
178 <?php $datetimepicker_timepicker = true; ?>
179 <?php $datetimepicker_showseconds = false; ?>
180 <?php $datetimepicker_formatInput = true; ?>
181 <?php $datetimepicker_minDate = false; ?>
182 <?php $datetimepicker_maxDate = false; ?>
183 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
184 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
186 $('.datepicker-past').datetimepicker({
187 <?php $datetimepicker_timepicker = false; ?>
188 <?php $datetimepicker_showseconds = false; ?>
189 <?php $datetimepicker_formatInput = true; ?>
190 <?php $datetimepicker_minDate = false; ?>
191 <?php $datetimepicker_maxDate = '+1970/01/01'; ?>
192 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
193 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
195 $('.datetimepicker-past').datetimepicker({
196 <?php $datetimepicker_timepicker = true; ?>
197 <?php $datetimepicker_showseconds = false; ?>
198 <?php $datetimepicker_formatInput = true; ?>
199 <?php $datetimepicker_minDate = false; ?>
200 <?php $datetimepicker_maxDate = '+1970/01/01'; ?>
201 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
202 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
204 $('.datepicker-future').datetimepicker({
205 <?php $datetimepicker_timepicker = false; ?>
206 <?php $datetimepicker_showseconds = false; ?>
207 <?php $datetimepicker_formatInput = true; ?>
208 <?php $datetimepicker_minDate = '-1970/01/01'; ?>
209 <?php $datetimepicker_maxDate = false; ?>
210 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
211 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
213 $('.datetimepicker-future').datetimepicker({
214 <?php $datetimepicker_timepicker = true; ?>
215 <?php $datetimepicker_showseconds = false; ?>
216 <?php $datetimepicker_formatInput = true; ?>
217 <?php $datetimepicker_minDate = '-1970/01/01'; ?>
218 <?php $datetimepicker_maxDate = false; ?>
219 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
220 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
223 // Support for beforeunload handler.
224 $('.tab input, .tab select, .tab textarea').change(function() {
225 somethingChanged = true;
227 window.addEventListener("beforeunload", function (e) {
228 if (somethingChanged && !top.timed_out) {
229 var msg = <?php echo xlj('You have unsaved changes.'); ?>;
230 e.returnValue = msg; // Gecko, Trident, Chrome 34+
231 return msg; // Gecko, WebKit, Chrome <34
235 if (window.checkSkipConditions) {
236 checkSkipConditions();
238 // Hide swap ins button if insurance is primary
239 $('#INSURANCE .tabNav a').click(function(){
240 let text = $(this).text();
241 if ( text != 'Primary') {
242 $('.swapIns').show();
243 } else {
244 $('.swapIns').hide();
249 var mypcc = <?php echo js_escape($GLOBALS['phone_country_code']); ?>;
251 //code used from http://tech.irt.org/articles/js037/
252 function replace(string,text,by) {
253 // Replaces text with by in string
254 var strLength = string.length, txtLength = text.length;
255 if ((strLength == 0) || (txtLength == 0)) return string;
257 var i = string.indexOf(text);
258 if ((!i) && (text != string.substring(0,txtLength))) return string;
259 if (i == -1) return string;
261 var newstr = string.substring(0,i) + by;
263 if (i+txtLength < strLength)
264 newstr += replace(string.substring(i+txtLength,strLength),text,by);
266 return newstr;
269 function upperFirst(string,text) {
270 return replace(string,text,text.charAt(0).toUpperCase() + text.substring(1,text.length));
273 <?php for ($i = 1; $i <= 3; $i++) { ?>
274 function auto_populate_employer_address<?php echo attr($i); ?>(){
275 var f = document.demographics_form;
276 if (f.form_i<?php echo attr($i); ?>subscriber_relationship.options[f.form_i<?php echo attr($i); ?>subscriber_relationship.selectedIndex].value == "self")
278 f.i<?php echo attr($i); ?>subscriber_fname.value=f.form_fname.value;
279 f.i<?php echo attr($i); ?>subscriber_mname.value=f.form_mname.value;
280 f.i<?php echo attr($i); ?>subscriber_lname.value=f.form_lname.value;
281 f.i<?php echo attr($i); ?>subscriber_street.value=f.form_street.value;
282 f.i<?php echo attr($i); ?>subscriber_street_line_2.value=f.form_street_line_2.value;
283 f.i<?php echo attr($i); ?>subscriber_city.value=f.form_city.value;
284 f.form_i<?php echo attr($i); ?>subscriber_state.value=f.form_state.value;
285 f.i<?php echo attr($i); ?>subscriber_postal_code.value=f.form_postal_code.value;
286 if (f.form_country_code)
287 f.form_i<?php echo attr($i); ?>subscriber_country.value=f.form_country_code.value;
288 f.i<?php echo attr($i); ?>subscriber_phone.value=f.form_phone_home.value;
289 f.i<?php echo attr($i); ?>subscriber_DOB.value=f.form_DOB.value;
290 if(typeof f.form_ss!="undefined")
292 f.i<?php echo attr($i); ?>subscriber_ss.value=f.form_ss.value;
294 f.form_i<?php echo attr($i); ?>subscriber_sex.value = f.form_sex.value;
295 f.i<?php echo attr($i); ?>subscriber_employer.value=f.form_em_name.value;
296 f.i<?php echo attr($i); ?>subscriber_employer_street.value=f.form_em_street.value;
297 f.i<?php echo attr($i); ?>subscriber_employer_street_line_2.value=f.form_em_street_line_2.value;
298 f.i<?php echo attr($i); ?>subscriber_employer_city.value=f.form_em_city.value;
299 f.form_i<?php echo attr($i); ?>subscriber_employer_state.value=f.form_em_state.value;
300 f.i<?php echo attr($i); ?>subscriber_employer_postal_code.value=f.form_em_postal_code.value;
301 if (f.form_em_country)
302 f.form_i<?php echo attr($i); ?>subscriber_employer_country.value=f.form_em_country.value;
306 <?php } ?>
308 function popUp(URL) {
309 day = new Date();
310 id = day.getTime();
311 top.restoreSession();
312 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');");
315 function checkNum () {
316 var re= new RegExp();
317 re = /^\d*\.?\d*$/;
318 str=document.demographics_form.monthly_income.value;
319 if(re.exec(str))
321 }else{
322 alert(<?php echo xlj('Please enter a monetary amount using only numbers and a decimal point.'); ?>);
326 function address_verify() {
327 top.restoreSession();
328 var f = document.demographics_form;
330 dlgopen('../../practice/address_verify.php?address1=' + encodeURIComponent(f.form_street.value) +
331 '&address2=' + encodeURIComponent(f.form_street_line_2.value) +
332 '&city=' + encodeURIComponent(f.form_city.value) +
333 '&state=' + encodeURIComponent(f.form_state.value) +
334 '&zip5=' + encodeURIComponent(f.form_postal_code.value.substring(0,5)) +
335 '&zip4=' + encodeURIComponent(f.form_postal_code.value.substring(5,9))
336 , '_blank', 400, 150, '', xl('Address Verify'));
338 return false;
341 // Indicates which insurance slot is being updated.
342 var insurance_index = 0;
344 // The OnClick handler for searching/adding the insurance company.
345 function ins_search(ins) {
346 insurance_index = ins;
347 return false;
350 function sendInsToSearch(ins) {
351 let thesel = $('#i' + ins + 'provider');
352 let theseldata = $(thesel).select2('data');
353 return theseldata[0]['id'];
356 function InsSaveClose() {
357 top.restoreSession();
358 document.location.reload();
360 // The ins_search.php window calls this to set the selected insurance.
361 function set_insurance(ins_id, ins_name) {
362 thesel = $('#i' + insurance_index + 'provider');
363 if ($(thesel).find("option[value='" + ins_id + "']").length) {
364 thesel.val(ins_id).trigger('change');
365 } else {
366 // no matching option was found so create one, append it to the
367 // end of the list, and select it.
368 let newOption = new Option(ins_name, ins_id, true, true);
369 thesel.append(newOption).trigger('change');
373 // This capitalizes the first letter of each word in the passed input
374 // element. It also strips out extraneous spaces.
375 function capitalizeMe(elem) {
376 var a = elem.value.split(' ');
377 var s = '';
378 for(var i = 0; i < a.length; ++i) {
379 if (a[i].length > 0) {
380 if (s.length > 0) s += ' ';
381 s += a[i].charAt(0).toUpperCase() + a[i].substring(1);
384 elem.value = s;
387 function divclick(cb, divid) {
388 var divstyle = document.getElementById(divid).style;
389 if (cb.checked) {
390 divstyle.display = 'block';
391 } else {
392 divstyle.display = 'none';
394 return true;
397 // Compute the length of a string without leading and trailing spaces.
398 function trimlen(s) {
399 var i = 0;
400 var j = s.length - 1;
401 for (; i <= j && s.charAt(i) == ' '; ++i);
402 for (; i <= j && s.charAt(j) == ' '; --j);
403 if (i > j) return 0;
404 return j + 1 - i;
407 function validate(f) {
408 var errCount = 0;
409 var errMsgs = new Array();
410 <?php generate_layout_validation('DEM'); ?>
412 var msg = "";
413 msg += <?php echo xlj('The following fields are required'); ?> + ":\n\n";
414 for ( var i = 0; i < errMsgs.length; i++ ) {
415 msg += errMsgs[i] + "\n";
417 msg += "\n" + <?php echo xlj('Please fill them in before continuing.'); ?>;
419 if ( errMsgs.length > 0 ) {
420 alert(msg);
423 //Misc Deceased Date Validation for Future Date
424 var dateVal = document.getElementById("form_deceased_date").value;
425 var currentDate;
426 var d = new Date();
427 month = '' + (d.getMonth() + 1),
428 day = '' + d.getDate(),
429 year = d.getFullYear();
430 if (month.length < 2) month = '0' + month;
431 if (day.length < 2) day = '0' + day;
432 currentDate = year+'-'+month+'-'+day;
433 if(dateVal > currentDate)
435 alert (<?php echo xlj("Deceased Date should not be greater than Today"); ?>);
436 return false;
439 //Patient Data validations
440 <?php if ($GLOBALS['erx_enable']) { ?>
441 alertMsg='';
442 for(i=0;i<f.length;i++){
443 if(f[i].type=='text' && f[i].value)
445 if(f[i].name == 'form_fname' || f[i].name == 'form_mname' || f[i].name == 'form_lname')
447 alertMsg += checkLength(f[i].name,f[i].value,35);
448 alertMsg += checkUsername(f[i].name,f[i].value);
450 else if(f[i].name == 'form_street' || f[i].name == 'form_city')
452 alertMsg += checkLength(f[i].name,f[i].value,35);
453 alertMsg += checkAlphaNumericExtended(f[i].name,f[i].value);
455 else if(f[i].name == 'form_phone_home')
457 alertMsg += checkPhone(f[i].name,f[i].value);
461 if(alertMsg)
463 alert(alertMsg);
464 return false;
466 <?php } ?>
467 //return false;
469 // Some insurance validation.
470 for (var i = 1; i <= 3; ++i) {
471 subprov = 'i' + i + 'provider';
472 if (!f[subprov] || f[subprov].selectedIndex <= 0) continue;
473 var subpfx = 'i' + i + 'subscriber_';
474 var subrelat = f['form_' + subpfx + 'relationship'];
475 var samename =
476 f[subpfx + 'fname'].value == f.form_fname.value &&
477 f[subpfx + 'mname'].value == f.form_mname.value &&
478 f[subpfx + 'lname'].value == f.form_lname.value;
479 var ss_regexp=/[0-9][0-9][0-9]-?[0-9][0-9]-?[0-9][0-9][0-9][0-9]/;
480 var samess=true;
481 var ss_valid=false;
482 if(typeof f.form_ss!="undefined")
484 samess = f[subpfx + 'ss'].value == f.form_ss.value;
485 ss_valid=ss_regexp.test(f[subpfx + 'ss'].value) && ss_regexp.test(f.form_ss.value);
487 if (subrelat.options[subrelat.selectedIndex].value == "self") {
488 if (!samename) {
489 if (!confirm(<?php echo xlj('Subscriber relationship is self but name is different! Is this really OK?'); ?>))
490 return false;
492 if (!samess && ss_valid) {
493 if(!confirm(<?php echo js_escape(xl('Subscriber relationship is self but SS number is different!') . " " . xl("Is this really OK?")); ?>))
494 return false;
496 } // end self
497 else {
498 if (samename) {
499 if (!confirm(<?php echo xlj('Subscriber relationship is not self but name is the same! Is this really OK?'); ?>))
500 return false;
502 if (samess && ss_valid) {
503 if(!confirm(<?php echo js_escape(xl('Subscriber relationship is not self but SS number is the same!') . " " . xl("Is this really OK?")); ?>))
504 return false;
506 } // end not self
507 } // end for
509 return errMsgs.length < 1;
512 // Added 06/2009 by BM to make compatible with list_options table and functions - using jquery
513 $(function () {
515 <?php for ($i = 1; $i <= 3; $i++) { ?>
516 $("#form_i<?php echo attr($i); ?>subscriber_relationship").change(function() { auto_populate_employer_address<?php echo attr($i); ?>(); });
517 <?php } ?>
521 </script>
523 <style>
524 div.demographicsEditContainer div.label_custom {
525 font-size: 0.8rem;
526 display: grid;
527 align-items: center;
528 line-height: 1.2;
529 padding-top: 0 !important;
530 margin-bottom: 0.2rem;
533 div.insuranceEditContainer div.label_custom span {
534 font-size: 0.8rem;
535 display: inline-flex;
536 height: 100%;
537 align-items: center;
538 line-height: 1.2;
541 <?php
542 if (!empty($GLOBALS['right_justify_labels_demographics']) && ($_SESSION['language_direction'] == 'ltr')) { ?>
543 div.label_custom {
544 text-align: right !important;
547 div.tab td.data, div.data {
548 padding-left: 0.5em;
549 padding-right: 2em;
551 <?php
552 } ?>
553 </style>
555 </head>
557 <?php
558 /*Get the constraint from the DB-> LBF forms accordinf the form_id*/
559 $constraints = LBF_Validation::generate_validate_constraints("DEM");
561 <script> var constraints = <?php echo $constraints;?>; </script>
563 <body class="body_top">
565 <form action='demographics_save.php' name='demographics_form' id="DEM" method='post' class='form-inline'
566 onsubmit="submitme(<?php echo $GLOBALS['new_validate'] ? 1 : 0;?>,event,'DEM',constraints)">
567 <input type="hidden" name="csrf_token_form" value="<?php echo attr(CsrfUtils::collectCsrfToken()); ?>" />
568 <input type='hidden' name='mode' value='save' />
569 <input type='hidden' name='db_id' value="<?php echo attr($result['id']); ?>" />
570 <input type="hidden" name="isSwapClicked" value="" />
572 <div class="container-xl">
573 <div class="row">
574 <div class="col-12">
575 <h2><?php echo xlt('Edit Current Patient');?></h2>
576 </div>
577 <div class="col-12">
578 <div class="btn-group">
579 <button type="submit" class="btn btn-primary btn-save" id="submit_btn" disabled="disabled" value="<?php echo xla('Save'); ?>">
580 <?php echo xlt('Save'); ?>
581 </button>
582 <a class="btn btn-secondary btn-cancel" href="demographics.php" onclick="top.restoreSession()">
583 <?php echo xlt('Cancel'); ?>
584 </a>
585 </div>
586 <hr>
587 </div>
588 </div>
589 </div>
590 <?php
591 $condition_str = '';
593 <br />
594 <div class='container-xl demographicsEditContainer'>
595 <div class="section-header">
596 <span class="text font-weight-bold"><?php echo xlt("Demographics")?></span>
597 </div>
598 <ul class="tabNav">
599 <?php display_layout_tabs('DEM', $result, $result2); ?>
600 </ul>
602 <div class="tabContainer">
603 <?php display_layout_tabs_data_editable('DEM', $result, $result2); ?>
604 </div>
605 </div>
606 <br />
608 <div class='container-xl'>
610 <?php
611 if (! $GLOBALS['simplified_demographics']) {
612 //Check to see if only one insurance is allowed
613 if ($GLOBALS['insurance_only_one']) {
614 $insurance_headings = array(xl("Primary Insurance Provider"));
615 $insurance_info = array();
616 $insurance_info[1] = getInsuranceData($pid, "primary");
617 } else {
618 $insurance_headings = array(xl("Primary Insurance Provider"), xl("Secondary Insurance Provider"), xl("Tertiary Insurance provider"));
619 $insurance_info = array();
620 $insurance_info[1] = getInsuranceData($pid, "primary");
621 $insurance_info[2] = getInsuranceData($pid, "secondary");
622 $insurance_info[3] = getInsuranceData($pid, "tertiary");
627 <div class="section-header">
628 <span class="text font-weight-bold"><?php echo xlt("Insurance")?></span>
629 </div>
630 <div id="INSURANCE" class="insuranceEditContainer">
631 <ul class="tabNav">
632 <?php
633 foreach ($insurance_array as $instype) {
635 <li <?php echo $instype == 'primary' ? 'class="current"' : '' ?>><a href="#"><?php $CapInstype = ucfirst($instype);
636 echo xlt($CapInstype); ?></a></li><?php } ?>
637 </ul>
639 <div class="tabContainer">
641 <?php
642 for ($i = 1; $i <= 3; $i++) {
643 $result3 = $insurance_info[$i];
646 <div class="tab <?php echo $i == 1 ? 'current' : '' ?> h-auto w-auto">
647 <div class="form-row">
648 <div class="col-md-6"><!-- start left column -->
650 <div class="form-row"><!-- start nested row -->
651 <div class="col-md-3 label_custom pb-3">
652 <span class='required'><?php echo text($insurance_headings[$i - 1]); ?>:</span>
653 </div>
654 <div class="col-md-9">
655 <a class="medium_modal btn btn-primary" href="../../practice/ins_search.php?ins=" role="button"
656 onclick="ins_search(<?php echo attr_js($i); ?>)"><?php echo xlt('Search/Add/Edit') ?></a>
657 <select id="i<?php echo attr($i); ?>provider" name="i<?php echo attr($i); ?>provider" class="form-control form-control-sm sel2 mb-1" style="width: 250px;">
658 <option value=""><?php echo xlt('Unassigned'); ?></option>
659 <?php
660 foreach ($insurancei as $iid => $iname) {
661 echo "<option value='" . attr($iid) . "'";
662 if (!empty($result3["provider"]) && (strtolower($iid) == strtolower($result3["provider"]))) {
663 echo " selected";
665 echo ">" . text($iname) . "</option>\n";
668 </select>
669 </div>
670 </div><!-- end nested row -->
672 <div class="form-row"><!-- start nested row -->
673 <div class="col-md-3 pb-1 label_custom">
674 <span class='required'><?php echo xlt('Plan Name'); ?>:</span>
675 </div>
676 <div class="col-md-6">
677 <input type='entry' class='form-control form-control-sm mb-1' size='20'
678 name='i<?php echo attr($i); ?>plan_name'
679 value="<?php echo attr($result3["plan_name"] ?? ''); ?>"
680 onchange="capitalizeMe(this);" />
681 </div>
682 <div class="col-md-3 swapIns <?php echo (empty($GLOBALS['enable_swap_secondary_insurance'])) ? ' d-none"' : '"'; ?>>
683 <a class="btn btn-secondary pb-1" href="#" role="button"
684 onclick="document.forms[0].isSwapClicked.value=<?php echo attr($i); ?>; document.forms[0].submit()">
685 <?php echo ($i == '2') ? xlt('Swap with Primary') : xlt('Swap with Secondary'); ?>
686 </a>
687 </div>
688 </div><!-- end nested row -->
690 <div class="form-row"><!-- start nested row -->
691 <div class="col-md-3 pb-1 label_custom ">
692 <span class='required'><?php echo xlt('Effective Date'); ?>:</span>
693 </div>
694 <div class="col-md-9">
695 <input type='entry' size='16' class='datepicker form-control form-control-sm mb-1'
696 id='i<?php echo attr($i); ?>effective_date'
697 name='i<?php echo attr($i); ?>effective_date'
698 value='<?php echo attr(oeFormatShortDate($result3['date'] ?? '')); ?>' />
699 </div>
700 </div><!-- end nested row -->
702 <div class="form-row"><!-- start nested row -->
703 <div class="col-md-3 pb-1 label_custom ">
704 <span class='required'><?php echo xlt('Effective Date End'); ?>:</span>
705 </div>
706 <div class="col-md-9">
707 <input type='entry' size='16' class='datepicker form-control form-control-sm mb-1'
708 id='i<?php echo attr($i); ?>effective_date_end'
709 name='i<?php echo attr($i); ?>effective_date_end'
710 value='<?php echo attr(oeFormatShortDate($result3['date_end'] ?? '')); ?>' />
711 </div>
712 </div><!-- end nested row -->
714 <div class="form-row"><!-- start nested row -->
715 <div class="col-md-3 pb-1 label_custom">
716 <span class='required'><?php echo xlt('Policy Number'); ?>:</span>
717 </div>
718 <div class="col-md-9">
719 <input type='entry' class='form-control form-control-sm mb-1' size='16'
720 name='i<?php echo attr($i); ?>policy_number'
721 value="<?php echo attr($result3["policy_number"] ?? ''); ?>"
722 onkeyup='policykeyup(this)' />
723 </div>
724 </div><!-- end nested row -->
726 <div class="form-row"><!-- start nested row -->
727 <div class="col-md-3 pb-1 label_custom ">
728 <span class='required'><?php echo xlt('Group Number'); ?>:</span>
729 </div>
730 <div class="col-md-9">
731 <input type="text" class='form-control form-control-sm mb-1' size='16'
732 name='i<?php echo attr($i); ?>group_number'
733 value="<?php echo attr($result3["group_number"] ?? ''); ?>"
734 onkeyup='policykeyup(this)' />
735 </div>
736 </div><!-- end nested row -->
738 <div class="form-row"<?php echo $GLOBALS['omit_employers'] ? " style='display:none'" : ""; ?>><!-- start nested row -->
739 <div class="col-md-3 pb-4 label_custom">
740 <span class='required'><?php echo xlt('Subscriber Employer (SE)'); ?>:</span>
741 </div>
742 <div class="col-md-9">
743 <input type='entry' class='form-control form-control-sm' size='25'
744 name='i<?php echo attr($i); ?>subscriber_employer'
745 value="<?php echo attr($result3["subscriber_employer"] ?? ''); ?>"
746 onchange="capitalizeMe(this);" />
747 <span class='small mb-1'><br /><?php echo xlt('if unemployed enter Student'); ?>,
748 <?php echo xlt('PT Student, or leave blank'); ?></span>
749 </div>
750 </div><!-- end nested row -->
752 <div class="form-row"<?php echo $GLOBALS['omit_employers'] ? " style='display:none'" : ""; ?>><!-- start nested row -->
753 <div class="col-md-3 pb-1 label_custom">
754 <span class='required'><?php echo xlt('SE Address'); ?>:</span>
755 </div>
756 <div class="col-md-9">
757 <input type='entry' class='form-control form-control-sm mb-1' size='25'
758 name='i<?php echo attr($i); ?>subscriber_employer_street'
759 value="<?php echo attr($result3["subscriber_employer_street"] ?? ''); ?>"
760 onchange="capitalizeMe(this);" />
761 </div>
762 <div class="col-md-3 pb-1 label_custom">
763 <span class='required'><?php echo xlt('SE Address Line 2'); ?>:</span>
764 </div>
765 <div class="col-md-9">
766 <input type='entry' class='form-control form-control-sm mb-1' size='25'
767 name='i<?php echo attr($i); ?>subscriber_employer_street_line_2'
768 value="<?php echo attr($result3["subscriber_employer_street_line_2"] ?? ''); ?>"
769 onchange="capitalizeMe(this);" />
770 </div>
771 </div><!-- end nested row -->
773 <div class="form-row"<?php echo $GLOBALS['omit_employers'] ? " style='display:none'" : ""; ?>><!-- start nested row -->
774 <div class="col-md-3 pb-1 label_custom">
775 <span class='required'><?php echo xlt('SE City'); ?>:</span>
776 </div>
777 <div class="col-md-9">
778 <input type='entry' class='form-control form-control-sm mb-1' size='15'
779 name='i<?php echo attr($i); ?>subscriber_employer_city'
780 value="<?php echo attr($result3["subscriber_employer_city"] ?? ''); ?>"
781 onchange="capitalizeMe(this);" />
782 </div>
783 </div><!-- end nested row -->
785 <div class="form-row"<?php echo $GLOBALS['omit_employers'] ? " style='display:none'" : ""; ?>><!-- start nested row -->
786 <div class="col-md-3 pb-1 label_custom">
787 <span class='required'><?php echo ($GLOBALS['phone_country_code'] == '1') ? xlt('SE State') : xlt('SE Locality') ?>:</span>
788 </div>
789 <div class="col-md-9">
790 <?php
791 generate_form_field(
792 array(
793 'data_type' => $GLOBALS['state_data_type'],
794 'field_id' => ('i' . $i . 'subscriber_employer_state'),
795 'list_id' => $GLOBALS['state_list'],
796 'fld_length' => '15',
797 'max_length' => '63',
798 'edit_options' => 'C',
799 'smallform' => 'true'
801 ($result3['subscriber_employer_state'] ?? '')
804 </div>
805 </div><!-- end nested row -->
807 <div class="form-row"<?php echo $GLOBALS['omit_employers'] ? " style='display:none'" : ""; ?>><!-- start nested row -->
808 <div class="col-md-3 pb-1 label_custom">
809 <span class='required'><?php echo ($GLOBALS['phone_country_code'] == '1') ? xlt('SE Zip Code') : xlt('SE Postal Code') ?>:</span>
810 </div>
811 <div class="col-md-9">
812 <input type='entry' class='form-control form-control-sm mb-1' size='15'
813 name='i<?php echo attr($i); ?>subscriber_employer_postal_code'
814 value="<?php echo attr($result3["subscriber_employer_postal_code"] ?? ''); ?>" />
815 </div>
816 </div><!-- end nested row -->
818 <div class="form-row"<?php echo $GLOBALS['omit_employers'] ? " style='display:none'" : ""; ?>><!-- start nested row -->
819 <div class="col-md-3 pb-1 label_custom">
820 <span class='required'><?php echo xlt('SE Country'); ?>:</span>
821 </div>
822 <div class="col-md-9">
823 <?php
824 // Modified 7/2009 by BM to incorporate data types
825 generate_form_field(
826 array(
827 'data_type' => $GLOBALS['country_data_type'],
828 'field_id' => ('i' . $i . 'subscriber_employer_country'),
829 'list_id' => $GLOBALS['country_list'],
830 'fld_length' => '10',
831 'max_length' => '63',
832 'edit_options' => 'C',
833 'smallform' => 'true'
835 ($result3['subscriber_employer_country'] ?? '')
838 </div>
839 </div><!-- end nested row -->
841 </div><!-- end left column -->
843 <div class="col-md-6"><!-- start right column -->
845 <div class="form-row"><!-- start nested row -->
846 <div class="col-md-3 pb-1 label_custom">
847 <span class='required'><?php echo xlt('Relationship'); ?>:</span>
848 </div>
849 <div class="col-md-9">
850 <?php
851 // Modified 6/2009 by BM to use list_options and function
852 generate_form_field(
853 array(
854 'data_type' => 1,
855 'field_id' => ('i' . $i . 'subscriber_relationship'),
856 'list_id' => 'sub_relation',
857 'empty_title' => ' ',
858 'smallform' => ' form-control form-control-sm mb-1'
860 ($result3['subscriber_relationship'] ?? '')
863 <a href="javascript:popUp('browse.php?browsenum=<?php echo attr_url($i); ?>')"
864 class='text'>(<?php echo xlt('Browse'); ?>)</a>
865 </div>
866 </div><!-- end nested row -->
868 <div class="form-row"><!-- start nested row -->
869 <div class="col-md-3 pb-1 label_custom">
870 <span class='required'><?php echo xlt('Subscriber'); ?>:</span>
871 </div>
872 <div class="col-md-9">
873 <input type='entry' class='form-control form-control-sm mb-1' size='10'
874 name='i<?php echo attr($i); ?>subscriber_fname'
875 value="<?php echo attr($result3["subscriber_fname"] ?? ''); ?>"
876 onchange="capitalizeMe(this);" />
877 <input type='entry' class='form-control form-control-sm mb-1' size='3'
878 name='i<?php echo attr($i); ?>subscriber_mname'
879 value="<?php echo attr($result3["subscriber_mname"] ?? ''); ?>"
880 onchange="capitalizeMe(this);" />
881 <input type='entry' class='form-control form-control-sm mb-1' size='10'
882 name='i<?php echo attr($i); ?>subscriber_lname'
883 value="<?php echo attr($result3["subscriber_lname"] ?? ''); ?>"
884 onchange="capitalizeMe(this);" />
885 </div>
886 </div><!-- end nested row -->
888 <div class="form-row"><!-- start nested row -->
889 <div class="col-md-3 pb-1 label_custom">
890 <span><?php echo xlt('D.O.B.'); ?>:</span>
891 </div>
892 <div class="col-md-9">
893 <input type='entry' class='datepicker form-control form-control-sm mb-1 mw-100'
894 id='i<?php echo attr($i); ?>subscriber_DOB' size='11'
895 name='i<?php echo attr($i); ?>subscriber_DOB'
896 value='<?php echo attr(oeFormatShortDate($result3['subscriber_DOB'] ?? '')); ?>' />
897 </div>
898 </div><!-- end nested row -->
900 <div class="form-row"><!-- start nested row -->
901 <div class="col-md-3 pb-1 label_custom">
902 <span><?php echo xlt('Sex'); ?>:</span>
903 </div>
904 <div class="col-md-9">
905 <?php
906 // Modified 6/2009 by BM to use list_options and function
907 generate_form_field(
908 array(
909 'data_type' => 1,
910 'field_id' => ('i' . $i . 'subscriber_sex'),
911 'list_id' => 'sex',
912 'smallform' => ' form-control form-control-sm mb-1'
914 ($result3['subscriber_sex'] ?? '')
917 </div>
918 </div><!-- end nested row -->
920 <div class="form-row"><!-- start nested row -->
921 <div class="col-md-3 pb-1 label_custom">
922 <span><?php echo xlt('S.S.'); ?>:</span>
923 </div>
924 <div class="col-md-9">
925 <input type='entry' class='form-control form-control-sm mb-1 mw-100' size='11'
926 name='i<?php echo attr($i); ?>subscriber_ss'
927 value="<?php echo attr(trim($result3["subscriber_ss"] ?? '')); ?>" />
928 </div>
929 </div><!-- end nested row -->
931 <div class="form-row"><!-- start nested row -->
932 <div class="col-md-3 pb-1 label_custom">
933 <span class='required'><?php echo xlt('Subscriber Address'); ?>:</span>
934 </div>
935 <div class="col-md-9">
936 <input type='entry' class='form-control form-control-sm mb-1 mw-100' size='20'
937 name='i<?php echo attr($i); ?>subscriber_street'
938 value="<?php echo attr($result3["subscriber_street"] ?? ''); ?>"
939 onchange="capitalizeMe(this);" />
940 </div>
941 </div><!-- end nested row -->
943 <div class="form-row"><!-- start nested row -->
944 <div class="col-md-3 pb-1 label_custom">
945 <span class='required'><?php echo xlt('Address Line 2'); ?>:</span>
946 </div>
947 <div class="col-md-9">
948 <input type='entry' class='form-control form-control-sm mb-1 mw-100' size='20'
949 name='i<?php echo attr($i); ?>subscriber_street_line_2'
950 value="<?php echo attr($result3["subscriber_street_line_2"] ?? ''); ?>"
951 onchange="capitalizeMe(this);" />
952 </div>
953 </div><!-- end nested row -->
955 <div class="form-row"><!-- start nested row -->
956 <div class="col-md-3 pb-1 label_custom">
957 <span class='required'><?php echo xlt('City'); ?>:</span>
958 </div>
959 <div class="col-md-9">
960 <input type='entry' class='form-control form-control-sm mb-1 mw-100' size='11'
961 name='i<?php echo attr($i); ?>subscriber_city'
962 value="<?php echo attr($result3["subscriber_city"] ?? ''); ?>"
963 onchange="capitalizeMe(this);" />
964 </div>
965 </div><!-- end nested row -->
967 <div class="form-row"><!-- start nested row -->
968 <div class="col-md-3 pb-1 label_custom">
969 <span class='required'><?php echo ($GLOBALS['phone_country_code'] == '1') ? xlt('State') : xlt('Locality') ?>:</span>
970 </div>
971 <div class="col-md-9">
972 <?php
973 // Modified 7/2009 by BM to incorporate data types
974 generate_form_field(
975 array(
976 'data_type' => $GLOBALS['state_data_type'],
977 'field_id' => ('i' . $i . 'subscriber_state'),
978 'list_id' => $GLOBALS['state_list'],
979 'fld_length' => '15',
980 'max_length' => '63',
981 'edit_options' => 'C',
982 'smallform' => 'true'
984 ($result3['subscriber_state'] ?? '')
987 </div>
988 </div><!-- end nested row -->
990 <div class="form-row"><!-- start nested row -->
991 <div class="col-md-3 pb-1 label_custom">
992 <span class='required'><?php echo ($GLOBALS['phone_country_code'] == '1') ? xlt('Zip Code') : xlt('Postal Code') ?>:</span>
993 </div>
994 <div class="col-md-9">
995 <input type='entry' class='form-control form-control-sm mb-1' size='15'
996 name='i<?php echo attr($i); ?>subscriber_postal_code'
997 value="<?php echo attr($result3["subscriber_postal_code"] ?? ''); ?>" />
998 </div>
999 </div><!-- end nested row -->
1001 <div class="form-row"><!-- start nested row -->
1002 <div class="col-md-3 pb-1 label_custom">
1003 <span class='required'><?php echo xlt('Country'); ?>:</span>
1004 </div>
1005 <div class="col-md-9">
1006 <?php
1007 // Modified 7/2009 by BM to incorporate data types
1008 generate_form_field(
1009 array(
1010 'data_type' => $GLOBALS['country_data_type'],
1011 'field_id' => ('i' . $i . 'subscriber_country'),
1012 'list_id' => $GLOBALS['country_list'],
1013 'fld_length' => '10',
1014 'max_length' => '63',
1015 'edit_options' => 'C',
1016 'smallform' => 'true'
1018 ($result3['subscriber_country'] ?? '')
1021 </div>
1022 </div><!-- end nested row -->
1024 <div class="form-row"><!-- start nested row -->
1025 <div class="col-md-3 pb-1 label_custom">
1026 <span><?php echo xlt('Subscriber Phone'); ?>:</span>
1027 </div>
1028 <div class="col-md-9">
1029 <input type='text' class='form-control form-control-sm mb-1' size='20'
1030 name='i<?php echo attr($i); ?>subscriber_phone'
1031 value='<?php echo attr($result3["subscriber_phone"] ?? ''); ?>'
1032 onkeyup='phonekeyup(this,mypcc)' />
1033 </div>
1034 </div><!-- end nested row -->
1036 <div class="form-row"><!-- start nested row -->
1037 <div class="col-md-3 pb-1 label_custom">
1038 <span><?php echo xlt('CoPay'); ?>:</span>
1039 </div>
1040 <div class="col-md-9">
1041 <input type='text' class='form-control form-control-sm mb-1' size="6"
1042 name='i<?php echo attr($i); ?>copay'
1043 value="<?php echo attr($result3["copay"] ?? ''); ?>" />
1044 </div>
1045 </div><!-- end nested row -->
1047 <div class="form-row"><!-- start nested row -->
1048 <div class="col-md-3 pb-1 label_custom">
1049 <span class='required'><?php echo xlt('Accept Assignment'); ?>:</span>
1050 </div>
1051 <div class="col-md-9">
1052 <select class='form-control form-control-sm mb-1'
1053 name='i<?php echo attr($i); ?>accept_assignment'>
1054 <option value="TRUE"
1055 <?php echo (!empty($result3["accept_assignment"]) && (strtoupper($result3["accept_assignment"]) == "TRUE")) ? "selected" : ""; ?>>
1056 <?php echo xlt('YES'); ?></option>
1057 <option value="FALSE"
1058 <?php echo (!empty($result3["accept_assignment"]) && (strtoupper($result3["accept_assignment"]) == "FALSE")) ? "selected" : ""; ?>>
1059 <?php echo xlt('NO'); ?></option>
1060 </select>
1061 </div>
1062 </div><!-- end nested row -->
1064 <div class="form-row"><!-- start nested row -->
1065 <div class="col-md-3 pb-1 label_custom">
1066 <span><?php echo xlt('Secondary Medicare Type'); ?>:</span>
1067 </div>
1068 <div class="col-md-9">
1069 <select class='form-control form-control-sm mb-1 sel2' name='i<?php echo attr($i); ?>policy_type'>
1070 <?php
1071 if (!empty($policy_types)) {
1072 foreach ($policy_types as $key => $value) {
1073 echo " <option value ='" . attr($key) . "'";
1074 if (!empty($result3['policy_type']) && ($key == $result3['policy_type'])) {
1075 echo " selected";
1077 echo ">" . text($value) . "</option>\n";
1081 </select>
1082 </div>
1083 </div><!-- end nested row -->
1085 </div><!-- end right column -->
1086 </div>
1087 </div>
1089 <?php
1090 } //end insurer for loop ?>
1092 </div>
1093 </div>
1095 <?php } // end of "if not simplified_demographics" ?>
1096 </div>
1097 </div>
1098 </form>
1100 <br />
1102 <script>
1104 // Array of skip conditions for the checkSkipConditions() function.
1105 var skipArray = [
1106 <?php echo $condition_str; ?>
1109 // hard code validation for old validation, in the new validation possible to add match rules
1110 <?php if ($GLOBALS['new_validate'] == 0) { ?>
1111 // fix inconsistently formatted phone numbers from the database
1112 var f = document.forms[0];
1113 if (f.form_phone_contact) phonekeyup(f.form_phone_contact,mypcc);
1114 if (f.form_phone_home ) phonekeyup(f.form_phone_home ,mypcc);
1115 if (f.form_phone_biz ) phonekeyup(f.form_phone_biz ,mypcc);
1116 if (f.form_phone_cell ) phonekeyup(f.form_phone_cell ,mypcc);
1118 <?php if (! $GLOBALS['simplified_demographics']) { ?>
1119 phonekeyup(f.i1subscriber_phone,mypcc);
1120 phonekeyup(f.i2subscriber_phone,mypcc);
1121 phonekeyup(f.i3subscriber_phone,mypcc);
1122 <?php } ?>
1124 <?php }?>
1126 <?php if ($set_pid) { ?>
1127 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'])); ?>);
1128 <?php } ?>
1130 <?php echo $date_init; ?>
1131 </script>
1133 <!-- include support for the list-add selectbox feature -->
1134 <?php require $GLOBALS['fileroot'] . "/library/options_listadd.inc.php"; ?>
1136 <?php /*Include the validation script and rules for this form*/
1137 $form_id = "DEM";
1138 //LBF forms use the new validation depending on the global value
1139 $use_validate_js = $GLOBALS['new_validate'];
1142 <?php include_once("$srcdir/validation/validation_script.js.php");?>
1145 <script>
1146 var duplicateFieldsArray=[];
1148 //This code deals with demographics before save action -
1149 <?php if (($GLOBALS['gbl_edit_patient_form'] == '1') && (checkIfPatientValidationHookIsActive())) :?>
1150 //Use the Zend patient validation hook.
1151 //TODO - get the edit part of patient validation hook to work smoothly and then
1152 // remove the closeBeforeOpening=1 in the url below.
1154 var f = $("form");
1156 // Use hook to open the controller and get the new patient validation .
1157 // when no params are sent this window will be closed from the zend controller.
1158 var url ='<?php echo $GLOBALS['web_root'] . "/interface/modules/zend_modules/public/patientvalidation";?>';
1159 $("#submit_btn").attr("name","btnSubmit");
1160 $("#submit_btn").attr("id","btnSubmit");
1161 $("#btnSubmit").click(function( event ) {
1163 top.restoreSession();
1165 if(!submitme(<?php echo $GLOBALS['new_validate'] ? 1 : 0;?>,event,'DEM',constraints)){
1166 event.preventDefault();
1167 return;
1169 somethingChanged = false;
1170 <?php
1171 // D in edit_options indicates the field is used in duplication checking.
1172 // This constructs a list of the names of those fields.
1173 $mflist = "";
1174 $mfres = sqlStatement("SELECT field_id FROM layout_options " .
1175 "WHERE form_id = 'DEM' AND uor > 0 AND field_id != '' AND " .
1176 "(edit_options LIKE '%D%' OR edit_options LIKE '%E%') " .
1177 "ORDER BY group_id, seq");
1178 while ($mfrow = sqlFetchArray($mfres)) {
1179 $field_id = $mfrow['field_id'];
1180 if (strpos($field_id, 'em_') === 0) {
1181 continue;
1184 if (!empty($mflist)) {
1185 $mflist .= ",";
1188 $mflist .= js_escape($field_id);
1189 } ?>
1191 var flds = new Array(<?php echo $mflist; ?>);
1192 var separator = '?';
1193 var valueIsChanged=false;
1194 for (var i = 0; i < flds.length; ++i) {
1195 var fval = $('#form_' + flds[i]).val();
1196 if(duplicateFieldsArray['#form_' + flds[i]]!=fval) {
1197 valueIsChanged = true;
1201 if (fval && fval != '') {
1202 url += separator;
1203 separator = '&';
1204 url += 'mf_' + flds[i] + '=' + encodeURIComponent(fval);
1209 //Only if check for duplicates values are changed open the popup hook screen
1210 if(valueIsChanged) {
1211 event.preventDefault();
1212 //("value has changed for duplicate check inputs");
1213 url += '&page=edit&closeBeforeOpening=1&mf_id=' + encodeURIComponent($("[name='db_id']").val());
1214 dlgopen(url, '_blank', 700, 500);
1216 else {//other wise submit me is a success just submit the form
1217 $('#DEM').submit();
1221 <?php endif;?>
1223 $(function () {
1224 //When document is ready collect all the values Marked with D (check duplicate) stored in the db into array duplicateFieldsArray.
1225 var flds = new Array(<?php echo ($mflist ?? ''); ?>);
1226 for (var i = 0; i < flds.length; ++i) {
1227 var fval = $('#form_' + flds[i]).val();
1228 duplicateFieldsArray['#form_' + flds[i]] = fval;
1230 $(".sel2").select2({
1231 theme: "bootstrap4",
1232 dropdownAutoWidth: true,
1233 width: 'resolve',
1234 <?php require($GLOBALS['srcdir'] . '/js/xl/select2.js.php'); ?>
1236 <?php if ($GLOBALS['usps_webtools_enable']) { ?>
1237 $("#value_id_text_postal_code").append(
1238 "<input type='button' class='btn btn-sm btn-secondary mb-1' onclick='address_verify()' value='<?php echo xla('Verify Address') ?>' />");
1239 <?php } ?>
1241 </script>
1243 </body>
1244 </html>