]> Softwares of Agnibho - simpleipd.git/commitdiff
Print data
authorAgnibho Mondal <mondal@agnibho.com>
Sat, 22 May 2021 06:36:05 +0000 (12:06 +0530)
committerAgnibho Mondal <mondal@agnibho.com>
Sat, 22 May 2021 06:36:05 +0000 (12:06 +0530)
access.json
config.php.example
lib/db.php
lib/functions.php
require.php
www/discharge.php
www/printdata.php [new file with mode: 0644]
www/view.php

index f4b2374a98692dd94ab7f356242dbcc445392d40..a64b0b63fc66a4b88f0b3ce5b41f2ba74067978a 100644 (file)
         "tech": "view",
         "clerk": "view"
     },
-
     "antibiogram": {
         "admin": "all",
         "visiting": "all",
         "lab": "all",
         "tech": "view",
         "clerk": "view"
+    },
+    "printdata": {
+        "admin": "view",
+        "visiting": "view",
+        "resident": "view",
+        "nursing": "view",
+        "lab": "view",
+        "tech": "view",
+        "clerk": "view"
     }
 }
index 7361f600123bca566ebaafab3e5ce308d4d3253b..ef401c5705ac6f7a1809738951ff951e45b9e1fe 100644 (file)
@@ -1,5 +1,6 @@
 <?php
-define("CONFIG_URL", "/");
+define("CONFIG_URL", "");
+define("CONFIG_TZ", "UTC");
 define("CONFIG_ROOT", __DIR__."/");
 define("CONFIG_WWW", CONFIG_ROOT."www/");
 define("CONFIG_LIB", CONFIG_ROOT."lib/");
index a2b9b97186b9b2f0794f79d6fae59107ca82a21c..8f7c4a85a62e6b0730d4a3603b274f4571e1b319 100644 (file)
@@ -280,6 +280,14 @@ class DB extends SQLite3 {
     $result=$stmt->execute();
     return($result);
   }
+  function getDeath($pid){
+    global $log;
+    if(!checkAccess("discharge", "dbGet")) return false;
+    $stmt=$this->prepare("SELECT data FROM death WHERE pid=:pid;");
+    $stmt->bindValue(":pid", $pid);
+    $result=$stmt->execute();
+    return($result);
+  }
   function getName($pid){
     global $log;
     if(!checkAccess("info", "dbGet")) return false;
index 7bf171e69d3025a0cabf01bcac6ee58c424d8b79..b02add6c9fb0617bde44dfcf1b188492b3ac63cc 100644 (file)
@@ -114,7 +114,7 @@ function viewData($data, $edit=null){
     else{
       $date="";
     }
-    $view=$view."<tr><th>".$description."</th><th>".$date."</th></tr>";
+    $view=$view."<tr><th class='w-25'>".$description."</th><th>".$date."</th></tr>";
     foreach($data as $field=>$value){
       if(!empty($value) && $field!="form" && $field!="date" && $field!="time"){
         if(!empty($schema->properties->$field)){
index 629b5caeadf4a26baa5aeeb5bad684690de90b75..35cf4271511fa913eaf1a965a2bd134bc7411bc4 100644 (file)
@@ -4,6 +4,7 @@ require("lib/access.php");
 require("lib/log.php");
 require("lib/db.php");
 require("lib/functions.php");
+date_default_timezone_set(CONFIG_TZ);
 session_start();
 $page=basename($_SERVER["PHP_SELF"]);
 if($page!="login.php"){
index 580b0d0975fe9d1d13b3d33a4e4cd74b2340479a..2c06977a4be46a7229048c17549a61e72c7112dd 100644 (file)
@@ -6,7 +6,7 @@ if(!empty($_GET["pid"])){
     $db->deleteAdvice($_POST["delete"]);
   }
   elseif(!empty($_POST["drug"])){
-    $db->addAdvice($pid, $_POST["drug"], $_POST["dose"], $_POST["route"], $_POST["frequency"], $_POST["duration"], $_POST["extra-note"]);
+    $db->addAdvice($pid, $_POST["drug"], $_POST["dose"], $_POST["route"], $_POST["frequency"], $_POST["duration"], $_POST["extra_note"]);
   }
   $list=$db->getAdvice($pid);
   $view="<form method='post' id='delete'></form>";
diff --git a/www/printdata.php b/www/printdata.php
new file mode 100644 (file)
index 0000000..078ed75
--- /dev/null
@@ -0,0 +1,82 @@
+<?php
+require(dirname(__DIR__)."/require.php");
+$physician=[];
+$nursing=[];
+$reports=[];
+$treatments="<h4>Treatment Received</h4><ol>";
+$discharge="<h4>Advice on Discharge</h4><ol>";
+$death="<h4>Medical Cause of Death</h4>";
+if($_GET["pid"]){
+  $pid=$_GET["pid"];
+  $status=$db->getStatus($pid)->fetchArray()["status"];
+  $info=getInfo($pid);
+  $history=viewData($db->getHistory($pid)->fetchArray()["history"]);
+  $physicianArray=$db->getAllData($pid, "physician");
+  while($c=$physicianArray->fetchArray()){
+    array_push($physician, viewData($c["data"]));
+  }
+  $nursingArray=$db->getAllData($pid, "nursing");
+  while($c=$nursingArray->fetchArray()){
+    array_push($nursing, viewData($c["data"]));
+  }
+  $reportsArray=$db->getAllData($pid, "reports");
+  while($r=$reportsArray->fetchArray()){
+    if(in_array($r["form"], ["report-as-grampos", "report-as-gramneg", "report-as-fungal"])){
+      array_push($reports, viewAntibiogram($r["data"]));
+    }
+    else{
+      array_push($reports, viewData($r["data"]));
+    }
+  }
+  $treatmentArray=$db->getDrugs($pid);
+  while($t=$treatmentArray->fetchArray()){
+    $start="";
+    if(!empty($r["start"])){
+      $start="from ".date("M j", $t["start"]);
+    }
+    $end="";
+    if(!empty($r["end"])){
+      $end="till ".date("M j", $t["end"]);
+    }
+    $addl="";
+    if(!empty($r["addl"])){
+      $addl="(".$t["addl"].")";
+    }
+    $treatments=$treatments."<li>".$t["drug"]." ".$t["dose"]." ".$t["route"]." ".$t["frequency"]." ".$end." ".$addl;
+  }
+  $dischargeArray=$db->getAdvice($pid);
+  while($t=$dischargeArray->fetchArray()){
+    $discharge=$discharge."<li>".$t["drug"]." ".$t["dose"]." ".$t["route"]." ".$t["frequency"]." for ".$t["duration"]." ".$t["addl"];
+  }
+  $deathArray=$db->getDeath($pid);
+  while($d=$deathArray->fetchArray()){
+    $death=$death.viewData($d["data"]);
+  }
+}
+$treatments=$treatments."</ol>";
+$discharge=$discharge."</ol>";
+?>
+<!DOCTYPE html>
+<html>
+  <head>
+    <?php include(CONFIG_LIB."head.php");?>
+    <title>Print Data</title>
+  </head>
+  <body>
+    <div class="container">
+      <h4><?php echo CONFIG_TITLE;?></h4>
+      <?php echo $info;?>
+      <?php echo "<p><strong>Status: </strong>".$status."</p>";?>
+      <?php echo $history;?>
+      <?php foreach($physician as $p) echo $p;?>
+      <?php foreach($nursing as $n) echo $n;?>
+      <?php foreach($reports as $r) echo $r;?>
+      <hr>
+      <?php echo $treatments;?>
+      <hr>
+      <?php if($status="expired"){ echo $death; } else { echo $discharge; }?>
+      <hr>
+      <?php echo "Retrieved on: ".date("M d, Y H:i T", time());?>
+    </div>
+  </body>
+</html>
index 572c62c922d769ae609156e964b9ac1864782c82..6361fc8d098954fb4265dcb2aaae39fc8e8051af 100644 (file)
@@ -123,7 +123,7 @@ if(isSet($_GET["pid"])){
                 </table>
               </div>
             </div>
-            <a href="#" id="showtransfer">Transfer</a>
+            <p><a href="#" id="showtransfer">Transfer</a></p>
             <form method="post" id="transfer" class="d-none">
               <div class="form-row">
                 <input type="hidden" name="shiftWard" value="true">
@@ -144,6 +144,7 @@ if(isSet($_GET["pid"])){
                 </div>
               </div>
             </form>
+            <p><a href="printdata.php?pid=<?php echo $pid;?>">Print Data</a></p>
           </div>
           <div class="tab-pane fade" id="history" role="tabpanel" aria-labelledby="history-tab">
             <?php echo $history;?>