some fixes (#1783)
[openemr.git] / acl_setup.php
blobcb449fdd17686f9ead14d6fc508581debc241eab
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', 'Documents Delete', 'docs_rm', 10, 0, 'ACO');
174 // xl('Documents Delete')
175 $gacl->add_object('patients', 'Patient Notes (write,addonly optional)', 'notes', 10, 0, 'ACO');
176 // xl('Patient Notes (write,addonly optional)')
177 $gacl->add_object('patients', 'Sign Lab Results (write,addonly optional)', 'sign', 10, 0, 'ACO');
178 // xl('Sign Lab Results (write,addonly optional)')
179 $gacl->add_object('patients', 'Patient Reminders (write,addonly optional)', 'reminder', 10, 0, 'ACO');
180 // xl('Patient Reminders (write,addonly optional)')
181 $gacl->add_object('patients', 'Clinical Reminders/Alerts (write,addonly optional)', 'alert', 10, 0, 'ACO');
182 // xl('Clinical Reminders/Alerts (write,addonly optional)')
183 $gacl->add_object('patients', 'Disclosures (write,addonly optional)', 'disclosure', 10, 0, 'ACO');
184 // xl('Disclosures (write,addonly optional)')
185 $gacl->add_object('patients', 'Prescriptions (write,addonly optional)', 'rx', 10, 0, 'ACO');
186 // xl('Prescriptions (write,addonly optional)')
187 $gacl->add_object('patients', 'Amendments (write,addonly optional)', 'amendment', 10, 0, 'ACO');
188 // xl('Amendments (write,addonly optional)')
189 $gacl->add_object('patients', 'Lab Results (write,addonly optional)', 'lab', 10, 0, 'ACO');
190 // xl('Lab Results (write,addonly optional)')
193 $gacl->add_object('groups', 'View/Add/Update groups', 'gadd', 10, 0, 'ACO');
194 // xl('View/Add/Update groups')
195 $gacl->add_object('groups', 'View/Create/Update groups appointment in calendar', 'gcalendar', 10, 0, 'ACO');
196 // xl('View/Create/Update groups appointment in calendar')
197 $gacl->add_object('groups', 'Group encounter log', 'glog', 10, 0, 'ACO');
198 // xl('Group encounter log')
199 $gacl->add_object('groups', 'Group detailed log of appointment in patient record', 'gdlog', 10, 0, 'ACO');
200 // xl('Group detailed log of appointment in patient record')
201 $gacl->add_object('groups', 'Send message from the permanent group therapist to the personal therapist', 'gm', 10, 0, 'ACO');
202 // xl('Send message from the permanent group therapist to the personal therapist')
204 // Create ACOs for sensitivities.
206 $gacl->add_object('sensitivities', 'Normal', 'normal', 10, 0, 'ACO');
207 // xl('Normal')
208 $gacl->add_object('sensitivities', 'High', 'high', 20, 0, 'ACO');
209 // xl('High')
211 // Create ACO for placeholder.
213 $gacl->add_object('placeholder', 'Placeholder (Maintains empty ACLs)', 'filler', 10, 0, 'ACO');
214 // xl('Placeholder (Maintains empty ACLs)')
216 // Create ACO for nationnotes.
218 $gacl->add_object('nationnotes', 'Nation Notes Configure', 'nn_configure', 10, 0, 'ACO');
219 // xl('Nation Notes Configure')
221 // Create ARO groups.
223 $users = $gacl->add_group('users', 'OpenEMR Users', 0, 'ARO');
224 // xl('OpenEMR Users')
225 $admin = $gacl->add_group('admin', 'Administrators', $users, 'ARO');
226 // xl('Administrators')
227 $clin = $gacl->add_group('clin', 'Clinicians', $users, 'ARO');
228 // xl('Clinicians')
229 $doc = $gacl->add_group('doc', 'Physicians', $users, 'ARO');
230 // xl('Physicians')
231 $front = $gacl->add_group('front', 'Front Office', $users, 'ARO');
232 // xl('Front Office')
233 $back = $gacl->add_group('back', 'Accounting', $users, 'ARO');
234 // xl('Accounting')
235 $breakglass = $gacl->add_group('breakglass', 'Emergency Login', $users, 'ARO');
236 // xl('Emergency Login')
239 // Create a Users section for the AROs (humans).
241 $gacl->add_object_section('Users', 'users', 10, 0, 'ARO');
242 // xl('Users')
244 // Create the Administrator in the above-created "users" section
245 // and add him/her to the above-created "admin" group.
246 // If this script is being used by OpenEMR's setup, then will
247 // incorporate the installation values. Otherwise will
248 // hardcode the 'admin' user.
249 if (isset($this) && isset($this->iuser)) {
250 $gacl->add_object('users', $this->iuname, $this->iuser, 10, 0, 'ARO');
251 $gacl->add_group_object($admin, 'users', $this->iuser, 'ARO');
252 } else {
253 $gacl->add_object('users', 'Administrator', 'admin', 10, 0, 'ARO');
254 $gacl->add_group_object($admin, 'users', 'admin', 'ARO');
257 // Declare return terms for language translations
258 // xl('write') xl('wsome') xl('addonly') xl('view')
260 // Set permissions for administrators.
262 $gacl->add_acl(
263 array(
264 'acct'=>array('bill', 'disc', 'eob', 'rep', 'rep_a'),
265 'admin'=>array('calendar', 'database', 'forms', 'practice', 'superbill', 'users', 'batchcom', 'language', 'super', 'drugs', 'acl','multipledb','menu','manage_modules'),
266 'encounters'=>array('auth_a', 'auth', 'coding_a', 'coding', 'notes_a', 'notes', 'date_a', 'relaxed'),
267 'lists'=>array('default','state','country','language','ethrace'),
268 'patients'=>array('appt', 'demo', 'med', 'trans', 'docs', 'notes', 'sign', 'reminder', 'alert', 'disclosure', 'rx', 'amendment', 'lab', 'docs_rm'),
269 'sensitivities'=>array('normal', 'high'),
270 'nationnotes'=>array('nn_configure'),
271 'patientportal'=>array('portal'),
272 'menus'=>array('modle'),
273 'groups'=>array('gadd','gcalendar','glog','gdlog','gm')
275 null,
276 array($admin),
277 null,
278 null,
281 'write',
282 'Administrators can do anything'
284 // xl('Administrators can do anything')
286 // Set permissions for physicians.
288 $gacl->add_acl(
289 array(
290 'placeholder'=>array('filler')
292 null,
293 array($doc),
294 null,
295 null,
298 'view',
299 'Things that physicians can only read'
301 // xl('Things that physicians can only read')
302 $gacl->add_acl(
303 array(
304 'placeholder'=>array('filler')
306 null,
307 array($doc),
308 null,
309 null,
312 'addonly',
313 'Things that physicians can read and enter but not modify'
315 // xl('Things that physicians can read and enter but not modify')
316 $gacl->add_acl(
317 array(
318 'placeholder'=>array('filler')
320 null,
321 array($doc),
322 null,
323 null,
326 'wsome',
327 'Things that physicians can read and partly modify'
329 // xl('Things that physicians can read and partly modify')
330 $gacl->add_acl(
331 array(
332 'acct'=>array('disc', 'rep'),
333 'admin'=>array('drugs'),
334 'encounters'=>array('auth_a', 'auth', 'coding_a', 'coding', 'notes_a', 'notes', 'date_a', 'relaxed'),
335 'patients' => array('appt', 'demo', 'med', 'trans', 'docs', 'notes', 'sign', 'reminder', 'alert',
336 'disclosure', 'rx', 'amendment', 'lab'),
337 'sensitivities'=>array('normal', 'high'),
338 'groups'=>array('gcalendar','glog')
340 null,
341 array($doc),
342 null,
343 null,
346 'write',
347 'Things that physicians can read and modify'
349 // xl('Things that physicians can read and modify')
351 // Set permissions for clinicians.
353 $gacl->add_acl(
354 array(
355 'placeholder'=>array('filler')
357 null,
358 array($clin),
359 null,
360 null,
363 'view',
364 'Things that clinicians can only read'
366 // xl('Things that clinicians can only read')
367 $gacl->add_acl(
368 array(
369 'encounters'=>array('notes', 'relaxed'),
370 'patients'=>array('demo', 'med', 'docs', 'notes','trans', 'reminder', 'alert', 'disclosure', 'rx', 'amendment', 'lab'),
371 'sensitivities'=>array('normal')
373 null,
374 array($clin),
375 null,
376 null,
379 'addonly',
380 'Things that clinicians can read and enter but not modify'
382 // xl('Things that clinicians can read and enter but not modify')
383 $gacl->add_acl(
384 array(
385 'placeholder'=>array('filler')
387 null,
388 array($clin),
389 null,
390 null,
393 'wsome',
394 'Things that clinicians can read and partly modify'
396 // xl('Things that clinicians can read and partly modify')
397 $gacl->add_acl(
398 array(
399 'admin'=>array('drugs'),
400 'encounters'=>array('coding'),
401 'patients'=>array('appt'),
402 'groups'=>array('gcalendar','glog')
404 null,
405 array($clin),
406 null,
407 null,
410 'write',
411 'Things that clinicians can read and modify'
413 // xl('Things that clinicians can read and modify')
415 // Set permissions for front office staff.
417 $gacl->add_acl(
418 array(
419 'patients'=>array('alert')
421 null,
422 array($front),
423 null,
424 null,
427 'view',
428 'Things that front office can only read'
430 // xl('Things that front office can only read')
431 $gacl->add_acl(
432 array(
433 'placeholder'=>array('filler')
435 null,
436 array($front),
437 null,
438 null,
441 'addonly',
442 'Things that front office can read and enter but not modify'
444 // xl('Things that front office can read and enter but not modify')
445 $gacl->add_acl(
446 array(
447 'placeholder'=>array('filler')
449 null,
450 array($front),
451 null,
452 null,
455 'wsome',
456 'Things that front office can read and partly modify'
458 // xl('Things that front office can read and partly modify')
459 $gacl->add_acl(
460 array(
461 'patients'=>array('appt', 'demo', 'trans', 'notes'),
462 'groups'=>array('gcalendar')
464 null,
465 array($front),
466 null,
467 null,
470 'write',
471 'Things that front office can read and modify'
473 // xl('Things that front office can read and modify')
475 // Set permissions for back office staff.
477 $gacl->add_acl(
478 array(
479 'patients'=>array('alert')
481 null,
482 array($back),
483 null,
484 null,
487 'view',
488 'Things that back office can only read'
490 // xl('Things that back office can only read')
491 $gacl->add_acl(
492 array(
493 'placeholder'=>array('filler')
495 null,
496 array($back),
497 null,
498 null,
501 'addonly',
502 'Things that back office can read and enter but not modify'
504 // xl('Things that back office can read and enter but not modify')
505 $gacl->add_acl(
506 array(
507 'placeholder'=>array('filler')
509 null,
510 array($back),
511 null,
512 null,
515 'wsome',
516 'Things that back office can read and partly modify'
518 // xl('Things that back office can read and partly modify')
519 $gacl->add_acl(
520 array(
521 'acct'=>array('bill', 'disc', 'eob', 'rep', 'rep_a'),
522 'admin'=>array('practice', 'superbill'),
523 'encounters'=>array('auth_a', 'coding_a', 'date_a'),
524 'patients'=>array('appt', 'demo')
526 null,
527 array($back),
528 null,
529 null,
532 'write',
533 'Things that back office can read and modify'
535 // xl('Things that back office can read and modify')
537 // Set permissions for Emergency Login.
539 $gacl->add_acl(
540 array(
541 'acct'=>array('bill', 'disc', 'eob', 'rep', 'rep_a'),
542 'admin'=>array('calendar', 'database', 'forms', 'practice', 'superbill', 'users', 'batchcom', 'language', 'super', 'drugs', 'acl','multipledb','menu','manage_modules'),
543 'encounters'=>array('auth_a', 'auth', 'coding_a', 'coding', 'notes_a', 'notes', 'date_a', 'relaxed'),
544 'lists'=>array('default','state','country','language','ethrace'),
545 'patients'=>array('appt', 'demo', 'med', 'trans', 'docs', 'notes', 'sign', 'reminder', 'alert', 'disclosure', 'rx', 'amendment', 'lab', 'docs_rm'),
546 'sensitivities'=>array('normal', 'high'),
547 'nationnotes'=>array('nn_configure'),
548 'patientportal'=>array('portal'),
549 'menus'=>array('modle'),
550 'groups'=>array('gadd','gcalendar','glog','gdlog','gm')
552 null,
553 array($breakglass),
554 null,
555 null,
558 'write',
559 'Emergency Login user can do anything'
561 // xl('Emergency Login user can do anything')
564 <html>
565 <head>
566 <title>OpenEMR ACL Setup</title>
567 <link rel=STYLESHEET href="interface/themes/style_blue.css">
568 </head>
569 <body>
570 <b>OpenEMR ACL Setup</b>
571 <br>
572 All done configuring and installing access controls (php-GACL)!
573 </body>
574 </html>