Highway to PSR2
[openemr.git] / portal / patient / libs / Reporter / OnsitePortalActivityReporter.php
blob6b4e7217cdfbb8208e303b167e3492bf59147420
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 /** import supporting libraries */
27 require_once("verysimple/Phreeze/Reporter.php");
29 /**
30 * This is an example Reporter based on the OnsitePortalActivity object. The reporter object
31 * allows you to run arbitrary queries that return data which may or may not fith within
32 * the data access API. This can include aggregate data or subsets of data.
34 * Note that Reporters are read-only and cannot be used for saving data.
36 * @package Openemr::Model::DAO
37 * @author ClassBuilder
38 * @version 1.0
40 class OnsitePortalActivityReporter extends Reporter
43 // the properties in this class must match the columns returned by GetCustomQuery().
44 // 'CustomFieldExample' is an example that is not part of the `onsite_portal_activity` table
45 public $CustomFieldExample;
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;
63 * GetCustomQuery returns a fully formed SQL statement. The result columns
64 * must match with the properties of this reporter object.
66 * @see Reporter::GetCustomQuery
67 * @param Criteria $criteria
68 * @return string SQL statement
70 static function GetCustomQuery($criteria)
72 $sql = "select
73 'custom value here...' as CustomFieldExample
74 ,`onsite_portal_activity`.`id` as Id
75 ,`onsite_portal_activity`.`date` as Date
76 ,`onsite_portal_activity`.`patient_id` as PatientId
77 ,`onsite_portal_activity`.`activity` as Activity
78 ,`onsite_portal_activity`.`require_audit` as RequireAudit
79 ,`onsite_portal_activity`.`pending_action` as PendingAction
80 ,`onsite_portal_activity`.`action_taken` as ActionTaken
81 ,`onsite_portal_activity`.`status` as Status
82 ,`onsite_portal_activity`.`narrative` as Narrative
83 ,`onsite_portal_activity`.`table_action` as TableAction
84 ,`onsite_portal_activity`.`table_args` as TableArgs
85 ,`onsite_portal_activity`.`action_user` as ActionUser
86 ,`onsite_portal_activity`.`action_taken_time` as ActionTakenTime
87 ,`onsite_portal_activity`.`checksum` as Checksum
88 from `onsite_portal_activity`";
90 // the criteria can be used or you can write your own custom logic.
91 // be sure to escape any user input with $criteria->Escape()
92 $sql .= $criteria->GetWhere();
93 $sql .= $criteria->GetOrder();
95 return $sql;
99 * GetCustomCountQuery returns a fully formed SQL statement that will count
100 * the results. This query must return the correct number of results that
101 * GetCustomQuery would, given the same criteria
103 * @see Reporter::GetCustomCountQuery
104 * @param Criteria $criteria
105 * @return string SQL statement
107 static function GetCustomCountQuery($criteria)
109 $sql = "select count(1) as counter from `onsite_portal_activity`";
111 // the criteria can be used or you can write your own custom logic.
112 // be sure to escape any user input with $criteria->Escape()
113 $sql .= $criteria->GetWhere();
115 return $sql;