/[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

Diff of /inc/pgSimptomi.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by ravilov, Fri Sep 7 12:55:13 2001 UTC revision 1.5 by ravilov, Fri Sep 28 23:34:37 2001 UTC
# Line 1  Line 1 
1  <?php  <?php
2          include_once("inc/conn.php");          include("inc/conn.php");
3          function mySS($a, $b) {          function mySS($a, $b) { return MyCompare($a["name"], $b["name"]); }
4                  return MyCompare($a["name"], $b["name"]);          function escape_quote($str) { return str_replace('"', "&quot;", $str); }
         }  
         function escape_quote($str) {  
                 return str_replace('"', "&quot;", $str);  
         }  
5          if (!$id) {          if (!$id) {
6                  $simptomi = array();                  $simptomi = array();
7                  $sql = "SELECT simptom_id, naziv FROM simptomi WHERE (simptom_id <> 0)";                  $sql = "SELECT simptom_id, naziv FROM simptomi WHERE (simptom_id <> 0) AND (overview != '')";
8                  $sth = $dbh->prepare($sql);                  $sth = $dbh->prepare($sql);
9                  if (!$sth) error("Cannot prepare query: \"$sql\"");                  if (!$sth) error("Cannot prepare query: \"$sql\"");
10                  if (!$sth->execute()) error("Cannot execute query: \"$sql\"");                  if (!$sth->execute()) error("Cannot execute query: \"$sql\"");
11                  while ($row = $sth->fetchrow_array())                  while ($row = $sth->fetchrow_array()) {
12                          array_push($simptomi, array("id" => $row[0]."-0", "name" => MyEscape($row[1])));                          array_push($simptomi, array("id" => $row[0]."-0", "name" => MyEscape($row[1])));
13                  $sth->finish();                          $sql = "SELECT alias_id, alias FROM simptomi_aliasi WHERE (simptom_id = ".$row[0].")";
14                  $sql = "SELECT simptom_id, alias_id, alias FROM simptomi_aliasi";                          $sth2 = $dbh->prepare($sql);
15                  $sth = $dbh->prepare($sql);                          if (!$sth2) error("Cannot prepare query: \"$sql\"");
16                  if (!$sth) error("Cannot prepare query: \"$sql\"");                          if (!$sth2->execute()) error("Cannot execute query: \"$sql\"");
17                  if (!$sth->execute()) error("Cannot execute query: \"$sql\"");                          while ($row2 = $sth2->fetchrow_array())
18                  while ($row = $sth->fetchrow_array())                                  array_push($simptomi, array("id" => $row[0]."-".$row2[0], "name" => MyEscape($row2[1])));
19                          array_push($simptomi, array("id" => $row[0]."-".$row[1], "name" => MyEscape($row[2])));                          $sth2->finish();
20                    }
21                  $sth->finish();                  $sth->finish();
22                  usort($simptomi, "mySS");                  usort($simptomi, "mySS");
23                  $slova = array();                  $slova = array();
# Line 46  Line 43 
43                  if (!$sth->execute()) error("Cannot execute query: \"$sql\"");                  if (!$sth->execute()) error("Cannot execute query: \"$sql\"");
44                  $row = $sth->fetchrow_array();                  $row = $sth->fetchrow_array();
45                  $sth->finish();                  $sth->finish();
46                  list($naziv, $opis, $overview, $invest, $redflags) = $row;                  list($snaziv, $opis, $overview, $invest, $redflags) = $row;
47                  $tpl->assign("symptom", escape_quote($naziv));                  $tpl->assign("symptom", escape_quote($snaziv));
48                    $tpl->assign("opis", escape_quote($opis));
49                  $tpl->assign("overview", escape_quote($overview));                  $tpl->assign("overview", escape_quote($overview));
50                  # $tpl->assign("investigations", escape_quote($invest));                  #$tpl->assign("investigations", escape_quote($invest));
51                  # $tpl->assign("red_flags", escape_quote($redflags));                  #$tpl->assign("red_flags", escape_quote($redflags));
52                  $sql = "SELECT alias FROM simptomi_aliasi WHERE (simptom_id = $sid) ORDER BY alias";                  $sql = "SELECT alias FROM simptomi_aliasi WHERE (simptom_id = $sid) ORDER BY alias";
53                  $sth = $dbh->prepare($sql);                  $sth = $dbh->prepare($sql);
54                  if (!$sth) error("Cannot prepare query: \"$sql\"");                  if (!$sth) error("Cannot prepare query: \"$sql\"");
# Line 59  Line 57 
57                  while ($row = $sth->fetchrow_array()) array_push($aliasi, MyEscape($row[0]));                  while ($row = $sth->fetchrow_array()) array_push($aliasi, MyEscape($row[0]));
58                  $sth->finish();                  $sth->finish();
59                  $tpl->assign("aliases", $aliasi);                  $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";                  $sql = "SELECT bolesti.bolest_id, bolesti.is_bolest, 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);                  $sth = $dbh->prepare($sql);
62                  if (!$sth) error("Cannot prepare query: \"$sql\"");                  if (!$sth) error("Cannot prepare query: \"$sql\"");
63                  if (!$sth->execute()) error("Cannot execute query: \"$sql\"");                  if (!$sth->execute()) error("Cannot execute query: \"$sql\"");
64                  $bolesti = array();                  $bolesti = array();
65                  $uobicajeno = $povremeno = $rijetko = false;                  $uobicajeno = $povremeno = $rijetko = false;
66                  while ($row = $sth->fetchrow_array()) {                  while ($row = $sth->fetchrow_array()) {
67                          list($bid, $naziv, $vjer) = $row;                          list($bid, $is, $naziv, $vjer) = $row;
68                          if ($vjer == 1) $uobicajeno = true;                          if ($vjer == 1) $uobicajeno = true;
69                          if ($vjer == 2) $povremeno = true;                          if ($vjer == 2) $povremeno = true;
70                          if ($vjer == 3) $rijetko = true;                          if ($vjer == 3) $rijetko = true;
71                            if ($is[0] == "f" || $is[0] == "F") unset($is);
72                          array_push($bolesti, array(                          array_push($bolesti, array(
73                                  "id" => "$bid-0",                                  "id" => "$bid-0",
74                                    "is" => $is ? true : false,
75                                  "naziv" => escape_quote($naziv),                                  "naziv" => escape_quote($naziv),
76                                  "vjerojatnost" => $vjer                                  "vjerojatnost" => $vjer
77                          ));                          ));
# Line 82  Line 82 
82                  $tpl->assign("povremeno", $povremeno);                  $tpl->assign("povremeno", $povremeno);
83                  $tpl->assign("rijetko", $rijetko);                  $tpl->assign("rijetko", $rijetko);
84                  $simptomi = array();                  $simptomi = array();
85                    $tmp = array();
86                    for ($i = 0; $i < count($bolesti); $i++) $tmp[$i] = array("exists" => true, "val" => 1);
87                    array_push($simptomi, array("id" => "$sid-0", "name" => escape_quote($snaziv), "values" => $tmp));
88                  for ($i = 0; $i < count($bolesti); $i++) {                  for ($i = 0; $i < count($bolesti); $i++) {
89                          if ($bolesti[$i]["vjerojatnost"] != 1) continue;                          if ($bolesti[$i]["vjerojatnost"] != 1) continue;
90                          $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"].")";                          $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"].")";
91                          $sth2 = $dbh->prepare($sql);                          $sth2 = $dbh->prepare($sql);
92                          if (!$sth2) error("Cannot prepare query: \"$sql\"");                          if (!$sth2) error("Cannot prepare query: \"$sql\"");
93                          if (!$sth2->execute()) error("Cannot execute query: \"$sql\"");                          if (!$sth2->execute()) error("Cannot execute query: \"$sql\"");
94                          while ($row = $sth2->fetchrow_array()) {                          while ($row = $sth2->fetchrow_array()) {
95                                  list($id, $simpt, $val) = $row;                                  list($id, $simpt, $ov, $val) = $row;
96                                  $simpt = escape_quote($simpt);                                  $simpt = escape_quote($simpt);
97                                  for ($j = 0; $j < count($simptomi); $j++) if ($simptomi[$j]["name"] == $simpt) break;                                  for ($j = 0; $j < count($simptomi); $j++) if ($simptomi[$j]["name"] == $simpt) break;
98                                  if (!$simptomi[$j]) {                                  if (!$simptomi[$j]) {
99                                          $tmp = array();                                          $tmp = array();
100                                          for ($k = 0; $k < count($bolesti); $k++) array_push($tmp, array("exists" => false));                                          for ($k = 0; $k < count($bolesti); $k++) array_push($tmp, array("exists" => false));
101                                          array_push($simptomi, array("id" => "$id-0", "name" => $simpt, "values" => $tmp));                                          array_push($simptomi, array("id" => $ov ? "$id-0" : "", "name" => $simpt, "values" => $tmp));
102                                  }                                  }
103                                  $simptomi[$j]["values"][$i]["exists"] = true;                                  $simptomi[$j]["values"][$i]["exists"] = true;
104                                  $simptomi[$j]["values"][$i]["val"] = $val;                                  $simptomi[$j]["values"][$i]["val"] = $val;

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.5

  ViewVC Help
Powered by ViewVC 1.1.26