more organization of autoloaded files (#424)
[openemr.git] / interface / de_identification_forms / re_identification_op_single_patient.php
blob0496c75c6255f7db6a00897f41f8db6dd1d11b80
1 <?php
2 /********************************************************************************\
3 * Copyright (C) ViCarePlus, Visolve (vicareplus_engg@visolve.com) *
4 * *
5 * 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 2 *
8 * of the License, or (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the Free Software *
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
18 \********************************************************************************/
19 require_once("../globals.php");
20 require_once("$srcdir/lists.inc");
21 require_once("$srcdir/patient.inc");
22 require_once("$srcdir/acl.inc");
23 require_once("$srcdir/options.inc.php");
24 $query = "SELECT status FROM re_identification_status";
25 $res = sqlStatement($query);
26 if ($row = sqlFetchArray($res))
28 $status = addslashes($row['status']);
29 /* $Status:
30 * 0 - There is no Re Identification in progress. (start new Re Identification process)
31 * 1 - A Re Identification process is currently in progress.
32 * 2 - The Re Identification process completed and xls file is ready to download
35 if($status == 0)
37 //0 - There is no Re Identification in progress. (start new Re Identification process)
39 <html>
40 <head>
41 <title><?php xl('Re Identification','e'); ?></title>
42 <link rel="stylesheet" href='<?php echo $css_header ?>' type='text/css'>
43 <link rel="stylesheet"
44 href='<?php echo $GLOBALS['webroot'] ?>/library/dynarch_calendar.css'
45 type='text/css'>
47 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/dialog.js?v=<?php echo $v_js_includes; ?>"></script>
49 <style type="text/css">
50 .style1 {
51 text-align: center;
53 </style>
54 </head>
55 <body class="body_top">
56 <strong><?php xl('Re Identification','e'); ?></strong>
57 <div id="overDiv"
58 style="position: absolute; visibility: hidden; z-index: 1000;"></div>
60 <form enctype="Re_identification_output" method="POST"><?php
61 if ($_POST["re_id_code"]) { $reIdCode = formData('re_id_code','P',true); }
63 //to store input for re-idenitification
64 $query = "DROP TABLE IF EXISTS temp_re_identification_code_table";
65 $res = sqlStatement($query);
67 $query = "create table temp_re_identification_code_table (re_identification_code varchar(50))";
68 $res = sqlStatement($query);
70 $query = "insert into temp_re_identification_code_table values ('$reIdCode')";
71 $res = sqlStatement($query);
73 $query = "update re_identification_status set status = 1;";
74 $res = sqlStatement($query);
76 //call procedure - execute in background
77 $sh_cmd='./re_identification_procedure.sh '.$sqlconf["host"].' '.$sqlconf["login"].' '.$sqlconf["pass"].' '.$sqlconf["dbase"].' &';
78 system ($sh_cmd);
81 <table>
82 <tr>
83 <td>&nbsp;</td>
84 <td>&nbsp;</td>
85 </tr>
86 <tr>
87 <td>&nbsp;</td>
88 <td>&nbsp;</td>
89 </tr>
90 </table>
91 <table class="de_identification_status_message" align="center">
92 <tr valign="top">
94 <td>&nbsp;</td>
95 <td rowspan="3"><br>
96 <?php echo xl('Re Identification Process is ongoing');
97 echo "</br></br>";
98 echo xl('Please visit Re Identification screen after some time');
99 echo "</br>"; ?> </br>
100 </td>
101 <td>&nbsp;</td>
102 </tr>
103 <tr>
104 <td>&nbsp;</td>
105 <td>&nbsp;</td>
106 </tr>
107 <tr>
108 <td>&nbsp;</td>
109 <td>&nbsp;</td>
110 </tr>
111 </table>
112 <table align="center">
113 <tr>
114 <td>&nbsp;</td>
115 <td>&nbsp;</td>
116 </tr>
117 </table>
118 <?php
121 else if($status == 2)
123 //2 - The Re Identification process completed and xls file is ready to download
124 $query = "update re_identification_status set status = 0";
125 $res = sqlStatement($query);
126 $query = "SELECT count(*) as count FROM re_identified_data";
127 $res = sqlStatement($query);
129 if ($row = sqlFetchArray($res))
131 $no_of_items = addslashes($row['count']);
133 if($no_of_items <= 1)
136 <table>
137 <tr>
138 <td>&nbsp;</td>
139 <td>&nbsp;</td>
140 </tr>
141 <tr>
142 <td>&nbsp;</td>
143 <td>&nbsp;</td>
144 </tr>
145 </table>
146 <table class="de_identification_status_message" align="center">
147 <tr valign="top">
148 <td>&nbsp;</td>
149 <td rowspan="3"><br>
150 <?php echo xl('No match Patient record found for the given Re Idenitification code');
151 echo "</br></br>";
152 echo xl('Please enter correct Re Identification code');
153 echo "</br>"; ?> </br>
154 </td>
155 <td>&nbsp;</td>
156 </tr>
157 <tr>
158 <td>&nbsp;</td>
159 <td>&nbsp;</td>
160 </tr>
161 <tr>
162 <td>&nbsp;</td>
163 <td>&nbsp;</td>
164 </tr>
165 </table>
166 <table align="center">
167 <tr>
168 <td>&nbsp;</td>
169 <td>&nbsp;</td>
170 </tr>
171 </table>
172 <?php
174 else
176 //delete old re_identified_data.xls file
177 $timestamp=0;
178 $query = "select now() as timestamp";
179 $res = sqlStatement($query);
180 if ($row = sqlFetchArray($res))
182 $timestamp = addslashes($row['timestamp']);
184 $timestamp = str_replace(" ","_",$timestamp);
185 $filename = $GLOBALS['temporary_files_dir']."/re_identified_data".$timestamp.".xls";
186 $query = "select * from re_identified_data into outfile '$filename' ";
187 $res = sqlStatement($query);
188 ob_end_clean();
189 //download Re Identification .xls file
190 if (file_exists($filename)) {
191 header('Content-Description: File Transfer');
192 header('Content-Type: application/octet-stream');
193 header('Content-Disposition: attachment; filename='.basename($filename));
194 header('Content-Transfer-Encoding: none');
195 header('Content-Type: application/vnd.ms-excel;'); // This should work for IE & Opera
196 header("Content-type: application/x-msexcel"); // This should work for the rest
197 header('Expires: 0');
198 header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
199 header('Pragma: public');
200 header('Content-Length: ' . filesize($filename));
201 ob_clean();
202 flush();
203 readfile($filename);
205 //xls file downloaded complete
210 ?></form>
211 </body>
212 </html>