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
;
18 * Default constructor.
20 public function __construct()
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']]);
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]);
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]);
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)
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]);
71 $note = sqlStatement("SELECT * FROM `onotes` ORDER BY `date` DESC LIMIT " . escape_limit($limit) . " OFFSET " . escape_limit($offset));
73 while ($row = sqlFetchArray($note)) {