ongoing new datepicker project
[openemr.git] / interface / orders / orders_results.php
blob8fc20e6503af2e20790616ad250c7c01ce11127d
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) die(xl('Not authorized'));
38 // Check authorization for pending review.
39 $reviewauth = acl_check('patients', 'sign');
40 if ($form_review and !$reviewauth and !$thisauth) die(xl('Not authorized'));
42 // Set pid for pending review.
43 if ($_GET['set_pid'] && $form_review) {
44 require_once("$srcdir/pid.inc");
45 require_once("$srcdir/patient.inc");
46 setpid($_GET['set_pid']);
48 $result = getPatientData($pid, "*, DATE_FORMAT(DOB,'%Y-%m-%d') as DOB_YMD");
50 <script language='JavaScript'>
51 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']) . "'"; ?>);
52 </script>
53 <?php
56 if (!$form_batch && !$pid && !$form_review) die(xl('There is no current patient'));
58 function oresRawData($name, $index) {
59 $s = isset($_POST[$name][$index]) ? $_POST[$name][$index] : '';
60 return trim(strip_escape_custom($s));
63 function oresData($name, $index) {
64 $s = isset($_POST[$name][$index]) ? $_POST[$name][$index] : '';
65 return formDataCore($s, true);
68 function QuotedOrNull($fld) {
69 if (empty($fld)) return "NULL";
70 return "'$fld'";
73 $current_report_id = 0;
75 if ($_POST['form_submit'] && !empty($_POST['form_line'])) {
76 foreach ($_POST['form_line'] as $lino => $line_value) {
77 list($order_id, $order_seq, $report_id, $result_id) = explode(':', $line_value);
79 // Not using xl() here because this is for debugging only.
80 if (empty($order_id)) die("Order ID is missing from line $lino.");
82 // If report data exists for this line, save it.
83 $date_report = oresData("form_date_report", $lino);
85 if (!empty($date_report)) {
86 $sets =
87 "procedure_order_id = '$order_id', " .
88 "procedure_order_seq = '$order_seq', " .
89 "date_report = '$date_report', " .
90 "date_collected = " . QuotedOrNull(oresData("form_date_collected", $lino)) . ", " .
91 "specimen_num = '" . oresData("form_specimen_num", $lino) . "', " .
92 "report_status = '" . oresData("form_report_status", $lino) . "'";
94 // Set the review status to reviewed.
95 if ($form_review)
96 $sets .= ", review_status = 'reviewed'";
98 if ($report_id) { // Report already exists.
99 sqlStatement("UPDATE procedure_report SET $sets " .
100 "WHERE procedure_report_id = '$report_id'");
102 else { // Add new report.
103 $report_id = sqlInsert("INSERT INTO procedure_report SET $sets");
107 // If this line had report data entry fields, filled or not, set the
108 // "current report ID" which the following result data will link to.
109 if (isset($_POST["form_date_report"][$lino])) $current_report_id = $report_id;
111 // If there's a report, save corresponding results.
112 if ($current_report_id) {
113 // Comments and notes will be combined into one comments field.
114 $form_comments = oresRawData("form_comments", $lino);
115 $form_comments = str_replace("\n" ,'~' , $form_comments);
116 $form_comments = str_replace("\r" ,'' , $form_comments);
117 $form_notes = oresRawData("form_notes", $lino);
118 if ($form_notes !== '') {
119 $form_comments .= "\n" . $form_notes;
121 $sets =
122 "procedure_report_id = '$current_report_id', " .
123 "result_code = '" . oresData("form_result_code", $lino) . "', " .
124 "result_text = '" . oresData("form_result_text", $lino) . "', " .
125 "abnormal = '" . oresData("form_result_abnormal", $lino) . "', " .
126 "result = '" . oresData("form_result_result", $lino) . "', " .
127 "`range` = '" . oresData("form_result_range", $lino) . "', " .
128 "units = '" . oresData("form_result_units", $lino) . "', " .
129 "facility = '" . oresData("form_facility", $lino) . "', " .
130 "comments = '" . add_escape_custom($form_comments) . "', " .
131 "result_status = '" . oresData("form_result_status", $lino) . "'";
132 if ($result_id) { // result already exists
133 sqlStatement("UPDATE procedure_result SET $sets " .
134 "WHERE procedure_result_id = '$result_id'");
136 else { // Add new result.
137 $result_id = sqlInsert("INSERT INTO procedure_result SET $sets");
140 } // end foreach
143 <html>
145 <head>
146 <?php html_header_show();?>
148 <link rel="stylesheet" href='<?php echo $css_header ?>' type='text/css'>
149 <link rel="stylesheet" href="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker-2-5-4/build/jquery.datetimepicker.min.css">
151 <title><?php xl('Procedure Results','e'); ?></title>
153 <style>
155 tr.head { font-size:10pt; background-color:#cccccc; text-align:center; }
156 tr.detail { font-size:10pt; }
157 a, a:visited, a:hover { color:#0000cc; }
159 .celltext {
160 font-size:10pt;
161 font-weight:normal;
162 border-style:solid;
163 border-top-width:0px;
164 border-bottom-width:0px;
165 border-left-width:0px;
166 border-right-width:0px;
167 border-color: #aaaaaa;
168 background-color:transparent;
169 width:100%;
170 color:#0000cc;
173 .celltextfw {
174 font-size:10pt;
175 font-weight:normal;
176 border-style:solid;
177 border-top-width:0px;
178 border-bottom-width:0px;
179 border-left-width:0px;
180 border-right-width:0px;
181 border-color: #aaaaaa;
182 background-color:transparent;
183 color:#0000cc;
186 .cellselect {
187 font-size:10pt;
188 background-color:transparent;
189 color:#0000cc;
192 .reccolor {
193 color:#008800;
196 </style>
197 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-3-1-1/index.js"></script>
198 <script type="text/javascript" src="../../library/dialog.js?v=<?php echo $v_js_includes; ?>"></script>
199 <script type="text/javascript" src="../../library/textformat.js?v=<?php echo $v_js_includes; ?>"></script>
200 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker-2-5-4/build/jquery.datetimepicker.full.min.js"></script>
202 <script language="JavaScript">
204 var mypcc = '<?php echo $GLOBALS['phone_country_code'] ?>';
206 // This invokes the find-procedure-type popup.
207 var ptvarname;
208 function sel_proc_type(varname) {
209 var f = document.forms[0];
210 if (typeof varname == 'undefined') varname = 'form_proc_type';
211 ptvarname = varname;
212 dlgopen('types.php?popup=1&order=' + f[ptvarname].value, '_blank', 800, 500);
215 // This is for callback by the find-procedure-type popup.
216 // Sets both the selected type ID and its descriptive name.
217 function set_proc_type(typeid, typename) {
218 var f = document.forms[0];
219 f[ptvarname].value = typeid;
220 f[ptvarname + '_desc'].value = typename;
223 // Helper functions.
224 function extGetX(elem) {
225 var x = 0;
226 while(elem != null) {
227 x += elem.offsetLeft;
228 elem = elem.offsetParent;
230 return x;
232 function extGetY(elem) {
233 var y = 0;
234 while(elem != null) {
235 y += elem.offsetTop;
236 elem = elem.offsetParent;
238 return y;
241 // Show or hide the "extras" div for a result.
242 var extdiv = null;
243 function extShow(lino, show) {
244 var thisdiv = document.getElementById("ext_" + lino);
245 if (extdiv) {
246 extdiv.style.visibility = 'hidden';
247 extdiv.style.left = '-1000px';
248 extdiv.style.top = '0px';
250 if (show && thisdiv != extdiv) {
251 extdiv = thisdiv;
252 var dw = window.innerWidth ? window.innerWidth - 20 : document.body.clientWidth;
253 x = dw - extdiv.offsetWidth;
254 if (x < 0) x = 0;
255 var y = extGetY(show) + show.offsetHeight;
256 extdiv.style.left = x;
257 extdiv.style.top = y;
258 extdiv.style.visibility = 'visible';
260 else {
261 extdiv = null;
265 // Helper function for validate.
266 function prDateRequired(rlino) {
267 var f = document.forms[0];
268 if (f['form_date_report['+rlino+']'].value.length < 10) {
269 alert('<?php xl('Missing report date','e') ?>');
270 if (f['form_date_report['+rlino+']'].focus)
271 f['form_date_report['+rlino+']'].focus();
272 return false;
274 return true;
277 // Validation at submit time.
278 function validate(f) {
279 var rlino = 0;
280 for (var lino = 0; f['form_line['+lino+']']; ++lino) {
281 if (f['form_date_report['+lino+']']) {
282 rlino = lino;
283 if (f['form_report_status['+rlino+']'].selectedIndex > 0) {
284 if (!prDateRequired(rlino)) return false;
287 var abnstat = f['form_result_abnormal['+lino+']'].selectedIndex > 0;
288 if (abnstat && !prDateRequired(rlino)) return false;
290 top.restoreSession();
291 return true;
294 $(document).ready(function() {
295 $('.datepicker').datetimepicker({
296 <?php $datetimepicker_timepicker = false; ?>
297 <?php $datetimepicker_showseconds = false; ?>
298 <?php $datetimepicker_formatInput = false; ?>
299 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
300 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
302 $('.datetimepicker').datetimepicker({
303 <?php $datetimepicker_timepicker = true; ?>
304 <?php $datetimepicker_showseconds = false; ?>
305 <?php $datetimepicker_formatInput = false; ?>
306 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
307 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
311 </script>
313 </head>
315 <body class="body_top">
316 <form method='post' action='orders_results.php?batch=<?php echo $form_batch; ?>&review=<?php echo $form_review; ?>'
317 onsubmit='return validate(this)'>
319 <table>
320 <tr>
321 <td class='text'>
322 <?php
323 if ($form_batch) {
324 $form_from_date = formData('form_from_date','P',true);
325 $form_to_date = formData('form_to_date','P',true);
326 if (empty($form_to_date)) $form_to_date = $form_from_date;
327 $form_proc_type = formData('form_proc_type') + 0;
328 if (!$form_proc_type) $form_proc_type = -1;
329 $form_proc_type_desc = '';
330 if ($form_proc_type > 0) {
331 $ptrow = sqlQuery("SELECT name FROM procedure_type WHERE " .
332 "procedure_type_id = '$form_proc_type'");
333 $form_proc_type_desc = $ptrow['name'];
336 <?php xl('Procedure','e'); ?>:
337 <input type='text' size='30' name='form_proc_type_desc'
338 value='<?php echo addslashes($form_proc_type_desc) ?>'
339 onclick='sel_proc_type()' onfocus='this.blur()'
340 title='<?php xl('Click to select the desired procedure','e'); ?>'
341 style='cursor:pointer;cursor:hand' readonly />
342 <input type='hidden' name='form_proc_type' value='<?php echo $form_proc_type ?>' />
344 &nbsp;<?php xl('From','e'); ?>:
345 <input type='text' size='10' class='datepicker' name='form_from_date' id='form_from_date'
346 value='<?php echo $form_from_date ?>'
347 title='<?php xl('yyyy-mm-dd','e'); ?>' />
349 &nbsp;<?php xl('To','e'); ?>:
350 <input type='text' size='10' class='datepicker' name='form_to_date' id='form_to_date'
351 value='<?php echo $form_to_date ?>'
352 title='<?php xl('yyyy-mm-dd','e'); ?>' />
354 &nbsp;
355 <?php
356 } // end header for batch option
358 <!-- removed by jcw -- check/submit sequece too tedious. This is a quick fix -->
359 <!-- <input type='checkbox' name='form_all' value='1' <?php if ($_POST['form_all']) echo " checked"; ?>><?php xl('Include Completed','e') ?>
360 &nbsp;-->
361 <input type='submit' name='form_refresh' value=<?php xl('Refresh','e'); ?>>
362 </td>
363 </tr>
364 </table>
366 <?php if (!$form_batch || ($form_proc_type > 0 && $form_from_date)) { ?>
368 <table width='100%' cellpadding='1' cellspacing='2'>
370 <tr class='head'>
371 <td colspan='2'><?php echo $form_batch ? xl('Patient') : xl('Order'); ?></td>
372 <td colspan='4'><?php xl('Report','e'); ?></td>
373 <td colspan='7'><?php xl('Results and','e'); ?> <span class='reccolor''>
374 <?php xl('Recommendations','e'); ?></span></td>
375 </tr>
377 <tr class='head'>
378 <td><?php echo $form_batch ? xl('Name') : xl('Date'); ?></td>
379 <td><?php echo $form_batch ? xl('ID') : xl('Procedure Name'); ?></td>
380 <td><?php xl('Reported','e'); ?></td>
381 <td><?php xl('Ext Time Collected','e'); ?></td>
382 <td><?php xl('Specimen','e'); ?></td>
383 <td><?php xl('Status','e'); ?></td>
384 <td><?php xl('Code','e'); ?></td>
385 <td><?php xl('Name','e'); ?></td>
386 <td><?php xl('Abn','e'); ?></td>
387 <td><?php xl('Value','e'); ?></td>
388 <td><?php xl('Units', 'e'); ?></td>
389 <td><?php xl('Range','e'); ?></td>
390 <td><?php xl('?','e'); ?></td>
391 </tr>
393 <?php
394 $selects =
395 "po.procedure_order_id, po.date_ordered, pc.procedure_order_seq, " .
396 "pt1.procedure_type_id AS order_type_id, pc.procedure_name, " .
397 "pr.procedure_report_id, pr.date_report, pr.date_collected, pr.specimen_num, " .
398 "pr.report_status, pr.review_status";
400 $joins =
401 "JOIN procedure_order_code AS pc ON pc.procedure_order_id = po.procedure_order_id " .
402 "LEFT JOIN procedure_type AS pt1 ON pt1.lab_id = po.lab_id AND pt1.procedure_code = pc.procedure_code " .
403 "LEFT JOIN procedure_report AS pr ON pr.procedure_order_id = po.procedure_order_id AND " .
404 "pr.procedure_order_seq = pc.procedure_order_seq";
406 $orderby =
407 "po.date_ordered, po.procedure_order_id, " .
408 "pc.procedure_order_seq, pr.procedure_report_id";
410 // removed by jcw -- check/submit sequece too tedious. This is a quick fix
411 //$where = empty($_POST['form_all']) ?
412 // "( pr.report_status IS NULL OR pr.report_status = '' OR pr.report_status = 'prelim' )" :
413 // "1 = 1";
415 $where = "1 = 1";
417 if ($form_batch) {
418 $query = "SELECT po.patient_id, " .
419 "pd.fname, pd.mname, pd.lname, pd.pubpid, $selects " .
420 "FROM procedure_order AS po " .
421 "LEFT JOIN patient_data AS pd ON pd.pid = po.patient_id $joins " .
422 "WHERE pt1.procedure_type_id = '$form_proc_type' AND " .
423 "po.date_ordered >= '$form_from_date' AND po.date_ordered <= '$form_to_date' " .
424 "AND $where " .
425 "ORDER BY pd.lname, pd.fname, pd.mname, po.patient_id, $orderby";
427 else {
428 $query = "SELECT $selects " .
429 "FROM procedure_order AS po " .
430 "$joins " .
431 "WHERE po.patient_id = '$pid' AND $where " .
432 "ORDER BY $orderby";
435 $res = sqlStatement($query);
437 $lastpoid = -1;
438 $lastpcid = -1;
439 $lastprid = -1;
440 $encount = 0;
441 $lino = 0;
442 $extra_html = '';
443 $lastrcn = '';
444 $facilities = array();
446 while ($row = sqlFetchArray($res)) {
447 $order_type_id = empty($row['order_type_id' ]) ? 0 : ($row['order_type_id' ] + 0);
448 $order_id = empty($row['procedure_order_id' ]) ? 0 : ($row['procedure_order_id' ] + 0);
449 $order_seq = empty($row['procedure_order_seq']) ? 0 : ($row['procedure_order_seq'] + 0);
450 $report_id = empty($row['procedure_report_id']) ? 0 : ($row['procedure_report_id'] + 0);
451 $date_report = empty($row['date_report' ]) ? '' : substr($row['date_report'], 0, 16);
452 $date_collected = empty($row['date_collected' ]) ? '' : substr($row['date_collected'], 0, 16);
453 $specimen_num = empty($row['specimen_num' ]) ? '' : $row['specimen_num'];
454 $report_status = empty($row['report_status' ]) ? '' : $row['report_status'];
455 $review_status = empty($row['review_status' ]) ? 'received' : $row['review_status'];
457 // skip report_status = receive to make sure do not show the report before it reviewed and sign off by Physicians
458 if ($form_review) {
459 if ($review_status == "reviewed") continue;
461 else {
462 if ($review_status == "received") continue;
465 $query_test=sqlFetchArray(sqlStatement("select deleted from forms where form_id=? and formdir='procedure_order'",array($order_id)));
466 // skip the procedure that has been deleted from the encounter form
467 if($query_test['deleted']==1) continue;
469 $selects = "pt2.procedure_type, pt2.procedure_code, pt2.units AS pt2_units, " .
470 "pt2.range AS pt2_range, pt2.procedure_type_id AS procedure_type_id, " .
471 "pt2.name AS name, pt2.description, pt2.seq AS seq, " .
472 "ps.procedure_result_id, ps.result_code AS result_code, ps.result_text, ps.abnormal, ps.result, " .
473 "ps.range, ps.result_status, ps.facility, ps.comments, ps.units, ps.comments";
475 // procedure_type_id for order:
476 $pt2cond = "pt2.parent = $order_type_id AND " .
477 "(pt2.procedure_type LIKE 'res%' OR pt2.procedure_type LIKE 'rec%')";
479 // pr.procedure_report_id or 0 if none:
480 $pscond = "ps.procedure_report_id = $report_id";
482 $joincond = "ps.result_code = pt2.procedure_code";
484 // This union emulates a full outer join. The idea is to pick up all
485 // result types defined for this order type, as well as any actual
486 // results that do not have a matching result type.
487 $query = "(SELECT $selects FROM procedure_type AS pt2 " .
488 "LEFT JOIN procedure_result AS ps ON $pscond AND $joincond " .
489 "WHERE $pt2cond" .
490 ") UNION (" .
491 "SELECT $selects FROM procedure_result AS ps " .
492 "LEFT JOIN procedure_type AS pt2 ON $pt2cond AND $joincond " .
493 "WHERE $pscond) " .
494 "ORDER BY seq, name, procedure_type_id, result_code";
496 $rres = sqlStatement($query);
497 while ($rrow = sqlFetchArray($rres)) {
498 $restyp_code = empty($rrow['procedure_code' ]) ? '' : $rrow['procedure_code'];
499 $restyp_type = empty($rrow['procedure_type' ]) ? '' : $rrow['procedure_type'];
500 $restyp_name = empty($rrow['name' ]) ? '' : $rrow['name'];
501 $restyp_units = empty($rrow['pt2_units' ]) ? '' : $rrow['pt2_units'];
502 $restyp_range = empty($rrow['pt2_range' ]) ? '' : $rrow['pt2_range'];
504 $result_id = empty($rrow['procedure_result_id']) ? 0 : ($rrow['procedure_result_id'] + 0);
505 $result_code = empty($rrow['result_code' ]) ? $restyp_code : $rrow['result_code'];
506 $result_text = empty($rrow['result_text' ]) ? $restyp_name : $rrow['result_text'];
507 $result_abnormal = empty($rrow['abnormal' ]) ? '' : $rrow['abnormal'];
508 $result_result = empty($rrow['result' ]) ? '' : $rrow['result'];
509 $result_units = empty($rrow['units' ]) ? $restyp_units : $rrow['units'];
510 $result_facility = empty($rrow['facility' ]) ? '' : $rrow['facility'];
511 $result_comments = empty($rrow['comments' ]) ? '' : $rrow['comments'];
512 $result_range = empty($rrow['range' ]) ? $restyp_range : $rrow['range'];
513 $result_status = empty($rrow['result_status' ]) ? '' : $rrow['result_status'];
515 // If there is more than one line of comments, everything after that is "notes".
516 $result_notes = '';
517 $i = strpos($result_comments, "\n");
518 if ($i !== FALSE) {
519 $result_notes = trim(substr($result_comments, $i + 1));
520 $result_comments = substr($result_comments, 0, $i);
522 $result_comments = trim($result_comments);
524 if($result_facility <> "" && !in_array($result_facility, $facilities)) {
525 $facilities[] = $result_facility;
528 if ($lastpoid != $order_id || $lastpcid != $order_seq) {
529 ++$encount;
530 $lastrcn = '';
532 $bgcolor = "#" . (($encount & 1) ? "ddddff" : "ffdddd");
534 echo " <tr class='detail' bgcolor='$bgcolor'>\n";
536 // Generate first 2 columns.
537 if ($lastpoid != $order_id || $lastpcid != $order_seq) {
538 $lastprid = -1; // force report fields on first line of each procedure
539 if ($form_batch) {
540 if ($lastpoid != $order_id) {
541 $tmp = $row['lname'];
542 if ($row['fname'] || $row['mname'])
543 $tmp .= ', ' . $row['fname'] . ' ' . $row['mname'];
544 echo " <td>" . text($tmp) . "</td>\n";
545 echo " <td>" . text($row['pubpid']) . "</td>\n";
547 else {
548 echo " <td colspan='2' style='background-color:transparent'>&nbsp;</td>";
551 else {
552 if ($lastpoid != $order_id) {
553 echo " <td>" . $row['date_ordered'] . "</td>\n";
555 else {
556 echo " <td style='background-color:transparent'>&nbsp;</td>";
558 echo " <td>" . text($row['procedure_name']) . "</td>\n";
561 else {
562 echo " <td colspan='2' style='background-color:transparent'>&nbsp;</td>";
565 // If this starts a new report or a new order, generate the report form
566 // fields. In the case of a new order with no report yet, the fields will
567 // have their blank/default values, and form_line (above) will indicate a
568 // report ID of 0.
570 // TBD: Also generate default report fields and another set of results if
571 // the previous report is marked "Preliminary".
573 if ($report_id != $lastprid) {
574 echo " <td nowrap>";
575 echo "<input type='text' size='13' name='form_date_report[$lino]'" .
576 " id='form_date_report[$lino]' class='celltextfw datetimepicker' value='" . attr($date_report) . "' " .
577 " title='" . xl('Date and time of this report') . "'" .
578 " />";
579 echo "</td>\n";
581 echo " <td nowrap>";
582 echo "<input type='text' size='13' name='form_date_collected[$lino]'" .
583 " id='form_date_collected[$lino]'" .
584 " class='celltextfw datetimepicker' value='" . attr($date_collected) . "' " .
585 " title='" . xl('Date and time of sample collection') . "'" .
586 " />";
587 echo "</td>\n";
589 echo " <td>";
590 echo "<input type='text' size='8' name='form_specimen_num[$lino]'" .
591 " class='celltext' value='" . attr($specimen_num) . "' " .
592 " title='" . xl('Specimen number/identifier') . "'" .
593 " />";
594 echo "</td>\n";
596 echo " <td>";
597 echo generate_select_list("form_report_status[$lino]", 'proc_rep_status',
598 $report_status, xl('Report Status'), ' ', 'cellselect');
599 echo "</td>\n";
601 else {
602 echo " <td colspan='4' style='background-color:transparent'>&nbsp;</td>\n";
605 echo " <td nowrap>";
606 echo "<input type='text' size='6' name='form_result_code[$lino]'" .
607 " class='celltext' value='" . attr($result_code) . "' />" .
608 "</td>\n";
610 echo " <td>" .
611 "<input type='text' size='16' name='form_result_text[$lino]'" .
612 " class='celltext' value='" . attr($result_text) . "' />";
613 "</td>\n";
615 echo " <td>";
616 echo generate_select_list("form_result_abnormal[$lino]", 'proc_res_abnormal',
617 $result_abnormal, xl('Indicates abnormality'), ' ', 'cellselect');
618 echo "</td>\n";
620 echo " <td>";
621 if ($result_units == 'bool') {
622 echo "&nbsp;--";
624 else {
625 echo "<input type='text' size='7' name='form_result_result[$lino]'" .
626 " class='celltext' value='" . attr($result_result) . "' " .
627 " />";
629 echo "</td>\n";
631 echo " <td>";
632 echo "<input type='text' size='4' name='form_result_units[$lino]'" .
633 " class='celltext' value='" . attr($result_units) . "' " .
634 " title='" . xl('Units applicable to the result value') . "'" .
635 " />";
636 echo "</td>\n";
638 echo " <td>";
639 echo "<input type='text' size='8' name='form_result_range[$lino]'" .
640 " class='celltext' value='" . attr($result_range) . "' " .
641 " title='" . xl('Reference range of results') . "'" .
642 " />";
643 // Include a hidden form field containing all IDs for this line.
644 echo "<input type='hidden' name='form_line[$lino]' " .
645 "value='$order_id:$order_seq:$report_id:$result_id' />";
646 echo "</td>\n";
648 echo " <td class='bold' style='cursor:pointer' " .
649 "onclick='extShow($lino, this)' align='center' " .
650 "title='" . xl('Click here to view/edit more details') . "'>";
651 echo "&nbsp;?&nbsp;";
652 echo "</td>\n";
654 echo " </tr>\n";
656 // Create a floating div for additional attributes of this result.
657 $extra_html .= "<div id='ext_$lino' " .
658 "style='position:absolute;width:750px;border:1px solid black;" .
659 "padding:2px;background-color:#cccccc;visibility:hidden;" .
660 "z-index:1000;left:-1000px;top:0px;font-size:9pt;'>\n" .
661 "<table width='100%'>\n" .
662 "<tr><td class='bold' align='center' colspan='2' style='padding:4pt 0 4pt 0'>" .
663 htmlspecialchars($result_text) .
664 "</td></tr>\n" .
665 "<tr><td class='bold' width='1%' nowrap>" . xlt('Status') . ": </td>" .
666 "<td>" . generate_select_list("form_result_status[$lino]", 'proc_res_status',
667 $result_status, xl('Result Status'), '') . "</td></tr>\n" .
668 "<tr><td class='bold' nowrap>" . xlt('Facility') . ": </td>" . // Ensoftek: Changed Facility to Text Area as the field procedure_result-->facility is now multi-line
669 "<td><textarea rows='3' cols='15' name='form_facility[$lino]'" .
670 " title='" . xla('Supplier facility name') . "'" .
671 " style='width:100%' />" . htmlspecialchars($result_facility) .
672 "</textarea></td></tr>\n" .
673 "<tr><td class='bold' nowrap>" . xlt('Comments') . ": </td>" .
674 "<td><textarea rows='3' cols='15' name='form_comments[$lino]'" .
675 " title='" . xla('Comments for this result or recommendation') . "'" .
676 " style='width:100%' />" . htmlspecialchars($result_comments) .
677 "</textarea></td></tr>\n" .
678 "<tr><td class='bold' nowrap>" . xlt('Notes') . ": </td>" .
679 "<td><textarea rows='4' cols='15' name='form_notes[$lino]'" .
680 " title='" . xla('Additional notes for this result or recommendation') . "'" .
681 " style='width:100%' />" . htmlspecialchars($result_notes) .
682 "</textarea></td></tr>\n" .
683 "</table>\n" .
684 "<p><center><input type='button' value='" . xla('Close') . "' " .
685 "onclick='extShow($lino, false)' /></center></p>\n".
686 "</div>";
688 $lastpoid = $order_id;
689 $lastpcid = $order_seq;
690 $lastprid = $report_id;
691 ++$lino;
695 if (!empty($facilities)) {
696 // display facility information
697 $extra_html .= "<table>";
698 $extra_html .= "<tr><th>". xl('Performing Laboratory Facility') . "</th></tr>";
699 foreach($facilities as $facilityID) {
700 foreach(explode(":", $facilityID) as $lab_facility) {
701 $facility_array = getFacilityInfo($lab_facility);
702 if($facility_array) {
703 $extra_html .=
704 "<tr><td><hr></td></tr>" .
705 "<tr><td>". htmlspecialchars($facility_array['fname']) . " " . htmlspecialchars($facility_array['lname']) . ", " . htmlspecialchars($facility_array['title']). "</td></tr>" .
706 "<tr><td>". htmlspecialchars($facility_array['organization']) . "</td></tr>" .
707 "<tr><td>". htmlspecialchars($facility_array['street']) . " " .htmlspecialchars($facility_array['city']) . " " . htmlspecialchars($facility_array['state']) . "</td></tr>" .
708 "<tr><td>". htmlspecialchars(formatPhone($facility_array['phone'])) . "</td></tr>";
712 $extra_html .= "</table>\n";
716 </table>
718 <?php
719 if ($form_review) {
720 // if user authorized for pending review.
721 if ($reviewauth) {
723 <center><p>
724 <input type='submit' name='form_submit' value='<?php xl('Sign Results','e'); ?>' />
725 </p></center>
726 <?php
728 else {
730 <center><p>
731 <input type='button' name='form_submit' value='<?php xl('Sign Results','e'); ?>' onclick="alert('<?php xl('Not authorized','e') ?>');" />
732 </p></center>
733 <?php
736 else {
738 <center><p>
739 <input type='submit' name='form_submit' value='<?php xl('Save','e'); ?>' />
740 </p></center>
741 <?php
745 <?php } ?>
747 <?php echo $extra_html; ?>
749 </form>
750 </body>
751 </html>