Remove concurrent_layout and clarify layout and themes selections (#272)
[openemr.git] / interface / orders / single_order_results.inc.php
blob3baeadf92c24912fb63969c64fadd864442e0c72
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>
22 require_once($GLOBALS["srcdir"] . "/acl.inc");
23 require_once($GLOBALS["srcdir"] . "/formdata.inc.php");
24 require_once($GLOBALS["srcdir"] . "/options.inc.php");
25 require_once($GLOBALS["srcdir"] . "/formatting.inc.php");
26 require_once($GLOBALS["srcdir"] . "/classes/Document.class.php");
28 function getListItem($listid, $value) {
29 $lrow = sqlQuery("SELECT title FROM list_options " .
30 "WHERE list_id = ? AND option_id = ?",
31 array($listid, $value));
32 $tmp = xl_list_label($lrow['title']);
33 if (empty($tmp)) $tmp = (($value === '') ? '' : "($value)");
34 return $tmp;
37 function myCellText($s) {
38 $s = trim($s);
39 if ($s === '') return '&nbsp;';
40 return text($s);
43 // Check if the given string already exists in the $aNotes array.
44 // If not, stores it as a new entry.
45 // Either way, returns the corresponding key which is a small integer.
46 function storeNote($s) {
47 global $aNotes;
48 $key = array_search($s, $aNotes);
49 if ($key !== FALSE) return $key;
50 $key = count($aNotes);
51 $aNotes[$key] = $s;
52 return $key;
55 // Display a single row of output including order, report and result information.
57 function generate_result_row(&$ctx, &$row, &$rrow, $priors_omitted=false) {
58 $lab_id = empty($row['lab_id' ]) ? 0 : ($row['lab_id' ] + 0);
59 $order_type_id = empty($row['order_type_id' ]) ? 0 : ($row['order_type_id' ] + 0);
60 $order_seq = empty($row['procedure_order_seq']) ? 0 : ($row['procedure_order_seq'] + 0);
61 $report_id = empty($row['procedure_report_id']) ? 0 : ($row['procedure_report_id'] + 0);
62 $procedure_code = empty($row['procedure_code' ]) ? '' : $row['procedure_code'];
63 $procedure_name = empty($row['procedure_name' ]) ? '' : $row['procedure_name'];
64 $date_report = empty($row['date_report' ]) ? '' : substr($row['date_report'], 0, 16);
65 $date_report_suf = empty($row['date_report_tz' ]) ? '' : (' ' . $row['date_report_tz' ]);
66 $date_collected = empty($row['date_collected' ]) ? '' : substr($row['date_collected'], 0, 16);
67 $date_collected_suf = empty($row['date_collected_tz' ]) ? '' : (' ' . $row['date_collected_tz' ]);
68 $specimen_num = empty($row['specimen_num' ]) ? '' : $row['specimen_num'];
69 $report_status = empty($row['report_status' ]) ? '' : $row['report_status'];
70 $review_status = empty($row['review_status' ]) ? 'received' : $row['review_status'];
72 $report_noteid = '';
73 if ($report_id && !isset($ctx['seen_report_ids'][$report_id])) {
74 $ctx['seen_report_ids'][$report_id] = true;
75 if ($review_status != 'reviewed') {
76 if ($ctx['sign_list']) $ctx['sign_list'] .= ',';
77 $ctx['sign_list'] .= $report_id;
79 // Allowing for multiple report notes separated by newlines.
80 if (!empty($row['report_notes'])) {
81 $notes = explode("\n", $row['report_notes']);
82 foreach ($notes as $note) {
83 if ($note === '') continue;
84 if ($report_noteid) $report_noteid .= ', ';
85 $report_noteid .= 1 + storeNote($note);
89 // allow for 0 to be displayed as a result value
90 if($rrow['result'] == '' && $rrow['result'] !== 0 && $rrow['result'] !== '0') {
91 $result_result = '';
92 } else {
93 $result_result = $rrow['result'];
95 $result_code = empty($rrow['result_code' ]) ? '' : $rrow['result_code'];
96 $result_text = empty($rrow['result_text' ]) ? '' : $rrow['result_text'];
97 $result_abnormal = empty($rrow['abnormal' ]) ? '' : $rrow['abnormal'];
98 $result_units = empty($rrow['units' ]) ? '' : $rrow['units'];
99 $result_facility = empty($rrow['facility' ]) ? '' : $rrow['facility'];
100 $result_comments = empty($rrow['comments' ]) ? '' : $rrow['comments'];
101 $result_range = empty($rrow['range' ]) ? '' : $rrow['range'];
102 $result_status = empty($rrow['result_status' ]) ? '' : $rrow['result_status'];
103 $result_document_id = empty($rrow['document_id' ]) ? '' : $rrow['document_id'];
105 // Someone changed the delimiter in result comments from \n to \r.
106 // Have to make sure results are consistent with those before that change.
107 $result_comments = str_replace("\r", "\n", $result_comments);
109 if ($i = strpos($result_comments, "\n")) { // "=" is not a mistake!
110 // If the first line of comments is not empty, then it is actually a long textual
111 // result value with lines delimited by "~" characters.
112 $result_comments = str_replace("~", "\n", substr($result_comments, 0, $i)) .
113 substr($result_comments, $i);
115 $result_comments = trim($result_comments);
117 $result_noteid = '';
118 if (!empty($result_comments)) {
119 $result_noteid = 1 + storeNote($result_comments);
121 if ($priors_omitted) {
122 if ($result_noteid) $result_noteid .= ', ';
123 $result_noteid .= 1 + storeNote(xl('This is the latest of multiple result values.'));
124 $ctx['priors_omitted'] = true;
127 // If a performing organization is provided, make a note for it also.
128 $result_facility = trim(str_replace("\r", "\n", $result_facility));
129 if ($result_facility) {
130 if ($result_noteid) $result_noteid .= ', ';
131 $result_noteid .= 1 + storeNote(xl('Performing organization') . ":\n" . $result_facility);
134 if ($ctx['lastpcid'] != $order_seq) {
135 ++$ctx['encount'];
137 $bgcolor = "#" . (($ctx['encount'] & 1) ? "ddddff" : "ffdddd");
139 echo " <tr class='detail' bgcolor='$bgcolor'>\n";
141 if ($ctx['lastpcid'] != $order_seq) {
142 $ctx['lastprid'] = -1; // force report fields on first line of each procedure
143 $tmp = text("$procedure_code: $procedure_name");
144 // Get the LOINC code if one exists in the compendium for this order type.
145 if (empty($GLOBALS['PATIENT_REPORT_ACTIVE'])) {
146 $trow = sqlQuery("SELECT standard_code FROM procedure_type WHERE " .
147 "lab_id = ? AND procedure_code = ? AND procedure_type = 'ord' " .
148 "ORDER BY procedure_type_id LIMIT 1",
149 array($lab_id, $procedure_code));
150 if (!empty($trow['standard_code'])) {
151 $tmp = "<a href='javascript:educlick(\"LOINC\",\"" . attr($trow['standard_code']) .
152 "\")'>$tmp</a>";
155 echo " <td>$tmp</td>\n";
157 else {
158 echo " <td style='background-color:transparent'>&nbsp;</td>";
161 // If this starts a new report or a new order, generate the report fields.
162 if ($report_id != $ctx['lastprid']) {
163 echo " <td>";
164 echo myCellText(oeFormatShortDate(substr($date_report, 0, 10)) . substr($date_report, 10) . $date_report_suf);
165 echo "</td>\n";
167 echo " <td>";
168 echo myCellText(oeFormatShortDate(substr($date_collected, 0, 10)) . substr($date_collected, 10) . $date_collected_suf);
169 echo "</td>\n";
171 echo " <td>";
172 echo myCellText($specimen_num);
173 echo "</td>\n";
175 echo " <td title='" . xla('Check mark indicates reviewed') . "'>";
176 echo myCellText(getListItem('proc_rep_status', $report_status));
177 if ($row['review_status'] == 'reviewed') {
178 echo " &#x2713;"; // unicode check mark character
180 echo "</td>\n";
182 echo " <td align='center'>";
183 echo myCellText($report_noteid);
184 echo "</td>\n";
186 else {
187 echo " <td colspan='5' style='background-color:transparent'>&nbsp;</td>\n";
190 if ($result_code !== '' || $result_document_id) {
191 $tmp = myCellText($result_code);
192 if (empty($GLOBALS['PATIENT_REPORT_ACTIVE']) && !empty($result_code)) {
193 $tmp = "<a href='javascript:educlick(\"LOINC\",\"" . attr($result_code) .
194 "\")'>$tmp</a>";
196 echo " <td>$tmp</td>\n";
197 echo " <td>";
198 echo myCellText($result_text);
199 echo "</td>\n";
200 echo " <td>";
201 $tmp = myCellText(getListItem('proc_res_abnormal', $result_abnormal));
202 if ($result_abnormal && strtolower($result_abnormal) != 'no') {
203 echo "<b><font color='red'>$tmp</font></b>";
205 else {
206 echo $tmp;
208 echo "</td>\n";
210 if ($result_document_id) {
211 $d = new Document($result_document_id);
212 echo " <td colspan='3'>";
213 if (empty($GLOBALS['PATIENT_REPORT_ACTIVE'])) {
214 echo "<a href='" . $GLOBALS['webroot'] . "/controller.php?document";
215 echo "&retrieve&patient_id=$patient_id&document_id=$result_document_id' ";
216 echo "onclick='top.restoreSession()'>";
218 echo $d->get_url_file();
219 if (empty($GLOBALS['PATIENT_REPORT_ACTIVE'])) {
220 echo "</a>";
222 echo "</td>\n";
224 else {
225 echo " <td>";
226 echo myCellText($result_result);
227 echo "</td>\n";
228 echo " <td>";
229 echo myCellText($result_range);
230 echo "</td>\n";
231 echo " <td>";
232 // Units comes from the lab so might not match anything in the proc_unit list,
233 // but in that case the call will return the same value.
234 echo myCellText(getListItemTitle('proc_unit', $result_units));
235 echo "</td>\n";
237 echo " <td align='center'>";
238 echo myCellText($result_noteid);
239 echo "</td>\n";
241 else {
242 echo " <td colspan='7' style='background-color:transparent'>&nbsp;</td>\n";
245 echo " </tr>\n";
247 $ctx['lastpcid'] = $order_seq;
248 $ctx['lastprid'] = $report_id;
249 ++$ctx['lino'];
252 function generate_order_report($orderid, $input_form=false, $genstyles=true, $finals_only=false) {
253 global $aNotes;
255 // Check authorization.
256 $thisauth = acl_check('patients', 'med');
257 if (!$thisauth) return xl('Not authorized');
259 $orow = sqlQuery("SELECT " .
260 "po.procedure_order_id, po.date_ordered, po.control_id, " .
261 "po.order_status, po.specimen_type, po.patient_id, " .
262 "pd.pubpid, pd.lname, pd.fname, pd.mname, pd.cmsportal_login, pd.language, " .
263 "fe.date, " .
264 "pp.name AS labname, " .
265 "u.lname AS ulname, u.fname AS ufname, u.mname AS umname " .
266 "FROM procedure_order AS po " .
267 "LEFT JOIN patient_data AS pd ON pd.pid = po.patient_id " .
268 "LEFT JOIN procedure_providers AS pp ON pp.ppid = po.lab_id " .
269 "LEFT JOIN users AS u ON u.id = po.provider_id " .
270 "LEFT JOIN form_encounter AS fe ON fe.pid = po.patient_id AND fe.encounter = po.encounter_id " .
271 "WHERE po.procedure_order_id = ?",
272 array($orderid));
274 $patient_id = $orow['patient_id'];
275 $language = $orow['language'];
278 <?php if ($genstyles) { ?>
279 <style>
281 <?php if (empty($_SESSION['language_direction']) || $_SESSION['language_direction'] == 'ltr') { ?>
283 .labres tr.head { font-size:10pt; background-color:#cccccc; text-align:center; }
284 .labres tr.detail { font-size:10pt; }
285 .labres a, .labres a:visited, .labres a:hover { color:#0000cc; }
287 .labres table {
288 border-style: solid;
289 border-width: 1px 0px 0px 1px;
290 border-color: black;
292 .labres td, .labres th {
293 border-style: solid;
294 border-width: 0px 1px 1px 0px;
295 border-color: black;
297 /***** What is this for? Seems ugly to me. --Rod
298 .labres tr{
299 background-color: #cccccc;
301 *****/
303 <?php } else { ?>
305 .labres tr.head { font-size:10pt; text-align:center; }
306 .labres tr.detail { font-size:10pt; }
308 .labres table {
309 border-style: none;
310 border-width: 1px 0px 0px 1px;
311 border-color: black;
313 .labres td, .labres th {
314 border-style: none;
315 border-width: 0px 1px 1px 0px;
316 border-color: black;
317 padding: 4px;
319 .labres table td.td-label{
321 font-weight: bold;
325 <?php } ?>
327 </style>
328 <?php } ?>
330 <?php if ($input_form) { ?>
331 <script type="text/javascript" src="<?php echo $GLOBALS['webroot']; ?>/library/textformat.js"></script>
332 <?php } // end if input form ?>
334 <?php if (empty($GLOBALS['PATIENT_REPORT_ACTIVE'])) { ?>
336 <script type="text/javascript" src="<?php echo $GLOBALS['webroot']; ?>/library/dialog.js"></script>
337 <script language="JavaScript">
339 var mypcc = '<?php echo $GLOBALS['phone_country_code'] ?>';
341 // Called to show patient notes related to this order in the "other" frame.
342 // This works even if we are in a separate window.
343 function showpnotes(orderid) {
344 // Find the top or bottom frame that contains or opened this page; return if none.
345 var w = window.opener ? window.opener : window;
346 for (; w.name != 'RTop' && w.name != 'RBot'; w = w.parent) {
347 if (w.parent == w) {
348 // This message is not translated because a developer will need to find it.
349 alert('Internal error locating target frame in ' + (window.opener ? 'opener' : 'window'));
350 return false;
353 var othername = (w.name == 'RTop') ? 'RBot' : 'RTop';
354 w.parent.left_nav.forceDual();
355 w.parent.left_nav.loadFrame('pno1', othername, 'patient_file/summary/pnotes_full.php?orderid=' + orderid);
356 return false;
359 // Process click on LOINC code for patient education popup.
360 function educlick(codetype, codevalue) {
361 dlgopen('<?php echo $GLOBALS['webroot']; ?>/interface/patient_file/education.php' +
362 '?type=' + encodeURIComponent(codetype) +
363 '&code=' + encodeURIComponent(codevalue) +
364 '&language=<?php echo urlencode($language); ?>',
365 '_blank', 1024, 750,true); // Force a new window instead of iframe to address cross site scripting potential
368 </script>
370 <?php } // end if not patient report ?>
372 <?php if ($input_form) { ?>
373 <form method='post' action='single_order_results.php?orderid=<?php echo $orderid; ?>'>
374 <?php } // end if input form ?>
376 <div class='labres'>
378 <table width='100%' cellpadding='2' cellspacing='0'>
379 <tr>
380 <td class="td-label" width='5%' nowrap><?php echo xlt('Patient ID'); ?></td>
381 <td width='45%'><?php echo myCellText($orow['pubpid']); ?></td>
382 <td class="td-label" width='5%' nowrap><?php echo xlt('Order ID'); ?></td>
383 <td width='45%'>
384 <?php
385 if (empty($GLOBALS['PATIENT_REPORT_ACTIVE'])) {
386 echo " <a href='" . $GLOBALS['webroot'];
387 echo "/interface/orders/order_manifest.php?orderid=";
388 echo attr($orow['procedure_order_id']);
389 echo "' target='_blank' onclick='top.restoreSession()'>";
391 echo myCellText($orow['procedure_order_id']);
392 if (empty($GLOBALS['PATIENT_REPORT_ACTIVE'])) {
393 echo "</a>\n";
395 if ($orow['control_id']) {
396 echo myCellText(' ' . xl('Lab') . ': ' . $orow['control_id']);
399 </td>
400 </tr>
401 <tr>
402 <td class="td-label" nowrap><?php echo xlt('Patient Name'); ?></td>
403 <td><?php echo myCellText($orow['lname'] . ', ' . $orow['fname'] . ' ' . $orow['mname']); ?></td>
404 <td class="td-label" nowrap><?php echo xlt('Ordered By'); ?></td>
405 <td><?php echo myCellText($orow['ulname'] . ', ' . $orow['ufname'] . ' ' . $orow['umname']); ?></td>
406 </tr>
407 <tr>
408 <td class="td-label" nowrap><?php echo xlt('Order Date'); ?></td>
409 <td><?php echo myCellText(oeFormatShortDate($orow['date_ordered'])); ?></td>
410 <td class="td-label" nowrap><?php echo xlt('Print Date'); ?></td>
411 <td><?php echo oeFormatShortDate(date('Y-m-d')); ?></td>
412 </tr>
413 <tr>
414 <td class="td-label" nowrap><?php echo xlt('Order Status'); ?></td>
415 <td><?php echo myCellText($orow['order_status']); ?></td>
416 <td class="td-label" nowrap><?php echo xlt('Encounter Date'); ?></td>
417 <td><?php echo myCellText(oeFormatShortDate(substr($orow['date'], 0, 10))); ?></td>
418 </tr>
419 <tr>
420 <td class="td-label" nowrap><?php echo xlt('Lab'); ?></td>
421 <td><?php echo myCellText($orow['labname']); ?></td>
422 <td class="td-label" nowrap><?php echo $orow['specimen_type'] ? xlt('Specimen Type') : '&nbsp;'; ?></td>
423 <td><?php echo myCellText($orow['specimen_type']); ?></td>
424 </tr>
425 </table>
427 &nbsp;<br />
429 <table width='100%' cellpadding='2' cellspacing='0'>
431 <tr class='head'>
432 <td class="td-label" rowspan='2' valign='middle'><?php echo xlt('Ordered Procedure'); ?></td>
433 <td class="td-label" colspan='5'><?php echo xlt('Report'); ?></td>
434 <td class="td-label" colspan='7'><?php echo xlt('Results'); ?></td>
435 </tr>
437 <tr class='head'>
438 <td><?php echo xlt('Reported'); ?></td>
439 <td><?php echo xlt('Collected'); ?></td>
440 <td><?php echo xlt('Specimen'); ?></td>
441 <td><?php echo xlt('Status'); ?></td>
442 <td><?php echo xlt('Note'); ?></td>
443 <td><?php echo xlt('Code'); ?></td>
444 <td><?php echo xlt('Name'); ?></td>
445 <td><?php echo xlt('Abn'); ?></td>
446 <td><?php echo xlt('Value'); ?></td>
447 <td><?php echo xlt('Range'); ?></td>
448 <td><?php echo xlt('Units'); ?></td>
449 <td><?php echo xlt('Note'); ?></td>
450 </tr>
452 <?php
453 $query = "SELECT " .
454 "po.lab_id, po.date_ordered, pc.procedure_order_seq, pc.procedure_code, " .
455 "pc.procedure_name, " .
456 "pr.date_report, pr.date_report_tz, pr.date_collected, pr.date_collected_tz, " .
457 "pr.procedure_report_id, pr.specimen_num, pr.report_status, pr.review_status, pr.report_notes " .
458 "FROM procedure_order AS po " .
459 "JOIN procedure_order_code AS pc ON pc.procedure_order_id = po.procedure_order_id " .
460 "LEFT JOIN procedure_report AS pr ON pr.procedure_order_id = po.procedure_order_id AND " .
461 "pr.procedure_order_seq = pc.procedure_order_seq " .
462 "WHERE po.procedure_order_id = ? " .
463 "ORDER BY pc.procedure_order_seq, pr.date_report, pr.procedure_report_id";
465 $res = sqlStatement($query, array($orderid));
466 $aNotes = array();
467 $finals = array();
468 $empty_results = array('result_code' => '');
470 // Context for this call that may be used in other functions.
471 $ctx = array(
472 'lastpcid' => -1,
473 'lastprid' => -1,
474 'encount' => 0,
475 'lino' => 0,
476 'sign_list' => '',
477 'seen_report_ids' => array(),
480 while ($row = sqlFetchArray($res)) {
481 $report_id = empty($row['procedure_report_id']) ? 0 : ($row['procedure_report_id'] + 0);
483 $query = "SELECT " .
484 "ps.result_code, ps.result_text, ps.abnormal, ps.result, ps.range, " .
485 "ps.result_status, ps.facility, ps.units, ps.comments, ps.document_id, ps.date " .
486 "FROM procedure_result AS ps " .
487 "WHERE ps.procedure_report_id = ? " .
488 "ORDER BY ps.procedure_result_id";
490 $rres = sqlStatement($query, array($report_id));
492 if ($finals_only) {
493 // We are consolidating reports.
494 if (sqlNumRows($rres)) {
495 $rrowsets = array();
496 // First pass creates a $rrowsets[$key] for each unique result code in *this* report, with
497 // the value being an array of the corresponding result rows. This caters to multiple
498 // occurrences of the same result code in the same report.
499 while ($rrow = sqlFetchArray($rres)) {
500 $result_code = empty($rrow['result_code']) ? '' : $rrow['result_code'];
501 $key = sprintf('%05d/', $row['procedure_order_seq']) . $result_code;
502 if (!isset($rrowsets[$key])) $rrowsets[$key] = array();
503 $rrowsets[$key][] = $rrow;
505 // Second pass builds onto the array of final results for *all* reports, where each final
506 // result for a given result code is its *array* of result rows from *one* of the reports.
507 foreach ($rrowsets as $key => $rrowset) {
508 // When two reports have the same date, use the result date to decide which is "latest".
509 if (isset($finals[$key]) &&
510 $row['date_report'] == $finals[$key][0]['date_report'] &&
511 !empty($rrow['date']) && !empty($finals[$key][1]['date']) &&
512 $rrow['date'] < $finals[$key][1]['date'])
514 $finals[$key][2] = true; // see comment below
515 continue;
517 // $finals[$key][2] indicates if there are multiple results for this result code.
518 $finals[$key] = array($row, $rrowset, isset($finals[$key]));
521 else {
522 // We have no results for this report.
523 $key = sprintf('%05d/', $row['procedure_order_seq']);
524 $finals[$key] = array($row, array($empty_results), false);
527 else {
528 // We are showing all results for all reports.
529 if (sqlNumRows($rres)) {
530 while ($rrow = sqlFetchArray($rres)) {
531 generate_result_row($ctx, $row, $rrow, false);
534 else {
535 generate_result_row($ctx, $row, $empty_results, false);
540 if ($finals_only) {
541 // The sort here was removed because $finals is already ordered by procedure_result_id
542 // within procedure_order_seq which is probably desirable. Sorting by result code defeats
543 // the sequencing of results chosen by the sender.
544 // ksort($finals);
545 foreach ($finals as $final) {
546 foreach ($final[1] as $rrow) {
547 generate_result_row($ctx, $final[0], $rrow, $final[2]);
554 </table>
556 &nbsp;<br />
557 <table width='100%' style='border-width:0px;'>
558 <tr>
559 <td style='border-width:0px;'>
560 <?php
561 if (!empty($aNotes)) {
562 echo "<table cellpadding='3' cellspacing='0'>\n";
563 echo " <tr bgcolor='#cccccc'>\n";
564 echo " <th align='center' colspan='2'>" . xlt('Notes') . "</th>\n";
565 echo " </tr>\n";
566 foreach ($aNotes as $key => $value) {
567 echo " <tr>\n";
568 echo " <td valign='top'>" . ($key + 1) . "</td>\n";
569 // <pre> tag because white space and a fixed font are often used to line things up.
570 echo " <td><pre style='white-space:pre-wrap;'>" . text($value) . "</pre></td>\n";
571 echo " </tr>\n";
573 echo "</table>\n";
576 </td>
577 <td style='border-width:0px;' align='right' valign='top'>
578 <?php if ($input_form && !empty($ctx['priors_omitted']) /* empty($_POST['form_showall']) */ ) { ?>
579 <input type='submit' name='form_showall' value='<?php echo xla('Show All Results'); ?>'
580 title='<?php echo xla('Include all values reported for each result code'); ?>' />
581 <?php } else if ($input_form && !empty($_POST['form_showall'])) { ?>
582 <input type='submit' name='form_latest' value='<?php echo xla('Latest Results Only'); ?>'
583 title='<?php echo xla('Show only latest values reported for each result code'); ?>' />
584 <?php } ?>
585 <?php if (empty($GLOBALS['PATIENT_REPORT_ACTIVE'])) { ?>
586 &nbsp;
587 <input type='button' value='<?php echo xla('Related Patient Notes'); ?>'
588 onclick='showpnotes(<?php echo $orderid; ?>)' />
589 <?php } ?>
590 <?php if ($input_form && $ctx['sign_list']) { ?>
591 &nbsp;
592 <input type='hidden' name='form_sign_list' value='<?php echo attr($ctx['sign_list']); ?>' />
593 <input type='submit' name='form_sign' value='<?php echo xla('Sign Results'); ?>'
594 title='<?php echo xla('Mark these reports as reviewed'); ?>' />
595 <?php
596 // If this is a portal patient, sending them a copy is an option.
597 if ($GLOBALS['gbl_portal_cms_enable'] && $orow['cmsportal_login'] !== '') {
598 echo "&nbsp;";
599 echo "<input type='checkbox' name='form_send_to_portal' value='" .
600 attr($orow['cmsportal_login']) . "' checked />\n";
601 echo xlt('Send to portal');
604 <?php } ?>
605 <?php if ($input_form) { ?>
606 &nbsp;
607 <input type='button' value='<?php echo xla('Close'); ?>' onclick='window.close()' />
608 <?php } ?>
609 </td>
610 </tr>
611 </table>
613 </div>
615 <?php if ($input_form) { ?>
616 </form>
617 <?php } // end if input form ?>
619 <?php
620 } // end function generate_order_report