/[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.3 - (show annotations)
Wed Sep 19 12:23:57 2001 UTC (22 years, 8 months ago) by ravilov
Branch: MAIN
Changes since 1.2: +3 -2 lines
Added thefilez/med/ (PLIVAmed site). Other major changes...

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