Exemple #1
0
function form30($orders, $dbh, $crd)
{
    $curdate = date("m.d.Y");
    $ordersid = "";
    $n = count($orders);
    for ($i = 1; $i < $n; $i++) {
        $ordersid .= $orders[$i];
        if ($i != $n - 1) {
            $ordersid .= ",";
        }
    }
    $results = "";
    $stmt = "select t.testname, t.id, o.id from ordtask o inner join tests t on t.id = o.testcode inner join orders ord on ord.id = o.ordersid inner join panels p on p.id = ord.panelid where ord.id in (" . $ordersid . ") order by p.priority ";
    $result = ibase_query($dbh, $stmt);
    while ($row = ibase_fetch_row($result)) {
        $restm = "select count(*) from results where ordtaskid = " . $row[2] . " and finalresult is not null and status in ('O','E') and show = 'Y'";
        $res = ibase_query($dbh, $restm);
        $n = ibase_fetch_row($res);
        $n = $n[0];
        ibase_free_result($res);
        if ($n == 1) {
            $restm = "select a.analyte, case a.analtype when 3 then replace(r.finalresult,'.',',') else coalesce(pos.inreport, r.finalresult) end, u.short, r.charlimits, r.status from results r left join units u on u.id = r.unit inner join analytes a on a.id = r.analyteid left join possibleresults pos on pos.analyte = r.analyteid  and r.rawresult = pos.result where r.ordtaskid = " . $row[2] . " and finalresult is not null order by a.sorter ";
            $res = ibase_query($dbh, $restm);
            $row = ibase_fetch_row($res);
            $ress = $row[1];
            if ($row[4] == "O") {
                $ress = "\\textbf{" . $row[1] . "}";
            }
            $row[0] = str_replace('%', '\\%', $row[0]);
            $row[0] = str_replace('β', '$\\beta$', $row[0]);
            $results .= "\\textbf{" . $row[0] . "} & " . $ress . " & " . $row[2] . " & " . $row[3] . " \\\\ \n";
            $results .= "\\hline" . "\n";
            ibase_free_result($res);
        } else {
            $row[0] = str_replace('%', '\\%', $row[0]);
            $row[0] = str_replace('β', '$\\beta$', $row[0]);
            $results .= "\\textbf{" . $row[0] . "} & & & \\\\ \n\\hline \n";
            $restm = "select a.analyte, case a.analtype when 3 then replace(r.finalresult,'.',',') else coalesce(pos.inreport, r.finalresult) end, coalesce(u.short, ' '), coalesce(r.charlimits, ' '), r.status from results r left join units u on u.id = r.unit inner join analytes a on a.id = r.analyteid left join possibleresults pos on pos.analyte = r.analyteid and pos.result = r.rawresult  where r.ordtaskid = " . $row[2] . " and finalresult is not null order by a.sorter";
            $res = ibase_query($dbh, $restm);
            while ($row = ibase_fetch_row($res)) {
                $unit = $row[2];
                //$unit = str_replace('%','\\%',$row[2]);
                //$unit = str_replace('^','\\^{}',$unit);
                $charlimits = str_replace('%', '\\%', $row[3]);
                $charlimits = str_replace('^', '\\^{}', $charlimits);
                $ress = $row[1];
                if ($row[4] == "O") {
                    $ress = "\\textbf{" . $row[1] . "}";
                }
                $results .= "~ \\footnotesize " . $row[0] . " & \\footnotesize " . $ress . " & \\footnotesize " . $unit . " & \\footnotesize " . $charlimits . " \\\\ \n";
                $results .= "\\hline" . "\n";
            }
            ibase_free_result($res);
        }
    }
    $user = "";
    $restm = "select distinct coalesce(u.fullname, '') from users u inner join results r on r.usernam = u.usernam inner join ordtask o on o.id = r.ordtaskid inner join orders ord on ord.id = o.ordersid where ord.id in (" . $ordersid . ") ";
    $res = ibase_query($dbh, $restm);
    while ($row = ibase_fetch_row($res)) {
        $user .= $row[0];
    }
    ibase_free_result($res);
    $appruser = "";
    $restm = "select distinct u.fullname from ordtask o inner join users u on u.usernam = o.appruser where o.ordersid in(" . $ordersid . ")";
    $res = ibase_query($dbh, $restm);
    while ($row = ibase_fetch_row($res)) {
        $appruser .= $row[0] . " ";
    }
    ibase_free_result($res);
    $comments = "";
    $restm = "select distinct f.comments  from foldercomments f inner join orders o on o.folderno = f.folderno where o.id in(" . $ordersid . ") and f.flag = 'Y' order by f.id";
    $res = ibase_query($dbh, $restm);
    while ($row = ibase_fetch_row($res)) {
        $comments .= "\\small \\quad " . $row[0] . "\n\n";
    }
    ibase_free_result($res);
    $biomat = find_biomat($ordersid, $dbh);
    $panelname = find_panel($ordersid, $dbh);
    $head = "\\vspace{-10px} \\flushleft \\normalsize Биоматериал: " . $biomat . "\n\n\\vspace{3px}";
    $head .= "\n\n\\vspace{1px}";
    $head .= "\\begin{center} ";
    $head .= "\\textbf{" . $panelname . "}\\end{center} \n\n\\vspace{-5px}";
    $head .= "\n\\begin{longtable}[h]{|m{160px}|>{\\centering\\arraybackslash}p{100px}|m{60px}|m{112px}|}\n\\hline\nИсследование & Результат & Единицы \\newline  измерения & Референты \\\\\n\\hline";
    $apprdate = find_apprdate($ordersid, $dbh);
    $comments = str_replace('%', '\\%', $comments);
    $end = "\\end{longtable}\n\\vspace{-15px}\n\\flushleft Комментарии:" . $comments . "\n\\vspace{-4px}\n\\flushleft Исследования проводил: " . $user . " \n\\vspace{-4px}\n\\flushleft Выпускающий врач: " . $appruser . " \n\\newline\n\\flushright Дата выдачи: " . $apprdate;
    return $head . $results . $end;
}
Exemple #2
0
            $ress = $row[1];
            if ($row[4] == "O") {
                $ress = "\\textbf{" . $row[1] . "}";
            }
            $results .= "~ \\footnotesize " . $row[0] . " & \\footnotesize " . $ress . " & \\footnotesize " . $unit . " & \\footnotesize " . $charlimits . " \\\\ \n";
            $results .= "\\hline" . "\n";
        }
        ibase_free_result($res);
    }
}
$user = getUserEnterResults($orderis, $dbh);
$appruser = getApprUser($ordersid, $dbh);
$comments = "";
$restm = "select distinct f.comments  from foldercomments f inner join orders o on o.folderno = f.folderno where o.id in(" . $ordersid . ") and f.flag = 'Y' order by f.id";
$res = ibase_query($dbh, $restm);
while ($row = ibase_fetch_row($res)) {
    $comments .= "\\small \\quad " . $row[0] . "\n\n";
}
ibase_free_result($res);
$biomat = find_biomat($ordersid, $dbh);
$panelname = find_panel($ordersid, $dbh);
$head = "\\SetWatermarkText{" . $watermark . "}\n";
$head .= "\\vspace{-10px} \\flushleft \\normalsize Биоматериал: " . $biomat . "\n\n\\vspace{3px}";
$head .= "\n\n\\vspace{1px}";
$head .= "\\begin{center} ";
$head .= "\\textbf{" . $panelname . "}\\end{center} \n\n\\vspace{-5px}";
$head .= "\n\\begin{longtable}[h]{|m{180px}|>{\\centering\\arraybackslash}p{100px}|m{60px}|m{112px}|}\n\\hline\nИсследование & Результат & Единицы \\newline  измерения & Референты \\\\\n\\hline";
$apprdate = find_apprdate($ordersid, $dbh);
$comments = str_replace('%', '\\%', $comments);
$end = "\\end{longtable}\n\\vspace{-15px}\n\\flushleft Комментарии:" . $comments . "\n\\vspace{-4px}\n\\flushleft Исследования проводил: " . $user . " \n\\vspace{-4px}\n\\flushleft Выпускающий врач: " . $appruser . " \n\\newline\n\\flushright Дата выдачи: " . $apprdate;
$response = $head . $results . $end;