3 * de_identification script
6 * @link http://www.open-emr.org
7 * @author ViCarePlus, Visolve <vicareplus_engg@visolve.com>
8 * @author Brady Miller <brady.g.miller@gmail.com>
9 * @copyright Copyright (c) 2010 ViCarePlus, Visolve <vicareplus_engg@visolve.com>
10 * @copyright Copyright (c) 2017 Brady Miller <brady.g.miller@gmail.com>
11 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
14 require_once("../globals.php");
15 require_once("$srcdir/lists.inc");
16 require_once("$srcdir/patient.inc");
17 require_once("$srcdir/acl.inc");
18 require_once("$srcdir/options.inc.php");
23 <title
><?php
xl('De Identification', 'e'); ?
></title
>
24 <link rel
="stylesheet" href
='<?php echo $css_header ?>' type
='text/css'>
25 <link rel
="stylesheet" href
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker-2-5-4/build/jquery.datetimepicker.min.css">
27 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-3-1-1/index.js"></script
>
28 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker-2-5-4/build/jquery.datetimepicker.full.min.js"></script
>
29 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/dialog.js?v=<?php echo $v_js_includes; ?>"></script
>
30 <style type
="text/css">
35 <script language
="JavaScript">
36 //get value from popup window
37 function set_related(s
,type
) {
39 if(type
== "diagnosis")
40 list = "diagnosis_list";
41 else if(type
== "drugs")
43 else if(type
== "immunizations")
44 list = "immunization_list";
47 var elSel
= document
.getElementById(list);
49 for (i
=0;p
[i
]!=null;i++
)
51 for(k
=0;k
<elSel
.length
;k++
)
53 if((elSel
.options
[k
].value
)==p
[i
])
58 var elOptNew
= document
.createElement('option');
60 elOptNew
.value
= p
[i
];
62 elSel
.add(elOptNew
, null); // standards compliant; doesn't work in IE
65 elSel
.add(elOptNew
); // IE only
72 function get_values(type
)
74 if(type
== "diagnosis")
75 dlgopen('find_code_popup.php', '_blank', 500, 400,true);
76 else if(type
== "drugs")
77 dlgopen('find_drug_popup.php', '_blank', 500, 400,true);
78 else if(type
== "immunizations")
79 dlgopen('find_immunization_popup.php', '_blank', 500, 400,true);
82 //remove item selected from list
83 function remove_selected(type
)
86 if(type
== "diagnosis")
87 list = "diagnosis_list";
88 else if(type
== "drugs")
90 else if(type
== "immunizations")
91 list = "immunization_list";
92 var elSel
= document
.getElementById(list);
94 for (i
= elSel
.length
- 1; i
>=0; i
--) {
95 if (elSel
.options
[i
].selected
)
103 function show_value(type
)
106 if(type
== "diagnosis")
107 { radio
= "diagnosis"; list = "diagnosis_list"; text
="diagnosis_text"; }
108 else if(type
== "drugs")
109 { radio
= "drugs"; list = "drug_list"; text
="drug_text"; }
110 else if(type
== "immunizations")
111 { radio
= "immunizations"; list = "immunization_list"; text
="immunization_text"; }
112 if(document
.getElementById(radio
) == "all")
114 document
.getElementById(text
).value
="all";
119 var elSel
= document
.getElementById(list);
121 for (i
= elSel
.length
- 1; i
>=0; i
--)
124 str
= elSel
.options
[i
].value
;
126 str
= str +
"#"+elSel
.options
[i
].value
;
129 document
.getElementById(text
).value
=str
;
133 //disable - enable other checkbox when all checkbox is clicked
134 function disable_other_chkbox()
136 var value
= document
.forms
[0].all
.checked
;
139 document
.forms
[0].history_data
.disabled
= true;
140 document
.forms
[0].prescriptions
.disabled
= true;
141 document
.forms
[0].lists
.disabled
= true;
142 document
.forms
[0].immunization
.disabled
= true;
143 document
.forms
[0].transactions
.disabled
= true;
144 document
.forms
[0].billing_data
.disabled
= true;
145 document
.forms
[0].insurance_data
.disabled
= true;
149 document
.forms
[0].history_data
.disabled
= false;
150 document
.forms
[0].prescriptions
.disabled
= false;
151 document
.forms
[0].lists
.disabled
= false;
152 document
.forms
[0].immunization
.disabled
= false;
153 document
.forms
[0].transactions
.disabled
= false;
154 document
.forms
[0].billing_data
.disabled
= false;
155 document
.forms
[0].insurance_data
.disabled
= false;
159 //disable list,add button,remove button when all option is selected
160 function disable_controls(type
)
162 var list,button1
,button2
;
163 if(type
== "diagnosis")
164 { button1
= "add_diagnosis"; button2
= "remove_diagnosis"; list = "diagnosis_list"; text
="diagnosis_text"; }
165 else if(type
== "drugs")
166 { button1
= "add_drug"; button2
= "remove_drug"; list = "drug_list"; text
="drug_text";}
167 else if(type
== "immunizations")
168 { button1
= "add_immunization"; button2
= "remove_immunization"; list = "immunization_list"; text
="immunization_text"; }
169 document
.getElementById(button1
).disabled
= true;
170 document
.getElementById(button2
).disabled
= true;
171 document
.getElementById(list).disabled
= true;
172 document
.getElementById(text
).value
= "all";
175 function enable_controls(type
)
177 var list,button1
,button2
;
178 if(type
== "diagnosis")
179 { button1
= "add_diagnosis"; button2
= "remove_diagnosis"; list = "diagnosis_list"; }
180 else if(type
== "drugs")
181 { button1
= "add_drug"; button2
= "remove_drug"; list = "drug_list"; }
182 else if(type
== "immunizations")
183 { button1
= "add_immunization"; button2
= "remove_immunization"; list = "immunization_list";
185 document
.getElementById(button1
).disabled
= false;
186 document
.getElementById(button2
).disabled
= false;
187 document
.getElementById(list).disabled
= false;
192 function form_validate()
194 if(document
.forms
[0].begin_date
.value
>= document
.forms
[0].end_date
.value
)
196 alert("<?php echo xl('End date should be greater than Begin date');?>");
200 if(document
.forms
[0].all
.checked
== false &&
201 document
.forms
[0].history_data
.checked
== false &&
202 document
.forms
[0].prescriptions
.checked
== false &&
203 document
.forms
[0].immunization
.checked
== false &&
204 document
.forms
[0].lists
.checked
== false &&
205 document
.forms
[0].transactions
.checked
== false &&
206 document
.forms
[0].billing_data
.checked
== false &&
207 document
.forms
[0].insurance_data
.checked
== false)
209 alert("<?php echo xl('Select Data Required for De Identification');?>");
213 if(document
.forms
[0].diagnosis_text
.value
== "undefined" || document
.forms
[0].diagnosis_text
.value
== "")
215 alert("<?php echo xl('Select Diagnosis for De Identification request');?>");
218 if(document
.forms
[0].drug_text
.value
== "undefined" || document
.forms
[0].drug_text
.value
== "")
220 alert("<?php echo xl('Select Drugs for De Identification request');?>");
223 if(document
.forms
[0].immunization_text
.value
== "undefined" || document
.forms
[0].immunization_text
.value
== "")
225 alert("<?php echo xl('Select Immunizations for De Identification request');?>");
228 alert("<?php echo xl('De Identification process is started and running in background');
230 echo xl('Please visit the screen after some time');?>");
231 top
.restoreSession();
235 function download_file()
237 alert("<?php echo xl('De-identification files will be saved in');
238 echo ' `'.$GLOBALS['temporary_files_dir'].'` ';
239 echo xl('location of the openemr machine and may contain sensitive data, so it is recommended to manually delete the files after its use');?>");
240 document
.de_identification
.submit();
243 $
(document
).ready(function(){
244 $
('.datepicker').datetimepicker({
245 <?php
$datetimepicker_timepicker = false; ?
>
246 <?php
$datetimepicker_showseconds = false; ?
>
247 <?php
$datetimepicker_formatInput = false; ?
>
248 <?php
require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?
>
249 <?php
// can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
255 <body
class="body_top">
256 <form name
="de_identification" id
="de_identification" action
="de_identification_screen2.php" method
="post" onsubmit
="return form_validate();">
257 <strong
><?php
xl('De Identification', 'e'); ?
></strong
>
259 $row = sqlQuery("SHOW TABLES LIKE 'de_identification_status'");
262 <table
> <tr
> <td
> 
;</td
> <td
> 
;</td
> </tr
>
263 <tr
> <td
> 
;</td
> <td
> 
;</td
> </tr
>
265 <table
class="de_identification_status_message" align
="center" >
270 <?php
echo xl('Please upgrade OpenEMR Database to include De Identification procedures, function, tables'); ?
>
271 </br
></br
><a target
="Blank" href
="../../contrib/util/de_identification_upgrade.php"><?php
echo xl('Click here');?
></a
>
272 <?php
echo xl('to run');
273 echo " de_identification_upgrade.php</br>";?
><br
>
288 $query = "select status from de_identification_status";
289 $res = sqlStatement($query);
290 if ($row = sqlFetchArray($res)) {
291 $deIdentificationStatus = addslashes($row['status']);
292 /* $deIdentificationStatus:
293 * 0 - There is no De Identification in progress. (start new De Identification process)
294 * 1 - A De Identification process is currently in progress.
295 * 2 - The De Identification process completed and xls file is ready to download
296 * 3 - The De Identification process completed with error
300 if ($deIdentificationStatus == 1) {
301 //1 - A De Identification process is currently in progress.
303 <table
> <tr
> <td
> 
;</td
> <td
> 
;</td
> </tr
>
304 <tr
> <td
> 
;</td
> <td
> 
;</td
> </tr
>
306 <table
class="de_identification_status_message" align
="center" >
311 <?php
echo xl('De Identification Process is ongoing');
313 echo xl('Please visit De Identification screen after some time');
314 echo "</br>"; ?
> <br
>
328 } else if ($deIdentificationStatus == 2) {
329 //2 - The De Identification process completed and xls file is ready to download
330 $query = "SELECT count(*) as count FROM de_identified_data ";
331 $res = sqlStatement($query);
332 if ($row = sqlFetchArray($res)) {
333 $no_of_items = addslashes($row['count']);
336 if ($no_of_items <= 1) {
337 //start new search - no patient record fount
338 $query = "update de_identification_status set status = 0";
339 $res = sqlStatement($query);
341 <table
> <tr
> <td
> 
;</td
> <td
> 
;</td
> </tr
>
342 <tr
> <td
> 
;</td
> <td
> 
;</td
> </tr
>
344 <table
class="de_identification_status_message" align
="center" >
350 <?php
echo xl('No Patient record found for given Selection criteria');
352 echo xl('Please start new De Identification process');
353 echo "</br>"; ?
> </br
>
357 <tr
> <td
> 
;</td
> <td
> 
;</td
> </tr
>
359 <tr
> <td
> 
;</td
> <td
> 
;</td
> </tr
>
362 <table align
="center">
363 <tr
> <td
> 
;</td
> <td
> 
;</td
> </tr
>
368 <table
> <tr
> <td
> 
;</td
> <td
> 
;</td
> </tr
>
369 <tr
> <td
> 
;</td
> <td
> 
;</td
> </tr
>
371 <table
class="de_identification_status_message" align
="center" >
376 <?php
echo xl('De Identification Process is completed');
378 echo xl('Please Click download button to download the De Identified data');
379 echo "</br>"; ?
> <br
>
383 <tr
> <td
> 
;</td
> <td
> 
;</td
> </tr
>
384 <tr
> <td
> 
;</td
> <td
> 
;</td
> </tr
>
386 <table align
="center">
387 <tr
> <td
> 
;</td
> <td
> 
;</td
> </tr
>
389 <td colspan
="2" class="style1">
390 <input type
="button" name
="Download" value
=<?php
echo xl("Download");?
> onclick
="download_file()" ></td
>
395 } else if ($deIdentificationStatus == 3) {
396 //3 - The De Identification process completed with error
398 <table
> <tr
> <td
> 
;</td
> <td
> 
;</td
> </tr
>
399 <tr
> <td
> 
;</td
> <td
> 
;</td
> </tr
>
401 <table
class="de_identification_status_message" align
="center" >
406 <?php
echo xl('Some error has occured during De Identification Process');
408 echo xl('De Identified data may not be complete');
410 ?
><span
class="text"><?php
echo xl('Please view De Identification error log table for more details');
411 echo "</br>"; ?
></span
> <br
>
415 <tr
> <td
> 
;</td
> <td
> 
;</td
> </tr
>
416 <tr
> <td
> 
;</td
> <td
> 
;</td
> </tr
>
418 <table align
="center">
419 <tr
> <td
> 
;</td
> <td
> 
;</td
> </tr
>
421 <td colspan
="2" class="style1">
422 <input type
="button" name
="Download" value
=<?php
echo xl("Download Anyway");?
> onclick
="download_file()"></td
>
431 if ($deIdentificationStatus == 0) {
432 //0 - There is no De Identification in progress. (start new De Identification process)
434 <div id
="overDiv" style
="position: absolute; visibility: hidden; z-index: 1000;">
436 <table style
="width: 74%" border
=0>
439 <td
><span
class="text"><?php
xl('Begin Date', 'e'); ?
></span
>
440 <input type
="text" size
="10" class="datepicker" name
="begin_date" id
="begin_date" value
="<?php echo $viewmode ? substr($result['date'], 0, 10) : date('Y-m-d'); ?>" title
="<?php xl('yyyy-mm-dd Date of service', 'e'); ?>" />
442 <td
><span
class="text"><?php
xl('End Date', 'e'); ?
></span
>
443 <input type
="text" size
="10" class="datepicker" name
="end_date" id
="end_date" value
="<?php echo $viewmode ? substr($result['date'], 0, 10) : date('Y-m-d'); ?>" title
="<?php xl('yyyy-mm-dd Date of service', 'e'); ?>" />
449 <td
> 
;</td
> </tr
>
451 <td colspan
=2 class="de_identification_input_controls_box"><input type
="checkbox" name
="unstructured" id
="unstructured" value
=<?php
echo xl("unstructured");?
>><span
class="text"><?php
xl('Include Unstructured data', 'e'); ?
></span
></td
>
456 <table
class="de_identification_input_controls_box">
458 <td
><span
class="text"><?php
xl('Select data to be included in De Identified data', 'e'); ?
></span
> <br
/>
459 <input type
="checkbox" name
="all" id
="all" value
='all' onclick
="disable_other_chkbox()"><span
class="text"><?php
xl('All', 'e'); ?
> </span
><br
/>
460 <input type
="checkbox" name
="history_data" id
="history_data" value
='history_data'><span
class="text"><?php
xl('History Data', 'e'); ?
></span
> <br
/>
461 <input type
="checkbox" name
="immunization" id
="immunization" value
="immunizations"><span
class="text"><?php
xl('Immunizations', 'e'); ?
></span
>
463 <input type
="checkbox" name
="prescriptions" id
="prescriptions" value
="prescriptions"><span
class="text"><?php
xl('Prescriptions', 'e'); ?
></span
>
467 <input type
="checkbox" name
="lists" id
="lists" value
="lists"><span
class="text"><?php
xl('Issues', 'e'); ?
> </span
><br
/>
468 <input type
="checkbox" name
="transactions" id
="transactions" value
="transactions"><span
class="text"><?php
xl('Transactions', 'e'); ?
></span
>
470 <input type
="checkbox" name
="insurance_data" id
="insurance_data" value
="insurance_data"><span
class="text"><?php
xl('Insurance Data', 'e'); ?
> </span
><br
/>
471 <input type
="checkbox" name
="billing_data" id
="billing_data" value
="billing_data"><span
class="text"><?php
xl('Billing Data', 'e'); ?
></span
> <br
/>
488 <table style
="width: 100%">
490 <!--diagnosis
--><td style
="width:50%;" class="style1"><span
class="text"><?php
xl('Enter Diagnosis', 'e'); ?
></span
>
491 <input type
="radio" id
="diagnosis" name
="diagnosis" value
="all" onclick
="disable_controls('diagnosis');" /><span
class="text"> <?php
xl('All', 'e'); ?
></span
>
492 <input type
="radio" id
="diagnosis" name
="diagnosis" value
="select_diagnosis" onclick
="enable_controls('diagnosis');" />
493 <span
class="text"><?php
xl('Select Diagnosis', 'e'); ?
></span
>
494 <select id
="diagnosis_list" name
="diagnosis_list" size
="10" style
="width: 60%">
498 <td style
="width:50%;" class="style1">
499 <!--drugs
--><span
class="text"><?php
xl('Enter Drugs', 'e'); ?
></span
>
500 <input type
="radio" id
="drugs" name
="drugs" value
="all"); onclick
="disable_controls('drugs')"/><span
class="text"> <?php
xl('All', 'e'); ?
></span
>
501 <input type
="radio" id
="drugs" name
="drugs" value
="select_drug" onclick
="enable_controls('drugs')" />
502 <span
class="text"><?php
xl('Select Drugs', 'e'); ?
> <br
></span
>
503 <select id
="drug_list" name
="drug_list" size
="10" style
="width: 60%">
508 <tr
> <td
class="style1">
509 <input type
="button" name
="add_diagnosis" id
= "add_diagnosis" value
=<?php
echo xl("Add Diagnosis"); ?
> onclick
="get_values('diagnosis')">
510 <input type
="button" name
="remove_diagnosis" id
="remove_diagnosis"value
=<?php
echo xl("Remove"); ?
> onclick
="remove_selected('diagnosis')"> 
; </td
> <td
class="style1">
511 <input type
="button" name
="add_drug" id
="add_drug" value
=<?php
echo xl("Add Drug"); ?
> onclick
="get_values('drugs')">
512 <input type
="button" name
="remove_drug" id
="remove_drug" value
=<?php
echo xl("Remove"); ?
> onclick
="remove_selected('drugs')">
520 <td colspan
="2" class="style1">
521 <!--immunizations
--><br
>
522 <span
class="text"><?php
xl('Enter Immunizations', 'e'); ?
></span
>
523 <input type
="radio" id
="immunizations" name
="immunizations" value
="all" onclick
="disable_controls('immunizations')"/><span
class="text"> <?php
xl('All', 'e'); ?
></span
>
524 <input type
="radio" id
="immunizations" name
="immunizations" value
="select_immunization" onclick
="enable_controls('immunizations')" />
525 <span
class="text"><?php
xl('Select Immunizations', 'e'); ?
></span
> <br
>
526 <select id
="immunization_list" name
="immunization_list" size
="10" width
="300" style
="width: 30%">
528 <input type
="button" name
="add_immunization" id
="add_immunization" value
=<?php
echo xl("Add Immunization"); ?
> onclick
="get_values('immunizations')">
529 <input type
="button" name
="remove_immunization" id
="remove_immunization" value
=<?php
echo xl("Remove"); ?
> onclick
="remove_selected('immunizations')">
536 <td colspan
="2" class="style1">
537 <input type
="submit" name
="Submit" value
=<?php
echo xl("Submit"); ?
> ></td
>
541 <input type
="hidden" name
="diagnosis_text" id
="diagnosis_text"><br
>
542 <input type
="hidden" name
="drug_text" id
="drug_text"><br
>
543 <input type
="hidden" name
="immunization_text" id
="immunization_text">