-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo-index.html
142 lines (135 loc) · 5.65 KB
/
demo-index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>HERALD Demo</title>
</head>
<body>
<div id="ghdmContent"></div>
<script>
/**
* Function to load a script
*/
function loadScript(url, callback) {
const script = document.createElement('script');
script.type = 'text/javascript';
script.src = url;
script.onload = () => {
if (callback) {
callback();
}
};
script.onerror = () => {
console.error(`Failed to load script: ${url}`);
};
document.head.appendChild(script);
}
// Define test data set to be loaded based on selected application use case in home.html
function getQueryVariable(variable) {
var query = window.location.search.substring(1);
var vars = query.split('&');
for (var i = 0; i < vars.length; i++) {
var pair = vars[i].split('=');
if (decodeURIComponent(pair[0]) == variable) {
return decodeURIComponent(pair[1]);
}
}
}
let caseKey = getQueryVariable("usecase");
let dataUrl;
let jsonData;
let predefinedQueries = [];
switch (caseKey) {
default:
case "case1":
dataUrl = 'data/cohort-comparison-chd-t2d.json';
predefinedQueries = [
['FirstDiag', 'FIRST (LABEL = "*Diabetes*" OR LABEL = "*Coronary Heart Disease*") AFTER (1980-01-01)'],
['Comorbidities', 'EXISTS (LABEL = "*Diabetes*") AND EXISTS (LABEL = "*Coronary Heart Disease*")'],
['BodyMassIndex', 'AVERAGE (LABEL = "*Body Mass Index*" AND UNIT = "*kg/m2*") CLOSE TO ("FirstDiag") BY 6 MONTHS'],
['LDLCholesterol', 'FIRST (LABEL = "*Low Density Lipoprotein Cholesterol*" AND UNIT = "*mg/dL*") AFTER ("FirstDiag") BY 4 WEEKS'],
['HDLCholesterol', 'ANY (LABEL = "*High Density Lipoprotein Cholesterol*" AND UNIT = "*mg/dL*") CLOSE TO ("LDLCholesterol") BY 1 DAY'],
['CholesterolRatio', 'RATIO BETWEEN ("LDLCholesterol") AND ("HDLCholesterol")']
];
break;
case "case2":
dataUrl = 'data/cohort-comparison-alzheimers.json';
predefinedQueries = [
[`Alzheimer'sDiagnosis`, `FIRST (LABEL = "*Alzheimer's disease (disorder)*" OR LABEL = "*Familial Alzheimer's disease of early onset (disorder)*")`],
['PneumoniaDiagnosis', 'FIRST (LABEL = "*Pneumonia*")'],
['FirstScoreMMSE', 'FIRST (LABEL = "*Total score MMSE*")'],
['LastScoreMMSE', 'LAST (LABEL = "*Total score MMSE*")'],
['ModerateScoreMMSE', 'FIRST (LABEL = "*Total score MMSE*" AND VALUE > "10" AND VALUE <= "20")'],
['SevereScoreMMSE', 'FIRST (LABEL = "*Total score MMSE*" AND VALUE <= "10")'],
['Medications', 'MOST FREQUENT (LABEL = "*Medications*")'],
['CarePlans', 'ANY (LABEL = "*Care Plans*")']
];
break;
case "case3":
dataUrl = 'data/cohort-comparison-lung-cancer.json';
predefinedQueries = [
['FirstCancerDiagnosis', 'FIRST (LABEL = "*Diagnosis*")'],
['FirstChemoRadio', 'FIRST (LABEL = "*Combined chemotherapy and radiation therapy (procedure)*")'],
['LastChemoRadio', 'LAST (LABEL = "*Combined chemotherapy and radiation therapy (procedure)*")'],
['CountChemoRadio', 'COUNT (LABEL = "*Combined chemotherapy and radiation therapy (procedure)*")'],
['MedicationChemoRadio', 'ANY (LABEL = "*Medications*") CLOSE TO ("FirstChemoRadio") BY 1 DAY'],
['HemoFirstChemo', 'ANY (LABEL = "*Hemoglobin A1c/Hemoglobin.total in Blood*") BEFORE ("FirstChemoRadio") BY 1 WEEK'],
['HemoLastChemo', 'ANY (LABEL = "*Hemoglobin A1c/Hemoglobin.total in Blood*") BEFORE ("LastChemoRadio") BY 1 WEEK'],
['GlucoseFirstChemo', 'ANY (LABEL = "*Glucose*") BEFORE ("FirstChemoRadio") BY 1 WEEK'],
['GlucoseLastChemo', 'ANY (LABEL = "*Glucose*") BEFORE ("LastChemoRadio") BY 1 WEEK']
];
break;
}
// If inside of iFrame
if (window !== window.parent) {
window.addEventListener("message", (event) => {
// Chain of relevant setup functions
loadScript("demo-logic.js", () => ghdmLoadStyles(() => ghdmLoadContent(() => ghdmLoadScripts(() => ghdmMain(event.data)))));
});
// Standalone deployment
} else {
// Chain of relevant setup functions
new Promise((resolve, reject) => {
fetch(dataUrl)
.then(data => {
if (!data.ok) {
throw new Error("HTTP error " + data.status);
}
return data.json();
})
.then(
jsonData => {
loadScript("js/ghdm-data.js",
() => loadScript("js/demo-logic.js",
() => ghdmLoadStyles(
() => ghdmLoadContent(
() => ghdmLoadScripts(
() => {
pluginMain(GHDM.parseJSONDataTypes(jsonData));
// Inject predined queries
predefinedQueries.forEach(queryTuple => {
HeraldUI.setLabelAndQueryManually(queryTuple[0], queryTuple[1]);
});
}
)
)
)
)
)}
)
.catch(error => {
console.log("Fetch error: JSON data could not be fetched " + error);
});
});
}
</script>
</body>
<style>
@media only screen and (max-width: 768px) {
body {
min-width: 1024px;
}
}
</style>
</html>