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