Fixes for restoreSession logic. (#4378)
[openemr.git] / library / group.inc
blob809840039a0768fd2e524270bd3e485ef89efcd2
1 <?php
3 /**
4  * interface/therapy_groups/index.php routing for therapy groups
5  *
6  * group.inc includes methods for groups
7  *
8  * Copyright (C) 2016 Shachar Zilbershlag <shaharzi@matrix.co.il>
9  * Copyright (C) 2016 Amiel Elboim <amielel@matrix.co.il>
10  *
11  * LICENSE: This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version 3
14  * of the License, or (at your option) any later version.
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
21  *
22  * @package OpenEMR
23  * @author  Shachar Zilbershlag <shaharzi@matrix.co.il>
24  * @author  Amiel Elboim <amielel@matrix.co.il>
25  * @link    http://www.open-emr.org
26  */
28 require_once(dirname(__FILE__) . "/sql.inc");
29 require_once(dirname(__FILE__) . "/../interface/therapy_groups/therapy_groups_models/therapy_groups_model.php");
30 require_once(dirname(__FILE__) . "/../interface/therapy_groups/therapy_groups_models/group_statuses_model.php");
31 require_once(dirname(__FILE__) . "/../interface/therapy_groups/therapy_groups_models/therapy_groups_counselors_model.php");
32 require_once(dirname(__FILE__) . "/../interface/therapy_groups/therapy_groups_models/users_model.php");
33 require_once(dirname(__FILE__) . "/../interface/therapy_groups/therapy_groups_models/therapy_groups_participants_model.php");
34 require_once(dirname(__FILE__) . "/../interface/therapy_groups/therapy_groups_controllers/therapy_groups_controller.php");
36 use OpenEMR\Common\Session\SessionUtil;
38 //Fetches groups data by given search parameter (used in popup search when in add_edit_event for groups)
39 function getGroup($gid)
41     $model = new Therapy_Groups();
42     $result = $model->getGroup($gid);
43     return $result;
46 //Fetches groups data by given search parameter (used in popup search when in add_edit_event for groups)
47 function getGroupData($search_params, $result_columns, $column)
49     $model = new Therapy_Groups();
50     $result = $model->getGroupData($search_params, $result_columns, $column);
51     return $result;
54 //Fetches group statuses from 'groupstat' list
55 function getGroupStatuses()
57     $model = new Group_Statuses();
58     $result = $model->getGroupStatuses();
59     return $result;
62 //Fetches group attendance statuses from 'attendstat' list
63 function getGroupAttendanceStatuses()
65     $model = new Group_Statuses();
66     $result = $model->getGroupAttendanceStatuses();
67     return $result;
70 //Fetches counselors for specific group
71 function getCounselors($gid)
73     $model = new Therapy_Groups_Counselors();
74     $result = $model->getCounselors($gid);
75     return $result;
78 //Fetches participants of group
79 function getParticipants($gid, $onlyActive = false)
81     $model = new Therapy_groups_participants();
82     $result = $model->getParticipants($gid, $onlyActive);
83     return $result;
86 //Fetches group status name by status key
87 function getTypeName($key)
89     $types_array = TherapyGroupsController::prepareGroupTypesList();
90     $types_name = $types_array[$key];
91     return $types_name;
94 //Fetches providers for a specific group event
95 function getProvidersOfEvent($eid)
97     $model = new Users();
98     $result = $model->getProvidersOfEvent($eid);
99     return $result;
102 //Fetches name of user by his id
103 function getUserNameById($uid)
105     $model = new Users();
106     $result = $model->getUserNameById($uid);
107     return $result;
110 function getGroupCounselorsNames($gid)
113     $model = new Therapy_Groups_Counselors();
114     $result = $model->getAllCounselorsNames($gid);
115     return $result;
118 function unsetGroup()
120     SessionUtil::unsetSession('therapy_group');