psr12 fixes for new PHP_CodeSniffer (#4795)
[openemr.git] / interface / modules / zend_modules / module / Patientvalidation / src / Patientvalidation / Controller / PatientvalidationController.php
blob1d689b84b23aa873af7cb7c5d5163a8801597b28
1 <?php
3 /* +-----------------------------------------------------------------------------+
4 * Copyright 2016 matrix israel
5 * LICENSE: This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 3
8 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see
15 * http://www.gnu.org/licenses/licenses.html#GPL
16 * @author Dror Golan <drorgo@matrix.co.il>
17 * +------------------------------------------------------------------------------+
20 namespace Patientvalidation\Controller;
22 use Patientvalidation\Model\PatientData;
23 use Laminas\Json\Server\Exception\ErrorException;
24 use Laminas\Mvc\Controller\AbstractActionController;
25 use Laminas\View\Model\ViewModel;
26 use Application\Listener\Listener;
27 use Patientvalidation\Model\PatientDataTable;
28 use Error;
30 class PatientvalidationController extends BaseController
32 /**
33 * @var PatientDataTable
35 private $PatientDataTable;
37 /**
38 * PatientvalidationController constructor.
40 public function __construct(PatientDataTable $dataTable)
42 parent::__construct();
43 $this->listenerObject = new Listener();
44 $this->PatientDataTable = $dataTable;
45 //todo add permission of admin
48 private function getAllRealatedPatients()
50 //Collect all of the data received from the new patient form
51 $patientParams = $this->getRequestedParamsArray();
52 if (isset($patientParams["closeBeforeOpening"])) {
53 $closeBeforeOpening = $patientParams["closeBeforeOpening"];
54 } else {
55 $closeBeforeOpening = '';
58 //clean the mf_
59 foreach ($patientParams as $key => $item) {
60 $keyArr = explode("mf_", $key);
61 $patientParams[$keyArr[1]] = $item;
62 unset($patientParams[$key]);
66 $patientData = $this->getPatientDataTable()->getPatients($patientParams);
69 if (isset($patientData)) {
70 foreach ($patientData as $data) {
71 if ($data['pubpid'] == $patientParams['pubpid']) {
72 return array("status" => "failed","list" => $patientData,"closeBeforeOpening" => $closeBeforeOpening);
76 return array("status" => "ok","list" => $patientData,"closeBeforeOpening" => $closeBeforeOpening);
79 /**
80 * @return \Laminas\Stdlib\ResponseInterface the index action
83 public function indexAction()
86 $this->getJsFiles();
87 $this->getCssFiles();
88 $this->layout()->setVariable('jsFiles', $this->jsFiles);
89 $this->layout()->setVariable('cssFiles', $this->cssFiles);
90 $this->layout()->setVariable("title", $this->listenerObject->z_xl("Patient validation"));
91 $this->layout()->setVariable("translate", $this->translate);
93 $relatedPatients = $this->getAllRealatedPatients();
97 return array("related_patients" => $relatedPatients['list'],"translate" => $this->translate,"closeBeforeOpening" => $relatedPatients['closeBeforeOpening'],"status" => $relatedPatients['status']);
99 /**
100 * get instance of Patientvalidation
101 * @return array|object
103 private function getPatientDataTable()
106 return $this->PatientDataTable;