]> Softwares of Agnibho - simpleipd.git/commitdiff
IO time
authorAgnibho Mondal <mondal@agnibho.com>
Tue, 1 Jun 2021 20:32:49 +0000 (02:02 +0530)
committerAgnibho Mondal <mondal@agnibho.com>
Tue, 1 Jun 2021 20:32:49 +0000 (02:02 +0530)
lib/db.php
www/nursing.php
www/res/script.js

index 505a92c08945ab9a1903975387aecaddc3b3aa89..dd91dc88c41f6d3e371aa818e0fea06a72e1bdf2 100644 (file)
@@ -37,15 +37,16 @@ class DB extends SQLite3 {
     $query->bindValue(":pid", $post["pid"]);
     $exist=$query->execute();
     if($exist->fetchArray()[0]==0){
-      $stmt=$this->prepare("INSERT INTO patients (pid,name,age,sex,status,vp,ward,bed,data) VALUES (:pid,:name,:age,:sex,:status,:vp,:ward,:bed,:data);");
+      $stmt=$this->prepare("INSERT INTO patients (pid,name,age,sex,admission,status,vp,ward,bed,data) VALUES (:pid,:name,:age,:sex,:admission,:status,:vp,:ward,:bed,:data);");
     }
     else{
-      $stmt=$this->prepare("UPDATE patients SET name=:name,age=:age,sex=:sex,ward=:ward,bed=:bed,vp=:vp,data=:data WHERE pid=:pid;");
+      $stmt=$this->prepare("UPDATE patients SET name=:name,age=:age,sex=:sex,admission=:admission,ward=:ward,bed=:bed,vp=:vp,data=:data WHERE pid=:pid;");
     }
     $stmt->bindValue(":pid", $post["pid"]);
     $stmt->bindValue(":name", $post["name"]);
     $stmt->bindValue(":age", $post["age"]);
     $stmt->bindValue(":sex", $post["sex"]);
+    $stmt->bindValue(":admission", strtotime($post["date"]." ".$post["time"]));
     $stmt->bindValue(":status", "admitted");
     $stmt->bindValue(":ward", $post["ward"]);
     $stmt->bindValue(":bed", $post["bed"]);
index 2bafa2e0699839906dfbc950b15dfad8f2d9b168..ba95dff2d11e784b3cbe2e07ca1ed8645c87774c 100644 (file)
@@ -16,6 +16,20 @@ if(!empty($_GET["pid"])){
     header("Location: view.php?pid=".$_GET["pid"]);
     exit();
   }
+  $all=$db->getAllData($pid, "nursing");
+  $io="";
+  $lastIO="";
+  while($io=="" && $a=$all->fetchArray()){
+    $d=json_decode($a["data"]);
+    $io=$d->intake.$d->output;
+    $lastIO=$d->io_to;
+  }
+  if($lastIO==""){
+    $d=$db->getAdmission($pid)->fetchArray();
+    $dt=new DateTime();
+    $dt->setTimestamp($d["admission"]);
+    $lastIO=$dt->format("H:i");
+  }
   if(isSet($_GET["id"])){
     $form=schema2form("forms/nursing.schema.json", $pid, $_GET["id"], "nursing");
   }
@@ -31,6 +45,7 @@ if(!empty($_GET["pid"])){
     <title>Nursing Notes</title>
   </head>
   <body>
+    <input type="hidden" id="io_to_val" name="lastIO" value="<?php echo $lastIO;?>">
     <div class="container">
       <?php include(CONFIG_LIB."top.php");?>
       <?php echo getInfo($pid);?>
index 2bb62338f553183e5a2c696568547b5f3a2630ad..8f98a106cb72116b07a5e9e7a6d53cb08ea43af7 100644 (file)
@@ -33,6 +33,10 @@ $(document).ready(function(){
       $(this).val(today.getFullYear()+"-"+("0"+(today.getMonth()+1)).slice(-2)+"-"+("0"+today.getDate()).slice(-2));
     }
   });
+  if($("#io_to_val").length){
+    console.log($("#io_to_val").val());
+    $("#io_from").val($("#io_to_val").val());
+  }
   $("[type='time']").each(function(){
     if($(this).val()==""){
       $(this).val(("0"+today.getHours()).slice(-2)+":"+("0"+today.getMinutes()).slice(-2));