forked from openemr/openemr
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathInsuranceRestController.php
More file actions
68 lines (55 loc) · 2.08 KB
/
InsuranceRestController.php
File metadata and controls
68 lines (55 loc) · 2.08 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
<?php
/**
* InsuranceRestController
*
* @package OpenEMR
* @link http://www.open-emr.org
* @author Matthew Vita <matthewvita48@gmail.com>
* @copyright Copyright (c) 2018 Matthew Vita <matthewvita48@gmail.com>
* @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
*/
namespace OpenEMR\RestControllers;
use OpenEMR\Services\InsuranceService;
use OpenEMR\RestControllers\RestControllerHelper;
class InsuranceRestController
{
private $insuranceService;
public function __construct()
{
$this->insuranceService = new InsuranceService();
}
public function getAll($pid)
{
$serviceResult = $this->insuranceService->getAll($pid);
return RestControllerHelper::responseHandler($serviceResult, null, 200);
}
public function getOne($pid, $type)
{
$serviceResult = $this->insuranceService->getOneByPid($pid, $type);
return RestControllerHelper::responseHandler($serviceResult, null, 200);
}
public function put($pid, $type, $data)
{
$data["type"] = $type;
$data["pid"] = $pid;
$validationResult = $this->insuranceService->validate($data);
$validationHandlerResult = RestControllerHelper::validationHandler($validationResult);
if (is_array($validationHandlerResult)) {
return $validationHandlerResult;
}
$serviceResult = $this->insuranceService->insert($pid, $type, $data);
return RestControllerHelper::responseHandler($serviceResult, $type, 200);
}
public function post($pid, $type, $data)
{
$data["type"] = $type;
$data["pid"] = $pid;
$validationResult = $this->insuranceService->validate($data);
$validationHandlerResult = RestControllerHelper::validationHandler($validationResult);
if (is_array($validationHandlerResult)) {
return $validationHandlerResult;
}
$serviceResult = $this->insuranceService->insert($pid, $type, $data);
return RestControllerHelper::responseHandler($serviceResult, $type, 201);
}
}