Fix some missing updates (#1373)
[openemr.git] / portal / report / portal_patient_report.php
blobf97fa42706212d8ef130992441b5bf2b1a214e8f
1 <?php
2 /**
4 * Copyright (C) 2016-2017 Jerry Padgett <sjpadgett@gmail.com>
6 * LICENSE: This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Affero General Public License as
8 * published by the Free Software Foundation, either version 3 of the
9 * License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Affero General Public License for more details.
16 * You should have received a copy of the GNU Affero General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 * @package OpenEMR
20 * @author Jerry Padgett <sjpadgett@gmail.com>
21 * @link http://www.open-emr.org
24 session_start();
26 //landing page definition -- where to go if something goes wrong
27 $landingpage = "../index.php?site=".$_SESSION['site_id'];
30 // kick out if patient not authenticated
31 if (isset($_SESSION['pid']) && isset($_SESSION['patient_portal_onsite_two'])) {
32 $pid = $_SESSION['pid'];
33 $user = $_SESSION['sessionUser'];
34 } else {
35 session_destroy();
36 header('Location: '.$landingpage.'&w');
37 exit;
40 $ignoreAuth = true;
41 global $ignoreAuth;
43 require_once('../../interface/globals.php');
44 require_once("$srcdir/lists.inc");
45 require_once("$srcdir/acl.inc");
46 require_once("$srcdir/forms.inc");
47 require_once("$srcdir/patient.inc");
48 require_once("$srcdir/formatting.inc.php");
50 // get various authorization levels
51 $auth_notes_a = true; //acl_check('encounters', 'notes_a');
52 $auth_notes = true; //acl_check('encounters', 'notes');
53 $auth_coding_a = true; //acl_check('encounters', 'coding_a');
54 $auth_coding = true; //acl_check('encounters', 'coding');
55 $auth_relaxed = true; //acl_check('encounters', 'relaxed');
56 $auth_med = true; //acl_check('patients' , 'med');
57 $auth_demo = true; //acl_check('patients' , 'demo');
59 $cmsportal = false;
60 if ($GLOBALS['gbl_portal_cms_enable']) {
61 $ptdata = getPatientData($pid, 'cmsportal_login');
62 $cmsportal = $ptdata['cmsportal_login'] !== '';
65 $ignoreAuth = 1;
68 <script type="text/javascript" src="../library/textformat.js?v=<?php echo $v_js_includes; ?>"></script>
70 <style>
71 input[type="checkbox"], input[type="radio"] {
72 margin: 0 5px 5px;
73 line-height: normal;
75 /*=============================================================
76 * Patient Reports
77 * seen in the patient reports screens
78 *============================================================*/
79 #patient_reports {
80 width: 100%;
82 #patient_reports .issues {
83 padding-right: 30px;
85 #patient_reports .issues table {
86 margin: 10px 0px 10px 0px;
88 #patient_reports .issues td {
89 padding: 2px;
91 #patient_reports .encounters td {
92 padding: 2px;
94 #patient_reports .encounter_forms {
95 margin: 5px 15px 5px 15px;
97 #patient_reports td {
98 vertical-align: top;
100 #patient_reports ul {
101 list-style: none;
104 /*=============================================================
105 * Report - Custom
106 * seen as the patient report (portal_custom_report.php)
107 *============================================================*/
108 #report_custom {
109 width: 100%;
111 #report_custom hr {
112 border: 2px dotted black;
114 #report_custom .billing {
115 margin: 5px;
116 padding: 5px;
118 #report_custom h1 {
119 font-size: 120%;
120 margin: 0px 0px 5px 0px;
121 padding: 0px;
123 #report_custom .immunizations {
124 margin: 5px;
125 padding: 5px;
127 #report_custom .notes {
128 margin: 5px;
129 padding: 5px;
131 #report_custom .transactions {
132 margin: 5px;
133 padding: 5px;
135 #report_custom .communications {
136 margin: 5px;
137 padding: 5px;
139 #report_custom .documents {
140 margin: 5px;
141 padding: 5px;
143 #report_custom .demographics {
144 margin: 5px;
145 padding: 5px;
147 #report_custom .insurance {
148 margin: 5px;
149 padding: 5px;
151 #report_custom .history {
152 margin: 5px;
153 padding: 5px;
155 #report_custom .issue {
156 margin-left: 20px;
158 #report_custom .issue_type {
159 font-weight: bold;
160 padding: 5px 0px 5px 0px;
162 #report_custom .issue_diag {
163 margin: 0px 20px 0px 20px;
165 #report_custom .encounter {
166 width: 100%;
167 border-top: 2px dotted black;
168 padding: 10px 5px 10px 5px;
169 margin-top: 10px;
171 #report_custom .encounter h1 {
172 font-size: 140%;
173 margin: 0px;
174 padding: 0px;
176 #report_custom .encounter_form {
177 margin: 10px;
178 padding: 10px;
179 border-top: 1px solid gray;
182 #addressbook_list tr.evenrow {
183 background-color: #ddddff;
186 #addressbook_list tr.oddrow {
187 background-color: #ffffff;
190 tr.odd, td.even {
191 background-color: #ffffff !important;
194 </style>
196 <script>
198 function checkAll(check) {
199 var f = document.forms['report_form'];
200 for (var i = 0; i < f.elements.length; ++i) {
201 if (f.elements[i].type == 'checkbox') f.elements[i].checked = check;
203 return false;
206 function show_date_fun(){
207 if(document.getElementById('show_date').checked == true){
208 document.getElementById('date_div').style.display = '';
209 }else{
210 document.getElementById('date_div').style.display = 'none';
212 return;
214 var mypcc = '<?php echo $GLOBALS['phone_country_code']; ?>';
215 </script>
217 <body class="body_top">
218 <div id="patient_reports"> <!-- large outer DIV -->
220 <?php if ($GLOBALS['activate_ccr_ccd_report']) { // show CCR/CCD reporting options ?>
221 <div id="ccr_report">
223 <form name='ccr_form' id='ccr_form' method='post' action="../ccr/createCCR.php?portal_auth_two=1">
224 <span class='title'><?php echo xlt('Continuity of Care Record (CCR)'); ?></span>&nbsp;&nbsp;
225 <br/>
226 <span class='text'>(<?php echo xlt('Pop ups need to be enabled to see these reports'); ?>)</span>
227 <br/>
228 <br/>
229 <input type='hidden' name='ccrAction'>
230 <input type='hidden' name='raw'>
231 <input type="checkbox" name="show_date" id="show_date" onchange="show_date_fun();" ><span class='text'><?php echo xlt('Use Date Range'); ?></span>
232 <br>
233 <div id="date_div" style="display:none" >
234 <br>
235 <table border="0" cellpadding="0" cellspacing="0" >
236 <tr>
237 <td>
238 <span class='bold'><?php echo xlt('Start Date');?>: </span>
239 </td>
240 <td>
241 <input type='text' size='10' name='Start' id='Start'
242 class='datepicker'
243 title='<?php echo xla('yyyy-mm-dd'); ?>' />
244 </td>
245 <td>
246 &nbsp;
247 <span class='bold'><?php echo xlt('End Date');?>: </span>
248 </td>
249 <td>
250 <input type='text' size='10' name='End' id='End'
251 class='datepicker'
252 title='<?php echo xla('yyyy-mm-dd'); ?>' />
253 </td>
254 </tr>
255 </table>
256 </div>
257 <br>
259 <!-- <button data-target="#reportdialog" data-toggle="modal" class="btn btn-default">
260 <?php //echo xla('Generate Report'); ?></button> -->
261 <input type="button" class="generateCCR" value="<?php echo xla('Generate Report'); ?>" />
262 <!-- <input type="button" class="generateCCR_download_h" value="<?php echo xl('Download')." (Hybrid)"; ?>" /> -->
263 <input type="button" class="generateCCR_download_p" value="<?php echo xlt('Download'); ?>" />
264 <?php if ($GLOBALS['phimail_enable']==true && $GLOBALS['phimail_ccr_enable']==true) { ?>
265 <input type="button" class="viewCCR_send_dialog" value="<?php echo xlt('Transmit'); ?>" />
266 <br>
267 <div id="ccr_send_dialog" style="display:none" >
268 <br>
269 <table border="0" cellpadding="0" cellspacing="0" >
270 <tr>
271 <td>
272 <span class='bold'><?php echo xlt('Enter Recipient\'s Direct Address');?>: </span>
273 <input type="text" size="64" name="ccr_send_to" id="ccr_send_to" value="">
274 <input type="hidden" name="ccr_sent_by" id="ccr_sent_by" value="user">
275 <input type="button" class="viewCCR_transmit" value="<?php echo xlt('Send'); ?>" />
276 <div id="ccr_send_result" style="display:none" >
277 <span class="text" id="ccr_send_message"></span>
278 </div>
279 </td>
280 </tr>
281 </table>
282 </div>
283 <?php } ?>
284 <hr/>
285 <span class='title'><?php echo xlt('Continuity of Care Document (CCD)'); ?></span>&nbsp;&nbsp;
286 <br/>
287 <span class='text'>(<?php echo xlt('Pop ups need to be enabled to see these reports'); ?>)</span>
288 <br/>
289 <br/>
290 <input type="button" class="viewCCD" value="<?php echo xla('Generate Report'); ?>" />
291 <input type="button" class="viewCCD_download" value="<?php echo xlt('Download'); ?>" />
292 <?php if ($GLOBALS['phimail_enable']==true && $GLOBALS['phimail_ccd_enable']==true) { ?>
293 <input type="button" class="viewCCD_send_dialog" value="<?php echo xlt('Transmit'); ?>" />
294 <br>
295 <div id="ccd_send_dialog" style="display:none" >
296 <br>
297 <table border="0" cellpadding="0" cellspacing="0" >
298 <tr>
299 <td>
300 <span class='bold'><?php echo xlt('Enter Recipient\'s Direct Address');?>: </span>
301 <input type="text" size="64" name="ccd_send_to" id="ccd_send_to" value="">
302 <input type="hidden" name="ccd_sent_by" id="ccd_sent_by" value="user">
303 <input type="button" class="viewCCD_transmit" value="<?php echo xlt('Send'); ?>" />
304 <div id="ccd_send_result" style="display:none" >
305 <span class="text" id="ccd_send_message"></span>
306 </div>
307 </td>
308 </tr>
309 </table>
310 </div>
311 <?php } ?>
313 </form>
315 <hr/>
317 </div>
318 <?php } // end CCR/CCD reporting options ?>
320 <form name='report_form' id="report_form" method='post' action='./report/portal_custom_report.php'>
322 <span class='panel-heading'><?php echo xlt('Patient Report'); ?></span>&nbsp;&nbsp;
323 <a class="link_submit" href="#" onclick="return checkAll(true)"><?php echo xlt('Check All'); ?></a>
325 <a class="link_submit" href="#" onclick="return checkAll(false)"><?php echo xlt('Clear All'); ?></a>
328 <table class="table includes">
329 <tr>
330 <td class='text'>
331 <input type='checkbox' name='include_demographics' id='include_demographics' value="demographics" checked><?php echo xlt('Demographics'); ?><br>
332 <input type='checkbox' name='include_history' id='include_history' value="history"><?php echo xlt('History'); ?><br>
333 <input type='checkbox' name='include_insurance' id='include_insurance' value="insurance"><?php echo xlt('Insurance'); ?><br>
334 <input type='checkbox' name='include_billing' id='include_billing' value="billing"
335 <?php if (!$GLOBALS['simplified_demographics']) {
336 echo 'checked';
337 } ?>><?php echo xlt('Billing'); ?><br>
338 </td>
339 <td class='text'>
340 <!--
341 <input type='checkbox' name='include_allergies' id='include_allergies' value="allergies">Allergies<br>
342 <input type='checkbox' name='include_medications' id='include_medications' value="medications">Medications<br>
344 <input type='checkbox' name='include_immunizations' id='include_immunizations' value="immunizations"><?php echo xlt('Immunizations'); ?><br>
345 <!--
346 <input type='checkbox' name='include_medical_problems' id='include_medical_problems' value="medical_problems">Medical Problems<br>
348 <input type='checkbox' name='include_notes' id='include_notes' value="notes"><?php echo xlt('Patient Notes'); ?><br>
349 <input type='checkbox' name='include_transactions' id='include_transactions' value="transactions"><?php echo xlt('Transactions'); ?><br>
350 <input type='checkbox' name='include_batchcom' id='include_batchcom' value="batchcom"><?php echo xlt('Communications'); ?><br>
351 </td>
352 </tr>
353 </table>
355 <input type='hidden' name='pdf' value='0'>
356 <br>
358 <!-- old ccr button position -->
360 <table class="issues_encounters_forms table">
361 <tr>
363 <!-- Issues -->
364 <td class='text'>
365 <div class="issues">
366 <span class='bold'><?php echo xlt('Issues'); ?>:</span>
367 <br>
368 <br>
370 <table>
372 <?php
373 // get issues
374 $pres = sqlStatement("SELECT * FROM lists WHERE pid = $pid " .
375 "ORDER BY type, begdate");
376 $lasttype = "";
377 while ($prow = sqlFetchArray($pres)) {
378 if ($lasttype != $prow['type']) {
379 $lasttype = $prow['type'];
381 /****
382 $disptype = $lasttype;
383 switch ($lasttype) {
384 case "allergy" : $disptype = "Allergies" ; break;
385 case "problem" :
386 case "medical_problem": $disptype = "Medical Problems"; break;
387 case "medication" : $disptype = "Medications" ; break;
388 case "surgery" : $disptype = "Surgeries" ; break;
390 ****/
391 $disptype = $ISSUE_TYPES[$lasttype][0];
393 echo " <tr>\n";
394 echo " <td colspan='4' class='bold'><b>$disptype</b></td>\n";
395 echo " </tr>\n";
398 $rowid = $prow['id'];
399 $disptitle = trim($prow['title']) ? $prow['title'] : "[Missing Title]";
401 $ieres = sqlStatement("SELECT encounter FROM issue_encounter WHERE " .
402 "pid = '$pid' AND list_id = '$rowid'");
404 echo " <tr class='text'>\n";
405 echo " <td>&nbsp;</td>\n";
406 echo " <td>";
407 echo "<input type='checkbox' name='issue_$rowid' id='issue_$rowid' class='issuecheckbox' value='/";
408 while ($ierow = sqlFetchArray($ieres)) {
409 echo $ierow['encounter'] . "/";
412 echo "' />$disptitle</td>\n";
413 echo " <td>" . $prow['begdate'];
415 if ($prow['enddate']) {
416 echo " - " . $prow['enddate'];
417 } else {
418 echo " Active";
421 echo "</td>\n";
422 echo "</tr>\n";
425 </table>
427 <?php //endif; // end of Issues output ?>
429 </div> <!-- end issues DIV -->
430 </td>
432 <!-- Encounters and Forms -->
434 <td class='text'>
435 <div class='encounters'>
436 <span class='bold'><?php echo xlt('Encounters &amp; Forms'); ?>:</span>
437 <br><br>
439 <?php if (!($auth_notes_a || $auth_notes || $auth_coding_a || $auth_coding || $auth_med || $auth_relaxed)) : ?>
440 (Encounters not authorized)
441 <?php else : ?>
443 <?php
445 $isfirst = 1;
446 $res = sqlStatement("SELECT forms.encounter, forms.form_id, forms.form_name, " .
447 "forms.formdir, forms.date AS fdate, form_encounter.date " .
448 ",form_encounter.reason ".
449 "FROM forms, form_encounter WHERE " .
450 "forms.pid = '$pid' AND form_encounter.pid = '$pid' AND " .
451 "form_encounter.encounter = forms.encounter " .
452 " AND forms.deleted=0 ". // --JRM--
453 "ORDER BY form_encounter.date DESC, fdate ASC");
454 $res2 = sqlStatement("SELECT name FROM registry ORDER BY priority");
455 $html_strings = array();
456 $registry_form_name = array();
457 while ($result2 = sqlFetchArray($res2)) {
458 array_push($registry_form_name, trim($result2['name']));
461 while ($result = sqlFetchArray($res)) {
462 if ($result{"form_name"} == "New Patient Encounter") {
463 if ($isfirst == 0) {
464 foreach ($registry_form_name as $var) {
465 if ($toprint = $html_strings[$var]) {
466 foreach ($toprint as $var) {
467 print $var;
472 $html_strings = array();
473 echo "</div>\n"; // end DIV encounter_forms
474 echo "</div>\n\n"; //end DIV encounter_data
475 echo "<br>";
478 $isfirst = 0;
479 echo "<div class='encounter_data'>\n";
480 echo "<input type=checkbox ".
481 " name='" . $result{"formdir"} . "_" . $result{"form_id"} . "'".
482 " id='" . $result{"formdir"} . "_" . $result{"form_id"} . "'".
483 " value='" . $result{"encounter"} . "'" .
484 " class='encounter'".
485 " >";
487 // show encounter reason, not just 'New Encounter'
488 // trim to a reasonable length for display purposes --cfapress
489 $maxReasonLength = 20;
490 if (strlen($result["reason"]) > $maxReasonLength) {
491 $result['reason'] = substr($result['reason'], 0, $maxReasonLength) . " ... ";
494 echo $result{"reason"}.
495 " (" . date("Y-m-d", strtotime($result{"date"})) .
496 ")\n";
497 echo "<div class='encounter_forms'>\n";
498 } else {
499 $form_name = trim($result{"form_name"});
500 //if form name is not in registry, look for the closest match by
501 // finding a registry name which is at the start of the form name.
502 //this is to allow for forms to put additional helpful information
503 //in the database in the same string as their form name after the name
504 $form_name_found_flag = 0;
505 foreach ($registry_form_name as $var) {
506 if ($var == $form_name) {
507 $form_name_found_flag = 1;
511 // if the form does not match precisely with any names in the registry, now see if any front partial matches
512 // and change $form_name appropriately so it will print above in $toprint = $html_strings[$var]
513 if (!$form_name_found_flag) {
514 foreach ($registry_form_name as $var) {
515 if (strpos($form_name, $var) == 0) {
516 $form_name = $var;
521 if (!is_array($html_strings[$form_name])) {
522 $html_strings[$form_name] = array();
525 array_push($html_strings[$form_name], "<input type='checkbox' ".
526 " name='" . $result{"formdir"} . "_" . $result{"form_id"} . "'".
527 " id='" . $result{"formdir"} . "_" . $result{"form_id"} . "'".
528 " value='" . $result{"encounter"} . "'" .
529 " class='encounter_form' ".
530 ">" . xl_form_title($result{"form_name"}) . "<br>\n");
534 foreach ($registry_form_name as $var) {
535 if ($toprint = $html_strings[$var]) {
536 foreach ($toprint as $var) {
537 print $var;
543 <?php endif; ?>
545 </div> <!-- end encounters DIV -->
546 </td>
547 </tr>
548 </table>
550 <!-- Procedure Orders -->
551 <hr/>
552 <table border="0" cellpadding="0" cellspacing="0" >
553 <tr>
554 <td class='bold'><?php echo xlt('Procedures'); ?>&nbsp;&nbsp;</td>
555 <td class='text'><?php echo xlt('Order Date'); ?>&nbsp;&nbsp;</td>
556 <td class='text'><?php echo xlt('Encounter Date'); ?>&nbsp;&nbsp;</td>
557 <td class='text'><?php echo xlt('Order Descriptions'); ?></td>
558 </tr>
559 <?php
560 $res = sqlStatement(
561 "SELECT po.procedure_order_id, po.date_ordered, fe.date " .
562 "FROM procedure_order AS po " .
563 "LEFT JOIN forms AS f ON f.pid = po.patient_id AND f.formdir = 'procedure_order' AND " .
564 "f.form_id = po.procedure_order_id AND f.deleted = 0 " .
565 "LEFT JOIN form_encounter AS fe ON fe.pid = f.pid AND fe.encounter = f.encounter " .
566 "WHERE po.patient_id = ? " .
567 "ORDER BY po.date_ordered DESC, po.procedure_order_id DESC",
568 array($pid)
570 while ($row = sqlFetchArray($res)) {
571 $poid = $row['procedure_order_id'];
572 echo " <tr>\n";
573 echo " <td align='center' class='text'>" .
574 "<input type='checkbox' name='procedures[]' value='$poid' />&nbsp;&nbsp;</td>\n";
575 echo " <td class='text'>" . text(oeFormatShortDate($row['date_ordered'])) . "&nbsp;&nbsp;</td>\n";
576 echo " <td class='text'>" . text(oeFormatShortDate($row['date'])) . "&nbsp;&nbsp;</td>\n";
577 echo " <td class='text'>";
578 $opres = sqlStatement(
579 "SELECT procedure_code, procedure_name FROM procedure_order_code " .
580 "WHERE procedure_order_id = ? ORDER BY procedure_order_seq",
581 array($poid)
583 while ($oprow = sqlFetchArray($opres)) {
584 $tmp = $oprow['procedure_name'];
585 if (empty($tmp)) {
586 $tmp = $oprow['procedure_code'];
589 echo text($tmp) . "<br />";
592 echo "</td>\n";
593 echo " </tr>\n";
596 </table>
598 <hr/>
599 <span class="bold"><?php echo xlt('Documents'); ?></span>:<br>
600 <ul>
601 <?php
602 // show available documents
603 $db = $GLOBALS['adodb']['db'];
604 $sql = "SELECT d.id, d.url, c.name FROM documents AS d " .
605 "LEFT JOIN categories_to_documents AS ctd ON d.id=ctd.document_id " .
606 "LEFT JOIN categories AS c ON c.id = ctd.category_id WHERE " .
607 "d.foreign_id = " . $db->qstr($pid);
608 $result = $db->Execute($sql);
609 if ($db->ErrorMsg()) {
610 echo $db->ErrorMsg();
613 while ($result && !$result->EOF) {
614 echo "<li class='bold'>";
615 echo '<input type="checkbox" name="documents[]" value="' .
616 $result->fields['id'] . '">';
617 echo '&nbsp;&nbsp;<i>' . xl_document_category($result->fields['name']) . "</i>";
618 echo '&nbsp;&nbsp;' . xl('Name') . ': <i>' . basename($result->fields['url']) . "</i>";
619 echo '</li>';
620 $result->MoveNext();
623 </ul>
624 </form>
626 <input type="button" class="genreport" value="<?php echo xlt('Generate Report'); ?>" />&nbsp;
627 <input type="button" class="genpdfrep" value="<?php echo xlt('Download PDF'); ?>" />&nbsp;
628 <?php if ($cmsportal) { ?>
629 <input type="button" class="genportal" value="<?php echo xlt('Send to Portal'); ?>" />
630 <?php } ?>
632 </div> <!-- close patient_reports DIV -->
634 <script>
636 // jQuery stuff to make the page a little easier to use
637 initReport = function(){
638 $(".genreport").click(function() {
639 document.report_form.pdf.value = 0;
640 showCustom();
641 /*$("#report_form").submit();*/
643 $(".genpdfrep").click(function() { document.report_form.pdf.value = 1; $("#report_form").submit(); });
644 $(".genportal").click(function() { document.report_form.pdf.value = 2; $("#report_form").submit(); });
645 $("#genfullreport").click(function() { location.href='<?php echo "$rootdir/patient_file/encounter/$returnurl";?>'; });
646 //$("#printform").click(function() { PrintForm(); });
647 $(".issuecheckbox").click(function() { issueClick(this); });
649 // check/uncheck all Forms of an encounter
650 $(".encounter").click(function() { SelectForms($(this)); });
651 function showCCR() {
652 var title = 'CCR Report';
653 var params = {
654 buttons: [
655 { text: 'Close', close: true, style: 'danger' },
656 { text: 'Print', close: false, style: 'success', click: showCCR }
659 size: eModal.size.lg,
660 title: title,
661 type: "POST",
662 url: '../ccr/createCCR.php',
663 data:{'portal_auth_two':'1','ccrAction':'generate','raw':'yes'}
666 return eModal
667 .ajax(params)
668 .then(function () { });
670 function showCustom(){
671 var formval = $( "#report_form" ).serializeArray();
672 var title = 'Custom Reports';
673 var params = {
674 buttons: [
675 { text: 'Close', close: true, style: 'danger' },
676 //{ text: 'Print', close: false, style: 'success', click: showCustom }
679 size: eModal.size.lg,
680 title: title,
681 //type: "POST",
682 url: './report/portal_custom_report.php',
683 data: formval
686 return eModal
687 .ajax(params)
688 .then(function () { });
690 $(".generateCCR").click(
691 function() {
692 if(document.getElementById('show_date').checked == true){
693 if(document.getElementById('Start').value == '' || document.getElementById('End').value == ''){
694 alert('<?php echo addslashes(xl('Please select a start date and end date')) ?>');
695 return false;
698 var ccrAction = document.getElementsByName('ccrAction');
699 ccrAction[0].value = 'generate';
700 var raw = document.getElementsByName('raw');
701 raw[0].value = 'no';
703 ccr_form.setAttribute("target", "_blank");
704 $("#ccr_form").submit();
705 //showCCR();
707 ccr_form.setAttribute("target", "");
709 $(".generateCCR_raw").click(
710 function() {
711 var ccrAction = document.getElementsByName('ccrAction');
712 ccrAction[0].value = 'generate';
713 var raw = document.getElementsByName('raw');
714 raw[0].value = 'yes';
716 ccr_form.setAttribute("target", "_blank");
717 $("#ccr_form").submit();
718 ccr_form.setAttribute("target", "");
720 $(".generateCCR_download_h").click(
721 function() {
722 var ccrAction = document.getElementsByName('ccrAction');
723 ccrAction[0].value = 'generate';
724 var raw = document.getElementsByName('raw');
725 raw[0].value = 'hybrid';
727 $("#ccr_form").submit();
729 $(".generateCCR_download_p").click(
730 function() {
731 if(document.getElementById('show_date').checked == true){
732 if(document.getElementById('Start').value == '' || document.getElementById('End').value == ''){
733 alert('<?php echo addslashes(xl('Please select a start date and end date')) ?>');
734 return false;
737 var ccrAction = document.getElementsByName('ccrAction');
738 ccrAction[0].value = 'generate';
739 var raw = document.getElementsByName('raw');
740 raw[0].value = 'pure';
742 $("#ccr_form").submit();
744 $(".viewCCD").click(
745 function() {
746 var ccrAction = document.getElementsByName('ccrAction');
747 ccrAction[0].value = 'viewccd';
748 var raw = document.getElementsByName('raw');
749 raw[0].value = 'no';
751 ccr_form.setAttribute("target", "_blank");
752 $("#ccr_form").submit();
753 ccr_form.setAttribute("target", "");
755 $(".viewCCD_raw").click(
756 function() {
757 var ccrAction = document.getElementsByName('ccrAction');
758 ccrAction[0].value = 'viewccd';
759 var raw = document.getElementsByName('raw');
760 raw[0].value = 'yes';
762 ccr_form.setAttribute("target", "_blank");
763 $("#ccr_form").submit();
764 ccr_form.setAttribute("target", "");
766 $(".viewCCD_download").click(
767 function() {
768 var ccrAction = document.getElementsByName('ccrAction');
769 ccrAction[0].value = 'viewccd';
770 var raw = document.getElementsByName('raw');
771 raw[0].value = 'pure';
772 $("#ccr_form").submit();
774 <?php if ($GLOBALS['phimail_enable']==true && $GLOBALS['phimail_ccr_enable']==true) { ?>
775 $(".viewCCR_send_dialog").click(
776 function() {
777 $("#ccr_send_dialog").toggle();
779 $(".viewCCR_transmit").click(
780 function() {
781 $(".viewCCR_transmit").attr('disabled','disabled');
782 var ccrAction = document.getElementsByName('ccrAction');
783 ccrAction[0].value = 'generate';
784 var ccrRecipient = $("#ccr_send_to").val();
785 var raw = document.getElementsByName('raw');
786 raw[0].value = 'send '+ccrRecipient;
787 if(ccrRecipient=="") {
788 $("#ccr_send_message").html("<?php
789 echo htmlspecialchars(xl('Please enter a valid Direct Address above.'), ENT_QUOTES);?>");
790 $("#ccr_send_result").show();
791 } else {
792 $(".viewCCR_transmit").attr('disabled','disabled');
793 $("#ccr_send_message").html("<?php
794 echo htmlspecialchars(xl('Working... this may take a minute.'), ENT_QUOTES);?>");
795 $("#ccr_send_result").show();
796 var action=$("#ccr_form").attr('action');
797 $.post(action, {ccrAction:'generate',raw:'send '+ccrRecipient,requested_by:'user'},
798 function(data) {
799 if(data=="SUCCESS") {
800 $("#ccr_send_message").html("<?php
801 echo htmlspecialchars(xl('Your message was submitted for delivery to'), ENT_QUOTES);
802 ?> "+ccrRecipient);
803 $("#ccr_send_to").val("");
804 } else {
805 $("#ccr_send_message").html(data);
807 $(".viewCCR_transmit").removeAttr('disabled');
811 <?php }
813 if ($GLOBALS['phimail_enable']==true && $GLOBALS['phimail_ccd_enable']==true) { ?>
814 $(".viewCCD_send_dialog").click(
815 function() {
816 $("#ccd_send_dialog").toggle();
818 $(".viewCCD_transmit").click(
819 function() {
820 $(".viewCCD_transmit").attr('disabled','disabled');
821 var ccrAction = document.getElementsByName('ccrAction');
822 ccrAction[0].value = 'viewccd';
823 var ccdRecipient = $("#ccd_send_to").val();
824 var raw = document.getElementsByName('raw');
825 raw[0].value = 'send '+ccdRecipient;
826 if(ccdRecipient=="") {
827 $("#ccd_send_message").html("<?php
828 echo htmlspecialchars(xl('Please enter a valid Direct Address above.'), ENT_QUOTES);?>");
829 $("#ccd_send_result").show();
830 } else {
831 $(".viewCCD_transmit").attr('disabled','disabled');
832 $("#ccd_send_message").html("<?php
833 echo htmlspecialchars(xl('Working... this may take a minute.'), ENT_QUOTES);?>");
834 $("#ccd_send_result").show();
835 var action=$("#ccr_form").attr('action');
836 $.post(action, {ccrAction:'viewccd',raw:'send '+ccdRecipient,requested_by:'user'},
837 function(data) {
838 if(data=="SUCCESS") {
839 $("#ccd_send_message").html("<?php
840 echo htmlspecialchars(xl('Your message was submitted for delivery to'), ENT_QUOTES);
841 ?> "+ccdRecipient);
842 $("#ccd_send_to").val("");
843 } else {
844 $("#ccd_send_message").html(data);
846 $(".viewCCD_transmit").removeAttr('disabled');
850 <?php } ?>
851 /* */
853 }; // end initReport
854 $( document ).ready(function(){
855 initReport();
857 $('.datepicker').datetimepicker({
858 <?php $datetimepicker_timepicker = false; ?>
859 <?php $datetimepicker_formatInput = false; ?>
860 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
861 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
865 // select/deselect the Forms related to the selected Encounter
866 // (it ain't pretty code folks)
867 var SelectForms = function (selectedEncounter) {
868 if ($(selectedEncounter).attr("checked")) {
869 $(selectedEncounter).parent().children().each(function(i, obj) {
870 $(this).children().each(function(i, obj) {
871 $(this).attr("checked", "checked");
875 else {
876 $(selectedEncounter).parent().children().each(function(i, obj) {
877 $(this).children().each(function(i, obj) {
878 $(this).removeAttr("checked");
884 // When an issue is checked, auto-check all the related encounters and forms
885 function issueClick(issue) {
886 // do nothing when unchecked
887 if (! $(issue).attr("checked")) return;
889 $("#report_form :checkbox").each(function(i, obj) {
890 if ($(issue).val().indexOf('/' + $(this).val() + '/') >= 0) {
891 $(this).attr("checked", "checked");
897 </script>