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