]> Softwares of Agnibho - simpleipd.git/blob - www/index.php
Bugfix
[simpleipd.git] / www / index.php
1 <?php
2 require(dirname(__DIR__)."/require.php");
3 if(!empty($_POST["req"])){
4 $db->receiveRequisition($_POST["req"]);
5 }
6 $list=$db->getAdmittedPatientList();
7 $showList="";
8 if($list){
9 while($arr=$list->fetchArray()){
10 $pid=$arr["pid"];
11 $showList=$showList."<tr><td><a href='view.php?pid=".$pid."'>".$pid."</a></td><td>".$arr["ward"]."-".$arr["bed"]."</td><td>".$arr["name"]."</td><td>".$arr["diagnosis"]."</td></tr>";
12 }
13 }
14 $reqs=$db->getRequisitionList();
15 $showReqs="";
16 if($reqs){
17 while($arr=$reqs->fetchArray()){
18 $pid=$arr["pid"];
19 if(!empty($arr["form"])){
20 if($arr["form"]=="report-cs"){
21 $test="<a href='vitek.php?pid=".$pid."&form=".$arr["form"]."&req=".$arr["rowid"]."&sample=".$arr["sample"]."&time=".$arr["time"]."&src=index'>".$arr["test"]."</a>";
22 if(checkAccess("report")=="all"){
23 $toReport="<a class='btn btn-sm btn-primary' href='vitek.php?pid=".$pid."&form=".$arr["form"]."&req=".$arr["rowid"]."&sample=".$arr["sample"]."&time=".$arr["time"]."&src=index'>Add Report</a>";
24 }
25 else{
26 $toReport="";
27 }
28 }
29 else{
30 $test="<a href='report.php?pid=".$pid."&form=".$arr["form"]."&req=".$arr["rowid"]."&sample=".$arr["sample"]."&time=".$arr["time"]."&src=index'>".$arr["test"]."</a>";
31 if(checkAccess("report")=="all"){
32 $toReport="<a class='btn btn-sm btn-primary' href='vitek.php?pid=".$pid."&form=".$arr["form"]."&req=".$arr["rowid"]."&sample=".$arr["sample"]."&time=".$arr["time"]."&src=index'>Add Report</a>";
33 $toReport="<a class='btn btn-sm btn-primary' href='report.php?pid=".$pid."&form=".$arr["form"]."&req=".$arr["rowid"]."&sample=".$arr["sample"]."&time=".$arr["time"]."&src=index'>Add Report</a>";
34 }
35 else{
36 $toReport="";
37 }
38 }
39 }
40 else{
41 $test="<a href='report.php?pid=".$pid."&form=report-other&req=".$arr["rowid"]."&src=index'>".$arr["test"]."</a>";
42 if(checkAccess("report")=="all"){
43 $toReport="<a class='btn btn-sm btn-primary' href='report.php?pid=".$pid."&form=report-other&req=".$arr["rowid"]."&src=index'>Add Report</a>";
44 }
45 else{
46 $toReport="";
47 }
48 }
49 if($arr["status"]=="received"){
50 $received="<span class='badge badge-success'>Sample Received</span>";
51 }
52 elseif(checkAccess("report")=="all"){
53 $received="<button class='btn btn-sm btn-outline-danger confirm' form='sample' name='req' value='".$arr["rowid"]."'>Receive Sample</button>";
54 }
55 else{
56 $received="<span class='badge badge-warning'>Sample Not Received</span>";
57 }
58
59 $showReqs=$showReqs."<tr class='room1' data-room='".$arr["room"]."'><td>".$test."</td><td>".$arr["sample"]."</td><td>".$arr["room"]."</td><td>".date("M j", $arr["time"])."</td><td><a href='view.php?pid=".$pid."' target='_blank'>".$pid." (".$db->getWard($pid)->fetchArray()["ward"]."-".$db->getBed($pid)->fetchArray()["bed"].")</a></td></tr><tr class='room2' data-room='".$arr["room"]."'><td></td><td colspan='2'>".$arr["addl"]."</td><td>".$received."</td><td>".$toReport."</td></tr>";
60 }
61 }
62 ?>
63 <!DOCTYPE html>
64 <html>
65 <head>
66 <?php include(CONFIG_LIB."head.php");?>
67 <title>View Info</title>
68 </head>
69 <body>
70 <div class="container">
71 <?php include(CONFIG_LIB."top.php");?>
72 <div class="card">
73 <div class="card-body">
74 <h4 class="card-title">Patient List</h4>
75 <table class="table">
76 <tr><th>Patient ID</th><th>Bed Number</th><th>Name</th><th>Diagnosis</th></tr>
77 <?php echo $showList;?>
78 </table>
79 <a class="btn btn-primary btn-lg" href="admission.php">Add New Patient</a>
80 <a href="archive.php" class="btn btn-outline-secondary float-right">Archive</a>
81 </div>
82 </div>
83 <div class="card">
84 <div class="card-body">
85 <h4 class="card-title">Requisition List</h4>
86 <div id="room-filter"><button class="btn btn-secondary m-2" data-room="all">All</button></div>
87 <form id="sample" method="post"></form>
88 <table class="table table-striped">
89 <tr><th>Test Needed</th><th>Sample</th><th>Place</th><th>Date</th><th>Patient ID</th></tr>
90 <?php echo $showReqs;?>
91 </table>
92 </div>
93 </div>
94 </div>
95 <?php include(CONFIG_LIB."foot.php");?>
96 <script>
97 var roomList=new Set();
98 $(document).ready(function(){
99 $(".room1").each(function(){
100 roomList.add($(this).data("room"));
101 });
102 roomName=roomList.entries();
103 for(const name of roomName){
104 if(name[0]){
105 $("#room-filter").html($("#room-filter").html()+"<button class='btn btn-outline-secondary m-2' data-room='"+name[0]+"'>"+name[0]+"</button>");
106 }
107 }
108 $("#room-filter").on("click", "button", function(){
109 $("#room-filter button").removeClass("btn-secondary");;
110 $("#room-filter button").addClass("btn-outline-secondary");;
111 $(this).removeClass("btn-outline-secondary");
112 $(this).addClass("btn-secondary");
113 room=$(this).data("room");
114 if(room=="all"){
115 $(".room1").show();
116 $(".room2").show();
117 }
118 else{
119 $(".room1").hide();
120 $(".room2").hide();
121 $(".room1").each(function(){
122 if($(this).data("room")==room){
123 $(this).show();
124 }
125 });
126 $(".room2").each(function(){
127 if($(this).data("room")==room){
128 $(this).show();
129 }
130 });
131 }
132 });
133 });
134 </script>
135 </body>
136 </html>