forked from openemr/openemr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
openemr.bootstrap.php
120 lines (108 loc) · 4.18 KB
/
openemr.bootstrap.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
<?php
/*
*
* @package OpenEMR
* @link https://www.open-emr.org
*
* @author Sherwin Gaddis <[email protected]>
* @copyright Copyright (c) 2021 Sherwin Gaddis <[email protected]>
* All Rights Reserved
*
*/
use OpenEMR\Common\Acl\AclMain;
use OpenEMR\Menu\MenuEvent;
use OpenEMR\Menu\PatientMenuEvent;
use OpenEMR\Events\PatientDemographics\RenderEvent;
use OpenEMR\Common\Csrf\CsrfUtils;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
function oe_module_priorauth_add_menu_item(MenuEvent $event)
{
$menu = $event->getMenu();
$menuItem = new stdClass();
$menuItem->requirement = 0;
$menuItem->target = 'mod';
$menuItem->menu_id = 'mod0';
$menuItem->label = xlt("Prior Authorization Report");
$menuItem->url = "/interface/modules/custom_modules/oe-module-prior-authorizations/public/reports/list_report.php";
$menuItem->children = [];
$menuItem->acl_req = ["patients", "docs"];
$menuItem->global_req = [];
foreach ($menu as $item) {
if ($item->menu_id == 'patimg') {
$item->children[] = $menuItem;
break;
}
}
$event->setMenu($menu);
return $event;
}
function oe_module_priorauth_patient_menu_item(PatientMenuEvent $menuEvent)
{
$menu = file_get_contents(__DIR__ . '/public/patient_menu/custom_patient_menu.json');
$menu_parsed = json_decode($menu);
$menuEvent->setMenu($menu_parsed);
return $menuEvent;
}
function renderButtonPostLoad(Event $event)
{
$patient_status = sqlQuery("SELECT `status` FROM `patient_status` WHERE `pid` = ? ORDER BY `statusId` DESC LIMIT 1", [$_SESSION['pid']]);
if (($patient_status['status'] != 'inactive') && (AclMain::aclCheckCore('admin', 'super'))) {
?>
<script>
let navbar = document.querySelector('nav.navbar:first-of-type');
let ele = document.createElement("div");
ele.id = "customepatientnav";
ele.innerHTML = '<button class="btn btn-danger" id="addButton">'<?php echo xlt("Mark Inactive") ?>'</button>';
navbar.appendChild(ele);
</script>
<?php
} else {
?>
<script>
let navbar = document.querySelector('nav.navbar:first-of-type');
let ele = document.createElement("div");
ele.id = "customepatientnav";
ele.innerHTML = '<button class="btn btn-success" id="addButton">'<?php echo xlt("Mark Active") ?>'</button>';
navbar.appendChild(ele);
</script>
<?php
}
?>
<script>
document
.getElementById('addButton')
.addEventListener("click", function (e){
if( ! confirm(<?php echo xlj('Do you really want to do this?') ?>)){
e.preventDefault();
} else {
alert(<?php echo xlj('Ok, lets do this! Click ok to really mark inactive.') ?>));
let libUrl = 'patient_status.php';
let pid = <?php echo js_escape($_SESSION['pid']); ?>;
let csrf = <?php echo js_escape(CsrfUtils::collectCsrfToken()); ?>;
$.ajax({
type: "POST",
url: libUrl,
data: {patientid: pid, csrf_token: csrf},
error: function (qXHR) {
console.log("There was an error");
alert(<?php echo xlj("File Error") ?> +"\n" + id)
},
success: function (result) {
alert(result);
}
});
}
});
</script
<?php
}
/**
* @var EventDispatcherInterface $eventDispatcher
* @var array $module
* @global $eventDispatcher @see ModulesApplication::loadCustomModule
* @global $module @see ModulesApplication::loadCustomModule
*/
$eventDispatcher->addListener(MenuEvent::MENU_UPDATE, 'oe_module_priorauth_add_menu_item');
$eventDispatcher->addListener(PatientMenuEvent::MENU_UPDATE, 'oe_module_priorauth_patient_menu_item');
$eventDispatcher->addListener(RenderEvent::EVENT_RENDER_POST_PAGELOAD, 'renderButtonPostLoad');