Merge pull request #828 from bradymiller/php-min-5_6
[openemr.git] / services / ChartTrackerService.php
blob8160618bf4d7e2bd261b5a54082d4df97a91822f
1 <?php
2 /**
3 * Chart tracker service.
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>;.
18 * @package OpenEMR
19 * @author Victor Kofia <victor.kofia@gmail.com>
20 * @link http://www.open-emr.org
23 namespace services;
25 class ChartTrackerService {
27 /**
28 * Logger used primarily for logging events that are of interest to
29 * developers.
31 private $logger;
33 /**
34 * The chart tracker repository to be used for db CRUD operations.
36 private $repository;
38 /**
39 * Default constructor.
41 public function __construct() {
42 $this->logger = new \common\logging\Logger("\services\ChartTrackerService");
43 $database = \common\database\Connector::Instance();
44 $entityManager = $database->entityManager;
45 $this->repository = $entityManager->getRepository('\entities\ChartTracker');
48 /**
49 * Add chart tracker table entry.
51 * @param array (pid, date, userid, location).
52 * @return the pid.
54 public function trackPatientLocation($patientLocation) {
55 $patientLocation->setPid(add_escape_custom($patientLocation->getPid()));
56 $patientLocation->setUserId(add_escape_custom($patientLocation->getUserId()));
57 $patientLocation->setLocation(add_escape_custom($patientLocation->getLocation()));
58 $this->logger->debug('Attempting to track patient location');
59 $this->repository->save($patientLocation);