forked from openemr/openemr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DrugRestController.php
50 lines (41 loc) · 1.38 KB
/
DrugRestController.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
<?php
/**
* DrugRestController
*
* @package OpenEMR
* @link http://www.open-emr.org
* @author Yash Bothra <yashrajbothra786gmail.com>
* @copyright Copyright (c) 2020 Yash Bothra <yashrajbothra786gmail.com>
* @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
*/
namespace OpenEMR\RestControllers;
use OpenEMR\Services\DrugService;
use OpenEMR\RestControllers\RestControllerHelper;
class DrugRestController
{
private $drugService;
public function __construct()
{
$this->drugService = new DrugService();
}
/**
* Fetches a single drug resource by id.
* @param $uuid- The drug uuid identifier in string format.
*/
public function getOne($uuid)
{
$processingResult = $this->drugService->getOne($uuid);
if (!$processingResult->hasErrors() && count($processingResult->getData()) == 0) {
return RestControllerHelper::handleProcessingResult($processingResult, 404);
}
return RestControllerHelper::handleProcessingResult($processingResult, 200);
}
/**
* Returns drug resources which match an optional search criteria.
*/
public function getAll($search = array())
{
$processingResult = $this->drugService->getAll($search);
return RestControllerHelper::handleProcessingResult($processingResult, 200, true);
}
}