From: Agnibho Mondal Date: Tue, 28 Mar 2017 06:06:40 +0000 (+0530) Subject: Standardized routine.js X-Git-Url: https://code.agnibho.com/repo?p=pdosage.git;a=commitdiff_plain;h=4d825345792995bde18381e8cb9cf7209baa757b Standardized routine.js --- diff --git a/index.html b/index.html index b6a1203..d6d8c92 100755 --- a/index.html +++ b/index.html @@ -1,106 +1,110 @@ - - PDosage - - - - - - - - -
- - - + + PDosage + + + + + + + + +
+ + + diff --git a/prepare.js b/prepare.js index 28892c4..d16d1b4 100644 --- a/prepare.js +++ b/prepare.js @@ -3,6 +3,7 @@ var DATA_FILE="./src/data.json"; var fs=require("fs"); var bigData={id:"com.agnibho.com.pdosage.data", timestamp: Date.now(), version: 0}; +bigData.version=parseInt(new Date().toISOString().slice(0,10).replace(/-/g, ""))+0.1; if(process.argv[2]=="watch"){ fs.watch(DATA_SRC, jsonCat); diff --git a/src/data/amlodipine.json b/src/data/amlodipine.json new file mode 100644 index 0000000..b7b07f0 --- /dev/null +++ b/src/data/amlodipine.json @@ -0,0 +1,76 @@ +{ + "name": "Amlodipine", + "form": [ + { + "mode": "Oral", + "gen": true, + "dose": + { + "perKg": [ + 0.05, + 0.5 + ], + "adult": [ + 5, + 10 + ], + "unit": "mg", + "txt": "OD" + } + }, + { + "mode": "Oral", + "content": "2.5mg", + "dose": + { + "approx": [ + 2.5, + "0.05*bw", + "0.5*bw" + ], + "adult": [ + 2, + 4 + ], + "unit": "tab", + "txt": "OD" + } + }, + { + "mode": "Oral", + "content": "5mg", + "dose": + { + "approx": [ + 5, + "0.05*bw", + "0.5*bw" + ], + "adult": [ + 1, + 2 + ], + "unit": "tab", + "txt": "OD" + } + }, + { + "mode": "Oral", + "content": "10mg", + "dose": + { + "approx": [ + 10, + "0.05*bw", + "0.5*bw" + ], + "adult": [ + 0.5, + 1 + ], + "unit": "tab", + "txt": "OD" + } + } + ] +} diff --git a/src/data/azithromycin.json b/src/data/azithromycin.json new file mode 100644 index 0000000..ff60360 --- /dev/null +++ b/src/data/azithromycin.json @@ -0,0 +1,69 @@ +{ + "name": "Azithromycin", + "form": [ + { + "mode": "Oral", + "gen": true, + "range": [ + { + "min": "6m", + "max": "12y", + "dose": [ + { + "perKg": 10, + "unit": "mg", + "txt": "per day on day 1" + }, + { + "perKg": 5, + "unit": "mg", + "txt": "per day on next 4 days" + }, + { + "perKg": 30, + "unit": "mg", + "txt": "single dose" + }, + { + "perKg": 20, + "unit": "mg", + "txt": "per day x 7-14 days for enteric fever" + }, + { + "perKg": 20, + "unit": "mg", + "txt": "single dose for cholera" + } + ] + }, + { + "min": "12y", + "dose": [ + { + "val": 500, + "unit": "mg", + "txt": "OD x 3 days" + }, + { + "val": 500, + "unit": "mg", + "txt": "on day 1" + }, + { + "val": 250, + "unit": "mg", + "txt": "on day 2-5", + "comment": "total dose 1.5 gm" + }, + { + "val": 1000, + "unit": "mg", + "txt": "single dose" + } + ] + } + ] + } + ], + "comment": "Available forms- Tab 100mg,250mg,500mg; Syr 100mg/5ml,200mg/5ml" +} diff --git a/src/data/metronidazole.json b/src/data/metronidazole.json new file mode 100644 index 0000000..dce1ab2 --- /dev/null +++ b/src/data/metronidazole.json @@ -0,0 +1,77 @@ +{ + "name": "Metronidazole", + "form": [ + { + "mode": "Oral", + "gen": true, + "dose": { + "perKg": [ + 15, + 20 + ], + "adult": [ + 200, + 400 + ], + "unit": "mg", + "txt": "q 8 hr x 5-7 days for giardiasis" + } + }, + { + "mode": "Oral", + "gen": true, + "dose": { + "perKg": [ + 35, + 50 + ], + "adult": [ + 200, + 400 + ], + "unit": "mg", + "txt": "q 8 hr x 10 days for amebiasis" + } + }, + { + "mode": "Oral", + "gen": true, + "dose": { + "perKg": 20, + "adult": [ + 200, + 400 + ], + "unit": "mg", + "txt": "q 8 hr x 7-10 days for antibiotic associated diarrhea" + } + }, + { + "mode": "Oral", + "gen": true, + "dose": { + "perKg": 20, + "adult": [ + 200, + 400 + ], + "unit": "mg", + "txt": "q 6 hr for anerobic infections" + } + }, + { + "mode": "IV", + "gen": true, + "dose": { + "perKg": 20, + "adult": [ + 200, + 400 + ], + "unit": "mg", + "txt": "q 6 hr for anerobic infections" + } + } + ], + "comment": "Available forms- Tab 200mg,400mg; Susp 200mg/5ml,100mg/5ml; Inj 500mg/100ml." +} diff --git a/src/data/piperacillin_tazobactum.json b/src/data/piperacillin_tazobactum.json new file mode 100644 index 0000000..d2d798f --- /dev/null +++ b/src/data/piperacillin_tazobactum.json @@ -0,0 +1,38 @@ +{ + "name": "Piperacillin / Tazobactum", + "form": [ + { + "mode": "IV", + "gen": true, + "dose": { + "perKg": [ + 0.3, + 0.4 + ], + "adult": [ + 12, + 15 + ], + "unit": "gm", + "txt": "per day q 8 hr" + } + }, + { + "mode": "IV", + "content": "4gm/500mg", + "dose": { + "approx": [ + 4, + "0.3*bw", + "0.4*bw" + ], + "adult": [ + 3, + 3.75 + ], + "unit": "vial", + "txt": "per day q 8 hr" + } + } + ] +} diff --git a/src/main.js b/src/main.js index a2673dc..53ea071 100644 --- a/src/main.js +++ b/src/main.js @@ -8,17 +8,17 @@ 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 . **********************************************************************/ @@ -49,44 +49,45 @@ import AboutView from "./AboutView.vue"; //Start app new Vue({ - el: "#app", - components: { - "data-input": DataInput, - "quick-view": QuickView, - "list-view": ListView, - "calculator-view": CalculatorView, - "about-view": AboutView - }, - data: { - patient: {age: {y:30, m:null, d:null}, wt:50}, - dosage: "", - favs: "[]" - }, - created:function(){ - try{ - this.favs=JSON.parse(localStorage.getItem("pdosage_favs")); - } - finally{ - if(this.favs==null){ - this.favs=["Paracetamol", "Levosalbutamol", "Domperidone", "Drotaverine", "Ranitidine"]; - } - } - try{ - var loc=JSON.parse(localStorage.getItem("pdosage_data")); - if(loc.version>data.version){ - this.dosage=new Dosage(loc.dosage); - } - else{ - localStorage.setItem("pdosage_data", JSON.stringify(data)); - } - } - catch(e){ - if(!this.dosage){ - this.dosage=new Dosage(data.dosage); - localStorage.setItem("pdosage_data", JSON.stringify(data)); - } - } + el: "#app", + components: { + "data-input": DataInput, + "quick-view": QuickView, + "list-view": ListView, + "calculator-view": CalculatorView, + "about-view": AboutView + }, + data: { + patient: {age: {y:30, m:null, d:null}, wt:50}, + dosage: "", + favs: "[]" + }, + created:function(){ + try{ + this.favs=JSON.parse(localStorage.getItem("pdosage_favs")); + } + finally{ + if(this.favs==null){ + this.favs=["Paracetamol", "Levosalbutamol", "Domperidone", "Drotaverine", "Ranitidine"]; + } + } + try{ + var loc=JSON.parse(localStorage.getItem(STORAGE)); + if(loc.version>data.version){ + this.dosage=new Dosage(loc.dosage); + } + else{ + this.dosage=new Dosage(data.dosage); + localStorage.setItem(STORAGE, JSON.stringify(data)); + } + } + catch(e){ + if(!this.dosage){ + this.dosage=new Dosage(data.dosage); + localStorage.setItem(STORAGE, JSON.stringify(data)); + } } + } }); //Routine jobs diff --git a/src/routine.js b/src/routine.js index 11a4242..dd075d8 100644 --- a/src/routine.js +++ b/src/routine.js @@ -1,114 +1,145 @@ /********************************************************************** - * Title: PDosage - * Description: Pediatric Calculator + * Title: DietSurvey + * Description: Nutritional Assessment App * 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 + This file is part of DietSurvey. + + DietSurvey 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, + + DietSurvey 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 . + along with DietSurvey. If not, see . **********************************************************************/ +$.ajaxSetup({cache:false}); + $(document).ready(function(){ - //Disable cache - $.ajaxSetup({"cache": false}); - //Remove loader - $(".loader").remove(); - $(".container").fadeIn(); + //Remove loader + $(".loader").remove(); + $(".container").fadeIn(); - //Insert version code - $(".version").text(VERSION); - $(".data-ver").text(JSON.parse(localStorage.getItem("pdosage_data")).version); + //Insert version code + $(".version").text(VERSION); + try{ + $(".data-ver").text(JSON.parse(localStorage.getItem(STORAGE)).version); + } catch(e){} - //Update copyright - $(".copyright").each(function(){ - if(new Date().getFullYear()>$(this).data("start")){ - $(this).text($(this).data("start")+"-"+new Date().getFullYear()); - } - else{ - $(this).text(new Date().getFullYear()); - } - }); + //Update copyright + $(".copyright").each(function(){ + if(new Date().getFullYear()>$(this).data("start")){ + $(this).text($(this).data("start")+"-"+new Date().getFullYear()); + } + else{ + $(this).text(new Date().getFullYear()); + } + }); - //Emit input on form reset - $("input[type='reset']").on("click", function(e){ - this.form.reset(); - $(this.form).find("input, select, textarea").each(function(){ - this.dispatchEvent(new Event("input")); - }); + //Emit input on form reset + $("input[type='reset']").on("click", function(e){ + this.form.reset(); + $(this.form).find("input, select, textarea").each(function(){ + this.dispatchEvent(new Event("input")); }); + }); - //Notifications - $(window).resize(function(){ - $("#notify").width($(".container").width()-20); - }); - $(window).scroll(function(){ - $("#notify").width($(".container").width()-20); - }); + //Change focus after number input + $(".jump-focus").on("input", function(){ + if($(this).val().length == $(this).prop("maxlength")){ + var all=$("input").toArray(); + var i=all.indexOf(this)+1; + $(all[i]).focus().select(); + } + }); + + //Defocus after input finished + $(".stop-focus").on("input", function(){ + if($(this).val().length == $(this).prop("maxlength")){ + $(this).blur(); + var target=$($(this).data("ref")); + console.log($(target).offset()); + $("html, body").animate({ + scrollTop: $(target).offset().top + }, 1000); + } + }); - //Parse app info from server - $.get("https://code.agnibho.com/pdosage/info.json", function(data){ - var vCurr=VERSION.split(".").map(Number); - var vLtst=data.latest.split(".").map(Number); - - if(isBiggerThan(data.latest, VERSION)){ - $("#notify").slideDown(); - $("#notify").width($(".container").width()-20); - $("#notify-text").text("A new version of PDosage is available."); - if(document.URL.indexOf("http://")==-1 && document.URL.indexOf("https://")==-1){ - if(/(android)/i.test(navigator.userAgent)){ - $("#notify-link").attr("href", data.apk); - $("#notify-link").text("Download"); - } - else{ - $("#notify-link").attr("href", data.url); - $("#notify-link").text("Load"); - } - } - else{ - $("#notify-link").attr("href", data.url); - $("#notify-link").text("Load"); - } - } - - try{ - if(data.data.latest>JSON.parse(localStorage.getItem("pdosage_data")).version){ - $.get(data.data.src, function(d){ - localStorage.setItem("pdosage_data", JSON.stringify(d)); - }); - } - } - catch(e){} + //Use custom datepicker if Firefox + if($(".datepicker").length && navigator.userAgent.indexOf("Firefox")!=-1){ + $(".datepicker").datepicker({ + format:"yyyy-mm-dd", + autoclose:true + }).on("changeDate", function(){ + this.dispatchEvent(new Event("input")); }); + } - //Compare versions + //Notifications + $(window).resize(function(){ + $("#notify").width($(".container").width()-20); + }); + $(window).scroll(function(){ + $("#notify").width($(".container").width()-20); + }); + //Get data from server + $.get(INFO_URL, function(data){ + var vCurr=VERSION.split(".").map(Number); + var vLtst=data.latest.split(".").map(Number); + //Define version comparator function isBiggerThan(v1, v2){ - while(v1.lengthv2[i]){ - return true; - } - } - return false; + while(v1.lengthv2[i]){ + return true; + } + } + return false; + } + //Compare versions + if(NOTIFY && isBiggerThan(data.latest, VERSION)){ + $("#notify").slideDown(); + $("#notify").width($(".container").width()-20); + $("#notify-text").text("A new version of "+NAME+" is available."); + if(document.URL.indexOf("http://")==-1 && document.URL.indexOf("https://")==-1){ + if(/(android)/i.test(navigator.userAgent)){ + $("#notify-link").attr("href", data.apk); + $("#notify-link").text("Download"); + } + else{ + $("#notify-link").attr("href", data.url); + $("#notify-link").text("Load"); + } + } + else{ + $("#notify-link").attr("href", data.url); + $("#notify-link").text("Load"); + } + } + //Update app data + try{ + if(data.data.latest>JSON.parse(localStorage.getItem(STORAGE)).version){ + $.get(data.data.src, function(d){ + localStorage.setItem(STORAGE, JSON.stringify(d)); + }); + } } + catch(e){} + }); });