Highway to PSR2
[openemr.git] / portal / report / portal_patient_report.php
blobc3b3c2f81ce58053349cfae17d90d18775739d74
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>
69 <script src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-3-1-1/index.js" type="text/javascript"></script>
70 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker-2-5-4/build/jquery.datetimepicker.full.min.js"></script>
72 <link rel="stylesheet" href="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker-2-5-4/build/jquery.datetimepicker.min.css">
74 <style>
75 input[type="checkbox"], input[type="radio"] {
76 margin: 0 5px 5px;
77 line-height: normal;
79 /*=============================================================
80 * Patient Reports
81 * seen in the patient reports screens
82 *============================================================*/
83 #patient_reports {
84 width: 100%;
86 #patient_reports .issues {
87 padding-right: 30px;
89 #patient_reports .issues table {
90 margin: 10px 0px 10px 0px;
92 #patient_reports .issues td {
93 padding: 2px;
95 #patient_reports .encounters td {
96 padding: 2px;
98 #patient_reports .encounter_forms {
99 margin: 5px 15px 5px 15px;
101 #patient_reports td {
102 vertical-align: top;
104 #patient_reports ul {
105 list-style: none;
108 /*=============================================================
109 * Report - Custom
110 * seen as the patient report (portal_custom_report.php)
111 *============================================================*/
112 #report_custom {
113 width: 100%;
115 #report_custom hr {
116 border: 2px dotted black;
118 #report_custom .billing {
119 margin: 5px;
120 padding: 5px;
122 #report_custom h1 {
123 font-size: 120%;
124 margin: 0px 0px 5px 0px;
125 padding: 0px;
127 #report_custom .immunizations {
128 margin: 5px;
129 padding: 5px;
131 #report_custom .notes {
132 margin: 5px;
133 padding: 5px;
135 #report_custom .transactions {
136 margin: 5px;
137 padding: 5px;
139 #report_custom .communications {
140 margin: 5px;
141 padding: 5px;
143 #report_custom .documents {
144 margin: 5px;
145 padding: 5px;
147 #report_custom .demographics {
148 margin: 5px;
149 padding: 5px;
151 #report_custom .insurance {
152 margin: 5px;
153 padding: 5px;
155 #report_custom .history {
156 margin: 5px;
157 padding: 5px;
159 #report_custom .issue {
160 margin-left: 20px;
162 #report_custom .issue_type {
163 font-weight: bold;
164 padding: 5px 0px 5px 0px;
166 #report_custom .issue_diag {
167 margin: 0px 20px 0px 20px;
169 #report_custom .encounter {
170 width: 100%;
171 border-top: 2px dotted black;
172 padding: 10px 5px 10px 5px;
173 margin-top: 10px;
175 #report_custom .encounter h1 {
176 font-size: 140%;
177 margin: 0px;
178 padding: 0px;
180 #report_custom .encounter_form {
181 margin: 10px;
182 padding: 10px;
183 border-top: 1px solid gray;
186 #addressbook_list tr.evenrow {
187 background-color: #ddddff;
190 #addressbook_list tr.oddrow {
191 background-color: #ffffff;
194 tr.odd, td.even {
195 background-color: #ffffff !important;
198 </style>
200 <script>
202 function checkAll(check) {
203 var f = document.forms['report_form'];
204 for (var i = 0; i < f.elements.length; ++i) {
205 if (f.elements[i].type == 'checkbox') f.elements[i].checked = check;
207 return false;
210 function show_date_fun(){
211 if(document.getElementById('show_date').checked == true){
212 document.getElementById('date_div').style.display = '';
213 }else{
214 document.getElementById('date_div').style.display = 'none';
216 return;
218 var mypcc = '<?php echo $GLOBALS['phone_country_code']; ?>';
219 </script>
221 <body class="body_top">
222 <div id="patient_reports"> <!-- large outer DIV -->
224 <?php if ($GLOBALS['activate_ccr_ccd_report']) { // show CCR/CCD reporting options ?>
225 <div id="ccr_report">
227 <form name='ccr_form' id='ccr_form' method='post' action="../ccr/createCCR.php?portal_auth_two=1">
228 <span class='title'><?php echo xlt('Continuity of Care Record (CCR)'); ?></span>&nbsp;&nbsp;
229 <br/>
230 <span class='text'>(<?php echo xlt('Pop ups need to be enabled to see these reports'); ?>)</span>
231 <br/>
232 <br/>
233 <input type='hidden' name='ccrAction'>
234 <input type='hidden' name='raw'>
235 <input type="checkbox" name="show_date" id="show_date" onchange="show_date_fun();" ><span class='text'><?php echo xlt('Use Date Range'); ?></span>
236 <br>
237 <div id="date_div" style="display:none" >
238 <br>
239 <table border="0" cellpadding="0" cellspacing="0" >
240 <tr>
241 <td>
242 <span class='bold'><?php echo xlt('Start Date');?>: </span>
243 </td>
244 <td>
245 <input type='text' size='10' name='Start' id='Start'
246 class='datepicker'
247 title='<?php echo xla('yyyy-mm-dd'); ?>' />
248 </td>
249 <td>
250 &nbsp;
251 <span class='bold'><?php echo xlt('End Date');?>: </span>
252 </td>
253 <td>
254 <input type='text' size='10' name='End' id='End'
255 class='datepicker'
256 title='<?php echo xla('yyyy-mm-dd'); ?>' />
257 </td>
258 </tr>
259 </table>
260 </div>
261 <br>
263 <!-- <button data-target="#reportdialog" data-toggle="modal" class="btn btn-default">
264 <?php //echo xla('Generate Report'); ?></button> -->
265 <input type="button" class="generateCCR" value="<?php echo xla('Generate Report'); ?>" />
266 <!-- <input type="button" class="generateCCR_download_h" value="<?php echo xl('Download')." (Hybrid)"; ?>" /> -->
267 <input type="button" class="generateCCR_download_p" value="<?php echo xlt('Download'); ?>" />
268 <?php if ($GLOBALS['phimail_enable']==true && $GLOBALS['phimail_ccr_enable']==true) { ?>
269 <input type="button" class="viewCCR_send_dialog" value="<?php echo xlt('Transmit'); ?>" />
270 <br>
271 <div id="ccr_send_dialog" style="display:none" >
272 <br>
273 <table border="0" cellpadding="0" cellspacing="0" >
274 <tr>
275 <td>
276 <span class='bold'><?php echo xlt('Enter Recipient\'s Direct Address');?>: </span>
277 <input type="text" size="64" name="ccr_send_to" id="ccr_send_to" value="">
278 <input type="hidden" name="ccr_sent_by" id="ccr_sent_by" value="user">
279 <input type="button" class="viewCCR_transmit" value="<?php echo xlt('Send'); ?>" />
280 <div id="ccr_send_result" style="display:none" >
281 <span class="text" id="ccr_send_message"></span>
282 </div>
283 </td>
284 </tr>
285 </table>
286 </div>
287 <?php } ?>
288 <hr/>
289 <span class='title'><?php echo xlt('Continuity of Care Document (CCD)'); ?></span>&nbsp;&nbsp;
290 <br/>
291 <span class='text'>(<?php echo xlt('Pop ups need to be enabled to see these reports'); ?>)</span>
292 <br/>
293 <br/>
294 <input type="button" class="viewCCD" value="<?php echo xla('Generate Report'); ?>" />
295 <input type="button" class="viewCCD_download" value="<?php echo xlt('Download'); ?>" />
296 <?php if ($GLOBALS['phimail_enable']==true && $GLOBALS['phimail_ccd_enable']==true) { ?>
297 <input type="button" class="viewCCD_send_dialog" value="<?php echo xlt('Transmit'); ?>" />
298 <br>
299 <div id="ccd_send_dialog" style="display:none" >
300 <br>
301 <table border="0" cellpadding="0" cellspacing="0" >
302 <tr>
303 <td>
304 <span class='bold'><?php echo xlt('Enter Recipient\'s Direct Address');?>: </span>
305 <input type="text" size="64" name="ccd_send_to" id="ccd_send_to" value="">
306 <input type="hidden" name="ccd_sent_by" id="ccd_sent_by" value="user">
307 <input type="button" class="viewCCD_transmit" value="<?php echo xlt('Send'); ?>" />
308 <div id="ccd_send_result" style="display:none" >
309 <span class="text" id="ccd_send_message"></span>
310 </div>
311 </td>
312 </tr>
313 </table>
314 </div>
315 <?php } ?>
317 </form>
319 <hr/>
321 </div>
322 <?php } // end CCR/CCD reporting options ?>
324 <form name='report_form' id="report_form" method='post' action='./report/portal_custom_report.php'>
326 <span class='panel-heading'><?php echo xlt('Patient Report'); ?></span>&nbsp;&nbsp;
327 <a class="link_submit" href="#" onclick="return checkAll(true)"><?php echo xlt('Check All'); ?></a>
329 <a class="link_submit" href="#" onclick="return checkAll(false)"><?php echo xlt('Clear All'); ?></a>
332 <table class="table includes">
333 <tr>
334 <td class='text'>
335 <input type='checkbox' name='include_demographics' id='include_demographics' value="demographics" checked><?php echo xlt('Demographics'); ?><br>
336 <input type='checkbox' name='include_history' id='include_history' value="history"><?php echo xlt('History'); ?><br>
337 <input type='checkbox' name='include_insurance' id='include_insurance' value="insurance"><?php echo xlt('Insurance'); ?><br>
338 <input type='checkbox' name='include_billing' id='include_billing' value="billing"
339 <?php if (!$GLOBALS['simplified_demographics']) {
340 echo 'checked';
341 } ?>><?php echo xlt('Billing'); ?><br>
342 </td>
343 <td class='text'>
344 <!--
345 <input type='checkbox' name='include_allergies' id='include_allergies' value="allergies">Allergies<br>
346 <input type='checkbox' name='include_medications' id='include_medications' value="medications">Medications<br>
348 <input type='checkbox' name='include_immunizations' id='include_immunizations' value="immunizations"><?php echo xlt('Immunizations'); ?><br>
349 <!--
350 <input type='checkbox' name='include_medical_problems' id='include_medical_problems' value="medical_problems">Medical Problems<br>
352 <input type='checkbox' name='include_notes' id='include_notes' value="notes"><?php echo xlt('Patient Notes'); ?><br>
353 <input type='checkbox' name='include_transactions' id='include_transactions' value="transactions"><?php echo xlt('Transactions'); ?><br>
354 <input type='checkbox' name='include_batchcom' id='include_batchcom' value="batchcom"><?php echo xlt('Communications'); ?><br>
355 </td>
356 </tr>
357 </table>
359 <input type='hidden' name='pdf' value='0'>
360 <br>
362 <!-- old ccr button position -->
364 <table class="issues_encounters_forms table">
365 <tr>
367 <!-- Issues -->
368 <td class='text'>
369 <div class="issues">
370 <span class='bold'><?php echo xlt('Issues'); ?>:</span>
371 <br>
372 <br>
374 <table>
376 <?php
377 // get issues
378 $pres = sqlStatement("SELECT * FROM lists WHERE pid = $pid " .
379 "ORDER BY type, begdate");
380 $lasttype = "";
381 while ($prow = sqlFetchArray($pres)) {
382 if ($lasttype != $prow['type']) {
383 $lasttype = $prow['type'];
385 /****
386 $disptype = $lasttype;
387 switch ($lasttype) {
388 case "allergy" : $disptype = "Allergies" ; break;
389 case "problem" :
390 case "medical_problem": $disptype = "Medical Problems"; break;
391 case "medication" : $disptype = "Medications" ; break;
392 case "surgery" : $disptype = "Surgeries" ; break;
394 ****/
395 $disptype = $ISSUE_TYPES[$lasttype][0];
397 echo " <tr>\n";
398 echo " <td colspan='4' class='bold'><b>$disptype</b></td>\n";
399 echo " </tr>\n";
402 $rowid = $prow['id'];
403 $disptitle = trim($prow['title']) ? $prow['title'] : "[Missing Title]";
405 $ieres = sqlStatement("SELECT encounter FROM issue_encounter WHERE " .
406 "pid = '$pid' AND list_id = '$rowid'");
408 echo " <tr class='text'>\n";
409 echo " <td>&nbsp;</td>\n";
410 echo " <td>";
411 echo "<input type='checkbox' name='issue_$rowid' id='issue_$rowid' class='issuecheckbox' value='/";
412 while ($ierow = sqlFetchArray($ieres)) {
413 echo $ierow['encounter'] . "/";
416 echo "' />$disptitle</td>\n";
417 echo " <td>" . $prow['begdate'];
419 if ($prow['enddate']) {
420 echo " - " . $prow['enddate'];
421 } else {
422 echo " Active";
425 echo "</td>\n";
426 echo "</tr>\n";
429 </table>
431 <?php //endif; // end of Issues output ?>
433 </div> <!-- end issues DIV -->
434 </td>
436 <!-- Encounters and Forms -->
438 <td class='text'>
439 <div class='encounters'>
440 <span class='bold'><?php echo xlt('Encounters &amp; Forms'); ?>:</span>
441 <br><br>
443 <?php if (!($auth_notes_a || $auth_notes || $auth_coding_a || $auth_coding || $auth_med || $auth_relaxed)) : ?>
444 (Encounters not authorized)
445 <?php else : ?>
447 <?php
449 $isfirst = 1;
450 $res = sqlStatement("SELECT forms.encounter, forms.form_id, forms.form_name, " .
451 "forms.formdir, forms.date AS fdate, form_encounter.date " .
452 ",form_encounter.reason ".
453 "FROM forms, form_encounter WHERE " .
454 "forms.pid = '$pid' AND form_encounter.pid = '$pid' AND " .
455 "form_encounter.encounter = forms.encounter " .
456 " AND forms.deleted=0 ". // --JRM--
457 "ORDER BY form_encounter.date DESC, fdate ASC");
458 $res2 = sqlStatement("SELECT name FROM registry ORDER BY priority");
459 $html_strings = array();
460 $registry_form_name = array();
461 while ($result2 = sqlFetchArray($res2)) {
462 array_push($registry_form_name, trim($result2['name']));
465 while ($result = sqlFetchArray($res)) {
466 if ($result{"form_name"} == "New Patient Encounter") {
467 if ($isfirst == 0) {
468 foreach ($registry_form_name as $var) {
469 if ($toprint = $html_strings[$var]) {
470 foreach ($toprint as $var) {
471 print $var;
476 $html_strings = array();
477 echo "</div>\n"; // end DIV encounter_forms
478 echo "</div>\n\n"; //end DIV encounter_data
479 echo "<br>";
482 $isfirst = 0;
483 echo "<div class='encounter_data'>\n";
484 echo "<input type=checkbox ".
485 " name='" . $result{"formdir"} . "_" . $result{"form_id"} . "'".
486 " id='" . $result{"formdir"} . "_" . $result{"form_id"} . "'".
487 " value='" . $result{"encounter"} . "'" .
488 " class='encounter'".
489 " >";
491 // show encounter reason, not just 'New Encounter'
492 // trim to a reasonable length for display purposes --cfapress
493 $maxReasonLength = 20;
494 if (strlen($result["reason"]) > $maxReasonLength) {
495 $result['reason'] = substr($result['reason'], 0, $maxReasonLength) . " ... ";
498 echo $result{"reason"}.
499 " (" . date("Y-m-d", strtotime($result{"date"})) .
500 ")\n";
501 echo "<div class='encounter_forms'>\n";
502 } else {
503 $form_name = trim($result{"form_name"});
504 //if form name is not in registry, look for the closest match by
505 // finding a registry name which is at the start of the form name.
506 //this is to allow for forms to put additional helpful information
507 //in the database in the same string as their form name after the name
508 $form_name_found_flag = 0;
509 foreach ($registry_form_name as $var) {
510 if ($var == $form_name) {
511 $form_name_found_flag = 1;
515 // if the form does not match precisely with any names in the registry, now see if any front partial matches
516 // and change $form_name appropriately so it will print above in $toprint = $html_strings[$var]
517 if (!$form_name_found_flag) {
518 foreach ($registry_form_name as $var) {
519 if (strpos($form_name, $var) == 0) {
520 $form_name = $var;
525 if (!is_array($html_strings[$form_name])) {
526 $html_strings[$form_name] = array();
529 array_push($html_strings[$form_name], "<input type='checkbox' ".
530 " name='" . $result{"formdir"} . "_" . $result{"form_id"} . "'".
531 " id='" . $result{"formdir"} . "_" . $result{"form_id"} . "'".
532 " value='" . $result{"encounter"} . "'" .
533 " class='encounter_form' ".
534 ">" . xl_form_title($result{"form_name"}) . "<br>\n");
538 foreach ($registry_form_name as $var) {
539 if ($toprint = $html_strings[$var]) {
540 foreach ($toprint as $var) {
541 print $var;
547 <?php endif; ?>
549 </div> <!-- end encounters DIV -->
550 </td>
551 </tr>
552 </table>
554 <!-- Procedure Orders -->
555 <hr/>
556 <table border="0" cellpadding="0" cellspacing="0" >
557 <tr>
558 <td class='bold'><?php echo xlt('Procedures'); ?>&nbsp;&nbsp;</td>
559 <td class='text'><?php echo xlt('Order Date'); ?>&nbsp;&nbsp;</td>
560 <td class='text'><?php echo xlt('Encounter Date'); ?>&nbsp;&nbsp;</td>
561 <td class='text'><?php echo xlt('Order Descriptions'); ?></td>
562 </tr>
563 <?php
564 $res = sqlStatement(
565 "SELECT po.procedure_order_id, po.date_ordered, fe.date " .
566 "FROM procedure_order AS po " .
567 "LEFT JOIN forms AS f ON f.pid = po.patient_id AND f.formdir = 'procedure_order' AND " .
568 "f.form_id = po.procedure_order_id AND f.deleted = 0 " .
569 "LEFT JOIN form_encounter AS fe ON fe.pid = f.pid AND fe.encounter = f.encounter " .
570 "WHERE po.patient_id = ? " .
571 "ORDER BY po.date_ordered DESC, po.procedure_order_id DESC",
572 array($pid)
574 while ($row = sqlFetchArray($res)) {
575 $poid = $row['procedure_order_id'];
576 echo " <tr>\n";
577 echo " <td align='center' class='text'>" .
578 "<input type='checkbox' name='procedures[]' value='$poid' />&nbsp;&nbsp;</td>\n";
579 echo " <td class='text'>" . oeFormatShortDate($row['date_ordered']) . "&nbsp;&nbsp;</td>\n";
580 echo " <td class='text'>" . oeFormatShortDate($row['date']) . "&nbsp;&nbsp;</td>\n";
581 echo " <td class='text'>";
582 $opres = sqlStatement(
583 "SELECT procedure_code, procedure_name FROM procedure_order_code " .
584 "WHERE procedure_order_id = ? ORDER BY procedure_order_seq",
585 array($poid)
587 while ($oprow = sqlFetchArray($opres)) {
588 $tmp = $oprow['procedure_name'];
589 if (empty($tmp)) {
590 $tmp = $oprow['procedure_code'];
593 echo text($tmp) . "<br />";
596 echo "</td>\n";
597 echo " </tr>\n";
600 </table>
602 <hr/>
603 <span class="bold"><?php echo xlt('Documents'); ?></span>:<br>
604 <ul>
605 <?php
606 // show available documents
607 $db = $GLOBALS['adodb']['db'];
608 $sql = "SELECT d.id, d.url, c.name FROM documents AS d " .
609 "LEFT JOIN categories_to_documents AS ctd ON d.id=ctd.document_id " .
610 "LEFT JOIN categories AS c ON c.id = ctd.category_id WHERE " .
611 "d.foreign_id = " . $db->qstr($pid);
612 $result = $db->Execute($sql);
613 if ($db->ErrorMsg()) {
614 echo $db->ErrorMsg();
617 while ($result && !$result->EOF) {
618 echo "<li class='bold'>";
619 echo '<input type="checkbox" name="documents[]" value="' .
620 $result->fields['id'] . '">';
621 echo '&nbsp;&nbsp;<i>' . xl_document_category($result->fields['name']) . "</i>";
622 echo '&nbsp;&nbsp;' . xl('Name') . ': <i>' . basename($result->fields['url']) . "</i>";
623 echo '</li>';
624 $result->MoveNext();
627 </ul>
628 </form>
630 <input type="button" class="genreport" value="<?php echo xlt('Generate Report'); ?>" />&nbsp;
631 <input type="button" class="genpdfrep" value="<?php echo xlt('Download PDF'); ?>" />&nbsp;
632 <?php if ($cmsportal) { ?>
633 <input type="button" class="genportal" value="<?php echo xlt('Send to Portal'); ?>" />
634 <?php } ?>
636 </div> <!-- close patient_reports DIV -->
638 <script>
640 // jQuery stuff to make the page a little easier to use
641 initReport = function(){
642 $(".genreport").click(function() {
643 document.report_form.pdf.value = 0;
644 showCustom();
645 /*$("#report_form").submit();*/
647 $(".genpdfrep").click(function() { document.report_form.pdf.value = 1; $("#report_form").submit(); });
648 $(".genportal").click(function() { document.report_form.pdf.value = 2; $("#report_form").submit(); });
649 $("#genfullreport").click(function() { location.href='<?php echo "$rootdir/patient_file/encounter/$returnurl";?>'; });
650 //$("#printform").click(function() { PrintForm(); });
651 $(".issuecheckbox").click(function() { issueClick(this); });
653 // check/uncheck all Forms of an encounter
654 $(".encounter").click(function() { SelectForms($(this)); });
655 function showCCR() {
656 var title = 'CCR Report';
657 var params = {
658 buttons: [
659 { text: 'Close', close: true, style: 'danger' },
660 { text: 'Print', close: false, style: 'success', click: showCCR }
663 size: eModal.size.lg,
664 title: title,
665 type: "POST",
666 url: '../ccr/createCCR.php',
667 data:{'portal_auth_two':'1','ccrAction':'generate','raw':'yes'}
670 return eModal
671 .ajax(params)
672 .then(function () { });
674 function showCustom(){
675 var formval = $( "#report_form" ).serializeArray();
676 var title = 'Custom Reports';
677 var params = {
678 buttons: [
679 { text: 'Close', close: true, style: 'danger' },
680 //{ text: 'Print', close: false, style: 'success', click: showCustom }
683 size: eModal.size.lg,
684 title: title,
685 //type: "POST",
686 url: './report/portal_custom_report.php',
687 data: formval
690 return eModal
691 .ajax(params)
692 .then(function () { });
694 $(".generateCCR").click(
695 function() {
696 if(document.getElementById('show_date').checked == true){
697 if(document.getElementById('Start').value == '' || document.getElementById('End').value == ''){
698 alert('<?php echo addslashes(xl('Please select a start date and end date')) ?>');
699 return false;
702 var ccrAction = document.getElementsByName('ccrAction');
703 ccrAction[0].value = 'generate';
704 var raw = document.getElementsByName('raw');
705 raw[0].value = 'no';
707 ccr_form.setAttribute("target", "_blank");
708 $("#ccr_form").submit();
709 //showCCR();
711 ccr_form.setAttribute("target", "");
713 $(".generateCCR_raw").click(
714 function() {
715 var ccrAction = document.getElementsByName('ccrAction');
716 ccrAction[0].value = 'generate';
717 var raw = document.getElementsByName('raw');
718 raw[0].value = 'yes';
720 ccr_form.setAttribute("target", "_blank");
721 $("#ccr_form").submit();
722 ccr_form.setAttribute("target", "");
724 $(".generateCCR_download_h").click(
725 function() {
726 var ccrAction = document.getElementsByName('ccrAction');
727 ccrAction[0].value = 'generate';
728 var raw = document.getElementsByName('raw');
729 raw[0].value = 'hybrid';
731 $("#ccr_form").submit();
733 $(".generateCCR_download_p").click(
734 function() {
735 if(document.getElementById('show_date').checked == true){
736 if(document.getElementById('Start').value == '' || document.getElementById('End').value == ''){
737 alert('<?php echo addslashes(xl('Please select a start date and end date')) ?>');
738 return false;
741 var ccrAction = document.getElementsByName('ccrAction');
742 ccrAction[0].value = 'generate';
743 var raw = document.getElementsByName('raw');
744 raw[0].value = 'pure';
746 $("#ccr_form").submit();
748 $(".viewCCD").click(
749 function() {
750 var ccrAction = document.getElementsByName('ccrAction');
751 ccrAction[0].value = 'viewccd';
752 var raw = document.getElementsByName('raw');
753 raw[0].value = 'no';
755 ccr_form.setAttribute("target", "_blank");
756 $("#ccr_form").submit();
757 ccr_form.setAttribute("target", "");
759 $(".viewCCD_raw").click(
760 function() {
761 var ccrAction = document.getElementsByName('ccrAction');
762 ccrAction[0].value = 'viewccd';
763 var raw = document.getElementsByName('raw');
764 raw[0].value = 'yes';
766 ccr_form.setAttribute("target", "_blank");
767 $("#ccr_form").submit();
768 ccr_form.setAttribute("target", "");
770 $(".viewCCD_download").click(
771 function() {
772 var ccrAction = document.getElementsByName('ccrAction');
773 ccrAction[0].value = 'viewccd';
774 var raw = document.getElementsByName('raw');
775 raw[0].value = 'pure';
776 $("#ccr_form").submit();
778 <?php if ($GLOBALS['phimail_enable']==true && $GLOBALS['phimail_ccr_enable']==true) { ?>
779 $(".viewCCR_send_dialog").click(
780 function() {
781 $("#ccr_send_dialog").toggle();
783 $(".viewCCR_transmit").click(
784 function() {
785 $(".viewCCR_transmit").attr('disabled','disabled');
786 var ccrAction = document.getElementsByName('ccrAction');
787 ccrAction[0].value = 'generate';
788 var ccrRecipient = $("#ccr_send_to").val();
789 var raw = document.getElementsByName('raw');
790 raw[0].value = 'send '+ccrRecipient;
791 if(ccrRecipient=="") {
792 $("#ccr_send_message").html("<?php
793 echo htmlspecialchars(xl('Please enter a valid Direct Address above.'), ENT_QUOTES);?>");
794 $("#ccr_send_result").show();
795 } else {
796 $(".viewCCR_transmit").attr('disabled','disabled');
797 $("#ccr_send_message").html("<?php
798 echo htmlspecialchars(xl('Working... this may take a minute.'), ENT_QUOTES);?>");
799 $("#ccr_send_result").show();
800 var action=$("#ccr_form").attr('action');
801 $.post(action, {ccrAction:'generate',raw:'send '+ccrRecipient,requested_by:'user'},
802 function(data) {
803 if(data=="SUCCESS") {
804 $("#ccr_send_message").html("<?php
805 echo htmlspecialchars(xl('Your message was submitted for delivery to'), ENT_QUOTES);
806 ?> "+ccrRecipient);
807 $("#ccr_send_to").val("");
808 } else {
809 $("#ccr_send_message").html(data);
811 $(".viewCCR_transmit").removeAttr('disabled');
815 <?php }
817 if ($GLOBALS['phimail_enable']==true && $GLOBALS['phimail_ccd_enable']==true) { ?>
818 $(".viewCCD_send_dialog").click(
819 function() {
820 $("#ccd_send_dialog").toggle();
822 $(".viewCCD_transmit").click(
823 function() {
824 $(".viewCCD_transmit").attr('disabled','disabled');
825 var ccrAction = document.getElementsByName('ccrAction');
826 ccrAction[0].value = 'viewccd';
827 var ccdRecipient = $("#ccd_send_to").val();
828 var raw = document.getElementsByName('raw');
829 raw[0].value = 'send '+ccdRecipient;
830 if(ccdRecipient=="") {
831 $("#ccd_send_message").html("<?php
832 echo htmlspecialchars(xl('Please enter a valid Direct Address above.'), ENT_QUOTES);?>");
833 $("#ccd_send_result").show();
834 } else {
835 $(".viewCCD_transmit").attr('disabled','disabled');
836 $("#ccd_send_message").html("<?php
837 echo htmlspecialchars(xl('Working... this may take a minute.'), ENT_QUOTES);?>");
838 $("#ccd_send_result").show();
839 var action=$("#ccr_form").attr('action');
840 $.post(action, {ccrAction:'viewccd',raw:'send '+ccdRecipient,requested_by:'user'},
841 function(data) {
842 if(data=="SUCCESS") {
843 $("#ccd_send_message").html("<?php
844 echo htmlspecialchars(xl('Your message was submitted for delivery to'), ENT_QUOTES);
845 ?> "+ccdRecipient);
846 $("#ccd_send_to").val("");
847 } else {
848 $("#ccd_send_message").html(data);
850 $(".viewCCD_transmit").removeAttr('disabled');
854 <?php } ?>
855 /* */
857 }; // end initReport
858 $( document ).ready(function(){
859 initReport();
861 $('.datepicker').datetimepicker({
862 <?php $datetimepicker_timepicker = false; ?>
863 <?php $datetimepicker_formatInput = false; ?>
864 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
865 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
869 // select/deselect the Forms related to the selected Encounter
870 // (it ain't pretty code folks)
871 var SelectForms = function (selectedEncounter) {
872 if ($(selectedEncounter).attr("checked")) {
873 $(selectedEncounter).parent().children().each(function(i, obj) {
874 $(this).children().each(function(i, obj) {
875 $(this).attr("checked", "checked");
879 else {
880 $(selectedEncounter).parent().children().each(function(i, obj) {
881 $(this).children().each(function(i, obj) {
882 $(this).removeAttr("checked");
888 // When an issue is checked, auto-check all the related encounters and forms
889 function issueClick(issue) {
890 // do nothing when unchecked
891 if (! $(issue).attr("checked")) return;
893 $("#report_form :checkbox").each(function(i, obj) {
894 if ($(issue).val().indexOf('/' + $(this).val() + '/') >= 0) {
895 $(this).attr("checked", "checked");
901 </script>