]> Softwares of Agnibho - simpleipd.git/blob - www/antibiogram.php
Hardcoded fix. Plan to remove in future.
[simpleipd.git] / www / antibiogram.php
1 <?php
2 require(dirname(__DIR__)."/require.php");
3 if(checkAccess("report")!="all"){
4 header("Location: error.php");
5 exit();
6 }
7 if(!empty($_GET["pid"]) && !empty($_GET["form"])){
8 $pid=$_GET["pid"];
9 if(!empty($_POST["date"])){
10 if(!empty($_GET["id"])){
11 $db->editReport($_POST, $pid, $_GET["id"], $_POST["form"]);
12 }
13 else{
14 $db->addReport($_POST, $pid, $_POST["form"]);
15 }
16 if(!empty($_GET["req"])){
17 $db->omitRequisition($_GET["req"]);
18 }
19 if(!empty($_GET["src"]) && $_GET["src"]=="index"){
20 header("Location: index.php");
21 exit();
22 }
23 else{
24 header("Location: view.php?pid=".$_GET["pid"]);
25 exit();
26 }
27 }
28 if(isSet($_GET["id"])){
29 $data=$db->getData($pid, $_GET["id"], "reports");
30 $data=json_decode($data->fetchArray()["data"]);
31 }
32 $abx=json_decode(file_get_contents(CONFIG_WWW."autocomplete/vitek.json"));
33 if($_GET["form"]=="report-as-grampos"){
34 $list=$abx->gram_positive;
35 }
36 elseif($_GET["form"]=="report-as-gramneg"){
37 $list=$abx->gram_negative;
38 }
39 elseif($_GET["form"]=="report-as-fungal"){
40 $list=$abx->fungal;
41 }
42 $form="<form method='post' id='antibiogram'><input type='hidden' name='form' value='".$_GET["form"]."'></form>";
43 $form=$form."<table class='table'>";
44 if(!empty($data)){
45 var_dump($data->organism);
46 $date="value='".$data->date."'";
47 $sample="value='".$data->sample."'";
48 $organism="value='".$data->organism."'";
49 }
50 elseif(!empty($_GET["time"]) || !empty($_GET["sample"])){
51 if(!empty($_GET["time"])){
52 $date="value='".date("Y-m-d", $_GET["time"])."'";
53 }
54 if(!empty($_GET["sample"])){
55 $sample="value='".$_GET["sample"]."'";
56 }
57 $organism="";
58 }
59 else{
60 $date="";
61 $sample="";
62 $organism="";
63 }
64 $form=$form."<tr><td>Date</td><td colspan='3'><input type='date' class='form-control' name='date' ".$date." form='antibiogram'></td></tr>";
65 $form=$form."<tr><td>Sample</td><td colspan='3'><input type='text' class='form-control' name='sample' ".$sample." form='antibiogram' required></td></tr>";
66 $form=$form."<tr><td>Organism</td><td colspan='3'><input type='text' class='form-control' name='organism' ".$organism." form='antibiogram' required></td></tr>";
67 $form=$form."<tr><th>Antibiotic</th><th>MIC</th><th>Interpretation</th>";
68 foreach($list as $k=>$v){
69 if(!empty($data)){
70 $mic="value='".$data->$k->mic."'";
71 $interpretation="value='".$data->$k->interpretation."'";
72 }
73 else{
74 $mic="";
75 $interpretation="";
76 }
77 $form=$form."<tr><td><input type='hidden' name='".$k."[name]' value='".$v."' form='antibiogram'><input type='text' form='antibiogram' class='form-control' name='' value='".$v."' title='".$v."' data-toggle='popover' readonly></td><td><input type='text' form='antibiogram' class='form-control' name='".$k."[mic]' ".$mic."></td><td><input type='text' form='antibiogram' class='form-control abinter' name='".$k."[interpretation]' ".$interpretation." step='any'></td></tr>";
78 }
79 if(!empty($data)){
80 $name="value='".$data->other->name."'";
81 $mic="value='".$data->other->mic."'";
82 $interpretation="value='".$data->other->interpretation."'";
83 }
84 else{
85 $name="";
86 $mic="";
87 $interpretation="";
88 }
89 $form=$form."<tr><td><input type='text' form='antibiogram' class='form-control' placeholder='Any other' name='other[name]' ".$name."></td><td><input type='text' form='antibiogram' class='form-control' name='other[mic]' ".$mic."></td><td><input type='text' form='antibiogram' class='form-control abinter' step='any' name='other[interpretation]' ".$interpretation."></td></tr>";
90 if(!empty($data)){
91 $note=$data->note;
92 }
93 else{
94 $note="";
95 }
96 $form=$form."<tr><td colspan='3'><textarea class='w-100' name='note' form='antibiogram' placeholder='Notes' ".$note."></textarea></td></tr>";
97 $form=$form."<tr><td colspan='3'><button type='submit' form='antibiogram' class='btn btn-primary btn-lg'>Save</button></td></tr>";
98 $form=$form."</table>";
99 }
100 ?>
101 <!DOCTYPE html>
102 <html>
103 <head>
104 <?php include(CONFIG_LIB."head.php");?>
105 <title>Antibiogram</title>
106 </head>
107 <body>
108 <div class="container">
109 <?php include(CONFIG_LIB."top.php");?>
110 <div class="card">
111 <div class="card-body">
112 <h4 class="card-title">Add New Report</h4>
113 <?php echo $form;?>
114 <a href="attachments.php?pid=<?php echo $pid;?>&name=vitek" target="_blank">Attach a PDF copy of report</a>
115 </div>
116 </div>
117 </div>
118 <?php include(CONFIG_LIB."foot.php");?>
119 </body>
120 </html>