4 * de_identification script
7 * @link http://www.open-emr.org
8 * @author ViCarePlus, 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) 2017-2019 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("De Identification")]);
34 <title
><?php
echo xlt('De Identification'); ?
></title
>
35 <?php Header
::setupHeader('datetime-picker'); ?
>
42 //get value from popup window
43 function set_related(s
,type
) {
45 if(type
== "diagnosis")
46 list = "diagnosis_list";
47 else if(type
== "drugs")
49 else if(type
== "immunizations")
50 list = "immunization_list";
53 var elSel
= document
.getElementById(list);
55 for (i
=0;p
[i
]!=null;i++
)
57 for(k
=0;k
<elSel
.length
;k++
)
59 if((elSel
.options
[k
].value
)==p
[i
])
64 var elOptNew
= document
.createElement('option');
66 elOptNew
.value
= p
[i
];
68 elSel
.add(elOptNew
, null); // standards compliant; doesn't work in IE
71 elSel
.add(elOptNew
); // IE only
78 function get_values(type
)
80 if(type
== "diagnosis")
81 dlgopen('find_code_popup.php', '_blank', 500, 400,true);
82 else if(type
== "drugs")
83 dlgopen('find_drug_popup.php', '_blank', 500, 400,true);
84 else if(type
== "immunizations")
85 dlgopen('find_immunization_popup.php', '_blank', 500, 400,true);
88 //remove item selected from list
89 function remove_selected(type
)
92 if(type
== "diagnosis")
93 list = "diagnosis_list";
94 else if(type
== "drugs")
96 else if(type
== "immunizations")
97 list = "immunization_list";
98 var elSel
= document
.getElementById(list);
100 for (i
= elSel
.length
- 1; i
>=0; i
--) {
101 if (elSel
.options
[i
].selected
)
109 function show_value(type
)
112 if(type
== "diagnosis")
113 { radio
= "diagnosis"; list = "diagnosis_list"; text
="diagnosis_text"; }
114 else if(type
== "drugs")
115 { radio
= "drugs"; list = "drug_list"; text
="drug_text"; }
116 else if(type
== "immunizations")
117 { radio
= "immunizations"; list = "immunization_list"; text
="immunization_text"; }
118 if(document
.getElementById(radio
) == "all")
120 document
.getElementById(text
).value
="all";
125 var elSel
= document
.getElementById(list);
127 for (i
= elSel
.length
- 1; i
>=0; i
--)
130 str
= elSel
.options
[i
].value
;
132 str
= str +
"#"+elSel
.options
[i
].value
;
135 document
.getElementById(text
).value
=str
;
139 //disable - enable other checkbox when all checkbox is clicked
140 function disable_other_chkbox()
142 var value
= document
.forms
[0].all
.checked
;
145 document
.forms
[0].history_data
.disabled
= true;
146 document
.forms
[0].prescriptions
.disabled
= true;
147 document
.forms
[0].lists
.disabled
= true;
148 document
.forms
[0].immunization
.disabled
= true;
149 document
.forms
[0].transactions
.disabled
= true;
150 document
.forms
[0].billing_data
.disabled
= true;
151 document
.forms
[0].insurance_data
.disabled
= true;
155 document
.forms
[0].history_data
.disabled
= false;
156 document
.forms
[0].prescriptions
.disabled
= false;
157 document
.forms
[0].lists
.disabled
= false;
158 document
.forms
[0].immunization
.disabled
= false;
159 document
.forms
[0].transactions
.disabled
= false;
160 document
.forms
[0].billing_data
.disabled
= false;
161 document
.forms
[0].insurance_data
.disabled
= false;
165 //disable list,add button,remove button when all option is selected
166 function disable_controls(type
)
168 var list,button1
,button2
;
169 if(type
== "diagnosis")
170 { button1
= "add_diagnosis"; button2
= "remove_diagnosis"; list = "diagnosis_list"; text
="diagnosis_text"; }
171 else if(type
== "drugs")
172 { button1
= "add_drug"; button2
= "remove_drug"; list = "drug_list"; text
="drug_text";}
173 else if(type
== "immunizations")
174 { button1
= "add_immunization"; button2
= "remove_immunization"; list = "immunization_list"; text
="immunization_text"; }
175 document
.getElementById(button1
).disabled
= true;
176 document
.getElementById(button2
).disabled
= true;
177 document
.getElementById(list).disabled
= true;
178 document
.getElementById(text
).value
= "all";
181 function enable_controls(type
)
183 var list,button1
,button2
;
184 if(type
== "diagnosis")
185 { button1
= "add_diagnosis"; button2
= "remove_diagnosis"; list = "diagnosis_list"; }
186 else if(type
== "drugs")
187 { button1
= "add_drug"; button2
= "remove_drug"; list = "drug_list"; }
188 else if(type
== "immunizations")
189 { button1
= "add_immunization"; button2
= "remove_immunization"; list = "immunization_list";
191 document
.getElementById(button1
).disabled
= false;
192 document
.getElementById(button2
).disabled
= false;
193 document
.getElementById(list).disabled
= false;
198 function form_validate()
200 if(document
.forms
[0].begin_date
.value
>= document
.forms
[0].end_date
.value
)
202 alert(<?php
echo xlj('End date should be greater than Begin date'); ?
>);
206 if(document
.forms
[0].all
.checked
== false &&
207 document
.forms
[0].history_data
.checked
== false &&
208 document
.forms
[0].prescriptions
.checked
== false &&
209 document
.forms
[0].immunization
.checked
== false &&
210 document
.forms
[0].lists
.checked
== false &&
211 document
.forms
[0].transactions
.checked
== false &&
212 document
.forms
[0].billing_data
.checked
== false &&
213 document
.forms
[0].insurance_data
.checked
== false)
215 alert(<?php
echo xlj('Select Data Required for De Identification'); ?
>);
219 if(document
.forms
[0].diagnosis_text
.value
== "undefined" || document
.forms
[0].diagnosis_text
.value
== "")
221 alert(<?php
echo xlj('Select Diagnosis for De Identification request'); ?
>);
224 if(document
.forms
[0].drug_text
.value
== "undefined" || document
.forms
[0].drug_text
.value
== "")
226 alert(<?php
echo xlj('Select Drugs for De Identification request'); ?
>);
229 if(document
.forms
[0].immunization_text
.value
== "undefined" || document
.forms
[0].immunization_text
.value
== "")
231 alert(<?php
echo xlj('Select Immunizations for De Identification request'); ?
>);
234 alert(<?php
echo xlj('De Identification process is started and running in background'); ?
> +
'\n' +
<?php
echo xlj('Please visit the screen after some time'); ?
>);
235 top
.restoreSession();
239 function download_file()
241 alert(<?php
echo xlj('De-identification files will be saved in'); ?
> +
' `' +
<?php
echo js_escape($GLOBALS['temporary_files_dir']); ?
> +
'` ' +
<?php
echo xlj('location of the openemr machine and may contain sensitive data, so it is recommended to manually delete the files after its use'); ?
>);
242 document
.de_identification
.submit();
246 $
('.datepicker').datetimepicker({
247 <?php
$datetimepicker_timepicker = false; ?
>
248 <?php
$datetimepicker_showseconds = false; ?
>
249 <?php
$datetimepicker_formatInput = false; ?
>
250 <?php
require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?
>
251 <?php
// can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
257 <body
class="body_top">
258 <form name
="de_identification" id
="de_identification" action
="de_identification_screen2.php" method
="post" onsubmit
="return form_validate();">
259 <input type
="hidden" name
="csrf_token_form" value
="<?php echo attr(CsrfUtils::collectCsrfToken()); ?>" />
260 <strong
><?php
echo xlt('De Identification'); ?
></strong
>
262 $row = sqlQuery("SHOW TABLES LIKE 'de_identification_status'");
265 <table
> <tr
> <td
> 
;</td
> <td
> 
;</td
> </tr
>
266 <tr
> <td
> 
;</td
> <td
> 
;</td
> </tr
>
268 <table
class="de_identification_status_message" align
="center" >
273 <?php
echo xlt('Please upgrade OpenEMR Database to include De Identification procedures, function, tables'); ?
>
274 <br
/><br
/><a target
="Blank" href
="../../contrib/util/de_identification_upgrade.php"><?php
echo xlt('Click here');?
></a
>
275 <?php
echo xlt('to run');
276 echo " de_identification_upgrade.php<br />";?
><br
/>
291 $query = "select status from de_identification_status";
292 $res = sqlStatement($query);
293 if ($row = sqlFetchArray($res)) {
294 $deIdentificationStatus = $row['status'];
295 /* $deIdentificationStatus:
296 * 0 - There is no De Identification in progress. (start new De Identification process)
297 * 1 - A De Identification process is currently in progress.
298 * 2 - The De Identification process completed and xls file is ready to download
299 * 3 - The De Identification process completed with error
303 if ($deIdentificationStatus == 1) {
304 //1 - A De Identification process is currently in progress.
306 <table
> <tr
> <td
> 
;</td
> <td
> 
;</td
> </tr
>
307 <tr
> <td
> 
;</td
> <td
> 
;</td
> </tr
>
309 <table
class="de_identification_status_message" align
="center" >
314 <?php
echo xlt('De Identification Process is ongoing');
316 echo xlt('Please visit De Identification screen after some time');
317 echo "<br />"; ?
> <br
/>
331 } elseif ($deIdentificationStatus == 2) {
332 //2 - The De Identification process completed and xls file is ready to download
333 $query = "SELECT count(*) as count FROM de_identified_data ";
334 $res = sqlStatement($query);
335 if ($row = sqlFetchArray($res)) {
336 $no_of_items = $row['count'];
339 if ($no_of_items <= 1) {
340 //start new search - no patient record fount
341 $query = "update de_identification_status set status = 0";
342 $res = sqlStatement($query);
344 <table
> <tr
> <td
> 
;</td
> <td
> 
;</td
> </tr
>
345 <tr
> <td
> 
;</td
> <td
> 
;</td
> </tr
>
347 <table
class="de_identification_status_message" align
="center" >
353 <?php
echo xlt('No Patient record found for given Selection criteria');
355 echo xlt('Please start new De Identification process');
356 echo "<br />"; ?
> <br
/>
360 <tr
> <td
> 
;</td
> <td
> 
;</td
> </tr
>
362 <tr
> <td
> 
;</td
> <td
> 
;</td
> </tr
>
365 <table align
="center">
366 <tr
> <td
> 
;</td
> <td
> 
;</td
> </tr
>
371 <table
> <tr
> <td
> 
;</td
> <td
> 
;</td
> </tr
>
372 <tr
> <td
> 
;</td
> <td
> 
;</td
> </tr
>
374 <table
class="de_identification_status_message" align
="center" >
379 <?php
echo xlt('De Identification Process is completed');
381 echo xlt('Please Click download button to download the De Identified data');
382 echo "<br />"; ?
> <br
/>
386 <tr
> <td
> 
;</td
> <td
> 
;</td
> </tr
>
387 <tr
> <td
> 
;</td
> <td
> 
;</td
> </tr
>
389 <table align
="center">
390 <tr
> <td
> 
;</td
> <td
> 
;</td
> </tr
>
392 <td colspan
="2" class="style1">
393 <input type
="button" name
="Download" value
=<?php
echo xla("Download");?
> onclick
="download_file()" ></td
>
398 } elseif ($deIdentificationStatus == 3) {
399 //3 - The De Identification process completed with error
401 <table
> <tr
> <td
> 
;</td
> <td
> 
;</td
> </tr
>
402 <tr
> <td
> 
;</td
> <td
> 
;</td
> </tr
>
404 <table
class="de_identification_status_message" align
="center" >
409 <?php
echo xlt('Some error has occured during De Identification Process');
411 echo xlt('De Identified data may not be complete');
413 ?
><span
class="text"><?php
echo xlt('Please view De Identification error log table for more details');
414 echo "<br />"; ?
></span
> <br
/>
418 <tr
> <td
> 
;</td
> <td
> 
;</td
> </tr
>
419 <tr
> <td
> 
;</td
> <td
> 
;</td
> </tr
>
421 <table align
="center">
422 <tr
> <td
> 
;</td
> <td
> 
;</td
> </tr
>
424 <td colspan
="2" class="style1">
425 <input type
="button" name
="Download" value
=<?php
echo xla("Download Anyway");?
> onclick
="download_file()"></td
>
434 if ($deIdentificationStatus == 0) {
435 //0 - There is no De Identification in progress. (start new De Identification process)
437 <div id
="overDiv" style
="position: absolute; visibility: hidden; z-index: 1000;">
439 <table style
="width: 74%" border
=0>
442 <td
><span
class="text"><?php
echo xlt('Begin Date'); ?
></span
>
443 <input type
="text" size
="10" class="datepicker" name
="begin_date" id
="begin_date" value
="<?php echo $viewmode ? attr(substr($result['date'], 0, 10)) : date('Y-m-d'); ?>" title
="<?php echo xla('yyyy-mm-dd Date of service'); ?>" />
445 <td
><span
class="text"><?php
xl('End Date', 'e'); ?
></span
>
446 <input type
="text" size
="10" class="datepicker" name
="end_date" id
="end_date" value
="<?php echo $viewmode ? attr(substr($result['date'], 0, 10)) : date('Y-m-d'); ?>" title
="<?php echo xla('yyyy-mm-dd Date of service'); ?>" />
452 <td
> 
;</td
> </tr
>
454 <td colspan
=2 class="de_identification_input_controls_box"><input type
="checkbox" name
="unstructured" id
="unstructured" value
=<?php
echo xla("unstructured");?
>><span
class="text"><?php
echo xlt('Include Unstructured data'); ?
></span
></td
>
459 <table
class="de_identification_input_controls_box">
461 <td
><span
class="text"><?php
echo xlt('Select data to be included in De Identified data'); ?
></span
> <br
/>
462 <input type
="checkbox" name
="all" id
="all" value
='all' onclick
="disable_other_chkbox()"><span
class="text"><?php
echo xlt('All'); ?
> </span
><br
/>
463 <input type
="checkbox" name
="history_data" id
="history_data" value
='history_data'><span
class="text"><?php
echo xlt('History Data'); ?
></span
> <br
/>
464 <input type
="checkbox" name
="immunization" id
="immunization" value
="immunizations"><span
class="text"><?php
echo xlt('Immunizations'); ?
></span
>
466 <input type
="checkbox" name
="prescriptions" id
="prescriptions" value
="prescriptions"><span
class="text"><?php
echo xlt('Prescriptions'); ?
></span
>
470 <input type
="checkbox" name
="lists" id
="lists" value
="lists"><span
class="text"><?php
echo xlt('Issues'); ?
> </span
><br
/>
471 <input type
="checkbox" name
="transactions" id
="transactions" value
="transactions"><span
class="text"><?php
echo xlt('Transactions'); ?
></span
>
473 <input type
="checkbox" name
="insurance_data" id
="insurance_data" value
="insurance_data"><span
class="text"><?php
echo xlt('Insurance Data'); ?
> </span
><br
/>
474 <input type
="checkbox" name
="billing_data" id
="billing_data" value
="billing_data"><span
class="text"><?php
echo xlt('Billing Data'); ?
></span
> <br
/>
484 <td colspan
="2"><br
/>
491 <table style
="width: 100%">
493 <!--diagnosis
--><td style
="width:50%;" class="style1"><span
class="text"><?php
echo xlt('Enter Diagnosis'); ?
></span
>
494 <input type
="radio" id
="diagnosis" name
="diagnosis" value
="all" onclick
="disable_controls('diagnosis');" /><span
class="text"> <?php
echo xlt('All'); ?
></span
>
495 <input type
="radio" id
="diagnosis" name
="diagnosis" value
="select_diagnosis" onclick
="enable_controls('diagnosis');" />
496 <span
class="text"><?php
echo xlt('Select Diagnosis'); ?
></span
>
497 <select id
="diagnosis_list" name
="diagnosis_list" size
="10" style
="width: 60%">
501 <td style
="width:50%;" class="style1">
502 <!--drugs
--><span
class="text"><?php
echo xlt('Enter Drugs'); ?
></span
>
503 <input type
="radio" id
="drugs" name
="drugs" value
="all"); onclick
="disable_controls('drugs')"/><span
class="text"> <?php
echo xlt('All'); ?
></span
>
504 <input type
="radio" id
="drugs" name
="drugs" value
="select_drug" onclick
="enable_controls('drugs')" />
505 <span
class="text"><?php
echo xlt('Select Drugs'); ?
> <br
/></span
>
506 <select id
="drug_list" name
="drug_list" size
="10" style
="width: 60%">
511 <tr
> <td
class="style1">
512 <input type
="button" name
="add_diagnosis" id
= "add_diagnosis" value
=<?php
echo xla("Add Diagnosis"); ?
> onclick
="get_values('diagnosis')">
513 <input type
="button" name
="remove_diagnosis" id
="remove_diagnosis"value
=<?php
echo xla("Remove"); ?
> onclick
="remove_selected('diagnosis')"> 
; </td
> <td
class="style1">
514 <input type
="button" name
="add_drug" id
="add_drug" value
=<?php
echo xla("Add Drug"); ?
> onclick
="get_values('drugs')">
515 <input type
="button" name
="remove_drug" id
="remove_drug" value
=<?php
echo xla("Remove"); ?
> onclick
="remove_selected('drugs')">
523 <td colspan
="2" class="style1">
524 <!--immunizations
--><br
/>
525 <span
class="text"><?php
echo xlt('Enter Immunizations'); ?
></span
>
526 <input type
="radio" id
="immunizations" name
="immunizations" value
="all" onclick
="disable_controls('immunizations')"/><span
class="text"> <?php
echo xlt('All'); ?
></span
>
527 <input type
="radio" id
="immunizations" name
="immunizations" value
="select_immunization" onclick
="enable_controls('immunizations')" />
528 <span
class="text"><?php
echo xlt('Select Immunizations'); ?
></span
> <br
/>
529 <select id
="immunization_list" name
="immunization_list" size
="10" width
="300" style
="width: 30%">
531 <input type
="button" name
="add_immunization" id
="add_immunization" value
="<?php echo xla("Add Immunization
"); ?>" onclick
="get_values('immunizations')">
532 <input type
="button" name
="remove_immunization" id
="remove_immunization" value
="<?php echo xla("Remove
"); ?>" onclick
="remove_selected('immunizations')">
539 <td colspan
="2" class="style1">
540 <input type
="submit" name
="Submit" value
="<?php echo xla("Submit
"); ?>" ></td
>
544 <input type
="hidden" name
="diagnosis_text" id
="diagnosis_text"><br
/>
545 <input type
="hidden" name
="drug_text" id
="drug_text"><br
/>
546 <input type
="hidden" name
="immunization_text" id
="immunization_text">