CCR Import, made changes per comments in github.
[openemr.git] / interface / de_identification_forms / de_identification_screen1.php
blobdec0c8e9633585c31bb4e9309d0fef4938965541
1 <?php
2 /********************************************************************************\
3 * Copyright (C) ViCarePlus, Visolve (vicareplus_engg@visolve.com) *
4 * *
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. *
9 * *
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. *
14 * *
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");
27 <html>
28 <head>
29 <title><?php xl('De Identification','e'); ?></title>
30 <link rel="stylesheet" href='<?php echo $css_header ?>' type='text/css'>
31 <link rel="stylesheet" href='<?php echo $GLOBALS['webroot'] ?>/library/dynarch_calendar.css' type='text/css'>
32 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/dialog.js"></script>
33 <style type="text/css">
34 .style1 {
35 text-align: center;
36 }</style>
37 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/dynarch_calendar.js"></script>
38 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/dynarch_calendar_en.js"></script>
39 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/dynarch_calendar_setup.js"></script>
40 <script language="JavaScript">
41 //get value from popup window
42 function set_related(s,type) {
43 var list;
44 if(type == "diagnosis")
45 list = "diagnosis_list";
46 else if(type == "drugs")
47 list = "drug_list";
48 else if(type == "immunizations")
49 list = "immunization_list";
51 var p=s.split("#");
52 var elSel = document.getElementById(list);
53 var i,k;
54 for (i=0;p[i]!=null;i++)
56 for(k=0;k<elSel.length;k++)
58 if((elSel.options[k].value)==p[i])
59 p[i]= " ";
61 if(p[i]!= " ")
63 var elOptNew = document.createElement('option');
64 elOptNew.text = p[i];
65 elOptNew.value = p[i];
66 try {
67 elSel.add(elOptNew, null); // standards compliant; doesn't work in IE
69 catch(ex) {
70 elSel.add(elOptNew); // IE only
74 show_value(type);
77 function get_values(type)
79 if(type == "diagnosis")
80 dlgopen('find_code_popup.php', '_blank', 500, 400);
81 else if(type == "drugs")
82 dlgopen('find_drug_popup.php', '_blank', 500, 400);
83 else if(type == "immunizations")
84 dlgopen('find_immunization_popup.php', '_blank', 500, 400);
87 //remove item selected from list
88 function remove_selected(type)
90 var list;
91 if(type == "diagnosis")
92 list = "diagnosis_list";
93 else if(type == "drugs")
94 list = "drug_list";
95 else if(type == "immunizations")
96 list = "immunization_list";
97 var elSel = document.getElementById(list);
98 var i;
99 for (i = elSel.length - 1; i>=0; i--) {
100 if (elSel.options[i].selected)
102 elSel.remove(i);
105 show_value(type);
108 function show_value(type)
110 var list,text,radio;
111 if(type == "diagnosis")
112 { radio = "diagnosis"; list = "diagnosis_list"; text="diagnosis_text"; }
113 else if(type == "drugs")
114 { radio = "drugs"; list = "drug_list"; text="drug_text"; }
115 else if(type == "immunizations")
116 { radio = "immunizations"; list = "immunization_list"; text="immunization_text"; }
117 if(document.getElementById(radio) == "all")
119 document.getElementById(text).value="all";
121 else
123 var str;
124 var elSel = document.getElementById(list);
125 var i;
126 for (i = elSel.length - 1; i>=0; i--)
128 if(!str)
129 str = elSel.options[i].value;
130 else
131 str = str +"#"+elSel.options[i].value;
134 document.getElementById(text).value=str;
138 //disable - enable other checkbox when all checkbox is clicked
139 function disable_other_chkbox()
141 var value = document.forms[0].all.checked;
142 if(value == 1)
144 document.forms[0].history_data.disabled = true;
145 document.forms[0].prescriptions.disabled = true;
146 document.forms[0].lists.disabled = true;
147 document.forms[0].immunization.disabled = true;
148 document.forms[0].transactions.disabled = true;
149 document.forms[0].billing_data.disabled = true;
150 document.forms[0].insurance_data.disabled = true;
152 else
154 document.forms[0].history_data.disabled = false;
155 document.forms[0].prescriptions.disabled = false;
156 document.forms[0].lists.disabled = false;
157 document.forms[0].immunization.disabled = false;
158 document.forms[0].transactions.disabled = false;
159 document.forms[0].billing_data.disabled = false;
160 document.forms[0].insurance_data.disabled = false;
164 //disable list,add button,remove button when all option is selected
165 function disable_controls(type)
167 var list,button1,button2;
168 if(type == "diagnosis")
169 { button1 = "add_diagnosis"; button2 = "remove_diagnosis"; list = "diagnosis_list"; text="diagnosis_text"; }
170 else if(type == "drugs")
171 { button1 = "add_drug"; button2 = "remove_drug"; list = "drug_list"; text="drug_text";}
172 else if(type == "immunizations")
173 { button1 = "add_immunization"; button2 = "remove_immunization"; list = "immunization_list"; text="immunization_text"; }
174 document.getElementById(button1).disabled = true;
175 document.getElementById(button2).disabled = true;
176 document.getElementById(list).disabled = true;
177 document.getElementById(text).value = "all";
180 function enable_controls(type)
182 var list,button1,button2;
183 if(type == "diagnosis")
184 { button1 = "add_diagnosis"; button2 = "remove_diagnosis"; list = "diagnosis_list"; }
185 else if(type == "drugs")
186 { button1 = "add_drug"; button2 = "remove_drug"; list = "drug_list"; }
187 else if(type == "immunizations")
188 { button1 = "add_immunization"; button2 = "remove_immunization"; list = "immunization_list";
190 document.getElementById(button1).disabled = false;
191 document.getElementById(button2).disabled = false;
192 document.getElementById(list).disabled = false;
193 show_value(type);
197 function form_validate()
199 if(document.forms[0].begin_date.value >= document.forms[0].end_date.value)
201 alert("<?php echo xl('End date should be greater than Begin date');?>");
202 return false;
205 if(document.forms[0].all.checked == false &&
206 document.forms[0].history_data.checked == false &&
207 document.forms[0].prescriptions.checked == false &&
208 document.forms[0].immunization.checked == false &&
209 document.forms[0].lists.checked == false &&
210 document.forms[0].transactions.checked == false &&
211 document.forms[0].billing_data.checked == false &&
212 document.forms[0].insurance_data.checked == false)
214 alert("<?php echo xl('Select Data Required for De Identification');?>");
215 return false;
218 if(document.forms[0].diagnosis_text.value == "undefined" || document.forms[0].diagnosis_text.value == "")
220 alert("<?php echo xl('Select Diagnosis for De Identification request');?>");
221 return false;
223 if(document.forms[0].drug_text.value == "undefined" || document.forms[0].drug_text.value == "")
225 alert("<?php echo xl('Select Drugs for De Identification request');?>");
226 return false;
228 if(document.forms[0].immunization_text.value == "undefined" || document.forms[0].immunization_text.value == "")
230 alert("<?php echo xl('Select Immunizations for De Identification request');?>");
231 return false;
233 alert("<?php echo xl('De Identification process is started and running in background'); echo '\n'; echo xl('Please visit the screen after some time');?>");
234 top.restoreSession();
235 return true;
238 function download_file()
240 alert("<?php echo xl('De-identification files will be saved in'); echo ' `'.$GLOBALS['temporary_files_dir'].'` '; echo xl('location of the openemr machine and may contain sensitive data, so it is recommended to manually delete the files after its use');?>");
241 document.de_identification.submit();
244 </script>
245 </head>
246 <body class="body_top">
247 <form name="de_identification" id="de_identification" action="de_identification_screen2.php" method="post" onsubmit="return form_validate();">
248 <strong><?php xl('De Identification','e'); ?></strong>
249 <?php
250 $row = sqlQuery("SHOW TABLES LIKE 'de_identification_status'");
251 if (empty($row))
254 <table> <tr> <td>&nbsp;</td> <td>&nbsp;</td> </tr>
255 <tr> <td>&nbsp;</td> <td>&nbsp;</td> </tr>
256 </table>
257 <table class="de_identification_status_message" align="center" >
258 <tr valign="top">
259 <td>&nbsp;</td>
260 <td rowspan="3">
261 <br>
262 <?php echo xl('Please upgrade OpenEMR Database to include De Identification procedures, function, tables'); ?>
263 </br></br><a target="Blank" href="../../contrib/util/de_identification_upgrade.php"><?php echo xl('Click here');?></a>
264 <?php echo xl('to run');
265 echo " de_identification_upgrade.php</br>";?><br>
266 </td>
267 <td>&nbsp;</td>
268 </tr>
269 <tr>
270 <td>&nbsp;</td>
271 <td>&nbsp;</td>
272 </tr>
273 <tr>
274 <td>&nbsp;</td>
275 <td>&nbsp;</td>
276 </tr>
277 </table>
278 <?php
280 else {
281 $query = "select status from de_identification_status";
282 $res = sqlStatement($query);
283 if ($row = sqlFetchArray($res))
285 $deIdentificationStatus = addslashes($row['status']);
286 /* $deIdentificationStatus:
287 * 0 - There is no De Identification in progress. (start new De Identification process)
288 * 1 - A De Identification process is currently in progress.
289 * 2 - The De Identification process completed and xls file is ready to download
290 * 3 - The De Identification process completed with error
293 if($deIdentificationStatus == 1)
295 //1 - A De Identification process is currently in progress.
297 <table> <tr> <td>&nbsp;</td> <td>&nbsp;</td> </tr>
298 <tr> <td>&nbsp;</td> <td>&nbsp;</td> </tr>
299 </table>
300 <table class="de_identification_status_message" align="center" >
301 <tr valign="top">
302 <td>&nbsp;</td>
303 <td rowspan="3">
304 <br>
305 <?php echo xl('De Identification Process is ongoing');
306 echo "</br></br>";
307 echo xl('Please visit De Identification screen after some time');
308 echo "</br>"; ?> <br>
309 </td>
310 <td>&nbsp;</td>
311 </tr>
312 <tr>
313 <td>&nbsp;</td>
314 <td>&nbsp;</td>
315 </tr>
316 <tr>
317 <td>&nbsp;</td>
318 <td>&nbsp;</td>
319 </tr>
320 </table>
321 <?php
323 else if($deIdentificationStatus == 2)
325 //2 - The De Identification process completed and xls file is ready to download
326 $query = "SELECT count(*) as count FROM de_identified_data ";
327 $res = sqlStatement($query);
328 if ($row = sqlFetchArray($res))
330 $no_of_items = addslashes($row['count']);
332 if($no_of_items <= 1)
334 //start new search - no patient record fount
335 $query = "update de_identification_status set status = 0";
336 $res = sqlStatement($query);
338 <table> <tr> <td>&nbsp;</td> <td>&nbsp;</td> </tr>
339 <tr> <td>&nbsp;</td> <td>&nbsp;</td> </tr>
340 </table>
341 <table class="de_identification_status_message" align="center" >
342 <tr valign="top">
344 <td>&nbsp;</td>
345 <td rowspan="3">
346 <br>
347 <?php echo xl('No Patient record found for given Selection criteria');
348 echo "</br></br>";
349 echo xl('Please start new De Identification process');
350 echo "</br>"; ?> </br>
351 </td>
352 <td>&nbsp;</td>
353 </tr>
354 <tr> <td>&nbsp;</td> <td>&nbsp;</td> </tr>
356 <tr> <td>&nbsp;</td> <td>&nbsp;</td> </tr>
357 </table>
359 <table align="center">
360 <tr> <td>&nbsp;</td> <td>&nbsp;</td> </tr>
361 </table>
362 <?php
364 else {
366 <table> <tr> <td>&nbsp;</td> <td>&nbsp;</td> </tr>
367 <tr> <td>&nbsp;</td> <td>&nbsp;</td> </tr>
368 </table>
369 <table class="de_identification_status_message" align="center" >
370 <tr valign="top">
371 <td>&nbsp;</td>
372 <td rowspan="3">
373 <br>
374 <?php echo xl('De Identification Process is completed');
375 echo "</br></br>";
376 echo xl('Please Click download button to download the De Identified data');
377 echo "</br>"; ?> <br>
378 </td>
379 <td>&nbsp;</td>
380 </tr>
381 <tr> <td>&nbsp;</td> <td>&nbsp;</td> </tr>
382 <tr> <td>&nbsp;</td> <td>&nbsp;</td> </tr>
383 </table>
384 <table align="center">
385 <tr> <td>&nbsp;</td> <td>&nbsp;</td> </tr>
386 <tr>
387 <td colspan="2" class="style1">
388 <input type="button" name="Download" value=<?php echo xl("Download");?> onclick="download_file()" ></td>
389 </tr>
390 </table>
391 <?php
394 else if($deIdentificationStatus == 3)
396 //3 - The De Identification process completed with error
398 <table> <tr> <td>&nbsp;</td> <td>&nbsp;</td> </tr>
399 <tr> <td>&nbsp;</td> <td>&nbsp;</td> </tr>
400 </table>
401 <table class="de_identification_status_message" align="center" >
402 <tr valign="top">
403 <td>&nbsp;</td>
404 <td rowspan="3">
405 <br>
406 <?php echo xl('Some error has occured during De Identification Process');
407 echo "</br></br>";
408 echo xl('De Identified data may not be complete');
409 echo "</br></br>";
410 ?><span class="text"><?php echo xl('Please view De Identification error log table for more details');
411 echo "</br>"; ?></span> <br>
412 </td>
413 <td>&nbsp;</td>
414 </tr>
415 <tr> <td>&nbsp;</td> <td>&nbsp;</td> </tr>
416 <tr> <td>&nbsp;</td> <td>&nbsp;</td> </tr>
417 </table>
418 <table align="center">
419 <tr> <td>&nbsp;</td> <td>&nbsp;</td> </tr>
420 <tr>
421 <td colspan="2" class="style1">
422 <input type="button" name="Download" value=<?php echo xl("Download Anyway");?> onclick="download_file()"></td>
423 </tr>
424 </table>
425 </tr>
426 </table>
428 <?php
430 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;">
435 </div>
436 <table style="width: 74%" border=0>
437 <tr rowspan=2>
438 <td>&nbsp;</td>
439 <td><span class="text"><?php xl('Begin Date','e'); ?></span>
440 <input type="text" size="10" 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'); ?>" onkeyup="datekeyup(this,mypcc)" onblur="dateblur(this,mypcc)" />
441 <img src="../pic/show_calendar.gif" align="absbottom" width="24" height="22" id="img_begin_date" border="0" alt="[?]" style="cursor: pointer; cursor: hand" title="<?php xl('Click here to choose a date','e'); ?>">&nbsp;
442 </td>
443 <td><span class="text"><?php xl('End Date','e'); ?></span>
444 <input type="text" size="10" 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'); ?>" onkeyup="datekeyup(this,mypcc)" onblur="dateblur(this,mypcc)" />
445 <img src="../pic/show_calendar.gif" align="absbottom" width="24" height="22" id="img_end_date" border="0" alt="[?]" style="cursor: pointer; cursor: hand" title="<?php xl('Click here to choose a date','e'); ?>">
446 </td>
447 <td>&nbsp;</td>
448 <td>&nbsp;</td>
449 </tr>
450 <tr>
451 <td>&nbsp;</td> </tr>
452 <tr><td>&nbsp;</td>
453 <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>
454 <td>&nbsp;</td></tr>
455 <tr>
456 <td>&nbsp;</td>
457 <td colspan="2">
458 <table class="de_identification_input_controls_box">
459 <tr>
460 <td><span class="text"><?php xl('Select data to be included in De Identified data','e'); ?></span> <br />
461 <input type="checkbox" name="all" id ="all" value='all' onclick="disable_other_chkbox()"><span class="text"><?php xl('All','e'); ?> </span><br />
462 <input type="checkbox" name="history_data" id="history_data" value='history_data'><span class="text"><?php xl('History Data','e'); ?></span> <br />
463 <input type="checkbox" name="immunization" id="immunization" value="immunizations"><span class="text"><?php xl('Immunizations','e'); ?></span>
464 <br />
465 <input type="checkbox" name="prescriptions" id="prescriptions" value="prescriptions"><span class="text"><?php xl('Prescriptions','e'); ?></span>
467 &nbsp;</td> <br />
468 <td><br>
469 <input type="checkbox" name="lists" id="lists" value="lists"><span class="text"><?php xl('Issues','e'); ?> </span><br />
470 <input type="checkbox" name="transactions" id="transactions" value="transactions"><span class="text"><?php xl('Transactions','e'); ?></span>
471 <br />
472 <input type="checkbox" name="insurance_data" id="insurance_data" value="insurance_data"><span class="text"><?php xl('Insurance Data','e'); ?> </span><br />
473 <input type="checkbox" name="billing_data" id="billing_data" value="billing_data"><span class="text"><?php xl('Billing Data','e'); ?></span> <br />
475 &nbsp;</td>
476 </tr>
477 </table>
478 </td>
479 <td>&nbsp;</td>
480 </tr>
481 <tr>
482 <td>&nbsp;</td>
483 <td colspan="2"><br>
484 </td>
485 <td>&nbsp;</td>
486 </tr>
487 <tr>
488 <td>&nbsp;</td>
489 <td colspan="3">
490 <table style="width: 100%">
491 <tr valign="top">
492 <!--diagnosis--><td style="width:50%;" class="style1"><span class="text"><?php xl('Enter Diagnosis','e'); ?></span>
493 <input type="radio" id="diagnosis" name="diagnosis" value="all" onclick="disable_controls('diagnosis');" /><span class="text"> <?php xl('All','e'); ?></span>
494 <input type="radio" id="diagnosis" name="diagnosis" value="select_diagnosis" onclick="enable_controls('diagnosis');" />
495 <span class="text"><?php xl('Select Diagnosis','e'); ?></span>
496 <select id="diagnosis_list" name="diagnosis_list" size="10" style="width: 60%">
497 </select>
499 </td>
500 <td style="width:50%;" class="style1">
501 <!--drugs--><span class="text"><?php xl('Enter Drugs','e'); ?></span>
502 <input type="radio" id="drugs" name="drugs" value="all"); onclick="disable_controls('drugs')"/><span class="text"> <?php xl('All','e'); ?></span>
503 <input type="radio" id="drugs" name="drugs" value="select_drug" onclick="enable_controls('drugs')" />
504 <span class="text"><?php xl('Select Drugs','e'); ?> <br></span>
505 <select id="drug_list" name="drug_list" size="10" style="width: 60%">
506 </select>
508 </td>
509 </tr>
510 <tr> <td class="style1">
511 <input type="button" name="add_diagnosis" id = "add_diagnosis" value=<?php echo xl("Add Diagnosis"); ?> onclick="get_values('diagnosis')">
512 <input type="button" name="remove_diagnosis" id="remove_diagnosis"value=<?php echo xl("Remove"); ?> onclick="remove_selected('diagnosis')">&nbsp; </td> <td class="style1">
513 <input type="button" name="add_drug" id="add_drug" value=<?php echo xl("Add Drug"); ?> onclick="get_values('drugs')">
514 <input type="button" name="remove_drug" id="remove_drug" value=<?php echo xl("Remove"); ?> onclick="remove_selected('drugs')">
515 </td> </tr>
516 </table>
517 </td>
518 <td>&nbsp;</td>
519 </tr>
520 <tr>
521 <td>&nbsp;</td>
522 <td colspan="2" class="style1">
523 <!--immunizations--><br>
524 <span class="text"><?php xl('Enter Immunizations','e'); ?></span>
525 <input type="radio" id="immunizations" name="immunizations" value="all" onclick="disable_controls('immunizations')"/><span class="text"> <?php xl('All','e'); ?></span>
526 <input type="radio" id="immunizations" name="immunizations" value="select_immunization" onclick="enable_controls('immunizations')" />
527 <span class="text"><?php xl('Select Immunizations','e'); ?></span> <br>
528 <select id="immunization_list" name="immunization_list" size="10" width="300" style="width: 30%">
529 </select> <br>
530 <input type="button" name="add_immunization" id="add_immunization" value=<?php echo xl("Add Immunization"); ?> onclick="get_values('immunizations')">
531 <input type="button" name="remove_immunization" id="remove_immunization" value=<?php echo xl("Remove"); ?> onclick="remove_selected('immunizations')">
532 <br>
533 &nbsp;</td>
534 <td>&nbsp;</td>
535 </tr>
536 <tr>
537 <td>&nbsp;</td>
538 <td colspan="2" class="style1">
539 <input type="submit" name="Submit" value=<?php echo xl("Submit"); ?> ></td>
540 <td>&nbsp;</td>
541 </tr>
543 <input type="hidden" name="diagnosis_text" id="diagnosis_text"><br>
544 <input type="hidden" name="drug_text" id="drug_text"><br>
545 <input type="hidden" name="immunization_text" id="immunization_text">
546 </table>
547 <script language='JavaScript'>
548 /* required for popup calendar */
549 Calendar.setup({inputField:"begin_date", ifFormat:"%Y-%m-%d", button:"img_begin_date"});
550 Calendar.setup({inputField:"end_date", ifFormat:"%Y-%m-%d", button:"img_end_date"});
551 </script>
552 <?php
557 </form>
558 </body>
559 </html>