Highway to PSR2
[openemr.git] / portal / patient / libs / Reporter / OnsiteActivityViewReporter-query.php
blobb2a858f4dd0bba63b9ad907fa1c41607ff10b816
1 <?php
2 /** @package Openemr::Reporter */
4 /**
6 * Copyright (C) 2016-2017 Jerry Padgett <sjpadgett@gmail.com>
8 * LICENSE: This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU Affero General Public License as
10 * published by the Free Software Foundation, either version 3 of the
11 * License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Affero General Public License for more details.
18 * You should have received a copy of the GNU Affero General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 * @package OpenEMR
22 * @author Jerry Padgett <sjpadgett@gmail.com>
23 * @link http://www.open-emr.org
26 /**
27 * import supporting libraries
29 require_once("verysimple/Phreeze/Reporter.php");
31 /**
32 * This is an example Reporter based on the OnsiteActivityView object.
33 * The reporter object
34 * allows you to run arbitrary queries that return data which may or may not fith within
35 * the data access API. This can include aggregate data or subsets of data.
37 * Note that Reporters are read-only and cannot be used for saving data.
39 * @package Openemr::Model::DAO
40 * @author ClassBuilder
41 * @version 1.0
43 class OnsiteActivityViewReporter extends Reporter
46 // the properties in this class must match the columns returned by GetCustomQuery().
47 // 'CustomFieldExample' is an example that is not part of the `onsite_activity_view` table
48 public $Id;
49 public $Date;
50 public $PatientId;
51 public $Activity;
52 public $RequireAudit;
53 public $PendingAction;
54 public $ActionTaken;
55 public $Status;
56 public $Narrative;
57 public $TableAction;
58 public $TableArgs;
59 public $ActionUser;
60 public $ActionTakenTime;
61 public $Checksum;
62 public $Title;
63 public $Fname;
64 public $Lname;
65 public $Mname;
66 public $Dob;
67 public $Ss;
68 public $Street;
69 public $PostalCode;
70 public $City;
71 public $State;
72 public $Referrerid;
73 public $Providerid;
74 public $RefProviderid;
75 public $Pubpid;
76 public $CareTeam;
77 public $Username;
78 public $Authorized;
79 public $Ufname;
80 public $Umname;
81 public $Ulname;
82 public $Facility;
83 public $Active;
84 public $Utitle;
85 public $PhysicianType;
88 * GetCustomQuery returns a fully formed SQL statement. The result columns
89 * must match with the properties of this reporter object.
91 * @see Reporter::GetCustomQuery
92 * @param Criteria $criteria
93 * @return string SQL statement
95 static function GetCustomQuery($criteria)
97 $sql = "select
98 `onsite_portal_activity`.`id` as Id
99 ,`onsite_portal_activity`.`date` as Date
100 ,`onsite_portal_activity`.`patient_id` as PatientId
101 ,`onsite_portal_activity`.`activity` as Activity
102 ,`onsite_portal_activity`.`require_audit` as RequireAudit
103 ,`onsite_portal_activity`.`pending_action` as PendingAction
104 ,`onsite_portal_activity`.`action_taken` as ActionTaken
105 ,`onsite_portal_activity`.`status` as Status
106 ,`onsite_portal_activity`.`narrative` as Narrative
107 ,`onsite_portal_activity`.`table_action` as TableAction
108 ,`onsite_portal_activity`.`table_args` as TableArgs
109 ,`onsite_portal_activity`.`action_user` as ActionUser
110 ,`onsite_portal_activity`.`action_taken_time` as ActionTakenTime
111 ,`onsite_portal_activity`.`checksum` as Checksum
112 ,` patient_data`.`title` as Title
113 ,` patient_data`.`fname` as Fname
114 ,` patient_data`.`lname` as Lname
115 ,` patient_data`.`mname` as Mname
116 ,` patient_data`.`DOB` as Dob
117 ,` patient_data`.`ss` as Ss
118 ,` patient_data`.`street` as Street
119 ,` patient_data`.`postal_code` as PostalCode
120 ,` patient_data`.`city` as City
121 ,` patient_data`.`state` as State
122 ,` patient_data`.`referrerID` as Referrerid
123 ,` patient_data`.`providerID` as Providerid
124 ,` patient_data`.`ref_providerID` as RefProviderid
125 ,` patient_data`.`pubpid` as Pubpid
126 ,` patient_data`.`care_team` as CareTeam
127 ,`users`.`username` as Username
128 ,`users`.`authorized` as Authorized
129 ,`users`.`ufname` as Ufname
130 ,`users`.`umname` as Umname
131 ,`users`.`ulname` as Ulname
132 ,`users`.`facility` as Facility
133 ,`users`.`active` as Active
134 ,`users`.`utitle` as Utitle
135 ,`users`.`physician_type` as PhysicianType ";
136 $sql .= "From onsite_portal_activity Left Join
137 patient_data On onsite_portal_activity.patient_id = patient_data.pid Left Join
138 users On patient_data.providerID = users.id ";
140 // the criteria can be used or you can write your own custom logic.
141 // be sure to escape any user input with $criteria->Escape()
142 $sql .= $criteria->GetWhere();
143 $sql .= $criteria->GetOrder();
145 return $sql;
149 * GetCustomCountQuery returns a fully formed SQL statement that will count
150 * the results. This query must return the correct number of results that
151 * GetCustomQuery would, given the same criteria
153 * @see Reporter::GetCustomCountQuery
154 * @param Criteria $criteria
155 * @return string SQL statement
157 static function GetCustomCountQuery($criteria)
159 $sql = "select count(1) as counter from `onsite_activity_view`";
161 // the criteria can be used or you can write your own custom logic.
162 // be sure to escape any user input with $criteria->Escape()
163 $sql .= $criteria->GetWhere();
165 return $sql;