2 // If you have installed phpGACL (http://phpgacl.sourceforge.net/)
3 // and have configured it for your site, then uncomment the following
4 // statement and change it to point to the location where
5 // gacl.class.php is intalled.
7 // $phpgacl_location = "/var/www/gacl";
9 // Tentatively, the following Access Control Objects will be supported.
10 // These are the "things to be protected":
12 // Section "admin" (Administration):
13 // super Superuser - can delete patients, encounters, issues
14 // calendar Calendar Settings
15 // database Database Reporting
16 // forms Forms Administration
17 // practice Practice Settings
18 // superbill Superbill Codes Administration
19 // users Users/Groups/Logs Administration
20 // batchcom Batch Communication Tool
21 // language Language Interface Tool
23 // Section "acct" (Accounting):
24 // bill Billing (write optional)
26 // rep Financial Reporting - my encounters
27 // rep_a Financial Reporting - anything
29 // Section "patients" (Patient Information):
30 // appt Appointments (write optional)
31 // demo Demographics (write,addonly optional)
32 // med Medical Records and History (write,addonly optional)
33 // trans Transactions, e.g. referrals (write optional)
34 // docs Documents (write,addonly optional)
35 // notes Patient Notes (write,addonly optional)
37 // Section "encounters" (Encounter Information):
38 // auth Authorize - my encounters
39 // auth_a Authorize - any encounters
40 // coding Coding - my encounters (write,wsome optional)
41 // coding_a Coding - any encounters (write,wsome optional)
42 // notes Notes - my encounters (write,addonly optional)
43 // notes_a Notes - any encounters (write,addonly optional)
44 // date_a Fix encounter dates - any encounters
45 // relaxed Less-private information (write,addonly optional)
46 // (e.g. the Sports Fitness encounter form)
48 // Section "squads" applies to sports team use only:
49 // acos in this section define the user-specified list of squads
51 if (isset ($phpgacl_location)) {
52 include_once("$phpgacl_location/gacl.class.php");
53 $gacl_object = new gacl();
56 // acl_check should return 0 if access is denied. Otherwise it may
57 // return anything that evaluates to true. In addition if any of the
58 // following types of access are applicable, then the corresponding value
59 // must be returned if and only if such access is granted (ony one may
62 // * write - the user may add or modify the ACO
63 // * wsome - the user has limited add/modify access to the ACO
64 // * addonly - the user may view and add but not modify entries
66 function acl_check($section, $value, $user = '') {
67 global $gacl_object, $phpgacl_location;
68 if (! $user) $user = $_SESSION['authUser'];
70 if ($phpgacl_location) {
71 return $gacl_object->acl_check($section, $value, 'users', $user);
74 // If no phpgacl, then apply the old static rules whereby "authorized"
75 // users (providers) can do anything, and other users can do most things.
76 // If you want custom access control but don't want to mess with phpGACL,
77 // then you could customize the code below instead.
79 if ($section == 'admin' && $value == 'super') return 0;
81 if ($_SESSION['userauthorized']) return 'write';
83 if ($section == 'patients') {
84 if ($value == 'med') return 1;
87 else if ($section == 'encounters') {
88 if (strpos($value, 'coding' ) === 0) return 'write';
89 if (strpos($value, 'notes' ) === 0) return 'write';
90 if ($value == 'relaxed') return 'write';
92 else if ($section != 'admin') {
99 // Get the ACO name/value pairs for a designated section. Each value
100 // is an array (section_value, value, order_value, name, hidden).
102 function acl_get_section_acos($section) {
103 global $phpgacl_location;
104 if ($phpgacl_location) {
105 include_once("$phpgacl_location/gacl_api.class.php");
106 $gacl = new gacl_api();
107 $arr1 = $gacl->get_objects($section, 1, 'ACO');
109 foreach ($arr1[$section] as $value) {
110 $odata = $gacl->get_object_data($gacl->get_object_id($section, $value, 'ACO'), 'ACO');
111 $arr[$value] = $odata[0];
118 // Return an array keyed on squad ACO names.
119 // This is only applicable for sports team use.
121 function acl_get_squads() {
122 return acl_get_section_acos('squads');
125 // Return an array keyed on encounter sensitivity level ACO names.
126 // Sensitivities are useful when some encounter notes are not
127 // medically sensitive (e.g. a physical fitness test), and/or if
128 // some will be "for doctor's eyes only" (e.g. STD treatment).
130 // When a non-blank sensitivity value exists in the new encounter
131 // form, it names an additional ACO required for access to all forms
132 // in the encounter. If you want some encounters to be non-sensitive,
133 // then you also need some default nonblank sensitivity for normal
134 // encounters, as well as greater encounter notes permissions for
135 // those allowed to view non-sensitive encounters.
137 function acl_get_sensitivities() {
138 return acl_get_section_acos('sensitivities');