bug fix for note save return after fancybox replace. (#1320)
[openemr.git] / interface / orders / single_order_results.php
blob5f89cabe24dd196c22a56afa5bcaa8aa4ccf6adb
1 <?php
2 /**
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>.
18 * @package OpenEMR
19 * @author Rod Roark <rod@sunsetsystems.com>
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) {
31 die(xl('Not authorized'));
34 $orderid = intval($_GET['orderid']);
36 $finals_only = empty($_POST['form_showall']);
38 if (!empty($_POST['form_sign']) && !empty($_POST['form_sign_list'])) {
39 if (!acl_check('patients', 'sign')) {
40 die(xl('Not authorized to sign results'));
43 // When signing results we are careful to sign only those reports that were
44 // in the sending form. While this will usually be all the reports linked to
45 // the order it's possible for a new report to come in while viewing these,
46 // and it would be very bad to sign results that nobody has seen!
47 $arrSign = explode(',', $_POST['form_sign_list']);
48 foreach ($arrSign as $id) {
49 sqlStatement("UPDATE procedure_report SET " .
50 "review_status = 'reviewed' WHERE " .
51 "procedure_report_id = ?", array($id));
55 // This mess generates a PDF report and sends it to the patient.
56 if (!empty($_POST['form_send_to_portal'])) {
57 // Borrowing the general strategy here from custom_report.php.
58 // See also: http://wiki.spipu.net/doku.php?id=html2pdf:en:v3:output
59 require_once("$srcdir/html2pdf/html2pdf.class.php");
60 require_once($GLOBALS["include_root"] . "/cmsportal/portal.inc.php");
61 $pdf = new HTML2PDF('P', 'Letter', 'en');
62 ob_start();
63 echo "<link rel='stylesheet' type='text/css' href='$webserver_root/interface/themes/style_pdf.css'>\n";
64 echo "<link rel='stylesheet' type='text/css' href='$webserver_root/library/ESign/css/esign_report.css'>\n";
65 $GLOBALS['PATIENT_REPORT_ACTIVE'] = true;
66 generate_order_report($orderid, false, true, $finals_only);
67 $GLOBALS['PATIENT_REPORT_ACTIVE'] = false;
68 // echo ob_get_clean(); exit(); // debugging
69 $pdf->writeHTML(ob_get_clean(), false);
70 $contents = $pdf->Output('', true);
71 // Send message with PDF as attachment.
72 $result = cms_portal_call(array(
73 'action' => 'putmessage',
74 'user' => $_POST['form_send_to_portal'],
75 'title' => xl('Your Lab Results'),
76 'message' => xl('Please see the attached PDF.'),
77 'filename' => 'results.pdf',
78 'mimetype' => 'application/pdf',
79 'contents' => base64_encode($contents),
80 ));
81 if ($result['errmsg']) {
82 die(text($result['errmsg']));
86 <html>
87 <head>
88 <?php html_header_show(); ?>
89 <link rel="stylesheet" href='<?php echo $css_header; ?>' type='text/css'>
90 <title><?php echo xlt('Order Results'); ?></title>
91 <style>
92 body {
93 margin: 9pt;
94 font-family: sans-serif;
95 font-size: 1em;
97 </style>
99 <script type="text/javascript" src="../../library/topdialog.js"></script>
100 <script language="JavaScript">
101 <?php require($GLOBALS['srcdir'] . "/restoreSession.php"); ?>
102 </script>
104 </head>
105 <body>
106 <?php
107 if (empty($_POST['form_sign'])) {
108 generate_order_report($orderid, true, true, $finals_only);
109 } else {
111 <script language='JavaScript'>
112 if (opener.document.forms && opener.document.forms[0]) {
113 // Opener should be list_reports.php. Make it refresh.
114 var f = opener.document.forms[0];
115 if (f.form_external_refresh) {
116 f.form_external_refresh.value = '1';
117 f.submit();
120 window.close();
121 </script>
122 <?php
125 </body>
126 </html>