3 * Script to display results for a given procedure order.
5 * Copyright (C) 2013-2015 Rod Roark <rod@sunsetsystems.com>
7 * LICENSE: This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the 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 General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>.
19 * @author Rod Roark <rod@sunsetsystems.com>
22 $sanitize_all_escapes = true;
23 $fake_register_globals = false;
25 require_once(dirname(__FILE__
) . '/../globals.php');
26 require_once($GLOBALS["include_root"] . "/orders/single_order_results.inc.php");
28 // Check authorization.
29 $thisauth = acl_check('patients', 'med');
30 if (!$thisauth) die(xl('Not authorized'));
32 $orderid = intval($_GET['orderid']);
34 $finals_only = empty($_POST['form_showall']);
36 if (!empty($_POST['form_sign']) && !empty($_POST['form_sign_list'])) {
37 if (!acl_check('patients', 'sign')) {
38 die(xl('Not authorized to sign results'));
40 // When signing results we are careful to sign only those reports that were
41 // in the sending form. While this will usually be all the reports linked to
42 // the order it's possible for a new report to come in while viewing these,
43 // and it would be very bad to sign results that nobody has seen!
44 $arrSign = explode(',', $_POST['form_sign_list']);
45 foreach ($arrSign as $id) {
46 sqlStatement("UPDATE procedure_report SET " .
47 "review_status = 'reviewed' WHERE " .
48 "procedure_report_id = ?", array($id));
52 // This mess generates a PDF report and sends it to the patient.
53 if (!empty($_POST['form_send_to_portal'])) {
54 // Borrowing the general strategy here from custom_report.php.
55 // See also: http://wiki.spipu.net/doku.php?id=html2pdf:en:v3:output
56 require_once("$srcdir/html2pdf/html2pdf.class.php");
57 require_once($GLOBALS["include_root"] . "/cmsportal/portal.inc.php");
58 $pdf = new HTML2PDF('P', 'Letter', 'en');
60 echo "<link rel='stylesheet' type='text/css' href='$webserver_root/interface/themes/style_pdf.css'>\n";
61 echo "<link rel='stylesheet' type='text/css' href='$webserver_root/library/ESign/css/esign_report.css'>\n";
62 $GLOBALS['PATIENT_REPORT_ACTIVE'] = true;
63 generate_order_report($orderid, false, true, $finals_only);
64 $GLOBALS['PATIENT_REPORT_ACTIVE'] = false;
65 // echo ob_get_clean(); exit(); // debugging
66 $pdf->writeHTML(ob_get_clean(), false);
67 $contents = $pdf->Output('', true);
68 // Send message with PDF as attachment.
69 $result = cms_portal_call(array(
70 'action' => 'putmessage',
71 'user' => $_POST['form_send_to_portal'],
72 'title' => xl('Your Lab Results'),
73 'message' => xl('Please see the attached PDF.'),
74 'filename' => 'results.pdf',
75 'mimetype' => 'application/pdf',
76 'contents' => base64_encode($contents),
78 if ($result['errmsg']) die(text($result['errmsg']));
83 <?php
html_header_show(); ?
>
84 <link rel
="stylesheet" href
='<?php echo $css_header; ?>' type
='text/css'>
85 <title
><?php
echo xlt('Order Results'); ?
></title
>
89 font
-family
: sans
-serif
;
94 <script type
="text/javascript" src
="../../library/topdialog.js"></script
>
95 <script language
="JavaScript">
96 <?php
require($GLOBALS['srcdir'] . "/restoreSession.php"); ?
>
102 if (empty($_POST['form_sign'])) {
103 generate_order_report($orderid, true, true, $finals_only);
107 <script language
='JavaScript'>
108 if (opener
.document
.forms
&& opener
.document
.forms
[0]) {
109 // Opener should be list_reports.php. Make it refresh.
110 var f
= opener
.document
.forms
[0];
111 if (f
.form_external_refresh
) {
112 f
.form_external_refresh
.value
= '1';