New onsite patient portal, take 4.
[openemr.git] / portal / patient / libs / Reporter / OnsiteActivityViewReporter-query.php
blobb98735b4b035d85fd451a4e4b74721b9731e70f0
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{
45 // the properties in this class must match the columns returned by GetCustomQuery().
46 // 'CustomFieldExample' is an example that is not part of the `onsite_activity_view` table
47 public $Id;
48 public $Date;
49 public $PatientId;
50 public $Activity;
51 public $RequireAudit;
52 public $PendingAction;
53 public $ActionTaken;
54 public $Status;
55 public $Narrative;
56 public $TableAction;
57 public $TableArgs;
58 public $ActionUser;
59 public $ActionTakenTime;
60 public $Checksum;
61 public $Title;
62 public $Fname;
63 public $Lname;
64 public $Mname;
65 public $Dob;
66 public $Ss;
67 public $Street;
68 public $PostalCode;
69 public $City;
70 public $State;
71 public $Referrerid;
72 public $Providerid;
73 public $RefProviderid;
74 public $Pubpid;
75 public $CareTeam;
76 public $Username;
77 public $Authorized;
78 public $Ufname;
79 public $Umname;
80 public $Ulname;
81 public $Facility;
82 public $Active;
83 public $Utitle;
84 public $PhysicianType;
87 * GetCustomQuery returns a fully formed SQL statement. The result columns
88 * must match with the properties of this reporter object.
90 * @see Reporter::GetCustomQuery
91 * @param Criteria $criteria
92 * @return string SQL statement
94 static function GetCustomQuery( $criteria ){
95 $sql = "select
96 `onsite_portal_activity`.`id` as Id
97 ,`onsite_portal_activity`.`date` as Date
98 ,`onsite_portal_activity`.`patient_id` as PatientId
99 ,`onsite_portal_activity`.`activity` as Activity
100 ,`onsite_portal_activity`.`require_audit` as RequireAudit
101 ,`onsite_portal_activity`.`pending_action` as PendingAction
102 ,`onsite_portal_activity`.`action_taken` as ActionTaken
103 ,`onsite_portal_activity`.`status` as Status
104 ,`onsite_portal_activity`.`narrative` as Narrative
105 ,`onsite_portal_activity`.`table_action` as TableAction
106 ,`onsite_portal_activity`.`table_args` as TableArgs
107 ,`onsite_portal_activity`.`action_user` as ActionUser
108 ,`onsite_portal_activity`.`action_taken_time` as ActionTakenTime
109 ,`onsite_portal_activity`.`checksum` as Checksum
110 ,` patient_data`.`title` as Title
111 ,` patient_data`.`fname` as Fname
112 ,` patient_data`.`lname` as Lname
113 ,` patient_data`.`mname` as Mname
114 ,` patient_data`.`DOB` as Dob
115 ,` patient_data`.`ss` as Ss
116 ,` patient_data`.`street` as Street
117 ,` patient_data`.`postal_code` as PostalCode
118 ,` patient_data`.`city` as City
119 ,` patient_data`.`state` as State
120 ,` patient_data`.`referrerID` as Referrerid
121 ,` patient_data`.`providerID` as Providerid
122 ,` patient_data`.`ref_providerID` as RefProviderid
123 ,` patient_data`.`pubpid` as Pubpid
124 ,` patient_data`.`care_team` as CareTeam
125 ,`users`.`username` as Username
126 ,`users`.`authorized` as Authorized
127 ,`users`.`ufname` as Ufname
128 ,`users`.`umname` as Umname
129 ,`users`.`ulname` as Ulname
130 ,`users`.`facility` as Facility
131 ,`users`.`active` as Active
132 ,`users`.`utitle` as Utitle
133 ,`users`.`physician_type` as PhysicianType ";
134 $sql .= "From onsite_portal_activity Left Join
135 patient_data On onsite_portal_activity.patient_id = patient_data.pid Left Join
136 users On patient_data.providerID = users.id ";
138 // the criteria can be used or you can write your own custom logic.
139 // be sure to escape any user input with $criteria->Escape()
140 $sql .= $criteria->GetWhere();
141 $sql .= $criteria->GetOrder();
143 return $sql;
147 * GetCustomCountQuery returns a fully formed SQL statement that will count
148 * the results. This query must return the correct number of results that
149 * GetCustomQuery would, given the same criteria
151 * @see Reporter::GetCustomCountQuery
152 * @param Criteria $criteria
153 * @return string SQL statement
155 static function GetCustomCountQuery( $criteria ){
156 $sql = "select count(1) as counter from `onsite_activity_view`";
158 // the criteria can be used or you can write your own custom logic.
159 // be sure to escape any user input with $criteria->Escape()
160 $sql .= $criteria->GetWhere();
162 return $sql;