psr12 fixes for new PHP_CodeSniffer (#4795)
[openemr.git] / portal / patient / libs / Controller / OnsiteActivityViewController.php
blobe451d7af4298433dad27a9b93dd3925e2dac2808
1 <?php
3 /**
4 * OnsiteActivityViewController.php
6 * @package OpenEMR
7 * @link https://www.open-emr.org
8 * @author Jerry Padgett <sjpadgett@gmail.com>
9 * @copyright Copyright (c) 2016-2017 Jerry Padgett <sjpadgett@gmail.com>
10 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
13 /**
14 * import supporting libraries
16 require_once("AppBasePortalController.php");
17 require_once("Model/OnsiteActivityView.php");
19 /**
20 * OnsiteActivityViewController is the controller class for the OnsiteActivityView object.
21 * The
22 * controller is responsible for processing input from the user, reading/updating
23 * the model as necessary and displaying the appropriate view.
25 * @package Patient Portal::Controller
26 * @author ClassBuilder
27 * @version 1.0
29 class OnsiteActivityViewController extends AppBasePortalController
31 /**
32 * Override here for any controller-specific functionality
34 * @inheritdocs
36 protected function Init()
38 parent::Init();
40 // $this->RequirePermission(User::$PERMISSION_USER,'SecureApp.LoginForm');
43 /**
44 * Displays a list view of Onsite Activity View objects
46 public function ListView()
48 $user = 0;
49 if (isset($_SESSION['authUser'])) {
50 $user = $_SESSION['authUser'];
51 } else {
52 header("refresh:6;url= ./provider");
53 echo 'Redirecting in about 5 secs. Session shared with Onsite Portal<br /> Shared session not allowed!.';
54 exit();
57 $this->Assign('cuser', $user);
58 $this->Render();
61 /**
62 * API Method queries for OnsiteActivityView records and render as JSON
64 public function Query()
66 self::CreateView('');
67 try {
68 $criteria = new OnsiteActivityViewCriteria();
69 $status = RequestUtil::Get('status');
70 $criteria->Status_Equals = $status;
72 $filter = RequestUtil::Get('filter');
73 if ($filter) {
74 $criteria->AddFilter(new CriteriaFilter('Id,Date,PatientId,Activity,RequireAudit,PendingAction,ActionTaken,Status,Narrative,TableAction,TableArgs,ActionUser,ActionTakenTime,Checksum,Title,Fname,Lname,Mname,Dob,Ss,Street,PostalCode,City,State,Referrerid,Providerid,RefProviderid,Pubpid,CareTeam,Username,Authorized,Ufname,Umname,Ulname,Facility,Active,Utitle,PhysicianType', '%' . $filter . '%'));
77 // TODO: this is generic query filtering based only on criteria properties
78 foreach (array_keys($_REQUEST) as $prop) {
79 $prop_normal = ucfirst($prop);
80 $prop_equals = $prop_normal . '_Equals';
82 if (property_exists($criteria, $prop_normal)) {
83 $criteria->$prop_normal = RequestUtil::Get($prop);
84 } elseif (property_exists($criteria, $prop_equals)) {
85 // this is a convenience so that the _Equals suffix is not needed
86 $criteria->$prop_equals = RequestUtil::Get($prop);
90 $output = new stdClass();
92 // if a sort order was specified then specify in the criteria
93 $output->orderBy = RequestUtil::Get('orderBy');
94 $output->orderDesc = RequestUtil::Get('orderDesc') != '';
95 if ($output->orderBy) {
96 $criteria->SetOrder($output->orderBy, $output->orderDesc);
99 $page = RequestUtil::Get('page');
101 if ($page != '') {
102 // if page is specified, use this instead (at the expense of one extra count query)
103 $pagesize = $this->GetDefaultPageSize();
105 $onsiteactivityviews = $this->Phreezer->Query('OnsiteActivityViewReporter', $criteria)->GetDataPage($page, $pagesize);
106 $output->rows = $onsiteactivityviews->ToObjectArray(true, $this->SimpleObjectParams());
107 $output->totalResults = $onsiteactivityviews->TotalResults;
108 $output->totalPages = $onsiteactivityviews->TotalPages;
109 $output->pageSize = $onsiteactivityviews->PageSize;
110 $output->currentPage = $onsiteactivityviews->CurrentPage;
111 } else {
112 // return all results
113 $onsiteactivityviews = $this->Phreezer->Query('OnsiteActivityViewReporter', $criteria);
114 $output->rows = $onsiteactivityviews->ToObjectArray(true, $this->SimpleObjectParams());
115 $output->totalResults = count($output->rows);
116 $output->totalPages = 1;
117 $output->pageSize = $output->totalResults;
118 $output->currentPage = 1;
121 $this->RenderJSON($output, $this->JSONPCallback());
122 } catch (Exception $ex) {
123 $this->RenderExceptionJSON($ex);
128 * API Method retrieves a single OnsiteActivityView record and render as JSON
130 public function Read()
132 try {
133 $pk = $this->GetRouter()->GetUrlParam('id');
134 $onsiteactivityview = $this->Phreezer->Get('OnsiteActivityView', $pk);
135 $this->RenderJSON($onsiteactivityview, $this->JSONPCallback(), true, $this->SimpleObjectParams());
136 } catch (Exception $ex) {
137 $this->RenderExceptionJSON($ex);
142 * Used for dashboard audit views.
144 * @param $viewcriteria
146 public function CreateView($viewcriteria)
148 $sql = "CREATE OR REPLACE VIEW onsite_activity_view As Select
149 onsite_portal_activity.status,
150 onsite_portal_activity.narrative,
151 onsite_portal_activity.table_action,
152 onsite_portal_activity.table_args,
153 onsite_portal_activity.action_user,
154 onsite_portal_activity.action_taken_time,
155 onsite_portal_activity.checksum,
156 patient_data.title,
157 patient_data.fname,
158 patient_data.lname,
159 patient_data.mname,
160 patient_data.DOB,
161 patient_data.ss,
162 patient_data.street,
163 patient_data.postal_code,
164 patient_data.city,
165 patient_data.state,
166 patient_data.referrerID,
167 patient_data.providerID,
168 patient_data.ref_providerID,
169 patient_data.pubpid,
170 patient_data.care_team_provider,
171 users.username,
172 users.authorized,
173 users.fname As ufname,
174 users.mname As umname,
175 users.lname As ulname,
176 users.facility,
177 users.active,
178 users.title As utitle,
179 users.physician_type,
180 onsite_portal_activity.date,
181 onsite_portal_activity.require_audit,
182 onsite_portal_activity.pending_action,
183 onsite_portal_activity.action_taken,
184 onsite_portal_activity.id,
185 onsite_portal_activity.activity,
186 onsite_portal_activity.patient_id ";
187 $sql .= "From onsite_portal_activity Left Join
188 patient_data On onsite_portal_activity.patient_id = patient_data.pid Left Join
189 users On patient_data.providerID = users.id ";
190 // $sql .= "Where onsite_portal_activity.status = 'waiting'";
191 try {
192 $this->Phreezer->DataAdapter->Execute($sql);
193 } catch (Exception $ex) {
194 $this->RenderExceptionJSON($ex);