updates to make oauth2/api compatible with php8 (#4069)
[openemr.git] / src / Services / ONoteService.php
blob0c6ba633942e7577747ab963ebc9fbd2717cbd8b
1 <?php
3 /**
4 * ONoteService
6 * @package OpenEMR
7 * @link http://www.open-emr.org
8 * @author Matthew Vita <matthewvita48@gmail.com>
9 * @copyright Copyright (c) 2017 Matthew Vita <matthewvita48@gmail.com>
10 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
13 namespace OpenEMR\Services;
15 class ONoteService
17 /**
18 * Default constructor.
20 public function __construct()
24 /**
25 * Creates a new office note.
27 * @param The text of the office note.
28 * @return $body New id.
30 public function add($body)
32 return sqlInsert("INSERT INTO `onotes` (`date`, `body`, `user`, `groupname`, `activity`) VALUES (NOW(), ?, ?, ?, 1)", [$body, $_SESSION["authUser"], $_SESSION['authProvider']]);
35 /**
36 * Toggles a office note to be enabled.
38 * @param $id The office note id.
39 * @return true/false if the update was successful.
41 public function enableNoteById($id)
43 sqlStatement("UPDATE `onotes` SET `activity` = 1 WHERE `id` = ?", [$id]);
46 /**
47 * Toggles a office note to be disabled.
49 * @param $id The office note id.
50 * @return true/false if the update was successful.
52 public function disableNoteById($id)
54 sqlStatement("UPDATE `onotes` SET `activity` = 0 WHERE `id` = ?", [$id]);
57 /**
58 * Get office notes with filters.
60 * @param $activity -1/0/1 to indicate filtered notes.
61 * @param $offset The start index for pagination.
62 * @param $limit The limit for pagination.
63 * @return array of office notes.
65 public function getNotes($activity, $offset, $limit)
67 $notes = [];
68 if (($activity == 0) || ($activity == 1)) {
69 $note = sqlStatement("SELECT * FROM `onotes` WHERE `activity` = ? ORDER BY `date` DESC LIMIT " . escape_limit($limit) . " OFFSET " . escape_limit($offset), [$activity]);
70 } else {
71 $note = sqlStatement("SELECT * FROM `onotes` ORDER BY `date` DESC LIMIT " . escape_limit($limit) . " OFFSET " . escape_limit($offset));
73 while ($row = sqlFetchArray($note)) {
74 $notes[] = $row;
76 return $notes;