2 /********************************************************************************\
3 * Copyright (C) ViCarePlus, Visolve (vicareplus_engg@visolve.com) *
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. *
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. *
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 require_once("$srcdir/translation.inc.php");
25 require_once("../../library/sqlconf.php");
28 /*executes the De Identification process, using the parameters chosen from the
29 de_identification_screen1.php */
30 $begin_date = $_POST["begin_date"];
31 $end_date = $_POST["end_date"];
33 if ($_POST["unstructured"])
34 $include_unstructured = 1;
36 $include_unstructured = 0;
39 $include_tables = "all";
42 if ($_POST["history_data"])
43 $include_tables = $include_tables . $_POST["history_data"]. "#";
44 if ($_POST["prescriptions"])
45 $include_tables = $include_tables . $_POST["prescriptions"]. "#";
46 if ($_POST["immunization"])
47 $include_tables = $include_tables . $_POST["immunization"]. "#";
49 $include_tables = $include_tables . $_POST["lists"]. "#";
50 if ($_POST["transactions"])
51 $include_tables = $include_tables . $_POST["transactions"]. "#";
52 if ($_POST["insurance_data"])
53 $include_tables = $include_tables . $_POST["insurance_data"]. "#";
54 if ($_POST["billing_data"])
55 $include_tables = $include_tables . "billing#payments";
58 $diagnosis_text = $_POST["diagnosis_text"];
59 $drug_text = $_POST["drug_text"];
60 $immunization_text = $_POST["immunization_text"];
62 $query = "select status from de_identification_status";
63 $res = sqlStatement($query);
64 if ($row = sqlFetchArray($res))
66 $deIdentificationStatus = addslashes($row['status']);
67 /* $deIdentificationStatus:
68 * 0 - There is no De Identification in progress. (start new De Identification process)
69 * 1 - A De Identification process is currently in progress.
70 * 2 - The De Identification process completed and xls file is ready to download
71 * 3 - The De Identification process completed with error
75 if($deIdentificationStatus == 0)
77 //0 - There is no De Identification in progress. (start new De Identification process)
81 <title
>De Identification
</title
>
82 <link rel
="stylesheet" href
='<?php echo $css_header ?>' type
='text/css'>
83 <link rel
="stylesheet"
84 href
='<?php echo $GLOBALS['webroot
'] ?>/library/dynarch_calendar.css'
86 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/dialog.js"></script
>
87 <style type
="text/css">
93 <body
class="body_top">
94 <strong
>De Identification
</strong
>
95 <form name
="De Identification1" id
="De Identification1" method
="post"><br
/>
98 $query = "SELECT count(*) as count FROM metadata_de_identification";
99 $res = sqlStatement($query);
100 if ($row = sqlFetchArray($res))
102 $no_of_items = addslashes($row['count']);
103 if($no_of_items == 0)
105 $cmd="cp ".$GLOBALS['webserver_root']."/sql/metadata_de_identification.txt ".$GLOBALS['temporary_files_dir']."/metadata_de_identification.txt";
106 $output3=shell_exec($cmd);
107 $query = "LOAD DATA INFILE '".$GLOBALS['temporary_files_dir']."/metadata_de_identification.txt' INTO TABLE metadata_de_identification FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n'";
108 $res = sqlStatement($query);
111 //create transaction tables
112 $query = "call create_transaction_tables()";
113 $res = sqlStatement($query);
115 //write input to data base
116 $query = "delete from param_include_tables";
117 $res = sqlStatement($query);
119 $query = "insert into param_include_tables values ('$include_tables','$include_unstructured')";
120 $res = sqlStatement($query);
122 $query = "delete from param_filter_pid";
123 $res = sqlStatement($query);
125 $query = "insert into param_filter_pid values ('$begin_date', '$end_date', '$diagnosis_text', '$drug_text', '$immunization_text')";
126 $res = sqlStatement($query);
129 $query = "update de_identification_status set status = 1";
130 $res = sqlStatement($query);
134 //call procedure - execute in background
135 $sh_cmd='./de_identification_procedure.sh '.$sqlconf["host"].' '.$sqlconf["login"].' '.$sqlconf["pass"].' '.$sqlconf["dbase"].' &';
139 $query = "SELECT status FROM de_identification_status ";
140 $res = sqlStatement($query);
141 if ($row = sqlFetchArray($res))
143 $de_identification_status = addslashes($row['status']);
144 if($de_identification_status == 2 ||
$de_identification_status == 3)
146 //2 - The De Identification process completed and xls file is ready to download
147 //3 - The De Identification process completed with error
148 $query = "SELECT count(*) as count FROM de_identified_data ";
149 $res = sqlStatement($query);
150 if ($row = sqlFetchArray($res))
152 $no_of_items = addslashes($row['count']);
153 if($no_of_items <= 1)
166 <table
class="de_identification_status_message" align
="center">
171 <?php
echo xl('No Patient record found for given Selection criteria');
173 echo xl('Please start new De Identification process');
174 echo "</br>"; ?
> </br
>
187 <table align
="center">
197 { //delete old de_identified_data.xls file
199 $query = "select now() as timestamp";
200 $res = sqlStatement($query);
201 if ($row = sqlFetchArray($res))
203 $timestamp = addslashes($row['timestamp']);
205 $timestamp = str_replace(" ","_",$timestamp);
206 $de_identified_file = $GLOBALS['temporary_files_dir']."/de_identified_data".$timestamp.".xls";
207 $query = "update de_identification_status set last_available_de_identified_data_file = '" . $de_identified_file . "'";
208 $res = sqlStatement($query);
209 $query = "select * from de_identified_data into outfile '$de_identified_file' ";
210 $res = sqlStatement($query);
222 <table
class="de_identification_status_message" align
="center">
226 <?php
echo xl('De Identification Process is ongoing');
228 echo xl('Please visit De Identification screen after some time');
229 echo "</br>"; ?
> </br
>
242 <table align
="center">
257 $query = "update de_identification_status set status = 3";
258 $res = sqlStatement($query);
261 else if($deIdentificationStatus == 2 or $deIdentificationStatus == 3)
263 //2 - The De Identification process completed and xls file is ready to download
264 //3 - The De Identification process completed with error
265 $query = "select last_available_de_identified_data_file from de_identification_status";
266 $res = sqlStatement($query);
267 if ($row = sqlFetchArray($res))
269 $filename = addslashes($row['last_available_de_identified_data_file']);
272 if (file_exists($filename)) {
274 header('Content-Description: File Transfer');
275 header('Content-Type: application/octet-stream');
276 header('Content-Disposition: attachment; filename='.basename($filename));
277 header('Content-Transfer-Encoding: binary');
278 header('Content-Type: application/vnd.ms-excel;'); // This should work for IE & Opera
279 header("Content-type: application/x-msexcel"); // This should work for the rest
280 header('Expires: 0');
281 header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
282 header('Pragma: public');
283 header('Content-Length: ' . filesize($filename));
290 //xls file downloaded complete
291 $query = "update de_identification_status set status = 0";
292 $res = sqlStatement($query);