added cache clearing support for dialog.js (#411)
[openemr.git] / interface / orders / orders_results.php
blob4e7a160e2ab43fb1251ba7b67e0616f0652d312c
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/formdata.inc.php");
14 require_once("$srcdir/options.inc.php");
15 require_once("$srcdir/formatting.inc.php");
16 require_once("../orders/lab_exchange_tools.php");
18 // Indicates if we are entering in batch mode.
19 $form_batch = empty($_GET['batch']) ? 0 : 1;
21 // Indicates if we are entering in review mode.
22 $form_review = empty($_GET['review']) ? 0 : 1;
24 // Check authorization.
25 $thisauth = acl_check('patients', 'med');
26 if (!$thisauth) die(xl('Not authorized'));
28 // Check authorization for pending review.
29 $reviewauth = acl_check('patients', 'sign');
30 if ($form_review and !$reviewauth and !$thisauth) die(xl('Not authorized'));
32 // Set pid for pending review.
33 if ($_GET['set_pid'] && $form_review) {
34 require_once("$srcdir/pid.inc");
35 require_once("$srcdir/patient.inc");
36 setpid($_GET['set_pid']);
38 $result = getPatientData($pid, "*, DATE_FORMAT(DOB,'%Y-%m-%d') as DOB_YMD");
40 <script language='JavaScript'>
41 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']) . "'"; ?>);
42 </script>
43 <?php
46 if (!$form_batch && !$pid && !$form_review) die(xl('There is no current patient'));
48 function oresRawData($name, $index) {
49 $s = isset($_POST[$name][$index]) ? $_POST[$name][$index] : '';
50 return trim(strip_escape_custom($s));
53 function oresData($name, $index) {
54 $s = isset($_POST[$name][$index]) ? $_POST[$name][$index] : '';
55 return formDataCore($s, true);
58 function QuotedOrNull($fld) {
59 if (empty($fld)) return "NULL";
60 return "'$fld'";
63 $current_report_id = 0;
65 if ($_POST['form_submit'] && !empty($_POST['form_line'])) {
66 foreach ($_POST['form_line'] as $lino => $line_value) {
67 list($order_id, $order_seq, $report_id, $result_id) = explode(':', $line_value);
69 // Not using xl() here because this is for debugging only.
70 if (empty($order_id)) die("Order ID is missing from line $lino.");
72 // If report data exists for this line, save it.
73 $date_report = oresData("form_date_report", $lino);
75 if (!empty($date_report)) {
76 $sets =
77 "procedure_order_id = '$order_id', " .
78 "procedure_order_seq = '$order_seq', " .
79 "date_report = '$date_report', " .
80 "date_collected = " . QuotedOrNull(oresData("form_date_collected", $lino)) . ", " .
81 "specimen_num = '" . oresData("form_specimen_num", $lino) . "', " .
82 "report_status = '" . oresData("form_report_status", $lino) . "'";
84 // Set the review status to reviewed.
85 if ($form_review)
86 $sets .= ", review_status = 'reviewed'";
88 if ($report_id) { // Report already exists.
89 sqlStatement("UPDATE procedure_report SET $sets " .
90 "WHERE procedure_report_id = '$report_id'");
92 else { // Add new report.
93 $report_id = sqlInsert("INSERT INTO procedure_report SET $sets");
97 // If this line had report data entry fields, filled or not, set the
98 // "current report ID" which the following result data will link to.
99 if (isset($_POST["form_date_report"][$lino])) $current_report_id = $report_id;
101 // If there's a report, save corresponding results.
102 if ($current_report_id) {
103 // Comments and notes will be combined into one comments field.
104 $form_comments = oresRawData("form_comments", $lino);
105 $form_comments = str_replace("\n" ,'~' , $form_comments);
106 $form_comments = str_replace("\r" ,'' , $form_comments);
107 $form_notes = oresRawData("form_notes", $lino);
108 if ($form_notes !== '') {
109 $form_comments .= "\n" . $form_notes;
111 $sets =
112 "procedure_report_id = '$current_report_id', " .
113 "result_code = '" . oresData("form_result_code", $lino) . "', " .
114 "result_text = '" . oresData("form_result_text", $lino) . "', " .
115 "abnormal = '" . oresData("form_result_abnormal", $lino) . "', " .
116 "result = '" . oresData("form_result_result", $lino) . "', " .
117 "`range` = '" . oresData("form_result_range", $lino) . "', " .
118 "units = '" . oresData("form_result_units", $lino) . "', " .
119 "facility = '" . oresData("form_facility", $lino) . "', " .
120 "comments = '" . add_escape_custom($form_comments) . "', " .
121 "result_status = '" . oresData("form_result_status", $lino) . "'";
122 if ($result_id) { // result already exists
123 sqlStatement("UPDATE procedure_result SET $sets " .
124 "WHERE procedure_result_id = '$result_id'");
126 else { // Add new result.
127 $result_id = sqlInsert("INSERT INTO procedure_result SET $sets");
130 } // end foreach
133 <html>
135 <head>
136 <?php html_header_show();?>
138 <link rel="stylesheet" href='<?php echo $css_header ?>' type='text/css'>
139 <title><?php xl('Procedure Results','e'); ?></title>
141 <style>
143 tr.head { font-size:10pt; background-color:#cccccc; text-align:center; }
144 tr.detail { font-size:10pt; }
145 a, a:visited, a:hover { color:#0000cc; }
147 .celltext {
148 font-size:10pt;
149 font-weight:normal;
150 border-style:solid;
151 border-top-width:0px;
152 border-bottom-width:0px;
153 border-left-width:0px;
154 border-right-width:0px;
155 border-color: #aaaaaa;
156 background-color:transparent;
157 width:100%;
158 color:#0000cc;
161 .celltextfw {
162 font-size:10pt;
163 font-weight:normal;
164 border-style:solid;
165 border-top-width:0px;
166 border-bottom-width:0px;
167 border-left-width:0px;
168 border-right-width:0px;
169 border-color: #aaaaaa;
170 background-color:transparent;
171 color:#0000cc;
174 .cellselect {
175 font-size:10pt;
176 background-color:transparent;
177 color:#0000cc;
180 .reccolor {
181 color:#008800;
184 </style>
186 <style type="text/css">@import url(<?php echo $GLOBALS['webroot'] ?>/library/dynarch_calendar.css);</style>
187 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/dynarch_calendar.js"></script>
188 <?php include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?>
189 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/dynarch_calendar_setup.js"></script>
191 <script type="text/javascript" src="../../library/dialog.js?v=<?php echo $v_js_includes; ?>"></script>
192 <script type="text/javascript" src="../../library/textformat.js"></script>
194 <script language="JavaScript">
196 var mypcc = '<?php echo $GLOBALS['phone_country_code'] ?>';
198 // This invokes the find-procedure-type popup.
199 var ptvarname;
200 function sel_proc_type(varname) {
201 var f = document.forms[0];
202 if (typeof varname == 'undefined') varname = 'form_proc_type';
203 ptvarname = varname;
204 dlgopen('types.php?popup=1&order=' + f[ptvarname].value, '_blank', 800, 500);
207 // This is for callback by the find-procedure-type popup.
208 // Sets both the selected type ID and its descriptive name.
209 function set_proc_type(typeid, typename) {
210 var f = document.forms[0];
211 f[ptvarname].value = typeid;
212 f[ptvarname + '_desc'].value = typename;
215 // Helper functions.
216 function extGetX(elem) {
217 var x = 0;
218 while(elem != null) {
219 x += elem.offsetLeft;
220 elem = elem.offsetParent;
222 return x;
224 function extGetY(elem) {
225 var y = 0;
226 while(elem != null) {
227 y += elem.offsetTop;
228 elem = elem.offsetParent;
230 return y;
233 // Show or hide the "extras" div for a result.
234 var extdiv = null;
235 function extShow(lino, show) {
236 var thisdiv = document.getElementById("ext_" + lino);
237 if (extdiv) {
238 extdiv.style.visibility = 'hidden';
239 extdiv.style.left = '-1000px';
240 extdiv.style.top = '0px';
242 if (show && thisdiv != extdiv) {
243 extdiv = thisdiv;
244 var dw = window.innerWidth ? window.innerWidth - 20 : document.body.clientWidth;
245 x = dw - extdiv.offsetWidth;
246 if (x < 0) x = 0;
247 var y = extGetY(show) + show.offsetHeight;
248 extdiv.style.left = x;
249 extdiv.style.top = y;
250 extdiv.style.visibility = 'visible';
252 else {
253 extdiv = null;
257 // Helper function for validate.
258 function prDateRequired(rlino) {
259 var f = document.forms[0];
260 if (f['form_date_report['+rlino+']'].value.length < 10) {
261 alert('<?php xl('Missing report date','e') ?>');
262 if (f['form_date_report['+rlino+']'].focus)
263 f['form_date_report['+rlino+']'].focus();
264 return false;
266 return true;
269 // Validation at submit time.
270 function validate(f) {
271 var rlino = 0;
272 for (var lino = 0; f['form_line['+lino+']']; ++lino) {
273 if (f['form_date_report['+lino+']']) {
274 rlino = lino;
275 if (f['form_report_status['+rlino+']'].selectedIndex > 0) {
276 if (!prDateRequired(rlino)) return false;
279 var abnstat = f['form_result_abnormal['+lino+']'].selectedIndex > 0;
280 if (abnstat && !prDateRequired(rlino)) return false;
282 top.restoreSession();
283 return true;
286 </script>
288 </head>
290 <body class="body_top">
291 <form method='post' action='orders_results.php?batch=<?php echo $form_batch; ?>&review=<?php echo $form_review; ?>'
292 onsubmit='return validate(this)'>
294 <table>
295 <tr>
296 <td class='text'>
297 <?php
298 if ($form_batch) {
299 $form_from_date = formData('form_from_date','P',true);
300 $form_to_date = formData('form_to_date','P',true);
301 if (empty($form_to_date)) $form_to_date = $form_from_date;
302 $form_proc_type = formData('form_proc_type') + 0;
303 if (!$form_proc_type) $form_proc_type = -1;
304 $form_proc_type_desc = '';
305 if ($form_proc_type > 0) {
306 $ptrow = sqlQuery("SELECT name FROM procedure_type WHERE " .
307 "procedure_type_id = '$form_proc_type'");
308 $form_proc_type_desc = $ptrow['name'];
311 <?php xl('Procedure','e'); ?>:
312 <input type='text' size='30' name='form_proc_type_desc'
313 value='<?php echo addslashes($form_proc_type_desc) ?>'
314 onclick='sel_proc_type()' onfocus='this.blur()'
315 title='<?php xl('Click to select the desired procedure','e'); ?>'
316 style='cursor:pointer;cursor:hand' readonly />
317 <input type='hidden' name='form_proc_type' value='<?php echo $form_proc_type ?>' />
319 &nbsp;<?php xl('From','e'); ?>:
320 <input type='text' size='10' name='form_from_date' id='form_from_date'
321 value='<?php echo $form_from_date ?>'
322 title='<?php xl('yyyy-mm-dd','e'); ?>'
323 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)' />
324 <img src='../pic/show_calendar.gif' align='absbottom' width='24' height='22'
325 id='img_from_date' border='0' alt='[?]' style='cursor:pointer'
326 title='<?php xl('Click here to choose a date','e'); ?>' />
328 &nbsp;<?php xl('To','e'); ?>:
329 <input type='text' size='10' name='form_to_date' id='form_to_date'
330 value='<?php echo $form_to_date ?>'
331 title='<?php xl('yyyy-mm-dd','e'); ?>'
332 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)' />
333 <img src='../pic/show_calendar.gif' align='absbottom' width='24' height='22'
334 id='img_to_date' border='0' alt='[?]' style='cursor:pointer'
335 title='<?php xl('Click here to choose a date','e'); ?>' />
337 &nbsp;
338 <?php
339 } // end header for batch option
341 <!-- removed by jcw -- check/submit sequece too tedious. This is a quick fix -->
342 <!-- <input type='checkbox' name='form_all' value='1' <?php if ($_POST['form_all']) echo " checked"; ?>><?php xl('Include Completed','e') ?>
343 &nbsp;-->
344 <input type='submit' name='form_refresh' value=<?php xl('Refresh','e'); ?>>
345 </td>
346 </tr>
347 </table>
349 <?php if (!$form_batch || ($form_proc_type > 0 && $form_from_date)) { ?>
351 <table width='100%' cellpadding='1' cellspacing='2'>
353 <tr class='head'>
354 <td colspan='2'><?php echo $form_batch ? xl('Patient') : xl('Order'); ?></td>
355 <td colspan='4'><?php xl('Report','e'); ?></td>
356 <td colspan='7'><?php xl('Results and','e'); ?> <span class='reccolor''>
357 <?php xl('Recommendations','e'); ?></span></td>
358 </tr>
360 <tr class='head'>
361 <td><?php echo $form_batch ? xl('Name') : xl('Date'); ?></td>
362 <td><?php echo $form_batch ? xl('ID') : xl('Procedure Name'); ?></td>
363 <td><?php xl('Reported','e'); ?></td>
364 <td><?php xl('Ext Time Collected','e'); ?></td>
365 <td><?php xl('Specimen','e'); ?></td>
366 <td><?php xl('Status','e'); ?></td>
367 <td><?php xl('Code','e'); ?></td>
368 <td><?php xl('Name','e'); ?></td>
369 <td><?php xl('Abn','e'); ?></td>
370 <td><?php xl('Value','e'); ?></td>
371 <td><?php xl('Units', 'e'); ?></td>
372 <td><?php xl('Range','e'); ?></td>
373 <td><?php xl('?','e'); ?></td>
374 </tr>
376 <?php
377 $selects =
378 "po.procedure_order_id, po.date_ordered, pc.procedure_order_seq, " .
379 "pt1.procedure_type_id AS order_type_id, pc.procedure_name, " .
380 "pr.procedure_report_id, pr.date_report, pr.date_collected, pr.specimen_num, " .
381 "pr.report_status, pr.review_status";
383 $joins =
384 "JOIN procedure_order_code AS pc ON pc.procedure_order_id = po.procedure_order_id " .
385 "LEFT JOIN procedure_type AS pt1 ON pt1.lab_id = po.lab_id AND pt1.procedure_code = pc.procedure_code " .
386 "LEFT JOIN procedure_report AS pr ON pr.procedure_order_id = po.procedure_order_id AND " .
387 "pr.procedure_order_seq = pc.procedure_order_seq";
389 $orderby =
390 "po.date_ordered, po.procedure_order_id, " .
391 "pc.procedure_order_seq, pr.procedure_report_id";
393 // removed by jcw -- check/submit sequece too tedious. This is a quick fix
394 //$where = empty($_POST['form_all']) ?
395 // "( pr.report_status IS NULL OR pr.report_status = '' OR pr.report_status = 'prelim' )" :
396 // "1 = 1";
398 $where = "1 = 1";
400 if ($form_batch) {
401 $query = "SELECT po.patient_id, " .
402 "pd.fname, pd.mname, pd.lname, pd.pubpid, $selects " .
403 "FROM procedure_order AS po " .
404 "LEFT JOIN patient_data AS pd ON pd.pid = po.patient_id $joins " .
405 "WHERE pt1.procedure_type_id = '$form_proc_type' AND " .
406 "po.date_ordered >= '$form_from_date' AND po.date_ordered <= '$form_to_date' " .
407 "AND $where " .
408 "ORDER BY pd.lname, pd.fname, pd.mname, po.patient_id, $orderby";
410 else {
411 $query = "SELECT $selects " .
412 "FROM procedure_order AS po " .
413 "$joins " .
414 "WHERE po.patient_id = '$pid' AND $where " .
415 "ORDER BY $orderby";
418 $res = sqlStatement($query);
420 $lastpoid = -1;
421 $lastpcid = -1;
422 $lastprid = -1;
423 $encount = 0;
424 $lino = 0;
425 $extra_html = '';
426 $lastrcn = '';
427 $facilities = array();
429 while ($row = sqlFetchArray($res)) {
430 $order_type_id = empty($row['order_type_id' ]) ? 0 : ($row['order_type_id' ] + 0);
431 $order_id = empty($row['procedure_order_id' ]) ? 0 : ($row['procedure_order_id' ] + 0);
432 $order_seq = empty($row['procedure_order_seq']) ? 0 : ($row['procedure_order_seq'] + 0);
433 $report_id = empty($row['procedure_report_id']) ? 0 : ($row['procedure_report_id'] + 0);
434 $date_report = empty($row['date_report' ]) ? '' : substr($row['date_report'], 0, 16);
435 $date_collected = empty($row['date_collected' ]) ? '' : substr($row['date_collected'], 0, 16);
436 $specimen_num = empty($row['specimen_num' ]) ? '' : $row['specimen_num'];
437 $report_status = empty($row['report_status' ]) ? '' : $row['report_status'];
438 $review_status = empty($row['review_status' ]) ? 'received' : $row['review_status'];
440 // skip report_status = receive to make sure do not show the report before it reviewed and sign off by Physicians
441 if ($form_review) {
442 if ($review_status == "reviewed") continue;
444 else {
445 if ($review_status == "received") continue;
448 $query_test=sqlFetchArray(sqlStatement("select deleted from forms where form_id=? and formdir='procedure_order'",array($order_id)));
449 // skip the procedure that has been deleted from the encounter form
450 if($query_test['deleted']==1) continue;
452 $selects = "pt2.procedure_type, pt2.procedure_code, pt2.units AS pt2_units, " .
453 "pt2.range AS pt2_range, pt2.procedure_type_id AS procedure_type_id, " .
454 "pt2.name AS name, pt2.description, pt2.seq AS seq, " .
455 "ps.procedure_result_id, ps.result_code AS result_code, ps.result_text, ps.abnormal, ps.result, " .
456 "ps.range, ps.result_status, ps.facility, ps.comments, ps.units, ps.comments";
458 // procedure_type_id for order:
459 $pt2cond = "pt2.parent = $order_type_id AND " .
460 "(pt2.procedure_type LIKE 'res%' OR pt2.procedure_type LIKE 'rec%')";
462 // pr.procedure_report_id or 0 if none:
463 $pscond = "ps.procedure_report_id = $report_id";
465 $joincond = "ps.result_code = pt2.procedure_code";
467 // This union emulates a full outer join. The idea is to pick up all
468 // result types defined for this order type, as well as any actual
469 // results that do not have a matching result type.
470 $query = "(SELECT $selects FROM procedure_type AS pt2 " .
471 "LEFT JOIN procedure_result AS ps ON $pscond AND $joincond " .
472 "WHERE $pt2cond" .
473 ") UNION (" .
474 "SELECT $selects FROM procedure_result AS ps " .
475 "LEFT JOIN procedure_type AS pt2 ON $pt2cond AND $joincond " .
476 "WHERE $pscond) " .
477 "ORDER BY seq, name, procedure_type_id, result_code";
479 $rres = sqlStatement($query);
480 while ($rrow = sqlFetchArray($rres)) {
481 $restyp_code = empty($rrow['procedure_code' ]) ? '' : $rrow['procedure_code'];
482 $restyp_type = empty($rrow['procedure_type' ]) ? '' : $rrow['procedure_type'];
483 $restyp_name = empty($rrow['name' ]) ? '' : $rrow['name'];
484 $restyp_units = empty($rrow['pt2_units' ]) ? '' : $rrow['pt2_units'];
485 $restyp_range = empty($rrow['pt2_range' ]) ? '' : $rrow['pt2_range'];
487 $result_id = empty($rrow['procedure_result_id']) ? 0 : ($rrow['procedure_result_id'] + 0);
488 $result_code = empty($rrow['result_code' ]) ? $restyp_code : $rrow['result_code'];
489 $result_text = empty($rrow['result_text' ]) ? $restyp_name : $rrow['result_text'];
490 $result_abnormal = empty($rrow['abnormal' ]) ? '' : $rrow['abnormal'];
491 $result_result = empty($rrow['result' ]) ? '' : $rrow['result'];
492 $result_units = empty($rrow['units' ]) ? $restyp_units : $rrow['units'];
493 $result_facility = empty($rrow['facility' ]) ? '' : $rrow['facility'];
494 $result_comments = empty($rrow['comments' ]) ? '' : $rrow['comments'];
495 $result_range = empty($rrow['range' ]) ? $restyp_range : $rrow['range'];
496 $result_status = empty($rrow['result_status' ]) ? '' : $rrow['result_status'];
498 // If there is more than one line of comments, everything after that is "notes".
499 $result_notes = '';
500 $i = strpos($result_comments, "\n");
501 if ($i !== FALSE) {
502 $result_notes = trim(substr($result_comments, $i + 1));
503 $result_comments = substr($result_comments, 0, $i);
505 $result_comments = trim($result_comments);
507 if($result_facility <> "" && !in_array($result_facility, $facilities)) {
508 $facilities[] = $result_facility;
511 if ($lastpoid != $order_id || $lastpcid != $order_seq) {
512 ++$encount;
513 $lastrcn = '';
515 $bgcolor = "#" . (($encount & 1) ? "ddddff" : "ffdddd");
517 echo " <tr class='detail' bgcolor='$bgcolor'>\n";
519 // Generate first 2 columns.
520 if ($lastpoid != $order_id || $lastpcid != $order_seq) {
521 $lastprid = -1; // force report fields on first line of each procedure
522 if ($form_batch) {
523 if ($lastpoid != $order_id) {
524 $tmp = $row['lname'];
525 if ($row['fname'] || $row['mname'])
526 $tmp .= ', ' . $row['fname'] . ' ' . $row['mname'];
527 echo " <td>" . text($tmp) . "</td>\n";
528 echo " <td>" . text($row['pubpid']) . "</td>\n";
530 else {
531 echo " <td colspan='2' style='background-color:transparent'>&nbsp;</td>";
534 else {
535 if ($lastpoid != $order_id) {
536 echo " <td>" . $row['date_ordered'] . "</td>\n";
538 else {
539 echo " <td style='background-color:transparent'>&nbsp;</td>";
541 echo " <td>" . text($row['procedure_name']) . "</td>\n";
544 else {
545 echo " <td colspan='2' style='background-color:transparent'>&nbsp;</td>";
548 // If this starts a new report or a new order, generate the report form
549 // fields. In the case of a new order with no report yet, the fields will
550 // have their blank/default values, and form_line (above) will indicate a
551 // report ID of 0.
553 // TBD: Also generate default report fields and another set of results if
554 // the previous report is marked "Preliminary".
556 if ($report_id != $lastprid) {
557 echo " <td nowrap>";
558 echo "<input type='text' size='13' name='form_date_report[$lino]'" .
559 " id='form_date_report[$lino]' class='celltextfw' value='" . attr($date_report) . "' " .
560 " title='" . xl('Date and time of this report') . "'" .
561 " onkeyup='datekeyup(this,mypcc,true)' onblur='dateblur(this,mypcc,true)'" .
562 " />";
563 echo "<span class='bold' id='q_date_report[$lino]' style='cursor:pointer' " .
564 "title='" . xl('Click here to choose a date and time') . "' />?</span>";
565 echo "</td>\n";
567 echo " <td nowrap>";
568 echo "<input type='text' size='13' name='form_date_collected[$lino]'" .
569 " id='form_date_collected[$lino]'" .
570 " class='celltextfw' value='" . attr($date_collected) . "' " .
571 " title='" . xl('Date and time of sample collection') . "'" .
572 " onkeyup='datekeyup(this,mypcc,true)' onblur='dateblur(this,mypcc,true)'" .
573 " />";
574 echo "<span class='bold' id='q_date_collected[$lino]' style='cursor:pointer' " .
575 "title='" . xl('Click here to choose a date and time') . "' />?</span>";
576 echo "</td>\n";
578 echo " <td>";
579 echo "<input type='text' size='8' name='form_specimen_num[$lino]'" .
580 " class='celltext' value='" . attr($specimen_num) . "' " .
581 " title='" . xl('Specimen number/identifier') . "'" .
582 " />";
583 echo "</td>\n";
585 echo " <td>";
586 echo generate_select_list("form_report_status[$lino]", 'proc_rep_status',
587 $report_status, xl('Report Status'), ' ', 'cellselect');
588 echo "</td>\n";
590 else {
591 echo " <td colspan='4' style='background-color:transparent'>&nbsp;</td>\n";
594 echo " <td nowrap>";
595 echo "<input type='text' size='6' name='form_result_code[$lino]'" .
596 " class='celltext' value='" . attr($result_code) . "' />" .
597 "</td>\n";
599 echo " <td>" .
600 "<input type='text' size='16' name='form_result_text[$lino]'" .
601 " class='celltext' value='" . attr($result_text) . "' />";
602 "</td>\n";
604 echo " <td>";
605 echo generate_select_list("form_result_abnormal[$lino]", 'proc_res_abnormal',
606 $result_abnormal, xl('Indicates abnormality'), ' ', 'cellselect');
607 echo "</td>\n";
609 echo " <td>";
610 if ($result_units == 'bool') {
611 echo "&nbsp;--";
613 else {
614 echo "<input type='text' size='7' name='form_result_result[$lino]'" .
615 " class='celltext' value='" . attr($result_result) . "' " .
616 " />";
618 echo "</td>\n";
620 echo " <td>";
621 echo "<input type='text' size='4' name='form_result_units[$lino]'" .
622 " class='celltext' value='" . attr($result_units) . "' " .
623 " title='" . xl('Units applicable to the result value') . "'" .
624 " />";
625 echo "</td>\n";
627 echo " <td>";
628 echo "<input type='text' size='8' name='form_result_range[$lino]'" .
629 " class='celltext' value='" . attr($result_range) . "' " .
630 " title='" . xl('Reference range of results') . "'" .
631 " />";
632 // Include a hidden form field containing all IDs for this line.
633 echo "<input type='hidden' name='form_line[$lino]' " .
634 "value='$order_id:$order_seq:$report_id:$result_id' />";
635 echo "</td>\n";
637 echo " <td class='bold' style='cursor:pointer' " .
638 "onclick='extShow($lino, this)' align='center' " .
639 "title='" . xl('Click here to view/edit more details') . "'>";
640 echo "&nbsp;?&nbsp;";
641 echo "</td>\n";
643 echo " </tr>\n";
645 // Create a floating div for additional attributes of this result.
646 $extra_html .= "<div id='ext_$lino' " .
647 "style='position:absolute;width:750px;border:1px solid black;" .
648 "padding:2px;background-color:#cccccc;visibility:hidden;" .
649 "z-index:1000;left:-1000px;top:0px;font-size:9pt;'>\n" .
650 "<table width='100%'>\n" .
651 "<tr><td class='bold' align='center' colspan='2' style='padding:4pt 0 4pt 0'>" .
652 htmlspecialchars($result_text) .
653 "</td></tr>\n" .
654 "<tr><td class='bold' width='1%' nowrap>" . xlt('Status') . ": </td>" .
655 "<td>" . generate_select_list("form_result_status[$lino]", 'proc_res_status',
656 $result_status, xl('Result Status'), '') . "</td></tr>\n" .
657 "<tr><td class='bold' nowrap>" . xlt('Facility') . ": </td>" . // Ensoftek: Changed Facility to Text Area as the field procedure_result-->facility is now multi-line
658 "<td><textarea rows='3' cols='15' name='form_facility[$lino]'" .
659 " title='" . xla('Supplier facility name') . "'" .
660 " style='width:100%' />" . htmlspecialchars($result_facility) .
661 "</textarea></td></tr>\n" .
662 "<tr><td class='bold' nowrap>" . xlt('Comments') . ": </td>" .
663 "<td><textarea rows='3' cols='15' name='form_comments[$lino]'" .
664 " title='" . xla('Comments for this result or recommendation') . "'" .
665 " style='width:100%' />" . htmlspecialchars($result_comments) .
666 "</textarea></td></tr>\n" .
667 "<tr><td class='bold' nowrap>" . xlt('Notes') . ": </td>" .
668 "<td><textarea rows='4' cols='15' name='form_notes[$lino]'" .
669 " title='" . xla('Additional notes for this result or recommendation') . "'" .
670 " style='width:100%' />" . htmlspecialchars($result_notes) .
671 "</textarea></td></tr>\n" .
672 "</table>\n" .
673 "<p><center><input type='button' value='" . xla('Close') . "' " .
674 "onclick='extShow($lino, false)' /></center></p>\n".
675 "</div>";
677 $lastpoid = $order_id;
678 $lastpcid = $order_seq;
679 $lastprid = $report_id;
680 ++$lino;
684 if (!empty($facilities)) {
685 // display facility information
686 $extra_html .= "<table>";
687 $extra_html .= "<tr><th>". xl('Performing Laboratory Facility') . "</th></tr>";
688 foreach($facilities as $facilityID) {
689 foreach(explode(":", $facilityID) as $lab_facility) {
690 $facility_array = getFacilityInfo($lab_facility);
691 if($facility_array) {
692 $extra_html .=
693 "<tr><td><hr></td></tr>" .
694 "<tr><td>". htmlspecialchars($facility_array['fname']) . " " . htmlspecialchars($facility_array['lname']) . ", " . htmlspecialchars($facility_array['title']). "</td></tr>" .
695 "<tr><td>". htmlspecialchars($facility_array['organization']) . "</td></tr>" .
696 "<tr><td>". htmlspecialchars($facility_array['street']) . " " .htmlspecialchars($facility_array['city']) . " " . htmlspecialchars($facility_array['state']) . "</td></tr>" .
697 "<tr><td>". htmlspecialchars(formatPhone($facility_array['phone'])) . "</td></tr>";
701 $extra_html .= "</table>\n";
705 </table>
707 <?php
708 if ($form_review) {
709 // if user authorized for pending review.
710 if ($reviewauth) {
712 <center><p>
713 <input type='submit' name='form_submit' value='<?php xl('Sign Results','e'); ?>' />
714 </p></center>
715 <?php
717 else {
719 <center><p>
720 <input type='button' name='form_submit' value='<?php xl('Sign Results','e'); ?>' onclick="alert('<?php xl('Not authorized','e') ?>');" />
721 </p></center>
722 <?php
725 else {
727 <center><p>
728 <input type='submit' name='form_submit' value='<?php xl('Save','e'); ?>' />
729 </p></center>
730 <?php
734 <?php } ?>
736 <?php echo $extra_html; ?>
738 <script language='JavaScript'>
740 <?php if ($form_batch) { ?>
741 // Initialize calendar widgets for "from" and "to" dates.
742 Calendar.setup({inputField:'form_from_date', ifFormat:'%Y-%m-%d',
743 button:'img_from_date'});
744 Calendar.setup({inputField:'form_to_date', ifFormat:'%Y-%m-%d',
745 button:'img_to_date'});
746 <?php } ?>
748 // Initialize calendar widgets for report dates and collection dates.
749 var f = document.forms[0];
750 for (var lino = 0; f['form_line['+lino+']']; ++lino) {
751 if (f['form_date_report['+lino+']']) {
752 Calendar.setup({inputField:'form_date_report['+lino+']', ifFormat:'%Y-%m-%d %H:%M',
753 button:'q_date_report['+lino+']', showsTime:true});
754 Calendar.setup({inputField:'form_date_collected['+lino+']', ifFormat:'%Y-%m-%d %H:%M',
755 button:'q_date_collected['+lino+']', showsTime:true});
759 </script>
761 </form>
762 </body>
763 </html>