/[health_html]/inc/pgSimptomi.php
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /inc/pgSimptomi.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (show annotations)
Tue Sep 25 15:38:04 2001 UTC (22 years, 7 months ago) by ravilov
Branch: MAIN
Changes since 1.3: +21 -21 lines
Major changes. Too numeruous to mention all here.

1 <?php
2 include("inc/conn.php");
3 function mySS($a, $b) { return MyCompare($a["name"], $b["name"]); }
4 function escape_quote($str) { return str_replace('"', "&quot;", $str); }
5 if (!$id) {
6 $simptomi = array();
7 $sql = "SELECT simptom_id, naziv FROM simptomi WHERE (simptom_id <> 0) AND (overview != '')";
8 $sth = $dbh->prepare($sql);
9 if (!$sth) error("Cannot prepare query: \"$sql\"");
10 if (!$sth->execute()) error("Cannot execute query: \"$sql\"");
11 while ($row = $sth->fetchrow_array()) {
12 array_push($simptomi, array("id" => $row[0]."-0", "name" => MyEscape($row[1])));
13 $sql = "SELECT alias_id, alias FROM simptomi_aliasi WHERE (simptom_id = ".$row[0].")";
14 $sth2 = $dbh->prepare($sql);
15 if (!$sth2) error("Cannot prepare query: \"$sql\"");
16 if (!$sth2->execute()) error("Cannot execute query: \"$sql\"");
17 while ($row2 = $sth2->fetchrow_array())
18 array_push($simptomi, array("id" => $row[0]."-".$row2[0], "name" => MyEscape($row2[1])));
19 $sth2->finish();
20 }
21 $sth->finish();
22 usort($simptomi, "mySS");
23 $slova = array();
24 while (list($k, $v) = each($simptomi)) {
25 $fl = $v["name"][0];
26 for ($i = 0; $i < count($slova); $i++) if ($slova[$i]["fl"] == $fl) break;
27 if (!$slova[$i]) $slova[$i] = array("fl" => $fl, "simptomi" => array());
28 array_push($slova[$i]["simptomi"], $v);
29 }
30 $tpl->assign("slova", $slova);
31 } else {
32 list($sid, $aid) = explode("-", $id);
33 $sql = "SELECT ".($aid?"simptomi_aliasi.alias":"simptomi.naziv")." FROM simptomi".($aid?", simptomi_aliasi":"")." WHERE (simptomi.simptom_id = $sid)".($aid?" AND (simptomi_aliasi.simptom_id = simptomi.simptom_id) AND (simptomi_aliasi.alias_id = $aid)":"");
34 $sth = $dbh->prepare($sql);
35 if (!$sth) error("Cannot prepare query: \"$sql\"");
36 if (!$sth->execute()) error("Cannot execute query: \"$sql\"");
37 $row = $sth->fetchrow_array();
38 $sth->finish();
39 array_push($PATH, MyUpper($row[0]));
40 $sql = "SELECT naziv, opis, overview, investigations, red_flags FROM simptomi WHERE (simptomi.simptom_id = $sid)";
41 $sth = $dbh->prepare($sql);
42 if (!$sth) error("Cannot prepare query: \"$sql\"");
43 if (!$sth->execute()) error("Cannot execute query: \"$sql\"");
44 $row = $sth->fetchrow_array();
45 $sth->finish();
46 list($snaziv, $opis, $overview, $invest, $redflags) = $row;
47 $tpl->assign("symptom", escape_quote($snaziv));
48 $tpl->assign("opis", escape_quote($opis));
49 $tpl->assign("overview", escape_quote($overview));
50 #$tpl->assign("investigations", escape_quote($invest));
51 #$tpl->assign("red_flags", escape_quote($redflags));
52 $sql = "SELECT alias FROM simptomi_aliasi WHERE (simptom_id = $sid) ORDER BY alias";
53 $sth = $dbh->prepare($sql);
54 if (!$sth) error("Cannot prepare query: \"$sql\"");
55 if (!$sth->execute()) error("Cannot execute query: \"$sql\"");
56 $aliasi = array();
57 while ($row = $sth->fetchrow_array()) array_push($aliasi, MyEscape($row[0]));
58 $sth->finish();
59 $tpl->assign("aliases", $aliasi);
60 $sql = "SELECT bolesti.bolest_id, bolesti.naziv, simptomi_bolesti.vjerojatnost FROM bolesti, simptomi_bolesti WHERE (bolesti.bolest_id = simptomi_bolesti.bolest_id) AND (simptomi_bolesti.simptom_id = $sid) ORDER BY simptomi_bolesti.vjerojatnost, bolesti.naziv";
61 $sth = $dbh->prepare($sql);
62 if (!$sth) error("Cannot prepare query: \"$sql\"");
63 if (!$sth->execute()) error("Cannot execute query: \"$sql\"");
64 $bolesti = array();
65 $uobicajeno = $povremeno = $rijetko = false;
66 while ($row = $sth->fetchrow_array()) {
67 list($bid, $naziv, $vjer) = $row;
68 if ($vjer == 1) $uobicajeno = true;
69 if ($vjer == 2) $povremeno = true;
70 if ($vjer == 3) $rijetko = true;
71 array_push($bolesti, array(
72 "id" => "$bid-0",
73 "naziv" => escape_quote($naziv),
74 "vjerojatnost" => $vjer
75 ));
76 }
77 $sth->finish();
78 $tpl->assign("bolesti", $bolesti);
79 $tpl->assign("uobicajeno", $uobicajeno);
80 $tpl->assign("povremeno", $povremeno);
81 $tpl->assign("rijetko", $rijetko);
82 $simptomi = array();
83 $tmp = array();
84 for ($i = 0; $i < count($bolesti); $i++) $tmp[$i] = array("exists" => true, "val" => 1);
85 array_push($simptomi, array("id" => "$sid-0", "name" => escape_quote($snaziv), "values" => $tmp));
86 for ($i = 0; $i < count($bolesti); $i++) {
87 if ($bolesti[$i]["vjerojatnost"] != 1) continue;
88 $sql = "SELECT simptomi.simptom_id, simptomi.naziv, simptomi.overview, sorter.value FROM simptomi, sorter WHERE (sorter.simptom_main_id = $sid) AND (sorter.simptom_id = simptomi.simptom_id) AND (sorter.bolest_id = ".$bolesti[$i]["id"].")";
89 $sth2 = $dbh->prepare($sql);
90 if (!$sth2) error("Cannot prepare query: \"$sql\"");
91 if (!$sth2->execute()) error("Cannot execute query: \"$sql\"");
92 while ($row = $sth2->fetchrow_array()) {
93 list($id, $simpt, $ov, $val) = $row;
94 $simpt = escape_quote($simpt);
95 for ($j = 0; $j < count($simptomi); $j++) if ($simptomi[$j]["name"] == $simpt) break;
96 if (!$simptomi[$j]) {
97 $tmp = array();
98 for ($k = 0; $k < count($bolesti); $k++) array_push($tmp, array("exists" => false));
99 array_push($simptomi, array("id" => $ov ? "$id-0" : "", "name" => $simpt, "values" => $tmp));
100 }
101 $simptomi[$j]["values"][$i]["exists"] = true;
102 $simptomi[$j]["values"][$i]["val"] = $val;
103 }
104 $sth2->finish();
105 }
106 $tpl->assign("simptomi", $simptomi);
107 }
108 $dbh->disconnect();
109 $tpl->assign("ID", $id);
110 ?>

  ViewVC Help
Powered by ViewVC 1.1.26