migrated ubiquitous libraries to composer autoloader (#421)
[openemr.git] / interface / orders / orders_results.php
blob5e5a2f4328bd6f3d24f978150a779eade22e207c
1 <?php
2 /**
3 * Copyright (C) 2010-2013 Rod Roark <rod@sunsetsystems.com>
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 */
11 require_once("../globals.php");
12 require_once("$srcdir/acl.inc");
13 require_once("$srcdir/options.inc.php");
14 require_once("$srcdir/formatting.inc.php");
15 require_once("../orders/lab_exchange_tools.php");
17 // Indicates if we are entering in batch mode.
18 $form_batch = empty($_GET['batch']) ? 0 : 1;
20 // Indicates if we are entering in review mode.
21 $form_review = empty($_GET['review']) ? 0 : 1;
23 // Check authorization.
24 $thisauth = acl_check('patients', 'med');
25 if (!$thisauth) die(xl('Not authorized'));
27 // Check authorization for pending review.
28 $reviewauth = acl_check('patients', 'sign');
29 if ($form_review and !$reviewauth and !$thisauth) die(xl('Not authorized'));
31 // Set pid for pending review.
32 if ($_GET['set_pid'] && $form_review) {
33 require_once("$srcdir/pid.inc");
34 require_once("$srcdir/patient.inc");
35 setpid($_GET['set_pid']);
37 $result = getPatientData($pid, "*, DATE_FORMAT(DOB,'%Y-%m-%d') as DOB_YMD");
39 <script language='JavaScript'>
40 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']) . "'"; ?>);
41 </script>
42 <?php
45 if (!$form_batch && !$pid && !$form_review) die(xl('There is no current patient'));
47 function oresRawData($name, $index) {
48 $s = isset($_POST[$name][$index]) ? $_POST[$name][$index] : '';
49 return trim(strip_escape_custom($s));
52 function oresData($name, $index) {
53 $s = isset($_POST[$name][$index]) ? $_POST[$name][$index] : '';
54 return formDataCore($s, true);
57 function QuotedOrNull($fld) {
58 if (empty($fld)) return "NULL";
59 return "'$fld'";
62 $current_report_id = 0;
64 if ($_POST['form_submit'] && !empty($_POST['form_line'])) {
65 foreach ($_POST['form_line'] as $lino => $line_value) {
66 list($order_id, $order_seq, $report_id, $result_id) = explode(':', $line_value);
68 // Not using xl() here because this is for debugging only.
69 if (empty($order_id)) die("Order ID is missing from line $lino.");
71 // If report data exists for this line, save it.
72 $date_report = oresData("form_date_report", $lino);
74 if (!empty($date_report)) {
75 $sets =
76 "procedure_order_id = '$order_id', " .
77 "procedure_order_seq = '$order_seq', " .
78 "date_report = '$date_report', " .
79 "date_collected = " . QuotedOrNull(oresData("form_date_collected", $lino)) . ", " .
80 "specimen_num = '" . oresData("form_specimen_num", $lino) . "', " .
81 "report_status = '" . oresData("form_report_status", $lino) . "'";
83 // Set the review status to reviewed.
84 if ($form_review)
85 $sets .= ", review_status = 'reviewed'";
87 if ($report_id) { // Report already exists.
88 sqlStatement("UPDATE procedure_report SET $sets " .
89 "WHERE procedure_report_id = '$report_id'");
91 else { // Add new report.
92 $report_id = sqlInsert("INSERT INTO procedure_report SET $sets");
96 // If this line had report data entry fields, filled or not, set the
97 // "current report ID" which the following result data will link to.
98 if (isset($_POST["form_date_report"][$lino])) $current_report_id = $report_id;
100 // If there's a report, save corresponding results.
101 if ($current_report_id) {
102 // Comments and notes will be combined into one comments field.
103 $form_comments = oresRawData("form_comments", $lino);
104 $form_comments = str_replace("\n" ,'~' , $form_comments);
105 $form_comments = str_replace("\r" ,'' , $form_comments);
106 $form_notes = oresRawData("form_notes", $lino);
107 if ($form_notes !== '') {
108 $form_comments .= "\n" . $form_notes;
110 $sets =
111 "procedure_report_id = '$current_report_id', " .
112 "result_code = '" . oresData("form_result_code", $lino) . "', " .
113 "result_text = '" . oresData("form_result_text", $lino) . "', " .
114 "abnormal = '" . oresData("form_result_abnormal", $lino) . "', " .
115 "result = '" . oresData("form_result_result", $lino) . "', " .
116 "`range` = '" . oresData("form_result_range", $lino) . "', " .
117 "units = '" . oresData("form_result_units", $lino) . "', " .
118 "facility = '" . oresData("form_facility", $lino) . "', " .
119 "comments = '" . add_escape_custom($form_comments) . "', " .
120 "result_status = '" . oresData("form_result_status", $lino) . "'";
121 if ($result_id) { // result already exists
122 sqlStatement("UPDATE procedure_result SET $sets " .
123 "WHERE procedure_result_id = '$result_id'");
125 else { // Add new result.
126 $result_id = sqlInsert("INSERT INTO procedure_result SET $sets");
129 } // end foreach
132 <html>
134 <head>
135 <?php html_header_show();?>
137 <link rel="stylesheet" href='<?php echo $css_header ?>' type='text/css'>
138 <title><?php xl('Procedure Results','e'); ?></title>
140 <style>
142 tr.head { font-size:10pt; background-color:#cccccc; text-align:center; }
143 tr.detail { font-size:10pt; }
144 a, a:visited, a:hover { color:#0000cc; }
146 .celltext {
147 font-size:10pt;
148 font-weight:normal;
149 border-style:solid;
150 border-top-width:0px;
151 border-bottom-width:0px;
152 border-left-width:0px;
153 border-right-width:0px;
154 border-color: #aaaaaa;
155 background-color:transparent;
156 width:100%;
157 color:#0000cc;
160 .celltextfw {
161 font-size:10pt;
162 font-weight:normal;
163 border-style:solid;
164 border-top-width:0px;
165 border-bottom-width:0px;
166 border-left-width:0px;
167 border-right-width:0px;
168 border-color: #aaaaaa;
169 background-color:transparent;
170 color:#0000cc;
173 .cellselect {
174 font-size:10pt;
175 background-color:transparent;
176 color:#0000cc;
179 .reccolor {
180 color:#008800;
183 </style>
185 <style type="text/css">@import url(<?php echo $GLOBALS['webroot'] ?>/library/dynarch_calendar.css);</style>
186 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/dynarch_calendar.js"></script>
187 <?php include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?>
188 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/dynarch_calendar_setup.js"></script>
190 <script type="text/javascript" src="../../library/dialog.js?v=<?php echo $v_js_includes; ?>"></script>
191 <script type="text/javascript" src="../../library/textformat.js"></script>
193 <script language="JavaScript">
195 var mypcc = '<?php echo $GLOBALS['phone_country_code'] ?>';
197 // This invokes the find-procedure-type popup.
198 var ptvarname;
199 function sel_proc_type(varname) {
200 var f = document.forms[0];
201 if (typeof varname == 'undefined') varname = 'form_proc_type';
202 ptvarname = varname;
203 dlgopen('types.php?popup=1&order=' + f[ptvarname].value, '_blank', 800, 500);
206 // This is for callback by the find-procedure-type popup.
207 // Sets both the selected type ID and its descriptive name.
208 function set_proc_type(typeid, typename) {
209 var f = document.forms[0];
210 f[ptvarname].value = typeid;
211 f[ptvarname + '_desc'].value = typename;
214 // Helper functions.
215 function extGetX(elem) {
216 var x = 0;
217 while(elem != null) {
218 x += elem.offsetLeft;
219 elem = elem.offsetParent;
221 return x;
223 function extGetY(elem) {
224 var y = 0;
225 while(elem != null) {
226 y += elem.offsetTop;
227 elem = elem.offsetParent;
229 return y;
232 // Show or hide the "extras" div for a result.
233 var extdiv = null;
234 function extShow(lino, show) {
235 var thisdiv = document.getElementById("ext_" + lino);
236 if (extdiv) {
237 extdiv.style.visibility = 'hidden';
238 extdiv.style.left = '-1000px';
239 extdiv.style.top = '0px';
241 if (show && thisdiv != extdiv) {
242 extdiv = thisdiv;
243 var dw = window.innerWidth ? window.innerWidth - 20 : document.body.clientWidth;
244 x = dw - extdiv.offsetWidth;
245 if (x < 0) x = 0;
246 var y = extGetY(show) + show.offsetHeight;
247 extdiv.style.left = x;
248 extdiv.style.top = y;
249 extdiv.style.visibility = 'visible';
251 else {
252 extdiv = null;
256 // Helper function for validate.
257 function prDateRequired(rlino) {
258 var f = document.forms[0];
259 if (f['form_date_report['+rlino+']'].value.length < 10) {
260 alert('<?php xl('Missing report date','e') ?>');
261 if (f['form_date_report['+rlino+']'].focus)
262 f['form_date_report['+rlino+']'].focus();
263 return false;
265 return true;
268 // Validation at submit time.
269 function validate(f) {
270 var rlino = 0;
271 for (var lino = 0; f['form_line['+lino+']']; ++lino) {
272 if (f['form_date_report['+lino+']']) {
273 rlino = lino;
274 if (f['form_report_status['+rlino+']'].selectedIndex > 0) {
275 if (!prDateRequired(rlino)) return false;
278 var abnstat = f['form_result_abnormal['+lino+']'].selectedIndex > 0;
279 if (abnstat && !prDateRequired(rlino)) return false;
281 top.restoreSession();
282 return true;
285 </script>
287 </head>
289 <body class="body_top">
290 <form method='post' action='orders_results.php?batch=<?php echo $form_batch; ?>&review=<?php echo $form_review; ?>'
291 onsubmit='return validate(this)'>
293 <table>
294 <tr>
295 <td class='text'>
296 <?php
297 if ($form_batch) {
298 $form_from_date = formData('form_from_date','P',true);
299 $form_to_date = formData('form_to_date','P',true);
300 if (empty($form_to_date)) $form_to_date = $form_from_date;
301 $form_proc_type = formData('form_proc_type') + 0;
302 if (!$form_proc_type) $form_proc_type = -1;
303 $form_proc_type_desc = '';
304 if ($form_proc_type > 0) {
305 $ptrow = sqlQuery("SELECT name FROM procedure_type WHERE " .
306 "procedure_type_id = '$form_proc_type'");
307 $form_proc_type_desc = $ptrow['name'];
310 <?php xl('Procedure','e'); ?>:
311 <input type='text' size='30' name='form_proc_type_desc'
312 value='<?php echo addslashes($form_proc_type_desc) ?>'
313 onclick='sel_proc_type()' onfocus='this.blur()'
314 title='<?php xl('Click to select the desired procedure','e'); ?>'
315 style='cursor:pointer;cursor:hand' readonly />
316 <input type='hidden' name='form_proc_type' value='<?php echo $form_proc_type ?>' />
318 &nbsp;<?php xl('From','e'); ?>:
319 <input type='text' size='10' name='form_from_date' id='form_from_date'
320 value='<?php echo $form_from_date ?>'
321 title='<?php xl('yyyy-mm-dd','e'); ?>'
322 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)' />
323 <img src='../pic/show_calendar.gif' align='absbottom' width='24' height='22'
324 id='img_from_date' border='0' alt='[?]' style='cursor:pointer'
325 title='<?php xl('Click here to choose a date','e'); ?>' />
327 &nbsp;<?php xl('To','e'); ?>:
328 <input type='text' size='10' name='form_to_date' id='form_to_date'
329 value='<?php echo $form_to_date ?>'
330 title='<?php xl('yyyy-mm-dd','e'); ?>'
331 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)' />
332 <img src='../pic/show_calendar.gif' align='absbottom' width='24' height='22'
333 id='img_to_date' border='0' alt='[?]' style='cursor:pointer'
334 title='<?php xl('Click here to choose a date','e'); ?>' />
336 &nbsp;
337 <?php
338 } // end header for batch option
340 <!-- removed by jcw -- check/submit sequece too tedious. This is a quick fix -->
341 <!-- <input type='checkbox' name='form_all' value='1' <?php if ($_POST['form_all']) echo " checked"; ?>><?php xl('Include Completed','e') ?>
342 &nbsp;-->
343 <input type='submit' name='form_refresh' value=<?php xl('Refresh','e'); ?>>
344 </td>
345 </tr>
346 </table>
348 <?php if (!$form_batch || ($form_proc_type > 0 && $form_from_date)) { ?>
350 <table width='100%' cellpadding='1' cellspacing='2'>
352 <tr class='head'>
353 <td colspan='2'><?php echo $form_batch ? xl('Patient') : xl('Order'); ?></td>
354 <td colspan='4'><?php xl('Report','e'); ?></td>
355 <td colspan='7'><?php xl('Results and','e'); ?> <span class='reccolor''>
356 <?php xl('Recommendations','e'); ?></span></td>
357 </tr>
359 <tr class='head'>
360 <td><?php echo $form_batch ? xl('Name') : xl('Date'); ?></td>
361 <td><?php echo $form_batch ? xl('ID') : xl('Procedure Name'); ?></td>
362 <td><?php xl('Reported','e'); ?></td>
363 <td><?php xl('Ext Time Collected','e'); ?></td>
364 <td><?php xl('Specimen','e'); ?></td>
365 <td><?php xl('Status','e'); ?></td>
366 <td><?php xl('Code','e'); ?></td>
367 <td><?php xl('Name','e'); ?></td>
368 <td><?php xl('Abn','e'); ?></td>
369 <td><?php xl('Value','e'); ?></td>
370 <td><?php xl('Units', 'e'); ?></td>
371 <td><?php xl('Range','e'); ?></td>
372 <td><?php xl('?','e'); ?></td>
373 </tr>
375 <?php
376 $selects =
377 "po.procedure_order_id, po.date_ordered, pc.procedure_order_seq, " .
378 "pt1.procedure_type_id AS order_type_id, pc.procedure_name, " .
379 "pr.procedure_report_id, pr.date_report, pr.date_collected, pr.specimen_num, " .
380 "pr.report_status, pr.review_status";
382 $joins =
383 "JOIN procedure_order_code AS pc ON pc.procedure_order_id = po.procedure_order_id " .
384 "LEFT JOIN procedure_type AS pt1 ON pt1.lab_id = po.lab_id AND pt1.procedure_code = pc.procedure_code " .
385 "LEFT JOIN procedure_report AS pr ON pr.procedure_order_id = po.procedure_order_id AND " .
386 "pr.procedure_order_seq = pc.procedure_order_seq";
388 $orderby =
389 "po.date_ordered, po.procedure_order_id, " .
390 "pc.procedure_order_seq, pr.procedure_report_id";
392 // removed by jcw -- check/submit sequece too tedious. This is a quick fix
393 //$where = empty($_POST['form_all']) ?
394 // "( pr.report_status IS NULL OR pr.report_status = '' OR pr.report_status = 'prelim' )" :
395 // "1 = 1";
397 $where = "1 = 1";
399 if ($form_batch) {
400 $query = "SELECT po.patient_id, " .
401 "pd.fname, pd.mname, pd.lname, pd.pubpid, $selects " .
402 "FROM procedure_order AS po " .
403 "LEFT JOIN patient_data AS pd ON pd.pid = po.patient_id $joins " .
404 "WHERE pt1.procedure_type_id = '$form_proc_type' AND " .
405 "po.date_ordered >= '$form_from_date' AND po.date_ordered <= '$form_to_date' " .
406 "AND $where " .
407 "ORDER BY pd.lname, pd.fname, pd.mname, po.patient_id, $orderby";
409 else {
410 $query = "SELECT $selects " .
411 "FROM procedure_order AS po " .
412 "$joins " .
413 "WHERE po.patient_id = '$pid' AND $where " .
414 "ORDER BY $orderby";
417 $res = sqlStatement($query);
419 $lastpoid = -1;
420 $lastpcid = -1;
421 $lastprid = -1;
422 $encount = 0;
423 $lino = 0;
424 $extra_html = '';
425 $lastrcn = '';
426 $facilities = array();
428 while ($row = sqlFetchArray($res)) {
429 $order_type_id = empty($row['order_type_id' ]) ? 0 : ($row['order_type_id' ] + 0);
430 $order_id = empty($row['procedure_order_id' ]) ? 0 : ($row['procedure_order_id' ] + 0);
431 $order_seq = empty($row['procedure_order_seq']) ? 0 : ($row['procedure_order_seq'] + 0);
432 $report_id = empty($row['procedure_report_id']) ? 0 : ($row['procedure_report_id'] + 0);
433 $date_report = empty($row['date_report' ]) ? '' : substr($row['date_report'], 0, 16);
434 $date_collected = empty($row['date_collected' ]) ? '' : substr($row['date_collected'], 0, 16);
435 $specimen_num = empty($row['specimen_num' ]) ? '' : $row['specimen_num'];
436 $report_status = empty($row['report_status' ]) ? '' : $row['report_status'];
437 $review_status = empty($row['review_status' ]) ? 'received' : $row['review_status'];
439 // skip report_status = receive to make sure do not show the report before it reviewed and sign off by Physicians
440 if ($form_review) {
441 if ($review_status == "reviewed") continue;
443 else {
444 if ($review_status == "received") continue;
447 $query_test=sqlFetchArray(sqlStatement("select deleted from forms where form_id=? and formdir='procedure_order'",array($order_id)));
448 // skip the procedure that has been deleted from the encounter form
449 if($query_test['deleted']==1) continue;
451 $selects = "pt2.procedure_type, pt2.procedure_code, pt2.units AS pt2_units, " .
452 "pt2.range AS pt2_range, pt2.procedure_type_id AS procedure_type_id, " .
453 "pt2.name AS name, pt2.description, pt2.seq AS seq, " .
454 "ps.procedure_result_id, ps.result_code AS result_code, ps.result_text, ps.abnormal, ps.result, " .
455 "ps.range, ps.result_status, ps.facility, ps.comments, ps.units, ps.comments";
457 // procedure_type_id for order:
458 $pt2cond = "pt2.parent = $order_type_id AND " .
459 "(pt2.procedure_type LIKE 'res%' OR pt2.procedure_type LIKE 'rec%')";
461 // pr.procedure_report_id or 0 if none:
462 $pscond = "ps.procedure_report_id = $report_id";
464 $joincond = "ps.result_code = pt2.procedure_code";
466 // This union emulates a full outer join. The idea is to pick up all
467 // result types defined for this order type, as well as any actual
468 // results that do not have a matching result type.
469 $query = "(SELECT $selects FROM procedure_type AS pt2 " .
470 "LEFT JOIN procedure_result AS ps ON $pscond AND $joincond " .
471 "WHERE $pt2cond" .
472 ") UNION (" .
473 "SELECT $selects FROM procedure_result AS ps " .
474 "LEFT JOIN procedure_type AS pt2 ON $pt2cond AND $joincond " .
475 "WHERE $pscond) " .
476 "ORDER BY seq, name, procedure_type_id, result_code";
478 $rres = sqlStatement($query);
479 while ($rrow = sqlFetchArray($rres)) {
480 $restyp_code = empty($rrow['procedure_code' ]) ? '' : $rrow['procedure_code'];
481 $restyp_type = empty($rrow['procedure_type' ]) ? '' : $rrow['procedure_type'];
482 $restyp_name = empty($rrow['name' ]) ? '' : $rrow['name'];
483 $restyp_units = empty($rrow['pt2_units' ]) ? '' : $rrow['pt2_units'];
484 $restyp_range = empty($rrow['pt2_range' ]) ? '' : $rrow['pt2_range'];
486 $result_id = empty($rrow['procedure_result_id']) ? 0 : ($rrow['procedure_result_id'] + 0);
487 $result_code = empty($rrow['result_code' ]) ? $restyp_code : $rrow['result_code'];
488 $result_text = empty($rrow['result_text' ]) ? $restyp_name : $rrow['result_text'];
489 $result_abnormal = empty($rrow['abnormal' ]) ? '' : $rrow['abnormal'];
490 $result_result = empty($rrow['result' ]) ? '' : $rrow['result'];
491 $result_units = empty($rrow['units' ]) ? $restyp_units : $rrow['units'];
492 $result_facility = empty($rrow['facility' ]) ? '' : $rrow['facility'];
493 $result_comments = empty($rrow['comments' ]) ? '' : $rrow['comments'];
494 $result_range = empty($rrow['range' ]) ? $restyp_range : $rrow['range'];
495 $result_status = empty($rrow['result_status' ]) ? '' : $rrow['result_status'];
497 // If there is more than one line of comments, everything after that is "notes".
498 $result_notes = '';
499 $i = strpos($result_comments, "\n");
500 if ($i !== FALSE) {
501 $result_notes = trim(substr($result_comments, $i + 1));
502 $result_comments = substr($result_comments, 0, $i);
504 $result_comments = trim($result_comments);
506 if($result_facility <> "" && !in_array($result_facility, $facilities)) {
507 $facilities[] = $result_facility;
510 if ($lastpoid != $order_id || $lastpcid != $order_seq) {
511 ++$encount;
512 $lastrcn = '';
514 $bgcolor = "#" . (($encount & 1) ? "ddddff" : "ffdddd");
516 echo " <tr class='detail' bgcolor='$bgcolor'>\n";
518 // Generate first 2 columns.
519 if ($lastpoid != $order_id || $lastpcid != $order_seq) {
520 $lastprid = -1; // force report fields on first line of each procedure
521 if ($form_batch) {
522 if ($lastpoid != $order_id) {
523 $tmp = $row['lname'];
524 if ($row['fname'] || $row['mname'])
525 $tmp .= ', ' . $row['fname'] . ' ' . $row['mname'];
526 echo " <td>" . text($tmp) . "</td>\n";
527 echo " <td>" . text($row['pubpid']) . "</td>\n";
529 else {
530 echo " <td colspan='2' style='background-color:transparent'>&nbsp;</td>";
533 else {
534 if ($lastpoid != $order_id) {
535 echo " <td>" . $row['date_ordered'] . "</td>\n";
537 else {
538 echo " <td style='background-color:transparent'>&nbsp;</td>";
540 echo " <td>" . text($row['procedure_name']) . "</td>\n";
543 else {
544 echo " <td colspan='2' style='background-color:transparent'>&nbsp;</td>";
547 // If this starts a new report or a new order, generate the report form
548 // fields. In the case of a new order with no report yet, the fields will
549 // have their blank/default values, and form_line (above) will indicate a
550 // report ID of 0.
552 // TBD: Also generate default report fields and another set of results if
553 // the previous report is marked "Preliminary".
555 if ($report_id != $lastprid) {
556 echo " <td nowrap>";
557 echo "<input type='text' size='13' name='form_date_report[$lino]'" .
558 " id='form_date_report[$lino]' class='celltextfw' value='" . attr($date_report) . "' " .
559 " title='" . xl('Date and time of this report') . "'" .
560 " onkeyup='datekeyup(this,mypcc,true)' onblur='dateblur(this,mypcc,true)'" .
561 " />";
562 echo "<span class='bold' id='q_date_report[$lino]' style='cursor:pointer' " .
563 "title='" . xl('Click here to choose a date and time') . "' />?</span>";
564 echo "</td>\n";
566 echo " <td nowrap>";
567 echo "<input type='text' size='13' name='form_date_collected[$lino]'" .
568 " id='form_date_collected[$lino]'" .
569 " class='celltextfw' value='" . attr($date_collected) . "' " .
570 " title='" . xl('Date and time of sample collection') . "'" .
571 " onkeyup='datekeyup(this,mypcc,true)' onblur='dateblur(this,mypcc,true)'" .
572 " />";
573 echo "<span class='bold' id='q_date_collected[$lino]' style='cursor:pointer' " .
574 "title='" . xl('Click here to choose a date and time') . "' />?</span>";
575 echo "</td>\n";
577 echo " <td>";
578 echo "<input type='text' size='8' name='form_specimen_num[$lino]'" .
579 " class='celltext' value='" . attr($specimen_num) . "' " .
580 " title='" . xl('Specimen number/identifier') . "'" .
581 " />";
582 echo "</td>\n";
584 echo " <td>";
585 echo generate_select_list("form_report_status[$lino]", 'proc_rep_status',
586 $report_status, xl('Report Status'), ' ', 'cellselect');
587 echo "</td>\n";
589 else {
590 echo " <td colspan='4' style='background-color:transparent'>&nbsp;</td>\n";
593 echo " <td nowrap>";
594 echo "<input type='text' size='6' name='form_result_code[$lino]'" .
595 " class='celltext' value='" . attr($result_code) . "' />" .
596 "</td>\n";
598 echo " <td>" .
599 "<input type='text' size='16' name='form_result_text[$lino]'" .
600 " class='celltext' value='" . attr($result_text) . "' />";
601 "</td>\n";
603 echo " <td>";
604 echo generate_select_list("form_result_abnormal[$lino]", 'proc_res_abnormal',
605 $result_abnormal, xl('Indicates abnormality'), ' ', 'cellselect');
606 echo "</td>\n";
608 echo " <td>";
609 if ($result_units == 'bool') {
610 echo "&nbsp;--";
612 else {
613 echo "<input type='text' size='7' name='form_result_result[$lino]'" .
614 " class='celltext' value='" . attr($result_result) . "' " .
615 " />";
617 echo "</td>\n";
619 echo " <td>";
620 echo "<input type='text' size='4' name='form_result_units[$lino]'" .
621 " class='celltext' value='" . attr($result_units) . "' " .
622 " title='" . xl('Units applicable to the result value') . "'" .
623 " />";
624 echo "</td>\n";
626 echo " <td>";
627 echo "<input type='text' size='8' name='form_result_range[$lino]'" .
628 " class='celltext' value='" . attr($result_range) . "' " .
629 " title='" . xl('Reference range of results') . "'" .
630 " />";
631 // Include a hidden form field containing all IDs for this line.
632 echo "<input type='hidden' name='form_line[$lino]' " .
633 "value='$order_id:$order_seq:$report_id:$result_id' />";
634 echo "</td>\n";
636 echo " <td class='bold' style='cursor:pointer' " .
637 "onclick='extShow($lino, this)' align='center' " .
638 "title='" . xl('Click here to view/edit more details') . "'>";
639 echo "&nbsp;?&nbsp;";
640 echo "</td>\n";
642 echo " </tr>\n";
644 // Create a floating div for additional attributes of this result.
645 $extra_html .= "<div id='ext_$lino' " .
646 "style='position:absolute;width:750px;border:1px solid black;" .
647 "padding:2px;background-color:#cccccc;visibility:hidden;" .
648 "z-index:1000;left:-1000px;top:0px;font-size:9pt;'>\n" .
649 "<table width='100%'>\n" .
650 "<tr><td class='bold' align='center' colspan='2' style='padding:4pt 0 4pt 0'>" .
651 htmlspecialchars($result_text) .
652 "</td></tr>\n" .
653 "<tr><td class='bold' width='1%' nowrap>" . xlt('Status') . ": </td>" .
654 "<td>" . generate_select_list("form_result_status[$lino]", 'proc_res_status',
655 $result_status, xl('Result Status'), '') . "</td></tr>\n" .
656 "<tr><td class='bold' nowrap>" . xlt('Facility') . ": </td>" . // Ensoftek: Changed Facility to Text Area as the field procedure_result-->facility is now multi-line
657 "<td><textarea rows='3' cols='15' name='form_facility[$lino]'" .
658 " title='" . xla('Supplier facility name') . "'" .
659 " style='width:100%' />" . htmlspecialchars($result_facility) .
660 "</textarea></td></tr>\n" .
661 "<tr><td class='bold' nowrap>" . xlt('Comments') . ": </td>" .
662 "<td><textarea rows='3' cols='15' name='form_comments[$lino]'" .
663 " title='" . xla('Comments for this result or recommendation') . "'" .
664 " style='width:100%' />" . htmlspecialchars($result_comments) .
665 "</textarea></td></tr>\n" .
666 "<tr><td class='bold' nowrap>" . xlt('Notes') . ": </td>" .
667 "<td><textarea rows='4' cols='15' name='form_notes[$lino]'" .
668 " title='" . xla('Additional notes for this result or recommendation') . "'" .
669 " style='width:100%' />" . htmlspecialchars($result_notes) .
670 "</textarea></td></tr>\n" .
671 "</table>\n" .
672 "<p><center><input type='button' value='" . xla('Close') . "' " .
673 "onclick='extShow($lino, false)' /></center></p>\n".
674 "</div>";
676 $lastpoid = $order_id;
677 $lastpcid = $order_seq;
678 $lastprid = $report_id;
679 ++$lino;
683 if (!empty($facilities)) {
684 // display facility information
685 $extra_html .= "<table>";
686 $extra_html .= "<tr><th>". xl('Performing Laboratory Facility') . "</th></tr>";
687 foreach($facilities as $facilityID) {
688 foreach(explode(":", $facilityID) as $lab_facility) {
689 $facility_array = getFacilityInfo($lab_facility);
690 if($facility_array) {
691 $extra_html .=
692 "<tr><td><hr></td></tr>" .
693 "<tr><td>". htmlspecialchars($facility_array['fname']) . " " . htmlspecialchars($facility_array['lname']) . ", " . htmlspecialchars($facility_array['title']). "</td></tr>" .
694 "<tr><td>". htmlspecialchars($facility_array['organization']) . "</td></tr>" .
695 "<tr><td>". htmlspecialchars($facility_array['street']) . " " .htmlspecialchars($facility_array['city']) . " " . htmlspecialchars($facility_array['state']) . "</td></tr>" .
696 "<tr><td>". htmlspecialchars(formatPhone($facility_array['phone'])) . "</td></tr>";
700 $extra_html .= "</table>\n";
704 </table>
706 <?php
707 if ($form_review) {
708 // if user authorized for pending review.
709 if ($reviewauth) {
711 <center><p>
712 <input type='submit' name='form_submit' value='<?php xl('Sign Results','e'); ?>' />
713 </p></center>
714 <?php
716 else {
718 <center><p>
719 <input type='button' name='form_submit' value='<?php xl('Sign Results','e'); ?>' onclick="alert('<?php xl('Not authorized','e') ?>');" />
720 </p></center>
721 <?php
724 else {
726 <center><p>
727 <input type='submit' name='form_submit' value='<?php xl('Save','e'); ?>' />
728 </p></center>
729 <?php
733 <?php } ?>
735 <?php echo $extra_html; ?>
737 <script language='JavaScript'>
739 <?php if ($form_batch) { ?>
740 // Initialize calendar widgets for "from" and "to" dates.
741 Calendar.setup({inputField:'form_from_date', ifFormat:'%Y-%m-%d',
742 button:'img_from_date'});
743 Calendar.setup({inputField:'form_to_date', ifFormat:'%Y-%m-%d',
744 button:'img_to_date'});
745 <?php } ?>
747 // Initialize calendar widgets for report dates and collection dates.
748 var f = document.forms[0];
749 for (var lino = 0; f['form_line['+lino+']']; ++lino) {
750 if (f['form_date_report['+lino+']']) {
751 Calendar.setup({inputField:'form_date_report['+lino+']', ifFormat:'%Y-%m-%d %H:%M',
752 button:'q_date_report['+lino+']', showsTime:true});
753 Calendar.setup({inputField:'form_date_collected['+lino+']', ifFormat:'%Y-%m-%d %H:%M',
754 button:'q_date_collected['+lino+']', showsTime:true});
758 </script>
760 </form>
761 </body>
762 </html>