Highway to PSR2
[openemr.git] / portal / patient / libs / Reporter / OnsiteActivityViewReporter.php
blobc30add0fa597347f3762527a78608c21c1644a38
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 fit 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)
98 $sql = "select
99 `onsite_activity_view`.`id` as Id
100 ,`onsite_activity_view`.`date` as Date
101 ,`onsite_activity_view`.`patient_id` as PatientId
102 ,`onsite_activity_view`.`activity` as Activity
103 ,`onsite_activity_view`.`require_audit` as RequireAudit
104 ,`onsite_activity_view`.`pending_action` as PendingAction
105 ,`onsite_activity_view`.`action_taken` as ActionTaken
106 ,`onsite_activity_view`.`status` as Status
107 ,`onsite_activity_view`.`narrative` as Narrative
108 ,`onsite_activity_view`.`table_action` as TableAction
109 ,`onsite_activity_view`.`table_args` as TableArgs
110 ,`onsite_activity_view`.`action_user` as ActionUser
111 ,`onsite_activity_view`.`action_taken_time` as ActionTakenTime
112 ,`onsite_activity_view`.`checksum` as Checksum
113 ,`onsite_activity_view`.`title` as Title
114 ,`onsite_activity_view`.`fname` as Fname
115 ,`onsite_activity_view`.`lname` as Lname
116 ,`onsite_activity_view`.`mname` as Mname
117 ,`onsite_activity_view`.`DOB` as Dob
118 ,`onsite_activity_view`.`ss` as Ss
119 ,`onsite_activity_view`.`street` as Street
120 ,`onsite_activity_view`.`postal_code` as PostalCode
121 ,`onsite_activity_view`.`city` as City
122 ,`onsite_activity_view`.`state` as State
123 ,`onsite_activity_view`.`referrerID` as Referrerid
124 ,`onsite_activity_view`.`providerID` as Providerid
125 ,`onsite_activity_view`.`ref_providerID` as RefProviderid
126 ,`onsite_activity_view`.`pubpid` as Pubpid
127 ,`onsite_activity_view`.`care_team` as CareTeam
128 ,`onsite_activity_view`.`username` as Username
129 ,`onsite_activity_view`.`authorized` as Authorized
130 ,`onsite_activity_view`.`ufname` as Ufname
131 ,`onsite_activity_view`.`umname` as Umname
132 ,`onsite_activity_view`.`ulname` as Ulname
133 ,`onsite_activity_view`.`facility` as Facility
134 ,`onsite_activity_view`.`active` as Active
135 ,`onsite_activity_view`.`utitle` as Utitle
136 ,`onsite_activity_view`.`physician_type` as PhysicianType
137 from `onsite_activity_view`";
139 // the criteria can be used or you can write your own custom logic.
140 // be sure to escape any user input with $criteria->Escape()
141 $sql .= $criteria->GetWhere();
142 $sql .= $criteria->GetOrder();
144 return $sql;
148 * GetCustomCountQuery returns a fully formed SQL statement that will count
149 * the results. This query must return the correct number of results that
150 * GetCustomQuery would, given the same criteria
152 * @see Reporter::GetCustomCountQuery
153 * @param Criteria $criteria
154 * @return string SQL statement
156 static function GetCustomCountQuery($criteria)
158 $sql = "select count(1) as counter from `onsite_activity_view`";
160 // the criteria can be used or you can write your own custom logic.
161 // be sure to escape any user input with $criteria->Escape()
162 $sql .= $criteria->GetWhere();
164 return $sql;