4 * OnsiteActivityViewController.php
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
14 * import supporting libraries
16 require_once("AppBasePortalController.php");
17 require_once("Model/OnsiteActivityView.php");
20 * OnsiteActivityViewController is the controller class for the OnsiteActivityView object.
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
29 class OnsiteActivityViewController
extends AppBasePortalController
32 * Override here for any controller-specific functionality
36 protected function Init()
40 // $this->RequirePermission(User::$PERMISSION_USER,'SecureApp.LoginForm');
44 * Displays a list view of Onsite Activity View objects
46 public function ListView()
49 if (isset($_SESSION['authUser'])) {
50 $user = $_SESSION['authUser'];
52 header("refresh:6;url= ./provider");
53 echo 'Redirecting in about 5 secs. Session shared with Onsite Portal<br /> Shared session not allowed!.';
57 $this->Assign('cuser', $user);
62 * API Method queries for OnsiteActivityView records and render as JSON
64 public function Query()
68 $criteria = new OnsiteActivityViewCriteria();
69 $status = RequestUtil
::Get('status');
70 $criteria->Status_Equals
= $status;
72 $filter = RequestUtil
::Get('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');
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
;
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()
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,
163 patient_data.postal_code,
166 patient_data.referrerID,
167 patient_data.providerID,
168 patient_data.ref_providerID,
170 patient_data.care_team_provider,
173 users.fname As ufname,
174 users.mname As umname,
175 users.lname As ulname,
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'";
192 $this->Phreezer
->DataAdapter
->Execute($sql);
193 } catch (Exception
$ex) {
194 $this->RenderExceptionJSON($ex);