Fixes #7635 appointment comments double escaped (#7638)
[openemr.git] / interface / de_identification_forms / re_identification_op_single_patient.php
blob7f989d04afa393fa983aff9779d60ed4db2ad2cc
1 <?php
3 /**
4 * re_identification_op_single_patient.php
6 * @package OpenEMR
7 * @link http://www.open-emr.org
8 * @author Visolve <vicareplus_engg@visolve.com>
9 * @author Brady Miller <brady.g.miller@gmail.com>
10 * @copyright Copyright (c) 2010 ViCarePlus, Visolve <vicareplus_engg@visolve.com>
11 * @copyright Copyright (c) 2018 Brady Miller <brady.g.miller@gmail.com>
12 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
15 require_once("../globals.php");
16 require_once("$srcdir/lists.inc.php");
17 require_once("$srcdir/patient.inc.php");
18 require_once("$srcdir/options.inc.php");
20 use OpenEMR\Common\Acl\AclMain;
21 use OpenEMR\Common\Csrf\CsrfUtils;
22 use OpenEMR\Common\Twig\TwigContainer;
23 use OpenEMR\Core\Header;
25 if (!AclMain::aclCheckCore('admin', 'super')) {
26 echo (new TwigContainer(null, $GLOBALS['kernel']))->getTwig()->render('core/unauthorized.html.twig', ['pageTitle' => xl("Re Identification")]);
27 exit;
30 if (!CsrfUtils::verifyCsrfToken($_POST["csrf_token_form"])) {
31 CsrfUtils::csrfNotVerified();
34 $query = "SELECT status FROM re_identification_status";
35 $res = sqlStatement($query);
36 if ($row = sqlFetchArray($res)) {
37 $status = $row['status'];
38 /* $Status:
39 * 0 - There is no Re Identification in progress. (start new Re Identification process)
40 * 1 - A Re Identification process is currently in progress.
41 * 2 - The Re Identification process completed and xls file is ready to download
45 if ($status == 0) {
46 //0 - There is no Re Identification in progress. (start new Re Identification process)
48 <html>
49 <head>
50 <title><?php echo xlt('Re Identification'); ?></title>
52 <?php Header::setupHeader(); ?>
54 <style>
55 .style1 {
56 text-align: center;
58 </style>
59 </head>
60 <body class="body_top">
61 <strong><?php echo xlt('Re Identification'); ?></strong>
62 <div id="overDiv"
63 style="position: absolute; visibility: hidden; z-index: 1000;"></div>
65 <form enctype="Re_identification_output" method="POST"><?php
66 if ($_POST["re_id_code"]) {
67 $reIdCode = isset($_POST['re_id_code']) ? trim($_POST['re_id_code']) : '';
70 //to store input for re-idenitification
71 $query = "DROP TABLE IF EXISTS temp_re_identification_code_table";
72 $res = sqlStatement($query);
74 $query = "create table temp_re_identification_code_table (re_identification_code varchar(50))";
75 $res = sqlStatement($query);
77 $query = "insert into temp_re_identification_code_table values (?)";
78 $res = sqlStatement($query, array($reIdCode));
80 $query = "update re_identification_status set status = 1;";
81 $res = sqlStatement($query);
83 //call procedure - execute in background
84 $sh_cmd = './re_identification_procedure.sh ' . escapeshellarg($sqlconf["host"]) . ' ' . escapeshellarg($sqlconf["login"]) . ' ' . escapeshellarg($sqlconf["pass"]) . ' ' . escapeshellarg($sqlconf["dbase"]) . ' &';
85 system($sh_cmd);
88 <table>
89 <tr>
90 <td>&nbsp;</td>
91 <td>&nbsp;</td>
92 </tr>
93 <tr>
94 <td>&nbsp;</td>
95 <td>&nbsp;</td>
96 </tr>
97 </table>
98 <table class="de_identification_status_message" align="center">
99 <tr valign="top">
101 <td>&nbsp;</td>
102 <td rowspan="3"><br />
103 <?php echo xlt('Re Identification Process is ongoing');
104 echo "<br /><br />";
105 echo xlt('Please visit Re Identification screen after some time');
106 echo "<br />"; ?> <br />
107 </td>
108 <td>&nbsp;</td>
109 </tr>
110 <tr>
111 <td>&nbsp;</td>
112 <td>&nbsp;</td>
113 </tr>
114 <tr>
115 <td>&nbsp;</td>
116 <td>&nbsp;</td>
117 </tr>
118 </table>
119 <table align="center">
120 <tr>
121 <td>&nbsp;</td>
122 <td>&nbsp;</td>
123 </tr>
124 </table>
125 <?php
126 } elseif ($status == 2) {
127 //2 - The Re Identification process completed and xls file is ready to download
128 $query = "update re_identification_status set status = 0";
129 $res = sqlStatement($query);
130 $query = "SELECT count(*) as count FROM re_identified_data";
131 $res = sqlStatement($query);
133 if ($row = sqlFetchArray($res)) {
134 $no_of_items = $row['count'];
137 if ($no_of_items <= 1) {
139 <table>
140 <tr>
141 <td>&nbsp;</td>
142 <td>&nbsp;</td>
143 </tr>
144 <tr>
145 <td>&nbsp;</td>
146 <td>&nbsp;</td>
147 </tr>
148 </table>
149 <table class="de_identification_status_message" align="center">
150 <tr valign="top">
151 <td>&nbsp;</td>
152 <td rowspan="3"><br />
153 <?php echo xlt('No match Patient record found for the given Re Idenitification code');
154 echo "<br /><br />";
155 echo xlt('Please enter correct Re Identification code');
156 echo "<br />"; ?> <br />
157 </td>
158 <td>&nbsp;</td>
159 </tr>
160 <tr>
161 <td>&nbsp;</td>
162 <td>&nbsp;</td>
163 </tr>
164 <tr>
165 <td>&nbsp;</td>
166 <td>&nbsp;</td>
167 </tr>
168 </table>
169 <table align="center">
170 <tr>
171 <td>&nbsp;</td>
172 <td>&nbsp;</td>
173 </tr>
174 </table>
175 <?php
176 } 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)) {
182 $timestamp = $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 '" . add_escape_custom($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
210 ?></form>
211 </body>
212 </html>