]> Softwares of Agnibho - simpleipd.git/blob - www/antibiogram.php
Bugfix
[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 $date="value='".$data->date."'";
46 $sample="value='".$data->sample."'";
47 $labid="value='".$data->labid."'";
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 $labid="";
58 $organism="";
59 }
60 else{
61 $date="";
62 $sample="";
63 $labid="";
64 $organism="";
65 }
66 $form=$form."<tr><td>Sample Date</td><td colspan='3'><input type='date' class='form-control' name='date' ".$date." form='antibiogram'></td></tr>";
67 $form=$form."<tr><td>Report Date</td><td colspan='3'><input type='date' class='form-control' name='rdate' form='antibiogram'></td></tr>";
68 $form=$form."<tr><td>Sample</td><td colspan='3'><input type='text' class='form-control' name='sample' ".$sample." form='antibiogram' required></td></tr>";
69 $form=$form."<tr><td>Lab ID</td><td colspan='3'><input type='text' class='form-control' name='labid' ".$labid." form='antibiogram'></td></tr>";
70 $form=$form."<tr><td>Organism</td><td colspan='3'><input type='text' class='form-control' name='organism' ".$organism." form='antibiogram' required></td></tr>";
71 $form=$form."<tr><th>Antibiotic</th><th>MIC</th><th>Interpretation</th>";
72 foreach($list as $k=>$v){
73 if(!empty($data)){
74 $mic="value='".$data->$k->mic."'";
75 $interpretation="value='".$data->$k->interpretation."'";
76 }
77 else{
78 $mic="";
79 $interpretation="";
80 }
81 $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>";
82 }
83 if(!empty($data)){
84 $name="value='".$data->other->name."'";
85 $mic="value='".$data->other->mic."'";
86 $interpretation="value='".$data->other->interpretation."'";
87 }
88 else{
89 $name="";
90 $mic="";
91 $interpretation="";
92 }
93 $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>";
94 if(!empty($data)){
95 $note=$data->note;
96 }
97 else{
98 $note="";
99 }
100 $form=$form."<tr><td colspan='3'><textarea class='w-100' name='note' form='antibiogram' placeholder='Notes' ".$note."></textarea></td></tr>";
101 $form=$form."<tr><td colspan='3'><button type='submit' form='antibiogram' class='btn btn-primary btn-lg'>Save</button></td></tr>";
102 $form=$form."</table>";
103 }
104 ?>
105 <!DOCTYPE html>
106 <html>
107 <head>
108 <?php include(CONFIG_LIB."head.php");?>
109 <title>Antibiogram</title>
110 </head>
111 <body>
112 <div class="container">
113 <?php include(CONFIG_LIB."top.php");?>
114 <div class="card">
115 <div class="card-body">
116 <h4 class="card-title">Add New Report</h4>
117 <?php echo $form;?>
118 <a href="attachments.php?pid=<?php echo $pid;?>&name=vitek" target="_blank">Attach a PDF copy of report</a>
119 </div>
120 </div>
121 </div>
122 <?php include(CONFIG_LIB."foot.php");?>
123 </body>
124 </html>