fix: reset fail user fail counter on password update (#6198)
[openemr.git] / src / RestControllers / InsuranceRestController.php
blob05ebded13b98161bf18dc60e6a006cb8e5a1c2b3
1 <?php
3 /**
4 * InsuranceRestController
6 * @package OpenEMR
7 * @link http://www.open-emr.org
8 * @author Matthew Vita <matthewvita48@gmail.com>
9 * @copyright Copyright (c) 2018 Matthew Vita <matthewvita48@gmail.com>
10 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
13 namespace OpenEMR\RestControllers;
15 use OpenEMR\Services\InsuranceService;
16 use OpenEMR\RestControllers\RestControllerHelper;
18 class InsuranceRestController
20 private $insuranceService;
22 public function __construct()
24 $this->insuranceService = new InsuranceService();
27 public function getAll($pid)
29 $serviceResult = $this->insuranceService->getAll($pid);
30 return RestControllerHelper::responseHandler($serviceResult, null, 200);
33 public function getOne($pid, $type)
35 $serviceResult = $this->insuranceService->getOneByPid($pid, $type);
36 return RestControllerHelper::responseHandler($serviceResult, null, 200);
39 public function put($pid, $type, $data)
41 $data["type"] = $type;
42 $data["pid"] = $pid;
43 $validationResult = $this->insuranceService->validate($data);
45 $validationHandlerResult = RestControllerHelper::validationHandler($validationResult);
46 if (is_array($validationHandlerResult)) {
47 return $validationHandlerResult;
50 $serviceResult = $this->insuranceService->insert($pid, $type, $data);
51 return RestControllerHelper::responseHandler($serviceResult, $type, 200);
54 public function post($pid, $type, $data)
56 $data["type"] = $type;
57 $data["pid"] = $pid;
58 $validationResult = $this->insuranceService->validate($data);
60 $validationHandlerResult = RestControllerHelper::validationHandler($validationResult);
61 if (is_array($validationHandlerResult)) {
62 return $validationHandlerResult;
65 $serviceResult = $this->insuranceService->insert($pid, $type, $data);
66 return RestControllerHelper::responseHandler($serviceResult, $type, 201);