-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
234 lines (208 loc) · 7.39 KB
/
Copy pathindex.html
File metadata and controls
234 lines (208 loc) · 7.39 KB
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="theme-color" content="#151515">
<link rel="stylesheet" href="./style.css">
<title>TI-RADS Impressionizer</title>
<meta name="author" content="Felix Jin">
<meta name="description" content="A tool to generate impressions from TI-RADS findings.">
<meta name="keywords" content="TI-RADS, findings, impression, converter">
<link rel="canonical" href="https://fqjin.github.io/tirads/">
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-VELLK8VVEV"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-VELLK8VVEV');
</script>
<script>
async function parseText() {
let inputText = document.getElementById("findings").value;
if (inputText == "") {
try {
inputText = await navigator.clipboard.readText();
} catch (err) {
document.getElementById("impression").innerText = `${err}`;
tailShown = false;
return
}
}
inputText = inputText.replace(/\r\n/g, "\n");
const idxStart = inputText.search(/Nodule\s*\d:/);
const idxEnd = inputText.search(/impression:/i);
if (idxStart == -1) {
document.getElementById("impression").innerText = "No nodules detected.";
tailShown = false;
return
}
const trimmedText = (idxEnd == -1) ?
inputText.substring(idxStart) :
inputText.substring(idxStart, idxEnd);
const dataArray = trimmedText.split(/Nodule\s*(\d):/).slice(1);
if (dataArray.length % 2 !== 0) {
document.getElementById("impression").innerText = "Something went wrong.";
tailShown = false;
return
}
const regexSize = /Size:\s*([\d.]+)\s*x\s*([\d.]+)\s*x\s*([\d.]+)\s*cm/;
const regexLoc = /Location:(.+)\n/;
const regexTIRADS = /ACR TI-RADS category: TR(\d)/;
const regexBiopsy = /Prior biopsy:(.+)\n/;
let results = [];
results.push("TIRADS assessment of thyroid nodules:");
for (let i = 0; i < dataArray.length; i += 2) {
const noduleNumber = dataArray[i];
const noduleData = dataArray[i+1] + "\n";
let size, loc, tirads, biopsy, rec;
match = regexSize.exec(noduleData);
if (match) {
size = match.slice(1).sort((a, b) => Number(a) - Number(b)).slice(-1);
} else {
size = "unknown";
}
match = regexLoc.exec(noduleData);
if (match) {
loc = match[1].trim().replace(/ +/g, ' ');
if (loc.endsWith('.')) {
loc = loc.slice(0,-1);
}
} else {
loc = "unknown location";
}
match = regexTIRADS.exec(noduleData);
if (match) {
tirads = match[1];
} else {
tirads = " unknown";
}
match = regexBiopsy.exec(noduleData);
if (match) {
biopsy = match[1].trim().replace(/ +/g, ' ');
if (biopsy.endsWith('.')) {
biopsy = biopsy.slice(0,-1);
}
if (biopsy.slice(0,2).toLowerCase() == "no" || biopsy.slice(0,7).toLowerCase() == "unknown") {
rec = "Recommend: " + getRecommendation(size, tirads);
} else if (biopsy.slice(0,3).toLowerCase() == "yes") {
rec = `Previously biopsied ${biopsy.slice(4).trimStart()}. Follow up as clinically indicated`;
} else {
rec = `Previously biopsied ${biopsy}. Follow up as clinically indicated`;
}
} else {
rec = "Missing prior biopsy info";
}
results.push(` Nodule ${noduleNumber}, ${loc}. ACR TI-RADS TR${tirads}. Size: ${size} cm. ${rec}.\n`);
}
results = results.join("\n");
document.getElementById("impression").innerText = results;
tailShown = false;
}
function getRecommendation(size, tirads) {
size = parseFloat(size);
if (isNaN(size)) {
return "unknown size"
}
switch (parseInt(tirads)) {
case 1:
return "No further follow-up"
case 2:
return "No further follow-up"
case 3:
if (size < 1.5) {
return "No further follow-up"
} else if (size < 2.5) {
return "Follow-up ultrasound in 1 year"
} else {
return "Ultrasound-guided fine needle aspiration"
}
case 4:
if (size < 1.0) {
return "No further follow-up"
} else if (size < 1.5) {
return "Follow-up ultrasound in 1 year"
} else {
return "Ultrasound-guided fine needle aspiration"
}
case 5:
if (size < 0.5) {
return "No further follow-up"
} else if (size < 1.0) {
return "Follow-up ultrasound in 1 year"
} else {
return "Ultrasound-guided fine needle aspiration"
}
}
return "unknown TI-RADS"
}
function copyToClipboard() {
const impression = document.getElementById("impression").innerText;
navigator.clipboard.writeText(impression);
}
const tail = `
Other non-TIRADS findings: None
---------------------------------------------------------------------------------------
ACR TI-RADS recommendations
TR5 (≥7 points) - FNA if ≥ 1cm, follow-up annually if ≥ 0.5 cm
TR4 (4-6 points) - FNA if ≥ 1.5 cm, follow-up at 1, 2, 3, and 5 years if ≥ 1.0 cm
TR3 (3 points)- FNA if ≥ 2.5cm, follow-up at 1, 3, and 5 years if ≥ 1.5 cm
TR2 (2 points) & TR1 (0 points) - No FNA or follow-up
* ACR TI-RADS recommends that no more than two nodules with the highest ACR TI-RADS total point should be biopsied and no more than four nodules should be followed.
** TI-RADS recommendations are based on TI-RADS level. Management decisions such as whether to perform FNA and whether to follow up a nodule may differ from the TI-RADS recommendation based on clinician judgement, patient preference, risk factors for thyroid cancer, comorbidities, life expectancy and other considerations.`;
let tailShown = false;
function toggleTail() {
let impression = document.getElementById("impression").innerText;
if (tailShown) {
document.getElementById("impression").innerText = impression.slice(0, -tail.length);
tailShown = false;
} else {
document.getElementById("impression").innerText = impression + tail;
tailShown = true;
}
}
function clearText() {
document.getElementById("findings").value = "";
document.getElementById("impression").innerText = "";
tailShown = false;
}
</script>
</head>
<body>
<div class="container">
<header>
<div id="logo">
<img src="https://edge.sitecorecloud.io/americancoldf5f-acrorgf92a-productioncb02-3650/media/ACR/Images/Logos/1x1/RADS/ACR-TI-RADS.png" alt="Thyroid logo" width=100px height=100px>
</div>
<a id="a-title" href="https://fqjin.github.io/tirads/">
<h1>TI-RADS Impressionizer</h1>
</a>
<h2>A tool to generate impressions from TI-RADS findings.</h2>
</header>
<section id="main_content">
<p>Paste findings below:</p>
<textarea id="findings" placeholder="TI-RADS findings
Leaving this blank will pull from the clipboard" rows=15 cols=64></textarea>
<br>
<button type="button" class="btn" onclick=parseText()>Convert</button>
<button type="button" class="btn" onclick=copyToClipboard()>Copy to Clipboard</button>
<button type="button" class="btn" onclick=toggleTail()>Toggle Footer</button>
<button type="button" class="btn" onclick=clearText()>Clear</button>
<p>Generated impression:</p>
<div id="impression"></div>
<br>
<br>
</section>
<footer>
<p>
The information provided on this site is intended for educational and informational purposes only and does not constitute providing medical advice or professional services.
No material on this site is intended to be a substitute for professional medical advice, diagnosis or treatment.
TI-RADS and logo are trademarks of the American College of Radiology (ACR).
This site is not associated with or endorsed by the ACR.
<a href="https://github.com/fqjin/tirads">Source</a>
</p>
</footer>
</div>
</body>
</html>