Highway to PSR2
[openemr.git] / interface / patient_file / report / patient_report.php
blob70490cd44cdf9cd184e21787ede85488080252c9
1 <?php
3 require_once("../../globals.php");
4 require_once("$srcdir/lists.inc");
5 require_once("$srcdir/acl.inc");
6 require_once("$srcdir/forms.inc");
7 require_once("$srcdir/patient.inc");
9 // get various authorization levels
10 $auth_notes_a = acl_check('encounters', 'notes_a');
11 $auth_notes = acl_check('encounters', 'notes');
12 $auth_coding_a = acl_check('encounters', 'coding_a');
13 $auth_coding = acl_check('encounters', 'coding');
14 $auth_relaxed = acl_check('encounters', 'relaxed');
15 $auth_med = acl_check('patients', 'med');
16 $auth_demo = acl_check('patients', 'demo');
18 $cmsportal = false;
19 if ($GLOBALS['gbl_portal_cms_enable']) {
20 $ptdata = getPatientData($pid, 'cmsportal_login');
21 $cmsportal = $ptdata['cmsportal_login'] !== '';
24 <html>
25 <head>
26 <?php html_header_show();?>
28 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
29 <style type="text/css">@import url(../../../library/dynarch_calendar.css);</style>
30 <script type="text/javascript" src="../../../library/textformat.js"></script>
31 <script type="text/javascript" src="../../../library/dynarch_calendar.js"></script>
32 <?php include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?>
33 <script type="text/javascript" src="../../../library/dynarch_calendar_setup.js"></script>
35 <!-- include jQuery support -->
36 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-2-2/index.js"></script>
38 <script language='JavaScript'>
40 function checkAll(check) {
41 var f = document.forms['report_form'];
42 for (var i = 0; i < f.elements.length; ++i) {
43 if (f.elements[i].type == 'checkbox') f.elements[i].checked = check;
45 return false;
48 function show_date_fun(){
49 if(document.getElementById('show_date').checked == true){
50 document.getElementById('date_div').style.display = '';
51 }else{
52 document.getElementById('date_div').style.display = 'none';
54 return;
57 </script>
59 </head>
61 <body class="body_top">
62 <div id="patient_reports"> <!-- large outer DIV -->
64 <p>
65 <span class='title'><?php echo xlt('Patient Reports'); ?></span>
66 </p>
68 <?php if ($GLOBALS['activate_ccr_ccd_report']) { // show CCR/CCD reporting options ?>
69 <div id="ccr_report">
71 <form name='ccr_form' id='ccr_form' method='post' action='../../../ccr/createCCR.php'>
72 <span class='title'><?php xl('Continuity of Care Record (CCR)', 'e'); ?></span>&nbsp;&nbsp;
73 <br/>
74 <span class='text'>(<?php xl('Pop ups need to be enabled to see these reports', 'e'); ?>)</span>
75 <br/>
76 <br/>
77 <input type='hidden' name='ccrAction'>
78 <input type='hidden' name='raw'>
79 <input type="checkbox" name="show_date" id="show_date" onchange="show_date_fun();" ><span class='text'><?php xl('Use Date Range', 'e'); ?>
80 <br>
81 <div id="date_div" style="display:none" >
82 <br>
83 <table border="0" cellpadding="0" cellspacing="0" >
84 <tr>
85 <td>
86 <span class='bold'><?php xl('Start Date', 'e');?>: </span>
87 </td>
88 <td>
89 <input type='text' size='10' name='Start' id='Start'
90 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)'
91 title='<?php xl('yyyy-mm-dd', 'e'); ?>' />
92 <img src='../../pic/show_calendar.gif' align='absbottom' width='24' height='22'
93 id='img_start' border='0' alt='[?]' style='cursor:pointer'
94 title='<?php xl('Click here to choose a date', 'e'); ?>' >
95 <script LANGUAGE="JavaScript">
96 Calendar.setup({inputField:"Start", ifFormat:"%Y-%m-%d", button:"img_start"});
97 </script>
98 </td>
99 <td>
100 &nbsp;
101 <span class='bold'><?php xl('End Date', 'e');?>: </span>
102 </td>
103 <td>
104 <input type='text' size='10' name='End' id='End'
105 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)'
106 title='<?php xl('yyyy-mm-dd', 'e'); ?>' />
107 <img src='../../pic/show_calendar.gif' align='absbottom' width='24' height='22'
108 id='img_end' border='0' alt='[?]' style='cursor:pointer'
109 title='<?php xl('Click here to choose a date', 'e'); ?>' >
110 <script LANGUAGE="JavaScript">
111 Calendar.setup({inputField:"End", ifFormat:"%Y-%m-%d", button:"img_end"});
112 </script>
113 </td>
114 </tr>
115 </table>
116 </div>
117 <br>
118 <input type="button" class="generateCCR" value="<?php echo xla('Generate Report'); ?>" />
119 <!-- <input type="button" class="generateCCR_download_h" value="<?php echo xl('Download')." (Hybrid)"; ?>" /> -->
120 <input type="button" class="generateCCR_download_p" value="<?php echo xl('Download'); ?>" />
121 <!-- <input type="button" class="generateCCR_raw" value="<?php xl('Raw Report', 'e'); ?>" /> -->
122 <?php if ($GLOBALS['phimail_enable']==true && $GLOBALS['phimail_ccr_enable']==true) { ?>
123 <input type="button" class="viewCCR_send_dialog" value="<?php echo htmlspecialchars(xl('Transmit', ENT_QUOTES)); ?>" />
124 <br>
125 <div id="ccr_send_dialog" style="display:none" >
126 <br>
127 <table border="0" cellpadding="0" cellspacing="0" >
128 <tr>
129 <td>
130 <span class='bold'><?php echo htmlspecialchars(xl('Enter Recipient\'s Direct Address'), ENT_NOQUOTES);?>: </span>
131 <input type="text" size="64" name="ccr_send_to" id="ccr_send_to" value="">
132 <input type="hidden" name="ccr_sent_by" id="ccr_sent_by" value="user">
133 <input type="button" class="viewCCR_transmit" value="<?php echo htmlspecialchars(xl('Send', ENT_QUOTES)); ?>" />
134 <div id="ccr_send_result" style="display:none" >
135 <span class="text" id="ccr_send_message"></span>
136 </div>
137 </td>
138 </tr>
139 </table>
140 </div>
141 <?php } ?>
142 <hr/>
143 <span class='title'><?php xl('Continuity of Care Document (CCD)', 'e'); ?></span>&nbsp;&nbsp;
144 <br/>
145 <span class='text'>(<?php xl('Pop ups need to be enabled to see these reports', 'e'); ?>)</span>
146 <br/>
147 <br/>
148 <input type="button" class="viewCCD" value="<?php echo xla('Generate Report'); ?>" />
149 <input type="button" class="viewCCD_download" value="<?php echo htmlspecialchars(xl('Download', ENT_QUOTES)); ?>" />
150 <!-- <input type="button" class="viewCCD_raw" value="<?php xl('Raw Report', 'e'); ?>" /> -->
151 <?php if ($GLOBALS['phimail_enable']==true && $GLOBALS['phimail_ccd_enable']==true) { ?>
152 <input type="button" class="viewCCD_send_dialog" value="<?php echo htmlspecialchars(xl('Transmit', ENT_QUOTES)); ?>" />
153 <br>
154 <div id="ccd_send_dialog" style="display:none" >
155 <br>
156 <table border="0" cellpadding="0" cellspacing="0" >
157 <tr>
158 <td>
159 <span class='bold'><?php echo htmlspecialchars(xl('Enter Recipient\'s Direct Address'), ENT_NOQUOTES);?>: </span>
160 <input type="text" size="64" name="ccd_send_to" id="ccd_send_to" value="">
161 <input type="hidden" name="ccd_sent_by" id="ccd_sent_by" value="user">
162 <input type="button" class="viewCCD_transmit" value="<?php echo htmlspecialchars(xl('Send', ENT_QUOTES)); ?>" />
163 <div id="ccd_send_result" style="display:none" >
164 <span class="text" id="ccd_send_message"></span>
165 </div>
166 </td>
167 </tr>
168 </table>
169 </div>
170 <?php } ?>
172 </form>
173 <hr/>
174 <hr/>
176 </div>
177 <?php } // end CCR/CCD reporting options ?>
179 <form name='report_form' id="report_form" method='post' action='custom_report.php'>
182 <span class='title'><?php xl('Patient Report', 'e'); ?></span>&nbsp;&nbsp;
184 <!--
185 <a class="link_submit" href="full_report.php" onclick="top.restoreSession()">
186 [<?php xl('View Comprehensive Patient Report', 'e'); ?>]</a>
188 <a class="link_submit" href="#" onclick="return checkAll(true)"><?php xl('Check All', 'e'); ?></a>
190 <a class="link_submit" href="#" onclick="return checkAll(false)"><?php xl('Clear All', 'e'); ?></a>
193 <table class="includes">
194 <tr>
195 <td class='text'>
196 <input type='checkbox' name='include_demographics' id='include_demographics' value="demographics" checked><?php xl('Demographics', 'e'); ?><br>
197 <?php if (acl_check('patients', 'med')) : ?>
198 <input type='checkbox' name='include_history' id='include_history' value="history"><?php xl('History', 'e'); ?><br>
199 <?php endif; ?>
200 <!--
201 <input type='checkbox' name='include_employer' id='include_employer' value="employer"><?php xl('Employer', 'e'); ?><br>
203 <input type='checkbox' name='include_insurance' id='include_insurance' value="insurance"><?php xl('Insurance', 'e'); ?><br>
204 <input type='checkbox' name='include_billing' id='include_billing' value="billing"
205 <?php if (!$GLOBALS['simplified_demographics']) {
206 echo 'checked';
207 } ?>><?php xl('Billing', 'e'); ?><br>
208 </td>
209 <td class='text'>
210 <!--
211 <input type='checkbox' name='include_allergies' id='include_allergies' value="allergies">Allergies<br>
212 <input type='checkbox' name='include_medications' id='include_medications' value="medications">Medications<br>
214 <input type='checkbox' name='include_immunizations' id='include_immunizations' value="immunizations"><?php xl('Immunizations', 'e'); ?><br>
215 <!--
216 <input type='checkbox' name='include_medical_problems' id='include_medical_problems' value="medical_problems">Medical Problems<br>
218 <input type='checkbox' name='include_notes' id='include_notes' value="notes"><?php xl('Patient Notes', 'e'); ?><br>
219 <input type='checkbox' name='include_transactions' id='include_transactions' value="transactions"><?php xl('Transactions', 'e'); ?><br>
220 <input type='checkbox' name='include_batchcom' id='include_batchcom' value="batchcom"><?php xl('Communications', 'e'); ?><br>
221 </td>
222 <td class="text">
223 <input type='checkbox' name='include_recurring_days' id='include_recurring_days' value="recurring_days" ><?php echo xlt('Recurrent Appointments'); ?><br>
224 </td>
225 </tr>
226 </table>
228 <br>
229 <input type="button" class="genreport" value="<?php xl('Generate Report', 'e'); ?>" />&nbsp;
230 <input type="button" class="genpdfrep" value="<?php xl('Download PDF', 'e'); ?>" />&nbsp;
231 <?php if ($cmsportal) { ?>
232 <input type="button" class="genportal" value="<?php xl('Send to Portal', 'e'); ?>" />
233 <?php } ?>
234 <input type='hidden' name='pdf' value='0'>
235 <br>
237 <!-- old ccr button position -->
238 <hr/>
240 <table class="issues_encounters_forms">
241 <tr>
243 <!-- Issues -->
244 <td class='text'>
245 <div class="issues">
246 <span class='bold'><?php xl('Issues', 'e'); ?>:</span>
247 <br>
248 <br>
250 <?php if (! acl_check('patients', 'med')) : ?>
251 <br>(Issues not authorized)
253 <?php else : ?>
254 <table>
256 <?php
257 // get issues
258 $pres = sqlStatement("SELECT * FROM lists WHERE pid = $pid " .
259 "ORDER BY type, begdate");
260 $lasttype = "";
261 while ($prow = sqlFetchArray($pres)) {
262 if ($lasttype != $prow['type']) {
263 $lasttype = $prow['type'];
265 /****
266 $disptype = $lasttype;
267 switch ($lasttype) {
268 case "allergy" : $disptype = "Allergies" ; break;
269 case "problem" :
270 case "medical_problem": $disptype = "Medical Problems"; break;
271 case "medication" : $disptype = "Medications" ; break;
272 case "surgery" : $disptype = "Surgeries" ; break;
274 ****/
275 $disptype = $ISSUE_TYPES[$lasttype][0];
277 echo " <tr>\n";
278 echo " <td colspan='4' class='bold'><b>$disptype</b></td>\n";
279 echo " </tr>\n";
282 $rowid = $prow['id'];
283 $disptitle = trim($prow['title']) ? $prow['title'] : "[Missing Title]";
285 $ieres = sqlStatement("SELECT encounter FROM issue_encounter WHERE " .
286 "pid = '$pid' AND list_id = '$rowid'");
288 echo " <tr class='text'>\n";
289 echo " <td>&nbsp;</td>\n";
290 echo " <td>";
291 echo "<input type='checkbox' name='issue_$rowid' id='issue_$rowid' class='issuecheckbox' value='/";
292 while ($ierow = sqlFetchArray($ieres)) {
293 echo $ierow['encounter'] . "/";
296 echo "' />$disptitle</td>\n";
297 echo " <td>" . $prow['begdate'];
299 if ($prow['enddate']) {
300 echo " - " . $prow['enddate'];
301 } else {
302 echo " Active";
305 echo "</td>\n";
306 echo "</tr>\n";
309 </table>
311 <?php endif; // end of Issues output ?>
313 </div> <!-- end issues DIV -->
314 </td>
316 <!-- Encounters and Forms -->
318 <td class='text'>
319 <div class='encounters'>
320 <span class='bold'><?php xl('Encounters &amp; Forms', 'e'); ?>:</span>
321 <br><br>
323 <?php if (!($auth_notes_a || $auth_notes || $auth_coding_a || $auth_coding || $auth_med || $auth_relaxed)) : ?>
324 (Encounters not authorized)
325 <?php else : ?>
327 <?php
329 $isfirst = 1;
330 $res = sqlStatement("SELECT forms.encounter, forms.form_id, forms.form_name, " .
331 "forms.formdir, forms.date AS fdate, form_encounter.date " .
332 ",form_encounter.reason ".
333 "FROM forms, form_encounter WHERE " .
334 "forms.pid = '$pid' AND form_encounter.pid = '$pid' AND " .
335 "form_encounter.encounter = forms.encounter " .
336 " AND forms.deleted=0 ". // --JRM--
337 "ORDER BY form_encounter.date DESC, fdate ASC");
338 $res2 = sqlStatement("SELECT name FROM registry ORDER BY priority");
339 $html_strings = array();
340 $registry_form_name = array();
341 while ($result2 = sqlFetchArray($res2)) {
342 array_push($registry_form_name, trim($result2['name']));
345 while ($result = sqlFetchArray($res)) {
346 if ($result{"form_name"} == "New Patient Encounter") {
347 if ($isfirst == 0) {
348 foreach ($registry_form_name as $var) {
349 if ($toprint = $html_strings[$var]) {
350 foreach ($toprint as $var) {
351 print $var;
356 $html_strings = array();
357 echo "</div>\n"; // end DIV encounter_forms
358 echo "</div>\n\n"; //end DIV encounter_data
359 echo "<br>";
362 $isfirst = 0;
363 echo "<div class='encounter_data'>\n";
364 echo "<input type=checkbox ".
365 " name='" . $result{"formdir"} . "_" . $result{"form_id"} . "'".
366 " id='" . $result{"formdir"} . "_" . $result{"form_id"} . "'".
367 " value='" . $result{"encounter"} . "'" .
368 " class='encounter'".
369 " >";
371 // show encounter reason, not just 'New Encounter'
372 // trim to a reasonable length for display purposes --cfapress
373 $maxReasonLength = 20;
374 if (strlen($result["reason"]) > $maxReasonLength) {
375 // The default encoding for this mb_substr() call is set near top of globals.php
376 $result['reason'] = mb_substr($result['reason'], 0, $maxReasonLength) . " ... ";
379 echo $result{"reason"}.
380 " (" . date("Y-m-d", strtotime($result{"date"})) .
381 ")\n";
382 echo "<div class='encounter_forms'>\n";
383 } else {
384 $form_name = trim($result{"form_name"});
385 //if form name is not in registry, look for the closest match by
386 // finding a registry name which is at the start of the form name.
387 //this is to allow for forms to put additional helpful information
388 //in the database in the same string as their form name after the name
389 $form_name_found_flag = 0;
390 foreach ($registry_form_name as $var) {
391 if ($var == $form_name) {
392 $form_name_found_flag = 1;
396 // if the form does not match precisely with any names in the registry, now see if any front partial matches
397 // and change $form_name appropriately so it will print above in $toprint = $html_strings[$var]
398 if (!$form_name_found_flag) {
399 foreach ($registry_form_name as $var) {
400 if (strpos($form_name, $var) == 0) {
401 $form_name = $var;
406 if (!is_array($html_strings[$form_name])) {
407 $html_strings[$form_name] = array();
410 array_push($html_strings[$form_name], "<input type='checkbox' ".
411 " name='" . $result{"formdir"} . "_" . $result{"form_id"} . "'".
412 " id='" . $result{"formdir"} . "_" . $result{"form_id"} . "'".
413 " value='" . $result{"encounter"} . "'" .
414 " class='encounter_form' ".
415 ">" . xl_form_title($result{"form_name"}) . "<br>\n");
419 foreach ($registry_form_name as $var) {
420 if ($toprint = $html_strings[$var]) {
421 foreach ($toprint as $var) {
422 print $var;
428 <?php endif; ?>
430 </div> <!-- end encounters DIV -->
431 </td>
432 </tr>
433 </table>
434 <input type="button" class="genreport" value="<?php xl('Generate Report', 'e'); ?>" />&nbsp;
435 <input type="button" class="genpdfrep" value="<?php xl('Download PDF', 'e'); ?>" />&nbsp;
436 <?php if ($cmsportal) { ?>
437 <input type="button" class="genportal" value="<?php xl('Send to Portal', 'e'); ?>" />
438 <?php } ?>
440 <!-- Procedure Orders -->
441 <hr/>
442 <table border="0" cellpadding="0" cellspacing="0" >
443 <tr>
444 <td class='bold'><?php echo xlt('Procedures'); ?>&nbsp;&nbsp;</td>
445 <td class='text'><?php echo xlt('Order Date'); ?>&nbsp;&nbsp;</td>
446 <td class='text'><?php echo xlt('Encounter Date'); ?>&nbsp;&nbsp;</td>
447 <td class='text'><?php echo xlt('Order Descriptions'); ?></td>
448 </tr>
449 <?php
450 $res = sqlStatement(
451 "SELECT po.procedure_order_id, po.date_ordered, fe.date " .
452 "FROM procedure_order AS po " .
453 "LEFT JOIN forms AS f ON f.pid = po.patient_id AND f.formdir = 'procedure_order' AND " .
454 "f.form_id = po.procedure_order_id AND f.deleted = 0 " .
455 "LEFT JOIN form_encounter AS fe ON fe.pid = f.pid AND fe.encounter = f.encounter " .
456 "WHERE po.patient_id = ? " .
457 "ORDER BY po.date_ordered DESC, po.procedure_order_id DESC",
458 array($pid)
460 while ($row = sqlFetchArray($res)) {
461 $poid = $row['procedure_order_id'];
462 echo " <tr>\n";
463 echo " <td align='center' class='text'>" .
464 "<input type='checkbox' name='procedures[]' value='$poid' />&nbsp;&nbsp;</td>\n";
465 echo " <td class='text'>" . oeFormatShortDate($row['date_ordered']) . "&nbsp;&nbsp;</td>\n";
466 echo " <td class='text'>" . oeFormatShortDate($row['date']) . "&nbsp;&nbsp;</td>\n";
467 echo " <td class='text'>";
468 $opres = sqlStatement(
469 "SELECT procedure_code, procedure_name FROM procedure_order_code " .
470 "WHERE procedure_order_id = ? ORDER BY procedure_order_seq",
471 array($poid)
473 while ($oprow = sqlFetchArray($opres)) {
474 $tmp = $oprow['procedure_name'];
475 if (empty($tmp)) {
476 $tmp = $oprow['procedure_code'];
479 echo text($tmp) . "<br />";
482 echo "</td>\n";
483 echo " </tr>\n";
486 </table>
487 <input type="button" class="genreport" value="<?php xl('Generate Report', 'e'); ?>" />&nbsp;
488 <input type="button" class="genpdfrep" value="<?php xl('Download PDF', 'e'); ?>" />
490 <hr/>
491 <span class="bold"><?php xl('Documents', 'e'); ?></span>:<br>
492 <ul>
493 <?php
494 // show available documents
495 $db = $GLOBALS['adodb']['db'];
496 $sql = "SELECT d.id, d.url, c.name, c.aco_spec FROM documents AS d " .
497 "LEFT JOIN categories_to_documents AS ctd ON d.id=ctd.document_id " .
498 "LEFT JOIN categories AS c ON c.id = ctd.category_id WHERE " .
499 "d.foreign_id = " . $db->qstr($pid);
500 $result = $db->Execute($sql);
501 if ($db->ErrorMsg()) {
502 echo $db->ErrorMsg();
505 while ($result && !$result->EOF) {
506 if (empty($result->fields['aco_spec']) || acl_check_aco_spec($result->fields['aco_spec'])) {
507 echo "<li class='bold'>";
508 echo '<input type="checkbox" name="documents[]" value="' .
509 $result->fields['id'] . '">';
510 echo '&nbsp;&nbsp;<i>' . xl_document_category($result->fields['name']) . "</i>";
511 echo '&nbsp;&nbsp;' . xl('Name') . ': <i>' . basename($result->fields['url']) . "</i>";
512 echo '</li>';
515 $result->MoveNext();
518 </ul>
519 </form>
521 <input type="button" class="genreport" value="<?php xl('Generate Report', 'e'); ?>" />&nbsp;
522 <input type="button" class="genpdfrep" value="<?php xl('Download PDF', 'e'); ?>" />&nbsp;
523 <?php if ($cmsportal) { ?>
524 <input type="button" class="genportal" value="<?php xl('Send to Portal', 'e'); ?>" />
525 <?php } ?>
527 </div> <!-- close patient_reports DIV -->
528 </body>
530 <script language="javascript">
532 // jQuery stuff to make the page a little easier to use
533 $(document).ready(function(){
534 $(".genreport").click(function() { top.restoreSession(); document.report_form.pdf.value = 0; $("#report_form").submit(); });
535 $(".genpdfrep").click(function() { top.restoreSession(); document.report_form.pdf.value = 1; $("#report_form").submit(); });
536 $(".genportal").click(function() { top.restoreSession(); document.report_form.pdf.value = 2; $("#report_form").submit(); });
537 $("#genfullreport").click(function() { location.href='<?php echo "$rootdir/patient_file/encounter/$returnurl";?>'; });
538 //$("#printform").click(function() { PrintForm(); });
539 $(".issuecheckbox").click(function() { issueClick(this); });
541 // check/uncheck all Forms of an encounter
542 $(".encounter").click(function() { SelectForms($(this)); });
544 $(".generateCCR").click(
545 function() {
546 if(document.getElementById('show_date').checked == true){
547 if(document.getElementById('Start').value == '' || document.getElementById('End').value == ''){
548 alert('<?php echo addslashes(xl('Please select a start date and end date')) ?>');
549 return false;
552 var ccrAction = document.getElementsByName('ccrAction');
553 ccrAction[0].value = 'generate';
554 var raw = document.getElementsByName('raw');
555 raw[0].value = 'no';
556 top.restoreSession();
557 ccr_form.setAttribute("target", "_blank");
558 $("#ccr_form").submit();
559 ccr_form.setAttribute("target", "");
561 $(".generateCCR_raw").click(
562 function() {
563 var ccrAction = document.getElementsByName('ccrAction');
564 ccrAction[0].value = 'generate';
565 var raw = document.getElementsByName('raw');
566 raw[0].value = 'yes';
567 top.restoreSession();
568 ccr_form.setAttribute("target", "_blank");
569 $("#ccr_form").submit();
570 ccr_form.setAttribute("target", "");
572 $(".generateCCR_download_h").click(
573 function() {
574 var ccrAction = document.getElementsByName('ccrAction');
575 ccrAction[0].value = 'generate';
576 var raw = document.getElementsByName('raw');
577 raw[0].value = 'hybrid';
578 top.restoreSession();
579 $("#ccr_form").submit();
581 $(".generateCCR_download_p").click(
582 function() {
583 if(document.getElementById('show_date').checked == true){
584 if(document.getElementById('Start').value == '' || document.getElementById('End').value == ''){
585 alert('<?php echo addslashes(xl('Please select a start date and end date')) ?>');
586 return false;
589 var ccrAction = document.getElementsByName('ccrAction');
590 ccrAction[0].value = 'generate';
591 var raw = document.getElementsByName('raw');
592 raw[0].value = 'pure';
593 top.restoreSession();
594 $("#ccr_form").submit();
596 $(".viewCCD").click(
597 function() {
598 var ccrAction = document.getElementsByName('ccrAction');
599 ccrAction[0].value = 'viewccd';
600 var raw = document.getElementsByName('raw');
601 raw[0].value = 'no';
602 top.restoreSession();
603 ccr_form.setAttribute("target", "_blank");
604 $("#ccr_form").submit();
605 ccr_form.setAttribute("target", "");
607 $(".viewCCD_raw").click(
608 function() {
609 var ccrAction = document.getElementsByName('ccrAction');
610 ccrAction[0].value = 'viewccd';
611 var raw = document.getElementsByName('raw');
612 raw[0].value = 'yes';
613 top.restoreSession();
614 ccr_form.setAttribute("target", "_blank");
615 $("#ccr_form").submit();
616 ccr_form.setAttribute("target", "");
618 $(".viewCCD_download").click(
619 function() {
620 var ccrAction = document.getElementsByName('ccrAction');
621 ccrAction[0].value = 'viewccd';
622 var raw = document.getElementsByName('raw');
623 raw[0].value = 'pure';
624 $("#ccr_form").submit();
626 <?php if ($GLOBALS['phimail_enable']==true && $GLOBALS['phimail_ccr_enable']==true) { ?>
627 $(".viewCCR_send_dialog").click(
628 function() {
629 $("#ccr_send_dialog").toggle();
631 $(".viewCCR_transmit").click(
632 function() {
633 $(".viewCCR_transmit").attr('disabled','disabled');
634 var ccrAction = document.getElementsByName('ccrAction');
635 ccrAction[0].value = 'generate';
636 var ccrRecipient = $("#ccr_send_to").val();
637 var raw = document.getElementsByName('raw');
638 raw[0].value = 'send '+ccrRecipient;
639 if(ccrRecipient=="") {
640 $("#ccr_send_message").html("<?php
641 echo htmlspecialchars(xl('Please enter a valid Direct Address above.'), ENT_QUOTES);?>");
642 $("#ccr_send_result").show();
643 } else {
644 $(".viewCCR_transmit").attr('disabled','disabled');
645 $("#ccr_send_message").html("<?php
646 echo htmlspecialchars(xl('Working... this may take a minute.'), ENT_QUOTES);?>");
647 $("#ccr_send_result").show();
648 var action=$("#ccr_form").attr('action');
649 $.post(action, {ccrAction:'generate',raw:'send '+ccrRecipient,requested_by:'user'},
650 function(data) {
651 if(data=="SUCCESS") {
652 $("#ccr_send_message").html("<?php
653 echo htmlspecialchars(xl('Your message was submitted for delivery to'), ENT_QUOTES);
654 ?> "+ccrRecipient);
655 $("#ccr_send_to").val("");
656 } else {
657 $("#ccr_send_message").html(data);
659 $(".viewCCR_transmit").removeAttr('disabled');
663 <?php }
665 if ($GLOBALS['phimail_enable']==true && $GLOBALS['phimail_ccd_enable']==true) { ?>
666 $(".viewCCD_send_dialog").click(
667 function() {
668 $("#ccd_send_dialog").toggle();
670 $(".viewCCD_transmit").click(
671 function() {
672 $(".viewCCD_transmit").attr('disabled','disabled');
673 var ccrAction = document.getElementsByName('ccrAction');
674 ccrAction[0].value = 'viewccd';
675 var ccdRecipient = $("#ccd_send_to").val();
676 var raw = document.getElementsByName('raw');
677 raw[0].value = 'send '+ccdRecipient;
678 if(ccdRecipient=="") {
679 $("#ccd_send_message").html("<?php
680 echo htmlspecialchars(xl('Please enter a valid Direct Address above.'), ENT_QUOTES);?>");
681 $("#ccd_send_result").show();
682 } else {
683 $(".viewCCD_transmit").attr('disabled','disabled');
684 $("#ccd_send_message").html("<?php
685 echo htmlspecialchars(xl('Working... this may take a minute.'), ENT_QUOTES);?>");
686 $("#ccd_send_result").show();
687 var action=$("#ccr_form").attr('action');
688 $.post(action, {ccrAction:'viewccd',raw:'send '+ccdRecipient,requested_by:'user'},
689 function(data) {
690 if(data=="SUCCESS") {
691 $("#ccd_send_message").html("<?php
692 echo htmlspecialchars(xl('Your message was submitted for delivery to'), ENT_QUOTES);
693 ?> "+ccdRecipient);
694 $("#ccd_send_to").val("");
695 } else {
696 $("#ccd_send_message").html(data);
698 $(".viewCCD_transmit").removeAttr('disabled');
702 <?php } ?>
706 // select/deselect the Forms related to the selected Encounter
707 // (it ain't pretty code folks)
708 var SelectForms = function (selectedEncounter) {
709 if ($(selectedEncounter).attr("checked")) {
710 $(selectedEncounter).parent().children().each(function(i, obj) {
711 $(this).children().each(function(i, obj) {
712 $(this).attr("checked", "checked");
716 else {
717 $(selectedEncounter).parent().children().each(function(i, obj) {
718 $(this).children().each(function(i, obj) {
719 $(this).removeAttr("checked");
725 // When an issue is checked, auto-check all the related encounters and forms
726 function issueClick(issue) {
727 // do nothing when unchecked
728 if (! $(issue).attr("checked")) return;
730 $("#report_form :checkbox").each(function(i, obj) {
731 if ($(issue).val().indexOf('/' + $(this).val() + '/') >= 0) {
732 $(this).attr("checked", "checked");
738 </script>
740 </html>