forked from openemr/openemr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ImmunizationRestController.php
56 lines (46 loc) · 1.69 KB
/
ImmunizationRestController.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
51
52
53
54
55
56
<?php
/**
* ImmunizationRestController
*
* @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\ImmunizationService;
use OpenEMR\RestControllers\RestControllerHelper;
class ImmunizationRestController
{
private $immunizationService;
/**
* White list of immunization search fields
*/
private const WHITELISTED_FIELDS = array();
public function __construct()
{
$this->immunizationService = new ImmunizationService();
}
/**
* Fetches a single immunization resource by id.
* @param $uuid- The immunization uuid identifier in string format.
*/
public function getOne($uuid)
{
$processingResult = $this->immunizationService->getOne($uuid);
if (!$processingResult->hasErrors() && count($processingResult->getData()) == 0) {
return RestControllerHelper::handleProcessingResult($processingResult, 404);
}
return RestControllerHelper::handleProcessingResult($processingResult, 200);
}
/**
* Returns immunization resources which match an optional search criteria.
*/
public function getAll($search = array())
{
$validSearchFields = $this->immunizationService->filterData($search, self::WHITELISTED_FIELDS);
$processingResult = $this->immunizationService->getAll($validSearchFields);
return RestControllerHelper::handleProcessingResult($processingResult, 200, true);
}
}