forked from openemr/openemr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ONoteService.php
78 lines (71 loc) · 2.23 KB
/
ONoteService.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
/**
* ONoteService
*
* @package OpenEMR
* @link http://www.open-emr.org
* @author Matthew Vita <[email protected]>
* @copyright Copyright (c) 2017 Matthew Vita <[email protected]>
* @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
*/
namespace OpenEMR\Services;
class ONoteService
{
/**
* Default constructor.
*/
public function __construct()
{
}
/**
* Creates a new office note.
*
* @param The text of the office note.
* @return $body New id.
*/
public function add($body)
{
return sqlInsert("INSERT INTO `onotes` (`date`, `body`, `user`, `groupname`, `activity`) VALUES (NOW(), ?, ?, ?, 1)", [$body, $_SESSION["authUser"], $_SESSION['authProvider']]);
}
/**
* Toggles a office note to be enabled.
*
* @param $id The office note id.
* @return true/false if the update was successful.
*/
public function enableNoteById($id)
{
sqlStatement("UPDATE `onotes` SET `activity` = 1 WHERE `id` = ?", [$id]);
}
/**
* Toggles a office note to be disabled.
*
* @param $id The office note id.
* @return true/false if the update was successful.
*/
public function disableNoteById($id)
{
sqlStatement("UPDATE `onotes` SET `activity` = 0 WHERE `id` = ?", [$id]);
}
/**
* Get office notes with filters.
*
* @param $activity -1/0/1 to indicate filtered notes.
* @param $offset The start index for pagination.
* @param $limit The limit for pagination.
* @return array of office notes.
*/
public function getNotes($activity, $offset, $limit)
{
$notes = [];
if (($activity == 0) || ($activity == 1)) {
$note = sqlStatement("SELECT * FROM `onotes` WHERE `activity` = ? ORDER BY `date` DESC LIMIT " . escape_limit($limit) . " OFFSET " . escape_limit($offset), [$activity]);
} else {
$note = sqlStatement("SELECT * FROM `onotes` ORDER BY `date` DESC LIMIT " . escape_limit($limit) . " OFFSET " . escape_limit($offset));
}
while ($row = sqlFetchArray($note)) {
$notes[] = $row;
}
return $notes;
}
}