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
22 public function __construct()
24 $this->drugService
= new DrugService();
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);
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);