4 * Script to display results for a given procedure order.
7 * @link https://www.open-emr.org
8 * @author Rod Roark <rod@sunsetsystems.com>
9 * @author Brady Miller <brady.g.miller@gmail.com>
10 * @copyright Copyright (c) 2013-2015 Rod Roark <rod@sunsetsystems.com>
11 * @copyright Copyright (c) 2019 Brady Miller <brady.g.miller@gmail.com>
12 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
15 require_once(dirname(__FILE__
) . '/../globals.php');
16 require_once($GLOBALS["include_root"] . "/orders/single_order_results.inc.php");
19 use OpenEMR\Common\Acl\AclMain
;
20 use OpenEMR\Common\Twig\TwigContainer
;
21 use OpenEMR\Core\Header
;
23 // Check authorization.
24 $thisauth = AclMain
::aclCheckCore('patients', 'med');
26 echo (new TwigContainer(null, $GLOBALS['kernel']))->getTwig()->render('core/unauthorized.html.twig', ['pageTitle' => xl("Order Results")]);
30 $orderid = intval($_GET['orderid']);
32 $finals_only = empty($_POST['form_showall']);
34 if (!empty($_POST['form_sign']) && !empty($_POST['form_sign_list'])) {
35 if (!AclMain
::aclCheckCore('patients', 'sign')) {
36 die(xlt('Not authorized to sign results'));
39 // When signing results we are careful to sign only those reports that were
40 // in the sending form. While this will usually be all the reports linked to
41 // the order it's possible for a new report to come in while viewing these,
42 // and it would be very bad to sign results that nobody has seen!
43 $arrSign = explode(',', $_POST['form_sign_list']);
44 foreach ($arrSign as $id) {
45 sqlStatement("UPDATE procedure_report SET " .
46 "review_status = 'reviewed' WHERE " .
47 "procedure_report_id = ?", array($id));
50 sqlStatement("UPDATE procedure_order SET " .
51 "order_status = 'complete' WHERE " .
52 "procedure_order_id = ?", array($orderid));
56 // This mess generates a PDF report and sends it to the patient.
57 if (!empty($_POST['form_send_to_portal'])) {
58 // Borrowing the general strategy here from custom_report.php.
59 // See also: http://wiki.spipu.net/doku.php?id=html2pdf:en:v3:output
60 require_once($GLOBALS["include_root"] . "/cmsportal/portal.inc.php");
62 'tempDir' => $GLOBALS['MPDF_WRITE_DIR'],
63 'mode' => $GLOBALS['pdf_language'],
65 'default_font_size' => '9',
66 'default_font' => 'dejavusans',
67 'margin_left' => $GLOBALS['pdf_left_margin'],
68 'margin_right' => $GLOBALS['pdf_right_margin'],
69 'margin_top' => $GLOBALS['pdf_top_margin'],
70 'margin_bottom' => $GLOBALS['pdf_bottom_margin'],
71 'margin_header' => '',
72 'margin_footer' => '',
74 'shrink_tables_to_fit' => 1,
76 'autoScriptToLang' => true,
77 'keep_table_proportions' => true
79 $pdf = new mPDF($config_mpdf);
80 if ($_SESSION['language_direction'] == 'rtl') {
81 $pdf->SetDirectionality('rtl');
84 echo "<link rel='stylesheet' type='text/css' href='$webserver_root/interface/themes/style_pdf.css'>\n";
85 echo "<link rel='stylesheet' type='text/css' href='$webserver_root/library/ESign/css/esign_report.css'>\n";
86 $GLOBALS['PATIENT_REPORT_ACTIVE'] = true;
87 generate_order_report($orderid, false, true, $finals_only);
88 $GLOBALS['PATIENT_REPORT_ACTIVE'] = false;
89 // echo ob_get_clean(); exit(); // debugging
90 $pdf->writeHTML(ob_get_clean());
91 $contents = $pdf->Output('', true);
92 // Send message with PDF as attachment.
93 $result = cms_portal_call(array(
94 'action' => 'putmessage',
95 'user' => $_POST['form_send_to_portal'],
96 'title' => xl('Your Lab Results'),
97 'message' => xl('Please see the attached PDF.'),
98 'filename' => 'results.pdf',
99 'mimetype' => 'application/pdf',
100 'contents' => base64_encode($contents),
102 if ($result['errmsg']) {
103 die(text($result['errmsg']));
109 <?php Header
::setupHeader(); ?
>
110 <title
><?php
echo xlt('Order Results'); ?
></title
>
114 font
-family
: sans
-serif
;
119 <script src
="../../library/topdialog.js"></script
>
121 <?php
require($GLOBALS['srcdir'] . "/restoreSession.php"); ?
>
126 <?php
if (empty($_POST['form_sign'])) {
127 generate_order_report($orderid, true, true, $finals_only);
130 if (opener
.document
.forms
&& opener
.document
.forms
[0]) {
131 // Opener should be list_reports.php. Make it refresh.
132 var f
= opener
.document
.forms
[0];
133 if (f
.form_external_refresh
) {
134 f
.form_external_refresh
.value
= '1';
138 let stayHere
= './single_order_results.php?orderid=' +
<?php
echo js_escape($orderid); ?
>;
139 window
.location
.assign(stayHere
);