]> Softwares of Agnibho - simpleipd.git/blob - www/printdata.php
Bugfix
[simpleipd.git] / www / printdata.php
1 <?php
2 require(dirname(__DIR__)."/require.php");
3 $physician=[];
4 $nursing=[];
5 $reports=[];
6 $treatments="<h4>Treatment Received</h4><ol>";
7 $discharge="<h4>Advice on Discharge</h4><ol>";
8 $death="<h4>Medical Cause of Death</h4>";
9 if($_GET["pid"]){
10 $pid=$_GET["pid"];
11 $status=$db->getStatus($pid)->fetchArray()["status"];
12 $departure=$db->getDeparture($pid)->fetchArray()["departure"];
13 $info=getInfo($pid);
14 $history=viewData($db->getHistory($pid)->fetchArray()["history"]);
15 $physicianArray=$db->getAllData($pid, "physician");
16 while($c=$physicianArray->fetchArray()){
17 array_push($physician, viewData($c["data"]));
18 }
19 $nursingArray=$db->getAllData($pid, "nursing");
20 while($c=$nursingArray->fetchArray()){
21 array_push($nursing, viewData($c["data"]));
22 }
23 $reportsArray=$db->getAllData($pid, "reports");
24 while($r=$reportsArray->fetchArray()){
25 if(in_array($r["form"], ["report-as-grampos", "report-as-gramneg", "report-as-fungal"])){
26 array_push($reports, viewAntibiogram($r["data"]));
27 }
28 else{
29 array_push($reports, viewData($r["data"]));
30 }
31 }
32 $treatmentArray=$db->getDrugs($pid);
33 while($t=$treatmentArray->fetchArray()){
34 $start="";
35 if(!empty($t["start"])){
36 $start="from ".date("M j, Y", $t["start"]);
37 }
38 $end="";
39 if(!empty($t["end"])){
40 $end="till ".date("M j, Y", $t["end"]);
41 }
42 $addl="";
43 if(!empty($t["addl"])){
44 $addl="(".$t["addl"].")";
45 }
46 $treatments=$treatments."<li>".$t["drug"]." ".$t["dose"]." ".$t["route"]." ".$t["frequency"]." ".$start." ".$end." ".$addl;
47 }
48 $dischargeArray=$db->getDischargeAdvice($pid);
49 while($t=$dischargeArray->fetchArray()){
50 $discharge=$discharge."<li>".$t["drug"]." ".$t["dose"]." ".$t["route"]." ".$t["frequency"]." for ".$t["duration"]." ".$t["addl"];
51 }
52 $deathArray=$db->getDeath($pid);
53 while($d=$deathArray->fetchArray()){
54 $death=$death.viewData($d["data"]);
55 }
56 $imgs="";
57 $pdfs="";
58 foreach(glob("data/attachments/".str_replace("/", "", $pid)."-*") as $attach){
59 if(pathinfo($attach, PATHINFO_EXTENSION)=="pdf"){
60 $pdfs=$pdfs."<a href='".$attach."' target='_blank'>".pathinfo($attach, PATHINFO_BASENAME)."</a><br>";
61 }
62 else{
63 preg_match("/-([0-9]+)-/", pathinfo($attach, PATHINFO_FILENAME), $orig);
64 $imgs=$imgs."<figure><img class='w-100' src='".$attach."'><figcaption>Uploaded on: ".date("M d, Y h:i a", $orig[1])."</figcaption></figure>";
65 }
66 }
67 }
68 $treatments=$treatments."</ol>";
69 $discharge=$discharge."</ol>";
70 ?>
71 <!DOCTYPE html>
72 <html>
73 <head>
74 <?php include(CONFIG_LIB."head.php");?>
75 <title>Print Data</title>
76 </head>
77 <body>
78 <div class="container">
79 <h2><?php echo CONFIG_TITLE;?></h2>
80 <h4><?php echo "Patient Record";?></h4>
81 <?php echo $info;?>
82 <?php echo "<p><strong>Status: </strong>".$status."<br>";?>
83 <?php if(!empty($departure)) echo "(".date("M d, Y h:i a", $departure).")</p>"; ?>
84 <?php echo $history;?>
85 <?php foreach($physician as $p) echo $p;?>
86 <?php foreach($nursing as $n) echo $n;?>
87 <?php foreach($reports as $r) echo $r;?>
88 <hr>
89 <?php echo $treatments;?>
90 <hr>
91 <?php if($status=="expired"){ echo $death; } elseif($status=="discharged") { echo $discharge; }?>
92 <p class="mt-5"><small><?php echo "Data Retrieved on ".date("M d, Y H:i T", time())." from ".CONFIG_URL;?></small></p>
93 <div style="page-break-before: always" <?php if($imgs=="") echo "class='d-none'";?>>
94 <h2>Attached Images</h2>
95 <?php echo $imgs;?>
96 </div>
97 <hr>
98 <div class="d-print-none <?php if($pdfs=="") echo "d-none";?>">
99 <h2>Open Attached PDFs</h2>
100 <?php echo $pdfs;?>
101 </div>
102 </div>
103 </body>
104 </html>