diff --git a/src/bilirubin_app.js b/src/bilirubin_app.js index f5d8009..ecd15fc 100644 --- a/src/bilirubin_app.js +++ b/src/bilirubin_app.js @@ -1,6 +1,6 @@ /* Neonatal jaundice treatment threshold calculator - Copyright (C) 2024 Lee Yingtong Li + Copyright (C) 2024-2025 Lee Yingtong Li This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by @@ -26,8 +26,8 @@ function plotGraphData() { chart.data.datasets[0].data = []; chart.data.datasets[1].data = []; } else { - chart.data.datasets[0].data = [...Array(14*24).keys()].map((i) => i / 24).map((d) => ({x: d, y: phototherapy_thresh(d, gestation)})); - chart.data.datasets[1].data = [...Array(14*24).keys()].map((i) => i / 24).map((d) => ({x: d, y: exchange_thresh(d, gestation)})); + chart.data.datasets[0].data = [...Array(14*24).keys()].map((i) => i / 24).map((d) => ({x: d, y: nice_phototherapy_thresh(d, gestation)})); + chart.data.datasets[1].data = [...Array(14*24).keys()].map((i) => i / 24).map((d) => ({x: d, y: nice_exchange_thresh(d, gestation)})); } chart.update(); diff --git a/src/bilirubin_lib.js b/src/bilirubin_lib.js index 1f5606e..e4b3712 100644 --- a/src/bilirubin_lib.js +++ b/src/bilirubin_lib.js @@ -1,6 +1,6 @@ /* Neonatal jaundice treatment threshold calculator - Copyright (C) 2024 Lee Yingtong Li + Copyright (C) 2024-2025 Lee Yingtong Li This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by @@ -16,10 +16,10 @@ along with this program. If not, see . */ -// ---------------------- -// Threshold calculations +// ----------------------------- +// Threshold calculations (NICE) -function phototherapy_38wks(d) { +function nice_phototherapy_38wks(d) { if (d <= 0) { return 100; } @@ -32,7 +32,7 @@ function phototherapy_38wks(d) { return 350; } -function exchange_38wks(d) { +function nice_exchange_38wks(d) { if (d <= 0) { return 100; } @@ -42,9 +42,9 @@ function exchange_38wks(d) { return 450; } -function phototherapy_thresh(d, gestation) { +function nice_phototherapy_thresh(d, gestation) { if (gestation >= 38) { - return phototherapy_38wks(d); + return nice_phototherapy_38wks(d); } if (gestation < 23) { throw new Error('Invalid gestation'); @@ -59,9 +59,9 @@ function phototherapy_thresh(d, gestation) { return thresh_at_3days; } -function exchange_thresh(d, gestation) { +function nice_exchange_thresh(d, gestation) { if (gestation >= 38) { - return exchange_38wks(d); + return nice_exchange_38wks(d); } if (gestation < 23) { throw new Error('Invalid gestation'); @@ -83,8 +83,8 @@ function describeBilirubin(gestation, dateBirth, dateMeasurement, bilirubin) { // Chronological age in days let d = (dateMeasurement.getTime() - dateBirth.getTime()) / 1000 / 60 / 60 / 24; - let phototherapy_thresh_value = phototherapy_thresh(d, gestation); - let exchange_thresh_value = exchange_thresh(d, gestation); + let phototherapy_thresh_value = nice_phototherapy_thresh(d, gestation); + let exchange_thresh_value = nice_exchange_thresh(d, gestation); // Restate colours separately so Tailwind can detect them let result_text, text_colour, background_colour, accent_colour; diff --git a/src/index.html b/src/index.html index aaa03ac..43d89fd 100644 --- a/src/index.html +++ b/src/index.html @@ -1,26 +1,24 @@ + - - - Neonatal jaundice treatment threshold calculator @@ -67,7 +65,7 @@

Treatment thresholds as per: National Institute for Health and Clinical Excellence. Neonatal jaundice treatment threshold graphs. In: Jaundice in newborn babies under 28 days. London: National Institute for Health and Clinical Excellence; 2023. (NICE clinical guidelines; CG98). https://www.nice.org.uk/guidance/cg98

This tool is made available 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. Information provided in this tool is intended for reference by medical professionals. Nothing in this tool is intended to constitute medical advice.

-

Lee Yingtong Li, 2024. Source code available at https://yingtongli.me/git/bilirubin-calculator.

+

Lee Yingtong Li, 2024–2025. Source code available at https://yingtongli.me/git/bilirubin-calculator.

diff --git a/tests/thresholds.test.js b/tests/thresholds_nice.test.js similarity index 96% rename from tests/thresholds.test.js rename to tests/thresholds_nice.test.js index b484cbf..027d86f 100644 --- a/tests/thresholds.test.js +++ b/tests/thresholds_nice.test.js @@ -1,6 +1,6 @@ /* Neonatal jaundice treatment threshold calculator - Copyright (C) 2024 Lee Yingtong Li + Copyright (C) 2024-2025 Lee Yingtong Li This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by @@ -51,7 +51,7 @@ suite('Phototherapy thresholds vs NICE', () => { test('Phototherapy thresholds at >= 38 weeks', () => { for (let gestation = 42; gestation >= 38; gestation--) { for (let i = 0, d = 0; d <= 14; i += 1, d += 0.25) { - assert(nearlyEqual(phototherapy_thresh(d, gestation), expected_phototherapy[38][i], 0.5)); + assert(nearlyEqual(nice_phototherapy_thresh(d, gestation), expected_phototherapy[38][i], 0.5)); } } }); @@ -59,7 +59,7 @@ suite('Phototherapy thresholds vs NICE', () => { for (let gestation = 37; gestation >= 23; gestation--) { test('Phototherapy thresholds at ' + gestation + ' weeks', () => { for (let i = 0, d = 0; d <= 14; i += 1, d += 0.25) { - assert(nearlyEqual(phototherapy_thresh(d, gestation), expected_phototherapy[gestation >= 38 ? 38 : gestation][i], 0.5)); + assert(nearlyEqual(nice_phototherapy_thresh(d, gestation), expected_phototherapy[gestation >= 38 ? 38 : gestation][i], 0.5)); } }); } @@ -89,7 +89,7 @@ suite('Exchange therapy thresholds vs NICE', () => { test('Exchange transfusion thresholds at >= 38 weeks', () => { for (let gestation = 42; gestation >= 38; gestation--) { for (let i = 0, d = 0; d <= 14; i += 1, d += 0.25) { - assert(nearlyEqual(exchange_thresh(d, gestation), expected_exchange[38][i], 0.5)); + assert(nearlyEqual(nice_exchange_thresh(d, gestation), expected_exchange[38][i], 0.5)); } } }); @@ -97,7 +97,7 @@ suite('Exchange therapy thresholds vs NICE', () => { for (let gestation = 37; gestation >= 23; gestation--) { test('Exchange transfusion thresholds at ' + gestation + ' weeks', () => { for (let i = 0, d = 0; d <= 14; i += 1, d += 0.25) { - assert(nearlyEqual(exchange_thresh(d, gestation), expected_exchange[gestation >= 38 ? 38 : gestation][i], 0.5)); + assert(nearlyEqual(nice_exchange_thresh(d, gestation), expected_exchange[gestation >= 38 ? 38 : gestation][i], 0.5)); } }); }