<div class="text-primary">
<div class="jumbotron">
<h1>PDosage</h1>
- <h2>Pediatric Dose Calculator</h2>
+ <h2>Drug Dose Calculator</h2>
</div>
</div>
<div class="row" id="app">
<div class="col-md-6 col-md-offset-3">
<div class="panel panel-default">
<div class="panel-heading">
- <h3>About PDosage</h3>
+ <h3>About PDosage <span class="version"></span></h3>
</div>
<div class="panel-body">
<p>PDosage is a web application for calculating dosage of some commonly used drugs. Although it's primarily designed for the practice of Pediatrics, it also provides adult doses of drugs, making it useful for other disciplines too.</p>
<p>PDosage is written in Javascript.</p>
+ <p>App Version: <span class="version"></span></p>
+ <p>Data version: <span class="data-ver"></span></p>
<p>Copyright © <span class="copyright" data-start="2016">2016</span> Agnibho Mondal</p>
<p>E-mail: mail@agnibho.com</p>
</div>
props:["patient"],
data:function(){
return{
- inWt: "",
- inAgeY: "",
- inAgeM: "",
- inAgeD: ""
+ inWt: this.patient.wt,
+ inAgeY: this.patient.age.y,
+ inAgeM: this.patient.age.m,
+ inAgeD: this.patient.age.d
}
},
watch: {
--- /dev/null
+/**********************************************************************
+ * Title: PDosage
+ * Description: Pediatric Calculator
+ * Author: Agnibho Mondal
+ * Website: http://code.agnibho.com
+ **********************************************************************
+ Copyright (c) 2016 Agnibho Mondal
+ All rights reserved
+ **********************************************************************
+ This file is part of PDosage.
+
+ PDosage is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ PDosage is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with PDosage. If not, see <http://www.gnu.org/licenses/>.
+ **********************************************************************/
+
+export default function Dosage(data){
+
+ Object.defineProperty(data, "prop", {
+ writable: false
+ });
+
+ this.get=function(){
+ return data;
+ }
+
+ this.listDrugs=function(){
+ var list=data.map(function(obj){
+ return obj.name;
+ });
+ return list;
+ }
+
+ this.getDrug=function(name, patient){
+ if(this.listDrugs().indexOf(name)==-1){
+ return null;
+ }
+ var drug=JSON.parse(JSON.stringify(data.filter(extract)[0]));
+ function extract(obj){
+ return (obj.name == name);
+ }
+ for(var i=0; i<drug.form.length; i++){
+ drug.form[i]=calculateDose(drug.form[i], patient);
+ }
+ return drug;
+ }
+
+ function calculateDose(form, patient){
+ while(form.hasOwnProperty("range")){
+ var res=isolateRange(form, patient);
+ delete form.range;
+ if(res!=null){
+ if(res.hasOwnProperty("range")){
+ form.range=res.range;
+ }
+ else{
+ form.dose=res.dose;
+ }
+ }
+ }
+ if(form.dose){
+ form.dose=[].concat(form.dose);
+ for(var i=0; i<form.dose.length; i++){
+ if(form.dose[i].hasOwnProperty("val")){
+ form.dose[i].val=[].concat(form.dose[i].val);
+ }
+ else if(form.dose[i].hasOwnProperty("perKg")){
+ form.dose[i].perKg=[].concat(form.dose[i].perKg);
+ form.dose[i].val=[];
+ form.dose[i].val[0]=Math.round(parseFloat(form.dose[i].perKg[0])*parseFloat(patient.wt)*100)/100;
+ form.dose[i].val[1]=Math.round(parseFloat(form.dose[i].perKg[1])*parseFloat(patient.wt)*100)/100;
+ form.dose[i]=setLimit(form.dose[i]);
+ }
+ else if(form.dose[i].hasOwnProperty("approx")){
+ form.dose[i].val=[];
+ form.dose[i].val=findApprox(form.dose[i].approx);
+ form.dose[i]=setLimit(form.dose[i]);
+ }
+ else if(form.dose[i].hasOwnProperty("eq")){
+ form.dose[i].eq=[].concat(form.dose[i].eq);
+ form.dose[i].val=[];
+ form.dose[i].val[0]=solveEq(form.dose[i].eq[0]);
+ form.dose[i].val[1]=solveEq(form.dose[i].eq[1]);
+ form.dose[i]=setLimit(form.dose[i]);
+ }
+ else{
+ form.dose[i].val=[];
+ form.dose[i].val[0]=null;
+ form.dose[i].val[1]=null;
+ }
+ }
+ }
+ return form;
+
+ function isolateRange(form, patient){
+ var min=0;
+ var max=0;
+ var type="";
+ if(patient.age.y===null && patient.age.m===null && patient.age.d===null){
+ return null;
+ }
+ var pDays=patient.age.y*365+patient.age.m*30+patient.age.d;
+ for(var i=0; i<form.range.length; i++){
+ if(form.range[i].hasOwnProperty("min")){
+ if(form.range[i].min.indexOf("kg")!=-1){
+ min=form.range[i].min.slice(0, str.indexOf("kg"));
+ type="wt";
+ }
+ else{
+ min=strToDays(form.range[i].min);
+ type="age";
+ }
+ }
+ else{
+ min=0;
+ }
+ if(form.range[i].hasOwnProperty("max")){
+ if(form.range[i].max.indexOf("kg")!=-1){
+ max=form.range[i].max.slice(0, str.indexOf("kg"));
+ type="wt";
+ }
+ else{
+ max=strToDays(form.range[i].max);
+ type="age";
+ }
+ }
+ else{
+ max=Infinity;
+ }
+ if(type=="wt"){
+ if(patient.wt>=min && patient.wt<max){
+ return form.range[i];
+ }
+ }
+ else if(type=="age"){
+ if(pDays>=min && pDays<max){
+ return form.range[i];
+ }
+ }
+ }
+ return null;
+
+ function strToDays(str){
+ var age={y: 0, m: 0, d: 0};
+ var days=0;
+ str=str.replace(/\s+/g, "");
+ if(str.indexOf("y")!=-1){
+ age.y=str.slice(0, str.indexOf("y"));
+ str=str.slice(str.indexOf("y", -1));
+ }
+ if(str.indexOf("m")!=-1){
+ age.m=str.slice(0, str.indexOf("m"));
+ str=str.slice(str.indexOf("m", -1));
+ }
+ if(str.indexOf("d")!=-1){
+ age.d=str.slice(0, str.indexOf("d"));
+ str=str.slice(str.indexOf("d", -1));
+ }
+ days=age.y*365+age.m*30+age.d;
+ return days;
+ }
+ }
+
+ function findApprox(arr){
+ var ret=[];
+ arr[0]=arr[0]/2;
+ for(var i=1; i<arr.length; i++){
+ arr[i]=solveEq(arr[i]);
+ ret[i-1]=Math.round(arr[i]/arr[0])/2;
+ }
+ if(!ret[0] || (ret[0]==ret[1])){
+ ret[0]=ret[1];
+ ret[1]=null;
+ }
+ return ret;
+ }
+
+ function solveEq(str){
+ var bw=parseFloat(patient.wt);
+ var ageY=patient.age.y;
+ var ageM=ageY*12+patient.age.m;
+ var ageD=ageM*30+patient.age.d;
+ var ret=eval(str);
+ ret=Math.round(ret*100)/100;
+ return ret;
+ }
+
+ function setLimit(dose){
+ if(dose.adult && dose.val){
+ if(dose.val[0]>dose.adult[0]){
+ dose.val[0]=dose.adult[0];
+ }
+ if(dose.val[1]>dose.adult[1]){
+ dose.val[1]=dose.adult[1];
+ }
+ }
+ if(dose.limit && dose.val){
+ if(dose.val[0]>dose.limit[0]){
+ dose.val[0]=dose.limit[0];
+ }
+ if(dose.val[1]>dose.limit[1]){
+ dose.val[1]=dose.limit[1];
+ }
+ }
+ if(dose.val[1]==dose.val[0]){
+ dose.val[1]=null;
+ }
+ return dose;
+ }
+ }
+}
<template v-for="i in item.dose">
<template v-if="i.val[0]">
<tr>
- <td class="active">Dose:</td>
- <td>{{i.val[0]}}<span v-if="i.val[1]"> - {{i.val[1]}}</span> {{i.unit}} </td>
+ <td class="active" rowspan="2">Dose:</td>
+ <td>{{i.val[0]}}<span v-if="i.val[1]"> - {{i.val[1]}}</span> {{i.unit}}</td>
<td><span v-if="i.txt">{{i.txt}}</span><span v-else>per dose</span></td>
- <td v-if="i.comment">{{i.comment}}</td>
+ </tr>
+ <tr>
+ <td><template v-if="i.perKg && (!i.limit || i.limit[0]!=i.val[0] || i.limit[1]!=i.val[1])">
+ <template v-if="i.perKg">
+ <span v-if="i.perKg[0]">( {{i.perKg[0]}}<span v-if="i.perKg[1]">-{{i.perKg[1]}}</span> {{i.unit}}/kg</span>
+ <template v-if="i.adult">
+ ; Adult: {{i.adult[0]}}<span v-if="i.adult[1] && i.adult[1]!=i.adult[0]">-{{i.adult[1]}}</span> {{i.unit}}
+ </template>
+ <template v-if="i.limit">
+ ; Limit: {{i.limit[0]}}<span v-if="i.limit[1] && i.limit[1]!=i.limit[0]">-{{i.limit[1]}}</span> {{i.unit}}
+ </template>
+ )
+ </template>
+ </td>
+ <td><span v-if="i.comment">{{i.comment}}</span></td>
</tr>
</template>
</template>
"min": "2y",
"dose": {
"perKg": 80,
- "limit": [
+ "adult": [
3200,
3200
],
"min": "2y",
"dose": {
"perKg": 80,
- "limit": [
+ "adult": [
3200,
3200
],
15,
20
],
- "limit": [
+ "adult": [
1500,
1500
],
"15*bw",
"20*bw"
],
- "limit": [
+ "adult": [
15,
15
],
"15*bw",
"20*bw"
],
- "limit": [
+ "adult": [
6,
6
],
"15*bw",
"20*bw"
],
- "limit": [
+ "adult": [
3,
3
],
25,
50
],
- "limit": [
+ "adult": [
250,
500
],
50,
100
],
- "limit": [
+ "adult": [
1200,
1200
],
"25*bw",
"50*bw"
],
- "limit": [
+ "adult": [
1,
2
],
"25*bw",
"50*bw"
],
- "limit": [
+ "adult": [
0.5,
1
],
1,
2
],
- "limit": [
+ "adult": [
10,
20
],
"50*bw",
"100*bw"
],
- "limit": [
+ "adult": [
8,
8
],
"50*bw",
"100*bw"
],
- "limit": [
+ "adult": [
4,
4
],
"50*bw",
"100*bw"
],
- "limit": [
+ "adult": [
2,
2
],
"50*bw",
"100*bw"
],
- "limit": [
+ "adult": [
1,
1
],
"gen": true,
"dose": {
"perKg": 8,
- "limit": [
+ "adult": [
400,
400
],
"gen": true,
"dose": {
"perKg": 20,
- "limit": [
+ "adult": [
400,
400
],
50,
"8*bw"
],
- "limit": [
+ "adult": [
8,
8
],
100,
"8*bw"
],
- "limit": [
+ "adult": [
4,
4
],
200,
"8*bw"
],
- "limit": [
+ "adult": [
2,
2
],
400,
"8*bw"
],
- "limit": [
+ "adult": [
1,
1
],
"content": "100mg/5ml",
"dose": {
"perKg": 0.4,
- "limit": [
+ "adult": [
20,
20
],
50,
75
],
- "limit": [
+ "adult": [
1000,
1000
],
},
{
"mode": "Inj",
+ "gen": true,
"dose": {
"perKg": 50,
- "limit": [
+ "adult": [
1000,
1000
],
},
{
"mode": "Inj",
+ "gen": true,
"range": [
{
"max": "1y",
25,
50
],
- "limit": [
+ "adult": [
125,
125
],
},
{
"mode": "Inj",
+ "gen": true,
"dose": {
"val": 125,
"unit": "mg",
"txt": "single IM",
"comment": "prophylaxis for N. meningitidis."
}
+ },
+ {
+ "mode": "Inj",
+ "content": "125mg",
+ "dose": {
+ "approx": [
+ 125,
+ "50*bw",
+ "75*bw"
+ ],
+ "adult": [
+ 8,
+ 8
+ ],
+ "unit": "vial",
+ "txt": ""
+ }
+ },
+ {
+ "mode": "Inj",
+ "content": "250mg",
+ "dose": {
+ "approx": [
+ 250,
+ "50*bw",
+ "75*bw"
+ ],
+ "adult": [
+ 4,
+ 4
+ ],
+ "unit": "vial",
+ "txt": ""
+ }
+ },
+ {
+ "mode": "Inj",
+ "content": "500mg",
+ "dose": {
+ "approx": [
+ 500,
+ "50*bw",
+ "75*bw"
+ ],
+ "adult": [
+ 2,
+ 2
+ ],
+ "unit": "vial",
+ "txt": ""
+ }
+ },
+ {
+ "mode": "Inj",
+ "content": "1000mg",
+ "dose": {
+ "approx": [
+ 1000,
+ "50*bw",
+ "75*bw"
+ ],
+ "adult": [
+ 1,
+ 1
+ ],
+ "unit": "vial",
+ "txt": ""
+ }
}
]
}
20,
30
],
- "limit": [
+ "adult": [
500,
1000
],
"gen": true,
"dose": {
"perKg": 40,
- "limit": [
+ "adult": [
500,
1000
],
100,
150
],
- "limit": [
+ "adult": [
2250,
2250
],
"20*bw",
"30*bw"
],
- "limit": [
+ "adult": [
4,
8
],
"20*bw",
"30*bw"
],
- "limit": [
+ "adult": [
2,
4
],
"20*bw",
"30*bw"
],
- "limit": [
+ "adult": [
1,
2
],
0.8,
1.2
],
- "limit": [
+ "adult": [
20,
40
],
"100*bw",
"150*bw"
],
- "limit": [
+ "adult": [
2,
4
],
--- /dev/null
+{
+ "name": "Diazepam",
+ "form": [
+ {
+ "mode": "Inj",
+ "gen": true,
+ "range": [
+ {
+ "max": "1m",
+ "dose": [
+ {
+ "val": [
+ 1,
+ 5
+ ],
+ "unit": "mg",
+ "txt": "slow IV for Neonatal Tetanus, max 2mg/kg, every 2-4 hrs alternating with Chlorpromazine."
+ },
+ {
+ "perKg": [
+ 15,
+ 40
+ ],
+ "unit": "mg",
+ "txt": "per day continuous infusion for Neonatal Tetanus."
+ }
+ ]
+ },
+ {
+ "min": "1m",
+ "max": "5y",
+ "dose": {
+ "perKg": [
+ 0.2,
+ 0.5
+ ],
+ "limit": [
+ 5,
+ 5
+ ],
+ "unit": "mg",
+ "txt": "IV or IM as anti-convulsant, maybe repeated q 3-5 mins"
+ }
+ },
+ {
+ "min": "5y",
+ "dose": {
+ "perKg": [
+ 0.2,
+ 0.5
+ ],
+ "limit": [
+ 10,
+ 10
+ ],
+ "unit": "mg",
+ "txt": "IV or IM as anti-convulsant, maybe repeated q 3-5 mins"
+ }
+ }
+ ]
+ },
+ {
+ "mode": "Oral/IV/IM",
+ "gen": true,
+ "range": [
+ {
+ "max": "12y",
+ "dose": {
+ "perKg": [
+ 0.1,
+ 0.2
+ ],
+ "unit": "mg",
+ "txt": ""
+ }
+ },
+ {
+ "min": "12y",
+ "dose": [
+ {
+ "val": [
+ 2,
+ 10
+ ],
+ "unit": "mg",
+ "txt": "per day for anxiety"
+ },
+ {
+ "val": [
+ 5,
+ 10
+ ],
+ "unit": "mg",
+ "txt": "at bedtime for Insomnia"
+ },
+ {
+ "val": [
+ 10,
+ 30
+ ],
+ "unit": "mg",
+ "txt": "for muscle spasms & premedication"
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "comment": "Available forms- Tab 2mg,5mg,10mg; Syr 2mg/5ml; Inj 10mg/2ml; Rectal sol 2mg/ml,5mg/5ml; Suppository 2.5mg,5mg"
+}
0.2,
0.4
],
- "limit": [
+ "adult": [
10,
20
],
"0.2*bw",
"0.4*bw"
],
- "limit": [
+ "adult": [
1,
2
],
"0.2*bw",
"0.4*bw"
],
- "limit": [
+ "adult": [
2,
4
],
0.2,
0.4
],
- "limit": [
+ "adult": [
10,
20
],
0.02,
0.04
],
- "limit": [
+ "adult": [
1,
2
],
2,
6
],
- "limit": [
+ "adult": [
40,
80
],
1,
2
],
- "limit": [
+ "adult": [
40,
80
],
1,
3
],
- "limit": [
+ "adult": [
20,
40
],
2,
6
],
- "limit": [
+ "adult": [
1,
2
],
0.2,
0.6
],
- "limit": [
+ "adult": [
4,
8
],
"min": "6m",
"dose": {
"perKg": 2,
- "limit": [
+ "adult": [
50,
200
],
0.5,
1
],
- "limit": [
+ "adult": [
50,
200
],
10,
"2*bw"
],
- "limit": [
+ "adult": [
5,
20
],
25,
"2*bw"
],
- "limit": [
+ "adult": [
2,
8
],
"min": "6m",
"dose": {
"perKg": 1,
- "limit": [
+ "adult": [
25,
100
],
"min": "6m",
"dose": {
"perKg": 0.33,
- "limit": [
+ "adult": [
8.33,
33.33
],
0.02,
0.04
],
- "limit": [
+ "adult": [
2,
8
],
0.05,
0.2
],
- "limit": [
+ "adult": [
1,
2
],
"0.05*bw",
"0.2*bw"
],
- "limit": [
+ "adult": [
1,
2
],
"0.05*bw",
"0.2*bw"
],
- "limit": [
+ "adult": [
1,
2
],
0.25,
1
],
- "limit": [
+ "adult": [
5,
10
],
0.5,
2
],
- "limit": [
+ "adult": [
10,
20
],
"gen": true,
"dose": {
"perKg": 15,
- "limit": [
+ "adult": [
400,
800
],
5,
10
],
- "limit": [
+ "adult": [
400,
800
],
100,
"15*bw"
],
- "limit": [
+ "adult": [
4,
8
],
200,
"15*bw"
],
- "limit": [
+ "adult": [
2,
4
],
400,
"15*bw"
],
- "limit": [
+ "adult": [
1,
2
],
"content": "100mg/5ml",
"dose": {
"perKg": 0.75,
- "limit": [
+ "adult": [
20,
40
],
2.5,
5
],
- "limit": [
+ "adult": [
200,
400
],
1.25,
2.5
],
- "limit": [
+ "adult": [
100,
200
],
0.15,
0.45
],
- "limit": [
+ "adult": [
8,
8
],
},
{
"mode": "Tab",
- "content": "4",
+ "content": "4mg",
"range": [
{
"min": "3y",
0.08,
0.22
],
- "limit": [
+ "adult": [
4,
4
],
"gen": true,
"dose": [
{
- "perKg": [
- 15,
- 15
- ],
- "limit": [
+ "perKg": 15,
+ "adult": [
500,
1000
],
},
{
"perKg": 60,
- "limit": [
+ "adult": [
4000,
4000
],
"mode": "Rectal",
"gen": true,
"dose": {
- "perKg": [
- 15,
- 15
- ],
- "limit": [
+ "perKg": 15,
+ "adult": [
500,
1000
],
"mode": "IM",
"gen": true,
"dose": {
- "perKg": [
- 5,
- 5
- ],
- "limit": [
+ "perKg": 5,
+ "adult": [
500,
1000
],
"15*bw",
"15*bw"
],
- "limit": [
+ "adult": [
1,
2
],
"15*bw",
"15*bw"
],
- "limit": [
+ "adult": [
1,
1.5
],
"15*bw",
"15*bw"
],
- "limit": [
+ "adult": [
2,
4
],
"15*bw",
"15*bw"
],
- "limit": [
+ "adult": [
1,
1
],
"content":"125mg/5ml",
"dose": {
"perKg": 0.6,
- "limit": [
+ "adult": [
20,
40
],
"content":"250mg/5ml",
"dose": {
"perKg": 0.3,
- "limit": [
+ "adult": [
10,
20
],
"content":"100mg/ml",
"dose": {
"perKg": 0.15,
- "limit": [
+ "adult": [
5,
10
],
"15*bw",
"15*bw"
],
- "limit": [
+ "adult": [
4,
8
],
"15*bw",
"15*bw"
],
- "limit": [
+ "adult": [
2,
4
],
"content":"150mg/5ml",
"dose": {
"perKg": 0.03,
- "limit": [
+ "adult": [
3,
6.5
],
--- /dev/null
+{
+ "name": "Phenytoin",
+ "form": [
+ {
+ "mode": "Oral",
+ "gen": true,
+ "dose": {
+ "perKg": [
+ 5,
+ 8
+ ],
+ "adult": [
+ 150,
+ 300
+ ],
+ "unit": "mg",
+ "txt": "per day q 12 hr or single dose",
+ "comment": "Increased to max 200-400mg in adults"
+ }
+ },
+ {
+ "mode": "IV",
+ "gen": true,
+ "dose": {
+ "perKg": [
+ 15,
+ 20
+ ],
+ "unit": "mg",
+ "txt": "Loading dose @ 1mg/kg/min",
+ "comment": "diluted in NS, require cardiac monitoring"
+ }
+ },
+ {
+ "mode": "IV",
+ "gen": true,
+ "dose": [
+ {
+ "perKg": 1.25,
+ "adult":[
+ 1500,
+ 1500
+ ],
+ "unit": "mg",
+ "txt": "q 5min",
+ "comment": "Loading dose for arrythmia"
+ },
+ {
+ "perKg": 15,
+ "adult":[
+ 1500,
+ 1500
+ ],
+ "unit": "mg",
+ "txt": "",
+ "comment": "Max loading dose for arrythmia"
+ },
+ {
+ "perKg": [
+ 5,
+ 10
+ ],
+ "unit": "mg",
+ "txt": "per day q 12 hr",
+ "comment": "Maintenance dose for arrythmia"
+ }
+ ]
+ },
+ {
+ "mode": "Oral",
+ "gen": true,
+ "dose": {
+ "perKg": [
+ 5,
+ 10
+ ],
+ "unit": "mg",
+ "txt": "per day q 12 hr",
+ "comment": "Maintenance dose for arrythmia"
+ }
+ },
+ {
+ "mode": "Tab",
+ "content": "50mg",
+ "dose": {
+ "approx": [
+ 50,
+ "5*bw",
+ "8*bw"
+ ],
+ "adult": [
+ 3,
+ 6
+ ],
+ "unit": "tab",
+ "txt": ""
+ }
+ },
+ {
+ "mode": "Tab",
+ "content": "100mg",
+ "dose": {
+ "approx": [
+ 100,
+ "5*bw",
+ "8*bw"
+ ],
+ "adult": [
+ 1.5,
+ 3
+ ],
+ "unit": "tab",
+ "txt": ""
+ }
+ },
+ {
+ "mode": "Susp",
+ "content": "125mg/5ml",
+ "dose": {
+ "perKg": [
+ 0.2,
+ 0.32
+ ],
+ "adult": [
+ 6,
+ 12
+ ],
+ "unit": "ml",
+ "txt": ""
+ }
+ },
+ {
+ "mode": "Syr",
+ "content": "30mg/5ml",
+ "dose": {
+ "perKg": [
+ 0.8,
+ 1.3
+ ],
+ "adult": [
+ 25,
+ 50
+ ],
+ "unit": "ml",
+ "txt": ""
+ }
+ },
+ {
+ "mode": "IV",
+ "content": "25mg/ml",
+ "dose": {
+ "perKg": [
+ 0.6,
+ 0.8
+ ],
+ "unit": "ml",
+ "txt": ""
+ }
+ },
+ {
+ "mode": "IV",
+ "content": "50mg/ml",
+ "dose": {
+ "perKg": [
+ 0.3,
+ 0.4
+ ],
+ "unit": "ml",
+ "txt": ""
+ }
+ }
+ ]
+}
1,
2
],
- "limit": [
+ "adult": [
60,
60
],
"1*bw",
"2*bw"
],
- "limit": [
+ "adult": [
12,
12
],
"1*bw",
"2*bw"
],
- "limit": [
+ "adult": [
6,
6
],
"1*bw",
"2*bw"
],
- "limit": [
+ "adult": [
3,
3
],
"1*bw",
"2*bw"
],
- "limit": [
+ "adult": [
2,
2
],
"1*bw",
"2*bw"
],
- "limit": [
+ "adult": [
1.5,
1.5
],
1,
2
],
- "limit": [
+ "adult": [
60,
60
],
0.33,
0.66
],
- "limit": [
+ "adult": [
20,
20
],
2,
4
],
- "limit": [
+ "adult": [
300,
300
],
4,
8
],
- "limit": [
+ "adult": [
600,
600
],
1,
2
],
- "limit": [
+ "adult": [
200,
200
],
"2*bw",
"4*bw"
],
- "limit": [
+ "adult": [
2,
2
],
"2*bw",
"4*bw"
],
- "limit": [
+ "adult": [
1,
1
],
0.13,
0.26
],
- "limit": [
+ "adult": [
20,
20
],
0.04,
0.08
],
- "limit": [
+ "adult": [
8,
8
],
--- /dev/null
+{
+ "name": "Valproate",
+ "form": [
+ {
+ "mode": "Oral",
+ "gen": true,
+ "dose": [
+ {
+ "perKg": [
+ 10,
+ 15
+ ],
+ "adult": [
+ 600,
+ 600
+ ],
+ "unit": "mg",
+ "txt": "per day q 12 hr initially"
+ },
+ {
+ "perKg": [
+ 5,
+ 10
+ ],
+ "adult": [
+ 200,
+ 200
+ ],
+ "unit": "mg",
+ "txt": "per day; increment at weekly interval"
+ },
+ {
+ "perKg": 60,
+ "adult": [
+ 5000,
+ 5000
+ ],
+ "unit": "mg",
+ "txt": "per day; maximum dose",
+ "comment": "usual adult dose 1-2gm/day"
+ }
+ ]
+ },
+ {
+ "mode": "IV",
+ "gen": true,
+ "dose": [
+ {
+ "perKg": 20,
+ "unit": "mg",
+ "txt": "loading dose"
+ },
+ {
+ "perKg": [
+ 5,
+ 10
+ ],
+ "unit": "q 8 hr",
+ "txt": "maintenance dose @ 20mg/min max"
+ }
+ ]
+ }
+ ],
+ "comment": "Available forms- Tab 200mg,300mg,400mg,500mg; Syr 200mg/5ml; Inj 100mg/ml."
+}
"gen": true,
"dose": {
"perKg": 6,
- "limit": [
+ "adult": [
220,
220
],
+++ /dev/null
-/**********************************************************************
- * Title: PDosage
- * Description: Pediatric Calculator
- * Author: Agnibho Mondal
- * Website: http://code.agnibho.com
- **********************************************************************
- Copyright (c) 2016 Agnibho Mondal
- All rights reserved
- **********************************************************************
- This file is part of PDosage.
-
- PDosage is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- PDosage is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with PDosage. If not, see <http://www.gnu.org/licenses/>.
- **********************************************************************/
-
-export default function Dosage(data){
-
- Object.defineProperty(data, "prop", {
- writable: false
- });
-
- this.get=function(){
- return data;
- }
-
- this.listDrugs=function(){
- var list=data.map(function(obj){
- return obj.name;
- });
- return list;
- }
-
- this.getDrug=function(name, patient){
- if(this.listDrugs().indexOf(name)==-1){
- return null;
- }
- var drug=JSON.parse(JSON.stringify(data.filter(extract)[0]));
- function extract(obj){
- return (obj.name == name);
- }
- for(var i=0; i<drug.form.length; i++){
- drug.form[i]=calculateDose(drug.form[i], patient);
- }
- return drug;
- }
-
- function calculateDose(form, patient){
- while(form.hasOwnProperty("range")){
- var res=isolateRange(form, patient);
- delete form.range;
- if(res!=null){
- if(res.hasOwnProperty("range")){
- form.range=res.range;
- }
- else{
- form.dose=res.dose;
- }
- }
- }
- if(form.dose){
- form.dose=[].concat(form.dose);
- for(var i=0; i<form.dose.length; i++){
- if(form.dose[i].hasOwnProperty("val")){
- form.dose[i].val=[].concat(form.dose[i].val);
- }
- else if(form.dose[i].hasOwnProperty("perKg")){
- form.dose[i].perKg=[].concat(form.dose[i].perKg);
- form.dose[i].val=[];
- form.dose[i].val[0]=Math.round(parseFloat(form.dose[i].perKg[0])*parseFloat(patient.wt)*100)/100;
- form.dose[i].val[1]=Math.round(parseFloat(form.dose[i].perKg[1])*parseFloat(patient.wt)*100)/100;
- form.dose[i]=setLimit(form.dose[i]);
- }
- else if(form.dose[i].hasOwnProperty("approx")){
- form.dose[i].val=[];
- form.dose[i].val=findApprox(form.dose[i].approx);
- form.dose[i]=setLimit(form.dose[i]);
- }
- else if(form.dose[i].hasOwnProperty("eq")){
- form.dose[i].eq=[].concat(form.dose[i].eq);
- form.dose[i].val=[];
- form.dose[i].val[0]=solveEq(form.dose[i].eq[0]);
- form.dose[i].val[1]=solveEq(form.dose[i].eq[1]);
- form.dose[i]=setLimit(form.dose[i]);
- }
- else{
- form.dose[i].val=[];
- form.dose[i].val[0]=null;
- form.dose[i].val[1]=null;
- }
- }
- }
- return form;
-
- function isolateRange(form, patient){
- var min=0;
- var max=0;
- var type="";
- if(patient.age.y===null && patient.age.m===null && patient.age.d===null){
- return null;
- }
- var pDays=patient.age.y*365+patient.age.m*30+patient.age.d;
- for(var i=0; i<form.range.length; i++){
- if(form.range[i].hasOwnProperty("min")){
- if(form.range[i].min.indexOf("kg")!=-1){
- min=form.range[i].min.slice(0, str.indexOf("kg"));
- type="wt";
- }
- else{
- min=strToDays(form.range[i].min);
- type="age";
- }
- }
- else{
- min=0;
- }
- if(form.range[i].hasOwnProperty("max")){
- if(form.range[i].max.indexOf("kg")!=-1){
- max=form.range[i].max.slice(0, str.indexOf("kg"));
- type="wt";
- }
- else{
- max=strToDays(form.range[i].max);
- type="age";
- }
- }
- else{
- max=Infinity;
- }
- if(type=="wt"){
- if(patient.wt>=min && patient.wt<max){
- return form.range[i];
- }
- }
- else if(type=="age"){
- if(pDays>=min && pDays<max){
- return form.range[i];
- }
- }
- }
- return null;
-
- function strToDays(str){
- var age={y: 0, m: 0, d: 0};
- var days=0;
- str=str.replace(/\s+/g, "");
- if(str.indexOf("y")!=-1){
- age.y=str.slice(0, str.indexOf("y"));
- str=str.slice(str.indexOf("y", -1));
- }
- if(str.indexOf("m")!=-1){
- age.m=str.slice(0, str.indexOf("m"));
- str=str.slice(str.indexOf("m", -1));
- }
- if(str.indexOf("d")!=-1){
- age.d=str.slice(0, str.indexOf("d"));
- str=str.slice(str.indexOf("d", -1));
- }
- days=age.y*365+age.m*30+age.d;
- return days;
- }
- }
-
- function findApprox(arr){
- var ret=[];
- arr[0]=arr[0]/2;
- for(var i=1; i<arr.length; i++){
- arr[i]=solveEq(arr[i]);
- ret[i-1]=Math.round(arr[i]/arr[0])/2;
- }
- if(!ret[0] || (ret[0]==ret[1])){
- ret[0]=ret[1];
- ret[1]=null;
- }
- return ret;
- }
-
- function solveEq(str){
- var bw=parseFloat(patient.wt);
- var ageY=patient.age.y;
- var ageM=ageY*12+patient.age.m;
- var ageD=ageM*30+patient.age.d;
- var ret=eval(str);
- ret=Math.round(ret*100)/100;
- return ret;
- }
-
- function setLimit(dose){
- //console.log(">>"+JSON.stringify(dose));
- if(dose.limit && dose.val){
- if(dose.val[0]>dose.limit[0]){
- dose.val[0]=dose.limit[0];
- }
- if(dose.val[1]>dose.limit[1]){
- dose.val[1]=dose.limit[1];
- }
- }
- if(dose.val[1]==dose.val[0]){
- dose.val[1]=null;
- }
- return dose;
- }
- }
-}
import "bootstrap-validator";
//Backend files
-import Dosage from "./dosage.js";
+import Dosage from "./Dosage.js";
import data from "./data.json";
//Vue Components
"about-view": AboutView
},
data: {
- patient: {age: {y:null, m:null, d:null}, wt:null},
+ patient: {age: {y:30, m:null, d:null}, wt:50},
dosage: "",
favs: "[]"
},
//Insert version code
$(".version").text(VERSION);
+ $(".data-ver").text(JSON.parse(localStorage.getItem("pdosage_data")).version);
//Update copyright
$(".copyright").each(function(){