From: Agnibho Mondal Date: Thu, 10 Jun 2021 20:34:05 +0000 (+0530) Subject: Added General Measures X-Git-Url: https://code.agnibho.com/repo?a=commitdiff_plain;h=eed6459c83c6ce924d960a6908d2184d2d33d027;p=simpleipd.git Added General Measures --- diff --git a/data.schema.sql b/data.schema.sql index 1be4572..34eaf0d 100644 --- a/data.schema.sql +++ b/data.schema.sql @@ -1,3 +1,8 @@ +CREATE TABLE advice( +pid int, +time int, +data text +); CREATE TABLE death( pid int, time int, diff --git a/lib/db.php b/lib/db.php index 5aadf0c..9cdffbc 100644 --- a/lib/db.php +++ b/lib/db.php @@ -75,6 +75,24 @@ class DB extends SQLite3 { $stmt->execute(); $log->log($pid, "history", json_encode($post)); } + function advice($post, $pid){ + global $log; + if(!checkAccess("treatment", "dbSet")) return false; + $query=$this->prepare("SELECT count(rowid) FROM advice WHERE pid=:pid"); + $query->bindValue(":pid", $pid); + $exist=$query->execute(); + if($exist->fetchArray()[0]==0){ + $stmt=$this->prepare("INSERT INTO advice (pid,time,data) VALUES (:pid,:time,:data);"); + } + else{ + $stmt=$this->prepare("UPDATE advice SET pid=:pid,time=:time,data=:data WHERE pid=:pid;"); + } + $stmt->bindValue(":pid", $pid); + $stmt->bindValue(":time", time()); + $stmt->bindValue(":data", json_encode($post)); + $stmt->execute(); + $log->log($pid, "advice", json_encode($post)); + } function addPhysician($post, $pid){ global $log; if(!checkAccess("physician", "dbSet")) return false; @@ -294,7 +312,7 @@ class DB extends SQLite3 { $result=$stmt->execute(); return($result); } - function getAdvice($pid){ + function getDischargeAdvice($pid){ global $log; if(!checkAccess("discharge", "dbGet")) return false; $stmt=$this->prepare("SELECT rowid,* FROM discharge WHERE pid=:pid;"); @@ -445,6 +463,14 @@ class DB extends SQLite3 { $result=$stmt->execute(); return($result); } + function getAdvice($pid){ + global $log; + if(!checkAccess("treatment", "dbGet")) return false; + $stmt=$this->prepare("SELECT data FROM advice WHERE pid=:pid;"); + $stmt->bindValue(":pid", $pid); + $result=$stmt->execute(); + return($result); + } function getData($pid, $id, $cat){ global $log; if($cat=="physician"){ diff --git a/www/discharge.php b/www/discharge.php index ceae377..fc36b15 100644 --- a/www/discharge.php +++ b/www/discharge.php @@ -13,7 +13,7 @@ if(!empty($_GET["pid"])){ elseif(!empty($_POST["drug"])){ $db->addAdvice($pid, $_POST["drug"], $_POST["dose"], $_POST["route"], $_POST["frequency"], $_POST["duration"], $_POST["extra_note"]); } - $list=$db->getAdvice($pid); + $list=$db->getDischargeAdvice($pid); $view="
"; $view=$view.""; $view=$view.""; diff --git a/www/forms/advice.schema.json b/www/forms/advice.schema.json new file mode 100644 index 0000000..f3382e1 --- /dev/null +++ b/www/forms/advice.schema.json @@ -0,0 +1,35 @@ +{ + "$schema": "http://json-schema.org/draft/2020-12/schema", + "title": "advice", + "description": "General Measures", + "type": "object", + + "properties": { + "diet": { + "description": "Diet", + "type": "string" + }, + "rt_interval": { + "description": "RT Feed Interval", + "type": "string" + }, + "temp_interval": { + "description": "Temperature Interval", + "type": "string" + }, + "cbg_interval": { + "description": "CBG Interval", + "type": "string" + }, + "posture_interval": { + "description": "Posture Change Interval", + "type": "string" + }, + "other": { + "description": "Other Advices", + "type": "string", + "type": "textarea" + } + }, + "required": ["diet"] +} diff --git a/www/printdata.php b/www/printdata.php index 5315f73..60178f2 100644 --- a/www/printdata.php +++ b/www/printdata.php @@ -44,7 +44,7 @@ if($_GET["pid"]){ } $treatments=$treatments."
  • ".$t["drug"]." ".$t["dose"]." ".$t["route"]." ".$t["frequency"]." ".$start." ".$end." ".$addl; } - $dischargeArray=$db->getAdvice($pid); + $dischargeArray=$db->getDischargeAdvice($pid); while($t=$dischargeArray->fetchArray()){ $discharge=$discharge."
  • ".$t["drug"]." ".$t["dose"]." ".$t["route"]." ".$t["frequency"]." for ".$t["duration"]." ".$t["addl"]; } diff --git a/www/treatment.php b/www/treatment.php index 46357a1..a5426ba 100644 --- a/www/treatment.php +++ b/www/treatment.php @@ -19,9 +19,13 @@ if(!empty($_GET["pid"])){ elseif(!empty($_POST["delete"])){ $db->deleteDrug($_POST["delete"]); } + elseif(!empty($_POST["diet"])){ + $db->advice($_POST, $pid); + } elseif(!empty($_POST["drug"])){ $db->addDrug($pid, $_POST["drug"], $_POST["dose"], $_POST["route"], $_POST["frequency"], $_POST["date"], $_POST["time"], $_POST["duration"], $_POST["extra_note"]); } + $advice=$db->getAdvice($pid)->fetchArray()["data"]; $list=$db->getDrugs($pid); $view=""; while($drug=$list->fetchArray()){ @@ -56,6 +60,7 @@ if(!empty($_GET["pid"])){ $view=$view."
  • "; } $form=schema2form("forms/drugs.schema.json"); + $form2=schema2form("forms/advice.schema.json", null, null, null, json_decode($advice)); if(checkAccess("treatment")=="all" && $db->getStatus($pid)->fetchArray()["status"]=="admitted"){ $hideForm=""; } @@ -74,10 +79,17 @@ if(!empty($_GET["pid"])){
    +
    +
    +

    Advice

    + + Edit General Measures +
    +

    Medicine List

    - Add New Drug + Add New Drug
    @@ -96,13 +108,34 @@ if(!empty($_GET["pid"])){
    DrugDoseRouteFrequencyDurationNote
    ".$drug["drug"]."".$drug["dose"]."".$drug["route"]."".$drug["frequency"]."".date("M j", $drug["start"]).$end."".$drug["duration"]."".$drug["addl"]."".$last."
    -
    id="drug-form"> - +
    > + +
    +
    + +
    +
    + +
    +