]> Softwares of Agnibho - simpleipd.git/commitdiff
Added requisition
authorAgnibho Mondal <mondal@agnibho.com>
Sun, 16 May 2021 16:24:38 +0000 (21:54 +0530)
committerAgnibho Mondal <mondal@agnibho.com>
Sun, 16 May 2021 16:24:38 +0000 (21:54 +0530)
33 files changed:
' [new file with mode: 0644]
autocomplete/investigation.json [new file with mode: 0644]
forms/admission.schema.json
forms/death.schema.json
forms/drugs.schema.json
forms/history.schema.json
forms/nursing.schema.json
forms/physician.schema.json
forms/report-abg.schema.json
forms/report-blood-cs.schema.json
forms/report-ch.schema.json
forms/report-crp.schema.json
forms/report-ddimer.schema.json
forms/report-fluid.schema.json
forms/report-glycemic.schema.json
forms/report-ldh.schema.json
forms/report-lft.schema.json
forms/report-lipid.schema.json
forms/report-other.schema.json
forms/report-rft.schema.json
forms/report-sputum-cs.schema.json
forms/report-sputum-me.schema.json
forms/report-stool-ova.schema.json
forms/report-stool-re.schema.json
forms/report-urine-cs.schema.json
forms/report-urine-re.schema.json
index.php
lib/db.php
report.php
requisition.php [new file with mode: 0644]
schema.sql
treatment.php
view.php

diff --git a/' b/'
new file mode 100644 (file)
index 0000000..380aab9
--- /dev/null
+++ b/'
@@ -0,0 +1,276 @@
+<?php
+class DB extends SQLite3 {
+  function __construct(){
+    $this->open("data/data.db");
+  }
+  function checkUser($username, $password){
+    $stmt=$this->prepare("SELECT hash FROM users WHERE user=:user");
+    $stmt->bindValue(":user", $username);
+    $result=$stmt->execute();
+    $hash=$result->fetchArray();
+    if($hash){
+      return(password_verify($password, $hash["hash"]));
+    }
+    else{
+      return(false);
+    }
+  }
+  function admit($post){
+    $quer=$this->prepare("SELECT count(rowid) FROM patients WHERE pid=:pid");
+    $quer->bindValue(":pid", $post["pid"]);
+    $exist=$quer->execute();
+    if($exist->fetchArray()[0]==0){
+      $stmt=$this->prepare("INSERT INTO patients (pid,name,age,sex,status,summary,ward,bed,diagnosis,data) VALUES (:pid,:name,:age,:sex,'admitted',:summary,:ward,:bed,:diagnosis,:data);");
+    }
+    else{
+      $stmt=$this->prepare("UPDATE patients SET name=:name,age=:age,sex=:sex,ward=:ward,bed=:bed,diagnosis=:diagnosis,summary=:summary,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(":status", "admitted");
+    $stmt->bindValue(":ward", $post["ward"]);
+    $stmt->bindValue(":bed", $post["bed"]);
+    $stmt->bindValue(":diagnosis", $post["diagnosis"]);
+    $stmt->bindValue(":summary", $post["summary"]);
+    $stmt->bindValue(":data", json_encode($post));
+    $stmt->execute();
+  }
+  function updateHistory($post, $pid){
+    $stmt=$this->prepare("UPDATE patients SET history=:history WHERE pid=:pid;");
+    $stmt->bindValue(":history", json_encode($post));
+    $stmt->bindValue(":pid", $pid);
+    $stmt->execute();
+  }
+  function addPhysician($post, $pid){
+    $stmt=$this->prepare("INSERT INTO physician (pid, time, data) VALUES (:pid, :time, :data);");
+    $stmt->bindValue(":pid", $pid);
+    $stmt->bindValue(":time", strtotime($post["date"].$post["time"]));
+    $stmt->bindValue(":data", json_encode($post));
+    $stmt->execute();
+  }
+  function editPhysician($post, $pid, $id){
+    $stmt=$this->prepare("UPDATE physician SET time=:time,data=:data WHERE pid=:pid AND rowid=:id;");
+    $stmt->bindValue(":pid", $pid);
+    $stmt->bindValue(":id", $id);
+    $stmt->bindValue(":time", strtotime($post["date"].$post["time"]));
+    $stmt->bindValue(":data", json_encode($post));
+    $stmt->execute();
+  }
+  function addNursing($post, $pid){
+    $stmt=$this->prepare("INSERT INTO nursing (pid, time, data) VALUES (:pid, :time, :data);");
+    $stmt->bindValue(":pid", $pid);
+    $stmt->bindValue(":time", strtotime($post["date"].$post["time"]));
+    $stmt->bindValue(":data", json_encode($post));
+    $stmt->execute();
+  }
+  function editNursing($post, $pid, $id){
+    $stmt=$this->prepare("UPDATE nursing SET time=:time,data=:data WHERE pid=:pid AND rowid=:id;");
+    $stmt->bindValue(":pid", $pid);
+    $stmt->bindValue(":id", $id);
+    $stmt->bindValue(":time", strtotime($post["date"].$post["time"]));
+    $stmt->bindValue(":data", json_encode($post));
+    $stmt->execute();
+  }
+  function addReport($post, $pid, $form){
+    $stmt=$this->prepare("INSERT INTO reports (pid, time, form, data) VALUES (:pid, :time, :form, :data);");
+    $stmt->bindValue(":pid", $pid);
+    $stmt->bindValue(":time", strtotime($post["date"].$post["time"]));
+    $stmt->bindValue(":form", $post["form"]);
+    $stmt->bindValue(":data", json_encode($post));
+    $stmt->execute();
+  }
+  function editReport($post, $pid, $id, $form){
+    $stmt=$this->prepare("UPDATE reports SET time=:time,data=:data WHERE pid=:pid AND rowid=:id;");
+    $stmt->bindValue(":pid", $pid);
+    $stmt->bindValue(":id", $id);
+    $stmt->bindValue(":time", strtotime($post["date"].$post["time"]));
+    $stmt->bindValue(":data", json_encode($post));
+    $stmt->execute();
+  }
+  function addDrug($pid, $drug, $dose, $route, $frequency, $date, $time, $duration, $addl){
+    $stmt=$this->prepare("INSERT INTO treatment (pid, drug, dose, route, frequency, start, duration, omit, addl) VALUES (:pid, :drug, :dose, :route, :frequency, :start, :duration, :omit, :addl);");
+    $stmt->bindValue(":pid", $pid);
+    $stmt->bindValue(":drug", $drug);
+    $stmt->bindValue(":dose", $dose);
+    $stmt->bindValue(":route", $route);
+    $stmt->bindValue(":frequency", $frequency);
+    $stmt->bindValue(":start", strtotime($date." ".$time));
+    $stmt->bindValue(":duration", $duration);
+    $stmt->bindValue(":addl", $addl);
+    $stmt->bindValue(":omit", false);
+    $stmt->execute();
+  }
+  function omitDrug($id){
+    $stmt=$this->prepare("UPDATE treatment SET end=:end,omit=:omit WHERE rowid=:id;");
+    $stmt->bindValue(":end", time());
+    $stmt->bindValue(":omit", true);
+    $stmt->bindValue(":id", $id);
+    $stmt->execute();
+  }
+  function addRequisition($pid, $test, $date, $time, $room){
+    $stmt=$this->prepare("INSERT INTO requisition (pid, test, time, room, sample, status) VALUES (:pid, :test, :time, :room, :sample, :status);");
+    $stmt->bindValue(":pid", $pid);
+    $stmt->bindValue(":test", $test);
+    $stmt->bindValue(":time", strtotime($date." ".$time));
+    $stmt->bindValue(":room", $room);
+    $stmt->bindValue(":status", "sent");
+    $stmt->execute();
+  }
+  function omitRequisition($id){
+    $stmt=$this->prepare("UPDATE requisition SET status=:status WHERE rowid=:id;");
+    $stmt->bindValue(":status", "done");
+    $stmt->bindValue(":id", $id);
+    $stmt->execute();
+  }
+  function addAdvice($pid, $name, $dose, $route, $frequency, $duration, $addl){
+    $stmt=$this->prepare("INSERT INTO discharge (pid, name, dose, route, frequency, duration, addl) VALUES (:pid, :name, :dose, :route, :frequency, :duration, :addl);");
+    $stmt->bindValue(":pid", $pid);
+    $stmt->bindValue(":name", $name);
+    $stmt->bindValue(":dose", $dose);
+    $stmt->bindValue(":route", $route);
+    $stmt->bindValue(":frequency", $frequency);
+    $stmt->bindValue(":duration", $duration);
+    $stmt->bindValue(":addl", $addl);
+    $stmt->execute();
+  }
+  function deleteAdvice($id){
+    $stmt=$this->prepare("DELETE FROM discharge WHERE rowid=:id;");
+    $stmt->bindValue(":id", $id);
+    $stmt->execute();
+  }
+  function setDischarged($pid){
+    $stmt=$this->prepare("UPDATE patients SET status=:discharged WHERE pid=:pid;");
+    $stmt->bindValue(":pid", $pid);
+    $stmt->execute();
+  }
+  function setDead($pid, $post){
+    $stmt=$this->prepare("INSERT INTO death (pid, time, data) VALUES (:pid, :time, :data);");
+    $stmt->bindValue(":pid", $pid);
+    $stmt->bindValue(":time", strtotime($post["date"].$post["time"]));
+    $stmt->bindValue(":data", json_encode($post));
+    $stmt->execute();
+    $stmt=$this->prepare("UPDATE patients SET status='expired' WHERE pid=:pid;");
+    $stmt->bindValue(":pid", $pid);
+    $stmt->execute();
+  }
+  function getDrugs($pid){
+    $stmt=$this->prepare("SELECT rowid,* FROM treatment WHERE pid=:pid;");
+    $stmt->bindValue(":pid", $pid);
+    $result=$stmt->execute();
+    return($result);
+  }
+  function getRequisitions($pid){
+    $stmt=$this->prepare("SELECT rowid,* FROM requisition WHERE pid=:pid;");
+    $stmt->bindValue(":pid", $pid);
+    $result=$stmt->execute();
+    return($result);
+  }
+  function getAdvice($pid){
+    $stmt=$this->prepare("SELECT rowid,* FROM discharge WHERE pid=:pid;");
+    $stmt->bindValue(":pid", $pid);
+    $result=$stmt->execute();
+    return($result);
+  }
+  function getName($pid){
+    $stmt=$this->prepare("SELECT name FROM patients WHERE pid=:pid;");
+    $stmt->bindValue(":pid", $pid);
+    $result=$stmt->execute();
+    return($result);
+  }
+  function getAge($pid){
+    $stmt=$this->prepare("SELECT age FROM patients WHERE pid=:pid;");
+    $stmt->bindValue(":pid", $pid);
+    $result=$stmt->execute();
+    return($result);
+  }
+  function getSex($pid){
+    $stmt=$this->prepare("SELECT sex FROM patients WHERE pid=:pid;");
+    $stmt->bindValue(":pid", $pid);
+    $result=$stmt->execute();
+    return($result);
+  }
+  function getWard($pid){
+    $stmt=$this->prepare("SELECT ward FROM patients WHERE pid=:pid;");
+    $stmt->bindValue(":pid", $pid);
+    $result=$stmt->execute();
+    return($result);
+  }
+  function getBed($pid){
+    $stmt=$this->prepare("SELECT bed FROM patients WHERE pid=:pid;");
+    $stmt->bindValue(":pid", $pid);
+    $result=$stmt->execute();
+    return($result);
+  }
+  function getStatus($pid){
+    $stmt=$this->prepare("SELECT status FROM patients WHERE pid=:pid;");
+    $stmt->bindValue(":pid", $pid);
+    $result=$stmt->execute();
+    return($result);
+  }
+  function getDiagnosis($pid){
+    $stmt=$this->prepare("SELECT diagnosis FROM patients WHERE pid=:pid;");
+    $stmt->bindValue(":pid", $pid);
+    $result=$stmt->execute();
+    return($result);
+  }
+  function getList(){
+    $stmt=$this->prepare("SELECT pid FROM patients;");
+    $result=$stmt->execute();
+    return($result);
+  }
+  function getForm($id){
+      $stmt=$this->prepare("SELECT form FROM reports WHERE rowid=:id;");
+      $stmt->bindValue(":id", $id);
+      $result=$stmt->execute();
+      return($result);
+  }
+  function getAdmission($pid){
+      $stmt=$this->prepare("SELECT data FROM patients WHERE pid=:pid;");
+      $stmt->bindValue(":pid", $pid);
+      $result=$stmt->execute();
+      return($result);
+  }
+  function getHistory($pid){
+      $stmt=$this->prepare("SELECT history FROM patients WHERE pid=:pid;");
+      $stmt->bindValue(":pid", $pid);
+      $result=$stmt->execute();
+      return($result);
+  }
+  function getData($pid, $id, $cat){
+    if($cat=="physician"){
+      $stmt=$this->prepare("SELECT data FROM physician WHERE pid=:pid AND rowid=:id;");
+    } elseif($cat=="nursing"){
+      $stmt=$this->prepare("SELECT data FROM nursing WHERE pid=:pid AND rowid=:id;");
+    } elseif($cat=="reports"){
+      $stmt=$this->prepare("SELECT data FROM reports WHERE pid=:pid AND rowid=:id;");
+    } else{
+      return(false);
+    }
+    $stmt->bindValue(":pid", $pid);
+    $stmt->bindValue(":id", $id);
+    $result=$stmt->execute();
+    return($result);
+  }
+  function getAllData($pid, $cat){
+    if($cat=="physician"){
+      $stmt=$this->prepare("SELECT rowid,data FROM physician WHERE pid=:pid;");
+    } elseif($cat=="nursing"){
+      $stmt=$this->prepare("SELECT rowid,data FROM nursing WHERE pid=:pid;");
+    } elseif($cat=="reports"){
+      $stmt=$this->prepare("SELECT rowid,data FROM reports WHERE pid=:pid;");
+    } elseif($cat=="info"){
+      $stmt=$this->prepare("SELECT rowid,data FROM patients WHERE pid=:pid;");
+    } elseif($cat=="history"){
+      $stmt=$this->prepare("SELECT rowid,history FROM patients WHERE pid=:pid;");
+    } else{
+      return(false);
+    }
+    $stmt->bindValue(":pid", $pid);
+    $result=$stmt->execute();
+    return($result);
+  }
+}
+$db = new DB();
+?>
diff --git a/autocomplete/investigation.json b/autocomplete/investigation.json
new file mode 100644 (file)
index 0000000..641450e
--- /dev/null
@@ -0,0 +1,13 @@
+{
+    "tests": [
+        "Chest Xray",
+        "Straight Xray Abdomen",
+        "USG W/A"
+    ],
+    "rooms": [
+        "LabMed",
+        "R-4",
+        "R-19A",
+        "Other"
+    ]
+}
index 2a58dd707d3f5042be1d1039f182c10a2091d9a8..24a5bc0b4820231875e25afefc6d5725a0c69a49 100644 (file)
@@ -1,6 +1,6 @@
 {
     "$schema": "http://json-schema.org/draft/2020-12/schema",
-    "title": "Admission Form",
+    "title": "admission",
     "description": "Admission Form",
     "type": "object",
 
index a3dd706f0309cd0a664663bb50c3bcdcd8f92d93..dbdb9bb24671ac5b963da7f4703f8ab03950ec5e 100644 (file)
@@ -1,6 +1,6 @@
 {
     "$schema": "http://json-schema.org/draft/2020-12/schema",
-    "title": "Death Note",
+    "title": "death",
     "description": "Death Note",
     "type": "object",
 
index 8605693363a30e658135b7f3ba9f3142de2b235b..f3be49481508f5b120c970fd1111b0706397926d 100644 (file)
@@ -1,6 +1,6 @@
 {
     "$schema": "http://json-schema.org/draft/2020-12/schema",
-    "title": "Drugs",
+    "title": "drugs",
     "description": "Treatment",
     "type": "object",
 
index 0647afa5914de4bf297a176ad1c9aca22d2371db..1349c66392649bcaefaa8cdf48f651475047a51f 100644 (file)
@@ -1,6 +1,6 @@
 {
     "$schema": "http://json-schema.org/draft/2020-12/schema",
-    "title": "History",
+    "title": "history",
     "description": "History",
     "type": "object",
 
index f2687f4988533d52b0fa8c2a35cdd65216b0cc88..03ddc374575dae247b8f7104892d241a15bb4734 100644 (file)
@@ -1,7 +1,7 @@
 {
     "$schema": "http://json-schema.org/draft/2020-12/schema",
-    "title": "Clinical Notes",
-    "description": "Clinical Notes",
+    "title": "nursing",
+    "description": "Nursing Notes",
     "type": "object",
 
     "properties": {
index 6e91d7bf96801115182bb5c95d754a919fc3dbfd..c4c1056843f162168e57d46e55665f75d328bb17 100644 (file)
@@ -1,7 +1,7 @@
 {
     "$schema": "http://json-schema.org/draft/2020-12/schema",
-    "title": "Clinical Notes",
-    "description": "Clinical Notes",
+    "title": "physician",
+    "description": "Physician Notes",
     "type": "object",
 
     "properties": {
index 0ed6f569ee35468b39498d0f4ee303f3ee5fb1a7..1c015773d2da7134e382c75f6e4ac00d66817cd0 100644 (file)
@@ -1,6 +1,6 @@
 {
     "$schema": "http://json-schema.org/draft/2020-12/schema",
-    "title": "ABG",
+    "title": "abg",
     "description": "ABG",
     "type": "object",
 
index 51dfa1dd55bcb6c002764d1c28dde9079764fd90..ed9fe1ff113aec7dc81f1809dd137a3abf81ec9a 100644 (file)
@@ -1,6 +1,6 @@
 {
     "$schema": "http://json-schema.org/draft/2020-12/schema",
-    "title": "Blood CS",
+    "title": "blood_cs",
     "description": "Blood CS",
     "type": "object",
 
index 3c33b7143483e2d8ffda0cf917775032163c600d..7fcec71f54a511704194a09fbee57595a0bd167f 100644 (file)
@@ -1,6 +1,6 @@
 {
     "$schema": "http://json-schema.org/draft/2020-12/schema",
-    "title": "Complete Hemogram",
+    "title": "ch",
     "description": "Complete Hemogram",
     "type": "object",
 
index 08ce181cfe482723bce4a30bb2f7af1a5f5b22f1..c996b505c7d899e38c159a0d1e281ebf55f81247 100644 (file)
@@ -1,6 +1,6 @@
 {
     "$schema": "http://json-schema.org/draft/2020-12/schema",
-    "title": "CRP",
+    "title": "crp",
     "description": "CRP",
     "type": "object",
 
index f6380738675255db1d34599119545da822f8644f..8e26f796174e6a3b3c581c76b79ab6ac39de2c47 100644 (file)
@@ -1,6 +1,6 @@
 {
     "$schema": "http://json-schema.org/draft/2020-12/schema",
-    "title": "D-Dimer",
+    "title": "d_dimer",
     "description": "D-Dimer",
     "type": "object",
 
index 62bd4dc08eb5fe0ca494109d0b5fc9640f7a1e20..8b3f02d50003431b4b272d1fca29fccd57a66ba7 100644 (file)
@@ -1,6 +1,6 @@
 {
     "$schema": "http://json-schema.org/draft/2020-12/schema",
-    "title": "Fluid Study",
+    "title": "fluid_study",
     "description": "Fluid Study",
     "type": "object",
 
index 0875fb01b5231e80d4ffbe8e1302db8abb4e53f0..6109d7862d6cf7a1f7a617773705d372ebd981af 100644 (file)
@@ -1,6 +1,6 @@
 {
     "$schema": "http://json-schema.org/draft/2020-12/schema",
-    "title": "Glycemic Status",
+    "title": "glycemic",
     "description": "Glycemic Status",
     "type": "object",
 
index cce1e3854502490bf7a4f19952be79271aa61a1b..e22f810ab4a32edd70603cf9611d6a54447545e0 100644 (file)
@@ -1,6 +1,6 @@
 {
     "$schema": "http://json-schema.org/draft/2020-12/schema",
-    "title": "LDH",
+    "title": "ldh",
     "description": "LDH",
     "type": "object",
 
index 2f89980c7b45b7e1e3236e8753aa30fe60e2b15b..6401cadd9136743a6a2944169cb1a8ae11343afc 100644 (file)
@@ -1,6 +1,6 @@
 {
     "$schema": "http://json-schema.org/draft/2020-12/schema",
-    "title": "LFT",
+    "title": "lft",
     "description": "Liver Function Test",
     "type": "object",
 
index a203b15e22840ad61293b8794d22d8460c1206ef..d9052c4e6567efdc12f7df0be40539c7d7002e9f 100644 (file)
@@ -1,6 +1,6 @@
 {
     "$schema": "http://json-schema.org/draft/2020-12/schema",
-    "title": "Lipid Profile",
+    "title": "lipid",
     "description": "Lipid Profile",
     "type": "object",
 
index ba613ecb1704c3230f114c01e160cce3af5e692b..57749cb679c18a87b086d7894920057775a3370d 100644 (file)
@@ -1,7 +1,7 @@
 {
     "$schema": "http://json-schema.org/draft/2020-12/schema",
-    "title": "Other Reports",
-    "description": "Other Reports",
+    "title": "other",
+    "description": "Other Report",
     "type": "object",
 
     "properties": {
index 65df1d767a731206e966d45311b621c6852608e9..874f8f23776babe67456579ceb24d16622937b3b 100644 (file)
@@ -1,6 +1,6 @@
 {
     "$schema": "http://json-schema.org/draft/2020-12/schema",
-    "title": "RFT",
+    "title": "rft",
     "description": "Renal Function Test",
     "type": "object",
 
index 8ebf011145589679b92a2714c181edf621629b61..65d115f4c2c69c06659fab3db10e6bebaf7bde0b 100644 (file)
@@ -1,6 +1,6 @@
 {
     "$schema": "http://json-schema.org/draft/2020-12/schema",
-    "title": "Sputum CS",
+    "title": "sputum_cs",
     "description": "Sputum CS",
     "type": "object",
 
index 596507f2e3f24f109496afd769e51a1e013cb432..5883911d83d3e6dda989c4c5254de809a1a55d49 100644 (file)
@@ -1,6 +1,6 @@
 {
     "$schema": "http://json-schema.org/draft/2020-12/schema",
-    "title": "Sputum ME",
+    "title": "sputum_me",
     "description": "Sputum ME",
     "type": "object",
 
index 3551731ef9e51aed1583b662d5d2af84b1ebe197..8e2cd781cbdb8e7403a18f2fde6c2e63a200d4a3 100644 (file)
@@ -1,6 +1,6 @@
 {
     "$schema": "http://json-schema.org/draft/2020-12/schema",
-    "title": "Stool for Ova",
+    "title": "stool_ova",
     "description": "Stool for Ova",
     "type": "object",
 
index ab7ac5668f95012b946127bfbc48b90cf756402a..9db09db7763f20965a063abb15d97bc7df89144c 100644 (file)
@@ -1,6 +1,6 @@
 {
     "$schema": "http://json-schema.org/draft/2020-12/schema",
-    "title": "Stool RE",
+    "title": "stool_re",
     "description": "Stool RE",
     "type": "object",
 
index 93d8d5a063cfc278b014881cb72b637b17bdb891..16af87c805ce6bd6fa71b587d591367f0b40bdb6 100644 (file)
@@ -1,6 +1,6 @@
 {
     "$schema": "http://json-schema.org/draft/2020-12/schema",
-    "title": "Urine CS",
+    "title": "urine_cs",
     "description": "Urine CS",
     "type": "object",
 
index ac114f276fac75c5b1bd977c61912cebf5f82b09..80a2e0a6fe24447a9e0b68460fdf1294ac74a6e1 100644 (file)
@@ -1,6 +1,6 @@
 {
     "$schema": "http://json-schema.org/draft/2020-12/schema",
-    "title": "Urine RE",
+    "title": "urine_re",
     "description": "Urine RE",
     "type": "object",
 
index 72bc4847815db6ec5c3b5ff3b628974eafa85417..94632b15845bfeda38c290ae935eb95bf25f6362 100644 (file)
--- a/index.php
+++ b/index.php
@@ -2,19 +2,28 @@
 require("lib/db.php");
 require("lib/functions.php");
 session_start();
+var_dump($_SESSION);
 if(empty($_SESSION["user"])){
   header("Location: login.php");
   exit();
 }
-$list=$db->getList();
-$show="";
-if(!empty($list)){
-  while($arr=$list->fetchArray()){
-    $pid=$arr["pid"];
-    $name=$db->getName($pid)->fetchArray()["name"];
-    $bed=$db->getWard($pid)->fetchArray()["ward"]."-".$db->getBed($pid)->fetchArray()["bed"];
-    $show=$show."<tr><td><a href='view.php?pid=".$pid."'>".$pid."</a></td><td>".$bed."</td><td>".$name."</td></tr>";
+$list=$db->getPatientList();
+$showList="";
+while($arr=$list->fetchArray()){
+  $pid=$arr["pid"];
+  $showList=$showList."<tr><td><a href='view.php?pid=".$pid."'>".$pid."</a></td><td>".$arr["ward"]."-".$arr["bed"]."</td><td>".$arr["name"]."</td><td>".$arr["diagnosis"]."</tr>";
+}
+$reqs=$db->getRequisitionList();
+$showReqs="";
+while($arr=$reqs->fetchArray()){
+  $pid=$arr["pid"];
+  if(!empty($arr["form"])){
+    $test="<a href='report.php?pid=".$pid."&form=".$arr["form"]."&req=".$arr["rowid"]."'>".$arr["test"]."</a>";
+  }
+  else{
+    $test="<a href='report.php?pid=".$pid."&form=report-other&req=".$arr["rowid"]."'>".$arr["test"]."</a>";
   }
+  $showReqs=$showReqs."<tr><td>".$test."</td><td>".$arr["room"]."</td><td>".date("M j, Y", $arr["time"])."</td><td><a href='view.php?pid=".$pid."'>".$pid."</a></td></tr>";
 }
 ?>
 <!DOCTYPE html>
@@ -30,12 +39,21 @@ if(!empty($list)){
         <div class="card-body">
           <h4 class="card-title">Patient List</h4>
           <table class="table">
-            <tr><th>Patient ID</th><th>Bed Number</th><th>Name</th></tr>
-            <?php echo $show;?>
+            <tr><th>Patient ID</th><th>Bed Number</th><th>Name</th><th>Diagnosis</th></tr>
+            <?php echo $showList;?>
           </table>
           <a class="btn btn-primary btn-lg" href="admission.php">Add New Patient</a>
         </div>
       </div>
+      <div class="card">
+        <div class="card-body">
+          <h4 class="card-title">Requisition List</h4>
+          <table class="table">
+            <tr><th>Test Needed</th><th>Place</th><th>Date</th><th>Patient ID</th></tr>
+            <?php echo $showReqs;?>
+          </table>
+        </div>
+      </div>
     </div>
     <?php include("lib/foot.php");?>
   </body>
index 5c438b8baa13083a840b50285caf53e163a88e6a..a37bf669769cbeaad17ad5ee6a42f2a86017f696 100644 (file)
@@ -109,6 +109,22 @@ class DB extends SQLite3 {
     $stmt->bindValue(":id", $id);
     $stmt->execute();
   }
+  function addRequisition($pid, $test, $date, $time, $room, $form){
+    $stmt=$this->prepare("INSERT INTO requisition (pid, test, time, room, form, status) VALUES (:pid, :test, :time, :room, :form, :status);");
+    $stmt->bindValue(":pid", $pid);
+    $stmt->bindValue(":test", $test);
+    $stmt->bindValue(":time", strtotime($date." ".$time));
+    $stmt->bindValue(":room", $room);
+    $stmt->bindValue(":form", $form);
+    $stmt->bindValue(":status", "active");
+    $stmt->execute();
+  }
+  function omitRequisition($id){
+    $stmt=$this->prepare("UPDATE requisition SET status=:status WHERE rowid=:id;");
+    $stmt->bindValue(":status", "done");
+    $stmt->bindValue(":id", $id);
+    $stmt->execute();
+  }
   function addAdvice($pid, $name, $dose, $route, $frequency, $duration, $addl){
     $stmt=$this->prepare("INSERT INTO discharge (pid, name, dose, route, frequency, duration, addl) VALUES (:pid, :name, :dose, :route, :frequency, :duration, :addl);");
     $stmt->bindValue(":pid", $pid);
@@ -146,6 +162,13 @@ class DB extends SQLite3 {
     $result=$stmt->execute();
     return($result);
   }
+  function getRequisitions($pid){
+    $stmt=$this->prepare("SELECT rowid,* FROM requisition WHERE pid=:pid AND status=:status;");
+    $stmt->bindValue(":pid", $pid);
+    $stmt->bindValue(":status", "active");
+    $result=$stmt->execute();
+    return($result);
+  }
   function getAdvice($pid){
     $stmt=$this->prepare("SELECT rowid,* FROM discharge WHERE pid=:pid;");
     $stmt->bindValue(":pid", $pid);
@@ -194,8 +217,14 @@ class DB extends SQLite3 {
     $result=$stmt->execute();
     return($result);
   }
-  function getList(){
-    $stmt=$this->prepare("SELECT pid FROM patients;");
+  function getPatientList(){
+    $stmt=$this->prepare("SELECT pid,ward,bed,name,diagnosis FROM patients;");
+    $result=$stmt->execute();
+    return($result);
+  }
+  function getRequisitionList(){
+    $stmt=$this->prepare("SELECT rowid,pid,test,room,time,form FROM requisition WHERE status=:active;");
+    $stmt->bindValue(":active", "active");
     $result=$stmt->execute();
     return($result);
   }
index d21f96cfc7dfc6a9d0ccabe963e19b477785f3e4..c79189205900d458f7dc4681745289fc139e7760 100644 (file)
@@ -15,6 +15,9 @@ if(!empty($_GET["pid"]) && !empty($_GET["form"])){
     else{
       $db->addReport($_POST, $pid, $_POST["form"]);
     }
+    if(!empty($_GET["req"])){
+      $db->omitRequisition($_GET["req"]);
+    }
     //header("Location: view.php?id=".$_GET["id"]);
     //exit();
   }
diff --git a/requisition.php b/requisition.php
new file mode 100644 (file)
index 0000000..723059c
--- /dev/null
@@ -0,0 +1,90 @@
+<?php
+require("lib/db.php");
+require("lib/functions.php");
+session_start();
+if(empty($_SESSION["user"])){
+  header("Location: login.php");
+  exit();
+}
+if(isSet($_GET["pid"])){
+  $pid=$_GET["pid"];
+  if(!empty($_POST["del"])){
+    $db->omitRequisition($_POST["del"]);
+  }
+  if(!empty($_POST["test"])){
+    if(file_exists($_POST["test"])){
+      $form=str_replace(["forms/",".schema.json"], "", $_POST["test"]);
+      $test=json_decode(file_get_contents("forms/".$form.".schema.json"))->description;
+    }
+    else{
+      $test=$_POST["test"];
+      $form="";
+    }
+    $db->addRequisition($pid, $test, $_POST["date"], $_POST["time"], $_POST["room"], $form);
+  }
+  $inv=json_decode(file_get_contents("autocomplete/investigation.json"));
+  $testList="";
+  foreach(glob("forms/report*.json") as $file){
+    $form=json_decode(file_get_contents($file));
+    $testList=$testList."<option value='".$file."'>".$form->description."</option>";
+  }
+  foreach($inv->tests as $t){
+    $testList=$testList."<option>".$t."</option>";
+  }
+  $roomList="";
+  foreach($inv->rooms as $r){
+    $roomList=$roomList."<option>".$r."</option>";
+  }
+  $roomList=$roomList."<option selected='selected'>Other</option>";
+
+  $reqList=$db->getRequisitions($pid);
+  $list="";
+  while($req=$reqList->fetchArray()){
+    $list=$list."<tr><td>".$req["test"]."</td><td>".$req["room"]."</td><td>".date("M j, Y", $req["time"])."</td><td><button type='submit' class='btn btn-secondary' name='del' value='".$req["rowid"]."' form='delete'>Delete</button></td></tr>";
+  }
+}
+?>
+<!DOCTYPE html>
+<html>
+  <head>
+    <?php include("lib/head.php")?>
+    <title>Laboratory</title>
+  </head>
+  <body>
+    <div class="container">
+      <div class="card">
+        <div class="card-body">
+          <h4 class="card-title">List of Requisitions</h4>
+          <form method='post' id='delete'></form>
+          <table class="table">
+            <tr><th>Test Name</th><th>Destination</th><th>Date</th><th></th></tr>
+            <?php echo $list;?>
+          </table>
+          <form method="post">
+            <div class="row">
+              <div class="col">
+            <select name="test">
+              <?php echo $testList;?>
+            </select>
+              </div>
+              <div class="col">
+            <select name="room">
+              <?php echo $roomList;?>
+            </select>
+              </div>
+              <div class="col">
+                <input type="date" name="date" class="form-control">
+              </div>
+              <div class="col">
+                <input type="time" name="time" class="form-control">
+              </div>
+              <div class="col">
+            <button class="btn btn-primary" type="submit">Submit Requisition</button>
+              </div>
+          </form>
+        </div>
+      </div>
+    </div>
+    <?php include("lib/foot.php");?>
+  </body>
+</html>
index b745a8cc62e6d44d433df151310f9c04da26268f..b570d58cd142189a9da9be8bef19d4ea17e0ac94 100644 (file)
@@ -44,6 +44,15 @@ time int,
 form text,
 data text
 );
+CREATE TABLE requisition(
+pid int,
+test text,
+time int,
+room text,
+sample text,
+form text,
+status text
+);
 CREATE TABLE treatment(
 pid int,
 drug text,
index ac906fe338c4f508881f970bb8eef5699ca9cefc..2b8c29ddea38909701085bb4a4a7cad0aac65bf8 100644 (file)
@@ -15,9 +15,7 @@ if(!empty($_GET["pid"])){
     $db->addDrug($pid, $_POST["drug"], $_POST["dose"], $_POST["route"], $_POST["frequency"], $_POST["date"], $_POST["time"], $_POST["duration"], $_POST["extra-note"]);
   }
   $list=$db->getDrugs($pid);
-  $view="<form method='post' id='omitter'></form>";
-  $view=$view."<table class='table'>";
-  $view=$view."<tr><th>Drug</th><th>Dose</th><th>Route</th><th>Frequency</th><th>Start</th><th>Duration</th><th>Note</th></tr>";
+  $view="";
   while($drug=$list->fetchArray()){
     if($drug["omit"]){
       $omit="omit";
@@ -31,7 +29,7 @@ if(!empty($_GET["pid"])){
         }
       } catch(TypeError $e){}
     }
-    $view=$view."<tr class='".$omit."'><td>".$drug["drug"]."</td><td>".$drug["dose"]."</td><td>".$drug["route"]."</td><td>".$drug["frequency"]."</td><td>".date("M j", $drug["start"])."</td><td>".$drug["duration"]."</td><td>".$drug["addl"]."</td><td><button class='btn btn-warning' name='omit' value='".$drug["rowid"]."' form='omitter' ".$omit.">Omit</button></td></tr>";
+    $view=$view."<tr class='".$omit."'><td>".$drug["drug"]."</td><td>".$drug["dose"]."</td><td>".$drug["route"]."</td><td>".$drug["frequency"]."</td><td>".date("M j", $drug["start"])."</td><td>".$drug["duration"]."</td><td>".$drug["addl"]."</td><td><button type='submit' class='btn btn-warning' name='omit' value='".$drug["rowid"]."' form='omitter' ".$omit.">Omit</button></td></tr>";
   }
   $view=$view."</table>";
   $form=schema2form("forms/drugs.schema.json");
@@ -48,7 +46,11 @@ if(!empty($_GET["pid"])){
       <div class="card mb-4">
         <div class="card-body">
           <h4 class="card-title">Medicine List</h4>
-          <?php echo $view;?>
+          <form method='post' id='omitter'></form>
+          <table class="table">
+            <tr><th>Drug</th><th>Dose</th><th>Route</th><th>Frequency</th><th>Start</th><th>Duration</th><th>Note</th><th></th></tr>
+            <?php echo $view;?>
+          </table>
         </div>
       </div>
       <?php echo $form;?>
index a10738129bc4575eab264df0ffaef7ed173c4ae4..050f92a31e1c406b99cd63729880dec7e4ffbc5f 100644 (file)
--- a/view.php
+++ b/view.php
@@ -45,6 +45,7 @@ if(isSet($_GET["pid"])){
             <a class="mb-3 btn btn-secondary" href="physician.php?pid=<?php echo $pid;?>">Add Physician Note</a>
             <a class="mb-3 btn btn-secondary" href="nursing.php?pid=<?php echo $pid;?>">Add Nursing Note</a>
             <a class="mb-3 btn btn-secondary" href="laboratory.php?pid=<?php echo $pid;?>">Add Laboratory Report</a>
+            <a class="mb-3 btn btn-secondary" href="requisition.php?pid=<?php echo $pid;?>">Add Requisition</a>
         </div>
       </div>
       <div <?php if(empty($pid)) echo "style='display:none'";?>>