4 * re_identification_op_single_patient.php
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")]);
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'];
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
46 //0 - There is no Re Identification in progress. (start new Re Identification process)
50 <title
><?php
echo xlt('Re Identification'); ?
></title
>
52 <?php Header
::setupHeader(); ?
>
60 <body
class="body_top">
61 <strong
><?php
echo xlt('Re Identification'); ?
></strong
>
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"]) . ' &';
98 <table
class="de_identification_status_message" align
="center">
102 <td rowspan
="3"><br
/>
103 <?php
echo xlt('Re Identification Process is ongoing');
105 echo xlt('Please visit Re Identification screen after some time');
106 echo "<br />"; ?
> <br
/>
119 <table align
="center">
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) {
149 <table
class="de_identification_status_message" align
="center">
152 <td rowspan
="3"><br
/>
153 <?php
echo xlt('No match Patient record found for the given Re Idenitification code');
155 echo xlt('Please enter correct Re Identification code');
156 echo "<br />"; ?
> <br
/>
169 <table align
="center">
177 //delete old re_identified_data.xls file
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);
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));
206 //xls file downloaded complete