Highway to PSR2
[openemr.git] / interface / modules / zend_modules / module / Syndromicsurveillance / src / Syndromicsurveillance / Controller / SyndromicsurveillanceController.php
blobaae82f9a2b8a4da84114223d906fe41618cafdfc
1 <?php
2 /* +-----------------------------------------------------------------------------+
3 * OpenEMR - Open Source Electronic Medical Record
4 * Copyright (C) 2014 Z&H Consultancy Services Private Limited <sam@zhservices.com>
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Affero General Public License as
8 * published by the Free Software Foundation, either version 3 of the
9 * License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Affero General Public License for more details.
16 * You should have received a copy of the GNU Affero General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 * @author Vinish K <vinish@zhservices.com>
19 * +------------------------------------------------------------------------------+
21 namespace Syndromicsurveillance\Controller;
23 use Zend\Mvc\Controller\AbstractActionController;
24 use Zend\View\Model\ViewModel;
25 use Zend\View\Model\JsonModel;
26 use Application\Listener\Listener;
28 class SyndromicsurveillanceController extends AbstractActionController
30 protected $encounterccdadispatchTable;
32 protected $listenerObject;
34 public function __construct()
36 $this->listenerObject = new Listener;
40 * Display the list of patients having ICD9 codes which are reportable
42 * @param form_date_from date Encounter date
43 * @param form_date_to date Encounter date
44 * @param form_icd_codes string ICD9 code
45 * @param form_provider_id integer Selected provider id
47 public function indexAction()
49 $request = $this->getRequest();
50 $this->search = $request->getPost('search', null);
51 $fromDate = $request->getPost('form_date_from', null) ? $this->CommonPlugin()->date_format($request->getPost('form_date_from', null), 'yyyy-mm-dd', $GLOBALS['date_display_format']) : date('Y-m-d', strtotime(date('Ymd')) - (86400*7));
52 $toDate = $request->getPost('form_date_to', null) ? $this->CommonPlugin()->date_format($request->getPost('form_date_to', null), 'yyyy-mm-dd', $GLOBALS['date_display_format']) : date('Y-m-d');
53 $code_selected = $request->getPost('form_icd_codes', null);
54 $provider_selected = $request->getPost('form_provider_id', null);
56 $results = $request->getPost('form_results', 100);
57 $results = ($results > 0) ? $results : 100;
58 $current_page = $request->getPost('form_current_page', 1);
59 $end = $current_page*$results;
60 $start = ($end - $results);
61 $new_search = $request->getPost('form_new_search', null);
62 $form_sl_no = $request->getPost('form_sl_no', 0);
63 $download_hl7 = $request->getPost('download_hl7', 0);
65 $params = array(
66 'form_date_from' => $fromDate,
67 'form_date_to' => $toDate,
68 'form_icd_codes' => $code_selected,
69 'form_provider_id' => $provider_selected,
70 'results' => $results,
71 'current_page' => $current_page,
72 'limit_start' => $start,
73 'limit_end' => $end,
74 'sl_no' => $form_sl_no,
76 $params['form_icd_codes'][] = $code_selected;
78 if ($new_search) {
79 $count = $this->getSyndromicsurveillanceTable()->fetch_result($fromDate, $toDate, $code_selected, $provider_selected, $start, $end, 1);
80 } else {
81 $count = $request->getPost('form_count', $this->getSyndromicsurveillanceTable()->fetch_result($fromDate, $toDate, $code_selected, $provider_selected, $start, $end, 1));
84 $totalpages = ceil($count/$results);
86 $params['res_count'] = $count;
87 $params['total_pages'] = $totalpages;
88 if ($download_hl7) {
89 $this->getSyndromicsurveillanceTable()->generate_hl7($fromDate, $toDate, $code_selected, $provider_selected, $start, $end);
92 $search_result = $this->getSyndromicsurveillanceTable()->fetch_result($fromDate, $toDate, $code_selected, $provider_selected, $start, $end);
94 $code_list = $this->getSyndromicsurveillanceTable()->non_reported_codes();
95 $provider = $this->getSyndromicsurveillanceTable()->getProviderList();
97 $view = new ViewModel(array(
98 'code_list' => $code_list,
99 'provider' => $provider,
100 'result' => $search_result,
101 'form_data' => $params,
102 'table_obj' => $this->getSyndromicsurveillanceTable(),
103 'listenerObject'=> $this->listenerObject,
104 'commonplugin' => $this->CommonPlugin(),
106 return $view;
110 * Table Gateway
112 * @return type
114 public function getSyndromicsurveillanceTable()
116 if (!$this->syndromicsurveillanceTable) {
117 $sm = $this->getServiceLocator();
118 $this->syndromicsurveillanceTable = $sm->get('Syndromicsurveillance\Model\SyndromicsurveillanceTable');
121 return $this->syndromicsurveillanceTable;