5 * Copyright (C) 2017 Victor Kofia <victor.kofia@gmail.com>
7 * LICENSE: This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
19 * @author Victor Kofia <victor.kofia@gmail.com>
20 * @link http://www.open-emr.org
23 namespace OpenEMR\Services
;
29 * In the case where a patient doesn't have a picture uploaded,
30 * this value will be returned so that the document controller
31 * can return an empty response.
33 private $patient_picture_fallback_id = -1;
38 * Default constructor.
40 public function __construct()
44 public function setPid($pid)
49 public function getPid()
55 * TODO: This should go in the ChartTrackerService and doesn't have to be static.
56 * @param $pid unique patient id
59 public static function getChartTrackerInformationActivity($pid)
61 $sql = "SELECT ct.ct_when,
68 FROM chart_tracker AS ct
69 LEFT OUTER JOIN users AS u ON u.id = ct.ct_userid
71 ORDER BY ct.ct_when DESC";
72 return sqlStatement($sql, array($pid));
76 * TODO: This should go in the ChartTrackerService and doesn't have to be static.
79 public static function getChartTrackerInformation()
81 $sql = "SELECT ct.ct_when,
90 FROM chart_tracker AS ct
91 JOIN cttemp ON cttemp.ct_pid = ct.ct_pid AND cttemp.ct_when = ct.ct_when
92 LEFT OUTER JOIN users AS u ON u.id = ct.ct_userid
93 LEFT OUTER JOIN patient_data AS p ON p.pid = ct.ct_pid
94 WHERE ct.ct_userid != 0
96 return sqlStatement($sql);
102 public function getPatientPictureDocumentId()
104 $sql = "SELECT doc.id AS id
106 JOIN categories_to_documents cate_to_doc
107 ON doc.id = cate_to_doc.document_id
109 ON cate.id = cate_to_doc.category_id
110 WHERE cate.name LIKE ? and doc.foreign_id = ?";
112 $result = sqlQuery($sql, array($GLOBALS['patient_photo_category_name'], $this->pid
));
114 if (empty($result) ||
empty($result['id'])) {
115 return $this->patient_picture_fallback_id
;
118 return $result['id'];