/
demographics.php
1925 lines (1747 loc) · 91.6 KB
/
demographics.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/**
*
* Patient summary screen.
*
* @package OpenEMR
* @link http://www.open-emr.org
* @author Brady Miller <brady.g.miller@gmail.com>
* @author Sharon Cohen <sharonco@matrix.co.il>
* @author Stephen Waite <stephen.waite@cmsvt.com>
* @author Ranganath Pathak <pathak@scrs1.org>
* @author Tyler Wrenn <tyler@tylerwrenn.com>
* @author Robert Down <robertdown@live.com>
* @author Stephen Nielson <snielson@discoverandchange.com>
* @copyright Copyright (c) 2017-2020 Brady Miller <brady.g.miller@gmail.com>
* @copyright Copyright (c) 2017 Sharon Cohen <sharonco@matrix.co.il>
* @copyright Copyright (c) 2018-2020 Stephen Waite <stephen.waite@cmsvt.com>
* @copyright Copyright (c) 2018 Ranganath Pathak <pathak@scrs1.org>
* @copyright Copyright (c) 2020 Tyler Wrenn <tyler@tylerwrenn.com>
* @copyright Copyright (c) 2021-2022 Robert Down <robertdown@live.com
* @copyright Copyright (c) 2024 Care Management Solutions, Inc. <stephen.waite@cmsvt.com>
* @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
*/
require_once("../../globals.php");
require_once("$srcdir/lists.inc.php");
require_once("$srcdir/patient.inc.php");
require_once("$srcdir/options.inc.php");
require_once("../history/history.inc.php");
require_once("$srcdir/clinical_rules.php");
require_once("$srcdir/group.inc.php");
require_once(__DIR__ . "/../../../library/appointments.inc.php");
use OpenEMR\Billing\EDI270;
use OpenEMR\Common\Acl\AclMain;
use OpenEMR\Common\Csrf\CsrfUtils;
use OpenEMR\Common\Session\SessionUtil;
use OpenEMR\Common\Twig\TwigContainer;
use OpenEMR\Core\Header;
use OpenEMR\Events\Patient\Summary\Card\RenderEvent as CardRenderEvent;
use OpenEMR\Events\Patient\Summary\Card\SectionEvent;
use OpenEMR\Events\Patient\Summary\Card\RenderModel;
use OpenEMR\Events\Patient\Summary\Card\CardInterface;
use OpenEMR\Events\PatientDemographics\ViewEvent;
use OpenEMR\Events\PatientDemographics\RenderEvent;
use OpenEMR\FHIR\SMART\SmartLaunchController;
use OpenEMR\Menu\PatientMenuRole;
use OpenEMR\OeUI\OemrUI;
use OpenEMR\Patient\Cards\PortalCard;
use OpenEMR\Reminder\BirthdayReminder;
use OpenEMR\Services\AllergyIntoleranceService;
use OpenEMR\Services\ConditionService;
use OpenEMR\Services\ImmunizationService;
use OpenEMR\Services\PatientIssuesService;
use OpenEMR\Services\PatientService;
use Symfony\Component\EventDispatcher\EventDispatcher;
use OpenEMR\Patient\Cards\InsuranceViewCard;
use OpenEMR\Patient\Cards\BillingViewCard;
use OpenEMR\Patient\Cards\DemographicsViewCard;
$twig = new TwigContainer(null, $GLOBALS['kernel']);
// Set session for pid (via setpid). Also set session for encounter (if applicable)
if (isset($_GET['set_pid'])) {
require_once("$srcdir/pid.inc.php");
setpid($_GET['set_pid']);
$ptService = new PatientService();
$newPatient = $ptService->findByPid($pid);
$ptService->touchRecentPatientList($newPatient);
if (isset($_GET['set_encounterid']) && ((int)$_GET['set_encounterid'] > 0)) {
$encounter = (int)$_GET['set_encounterid'];
SessionUtil::setSession('encounter', $encounter);
}
}
// Note: it would eventually be a good idea to move this into
// it's own module that people can remove / add if they don't
// want smart support in their system.
$smartLaunchController = new SMARTLaunchController($GLOBALS["kernel"]->getEventDispatcher());
$smartLaunchController->registerContextEvents();
/**
* @var EventDispatcher
*/
$ed = $GLOBALS['kernel']->getEventDispatcher();
$active_reminders = false;
$all_allergy_alerts = false;
if ($GLOBALS['enable_cdr']) {
//CDR Engine stuff
if ($GLOBALS['enable_allergy_check'] && $GLOBALS['enable_alert_log']) {
//Check for new allergies conflicts and throw popup if any exist(note need alert logging to support this)
$new_allergy_alerts = allergy_conflict($pid, 'new', $_SESSION['authUser']);
if (!empty($new_allergy_alerts)) {
$pod_warnings = '';
foreach ($new_allergy_alerts as $new_allergy_alert) {
$pod_warnings .= js_escape($new_allergy_alert) . ' + "\n"';
}
$allergyWarningMessage = '<script>alert(' . xlj('WARNING - FOLLOWING ACTIVE MEDICATIONS ARE ALLERGIES') . ' + "\n" + ' . $pod_warnings . ')</script>';
}
}
if ((empty($_SESSION['alert_notify_pid']) || ($_SESSION['alert_notify_pid'] != $pid)) && isset($_GET['set_pid']) && $GLOBALS['enable_cdr_crp']) {
// showing a new patient, so check for active reminders and allergy conflicts, which use in active reminder popup
$active_reminders = active_alert_summary($pid, "reminders-due", '', 'default', $_SESSION['authUser'], true);
if ($GLOBALS['enable_allergy_check']) {
$all_allergy_alerts = allergy_conflict($pid, 'all', $_SESSION['authUser'], true);
}
}
SessionUtil::setSession('alert_notify_pid', $pid);
// can not output html until after above setSession call
if (!empty($allergyWarningMessage)) {
echo $allergyWarningMessage;
}
}
//Check to see is only one insurance is allowed
if ($GLOBALS['insurance_only_one']) {
$insurance_array = array('primary');
} else {
$insurance_array = array('primary', 'secondary', 'tertiary');
}
function print_as_money($money)
{
preg_match("/(\d*)\.?(\d*)/", $money, $moneymatches);
$tmp = wordwrap(strrev($moneymatches[1]), 3, ",", 1);
$ccheck = strrev($tmp);
if ($ccheck[0] == ",") {
$tmp = substr($ccheck, 1, strlen($ccheck) - 1);
}
if ($moneymatches[2] != "") {
return "$ " . strrev($tmp) . "." . $moneymatches[2];
} else {
return "$ " . strrev($tmp);
}
}
// get an array from Photos category
function pic_array($pid, $picture_directory)
{
$pics = array();
$sql_query = "select documents.id from documents join categories_to_documents " .
"on documents.id = categories_to_documents.document_id " .
"join categories on categories.id = categories_to_documents.category_id " .
"where categories.name like ? and documents.foreign_id = ? and documents.deleted = 0";
if ($query = sqlStatement($sql_query, array($picture_directory, $pid))) {
while ($results = sqlFetchArray($query)) {
array_push($pics, $results['id']);
}
}
return ($pics);
}
// Get the document ID's in a specific catg.
// this is only used in one place, here for id photos
function get_document_by_catg($pid, $doc_catg, $limit = 1)
{
$results = null;
if ($pid and $doc_catg) {
$query = sqlStatement("SELECT d.id, d.date, d.url
FROM documents AS d, categories_to_documents AS cd, categories AS c
WHERE d.foreign_id = ?
AND cd.document_id = d.id
AND c.id = cd.category_id
AND c.name LIKE ?
ORDER BY d.date DESC LIMIT " . escape_limit($limit), array($pid, $doc_catg));
}
while ($result = sqlFetchArray($query)) {
$results[] = $result['id'];
}
return ($results ?? false);
}
function isPortalEnabled(): bool
{
if (
!$GLOBALS['portal_onsite_two_enable']
) {
return false;
}
return true;
}
function isPortalSiteAddressValid(): bool
{
if (
// maybe can use filter_var() someday but the default value in GLOBALS
// fails with FILTER_VALIDATE_URL
!isset($GLOBALS['portal_onsite_two_address'])
) {
return false;
}
return true;
}
function isPortalAllowed($pid): bool
{
$return = false;
$portalStatus = sqlQuery("SELECT allow_patient_portal FROM patient_data WHERE pid = ?", [$pid]);
if ($portalStatus['allow_patient_portal'] == 'YES') {
$return = true;
}
return $return;
}
function isApiAllowed($pid): bool
{
$return = false;
$apiStatus = sqlQuery("SELECT prevent_portal_apps FROM patient_data WHERE pid = ?", [$pid]);
if (strtoupper($apiStatus['prevent_portal_apps'] ?? '') != 'YES') {
$return = true;
}
return $return;
}
function areCredentialsCreated($pid): bool
{
$return = false;
$credentialsCreated = sqlQuery("SELECT date_created FROM `patient_access_onsite` WHERE `pid`=?", [$pid]);
if ($credentialsCreated['date_created'] ?? null) {
$return = true;
}
return $return;
}
function isContactEmail($pid): bool
{
$return = false;
$email = sqlQuery("SELECT email, email_direct FROM patient_data WHERE pid = ?", [$pid]);
if (!empty($email['email']) || !empty($email['email_direct'])) {
$return = true;
}
return $return;
}
function isEnforceSigninEmailPortal(): bool
{
if (
$GLOBALS['enforce_signin_email']
) {
return true;
}
return false;
}
function deceasedDays($days_deceased)
{
$deceased_days = intval($days_deceased['days_deceased'] ?? '');
if ($deceased_days == 0) {
$num_of_days = xl("Today");
} elseif ($deceased_days == 1) {
$num_of_days = $deceased_days . " " . xl("day ago");
} elseif ($deceased_days > 1 && $deceased_days < 90) {
$num_of_days = $deceased_days . " " . xl("days ago");
} elseif ($deceased_days >= 90 && $deceased_days < 731) {
$num_of_days = "~" . round($deceased_days / 30) . " " . xl("months ago"); // function intdiv available only in php7
} elseif ($deceased_days >= 731) {
$num_of_days = xl("More than") . " " . round($deceased_days / 365) . " " . xl("years ago");
}
if (strlen($days_deceased['date_deceased'] ?? '') > 10 && $GLOBALS['date_display_format'] < 1) {
$deceased_date = substr($days_deceased['date_deceased'], 0, 10);
} else {
$deceased_date = oeFormatShortDate($days_deceased['date_deceased'] ?? '');
}
return xlt("Deceased") . " - " . text($deceased_date) . " (" . text($num_of_days) . ")";
}
$deceased = is_patient_deceased($pid);
// Display image in 'widget style'
function image_widget($doc_id, $doc_catg)
{
global $pid, $web_root;
$docobj = new Document($doc_id);
$image_file = $docobj->get_url_file();
$image_file_name = $docobj->get_name();
$image_width = $GLOBALS['generate_doc_thumb'] == 1 ? '' : 'width=100';
$extension = substr($image_file_name, strrpos($image_file_name, "."));
$viewable_types = array('.png', '.jpg', '.jpeg', '.png', '.bmp', '.PNG', '.JPG', '.JPEG', '.PNG', '.BMP');
if (in_array($extension, $viewable_types)) { // extension matches list
$to_url = "<td> <a href = '$web_root" .
"/controller.php?document&retrieve&patient_id=" . attr_url($pid) . "&document_id=" . attr_url($doc_id) . "&as_file=false&original_file=true&disable_exit=false&show_original=true'" .
" onclick='top.restoreSession();' class='image_modal'>" .
" <img src = '$web_root" .
"/controller.php?document&retrieve&patient_id=" . attr_url($pid) . "&document_id=" . attr_url($doc_id) . "&as_file=false'" .
" $image_width alt='" . attr($doc_catg) . ":" . attr($image_file_name) . "'> </a> </td> <td class='align-middle'>" .
text($doc_catg) . '<br /> ' . text($image_file_name) . "</td>";
} else {
$to_url = "<td> <a href='" . $web_root . "/controller.php?document&retrieve" .
"&patient_id=" . attr_url($pid) . "&document_id=" . attr_url($doc_id) . "'" .
" onclick='top.restoreSession()' class='btn btn-primary btn-sm'>" .
"<span>" .
xlt("View") . "</a> " .
text("$doc_catg - $image_file_name") .
"</span> </td>";
}
echo "<table><tr>";
echo $to_url;
echo "</tr></table>";
}
// Determine if the Vitals form is in use for this site.
$tmp = sqlQuery("SELECT count(*) AS count FROM registry WHERE directory = 'vitals' AND state = 1");
$vitals_is_registered = $tmp['count'];
// Get patient/employer/insurance information.
//
$result = getPatientData($pid, "*, DATE_FORMAT(DOB,'%Y-%m-%d') as DOB_YMD");
$result2 = getEmployerData($pid);
$result3 = getInsuranceData(
$pid,
"primary",
"copay,
provider,
DATE_FORMAT(`date`,'%Y-%m-%d') as effdate,
DATE_FORMAT(`date_end`,'%Y-%m-%d') as effdate_end"
);
$insco_name = "";
if (!empty($result3['provider'])) { // Use provider in case there is an ins record w/ unassigned insco
$insco_name = getInsuranceProvider($result3['provider']);
}
$arrOeUiSettings = array(
'page_id' => 'core.mrd',
'heading_title' => xl('Medical Record Dashboard'),
'include_patient_name' => true,
'expandable' => true,
'expandable_files' => array('demographics_xpd'), //all file names need suffix _xpd
'action' => "", //conceal, reveal, search, reset, link or back
'action_title' => "",
'action_href' => "", //only for actions - reset, link or back
'show_help_icon' => true,
'help_file_name' => "medical_dashboard_help.php"
);
$oemr_ui = new OemrUI($arrOeUiSettings);
?>
<!DOCTYPE html>
<html>
<head>
<?php
Header::setupHeader(['common','utility']);
require_once("$srcdir/options.js.php");
?>
<script>
// Process click on diagnosis for referential cds popup.
function referentialCdsClick(codetype, codevalue) {
top.restoreSession();
// Force a new window instead of iframe to address cross site scripting potential
dlgopen('../education.php?type=' + encodeURIComponent(codetype) + '&code=' + encodeURIComponent(codevalue), '_blank', 1024, 750,true);
}
function oldEvt(apptdate, eventid) {
let title = <?php echo xlj('Appointments'); ?>;
dlgopen('../../main/calendar/add_edit_event.php?date=' + encodeURIComponent(apptdate) + '&eid=' + encodeURIComponent(eventid), '_blank', 800, 500, '', title);
}
function advdirconfigure() {
dlgopen('advancedirectives.php', '_blank', 400, 500);
}
function refreshme() {
top.restoreSession();
location.reload();
}
// Process click on Delete link.
function deleteme() { // @todo don't think this is used any longer!!
dlgopen('../deleter.php?patient=' + <?php echo js_url($pid); ?> + '&csrf_token_form=' + <?php echo js_url(CsrfUtils::collectCsrfToken()); ?>, '_blank', 500, 450, '', '', {
allowResize: false,
allowDrag: false,
dialogId: 'patdel',
type: 'iframe'
});
return false;
}
// Called by the deleteme.php window on a successful delete.
function imdeleted() {
top.clearPatient();
}
function newEvt() {
let title = <?php echo xlj('Appointments'); ?>;
let url = '../../main/calendar/add_edit_event.php?patientid=' + <?php echo js_url($pid); ?>;
dlgopen(url, '_blank', 800, 500, '', title);
return false;
}
function toggleIndicator(target, div) {
// <i id="show_hide" class="fa fa-lg small fa-eye-slash" title="Click to Hide"></i>
$mode = $(target).find(".indicator").text();
if ($mode == <?php echo xlj('collapse'); ?>) {
$(target).find(".indicator").text(<?php echo xlj('expand'); ?>);
$("#" + div).hide();
$.post("../../../library/ajax/user_settings.php", {
target: div,
mode: 0,
csrf_token_form: <?php echo js_escape(CsrfUtils::collectCsrfToken()); ?>
});
} else {
$(target).find(".indicator").text(<?php echo xlj('collapse'); ?>);
$("#" + div).show();
$.post("../../../library/ajax/user_settings.php", {
target: div,
mode: 1,
csrf_token_form: <?php echo js_escape(CsrfUtils::collectCsrfToken()); ?>
});
}
}
// edit prescriptions dialog.
// called from stats.php.
//
function editScripts(url) {
var AddScript = function() {
var __this = $(this);
__this.find("#clearButton").css("display", "");
__this.find("#backButton").css("display", "");
__this.find("#addButton").css("display", "none");
var iam = top.frames.editScripts;
iam.location.href = '<?php echo $GLOBALS['webroot'] ?>/controller.php?prescription&edit&id=0&pid=' + <?php echo js_url($pid); ?>;
};
var ListScripts = function() {
var __this = $(this);
__this.find("#clearButton").css("display", "none");
__this.find("#backButton").css("display", "none");
__this.find("#addButton").css("display", "");
var iam = top.frames.editScripts
iam.location.href = '<?php echo $GLOBALS['webroot'] ?>/controller.php?prescription&list&id=' + <?php echo js_url($pid); ?>;
};
let title = <?php echo xlj('Prescriptions'); ?>;
let w = 960; // for weno width
dlgopen(url, 'editScripts', w, 400, '', '', {
buttons: [{
text: <?php echo xlj('Add'); ?>,
close: false,
id: 'addButton',
class: 'btn-primary btn-sm',
click: AddScript
},
{
text: <?php echo xlj('Clear'); ?>,
close: false,
id: 'clearButton',
style: 'display:none;',
class: 'btn-primary btn-sm',
click: AddScript
},
{
text: <?php echo xlj('Back'); ?>,
close: false,
id: 'backButton',
style: 'display:none;',
class: 'btn-primary btn-sm',
click: ListScripts
},
{
text: <?php echo xlj('Quit'); ?>,
close: true,
id: 'doneButton',
class: 'btn-secondary btn-sm'
}
],
onClosed: 'refreshme',
allowResize: true,
allowDrag: true,
dialogId: 'editscripts',
type: 'iframe'
});
return false;
}
/**
* async function fetchHtml(...)
*
* @param {*} url
* @param {boolean} embedded
* @param {boolean} sessionRestore
* @returns {text}
*/
async function fetchHtml(url, embedded = false, sessionRestore = false) {
if (sessionRestore === true) {
// restore cookie before fetch.
top.restoreSession();
}
let csrf = new FormData;
// a security given.
csrf.append("csrf_token_form", <?php echo js_escape(CsrfUtils::collectCsrfToken()); ?>);
if (embedded === true) {
// special formatting in certain widgets.
csrf.append("embeddedScreen", true);
}
const response = await fetch(url, {
method: 'POST',
credentials: 'same-origin',
body: csrf
});
return await response.text();
}
/**
* async function placeHtml(...) will await fetch of html then place in divId.
* This function will return a promise for use to init various items regarding
* inserted HTML if needed.
* If divId does not exist, then will skip.
* Example
*
* @param {*} url
* @param {string} divId id
* @param {boolean} embedded
* @param {boolean} sessionRestore
* @returns {object} promise
*/
async function placeHtml(url, divId, embedded = false, sessionRestore = false) {
const contentDiv = document.getElementById(divId);
if (contentDiv) {
await fetchHtml(url, embedded, sessionRestore).then(fragment => {
contentDiv.innerHTML = fragment;
});
}
}
if (typeof load_location === 'undefined') {
function load_location(location) {
top.restoreSession();
document.location = location;
}
}
$(function() {
var msg_updation = '';
<?php
if ($GLOBALS['erx_enable']) {
$soap_status = sqlStatement("select soap_import_status,pid from patient_data where pid=? and soap_import_status in ('1','3')", array($pid));
while ($row_soapstatus = sqlFetchArray($soap_status)) { ?>
top.restoreSession();
let reloadRequired = false;
$.ajax({
type: "POST",
url: "../../soap_functions/soap_patientfullmedication.php",
dataType: "html",
data: {
patient: <?php echo js_escape($row_soapstatus['pid']); ?>,
},
async: false,
success: function(thedata) {
if (!thedata.includes("Nothing")) {
reloadRequired = true;
}
msg_updation += thedata;
},
error: function() {
alert('ajax error');
}
});
top.restoreSession();
$.ajax({
type: "POST",
url: "../../soap_functions/soap_allergy.php",
dataType: "html",
data: {
patient: <?php echo js_escape($row_soapstatus['pid']); ?>,
},
async: false,
success: function(thedata) {
if (!thedata.includes("Nothing")) {
reloadRequired = true;
}
msg_updation += "\n" + thedata;
},
error: function() {
alert('ajax error');
}
});
if (reloadRequired) {
document.location.reload();
}
<?php
if ($GLOBALS['erx_import_status_message']) { ?>
if (msg_updation)
alert(msg_updation);
<?php
}
}
}
?>
// load divs
placeHtml("stats.php", "stats_div", true).then(() => {
$('[data-toggle="collapse"]').on('click', function (e) {
updateUserVisibilitySetting(e);
});
});
placeHtml("pnotes_fragment.php", 'pnotes_ps_expand').then(() => {
// must be delegated event!
$(this).on("click", ".complete_btn", function() {
let btn = $(this);
let csrf = new FormData;
csrf.append("csrf_token_form", <?php echo js_escape(CsrfUtils::collectCsrfToken()); ?>);
fetch("pnotes_fragment.php?docUpdateId=" + encodeURIComponent(btn.attr('data-id')), {
method: "POST",
credentials: 'same-origin',
body: csrf
})
.then(function() {
placeHtml("pnotes_fragment.php", 'pnotes_ps_expand');
});
});
});
placeHtml("disc_fragment.php", "disclosures_ps_expand");
placeHtml("labdata_fragment.php", "labdata_ps_expand");
placeHtml("track_anything_fragment.php", "track_anything_ps_expand");
<?php if ($vitals_is_registered && AclMain::aclCheckCore('patients', 'med')) { ?>
// Initialize the Vitals form if it is registered and user is authorized.
placeHtml("vitals_fragment.php", "vitals_ps_expand");
<?php } ?>
<?php if ($GLOBALS['enable_cdr'] && $GLOBALS['enable_cdr_crw']) { ?>
placeHtml("clinical_reminders_fragment.php", "clinical_reminders_ps_expand", true, true).then(() => {
// (note need to place javascript code here also to get the dynamic link to work)
$(".medium_modal").on('click', function(e) {
e.preventDefault();
e.stopPropagation();
dlgopen('', '', 800, 200, '', '', {
buttons: [{
text: <?php echo xlj('Close'); ?>,
close: true,
style: 'secondary btn-sm'
}],
onClosed: 'refreshme',
allowResize: false,
allowDrag: true,
dialogId: 'demreminder',
type: 'iframe',
url: $(this).attr('href')
});
});
});
<?php } // end crw
?>
<?php if ($GLOBALS['enable_cdr'] && $GLOBALS['enable_cdr_prw']) { ?>
placeHtml("patient_reminders_fragment.php", "patient_reminders_ps_expand", false, true);
<?php } // end prw
?>
<?php
// Initialize for each applicable LBF form.
$gfres = sqlStatement("SELECT grp_form_id
FROM layout_group_properties
WHERE grp_form_id LIKE 'LBF%'
AND grp_group_id = ''
AND grp_repeats > 0
AND grp_activity = 1
ORDER BY grp_seq, grp_title");
while ($gfrow = sqlFetchArray($gfres)) { ?>
$(<?php echo js_escape("#" . $gfrow['grp_form_id'] . "_ps_expand"); ?>).load("lbf_fragment.php?formname=" + <?php echo js_url($gfrow['grp_form_id']); ?>, {
csrf_token_form: <?php echo js_escape(CsrfUtils::collectCsrfToken()); ?>
});
<?php } ?>
tabbify();
// modal for dialog boxes
$(".large_modal").on('click', function(e) {
e.preventDefault();
e.stopPropagation();
dlgopen('', '', 1000, 600, '', '', {
buttons: [{
text: <?php echo xlj('Close'); ?>,
close: true,
style: 'secondary btn-sm'
}],
allowResize: true,
allowDrag: true,
dialogId: '',
type: 'iframe',
url: $(this).attr('href')
});
});
$(".rx_modal").on('click', function(e) {
e.preventDefault();
e.stopPropagation();
var title = <?php echo xlj('Amendments'); ?>;
dlgopen('', 'editAmendments', 800, 300, '', title, {
onClosed: 'refreshme',
allowResize: true,
allowDrag: true,
dialogId: '',
type: 'iframe',
url: $(this).attr('href')
});
});
// modal for image viewer
$(".image_modal").on('click', function(e) {
e.preventDefault();
e.stopPropagation();
dlgopen('', '', 400, 300, '', <?php echo xlj('Patient Images'); ?>, {
allowResize: true,
allowDrag: true,
dialogId: '',
type: 'iframe',
url: $(this).attr('href')
});
});
$(".deleter").on('click', function(e) {
e.preventDefault();
e.stopPropagation();
dlgopen('', '', 600, 360, '', '', {
buttons: [{
text: <?php echo xlj('Close'); ?>,
close: true,
style: 'secondary btn-sm'
}],
//onClosed: 'imdeleted',
allowResize: false,
allowDrag: false,
dialogId: 'patdel',
type: 'iframe',
url: $(this).attr('href')
});
});
$(".iframe1").on('click', function(e) {
e.preventDefault();
e.stopPropagation();
dlgopen('', '', 350, 300, '', '', {
buttons: [{
text: <?php echo xlj('Close'); ?>,
close: true,
style: 'secondary btn-sm'
}],
allowResize: true,
allowDrag: true,
dialogId: '',
type: 'iframe',
url: $(this).attr('href')
});
});
// for patient portal
$(".small_modal").on('click', function(e) {
e.preventDefault();
e.stopPropagation();
dlgopen('', '', 550, 550, '', '', {
buttons: [{
text: <?php echo xlj('Close'); ?>,
close: true,
style: 'secondary btn-sm'
}],
allowResize: true,
allowDrag: true,
dialogId: '',
type: 'iframe',
url: $(this).attr('href')
});
});
function openReminderPopup() {
top.restoreSession()
dlgopen('', 'reminders', 500, 250, '', '', {
buttons: [{
text: <?php echo xlj('Close'); ?>,
close: true,
style: 'secondary btn-sm'
}],
allowResize: true,
allowDrag: true,
dialogId: '',
type: 'iframe',
url: $("#reminder_popup_link").attr('href')
});
}
<?php if ($GLOBALS['patient_birthday_alert']) {
// To display the birthday alert:
// 1. The patient is not deceased
// 2. The birthday is today (or in the past depending on global selection)
// 3. The notification has not been turned off (or shown depending on global selection) for this year
$birthdayAlert = new BirthdayReminder($pid, $_SESSION['authUserID']);
if ($birthdayAlert->isDisplayBirthdayAlert()) {
?>
// show the active reminder modal
dlgopen('', 'bdayreminder', 300, 170, '', false, {
allowResize: false,
allowDrag: true,
dialogId: '',
type: 'iframe',
url: $("#birthday_popup").attr('href')
});
<?php } elseif ($active_reminders || $all_allergy_alerts) { ?>
openReminderPopup();
<?php } ?>
<?php } elseif ($active_reminders || $all_allergy_alerts) { ?>
openReminderPopup();
<?php } ?>
});
/**
* Change the preference to expand/collapse a given card.
*
* For the given e element, find the corresponding card body, determine if it is collapsed
* or shown, and then save the state to the user preferences via an async fetch call POST'ing
* the updated setting.
*
* @var e element The Button that was clicked to collapse/expand the card
*/
async function updateUserVisibilitySetting(e) {
const targetID = e.target.getAttribute("data-target");
const target = document.querySelector(targetID);
const targetStr = targetID.substring(1);
// test ensure at least an element we want.
if (target.classList.contains("collapse")) {
// who is icon. Easier to catch BS event than create one specific for this decision..
// Should always be icon target
let iconTarget = e.target.children[0] || e.target;
// toggle
if (iconTarget.classList.contains("fa-expand")) {
iconTarget.classList.remove('fa-expand');
iconTarget.classList.add('fa-compress');
}
else {
iconTarget.classList.remove('fa-compress');
iconTarget.classList.add('fa-expand');
}
}
let formData = new FormData();
formData.append("csrf_token_form", <?php echo js_escape(CsrfUtils::collectCsrfToken()); ?>);
formData.append("target", targetStr);
formData.append("mode", (target.classList.contains("show")) ? 0 : 1);
top.restoreSession();
const response = await fetch("../../../library/ajax/user_settings.php", {
method: "POST",
credentials: 'same-origin',
body: formData,
});
return await response.text();
}
// JavaScript stuff to do when a new patient is set.
//
function setMyPatient() {
<?php
if (isset($_GET['set_pid'])) {
$date_of_death = is_patient_deceased($pid);
if (!empty($date_of_death)) {
$date_of_death = $date_of_death['date_deceased'];
}
?>
parent.left_nav.setPatient(<?php echo js_escape($result['fname'] . " " . $result['lname']) .
"," . js_escape($pid) . "," . js_escape($result['pubpid']) . ",'',";
if (empty($date_of_death)) {
echo js_escape(" " . xl('DOB') . ": " . oeFormatShortDate($result['DOB_YMD']) . " " . xl('Age') . ": " . getPatientAgeDisplay($result['DOB_YMD']));
} else {
echo js_escape(" " . xl('DOB') . ": " . oeFormatShortDate($result['DOB_YMD']) . " " . xl('Age at death') . ": " . oeFormatAge($result['DOB_YMD'], $date_of_death));
} ?>);
var EncounterDateArray = [];
var CalendarCategoryArray = new Array;
var EncounterIdArray = new Array;
var Count = 0;
<?php
//Encounter details are stored to javacript as array.
$result4 = sqlStatement("SELECT fe.encounter,fe.date,openemr_postcalendar_categories.pc_catname FROM form_encounter AS fe " .
" left join openemr_postcalendar_categories on fe.pc_catid=openemr_postcalendar_categories.pc_catid WHERE fe.pid = ? order by fe.date desc", array($pid));
if (sqlNumRows($result4) > 0) {
while ($rowresult4 = sqlFetchArray($result4)) { ?>
EncounterIdArray[Count] = <?php echo js_escape($rowresult4['encounter']); ?>;
EncounterDateArray[Count] = <?php echo js_escape(oeFormatShortDate(date("Y-m-d", strtotime($rowresult4['date'])))); ?>;
CalendarCategoryArray[Count] = <?php echo js_escape(xl_appt_category($rowresult4['pc_catname'])); ?>;
Count++;
<?php
}
}
?>
parent.left_nav.setPatientEncounter(EncounterIdArray, EncounterDateArray, CalendarCategoryArray);
<?php
} // end setting new pid
?>
parent.left_nav.syncRadios();
<?php if ((isset($_GET['set_pid'])) && (isset($_GET['set_encounterid'])) && (intval($_GET['set_encounterid']) > 0)) {
$query_result = sqlQuery("SELECT `date` FROM `form_encounter` WHERE `encounter` = ?", array($encounter)); ?>
encurl = 'encounter/encounter_top.php?set_encounter=' + <?php echo js_url($encounter); ?> + '&pid=' + <?php echo js_url($pid); ?>;
parent.left_nav.setEncounter(<?php echo js_escape(oeFormatShortDate(date("Y-m-d", strtotime($query_result['date'])))); ?>, <?php echo js_escape($encounter); ?>, 'enc');
top.restoreSession();
parent.left_nav.loadFrame('enc2', 'enc', 'patient_file/' + encurl);
<?php } // end setting new encounter id (only if new pid is also set)
?>
}
$(window).on('load', function() {
setMyPatient();
});
</script>
<style>
/* Bad practice to override here, will get moved to base style theme */
.card {
box-shadow: 1px 1px 1px hsl(0 0% 0% / .2);
border-radius: 0;
}
/* Short term fix. This ensures the problem list, allergies, medications, and immunization cards handle long lists without interuppting
the UI. This should be configurable and should go in a more appropriate place
.pami-list {
max-height: 200px;
overflow-y: scroll;
} */
<?php
if (!empty($GLOBALS['right_justify_labels_demographics']) && ($_SESSION['language_direction'] == 'ltr')) { ?>
div.tab td.label_custom, div.label_custom {
text-align: right !important;
}
div.tab td.data, div.data {
padding-left: 0.5em;
padding-right: 2em;
}
<?php
} ?>
<?php
// This is for layout font size override.
$grparr = array();
getLayoutProperties('DEM', $grparr, 'grp_size');
if (!empty($grparr['']['grp_size'])) {
$FONTSIZE = round($grparr['']['grp_size'] * 1.333333);
$FONTSIZE = round($FONTSIZE * 0.0625, 2);
?>
/* Override font sizes in the theme. */
#DEM .groupname {
font-size: <?php echo attr($FONTSIZE); ?>rem;
}
#DEM .label {
font-size: <?php echo attr($FONTSIZE); ?>rem;
}
#DEM .data {
font-size: <?php echo attr($FONTSIZE); ?>rem;
}
#DEM .data td {
font-size: <?php echo attr($FONTSIZE); ?>rem;
}
<?php } ?> :root {
--white: #fff;
--bg: hsl(0 0% 90%);
}
body {
background: var(--bg) !important;
}
section {
background: var(--white);
margin-top: .25em;
padding: .25em;
}
.section-header-dynamic {
border-bottom: none;
}
</style>
<title><?php echo xlt("Dashboard{{patient file}}"); ?></title>
</head>
<body class="mt-1 patient-demographic bg-light">
<?php
// Create and fire the patient demographics view event
$viewEvent = new ViewEvent($pid);