Openemr fhir search (#4349)
[openemr.git] / src / RestControllers / DrugRestController.php
blob4f4402f1ba63d16f7323655464da027b3ebdcc97
1 <?php
3 /**
4 * DrugRestController
6 * @package OpenEMR
7 * @link http://www.open-emr.org
8 * @author Yash Bothra <yashrajbothra786gmail.com>
9 * @copyright Copyright (c) 2020 Yash Bothra <yashrajbothra786gmail.com>
10 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
13 namespace OpenEMR\RestControllers;
15 use OpenEMR\Services\DrugService;
16 use OpenEMR\RestControllers\RestControllerHelper;
18 class DrugRestController
20 private $drugService;
22 public function __construct()
24 $this->drugService = new DrugService();
27 /**
28 * Fetches a single drug resource by id.
29 * @param $uuid- The drug uuid identifier in string format.
31 public function getOne($uuid)
33 $processingResult = $this->drugService->getOne($uuid);
35 if (!$processingResult->hasErrors() && count($processingResult->getData()) == 0) {
36 return RestControllerHelper::handleProcessingResult($processingResult, 404);
39 return RestControllerHelper::handleProcessingResult($processingResult, 200);
42 /**
43 * Returns drug resources which match an optional search criteria.
45 public function getAll($search = array())
47 $processingResult = $this->drugService->getAll($search);
48 return RestControllerHelper::handleProcessingResult($processingResult, 200, true);