Setup script bootstrapped with new theme selector - Take 2 (#2139)
[openemr.git] / rest_controllers / AppointmentRestController.php
blob0b25cb05a59bb03b841800a0481689585a74b456
1 <?php
2 /**
3 * AppointmentRestController
5 * @package OpenEMR
6 * @link http://www.open-emr.org
7 * @author Matthew Vita <matthewvita48@gmail.com>
8 * @copyright Copyright (c) 2018 Matthew Vita <matthewvita48@gmail.com>
9 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
13 namespace OpenEMR\RestControllers;
15 use OpenEMR\Services\AppointmentService;
16 use OpenEMR\RestControllers\RestControllerHelper;
18 class AppointmentRestController
20 private $appointmentService;
22 public function __construct()
24 $this->appointmentService = new AppointmentService();
27 public function getOne($eid)
29 $serviceResult = $this->appointmentService->getAppointment($eid);
30 return RestControllerHelper::responseHandler($serviceResult, null, 200);
33 public function getAll()
35 $serviceResult = $this->appointmentService->getAppointmentsForPatient(null);
36 return RestControllerHelper::responseHandler($serviceResult, null, 200);
39 public function getAllForPatient($pid)
41 $serviceResult = $this->appointmentService->getAppointmentsForPatient($pid);
42 return RestControllerHelper::responseHandler($serviceResult, null, 200);
45 public function post($pid, $data)
47 $validationResult = $this->appointmentService->validate($data);
49 $validationHandlerResult = RestControllerHelper::validationHandler($validationResult);
50 if (is_array($validationHandlerResult)) {
51 return $validationHandlerResult; }
53 $serviceResult = $this->appointmentService->insert($pid, $data);
54 return RestControllerHelper::responseHandler(array("id" => $serviceResult), null, 200);
57 public function delete($eid)
59 $serviceResult = $this->appointmentService->delete($eid);
60 return RestControllerHelper::responseHandler($serviceResult, null, 200);