migrated ubiquitous libraries to composer autoloader (#421)
[openemr.git] / interface / de_identification_forms / re_identification_op_single_patient.php
blob9e186bed567e720c00afed3d87b7712c5429dbed
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 include_once("../../library/sql.inc");
25 $query = "SELECT status FROM re_identification_status";
26 $res = sqlStatement($query);
27 if ($row = sqlFetchArray($res))
29 $status = addslashes($row['status']);
30 /* $Status:
31 * 0 - There is no Re Identification in progress. (start new Re Identification process)
32 * 1 - A Re Identification process is currently in progress.
33 * 2 - The Re Identification process completed and xls file is ready to download
36 if($status == 0)
38 //0 - There is no Re Identification in progress. (start new Re Identification process)
40 <html>
41 <head>
42 <title><?php xl('Re Identification','e'); ?></title>
43 <link rel="stylesheet" href='<?php echo $css_header ?>' type='text/css'>
44 <link rel="stylesheet"
45 href='<?php echo $GLOBALS['webroot'] ?>/library/dynarch_calendar.css'
46 type='text/css'>
48 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/dialog.js?v=<?php echo $v_js_includes; ?>"></script>
50 <style type="text/css">
51 .style1 {
52 text-align: center;
54 </style>
55 </head>
56 <body class="body_top">
57 <strong><?php xl('Re Identification','e'); ?></strong>
58 <div id="overDiv"
59 style="position: absolute; visibility: hidden; z-index: 1000;"></div>
61 <form enctype="Re_identification_output" method="POST"><?php
62 if ($_POST["re_id_code"]) { $reIdCode = formData('re_id_code','P',true); }
64 //to store input for re-idenitification
65 $query = "DROP TABLE IF EXISTS temp_re_identification_code_table";
66 $res = sqlStatement($query);
68 $query = "create table temp_re_identification_code_table (re_identification_code varchar(50))";
69 $res = sqlStatement($query);
71 $query = "insert into temp_re_identification_code_table values ('$reIdCode')";
72 $res = sqlStatement($query);
74 $query = "update re_identification_status set status = 1;";
75 $res = sqlStatement($query);
77 //call procedure - execute in background
78 $sh_cmd='./re_identification_procedure.sh '.$sqlconf["host"].' '.$sqlconf["login"].' '.$sqlconf["pass"].' '.$sqlconf["dbase"].' &';
79 system ($sh_cmd);
82 <table>
83 <tr>
84 <td>&nbsp;</td>
85 <td>&nbsp;</td>
86 </tr>
87 <tr>
88 <td>&nbsp;</td>
89 <td>&nbsp;</td>
90 </tr>
91 </table>
92 <table class="de_identification_status_message" align="center">
93 <tr valign="top">
95 <td>&nbsp;</td>
96 <td rowspan="3"><br>
97 <?php echo xl('Re Identification Process is ongoing');
98 echo "</br></br>";
99 echo xl('Please visit Re Identification screen after some time');
100 echo "</br>"; ?> </br>
101 </td>
102 <td>&nbsp;</td>
103 </tr>
104 <tr>
105 <td>&nbsp;</td>
106 <td>&nbsp;</td>
107 </tr>
108 <tr>
109 <td>&nbsp;</td>
110 <td>&nbsp;</td>
111 </tr>
112 </table>
113 <table align="center">
114 <tr>
115 <td>&nbsp;</td>
116 <td>&nbsp;</td>
117 </tr>
118 </table>
119 <?php
122 else if($status == 2)
124 //2 - The Re Identification process completed and xls file is ready to download
125 $query = "update re_identification_status set status = 0";
126 $res = sqlStatement($query);
127 $query = "SELECT count(*) as count FROM re_identified_data";
128 $res = sqlStatement($query);
130 if ($row = sqlFetchArray($res))
132 $no_of_items = addslashes($row['count']);
134 if($no_of_items <= 1)
137 <table>
138 <tr>
139 <td>&nbsp;</td>
140 <td>&nbsp;</td>
141 </tr>
142 <tr>
143 <td>&nbsp;</td>
144 <td>&nbsp;</td>
145 </tr>
146 </table>
147 <table class="de_identification_status_message" align="center">
148 <tr valign="top">
149 <td>&nbsp;</td>
150 <td rowspan="3"><br>
151 <?php echo xl('No match Patient record found for the given Re Idenitification code');
152 echo "</br></br>";
153 echo xl('Please enter correct Re Identification code');
154 echo "</br>"; ?> </br>
155 </td>
156 <td>&nbsp;</td>
157 </tr>
158 <tr>
159 <td>&nbsp;</td>
160 <td>&nbsp;</td>
161 </tr>
162 <tr>
163 <td>&nbsp;</td>
164 <td>&nbsp;</td>
165 </tr>
166 </table>
167 <table align="center">
168 <tr>
169 <td>&nbsp;</td>
170 <td>&nbsp;</td>
171 </tr>
172 </table>
173 <?php
175 else
177 //delete old re_identified_data.xls file
178 $timestamp=0;
179 $query = "select now() as timestamp";
180 $res = sqlStatement($query);
181 if ($row = sqlFetchArray($res))
183 $timestamp = addslashes($row['timestamp']);
185 $timestamp = str_replace(" ","_",$timestamp);
186 $filename = $GLOBALS['temporary_files_dir']."/re_identified_data".$timestamp.".xls";
187 $query = "select * from re_identified_data into outfile '$filename' ";
188 $res = sqlStatement($query);
189 ob_end_clean();
190 //download Re Identification .xls file
191 if (file_exists($filename)) {
192 header('Content-Description: File Transfer');
193 header('Content-Type: application/octet-stream');
194 header('Content-Disposition: attachment; filename='.basename($filename));
195 header('Content-Transfer-Encoding: none');
196 header('Content-Type: application/vnd.ms-excel;'); // This should work for IE & Opera
197 header("Content-type: application/x-msexcel"); // This should work for the rest
198 header('Expires: 0');
199 header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
200 header('Pragma: public');
201 header('Content-Length: ' . filesize($filename));
202 ob_clean();
203 flush();
204 readfile($filename);
206 //xls file downloaded complete
211 ?></form>
212 </body>
213 </html>