Highway to PSR2
[openemr.git] / interface / orders / orders_results.php
blob82676eaea6e6a948404a9055f8120b8dc77b4304
1 <?php
2 /**
3 * Copyright (C) 2010-2010 Rod Roark <rod@sunsetsystems.com>
4 * Copyright (C) 2017 Brady Miller <brady.g.miller@gmail.com>
6 * LICENSE: This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>.
17 * @package OpenEMR
18 * @author Rod Roark <rod@sunsetsystems.com>
19 * @author Brady Miller <brady.g.miller@gmail.com>
20 * @link http://www.open-emr.org
23 require_once("../globals.php");
24 require_once("$srcdir/acl.inc");
25 require_once("$srcdir/options.inc.php");
26 require_once("../orders/lab_exchange_tools.php");
28 // Indicates if we are entering in batch mode.
29 $form_batch = empty($_GET['batch']) ? 0 : 1;
31 // Indicates if we are entering in review mode.
32 $form_review = empty($_GET['review']) ? 0 : 1;
34 // Check authorization.
35 $thisauth = acl_check('patients', 'med');
36 if (!$thisauth) {
37 die(xl('Not authorized'));
40 // Check authorization for pending review.
41 $reviewauth = acl_check('patients', 'sign');
42 if ($form_review and !$reviewauth and !$thisauth) {
43 die(xl('Not authorized'));
46 // Set pid for pending review.
47 if ($_GET['set_pid'] && $form_review) {
48 require_once("$srcdir/pid.inc");
49 require_once("$srcdir/patient.inc");
50 setpid($_GET['set_pid']);
52 $result = getPatientData($pid, "*, DATE_FORMAT(DOB,'%Y-%m-%d') as DOB_YMD");
54 <script language='JavaScript'>
55 parent.left_nav.setPatient(<?php echo "'" . addslashes($result['fname']) . " " . addslashes($result['lname']) . "',$pid,'" . addslashes($result['pubpid']) . "','', ' " . xl('DOB') . ": " . oeFormatShortDate($result['DOB_YMD']) . " " . xl('Age') . ": " . getPatientAge($result['DOB_YMD']) . "'"; ?>);
56 </script>
57 <?php
60 if (!$form_batch && !$pid && !$form_review) {
61 die(xl('There is no current patient'));
64 function oresRawData($name, $index)
66 $s = isset($_POST[$name][$index]) ? $_POST[$name][$index] : '';
67 return trim(strip_escape_custom($s));
70 function oresData($name, $index)
72 $s = isset($_POST[$name][$index]) ? $_POST[$name][$index] : '';
73 return formDataCore($s, true);
76 function QuotedOrNull($fld)
78 if (empty($fld)) {
79 return "NULL";
82 return "'$fld'";
85 $current_report_id = 0;
87 if ($_POST['form_submit'] && !empty($_POST['form_line'])) {
88 foreach ($_POST['form_line'] as $lino => $line_value) {
89 list($order_id, $order_seq, $report_id, $result_id) = explode(':', $line_value);
91 // Not using xl() here because this is for debugging only.
92 if (empty($order_id)) {
93 die("Order ID is missing from line $lino.");
96 // If report data exists for this line, save it.
97 $date_report = oresData("form_date_report", $lino);
99 if (!empty($date_report)) {
100 $sets =
101 "procedure_order_id = '$order_id', " .
102 "procedure_order_seq = '$order_seq', " .
103 "date_report = '$date_report', " .
104 "date_collected = " . QuotedOrNull(oresData("form_date_collected", $lino)) . ", " .
105 "specimen_num = '" . oresData("form_specimen_num", $lino) . "', " .
106 "report_status = '" . oresData("form_report_status", $lino) . "'";
108 // Set the review status to reviewed.
109 if ($form_review) {
110 $sets .= ", review_status = 'reviewed'";
113 if ($report_id) { // Report already exists.
114 sqlStatement("UPDATE procedure_report SET $sets " .
115 "WHERE procedure_report_id = '$report_id'");
116 } else { // Add new report.
117 $report_id = sqlInsert("INSERT INTO procedure_report SET $sets");
121 // If this line had report data entry fields, filled or not, set the
122 // "current report ID" which the following result data will link to.
123 if (isset($_POST["form_date_report"][$lino])) {
124 $current_report_id = $report_id;
127 // If there's a report, save corresponding results.
128 if ($current_report_id) {
129 // Comments and notes will be combined into one comments field.
130 $form_comments = oresRawData("form_comments", $lino);
131 $form_comments = str_replace("\n", '~', $form_comments);
132 $form_comments = str_replace("\r", '', $form_comments);
133 $form_notes = oresRawData("form_notes", $lino);
134 if ($form_notes !== '') {
135 $form_comments .= "\n" . $form_notes;
138 $sets =
139 "procedure_report_id = '$current_report_id', " .
140 "result_code = '" . oresData("form_result_code", $lino) . "', " .
141 "result_text = '" . oresData("form_result_text", $lino) . "', " .
142 "abnormal = '" . oresData("form_result_abnormal", $lino) . "', " .
143 "result = '" . oresData("form_result_result", $lino) . "', " .
144 "`range` = '" . oresData("form_result_range", $lino) . "', " .
145 "units = '" . oresData("form_result_units", $lino) . "', " .
146 "facility = '" . oresData("form_facility", $lino) . "', " .
147 "comments = '" . add_escape_custom($form_comments) . "', " .
148 "result_status = '" . oresData("form_result_status", $lino) . "'";
149 if ($result_id) { // result already exists
150 sqlStatement("UPDATE procedure_result SET $sets " .
151 "WHERE procedure_result_id = '$result_id'");
152 } else { // Add new result.
153 $result_id = sqlInsert("INSERT INTO procedure_result SET $sets");
156 } // end foreach
159 <html>
161 <head>
162 <?php html_header_show();?>
164 <link rel="stylesheet" href='<?php echo $css_header ?>' type='text/css'>
165 <link rel="stylesheet" href="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker-2-5-4/build/jquery.datetimepicker.min.css">
167 <title><?php xl('Procedure Results', 'e'); ?></title>
169 <style>
171 tr.head { font-size:10pt; background-color:#cccccc; text-align:center; }
172 tr.detail { font-size:10pt; }
173 a, a:visited, a:hover { color:#0000cc; }
175 .celltext {
176 font-size:10pt;
177 font-weight:normal;
178 border-style:solid;
179 border-top-width:0px;
180 border-bottom-width:0px;
181 border-left-width:0px;
182 border-right-width:0px;
183 border-color: #aaaaaa;
184 background-color:transparent;
185 width:100%;
186 color:#0000cc;
189 .celltextfw {
190 font-size:10pt;
191 font-weight:normal;
192 border-style:solid;
193 border-top-width:0px;
194 border-bottom-width:0px;
195 border-left-width:0px;
196 border-right-width:0px;
197 border-color: #aaaaaa;
198 background-color:transparent;
199 color:#0000cc;
202 .cellselect {
203 font-size:10pt;
204 background-color:transparent;
205 color:#0000cc;
208 .reccolor {
209 color:#008800;
212 </style>
213 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-3-1-1/index.js"></script>
214 <script type="text/javascript" src="../../library/dialog.js?v=<?php echo $v_js_includes; ?>"></script>
215 <script type="text/javascript" src="../../library/textformat.js?v=<?php echo $v_js_includes; ?>"></script>
216 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker-2-5-4/build/jquery.datetimepicker.full.min.js"></script>
218 <script language="JavaScript">
220 var mypcc = '<?php echo $GLOBALS['phone_country_code'] ?>';
222 // This invokes the find-procedure-type popup.
223 var ptvarname;
224 function sel_proc_type(varname) {
225 var f = document.forms[0];
226 if (typeof varname == 'undefined') varname = 'form_proc_type';
227 ptvarname = varname;
228 dlgopen('types.php?popup=1&order=' + f[ptvarname].value, '_blank', 800, 500);
231 // This is for callback by the find-procedure-type popup.
232 // Sets both the selected type ID and its descriptive name.
233 function set_proc_type(typeid, typename) {
234 var f = document.forms[0];
235 f[ptvarname].value = typeid;
236 f[ptvarname + '_desc'].value = typename;
239 // Helper functions.
240 function extGetX(elem) {
241 var x = 0;
242 while(elem != null) {
243 x += elem.offsetLeft;
244 elem = elem.offsetParent;
246 return x;
248 function extGetY(elem) {
249 var y = 0;
250 while(elem != null) {
251 y += elem.offsetTop;
252 elem = elem.offsetParent;
254 return y;
257 // Show or hide the "extras" div for a result.
258 var extdiv = null;
259 function extShow(lino, show) {
260 var thisdiv = document.getElementById("ext_" + lino);
261 if (extdiv) {
262 extdiv.style.visibility = 'hidden';
263 extdiv.style.left = '-1000px';
264 extdiv.style.top = '0px';
266 if (show && thisdiv != extdiv) {
267 extdiv = thisdiv;
268 var dw = window.innerWidth ? window.innerWidth - 20 : document.body.clientWidth;
269 x = dw - extdiv.offsetWidth;
270 if (x < 0) x = 0;
271 var y = extGetY(show) + show.offsetHeight;
272 extdiv.style.left = x;
273 extdiv.style.top = y;
274 extdiv.style.visibility = 'visible';
276 else {
277 extdiv = null;
281 // Helper function for validate.
282 function prDateRequired(rlino) {
283 var f = document.forms[0];
284 if (f['form_date_report['+rlino+']'].value.length < 10) {
285 alert('<?php xl('Missing report date', 'e') ?>');
286 if (f['form_date_report['+rlino+']'].focus)
287 f['form_date_report['+rlino+']'].focus();
288 return false;
290 return true;
293 // Validation at submit time.
294 function validate(f) {
295 var rlino = 0;
296 for (var lino = 0; f['form_line['+lino+']']; ++lino) {
297 if (f['form_date_report['+lino+']']) {
298 rlino = lino;
299 if (f['form_report_status['+rlino+']'].selectedIndex > 0) {
300 if (!prDateRequired(rlino)) return false;
303 var abnstat = f['form_result_abnormal['+lino+']'].selectedIndex > 0;
304 if (abnstat && !prDateRequired(rlino)) return false;
306 top.restoreSession();
307 return true;
310 $(document).ready(function() {
311 $('.datepicker').datetimepicker({
312 <?php $datetimepicker_timepicker = false; ?>
313 <?php $datetimepicker_showseconds = false; ?>
314 <?php $datetimepicker_formatInput = false; ?>
315 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
316 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
318 $('.datetimepicker').datetimepicker({
319 <?php $datetimepicker_timepicker = true; ?>
320 <?php $datetimepicker_showseconds = false; ?>
321 <?php $datetimepicker_formatInput = false; ?>
322 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
323 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
327 </script>
329 </head>
331 <body class="body_top">
332 <form method='post' action='orders_results.php?batch=<?php echo $form_batch; ?>&review=<?php echo $form_review; ?>'
333 onsubmit='return validate(this)'>
335 <table>
336 <tr>
337 <td class='text'>
338 <?php
339 if ($form_batch) {
340 $form_from_date = formData('form_from_date', 'P', true);
341 $form_to_date = formData('form_to_date', 'P', true);
342 if (empty($form_to_date)) {
343 $form_to_date = $form_from_date;
346 $form_proc_type = formData('form_proc_type') + 0;
347 if (!$form_proc_type) {
348 $form_proc_type = -1;
351 $form_proc_type_desc = '';
352 if ($form_proc_type > 0) {
353 $ptrow = sqlQuery("SELECT name FROM procedure_type WHERE " .
354 "procedure_type_id = '$form_proc_type'");
355 $form_proc_type_desc = $ptrow['name'];
358 <?php xl('Procedure', 'e'); ?>:
359 <input type='text' size='30' name='form_proc_type_desc'
360 value='<?php echo addslashes($form_proc_type_desc) ?>'
361 onclick='sel_proc_type()' onfocus='this.blur()'
362 title='<?php xl('Click to select the desired procedure', 'e'); ?>'
363 style='cursor:pointer;cursor:hand' readonly />
364 <input type='hidden' name='form_proc_type' value='<?php echo $form_proc_type ?>' />
366 &nbsp;<?php xl('From', 'e'); ?>:
367 <input type='text' size='10' class='datepicker' name='form_from_date' id='form_from_date'
368 value='<?php echo $form_from_date ?>'
369 title='<?php xl('yyyy-mm-dd', 'e'); ?>' />
371 &nbsp;<?php xl('To', 'e'); ?>:
372 <input type='text' size='10' class='datepicker' name='form_to_date' id='form_to_date'
373 value='<?php echo $form_to_date ?>'
374 title='<?php xl('yyyy-mm-dd', 'e'); ?>' />
376 &nbsp;
377 <?php
378 } // end header for batch option
380 <!-- removed by jcw -- check/submit sequece too tedious. This is a quick fix -->
381 <!-- <input type='checkbox' name='form_all' value='1' <?php if ($_POST['form_all']) {
382 echo " checked";
383 } ?>><?php xl('Include Completed', 'e') ?>
384 &nbsp;-->
385 <input type='submit' name='form_refresh' value=<?php xl('Refresh', 'e'); ?>>
386 </td>
387 </tr>
388 </table>
390 <?php if (!$form_batch || ($form_proc_type > 0 && $form_from_date)) { ?>
392 <table width='100%' cellpadding='1' cellspacing='2'>
394 <tr class='head'>
395 <td colspan='2'><?php echo $form_batch ? xl('Patient') : xl('Order'); ?></td>
396 <td colspan='4'><?php xl('Report', 'e'); ?></td>
397 <td colspan='7'><?php xl('Results and', 'e'); ?> <span class='reccolor''>
398 <?php xl('Recommendations', 'e'); ?></span></td>
399 </tr>
401 <tr class='head'>
402 <td><?php echo $form_batch ? xl('Name') : xl('Date'); ?></td>
403 <td><?php echo $form_batch ? xl('ID') : xl('Procedure Name'); ?></td>
404 <td><?php xl('Reported', 'e'); ?></td>
405 <td><?php xl('Ext Time Collected', 'e'); ?></td>
406 <td><?php xl('Specimen', 'e'); ?></td>
407 <td><?php xl('Status', 'e'); ?></td>
408 <td><?php xl('Code', 'e'); ?></td>
409 <td><?php xl('Name', 'e'); ?></td>
410 <td><?php xl('Abn', 'e'); ?></td>
411 <td><?php xl('Value', 'e'); ?></td>
412 <td><?php xl('Units', 'e'); ?></td>
413 <td><?php xl('Range', 'e'); ?></td>
414 <td><?php xl('?', 'e'); ?></td>
415 </tr>
417 <?php
418 $selects =
419 "po.procedure_order_id, po.date_ordered, pc.procedure_order_seq, " .
420 "pt1.procedure_type_id AS order_type_id, pc.procedure_name, " .
421 "pr.procedure_report_id, pr.date_report, pr.date_collected, pr.specimen_num, " .
422 "pr.report_status, pr.review_status";
424 $joins =
425 "JOIN procedure_order_code AS pc ON pc.procedure_order_id = po.procedure_order_id " .
426 "LEFT JOIN procedure_type AS pt1 ON pt1.lab_id = po.lab_id AND pt1.procedure_code = pc.procedure_code " .
427 "LEFT JOIN procedure_report AS pr ON pr.procedure_order_id = po.procedure_order_id AND " .
428 "pr.procedure_order_seq = pc.procedure_order_seq";
430 $orderby =
431 "po.date_ordered, po.procedure_order_id, " .
432 "pc.procedure_order_seq, pr.procedure_report_id";
434 // removed by jcw -- check/submit sequece too tedious. This is a quick fix
435 //$where = empty($_POST['form_all']) ?
436 // "( pr.report_status IS NULL OR pr.report_status = '' OR pr.report_status = 'prelim' )" :
437 // "1 = 1";
439 $where = "1 = 1";
441 if ($form_batch) {
442 $query = "SELECT po.patient_id, " .
443 "pd.fname, pd.mname, pd.lname, pd.pubpid, $selects " .
444 "FROM procedure_order AS po " .
445 "LEFT JOIN patient_data AS pd ON pd.pid = po.patient_id $joins " .
446 "WHERE pt1.procedure_type_id = '$form_proc_type' AND " .
447 "po.date_ordered >= '$form_from_date' AND po.date_ordered <= '$form_to_date' " .
448 "AND $where " .
449 "ORDER BY pd.lname, pd.fname, pd.mname, po.patient_id, $orderby";
450 } else {
451 $query = "SELECT $selects " .
452 "FROM procedure_order AS po " .
453 "$joins " .
454 "WHERE po.patient_id = '$pid' AND $where " .
455 "ORDER BY $orderby";
458 $res = sqlStatement($query);
460 $lastpoid = -1;
461 $lastpcid = -1;
462 $lastprid = -1;
463 $encount = 0;
464 $lino = 0;
465 $extra_html = '';
466 $lastrcn = '';
467 $facilities = array();
469 while ($row = sqlFetchArray($res)) {
470 $order_type_id = empty($row['order_type_id' ]) ? 0 : ($row['order_type_id' ] + 0);
471 $order_id = empty($row['procedure_order_id' ]) ? 0 : ($row['procedure_order_id' ] + 0);
472 $order_seq = empty($row['procedure_order_seq']) ? 0 : ($row['procedure_order_seq'] + 0);
473 $report_id = empty($row['procedure_report_id']) ? 0 : ($row['procedure_report_id'] + 0);
474 $date_report = empty($row['date_report' ]) ? '' : substr($row['date_report'], 0, 16);
475 $date_collected = empty($row['date_collected' ]) ? '' : substr($row['date_collected'], 0, 16);
476 $specimen_num = empty($row['specimen_num' ]) ? '' : $row['specimen_num'];
477 $report_status = empty($row['report_status' ]) ? '' : $row['report_status'];
478 $review_status = empty($row['review_status' ]) ? 'received' : $row['review_status'];
480 // skip report_status = receive to make sure do not show the report before it reviewed and sign off by Physicians
481 if ($form_review) {
482 if ($review_status == "reviewed") {
483 continue;
485 } else {
486 if ($review_status == "received") {
487 continue;
491 $query_test=sqlFetchArray(sqlStatement("select deleted from forms where form_id=? and formdir='procedure_order'", array($order_id)));
492 // skip the procedure that has been deleted from the encounter form
493 if ($query_test['deleted']==1) {
494 continue;
497 $selects = "pt2.procedure_type, pt2.procedure_code, pt2.units AS pt2_units, " .
498 "pt2.range AS pt2_range, pt2.procedure_type_id AS procedure_type_id, " .
499 "pt2.name AS name, pt2.description, pt2.seq AS seq, " .
500 "ps.procedure_result_id, ps.result_code AS result_code, ps.result_text, ps.abnormal, ps.result, " .
501 "ps.range, ps.result_status, ps.facility, ps.comments, ps.units, ps.comments";
503 // procedure_type_id for order:
504 $pt2cond = "pt2.parent = $order_type_id AND " .
505 "(pt2.procedure_type LIKE 'res%' OR pt2.procedure_type LIKE 'rec%')";
507 // pr.procedure_report_id or 0 if none:
508 $pscond = "ps.procedure_report_id = $report_id";
510 $joincond = "ps.result_code = pt2.procedure_code";
512 // This union emulates a full outer join. The idea is to pick up all
513 // result types defined for this order type, as well as any actual
514 // results that do not have a matching result type.
515 $query = "(SELECT $selects FROM procedure_type AS pt2 " .
516 "LEFT JOIN procedure_result AS ps ON $pscond AND $joincond " .
517 "WHERE $pt2cond" .
518 ") UNION (" .
519 "SELECT $selects FROM procedure_result AS ps " .
520 "LEFT JOIN procedure_type AS pt2 ON $pt2cond AND $joincond " .
521 "WHERE $pscond) " .
522 "ORDER BY seq, name, procedure_type_id, result_code";
524 $rres = sqlStatement($query);
525 while ($rrow = sqlFetchArray($rres)) {
526 $restyp_code = empty($rrow['procedure_code' ]) ? '' : $rrow['procedure_code'];
527 $restyp_type = empty($rrow['procedure_type' ]) ? '' : $rrow['procedure_type'];
528 $restyp_name = empty($rrow['name' ]) ? '' : $rrow['name'];
529 $restyp_units = empty($rrow['pt2_units' ]) ? '' : $rrow['pt2_units'];
530 $restyp_range = empty($rrow['pt2_range' ]) ? '' : $rrow['pt2_range'];
532 $result_id = empty($rrow['procedure_result_id']) ? 0 : ($rrow['procedure_result_id'] + 0);
533 $result_code = empty($rrow['result_code' ]) ? $restyp_code : $rrow['result_code'];
534 $result_text = empty($rrow['result_text' ]) ? $restyp_name : $rrow['result_text'];
535 $result_abnormal = empty($rrow['abnormal' ]) ? '' : $rrow['abnormal'];
536 $result_result = empty($rrow['result' ]) ? '' : $rrow['result'];
537 $result_units = empty($rrow['units' ]) ? $restyp_units : $rrow['units'];
538 $result_facility = empty($rrow['facility' ]) ? '' : $rrow['facility'];
539 $result_comments = empty($rrow['comments' ]) ? '' : $rrow['comments'];
540 $result_range = empty($rrow['range' ]) ? $restyp_range : $rrow['range'];
541 $result_status = empty($rrow['result_status' ]) ? '' : $rrow['result_status'];
543 // If there is more than one line of comments, everything after that is "notes".
544 $result_notes = '';
545 $i = strpos($result_comments, "\n");
546 if ($i !== false) {
547 $result_notes = trim(substr($result_comments, $i + 1));
548 $result_comments = substr($result_comments, 0, $i);
551 $result_comments = trim($result_comments);
553 if ($result_facility <> "" && !in_array($result_facility, $facilities)) {
554 $facilities[] = $result_facility;
557 if ($lastpoid != $order_id || $lastpcid != $order_seq) {
558 ++$encount;
559 $lastrcn = '';
562 $bgcolor = "#" . (($encount & 1) ? "ddddff" : "ffdddd");
564 echo " <tr class='detail' bgcolor='$bgcolor'>\n";
566 // Generate first 2 columns.
567 if ($lastpoid != $order_id || $lastpcid != $order_seq) {
568 $lastprid = -1; // force report fields on first line of each procedure
569 if ($form_batch) {
570 if ($lastpoid != $order_id) {
571 $tmp = $row['lname'];
572 if ($row['fname'] || $row['mname']) {
573 $tmp .= ', ' . $row['fname'] . ' ' . $row['mname'];
576 echo " <td>" . text($tmp) . "</td>\n";
577 echo " <td>" . text($row['pubpid']) . "</td>\n";
578 } else {
579 echo " <td colspan='2' style='background-color:transparent'>&nbsp;</td>";
581 } else {
582 if ($lastpoid != $order_id) {
583 echo " <td>" . $row['date_ordered'] . "</td>\n";
584 } else {
585 echo " <td style='background-color:transparent'>&nbsp;</td>";
588 echo " <td>" . text($row['procedure_name']) . "</td>\n";
590 } else {
591 echo " <td colspan='2' style='background-color:transparent'>&nbsp;</td>";
594 // If this starts a new report or a new order, generate the report form
595 // fields. In the case of a new order with no report yet, the fields will
596 // have their blank/default values, and form_line (above) will indicate a
597 // report ID of 0.
599 // TBD: Also generate default report fields and another set of results if
600 // the previous report is marked "Preliminary".
602 if ($report_id != $lastprid) {
603 echo " <td nowrap>";
604 echo "<input type='text' size='13' name='form_date_report[$lino]'" .
605 " id='form_date_report[$lino]' class='celltextfw datetimepicker' value='" . attr($date_report) . "' " .
606 " title='" . xl('Date and time of this report') . "'" .
607 " />";
608 echo "</td>\n";
610 echo " <td nowrap>";
611 echo "<input type='text' size='13' name='form_date_collected[$lino]'" .
612 " id='form_date_collected[$lino]'" .
613 " class='celltextfw datetimepicker' value='" . attr($date_collected) . "' " .
614 " title='" . xl('Date and time of sample collection') . "'" .
615 " />";
616 echo "</td>\n";
618 echo " <td>";
619 echo "<input type='text' size='8' name='form_specimen_num[$lino]'" .
620 " class='celltext' value='" . attr($specimen_num) . "' " .
621 " title='" . xl('Specimen number/identifier') . "'" .
622 " />";
623 echo "</td>\n";
625 echo " <td>";
626 echo generate_select_list(
627 "form_report_status[$lino]",
628 'proc_rep_status',
629 $report_status,
630 xl('Report Status'),
631 ' ',
632 'cellselect'
634 echo "</td>\n";
635 } else {
636 echo " <td colspan='4' style='background-color:transparent'>&nbsp;</td>\n";
639 echo " <td nowrap>";
640 echo "<input type='text' size='6' name='form_result_code[$lino]'" .
641 " class='celltext' value='" . attr($result_code) . "' />" .
642 "</td>\n";
644 echo " <td>" .
645 "<input type='text' size='16' name='form_result_text[$lino]'" .
646 " class='celltext' value='" . attr($result_text) . "' />";
647 "</td>\n";
649 echo " <td>";
650 echo generate_select_list(
651 "form_result_abnormal[$lino]",
652 'proc_res_abnormal',
653 $result_abnormal,
654 xl('Indicates abnormality'),
655 ' ',
656 'cellselect'
658 echo "</td>\n";
660 echo " <td>";
661 if ($result_units == 'bool') {
662 echo "&nbsp;--";
663 } else {
664 echo "<input type='text' size='7' name='form_result_result[$lino]'" .
665 " class='celltext' value='" . attr($result_result) . "' " .
666 " />";
669 echo "</td>\n";
671 echo " <td>";
672 echo "<input type='text' size='4' name='form_result_units[$lino]'" .
673 " class='celltext' value='" . attr($result_units) . "' " .
674 " title='" . xl('Units applicable to the result value') . "'" .
675 " />";
676 echo "</td>\n";
678 echo " <td>";
679 echo "<input type='text' size='8' name='form_result_range[$lino]'" .
680 " class='celltext' value='" . attr($result_range) . "' " .
681 " title='" . xl('Reference range of results') . "'" .
682 " />";
683 // Include a hidden form field containing all IDs for this line.
684 echo "<input type='hidden' name='form_line[$lino]' " .
685 "value='$order_id:$order_seq:$report_id:$result_id' />";
686 echo "</td>\n";
688 echo " <td class='bold' style='cursor:pointer' " .
689 "onclick='extShow($lino, this)' align='center' " .
690 "title='" . xl('Click here to view/edit more details') . "'>";
691 echo "&nbsp;?&nbsp;";
692 echo "</td>\n";
694 echo " </tr>\n";
696 // Create a floating div for additional attributes of this result.
697 $extra_html .= "<div id='ext_$lino' " .
698 "style='position:absolute;width:750px;border:1px solid black;" .
699 "padding:2px;background-color:#cccccc;visibility:hidden;" .
700 "z-index:1000;left:-1000px;top:0px;font-size:9pt;'>\n" .
701 "<table width='100%'>\n" .
702 "<tr><td class='bold' align='center' colspan='2' style='padding:4pt 0 4pt 0'>" .
703 htmlspecialchars($result_text) .
704 "</td></tr>\n" .
705 "<tr><td class='bold' width='1%' nowrap>" . xlt('Status') . ": </td>" .
706 "<td>" . generate_select_list(
707 "form_result_status[$lino]",
708 'proc_res_status',
709 $result_status,
710 xl('Result Status'),
712 ) . "</td></tr>\n" .
713 "<tr><td class='bold' nowrap>" . xlt('Facility') . ": </td>" . // Ensoftek: Changed Facility to Text Area as the field procedure_result-->facility is now multi-line
714 "<td><textarea rows='3' cols='15' name='form_facility[$lino]'" .
715 " title='" . xla('Supplier facility name') . "'" .
716 " style='width:100%' />" . htmlspecialchars($result_facility) .
717 "</textarea></td></tr>\n" .
718 "<tr><td class='bold' nowrap>" . xlt('Comments') . ": </td>" .
719 "<td><textarea rows='3' cols='15' name='form_comments[$lino]'" .
720 " title='" . xla('Comments for this result or recommendation') . "'" .
721 " style='width:100%' />" . htmlspecialchars($result_comments) .
722 "</textarea></td></tr>\n" .
723 "<tr><td class='bold' nowrap>" . xlt('Notes') . ": </td>" .
724 "<td><textarea rows='4' cols='15' name='form_notes[$lino]'" .
725 " title='" . xla('Additional notes for this result or recommendation') . "'" .
726 " style='width:100%' />" . htmlspecialchars($result_notes) .
727 "</textarea></td></tr>\n" .
728 "</table>\n" .
729 "<p><center><input type='button' value='" . xla('Close') . "' " .
730 "onclick='extShow($lino, false)' /></center></p>\n".
731 "</div>";
733 $lastpoid = $order_id;
734 $lastpcid = $order_seq;
735 $lastprid = $report_id;
736 ++$lino;
740 if (!empty($facilities)) {
741 // display facility information
742 $extra_html .= "<table>";
743 $extra_html .= "<tr><th>". xl('Performing Laboratory Facility') . "</th></tr>";
744 foreach ($facilities as $facilityID) {
745 foreach (explode(":", $facilityID) as $lab_facility) {
746 $facility_array = getFacilityInfo($lab_facility);
747 if ($facility_array) {
748 $extra_html .=
749 "<tr><td><hr></td></tr>" .
750 "<tr><td>". htmlspecialchars($facility_array['fname']) . " " . htmlspecialchars($facility_array['lname']) . ", " . htmlspecialchars($facility_array['title']). "</td></tr>" .
751 "<tr><td>". htmlspecialchars($facility_array['organization']) . "</td></tr>" .
752 "<tr><td>". htmlspecialchars($facility_array['street']) . " " .htmlspecialchars($facility_array['city']) . " " . htmlspecialchars($facility_array['state']) . "</td></tr>" .
753 "<tr><td>". htmlspecialchars(formatPhone($facility_array['phone'])) . "</td></tr>";
758 $extra_html .= "</table>\n";
762 </table>
764 <?php
765 if ($form_review) {
766 // if user authorized for pending review.
767 if ($reviewauth) {
769 <center><p>
770 <input type='submit' name='form_submit' value='<?php xl('Sign Results', 'e'); ?>' />
771 </p></center>
772 <?php
773 } else {
775 <center><p>
776 <input type='button' name='form_submit' value='<?php xl('Sign Results', 'e'); ?>' onclick="alert('<?php xl('Not authorized', 'e') ?>');" />
777 </p></center>
778 <?php
780 } else {
782 <center><p>
783 <input type='submit' name='form_submit' value='<?php xl('Save', 'e'); ?>' />
784 </p></center>
785 <?php
789 <?php } ?>
791 <?php echo $extra_html; ?>
793 </form>
794 </body>
795 </html>