3 * Office note repository.
5 * Copyright (C) 2017 Matthew Vita <matthewvita48@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 Matthew Vita <matthewvita48@gmail.com>
20 * @link http://www.open-emr.org
23 namespace repositories
;
25 use Doctrine\ORM\EntityRepository
;
27 class ONoteRepository
extends EntityRepository
{
29 * Add new office note.
31 * @param $note The new office note.
34 public function save(\entities\ONote
$note) {
35 $this->_em
->persist($note);
37 return $note->getId();
41 * @param $id The office note id.
42 * @return The single note.
44 public function findNoteById($id) {
45 $result = $this->_em
->getRepository($this->_entityName
)->findOneBy(array("id" => $id));
50 * Toggles a office note to be enabled.
52 * @param $id The office note id.
53 * @return true/false if the update was successful.
55 public function enableNoteById($id) {
59 $note = $this->findNoteById($id);
62 $note->setActivity(1);
63 $this->_em
->persist($note);
67 } catch (Exception
$e) {}
73 * Toggles a office note to be enabled.
75 * @param $id The office note id.
76 * @return true/false if the update was successful.
78 public function disableNoteById($id) {
82 $note = $this->findNoteById($id);
85 $note->setActivity(0);
86 $this->_em
->persist($note);
90 } catch (Exception
$e) {}
96 * Get office notes with filters, Sorted by DESC. Note
97 * that -1 indicates that all activity types should be
100 * @param $activity -1/0/1 to indicate filtered notes.
101 * @param $offset The start index for pagination.
102 * @param $limit The limit for pagination.
103 * @return list of office notes.
105 public function getNotes($activity, $offset, $limit) {
106 if (!is_numeric($offset) ||
!is_numeric($limit)) {
112 if ($activity == 1) {
113 $criteria["activity"] = 1;
114 } else if ($activity == 0) {
115 $criteria["activity"] = 0;
118 $result = $this->_em
->getRepository($this->_entityName
)->findBy(
120 array("date" => "DESC"),
129 * An example of how to use HQL with JOINs. Only use
130 * HQL when the methods that EntityRepository provides
131 * cannot sufficiently meet the complexity of your query.
133 public function findAllHqlExample() {
134 // $sql = "SELECT o ";
135 // $sql .= "FROM entities\\ONote o ";
136 // $sql .= "JOIN entities\\User u ";
137 // $sql .= "WITH o.user = u.username";
139 // return $this->_em->createQuery($sql)->getResult();