fixes for prior commit - moved Documents menu item to Procedures->Lab documents
[openemr.git] / interface / patient_file / report / patient_report.php
blob8053e0fb87cf96b2933ff62aec9fb24c192dcbf8
1 <?php
3 include_once("../../globals.php");
4 include_once("$srcdir/lists.inc");
5 include_once("$srcdir/acl.inc");
6 include_once("$srcdir/forms.inc");
7 include_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['webroot'] ?>/library/js/jquery.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 <?php if ( $GLOBALS['activate_ccr_ccd_report'] ) { // show CCR/CCD reporting options ?>
65 <div id="ccr_report">
67 <form name='ccr_form' id='ccr_form' method='post' action='../../../ccr/createCCR.php'>
68 <span class='title'><?php xl('Continuity of Care Record (CCR)','e'); ?></span>&nbsp;&nbsp;
69 <br/>
70 <span class='text'>(<?php xl('Pop ups need to be enabled to see these reports','e'); ?>)</span>
71 <br/>
72 <br/>
73 <input type='hidden' name='ccrAction'>
74 <input type='hidden' name='raw'>
75 <input type="checkbox" name="show_date" id="show_date" onchange="show_date_fun();" ><span class='text'><?php xl('Use Date Range','e'); ?>
76 <br>
77 <div id="date_div" style="display:none" >
78 <br>
79 <table border="0" cellpadding="0" cellspacing="0" >
80 <tr>
81 <td>
82 <span class='bold'><?php xl('Start Date','e');?>: </span>
83 </td>
84 <td>
85 <input type='text' size='10' name='Start' id='Start'
86 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)'
87 title='<?php xl('yyyy-mm-dd','e'); ?>' />
88 <img src='../../pic/show_calendar.gif' align='absbottom' width='24' height='22'
89 id='img_start' border='0' alt='[?]' style='cursor:pointer'
90 title='<?php xl('Click here to choose a date','e'); ?>' >
91 <script LANGUAGE="JavaScript">
92 Calendar.setup({inputField:"Start", ifFormat:"%Y-%m-%d", button:"img_start"});
93 </script>
94 </td>
95 <td>
96 &nbsp;
97 <span class='bold'><?php xl('End Date','e');?>: </span>
98 </td>
99 <td>
100 <input type='text' size='10' name='End' id='End'
101 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)'
102 title='<?php xl('yyyy-mm-dd','e'); ?>' />
103 <img src='../../pic/show_calendar.gif' align='absbottom' width='24' height='22'
104 id='img_end' border='0' alt='[?]' style='cursor:pointer'
105 title='<?php xl('Click here to choose a date','e'); ?>' >
106 <script LANGUAGE="JavaScript">
107 Calendar.setup({inputField:"End", ifFormat:"%Y-%m-%d", button:"img_end"});
108 </script>
109 </td>
110 </tr>
111 </table>
112 </div>
113 <br>
114 <input type="button" class="generateCCR" value="<?php xl('View/Print','e'); ?>" />
115 <!-- <input type="button" class="generateCCR_download_h" value="<?php echo xl('Download')." (Hybrid)"; ?>" /> -->
116 <input type="button" class="generateCCR_download_p" value="<?php echo xl('Download'); ?>" />
117 <!-- <input type="button" class="generateCCR_raw" value="<?php xl('Raw Report','e'); ?>" /> -->
118 <?php if ($GLOBALS['phimail_enable']==true && $GLOBALS['phimail_ccr_enable']==true) { ?>
119 <input type="button" class="viewCCR_send_dialog" value="<?php echo htmlspecialchars( xl('Transmit', ENT_QUOTES)); ?>" />
120 <br>
121 <div id="ccr_send_dialog" style="display:none" >
122 <br>
123 <table border="0" cellpadding="0" cellspacing="0" >
124 <tr>
125 <td>
126 <span class='bold'><?php echo htmlspecialchars( xl('Enter Recipient\'s Direct Address'), ENT_NOQUOTES);?>: </span>
127 <input type="text" size="64" name="ccr_send_to" id="ccr_send_to" value="">
128 <input type="hidden" name="ccr_sent_by" id="ccr_sent_by" value="user">
129 <input type="button" class="viewCCR_transmit" value="<?php echo htmlspecialchars( xl('Send', ENT_QUOTES)); ?>" />
130 <div id="ccr_send_result" style="display:none" >
131 <span class="text" id="ccr_send_message"></span>
132 </div>
133 </td>
134 </tr>
135 </table>
136 </div>
137 <?php } ?>
138 <hr/>
139 <span class='title'><?php xl('Continuity of Care Document (CCD)','e'); ?></span>&nbsp;&nbsp;
140 <br/>
141 <span class='text'>(<?php xl('Pop ups need to be enabled to see these reports','e'); ?>)</span>
142 <br/>
143 <br/>
144 <input type="button" class="viewCCD" value="<?php xl('View/Print','e'); ?>" />
145 <input type="button" class="viewCCD_download" value="<?php echo htmlspecialchars( xl('Download', ENT_QUOTES)); ?>" />
146 <!-- <input type="button" class="viewCCD_raw" value="<?php xl('Raw Report','e'); ?>" /> -->
147 <?php if ($GLOBALS['phimail_enable']==true && $GLOBALS['phimail_ccd_enable']==true) { ?>
148 <input type="button" class="viewCCD_send_dialog" value="<?php echo htmlspecialchars( xl('Transmit', ENT_QUOTES)); ?>" />
149 <br>
150 <div id="ccd_send_dialog" style="display:none" >
151 <br>
152 <table border="0" cellpadding="0" cellspacing="0" >
153 <tr>
154 <td>
155 <span class='bold'><?php echo htmlspecialchars( xl('Enter Recipient\'s Direct Address'), ENT_NOQUOTES);?>: </span>
156 <input type="text" size="64" name="ccd_send_to" id="ccd_send_to" value="">
157 <input type="hidden" name="ccd_sent_by" id="ccd_sent_by" value="user">
158 <input type="button" class="viewCCD_transmit" value="<?php echo htmlspecialchars( xl('Send', ENT_QUOTES)); ?>" />
159 <div id="ccd_send_result" style="display:none" >
160 <span class="text" id="ccd_send_message"></span>
161 </div>
162 </td>
163 </tr>
164 </table>
165 </div>
166 <?php } ?>
168 </form>
169 <hr/>
170 <hr/>
172 </div>
173 <?php } // end CCR/CCD reporting options ?>
175 <form name='report_form' id="report_form" method='post' action='custom_report.php'>
178 <span class='title'><?php xl('Patient Report','e'); ?></span>&nbsp;&nbsp;
180 <!--
181 <a class="link_submit" href="full_report.php" onclick="top.restoreSession()">
182 [<?php xl('View Comprehensive Patient Report','e'); ?>]</a>
184 <a class="link_submit" href="#" onclick="return checkAll(true)"><?php xl('Check All','e'); ?></a>
186 <a class="link_submit" href="#" onclick="return checkAll(false)"><?php xl('Clear All','e'); ?></a>
189 <table class="includes">
190 <tr>
191 <td class='text'>
192 <input type='checkbox' name='include_demographics' id='include_demographics' value="demographics" checked><?php xl('Demographics','e'); ?><br>
193 <?php if (acl_check('patients', 'med')): ?>
194 <input type='checkbox' name='include_history' id='include_history' value="history"><?php xl('History','e'); ?><br>
195 <?php endif; ?>
196 <!--
197 <input type='checkbox' name='include_employer' id='include_employer' value="employer"><?php xl('Employer','e'); ?><br>
199 <input type='checkbox' name='include_insurance' id='include_insurance' value="insurance"><?php xl('Insurance','e'); ?><br>
200 <input type='checkbox' name='include_billing' id='include_billing' value="billing"
201 <?php if (!$GLOBALS['simplified_demographics']) echo 'checked'; ?>><?php xl('Billing','e'); ?><br>
202 </td>
203 <td class='text'>
204 <!--
205 <input type='checkbox' name='include_allergies' id='include_allergies' value="allergies">Allergies<br>
206 <input type='checkbox' name='include_medications' id='include_medications' value="medications">Medications<br>
208 <input type='checkbox' name='include_immunizations' id='include_immunizations' value="immunizations"><?php xl('Immunizations','e'); ?><br>
209 <!--
210 <input type='checkbox' name='include_medical_problems' id='include_medical_problems' value="medical_problems">Medical Problems<br>
212 <input type='checkbox' name='include_notes' id='include_notes' value="notes"><?php xl('Patient Notes','e'); ?><br>
213 <input type='checkbox' name='include_transactions' id='include_transactions' value="transactions"><?php xl('Transactions','e'); ?><br>
214 <input type='checkbox' name='include_batchcom' id='include_batchcom' value="batchcom"><?php xl('Communications','e'); ?><br>
215 </td>
216 </tr>
217 </table>
219 <br>
220 <input type="button" class="genreport" value="<?php xl('Generate Report','e'); ?>" />&nbsp;
221 <input type="button" class="genpdfrep" value="<?php xl('Download PDF','e'); ?>" />&nbsp;
222 <?php if ($cmsportal) { ?>
223 <input type="button" class="genportal" value="<?php xl('Send to Portal','e'); ?>" />
224 <?php } ?>
225 <input type='hidden' name='pdf' value='0'>
226 <br>
228 <!-- old ccr button position -->
229 <hr/>
231 <table class="issues_encounters_forms">
232 <tr>
234 <!-- Issues -->
235 <td class='text'>
236 <div class="issues">
237 <span class='bold'><?php xl('Issues','e'); ?>:</span>
238 <br>
239 <br>
241 <?php if (! acl_check('patients', 'med')): ?>
242 <br>(Issues not authorized)
244 <?php else: ?>
245 <table>
247 <?php
248 // get issues
249 $pres = sqlStatement("SELECT * FROM lists WHERE pid = $pid " .
250 "ORDER BY type, begdate");
251 $lasttype = "";
252 while ($prow = sqlFetchArray($pres)) {
253 if ($lasttype != $prow['type']) {
254 $lasttype = $prow['type'];
256 /****
257 $disptype = $lasttype;
258 switch ($lasttype) {
259 case "allergy" : $disptype = "Allergies" ; break;
260 case "problem" :
261 case "medical_problem": $disptype = "Medical Problems"; break;
262 case "medication" : $disptype = "Medications" ; break;
263 case "surgery" : $disptype = "Surgeries" ; break;
265 ****/
266 $disptype = $ISSUE_TYPES[$lasttype][0];
268 echo " <tr>\n";
269 echo " <td colspan='4' class='bold'><b>$disptype</b></td>\n";
270 echo " </tr>\n";
272 $rowid = $prow['id'];
273 $disptitle = trim($prow['title']) ? $prow['title'] : "[Missing Title]";
275 $ieres = sqlStatement("SELECT encounter FROM issue_encounter WHERE " .
276 "pid = '$pid' AND list_id = '$rowid'");
278 echo " <tr class='text'>\n";
279 echo " <td>&nbsp;</td>\n";
280 echo " <td>";
281 echo "<input type='checkbox' name='issue_$rowid' id='issue_$rowid' class='issuecheckbox' value='/";
282 while ($ierow = sqlFetchArray($ieres)) {
283 echo $ierow['encounter'] . "/";
285 echo "' />$disptitle</td>\n";
286 echo " <td>" . $prow['begdate'];
288 if ($prow['enddate']) { echo " - " . $prow['enddate']; }
289 else { echo " Active"; }
291 echo "</td>\n";
292 echo "</tr>\n";
295 </table>
297 <?php endif; // end of Issues output ?>
299 </div> <!-- end issues DIV -->
300 </td>
302 <!-- Encounters and Forms -->
304 <td class='text'>
305 <div class='encounters'>
306 <span class='bold'><?php xl('Encounters &amp; Forms','e'); ?>:</span>
307 <br><br>
309 <?php if (!($auth_notes_a || $auth_notes || $auth_coding_a || $auth_coding || $auth_med || $auth_relaxed)): ?>
310 (Encounters not authorized)
311 <?php else: ?>
313 <?php
315 $isfirst = 1;
316 $res = sqlStatement("SELECT forms.encounter, forms.form_id, forms.form_name, " .
317 "forms.formdir, forms.date AS fdate, form_encounter.date " .
318 ",form_encounter.reason ".
319 "FROM forms, form_encounter WHERE " .
320 "forms.pid = '$pid' AND form_encounter.pid = '$pid' AND " .
321 "form_encounter.encounter = forms.encounter " .
322 " AND forms.deleted=0 ". // --JRM--
323 "ORDER BY form_encounter.date DESC, fdate ASC");
324 $res2 = sqlStatement("SELECT name FROM registry ORDER BY priority");
325 $html_strings = array();
326 $registry_form_name = array();
327 while($result2 = sqlFetchArray($res2)) {
328 array_push($registry_form_name,trim($result2['name']));
330 while($result = sqlFetchArray($res)) {
331 if ($result{"form_name"} == "New Patient Encounter") {
332 if ($isfirst == 0) {
333 foreach($registry_form_name as $var) {
334 if ($toprint = $html_strings[$var]) {
335 foreach($toprint as $var) {print $var;}
338 $html_strings = array();
339 echo "</div>\n"; // end DIV encounter_forms
340 echo "</div>\n\n"; //end DIV encounter_data
341 echo "<br>";
343 $isfirst = 0;
344 echo "<div class='encounter_data'>\n";
345 echo "<input type=checkbox ".
346 " name='" . $result{"formdir"} . "_" . $result{"form_id"} . "'".
347 " id='" . $result{"formdir"} . "_" . $result{"form_id"} . "'".
348 " value='" . $result{"encounter"} . "'" .
349 " class='encounter'".
350 " >";
352 // show encounter reason, not just 'New Encounter'
353 // trim to a reasonable length for display purposes --cfapress
354 $maxReasonLength = 20;
355 if (strlen($result["reason"]) > $maxReasonLength) {
356 $result['reason'] = substr($result['reason'], 0, $maxReasonLength) . " ... ";
359 echo $result{"reason"}.
360 " (" . date("Y-m-d",strtotime($result{"date"})) .
361 ")\n";
362 echo "<div class='encounter_forms'>\n";
364 else {
365 $form_name = trim($result{"form_name"});
366 //if form name is not in registry, look for the closest match by
367 // finding a registry name which is at the start of the form name.
368 //this is to allow for forms to put additional helpful information
369 //in the database in the same string as their form name after the name
370 $form_name_found_flag = 0;
371 foreach($registry_form_name as $var) {if ($var == $form_name) {$form_name_found_flag = 1;}}
372 // if the form does not match precisely with any names in the registry, now see if any front partial matches
373 // and change $form_name appropriately so it will print above in $toprint = $html_strings[$var]
374 if (!$form_name_found_flag) { foreach($registry_form_name as $var) {if (strpos($form_name,$var) == 0) {$form_name = $var;}}}
376 if (!is_array($html_strings[$form_name])) {$html_strings[$form_name] = array();}
377 array_push($html_strings[$form_name], "<input type='checkbox' ".
378 " name='" . $result{"formdir"} . "_" . $result{"form_id"} . "'".
379 " id='" . $result{"formdir"} . "_" . $result{"form_id"} . "'".
380 " value='" . $result{"encounter"} . "'" .
381 " class='encounter_form' ".
382 ">" . xl_form_title($result{"form_name"}) . "<br>\n");
385 foreach($registry_form_name as $var) {
386 if ($toprint = $html_strings[$var]) {
387 foreach($toprint as $var) {print $var;}
392 <?php endif; ?>
394 </div> <!-- end encounters DIV -->
395 </td>
396 </tr>
397 </table>
398 <input type="button" class="genreport" value="<?php xl('Generate Report','e'); ?>" />&nbsp;
399 <input type="button" class="genpdfrep" value="<?php xl('Download PDF','e'); ?>" />&nbsp;
400 <?php if ($cmsportal) { ?>
401 <input type="button" class="genportal" value="<?php xl('Send to Portal','e'); ?>" />
402 <?php } ?>
404 <hr/>
406 <span class="bold"><?php xl('Documents','e'); ?></span>:<br>
407 <ul>
408 <?php
409 // show available documents
410 $db = $GLOBALS['adodb']['db'];
411 $sql = "SELECT d.id, d.url, c.name FROM documents AS d " .
412 "LEFT JOIN categories_to_documents AS ctd ON d.id=ctd.document_id " .
413 "LEFT JOIN categories AS c ON c.id = ctd.category_id WHERE " .
414 "d.foreign_id = " . $db->qstr($pid);
415 $result = $db->Execute($sql);
416 if ($db->ErrorMsg()) echo $db->ErrorMsg();
417 while ($result && !$result->EOF) {
418 echo "<li class='bold'>";
419 echo '<input type="checkbox" name="documents[]" value="' .
420 $result->fields['id'] . '">';
421 echo '&nbsp;&nbsp;<i>' . xl_document_category($result->fields['name']) . "</i>";
422 echo '&nbsp;&nbsp;' . xl('Name') . ': <i>' . basename($result->fields['url']) . "</i>";
423 echo '</li>';
424 $result->MoveNext();
427 </ul>
428 </form>
430 <input type="button" class="genreport" value="<?php xl('Generate Report','e'); ?>" />&nbsp;
431 <input type="button" class="genpdfrep" value="<?php xl('Download PDF','e'); ?>" />&nbsp;
432 <?php if ($cmsportal) { ?>
433 <input type="button" class="genportal" value="<?php xl('Send to Portal','e'); ?>" />
434 <?php } ?>
436 </div> <!-- close patient_reports DIV -->
437 </body>
439 <script language="javascript">
441 // jQuery stuff to make the page a little easier to use
442 $(document).ready(function(){
443 $(".genreport").click(function() { top.restoreSession(); document.report_form.pdf.value = 0; $("#report_form").submit(); });
444 $(".genpdfrep").click(function() { top.restoreSession(); document.report_form.pdf.value = 1; $("#report_form").submit(); });
445 $(".genportal").click(function() { top.restoreSession(); document.report_form.pdf.value = 2; $("#report_form").submit(); });
446 $("#genfullreport").click(function() { location.href='<?php echo "$rootdir/patient_file/encounter/$returnurl";?>'; });
447 //$("#printform").click(function() { PrintForm(); });
448 $(".issuecheckbox").click(function() { issueClick(this); });
450 // check/uncheck all Forms of an encounter
451 $(".encounter").click(function() { SelectForms($(this)); });
453 $(".generateCCR").click(
454 function() {
455 if(document.getElementById('show_date').checked == true){
456 if(document.getElementById('Start').value == '' || document.getElementById('End').value == ''){
457 alert('<?php echo addslashes( xl('Please select a start date and end date')) ?>');
458 return false;
461 var ccrAction = document.getElementsByName('ccrAction');
462 ccrAction[0].value = 'generate';
463 var raw = document.getElementsByName('raw');
464 raw[0].value = 'no';
465 top.restoreSession();
466 ccr_form.setAttribute("target", "_blank");
467 $("#ccr_form").submit();
468 ccr_form.setAttribute("target", "");
470 $(".generateCCR_raw").click(
471 function() {
472 var ccrAction = document.getElementsByName('ccrAction');
473 ccrAction[0].value = 'generate';
474 var raw = document.getElementsByName('raw');
475 raw[0].value = 'yes';
476 top.restoreSession();
477 ccr_form.setAttribute("target", "_blank");
478 $("#ccr_form").submit();
479 ccr_form.setAttribute("target", "");
481 $(".generateCCR_download_h").click(
482 function() {
483 var ccrAction = document.getElementsByName('ccrAction');
484 ccrAction[0].value = 'generate';
485 var raw = document.getElementsByName('raw');
486 raw[0].value = 'hybrid';
487 top.restoreSession();
488 $("#ccr_form").submit();
490 $(".generateCCR_download_p").click(
491 function() {
492 if(document.getElementById('show_date').checked == true){
493 if(document.getElementById('Start').value == '' || document.getElementById('End').value == ''){
494 alert('<?php echo addslashes( xl('Please select a start date and end date')) ?>');
495 return false;
498 var ccrAction = document.getElementsByName('ccrAction');
499 ccrAction[0].value = 'generate';
500 var raw = document.getElementsByName('raw');
501 raw[0].value = 'pure';
502 top.restoreSession();
503 $("#ccr_form").submit();
505 $(".viewCCD").click(
506 function() {
507 var ccrAction = document.getElementsByName('ccrAction');
508 ccrAction[0].value = 'viewccd';
509 var raw = document.getElementsByName('raw');
510 raw[0].value = 'no';
511 top.restoreSession();
512 ccr_form.setAttribute("target", "_blank");
513 $("#ccr_form").submit();
514 ccr_form.setAttribute("target", "");
516 $(".viewCCD_raw").click(
517 function() {
518 var ccrAction = document.getElementsByName('ccrAction');
519 ccrAction[0].value = 'viewccd';
520 var raw = document.getElementsByName('raw');
521 raw[0].value = 'yes';
522 top.restoreSession();
523 ccr_form.setAttribute("target", "_blank");
524 $("#ccr_form").submit();
525 ccr_form.setAttribute("target", "");
527 $(".viewCCD_download").click(
528 function() {
529 var ccrAction = document.getElementsByName('ccrAction');
530 ccrAction[0].value = 'viewccd';
531 var raw = document.getElementsByName('raw');
532 raw[0].value = 'pure';
533 $("#ccr_form").submit();
535 <?php if ($GLOBALS['phimail_enable']==true && $GLOBALS['phimail_ccr_enable']==true) { ?>
536 $(".viewCCR_send_dialog").click(
537 function() {
538 $("#ccr_send_dialog").toggle();
540 $(".viewCCR_transmit").click(
541 function() {
542 $(".viewCCR_transmit").attr('disabled','disabled');
543 var ccrAction = document.getElementsByName('ccrAction');
544 ccrAction[0].value = 'generate';
545 var ccrRecipient = $("#ccr_send_to").val();
546 var raw = document.getElementsByName('raw');
547 raw[0].value = 'send '+ccrRecipient;
548 if(ccrRecipient=="") {
549 $("#ccr_send_message").html("<?php
550 echo htmlspecialchars(xl('Please enter a valid Direct Address above.'), ENT_QUOTES);?>");
551 $("#ccr_send_result").show();
552 } else {
553 $(".viewCCR_transmit").attr('disabled','disabled');
554 $("#ccr_send_message").html("<?php
555 echo htmlspecialchars(xl('Working... this may take a minute.'), ENT_QUOTES);?>");
556 $("#ccr_send_result").show();
557 var action=$("#ccr_form").attr('action');
558 $.post(action, {ccrAction:'generate',raw:'send '+ccrRecipient,requested_by:'user'},
559 function(data) {
560 if(data=="SUCCESS") {
561 $("#ccr_send_message").html("<?php
562 echo htmlspecialchars(xl('Your message was submitted for delivery to'), ENT_QUOTES);
563 ?> "+ccrRecipient);
564 $("#ccr_send_to").val("");
565 } else {
566 $("#ccr_send_message").html(data);
568 $(".viewCCR_transmit").removeAttr('disabled');
572 <?php }
573 if ($GLOBALS['phimail_enable']==true && $GLOBALS['phimail_ccd_enable']==true) { ?>
574 $(".viewCCD_send_dialog").click(
575 function() {
576 $("#ccd_send_dialog").toggle();
578 $(".viewCCD_transmit").click(
579 function() {
580 $(".viewCCD_transmit").attr('disabled','disabled');
581 var ccrAction = document.getElementsByName('ccrAction');
582 ccrAction[0].value = 'viewccd';
583 var ccdRecipient = $("#ccd_send_to").val();
584 var raw = document.getElementsByName('raw');
585 raw[0].value = 'send '+ccdRecipient;
586 if(ccdRecipient=="") {
587 $("#ccd_send_message").html("<?php
588 echo htmlspecialchars(xl('Please enter a valid Direct Address above.'), ENT_QUOTES);?>");
589 $("#ccd_send_result").show();
590 } else {
591 $(".viewCCD_transmit").attr('disabled','disabled');
592 $("#ccd_send_message").html("<?php
593 echo htmlspecialchars(xl('Working... this may take a minute.'), ENT_QUOTES);?>");
594 $("#ccd_send_result").show();
595 var action=$("#ccr_form").attr('action');
596 $.post(action, {ccrAction:'viewccd',raw:'send '+ccdRecipient,requested_by:'user'},
597 function(data) {
598 if(data=="SUCCESS") {
599 $("#ccd_send_message").html("<?php
600 echo htmlspecialchars(xl('Your message was submitted for delivery to'), ENT_QUOTES);
601 ?> "+ccdRecipient);
602 $("#ccd_send_to").val("");
603 } else {
604 $("#ccd_send_message").html(data);
606 $(".viewCCD_transmit").removeAttr('disabled');
610 <?php } ?>
614 // select/deselect the Forms related to the selected Encounter
615 // (it ain't pretty code folks)
616 var SelectForms = function (selectedEncounter) {
617 if ($(selectedEncounter).attr("checked")) {
618 $(selectedEncounter).parent().children().each(function(i, obj) {
619 $(this).children().each(function(i, obj) {
620 $(this).attr("checked", "checked");
624 else {
625 $(selectedEncounter).parent().children().each(function(i, obj) {
626 $(this).children().each(function(i, obj) {
627 $(this).removeAttr("checked");
633 // When an issue is checked, auto-check all the related encounters and forms
634 function issueClick(issue) {
635 // do nothing when unchecked
636 if (! $(issue).attr("checked")) return;
638 $("#report_form :checkbox").each(function(i, obj) {
639 if ($(issue).val().indexOf('/' + $(this).val() + '/') >= 0) {
640 $(this).attr("checked", "checked");
646 </script>
648 </html>