SimTIVA is a computer simulation program to simulate delivery of total intra
Written by Terence Luk, 2023. This work is licensed under GNU General Public License v3.0. Read more about the project here, or contact me on Twitter/X for ideas, suggestions or comments. Your advice is greatly appreciated!
This is an open source project and the source code is published on GitHub.
- Last updated 1/11/2023 (V4.1) Build 90.
+ Last updated 1/12/2023 (V4.2) Build 91.
The purposes are: (1) To simulate TCI/TIVA for educational purposes, and (2) Potentially, to help deliver TCI/TIVA in a low resource setting with no TCI pumps available. Coding is done in Javascript. The code to the mathematical calculations are based on "STANPUMP", which is freely available from the link below. The pharmacokinetic models available in this program are Marsh, Schnider, Paedfusor and Eleveld for propofol, and Minto and Eleveld for remifentanil. For instructions on using this app, visit the 'Help' page. For documentation of the pharmacological details, visit the 'Documentation' page.
@@ -450,16 +441,35 @@
SimTIVA is a computer simulation program to simulate delivery of total intra
-
LOAD SIM FILE
+
LOAD SIM FILE
- Select a SIM-FILE to load:
+ Select a SIM-FILE to load:
+
SimTIVA is a computer simulation program to simulate delivery of total intra
REMINDER - next change in
10s
-
_
+
_
@@ -1152,7 +1162,7 @@
SimTIVA is a computer simulation program to simulate delivery of total intra
PREVIEW: To achieve target
-
+
@@ -1161,7 +1171,7 @@
SimTIVA is a computer simulation program to simulate delivery of total intra
Current rate
-
Waiting to start
+
Waiting to start
diff --git a/main.js b/main.js
index b5ef68f..2b179c8 100644
--- a/main.js
+++ b/main.js
@@ -220,7 +220,12 @@ screen.orientation.addEventListener("change", (event) => {
//for tooltip destruction on touchend for mobile devices
document.addEventListener('touchend', function(event) {
if (event.target && event.target.tagName.toLowerCase() !== "canvas") {
- myChart.canvas.dispatchEvent(new Event("mouseout"));
+ if (popupon) {
+ popupchart.canvas.dispatchEvent(new Event("mouseout"));
+ } else {
+ myChart.canvas.dispatchEvent(new Event("mouseout"));
+ }
+
}
})
@@ -1723,7 +1728,7 @@ function displaypreview2(x,ind) {
preview_cpt(x,ind);
document.getElementById("preview_cpt").innerHTML = "CP " + x + drug_sets[ind].conc_units + "/ml";
if (drug_sets[ind].preview_bolus>0) {
- document.getElementById("preview_msg").innerHTML = "Bolus " + drug_sets[ind].preview_bolus + drug_sets[ind].infused_units + " (" + Math.round(drug_sets[ind].preview_bolus / drug_sets[ind].infusate_concentration * 10)/10 + "ml) then infuse at " + drug_sets[ind].preview_rate + "ml/h";
+ document.getElementById("preview_msg").innerHTML = "Bolus " + drug_sets[ind].preview_bolus + drug_sets[ind].infused_units + " (" + Math.round(drug_sets[ind].preview_bolus / drug_sets[ind].infusate_concentration * 10)/10 + "ml) " + "" + " Infuse at " + drug_sets[ind].preview_rate + "ml/h";
document.getElementById("previewicon").className = "fas fa-arrow-circle-up";
} else if (drug_sets[ind].preview_rate>0) {
document.getElementById("preview_msg").innerHTML = "Change infusion rate to " + drug_sets[ind].preview_rate + "ml/h";
@@ -3392,7 +3397,7 @@ function apply_fentanyl_correction(ind) {
//myChart.data.datasets[3].data[counterfen].y = cpt_ce[counterfen][0] + cpt_ce[counterfen][1] + cpt_ce[counterfen][2] + cpt_ce[counterfen][3];
}
//find beginning of elem of chart of working clock
- chartBeginIndex = myChart.data.datasets[ind*2+2].data.findIndex((element)=>element.x>=working_clock/60);
+ chartBeginIndex = myChart.data.datasets[ind*2+2].data.findIndex((element)=>element.x>=working_clock/60) ;
for (counterfen=chartBeginIndex; counterfen elem[0]==input_uid);
+ if (tempFileIndex != -1) {
+ parseobject(null,true,importDataArray[tempFileIndex][1]);
+ }
+ } else {
+ parseobject(input_uid);
+ }
var timestamp_lastdatadate = new Date(input_uid*1000 + time_in_s*1000);
var timestamp_lastdatatime = timestamp_lastdatadate.toLocaleDateString() + " " + timestamp_lastdatadate.toLocaleTimeString();
setTimeout(function() {
@@ -8134,6 +8164,7 @@ function reanimate(arg_time) {
//copy from common start calls
document.getElementById("top_subtitle").classList.add("topClose");
document.getElementById("top_title").classList.add("topOpen");
+ document.getElementById("expandbutton").style.display = "block";
if (complex_mode == 0) {
var argument = object.P_hx[0][0];
// 0 is manual
@@ -9316,13 +9347,46 @@ function loadobject(input_uid) {
}
function load() {
+ toLoadTransition();
+}
+
+
+function loadSourceExt() {
+ document.getElementById("rescuebuttons").style.display = "none";
+ document.getElementById("modalLoadHugeButtons").style.display = "none";
+ document.getElementById("modalLoadImportButtons").style.display = "block";
+ document.getElementById("fileselection").style.display = "block";
+ document.getElementById("modalLoadDescription").style.display = "inline";
+ document.getElementById("modalLoadDescription").innerHTML = "Import from external .CSV file:";
+ document.getElementById("loadfile_container").classList.add("collapse");
+ document.getElementById("loadfile_container").classList.remove("compress");
+ document.getElementById("loadfile_container").style.display = "block";
+ document.getElementById("loadfile_container").innerHTML =
+ `
+
After loading, the database of external sim-files will appear here.
+ `
+ //document.getElementById("loadfile_container").style.display = "block";
+ //importDialog();
+}
+
+function loadSourceLocal() {
if ((localStorage.getItem("keys") == null) || (JSON.parse(localStorage.getItem("keys")).length == 0)) {
displayWarning("No saved data", "No previously saved sim-file data.")
} else {
generateFileKeys();
- toLoadTransition();
document.getElementById("rescuebuttons").style.display = "none";
+ document.getElementById("modalLoadHugeButtons").style.display = "none";
+ document.getElementById("fileselection").style.display = "none";
+ document.getElementById("modalLoadNormalButtons").style.display = "block";
+ document.getElementById("modalLoadDescription").style.display = "inline";
+ document.getElementById("loadfile_container").classList.remove("collapse");
+ document.getElementById("loadfile_container").classList.remove("compress");
+ document.getElementById("loadfile_container").style.display = "block";
+
+ importDataArray.length = 0;
+
}
+
}
function rescue() {
@@ -9347,10 +9411,25 @@ function generateFileKeys() {
}
function renderImportList() {
- let El1 = document.getElementById("filecontent");
- for (impcountr = 0; impcountr=0; i--) {
tempObject = loadobject(inputkeysarray[i]);
@@ -9486,13 +9565,13 @@ function renderFileList(inputkeysarray) {
El2.setAttribute('data-duration', tempDuration);
if (isComplex == 0) {
if (tempObject.name != "") {
- El2.setAttribute('style', 'height:88px');
+ El2.setAttribute('style', 'height:90px');
}
} else {
if (tempObject.name != "") {
- El2.setAttribute('style', 'height:104px');
+ El2.setAttribute('style', 'height:107px');
} else {
- El2.setAttribute('style', 'height:88px');
+ El2.setAttribute('style', 'height:90px');
}
}
if (isComplex == 0) {
@@ -9634,9 +9713,27 @@ async function downloadExcel() {
}
*/
+let inputname = "";
+
function exportFunction() {
- if (confirm("This will export all the Sim-Files on device to a .csv (comma-separated values) file. You can then open this file in Excel or other spreadsheet application.")) {
- exportKeys();
+ //reset inputname
+ inputname = "";
+ testKeys = JSON.parse(localStorage.getItem("keys"));
+ if (testKeys.length>=1) {
+ displayWarning("Export sim-files to CSV",
+ `
+
This will export all ${testKeys.length} sim-files on device to a .csv (comma-separated values) file. You can then open this file in Excel or other spreadsheet application. You may also import this database file into SimTIVA for viewing.