This is an API for storing the documents in Apache CouchDB instead of in the disk.
[openemr.git] / interface / orders / orders_results.php
blobc58915b156404bc3432a62fe18441b671fce5891
1 <?php
2 // Copyright (C) 2010 Rod Roark <rod@sunsetsystems.com>
3 //
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
9 require_once("../globals.php");
10 require_once("$srcdir/acl.inc");
11 require_once("$srcdir/formdata.inc.php");
12 require_once("$srcdir/options.inc.php");
13 require_once("$srcdir/formatting.inc.php");
14 require_once("../orders/lab_exchange_tools.php");
16 // Indicates if we are entering in batch mode.
17 $form_batch = empty($_GET['batch']) ? 0 : 1;
19 // Indicates if we are entering in review mode.
20 $form_review = empty($_GET['review']) ? 0 : 1;
22 // Check authorization.
23 $thisauth = acl_check('patients', 'med');
24 if (!$thisauth) die(xl('Not authorized'));
26 // Check authorization for panding review.
27 $reviewauth = acl_check('patients', 'sign');
28 if ($form_review and !$reviewauth and !$thisauth) die(xl('Not authorized'));
30 // Set pid for panding review.
31 if ($_GET['set_pid'] && $form_review) {
32 require_once("$srcdir/pid.inc");
33 require_once("$srcdir/patient.inc");
34 setpid($_GET['set_pid']);
36 $result = getPatientData($pid, "*, DATE_FORMAT(DOB,'%Y-%m-%d') as DOB_YMD");
38 <script language='JavaScript'>
39 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']) . "'"; ?>);
40 parent.left_nav.setRadio(window.name, 'orp');
41 </script>
42 <?php
45 if (!$form_batch && !$pid && !$form_review) die(xl('There is no current patient'));
47 function oresData($name, $index) {
48 $s = isset($_POST[$name][$index]) ? $_POST[$name][$index] : '';
49 return formDataCore($s, true);
52 function QuotedOrNull($fld) {
53 if (empty($fld)) return "NULL";
54 return "'$fld'";
57 $current_report_id = 0;
59 if ($_POST['form_submit']) {
60 if($_POST['form_line']!='') {
61 foreach ($_POST['form_line'] as $lino => $line_value) {
62 list($order_id, $restyp_id, $report_id, $result_id) = explode(':', $line_value);
64 // Not using xl() here because these errors are for debugging only.
65 if (empty($order_id)) die("Order ID is missing from line $lino.");
66 if (empty($restyp_id)) die("Result type ID is missing from line $lino.");
68 // If report data exists for this line, save it.
69 $date_report = oresData("form_date_report", $lino);
71 if (!empty($date_report)) {
72 $sets =
73 "procedure_order_id = '$order_id', " .
74 "date_report = '$date_report', " .
75 "date_collected = " . QuotedOrNull(oresData("form_date_collected", $lino)) . ", " .
76 "specimen_num = '" . oresData("form_specimen_num", $lino) . "', " .
77 "report_status = '" . oresData("form_report_status", $lino) . "'";
79 // Set the review status to reviewed.
80 if ($form_review)
81 $sets .= ", review_status = 'reviewed'";
83 if ($report_id) { // Report already exists.
84 sqlStatement("UPDATE procedure_report SET $sets " .
85 "WHERE procedure_report_id = '$report_id'");
87 else { // Add new report.
88 $report_id = sqlInsert("INSERT INTO procedure_report SET $sets");
92 // If this line had report data entry fields, filled or not, set the
93 // "current report ID" which the following result data will link to.
94 if (isset($_POST["form_date_report"][$lino])) $current_report_id = $report_id;
96 // If there's a report, save corresponding results.
97 if ($current_report_id) {
98 $sets =
99 "procedure_report_id = '$current_report_id', " .
100 "procedure_type_id = '$restyp_id', " .
101 "abnormal = '" . oresData("form_result_abnormal", $lino) . "', " .
102 "result = '" . oresData("form_result_result", $lino) . "', " .
103 "`range` = '" . oresData("form_result_range", $lino) . "', " .
104 "facility = '" . oresData("form_facility", $lino) . "', " .
105 "comments = '" . oresData("form_comments", $lino) . "', " .
106 "result_status = '" . oresData("form_result_status", $lino) . "'";
107 if ($result_id) { // result already exists
108 sqlStatement("UPDATE procedure_result SET $sets " .
109 "WHERE procedure_result_id = '$result_id'");
111 else { // Add new result.
112 $result_id = sqlInsert("INSERT INTO procedure_result SET $sets");
116 } // end foreach
120 <html>
122 <head>
123 <?php html_header_show();?>
125 <link rel="stylesheet" href='<?php echo $css_header ?>' type='text/css'>
126 <title><?php xl('Procedure Results','e'); ?></title>
128 <style>
130 tr.head { font-size:10pt; background-color:#cccccc; text-align:center; }
131 tr.detail { font-size:10pt; }
132 a, a:visited, a:hover { color:#0000cc; }
134 .celltext {
135 font-size:10pt;
136 font-weight:normal;
137 border-style:solid;
138 border-top-width:0px;
139 border-bottom-width:0px;
140 border-left-width:0px;
141 border-right-width:0px;
142 border-color: #aaaaaa;
143 background-color:transparent;
144 width:100%;
145 color:#0000cc;
148 .celltextfw {
149 font-size:10pt;
150 font-weight:normal;
151 border-style:solid;
152 border-top-width:0px;
153 border-bottom-width:0px;
154 border-left-width:0px;
155 border-right-width:0px;
156 border-color: #aaaaaa;
157 background-color:transparent;
158 color:#0000cc;
161 .cellselect {
162 font-size:10pt;
163 background-color:transparent;
164 color:#0000cc;
167 .reccolor {
168 color:#008800;
171 </style>
173 <style type="text/css">@import url(<?php echo $GLOBALS['webroot'] ?>/library/dynarch_calendar.css);</style>
174 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/dynarch_calendar.js"></script>
175 <?php include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?>
176 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/dynarch_calendar_setup.js"></script>
178 <script type="text/javascript" src="../../library/dialog.js"></script>
179 <script type="text/javascript" src="../../library/textformat.js"></script>
181 <script language="JavaScript">
183 var mypcc = '<?php echo $GLOBALS['phone_country_code'] ?>';
185 // This invokes the find-procedure-type popup.
186 var ptvarname;
187 function sel_proc_type(varname) {
188 var f = document.forms[0];
189 if (typeof varname == 'undefined') varname = 'form_proc_type';
190 ptvarname = varname;
191 dlgopen('types.php?popup=1&order=' + f[ptvarname].value, '_blank', 800, 500);
194 // This is for callback by the find-procedure-type popup.
195 // Sets both the selected type ID and its descriptive name.
196 function set_proc_type(typeid, typename) {
197 var f = document.forms[0];
198 f[ptvarname].value = typeid;
199 f[ptvarname + '_desc'].value = typename;
202 // Helper functions.
203 function extGetX(elem) {
204 var x = 0;
205 while(elem != null) {
206 x += elem.offsetLeft;
207 elem = elem.offsetParent;
209 return x;
211 function extGetY(elem) {
212 var y = 0;
213 while(elem != null) {
214 y += elem.offsetTop;
215 elem = elem.offsetParent;
217 return y;
220 // Show or hide the "extras" div for a result.
221 var extdiv = null;
222 function extShow(lino, show) {
223 var thisdiv = document.getElementById("ext_" + lino);
224 if (extdiv) {
225 extdiv.style.visibility = 'hidden';
226 extdiv.style.left = '-1000px';
227 extdiv.style.top = '0px';
229 if (show && thisdiv != extdiv) {
230 extdiv = thisdiv;
231 var dw = window.innerWidth ? window.innerWidth - 20 : document.body.clientWidth;
232 x = dw - extdiv.offsetWidth;
233 if (x < 0) x = 0;
234 var y = extGetY(show) + show.offsetHeight;
235 extdiv.style.left = x;
236 extdiv.style.top = y;
237 extdiv.style.visibility = 'visible';
239 else {
240 extdiv = null;
244 // Helper function for validate.
245 function prDateRequired(rlino) {
246 var f = document.forms[0];
247 if (f['form_date_report['+rlino+']'].value.length < 10) {
248 alert('<?php xl('Missing report date','e') ?>');
249 if (f['form_date_report['+rlino+']'].focus)
250 f['form_date_report['+rlino+']'].focus();
251 return false;
253 return true;
256 // Validation at submit time.
257 function validate(f) {
258 var rlino = 0;
259 for (var lino = 0; f['form_line['+lino+']']; ++lino) {
260 if (f['form_date_report['+lino+']']) {
261 rlino = lino;
262 if (f['form_report_status['+rlino+']'].selectedIndex > 0) {
263 if (!prDateRequired(rlino)) return false;
266 var abnstat = f['form_result_abnormal['+lino+']'].selectedIndex > 0;
267 if (abnstat && !prDateRequired(rlino)) return false;
268 /*******************************************************************
269 var resstat = f['form_result_status['+lino+']'].selectedIndex > 0;
270 if (resstat != abnstat) {
271 alert('<?php xl('Result status or abnormality is missing','e') ?>');
272 if (f['form_result_abnormal['+lino+']'].focus)
273 f['form_result_abnormal['+lino+']'].focus();
274 return false;
276 *******************************************************************/
278 top.restoreSession();
279 return true;
282 </script>
284 </head>
286 <body class="body_top">
287 <form method='post' action='orders_results.php?batch=<?php echo $form_batch; ?>&review=<?php echo $form_review; ?>'
288 onsubmit='return validate(this)'>
290 <table>
291 <tr>
292 <td class='text'>
293 <?php
294 if ($form_batch) {
295 $form_from_date = formData('form_from_date','P',true);
296 $form_to_date = formData('form_to_date','P',true);
297 if (empty($form_to_date)) $form_to_date = $form_from_date;
298 $form_proc_type = formData('form_proc_type') + 0;
299 if (!$form_proc_type) $form_proc_type = -1;
300 $form_proc_type_desc = '';
301 if ($form_proc_type > 0) {
302 $ptrow = sqlQuery("SELECT name FROM procedure_type WHERE " .
303 "procedure_type_id = '$form_proc_type'");
304 $form_proc_type_desc = $ptrow['name'];
307 <?php xl('Procedure','e'); ?>:
308 <input type='text' size='30' name='form_proc_type_desc'
309 value='<?php echo addslashes($form_proc_type_desc) ?>'
310 onclick='sel_proc_type()' onfocus='this.blur()'
311 title='<?php xl('Click to select the desired procedure','e'); ?>'
312 style='cursor:pointer;cursor:hand' readonly />
313 <input type='hidden' name='form_proc_type' value='<?php echo $form_proc_type ?>' />
315 &nbsp;<?php xl('From','e'); ?>:
316 <input type='text' size='10' name='form_from_date' id='form_from_date'
317 value='<?php echo $form_from_date ?>'
318 title='<?php xl('yyyy-mm-dd','e'); ?>'
319 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)' />
320 <img src='../pic/show_calendar.gif' align='absbottom' width='24' height='22'
321 id='img_from_date' border='0' alt='[?]' style='cursor:pointer'
322 title='<?php xl('Click here to choose a date','e'); ?>' />
324 &nbsp;<?php xl('To','e'); ?>:
325 <input type='text' size='10' name='form_to_date' id='form_to_date'
326 value='<?php echo $form_to_date ?>'
327 title='<?php xl('yyyy-mm-dd','e'); ?>'
328 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)' />
329 <img src='../pic/show_calendar.gif' align='absbottom' width='24' height='22'
330 id='img_to_date' border='0' alt='[?]' style='cursor:pointer'
331 title='<?php xl('Click here to choose a date','e'); ?>' />
333 &nbsp;
334 <?php
335 } // end header for batch option
337 <!-- removed by jcw -- check/submit sequece too tedious. This is a quick fix -->
338 <!-- <input type='checkbox' name='form_all' value='1' <?php if ($_POST['form_all']) echo " checked"; ?>><?php xl('Include Completed','e') ?>
339 &nbsp;-->
340 <input type='submit' name='form_refresh' value=<?php xl('Refresh','e'); ?>>
341 </td>
342 </tr>
343 </table>
345 <?php if (!$form_batch || ($form_proc_type > 0 && $form_from_date)) { ?>
347 <table width='100%' cellpadding='1' cellspacing='2'>
349 <tr class='head'>
350 <td colspan='2'><?php echo $form_batch ? xl('Patient') : xl('Order'); ?></td>
351 <td colspan='4'><?php xl('Report','e'); ?></td>
352 <td colspan='6'><?php xl('Results and','e'); ?> <span class='reccolor''>
353 <?php xl('Recommendations','e'); ?></span></td>
354 </tr>
356 <tr class='head'>
357 <td><?php echo $form_batch ? xl('Name') : xl('Date'); ?></td>
358 <td><?php echo $form_batch ? xl('ID') : xl('Name'); ?></td>
359 <td><?php xl('Reported','e'); ?></td>
360 <td><?php xl('Ext Time Collected','e'); ?></td>
361 <td><?php xl('Specimen','e'); ?></td>
362 <td><?php xl('Status','e'); ?></td>
363 <td><?php xl('Group','e'); ?></td>
364 <td><?php xl('Name (click for more)','e'); ?></td>
365 <td><?php xl('Abn','e'); ?></td>
366 <td><?php xl('Value','e'); ?></td>
367 <td><?php xl('Units', 'e'); ?></td>
368 <td><?php xl('Range','e'); ?></td>
369 </tr>
371 <?php
372 $selects =
373 "po.procedure_order_id, po.date_ordered, " .
374 "po.procedure_type_id AS order_type_id, pt1.name AS procedure_name, " .
375 "ptrc.name AS result_category_name, " .
376 "pt2.procedure_type AS result_type, " .
377 "pt2.procedure_type_id AS result_type_id, pt2.name AS result_name, " .
378 "pt2.units AS result_def_units, pt2.range AS result_def_range, " .
379 "pt2.description AS result_description, lo.title AS units_name, " .
380 "pr.procedure_report_id, pr.date_report, pr.date_collected, pr.specimen_num, pr.report_status, pr.review_status, " .
381 "ps.procedure_result_id, ps.abnormal, ps.result, ps.range, ps.result_status, " .
382 "ps.facility, ps.comments, ps.units ";
384 // This join syntax means that results must all be at the same "level".
385 // Either there is one result the same as the order, or all results are
386 // direct children of the order, or all results are grandchildren of the
387 // order. No other arrangements are allowed.
389 $joins =
390 "LEFT JOIN procedure_type AS pt1 ON pt1.procedure_type_id = po.procedure_type_id " .
391 // ptrc is an optional result category just under the order type
392 "LEFT JOIN procedure_type AS ptrc ON ptrc.parent = po.procedure_type_id " .
393 "AND ptrc.procedure_type LIKE 'grp%' " .
394 // pt2 is a result or recommendation type the same as or just under the order type
395 "LEFT JOIN procedure_type AS pt2 ON " .
396 "( ( ptrc.procedure_type_id IS NULL AND ( pt2.parent = po.procedure_type_id " .
397 "OR pt2.procedure_type_id = po.procedure_type_id ) ) OR " .
398 "( ptrc.procedure_type_id IS NOT NULL AND pt2.parent = ptrc.procedure_type_id ) " .
399 ") AND ( pt2.procedure_type LIKE 'res%' OR pt2.procedure_type LIKE 'rec%' ) " .
401 "LEFT JOIN list_options AS lo ON list_id = 'proc_unit' AND option_id = pt2.units " .
402 "LEFT JOIN procedure_report AS pr ON pr.procedure_order_id = po.procedure_order_id " .
403 "LEFT JOIN procedure_result AS ps ON ps.procedure_report_id = pr.procedure_report_id " .
404 "AND ps.procedure_type_id = pt2.procedure_type_id";
406 $orderby =
407 "po.date_ordered, po.procedure_order_id, pr.procedure_report_id, " .
408 "ptrc.seq, ptrc.name, ptrc.procedure_type_id, " .
409 "pt2.seq, pt2.name, pt2.procedure_type_id";
411 // removed by jcw -- check/submit sequece too tedious. This is a quick fix
412 //$where = empty($_POST['form_all']) ?
413 // "( pr.report_status IS NULL OR pr.report_status = '' OR pr.report_status = 'prelim' )" :
414 // "1 = 1";
416 $where = "1 = 1";
418 if ($form_batch) {
419 $res = sqlStatement("SELECT po.patient_id, " .
420 "pd.fname, pd.mname, pd.lname, pd.pubpid, $selects " .
421 "FROM procedure_order AS po " .
422 "LEFT JOIN patient_data AS pd ON pd.pid = po.patient_id $joins " .
423 "WHERE po.procedure_type_id = '$form_proc_type' AND " .
424 "po.date_ordered >= '$form_from_date' AND po.date_ordered <= '$form_to_date' " .
425 "AND $where " .
426 "ORDER BY pd.lname, pd.fname, pd.mname, po.patient_id, $orderby");
428 else {
429 $res = sqlStatement("SELECT $selects " .
430 "FROM procedure_order AS po $joins " .
431 "WHERE po.patient_id = '$pid' AND $where " .
432 "ORDER BY $orderby");
435 $lastpoid = -1;
436 $lastprid = -1;
437 $encount = 0;
438 $lino = 0;
439 $extra_html = '';
440 $lastrcn = '';
441 $facilities = array();
443 while ($row = sqlFetchArray($res)) {
444 $order_id = empty($row['procedure_order_id' ]) ? 0 : ($row['procedure_order_id' ] + 0);
445 $restyp_id = empty($row['result_type_id']) ? 0 : ($row['result_type_id' ] + 0);
446 $report_id = empty($row['procedure_report_id']) ? 0 : ($row['procedure_report_id'] + 0);
447 $result_id = empty($row['procedure_result_id']) ? 0 : ($row['procedure_result_id'] + 0);
449 /*******************************************************************
450 $result_name = '';
451 if (!empty($row['result_category_name'])) $result_name = $row['result_category_name'] . ' / ';
452 if (!empty($row['result_name'])) $result_name .= $row['result_name'];
453 *******************************************************************/
454 $result_category_name = empty($row['result_category_name']) ? '--' : $row['result_category_name'];
455 $result_name = empty($row['result_name' ]) ? '' : $row['result_name'];
457 $date_report = empty($row['date_report' ]) ? '' : $row['date_report'];
458 $date_collected = empty($row['date_collected' ]) ? '' : substr($row['date_collected'], 0, 16);
459 $specimen_num = empty($row['specimen_num' ]) ? '' : $row['specimen_num'];
460 $report_status = empty($row['report_status' ]) ? '' : $row['report_status'];
461 $result_abnormal = empty($row['abnormal' ]) ? '' : $row['abnormal'];
462 $result_result = empty($row['result' ]) ? '' : $row['result'];
463 $result_unit = empty($row['units' ]) ? '' : $row['units'];
464 $facility = empty($row['facility' ]) ? '' : $row['facility'];
465 $comments = empty($row['comments' ]) ? '' : $row['comments'];
466 $result_range = empty($row['range' ]) ? $row['result_def_range'] : $row['range'];
467 $result_status = empty($row['result_status' ]) ? '' : $row['result_status'];
468 $result_def_units = empty($row['result_def_units']) ? '' : $row['result_def_units'];
469 $units_name = empty($row['units_name' ]) ? xl('Units not defined') : $row['units_name'];
471 $review_status = empty($row['review_status' ]) ? 'received' : $row['review_status'];
473 //echo $facility. "<br>";
474 if($facility <> "" && !in_array($facility, $facilities))
476 $facilities[] = $facility;
479 // skip report_status = receive to make sure do not show the report before it reviewed and sign off by Physicians
480 if ($form_review) {
481 if ($review_status == "reviewed") continue;
483 else {
484 if ($review_status == "received") continue;
487 if ($lastpoid != $order_id) {
488 ++$encount;
489 $lastrcn = '';
491 $bgcolor = "#" . (($encount & 1) ? "ddddff" : "ffdddd");
493 echo " <tr class='detail' bgcolor='$bgcolor'>\n";
495 // If this starts a new order, display its date and procedure name,
496 // otherwise empty space.
498 if ($lastpoid != $order_id) {
499 if ($form_batch) {
500 $tmp = $row['lname'];
501 if ($row['fname'] || $row['mname'])
502 $tmp .= ', ' . $row['fname'] . ' ' . $row['mname'];
503 echo " <td>" . htmlentities($tmp) . "</td>\n";
504 echo " <td>" . htmlentities($row['pubpid']) . "</td>\n";
506 else {
507 echo " <td>" . $row['date_ordered'] . "</td>\n";
508 echo " <td>" . htmlentities($row['procedure_name']) . "</td>\n";
510 $lastprid = -1; // force report fields on first line of each order
511 } else {
512 echo " <td colspan='2' style='background-color:#94d6e7'>&nbsp;";
514 // Include a hidden form field containing all IDs for this line.
515 echo "<input type='hidden' name='form_line[$lino]' value='$order_id:$restyp_id:$report_id:$result_id' />";
516 echo "</td>\n";
518 // If this starts a new report or a new order, generate the report form
519 // fields. In the case of a new order with no report yet, the fields will
520 // have their blank/default values, and form_line (above) will indicate a
521 // report ID of 0.
523 // TBD: Also generate default report fields and another set of results if
524 // the previous report is marked "Preliminary".
526 if ($report_id != $lastprid) {
527 echo " <td nowrap>";
528 echo "<input type='text' size='8' name='form_date_report[$lino]'" .
529 " id='form_date_report[$lino]' class='celltextfw' value='$date_report' " .
530 " title='" . xl('Date of this report') . "'" .
531 " onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)'" .
532 " />";
533 echo "<span class='bold' id='q_date_report[$lino]' style='cursor:pointer' " .
534 "title='" . xl('Click here to choose a date') . "' />?</span>";
535 echo "</td>\n";
537 echo " <td nowrap>";
538 echo "<input type='text' size='13' name='form_date_collected[$lino]'" .
539 " id='form_date_collected[$lino]'" .
540 " class='celltextfw' value='$date_collected' " .
541 " title='" . xl('Date and time of sample collection') . "'" .
542 " onkeyup='datekeyup(this,mypcc,true)' onblur='dateblur(this,mypcc,true)'" .
543 " />";
544 echo "<span class='bold' id='q_date_collected[$lino]' style='cursor:pointer' " .
545 "title='" . xl('Click here to choose a date and time') . "' />?</span>";
546 echo "</td>\n";
548 echo " <td>";
549 echo "<input type='text' size='8' name='form_specimen_num[$lino]'" .
550 " class='celltext' value='$specimen_num' " .
551 " title='" . xl('Specimen number/identifier') . "'" .
552 " />";
553 echo "</td>\n";
555 echo " <td>";
556 echo generate_select_list("form_report_status[$lino]", 'proc_rep_status',
557 $report_status, xl('Report Status'), ' ', 'cellselect');
558 echo "</td>\n";
560 else {
561 echo " <td colspan='4' style='background-color:#94d6e7'>&nbsp;</td>\n";
564 if ($result_category_name != $lastrcn) {
565 echo " <td>";
566 echo htmlentities($result_category_name);
567 echo "</td>\n";
568 $lastrcn = $result_category_name;
570 else {
571 echo " <td style='background-color:#94d6e7'>&nbsp;</td>\n";
574 echo " <td title='" . addslashes($row['result_description']) . "'";
575 if ($row['result_type'] == 'rec') echo " class='reccolor'";
576 echo " style='cursor:pointer' onclick='extShow($lino, this)'>" .
577 htmlentities($result_name) . "</td>\n";
579 echo " <td>";
580 echo generate_select_list("form_result_abnormal[$lino]", 'proc_res_abnormal',
581 $result_abnormal, xl('Indicates abnormality'), ' ', 'cellselect');
582 echo "</td>\n";
584 echo " <td>";
585 if ($result_def_units == 'bool') {
586 // echo generate_select_list("form_result_result[$lino]", 'proc_res_bool',
587 // $result_result, $units_name, ' ', 'cellselect');
588 echo "&nbsp;--";
590 else {
591 echo "<input type='text' size='4' name='form_result_result[$lino]'" .
592 " class='celltext' value='$result_result' " .
593 " title='" . addslashes($units_name) . "'" .
594 " />";
596 echo "</td>\n";
598 echo "<td>";
599 echo $result_unit;
600 echo "</td>";
603 echo " <td>";
604 echo "<input type='text' size='8' name='form_result_range[$lino]'" .
605 " class='celltext' value='$result_range' " .
606 " title='" . xl('Reference range of results') . "'" .
607 " />";
608 echo "</td>\n";
610 echo " </tr>\n";
612 // Create a floating div for additional attributes of this result.
613 $extra_html .= "<div id='ext_$lino' " .
614 "style='position:absolute;width:500px;border:1px solid black;" .
615 "padding:2px;background-color:#cccccc;visibility:hidden;" .
616 "z-index:1000;left:-1000px;top:0px;font-size:9pt;'>\n" .
617 "<table width='100%'>\n" .
618 "<tr><td class='bold' align='center' colspan='2' style='padding:4pt 0 4pt 0'>" .
619 // xl('Additional Attributes') .
620 htmlspecialchars($result_name) .
621 "</td></tr>\n" .
622 "<tr><td class='bold' width='1%' nowrap>" . xl('Status') . ": </td>" .
623 "<td>" . generate_select_list("form_result_status[$lino]", 'proc_res_status',
624 $result_status, xl('Result Status'), '') . "</td></tr>\n" .
625 "<tr><td class='bold' nowrap>" . xl('Facility') . ": </td>" .
626 "<td><input type='text' size='15' name='form_facility[$lino]'" .
627 " value='$facility' " .
628 " title='" . xl('Supplier facility name') . "'" .
629 " style='width:100%' /></td></tr>\n" .
630 "<tr><td class='bold' nowrap>" . xl('Comments') . ": </td>" .
631 "<td><textarea rows='3' cols='15' name='form_comments[$lino]'" .
632 " title='" . xl('Comments for this result or recommendation') . "'" .
633 " style='width:100%' />" . htmlspecialchars($comments) .
634 "</textarea></td></tr>\n" .
635 "</table>\n" .
636 "<p><center><input type='button' value='" . xl('Close') . "' " .
637 "onclick='extShow($lino, false)' /></center></p>\n".
638 "</div>";
640 $lastpoid = $order_id;
641 $lastprid = $report_id;
642 ++$lino;
645 // display facility information
646 $extra_html .= "<table>";
647 $extra_html .= "<th>". xl('Performing Laboratory Facility') . "</th>";
648 foreach($facilities as $facilityID)
650 foreach(explode(":", $facilityID) as $lab_facility)
653 $facility_array = getFacilityInfo($lab_facility);
654 if($facility_array)
656 $extra_html .=
657 "<tr><td><hr></td></tr>" .
658 "<tr><td>". htmlspecialchars($facility_array['fname']) . " " . htmlspecialchars($facility_array['lname']) . ", " . htmlspecialchars($facility_array['title']). "</td></tr>" .
659 "<tr><td>". htmlspecialchars($facility_array['organization']) . "</td></tr>" .
660 "<tr><td>". htmlspecialchars($facility_array['street']) . " " .htmlspecialchars($facility_array['city']) . " " . htmlspecialchars($facility_array['state']) . "</td></tr>" .
661 "<tr><td>". htmlspecialchars(formatPhone($facility_array['phone'])) . "</td></tr>";
666 $extra_html .= "</table>\n";
668 </table>
670 <?php
671 if ($form_review) {
672 // if user authorised for panding review.
673 if ($reviewauth) {
675 <center><p>
676 <input type='submit' name='form_submit' value='<?php xl('Sign Results','e'); ?>' />
677 </p></center>
678 <?php
680 else {
682 <center><p>
683 <input type='button' name='form_submit' value='<?php xl('Sign Results','e'); ?>' onclick="alert('<?php xl('Not authorized','e') ?>');" />
684 </p></center>
685 <?php
688 else {
690 <center><p>
691 <input type='submit' name='form_submit' value='<?php xl('Save','e'); ?>' />
692 </p></center>
693 <?php
697 <?php } ?>
699 <?php echo $extra_html; ?>
701 <script language='JavaScript'>
703 <?php if ($form_batch) { ?>
704 // Initialize calendar widgets for "from" and "to" dates.
705 Calendar.setup({inputField:'form_from_date', ifFormat:'%Y-%m-%d',
706 button:'img_from_date'});
707 Calendar.setup({inputField:'form_to_date', ifFormat:'%Y-%m-%d',
708 button:'img_to_date'});
709 <?php } ?>
711 // Initialize calendar widgets for report dates and collection dates.
712 var f = document.forms[0];
713 for (var lino = 0; f['form_line['+lino+']']; ++lino) {
714 if (f['form_date_report['+lino+']']) {
715 Calendar.setup({inputField:'form_date_report['+lino+']', ifFormat:'%Y-%m-%d',
716 button:'q_date_report['+lino+']'});
717 Calendar.setup({inputField:'form_date_collected['+lino+']', ifFormat:'%Y-%m-%d %H:%M',
718 button:'q_date_collected['+lino+']', showsTime:true});
722 </script>
724 </form>
725 </body>
726 </html>