Merge pull request #1334 from bradymiller/globals-bootstrap-first-step_1
[openemr.git] / acl_setup.php
blobbf22d14f8a6b290f144045b55c81e05fa1b35e16
1 <?php
2 /**
3 * This program is run by the OpenEMR setup.php script to install phpGACL
4 * and creates the Access Control Objects and their sections.
5 * See openemr/library/acl.inc file for the list of
6 * currently supported Access Control Objects(ACO), which this
7 * script will install. This script also creates several
8 * ARO groups, an "admin" ARO, and some reasonable ACL entries for
9 * the groups.
10 * ARO groups include:
11 * Administrators
12 * Physicians (Doctors)
13 * Clinicians (Nurses, Physician Assistants, etc.)
14 * Front Office (Receptionist)
15 * Accounting
17 * Upgrade Howto
18 * When upgrading to a new version of OpenEMR, run the acl_upgrade.php
19 * script to update the phpGACL access controls. This is required to
20 * ensure the database includes all the required Access Control
21 * Objects(ACO).
23 * @package OpenEMR
24 * @link http://www.open-emr.org
25 * @author Rod Roark <rod@sunsetsystems.com>
26 * @author Brady Miller <brady.g.miller@gmail.com>
27 * @copyright Copyright (c) 2005-2017 Rod Roark <rod@sunsetsystems.com>
28 * @copyright Copyright (c) 2017 Brady Miller <brady.g.miller@gmail.com>
29 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
32 require_once(dirname(__FILE__).'/library/acl.inc');
34 if (empty($phpgacl_location)) {
35 die("You must first set up library/acl.inc to use phpGACL!");
38 require_once("$phpgacl_location/gacl_api.class.php");
40 $gacl = new gacl_api();
42 // Create the ACO sections. Every ACO must have a section.
44 if ($gacl->add_object_section('Accounting', 'acct', 10, 0, 'ACO') === false) {
45 echo "Unable to create the access controls for OpenEMR. You have likely already run this script (acl_setup.php) successfully.<br>Other possible problems include php-GACL configuration file errors (gacl.ini.php or gacl.class.php).<br>";
46 return;
48 // xl('Accounting')
49 $gacl->add_object_section('Administration', 'admin', 10, 0, 'ACO');
50 // xl('Administration')
51 $gacl->add_object_section('Encounters', 'encounters', 10, 0, 'ACO');
52 // xl('Encounters')
53 $gacl->add_object_section('Lists', 'lists', 10, 0, 'ACO');
54 // xl('Lists')
55 $gacl->add_object_section('Patients', 'patients', 10, 0, 'ACO');
56 // xl('Patients')
57 $gacl->add_object_section('Squads', 'squads', 10, 0, 'ACO');
58 // xl('Squads')
59 $gacl->add_object_section('Sensitivities', 'sensitivities', 10, 0, 'ACO');
60 // xl('Sensitivities')
61 $gacl->add_object_section('Placeholder', 'placeholder', 10, 0, 'ACO');
62 // xl('Placeholder')
63 $gacl->add_object_section('Nation Notes', 'nationnotes', 10, 0, 'ACO');
64 // xl('Nation Notes')
65 $gacl->add_object_section('Patient Portal', 'patientportal', 10, 0, 'ACO');
66 // xl('Patient Portal')
67 $gacl->add_object_section('Menus', 'menus', 10, 0, 'ACO');
68 // xl('Menus')
69 $gacl->add_object_section('Groups', 'groups', 10, 0, 'ACO');
70 // xl('Groups')
74 // Create Accounting ACOs.
76 $gacl->add_object('acct', 'Billing (write optional)', 'bill', 10, 0, 'ACO');
77 // xl('Billing (write optional)')
78 $gacl->add_object('acct', 'Price Discounting', 'disc', 10, 0, 'ACO');
79 // xl('Price Discounting')
80 $gacl->add_object('acct', 'EOB Data Entry', 'eob', 10, 0, 'ACO');
81 // xl('EOB Data Entry')
82 $gacl->add_object('acct', 'Financial Reporting - my encounters', 'rep', 10, 0, 'ACO');
83 // xl('Financial Reporting - my encounters')
84 $gacl->add_object('acct', 'Financial Reporting - anything', 'rep_a', 10, 0, 'ACO');
85 // xl('Financial Reporting - anything')
87 // Create Administration ACOs.
89 $gacl->add_object('admin', 'Superuser', 'super', 10, 0, 'ACO');
90 // xl('Superuser')
91 $gacl->add_object('admin', 'Calendar Settings', 'calendar', 10, 0, 'ACO');
92 // xl('Calendar Settings')
93 $gacl->add_object('admin', 'Database Reporting', 'database', 10, 0, 'ACO');
94 // xl('Database Reporting')
95 $gacl->add_object('admin', 'Forms Administration', 'forms', 10, 0, 'ACO');
96 // xl('Forms Administration')
97 $gacl->add_object('admin', 'Practice Settings', 'practice', 10, 0, 'ACO');
98 // xl('Practice Settings')
99 $gacl->add_object('admin', 'Superbill Codes Administration', 'superbill', 10, 0, 'ACO');
100 // xl('Superbill Codes Administration')
101 $gacl->add_object('admin', 'Users/Groups/Logs Administration', 'users', 10, 0, 'ACO');
102 // xl('Users/Groups/Logs Administration')
103 $gacl->add_object('admin', 'Batch Communication Tool', 'batchcom', 10, 0, 'ACO');
104 // xl('Batch Communication Tool')
105 $gacl->add_object('admin', 'Language Interface Tool', 'language', 10, 0, 'ACO');
106 // xl('Language Interface Tool')
107 $gacl->add_object('admin', 'Pharmacy Dispensary', 'drugs', 10, 0, 'ACO');
108 // xl('Pharmacy Dispensary')
109 $gacl->add_object('admin', 'ACL Administration', 'acl', 10, 0, 'ACO');
110 // xl('ACL Administration')
111 $gacl->add_object('admin', 'Multipledb', 'multipledb', 10, 0, 'ACO');
112 // xl('Multipledb')
113 $gacl->add_object('admin', 'Menu', 'menu', 10, 0, 'ACO');
114 // xl('Menu')
115 $gacl->add_object('admin', 'Manage modules', 'manage_modules', 10, 0, 'ACO');
116 // xl('Manage modules')
119 // Create ACOs for encounters.
121 $gacl->add_object('encounters', 'Authorize - my encounters', 'auth', 10, 0, 'ACO');
122 // xl('Authorize - my encounters')
123 $gacl->add_object('encounters', 'Authorize - any encounters', 'auth_a', 10, 0, 'ACO');
124 // xl('Authorize - any encounters')
125 $gacl->add_object('encounters', 'Coding - my encounters (write,wsome optional)', 'coding', 10, 0, 'ACO');
126 // xl('Coding - my encounters (write,wsome optional)')
127 $gacl->add_object('encounters', 'Coding - any encounters (write,wsome optional)', 'coding_a', 10, 0, 'ACO');
128 // xl('Coding - any encounters (write,wsome optional)')
129 $gacl->add_object('encounters', 'Notes - my encounters (write,addonly optional)', 'notes', 10, 0, 'ACO');
130 // xl('Notes - my encounters (write,addonly optional)')
131 $gacl->add_object('encounters', 'Notes - any encounters (write,addonly optional)', 'notes_a', 10, 0, 'ACO');
132 // xl('Notes - any encounters (write,addonly optional)')
133 $gacl->add_object('encounters', 'Fix encounter dates - any encounters', 'date_a', 10, 0, 'ACO');
134 // xl('Fix encounter dates - any encounters')
135 $gacl->add_object('encounters', 'Less-private information (write,addonly optional)', 'relaxed', 10, 0, 'ACO');
136 // xl('Less-private information (write,addonly optional)')
138 // Create ACOs for lists.
140 $gacl->add_object('lists', 'Default List (write,addonly optional)', 'default', 10, 0, 'ACO');
141 // xl('Default List (write,addonly optional)')
142 $gacl->add_object('lists', 'State List (write,addonly optional)', 'state', 10, 0, 'ACO');
143 // xl('State List (write,addonly optional)')
144 $gacl->add_object('lists', 'Country List (write,addonly optional)', 'country', 10, 0, 'ACO');
145 // xl('Country List (write,addonly optional)')
146 $gacl->add_object('lists', 'Language List (write,addonly optional)', 'language', 10, 0, 'ACO');
147 // xl('Language List (write,addonly optional)')
148 $gacl->add_object('lists', 'Ethnicity-Race List (write,addonly optional)', 'ethrace', 10, 0, 'ACO');
149 // xl('Ethnicity-Race List (write,addonly optional)')
151 // Create ACOs for patientportal.
153 $gacl->add_object('patientportal', 'Patient Portal', 'portal', 10, 0, 'ACO');
154 // xl('Patient Portal')
156 // Create ACOs for modules.
158 $gacl->add_object('menus', 'Modules', 'modle', 10, 0, 'ACO');
159 // xl('Modules')
161 // Create ACOs for patients.
163 $gacl->add_object('patients', 'Appointments (write,wsome optional)', 'appt', 10, 0, 'ACO');
164 // xl('Appointments (write,wsome optional)')
165 $gacl->add_object('patients', 'Demographics (write,addonly optional)', 'demo', 10, 0, 'ACO');
166 // xl('Demographics (write,addonly optional)')
167 $gacl->add_object('patients', 'Medical/History (write,addonly optional)', 'med', 10, 0, 'ACO');
168 // xl('Medical/History (write,addonly optional)')
169 $gacl->add_object('patients', 'Transactions (write optional)', 'trans', 10, 0, 'ACO');
170 // xl('Transactions (write optional)')
171 $gacl->add_object('patients', 'Documents (write,addonly optional)', 'docs', 10, 0, 'ACO');
172 // xl('Documents (write,addonly optional)')
173 $gacl->add_object('patients', 'Patient Notes (write,addonly optional)', 'notes', 10, 0, 'ACO');
174 // xl('Patient Notes (write,addonly optional)')
175 $gacl->add_object('patients', 'Sign Lab Results (write,addonly optional)', 'sign', 10, 0, 'ACO');
176 // xl('Sign Lab Results (write,addonly optional)')
177 $gacl->add_object('patients', 'Patient Reminders (write,addonly optional)', 'reminder', 10, 0, 'ACO');
178 // xl('Patient Reminders (write,addonly optional)')
179 $gacl->add_object('patients', 'Clinical Reminders/Alerts (write,addonly optional)', 'alert', 10, 0, 'ACO');
180 // xl('Clinical Reminders/Alerts (write,addonly optional)')
181 $gacl->add_object('patients', 'Disclosures (write,addonly optional)', 'disclosure', 10, 0, 'ACO');
182 // xl('Disclosures (write,addonly optional)')
183 $gacl->add_object('patients', 'Prescriptions (write,addonly optional)', 'rx', 10, 0, 'ACO');
184 // xl('Prescriptions (write,addonly optional)')
185 $gacl->add_object('patients', 'Amendments (write,addonly optional)', 'amendment', 10, 0, 'ACO');
186 // xl('Amendments (write,addonly optional)')
187 $gacl->add_object('patients', 'Lab Results (write,addonly optional)', 'lab', 10, 0, 'ACO');
188 // xl('Lab Results (write,addonly optional)')
191 $gacl->add_object('groups', 'View/Add/Update groups', 'gadd', 10, 0, 'ACO');
192 // xl('View/Add/Update groups')
193 $gacl->add_object('groups', 'View/Create/Update groups appointment in calendar', 'gcalendar', 10, 0, 'ACO');
194 // xl('View/Create/Update groups appointment in calendar')
195 $gacl->add_object('groups', 'Group encounter log', 'glog', 10, 0, 'ACO');
196 // xl('Group encounter log')
197 $gacl->add_object('groups', 'Group detailed log of appointment in patient record', 'gdlog', 10, 0, 'ACO');
198 // xl('Group detailed log of appointment in patient record')
199 $gacl->add_object('groups', 'Send message from the permanent group therapist to the personal therapist', 'gm', 10, 0, 'ACO');
200 // xl('Send message from the permanent group therapist to the personal therapist')
202 // Create ACOs for sensitivities.
204 $gacl->add_object('sensitivities', 'Normal', 'normal', 10, 0, 'ACO');
205 // xl('Normal')
206 $gacl->add_object('sensitivities', 'High', 'high', 20, 0, 'ACO');
207 // xl('High')
209 // Create ACO for placeholder.
211 $gacl->add_object('placeholder', 'Placeholder (Maintains empty ACLs)', 'filler', 10, 0, 'ACO');
212 // xl('Placeholder (Maintains empty ACLs)')
214 // Create ACO for nationnotes.
216 $gacl->add_object('nationnotes', 'Nation Notes Configure', 'nn_configure', 10, 0, 'ACO');
217 // xl('Nation Notes Configure')
219 // Create ARO groups.
221 $users = $gacl->add_group('users', 'OpenEMR Users', 0, 'ARO');
222 // xl('OpenEMR Users')
223 $admin = $gacl->add_group('admin', 'Administrators', $users, 'ARO');
224 // xl('Administrators')
225 $clin = $gacl->add_group('clin', 'Clinicians', $users, 'ARO');
226 // xl('Clinicians')
227 $doc = $gacl->add_group('doc', 'Physicians', $users, 'ARO');
228 // xl('Physicians')
229 $front = $gacl->add_group('front', 'Front Office', $users, 'ARO');
230 // xl('Front Office')
231 $back = $gacl->add_group('back', 'Accounting', $users, 'ARO');
232 // xl('Accounting')
233 $breakglass = $gacl->add_group('breakglass', 'Emergency Login', $users, 'ARO');
234 // xl('Emergency Login')
237 // Create a Users section for the AROs (humans).
239 $gacl->add_object_section('Users', 'users', 10, 0, 'ARO');
240 // xl('Users')
242 // Create the Administrator in the above-created "users" section
243 // and add him/her to the above-created "admin" group.
244 // If this script is being used by OpenEMR's setup, then will
245 // incorporate the installation values. Otherwise will
246 // hardcode the 'admin' user.
247 if (isset($this) && isset($this->iuser)) {
248 $gacl->add_object('users', $this->iuname, $this->iuser, 10, 0, 'ARO');
249 $gacl->add_group_object($admin, 'users', $this->iuser, 'ARO');
250 } else {
251 $gacl->add_object('users', 'Administrator', 'admin', 10, 0, 'ARO');
252 $gacl->add_group_object($admin, 'users', 'admin', 'ARO');
255 // Declare return terms for language translations
256 // xl('write') xl('wsome') xl('addonly') xl('view')
258 // Set permissions for administrators.
260 $gacl->add_acl(
261 array(
262 'acct'=>array('bill', 'disc', 'eob', 'rep', 'rep_a'),
263 'admin'=>array('calendar', 'database', 'forms', 'practice', 'superbill', 'users', 'batchcom', 'language', 'super', 'drugs', 'acl','multipledb','menu','manage_modules'),
264 'encounters'=>array('auth_a', 'auth', 'coding_a', 'coding', 'notes_a', 'notes', 'date_a', 'relaxed'),
265 'lists'=>array('default','state','country','language','ethrace'),
266 'patients'=>array('appt', 'demo', 'med', 'trans', 'docs', 'notes', 'sign', 'reminder', 'alert', 'disclosure', 'rx', 'amendment', 'lab'),
267 'sensitivities'=>array('normal', 'high'),
268 'nationnotes'=>array('nn_configure'),
269 'patientportal'=>array('portal'),
270 'menus'=>array('modle'),
271 'groups'=>array('gadd','gcalendar','glog','gdlog','gm')
273 null,
274 array($admin),
275 null,
276 null,
279 'write',
280 'Administrators can do anything'
282 // xl('Administrators can do anything')
284 // Set permissions for physicians.
286 $gacl->add_acl(
287 array(
288 'placeholder'=>array('filler')
290 null,
291 array($doc),
292 null,
293 null,
296 'view',
297 'Things that physicians can only read'
299 // xl('Things that physicians can only read')
300 $gacl->add_acl(
301 array(
302 'placeholder'=>array('filler')
304 null,
305 array($doc),
306 null,
307 null,
310 'addonly',
311 'Things that physicians can read and enter but not modify'
313 // xl('Things that physicians can read and enter but not modify')
314 $gacl->add_acl(
315 array(
316 'placeholder'=>array('filler')
318 null,
319 array($doc),
320 null,
321 null,
324 'wsome',
325 'Things that physicians can read and partly modify'
327 // xl('Things that physicians can read and partly modify')
328 $gacl->add_acl(
329 array(
330 'acct'=>array('disc', 'rep'),
331 'admin'=>array('drugs'),
332 'encounters'=>array('auth_a', 'auth', 'coding_a', 'coding', 'notes_a', 'notes', 'date_a', 'relaxed'),
333 'patients' => array('appt', 'demo', 'med', 'trans', 'docs', 'notes', 'sign', 'reminder', 'alert',
334 'disclosure', 'rx', 'amendment', 'lab'),
335 'sensitivities'=>array('normal', 'high'),
336 'groups'=>array('gcalendar','glog')
338 null,
339 array($doc),
340 null,
341 null,
344 'write',
345 'Things that physicians can read and modify'
347 // xl('Things that physicians can read and modify')
349 // Set permissions for clinicians.
351 $gacl->add_acl(
352 array(
353 'placeholder'=>array('filler')
355 null,
356 array($clin),
357 null,
358 null,
361 'view',
362 'Things that clinicians can only read'
364 // xl('Things that clinicians can only read')
365 $gacl->add_acl(
366 array(
367 'encounters'=>array('notes', 'relaxed'),
368 'patients'=>array('demo', 'med', 'docs', 'notes','trans', 'reminder', 'alert', 'disclosure', 'rx', 'amendment', 'lab'),
369 'sensitivities'=>array('normal')
371 null,
372 array($clin),
373 null,
374 null,
377 'addonly',
378 'Things that clinicians can read and enter but not modify'
380 // xl('Things that clinicians can read and enter but not modify')
381 $gacl->add_acl(
382 array(
383 'placeholder'=>array('filler')
385 null,
386 array($clin),
387 null,
388 null,
391 'wsome',
392 'Things that clinicians can read and partly modify'
394 // xl('Things that clinicians can read and partly modify')
395 $gacl->add_acl(
396 array(
397 'admin'=>array('drugs'),
398 'encounters'=>array('coding'),
399 'patients'=>array('appt'),
400 'groups'=>array('gcalendar','glog')
402 null,
403 array($clin),
404 null,
405 null,
408 'write',
409 'Things that clinicians can read and modify'
411 // xl('Things that clinicians can read and modify')
413 // Set permissions for front office staff.
415 $gacl->add_acl(
416 array(
417 'patients'=>array('alert')
419 null,
420 array($front),
421 null,
422 null,
425 'view',
426 'Things that front office can only read'
428 // xl('Things that front office can only read')
429 $gacl->add_acl(
430 array(
431 'placeholder'=>array('filler')
433 null,
434 array($front),
435 null,
436 null,
439 'addonly',
440 'Things that front office can read and enter but not modify'
442 // xl('Things that front office can read and enter but not modify')
443 $gacl->add_acl(
444 array(
445 'placeholder'=>array('filler')
447 null,
448 array($front),
449 null,
450 null,
453 'wsome',
454 'Things that front office can read and partly modify'
456 // xl('Things that front office can read and partly modify')
457 $gacl->add_acl(
458 array(
459 'patients'=>array('appt', 'demo', 'trans', 'notes'),
460 'groups'=>array('gcalendar')
462 null,
463 array($front),
464 null,
465 null,
468 'write',
469 'Things that front office can read and modify'
471 // xl('Things that front office can read and modify')
473 // Set permissions for back office staff.
475 $gacl->add_acl(
476 array(
477 'patients'=>array('alert')
479 null,
480 array($back),
481 null,
482 null,
485 'view',
486 'Things that back office can only read'
488 // xl('Things that back office can only read')
489 $gacl->add_acl(
490 array(
491 'placeholder'=>array('filler')
493 null,
494 array($back),
495 null,
496 null,
499 'addonly',
500 'Things that back office can read and enter but not modify'
502 // xl('Things that back office can read and enter but not modify')
503 $gacl->add_acl(
504 array(
505 'placeholder'=>array('filler')
507 null,
508 array($back),
509 null,
510 null,
513 'wsome',
514 'Things that back office can read and partly modify'
516 // xl('Things that back office can read and partly modify')
517 $gacl->add_acl(
518 array(
519 'acct'=>array('bill', 'disc', 'eob', 'rep', 'rep_a'),
520 'admin'=>array('practice', 'superbill'),
521 'encounters'=>array('auth_a', 'coding_a', 'date_a'),
522 'patients'=>array('appt', 'demo')
524 null,
525 array($back),
526 null,
527 null,
530 'write',
531 'Things that back office can read and modify'
533 // xl('Things that back office can read and modify')
535 // Set permissions for Emergency Login.
537 $gacl->add_acl(
538 array(
539 'acct'=>array('bill', 'disc', 'eob', 'rep', 'rep_a'),
540 'admin'=>array('calendar', 'database', 'forms', 'practice', 'superbill', 'users', 'batchcom', 'language', 'super', 'drugs', 'acl','multipledb','menu','manage_modules'),
541 'encounters'=>array('auth_a', 'auth', 'coding_a', 'coding', 'notes_a', 'notes', 'date_a', 'relaxed'),
542 'lists'=>array('default','state','country','language','ethrace'),
543 'patients'=>array('appt', 'demo', 'med', 'trans', 'docs', 'notes', 'sign', 'reminder', 'alert', 'disclosure', 'rx', 'amendment', 'lab'),
544 'sensitivities'=>array('normal', 'high'),
545 'nationnotes'=>array('nn_configure'),
546 'patientportal'=>array('portal'),
547 'menus'=>array('modle'),
548 'groups'=>array('gadd','gcalendar','glog','gdlog','gm')
550 null,
551 array($breakglass),
552 null,
553 null,
556 'write',
557 'Emergency Login user can do anything'
559 // xl('Emergency Login user can do anything')
562 <html>
563 <head>
564 <title>OpenEMR ACL Setup</title>
565 <link rel=STYLESHEET href="interface/themes/style_blue.css">
566 </head>
567 <body>
568 <b>OpenEMR ACL Setup</b>
569 <br>
570 All done configuring and installing access controls (php-GACL)!
571 </body>
572 </html>