From: Agnibho Mondal Date: Fri, 28 May 2021 11:57:19 +0000 (+0530) Subject: Added basic chart X-Git-Url: https://code.agnibho.com/repo?a=commitdiff_plain;h=a24e60f2af76b0e6b8e4a102049c5c5bb6e5bd6f;p=simpleipd.git Added basic chart --- diff --git a/access.json b/access.json index 8136e38..065b9de 100644 --- a/access.json +++ b/access.json @@ -170,6 +170,15 @@ "tech": "view", "clerk": "view" }, + "chart": { + "admin": "view", + "visiting": "view", + "resident": "view", + "nursing": "view", + "lab": "view", + "tech": "view", + "clerk": "view" + }, "printdata": { "admin": "view", "visiting": "view", diff --git a/www/chart.php b/www/chart.php new file mode 100644 index 0000000..073357a --- /dev/null +++ b/www/chart.php @@ -0,0 +1,91 @@ +getAllData($pid, "nursing"); + while($item=$nursingArray->fetchArray()){ + array_push($nursing, json_decode($item["data"])); + } + echo json_encode($nursing); + exit(); + } + if(!empty($_GET["get"]) && $_GET["get"]=="physician"){ + $physician=[]; + $physicianArray=$db->getAllData($pid, "physician"); + while($item=$physicianArray->fetchArray()){ + array_push($physician, json_decode($item["data"])); + } + echo json_encode($physician); + exit(); + } + if(!empty($_GET["get"]) && $_GET["get"]=="reports"){ + $reports=[]; + $reportsArray=$db->getAllData($pid, "reports"); + while($item=$reportsArray->fetchArray()){ + array_push($reports, json_decode($item["data"])); + } + echo json_encode($reports); + exit(); + } + if(!empty($_GET["get"]) && $_GET["get"]=="treatment"){ + $treatment=[]; + $treatmentArray=$db->getDrugs($pid); + while($item=$treatmentArray->fetchArray()){ + if($item["omit"]==0){ + array_push($treatment, $item); + } + } + echo json_encode($treatment); + exit(); + } +} +?> + + + + + View Info + + +
+ +

This page contains experimental features. Please double check for the time being.

+

Patient Data

+ +
+
Possible inconsistent intake output data. ()
+
+
+

Intake/Output

+
    +
  • Approximate hours intake: ml
  • +
  • Approximate hours output: ml
  • +
+
+
+ + + + + + +
Time
+ + + + + + +
Time
+ + +
+ + + +
+ + diff --git a/www/res/calc.js b/www/res/calc.js new file mode 100644 index 0000000..ebd31c2 --- /dev/null +++ b/www/res/calc.js @@ -0,0 +1,168 @@ +function entrySort(i, j){ + if(i[0]==j[0]){ + return 0; + } + else if(i[0]>j[0]){ + return -1; + } + else{ + return 1; + } +} +var io=[]; +var clinical={pr:[], rr:[], spo2:[], sbp:[], dbp:[]}; +var reports={}; +var treatment={}; +$(document).ready(function(){ + $.getJSON("chart.php?pid="+pid+"&get=nursing", function(data){ + flag=""; + $.each(data, function(num, entry){ + // INTAKE-OUTPUT + stamp=moment(entry.date+" "+entry.time); + if(entry.io_from!="" && entry.io_to!=""){ + start=moment(entry.date+" "+entry.io_from); + end=moment(entry.date+" "+entry.io_to); + if(start.isValid() && end.isValid()){ + if(end.format("X")-start.format("X")>24*60*60){ + flag=entry.date; + } + if(start==end){ + flag=entry.date; + } + if(start>end){ + start.subtract(1, "days"); + } + io.push({start: start, end: end, in: entry.intake, out: entry.output}); + } + } + // CLINICAL + if(entry.pr){ + clinical.pr.push([stamp, entry.pr]); + } + if(entry.rr){ + clinical.rr.push([stamp, entry.rr]); + } + if(entry.spo2){ + clinical.spo2.push([stamp, entry.spo2]); + } + if(entry.bp){ + clinical.sbp.push([stamp, entry.bp.split("/")[0]]); + } + if(entry.bp){ + clinical.dbp.push([stamp, entry.bp.split("/")[1]]); + } + }); + // INTAKE-OUTPUT + approxIn=0; + approxOut=0; + ioGap=0; + io.forEach(function(i){ + if(ioGap<(24*60*60)){ + ioBuff=ioGap+(i.end.format("X")-i.start.format("X")); + if(ioBuff>(24*60*60)){ + frac=(24-ioGap)/(ioBuff-ioGap); + ioGap=(24*60*60); + } + else{ + frac=1; + ioGap=ioBuff; + } + approxIn=approxIn+(Number(i.in)*frac); + approxOut=approxOut+(Number(i.out)*frac); + if(flag==""){ + $(".ioGap").each(function(){ + $(this).text(ioGap/3600); + }); + $("#approxIn").text(approxIn); + $("#approxOut").text(approxOut); + $("#ioData").removeClass("d-none"); + } + else{ + $("#ioInconsistent").text(flag); + $("#ioAlert").removeClass("d-none"); + } + } + }); + // CLINICAL + $.getJSON("chart.php?pid="+pid+"&get=physician", function(data){ + $.each(data, function(num, entry){ + stamp=moment(entry.date+" "+entry.time); + if(entry.pr){ + clinical.pr.push([stamp, entry.pr]); + } + if(entry.rr){ + clinical.rr.push([stamp, entry.rr]); + } + if(entry.spo2){ + clinical.spo2.push([stamp, entry.spo2]); + } + if(entry.bp){ + clinical.sbp.push([stamp, entry.bp.split("/")[0]]); + } + if(entry.bp){ + clinical.dbp.push([stamp, entry.bp.split("/")[1]]); + } + }); + clinical.pr.sort(entrySort); + Object.keys(clinical).forEach(function(i){ + $("#clinVar").html($("#clinVar").html()+""); + }); + }); + // REPORTS + $.getJSON("chart.php?pid="+pid+"&get=reports", function(data){ + $.each(data, function(num, entry){ + stamp=moment(entry.date+" "+entry.time); + Object.keys(entry).forEach(function(i){ + if(entry[i] && !isNaN(entry[i])){ + if(!Array.isArray(reports[i])){ + reports[i]=[]; + } + reports[i].push([stamp, entry[i]]); + } + }); + }); + reports=Object.keys(reports).sort().reduce(function(obj, key){ + obj[key]=reports[key]; + return obj; + },{}); + Object.keys(reports).forEach(function(i){ + $("#reportsVar").html($("#reportsVar").html()+""); + }); + }); + // TREATMENT + $.getJSON("chart.php?pid="+pid+"&get=treatment", function(data){ + $.each(data, function(num, entry){ + treat=[]; + treat[0]=entry.drug+" "+entry.dose+" "+entry.route+" "+entry.frequency; + treat[1]=$.parseJSON(entry.administer); + treatment[entry.drug]=treat; + }); + Object.keys(treatment).forEach(function(i){ + $("#drugVar").html($("#drugVar").html()+""); + }); + }); + }); + // EVENTS + $("#clinVar").change(function(){ + $("#clinData").html(""); + param=$("#clinVar").val(); + clinical[param].forEach(function(i){ + $("#clinData").html($("#clinData").html()+""+i[0].format("MMM D, HH:mm")+""+i[1]+""); + }); + }); + $("#reportsVar").change(function(){ + $("#reportsData").html(""); + param=$("#reportsVar").val(); + reports[param].forEach(function(i){ + $("#reportsData").html($("#reportsData").html()+""+i[0].format("MMM D, HH:mm")+""+i[1]+""); + }); + }); + $("#drugVar").change(function(){ + param=$("#drugVar").val(); + $("#drugData1").html(treatment[param][0]); + $("#drugData2").html(""); + treatment[param][1].forEach(function(i){ + $("#drugData2").html($("#drugData2").html()+" "+moment(i*1000).format("MMM D HH:mm")+""); + }); + }); +});