ceddcozum 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +51 -66
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -14337,7 +14337,8 @@ function calculateSyndromeSpecificSDSByDataset(value, age, sex, datasetId, measu
|
|
|
14337
14337
|
|
|
14338
14338
|
// ../src/lib/calculators/unified-sds.ts
|
|
14339
14339
|
function calculateLMSBasedSDS(value, L, M, S, applySD23 = false) {
|
|
14340
|
-
if (value
|
|
14340
|
+
if (!Number.isFinite(value) || !Number.isFinite(M) || !Number.isFinite(S)) return NaN;
|
|
14341
|
+
if (value <= 0 || M <= 0 || S <= 0) return NaN;
|
|
14341
14342
|
let sds;
|
|
14342
14343
|
if (Math.abs(L) < 1e-7) {
|
|
14343
14344
|
sds = Math.log(value / M) / S;
|
|
@@ -14351,7 +14352,8 @@ function calculateLMSBasedSDS(value, L, M, S, applySD23 = false) {
|
|
|
14351
14352
|
return sds;
|
|
14352
14353
|
}
|
|
14353
14354
|
function calculateMeanSDBasedSDS(value, mean, sd) {
|
|
14354
|
-
if (
|
|
14355
|
+
if (!Number.isFinite(value) || !Number.isFinite(mean) || !Number.isFinite(sd)) return NaN;
|
|
14356
|
+
if (sd <= 0) return NaN;
|
|
14355
14357
|
return (value - mean) / sd;
|
|
14356
14358
|
}
|
|
14357
14359
|
function applySD23Correction(sds, L, M, S) {
|
|
@@ -14391,6 +14393,7 @@ function calculateValueForSDS(sds, L, M, S) {
|
|
|
14391
14393
|
}
|
|
14392
14394
|
}
|
|
14393
14395
|
function sdsToPercentile(sds) {
|
|
14396
|
+
if (Number.isNaN(sds)) return NaN;
|
|
14394
14397
|
const minSDS = PERCENTILE_SDS_LOOKUP[0].sds;
|
|
14395
14398
|
const maxSDS = PERCENTILE_SDS_LOOKUP[PERCENTILE_SDS_LOOKUP.length - 1].sds;
|
|
14396
14399
|
if (sds < minSDS) {
|
|
@@ -17365,26 +17368,45 @@ function findCorrectedBmdBand(sex, age) {
|
|
|
17365
17368
|
}
|
|
17366
17369
|
|
|
17367
17370
|
// ../src/lib/calculators/corrected-bmd.ts
|
|
17368
|
-
|
|
17369
|
-
|
|
17370
|
-
return
|
|
17371
|
+
var CORRECTED_BMD_SITES_WITH_REFERENCE = ["spine"];
|
|
17372
|
+
function siteHasReference(site) {
|
|
17373
|
+
return CORRECTED_BMD_SITES_WITH_REFERENCE.includes(site);
|
|
17374
|
+
}
|
|
17375
|
+
function calculateKatzmanX(bmc, area, site = "spine", heightCm) {
|
|
17376
|
+
if (!Number.isFinite(bmc) || !Number.isFinite(area) || bmc <= 0 || area <= 0) return NaN;
|
|
17377
|
+
switch (site) {
|
|
17378
|
+
case "spine":
|
|
17379
|
+
return bmc / Math.pow(area, 1.5);
|
|
17380
|
+
case "radiusNeck":
|
|
17381
|
+
return bmc / Math.pow(area, 2);
|
|
17382
|
+
case "wholeBody":
|
|
17383
|
+
if (!Number.isFinite(heightCm) || heightCm <= 0) return NaN;
|
|
17384
|
+
return bmc * heightCm / Math.pow(area, 2);
|
|
17385
|
+
}
|
|
17371
17386
|
}
|
|
17372
17387
|
function calculateCorrectedBmdSds(input) {
|
|
17373
|
-
const { bmc, area, age, sex } = input;
|
|
17374
|
-
|
|
17375
|
-
|
|
17388
|
+
const { bmc, area, age, sex, site = "spine", heightCm } = input;
|
|
17389
|
+
const xValue = calculateKatzmanX(bmc, area, site, heightCm);
|
|
17390
|
+
if (!Number.isFinite(xValue)) return null;
|
|
17391
|
+
if (!siteHasReference(site)) {
|
|
17392
|
+
return {
|
|
17393
|
+
xValue,
|
|
17394
|
+
site,
|
|
17395
|
+
sds: null,
|
|
17396
|
+
percentile: null,
|
|
17397
|
+
referenceMedian: null,
|
|
17398
|
+
referenceSd: null,
|
|
17399
|
+
ageBandRange: ""
|
|
17400
|
+
};
|
|
17376
17401
|
}
|
|
17377
17402
|
const band = findCorrectedBmdBand(sex, age);
|
|
17378
|
-
if (!band)
|
|
17379
|
-
return null;
|
|
17380
|
-
}
|
|
17381
|
-
const xValue = calculateKatzmanX(bmc, area);
|
|
17403
|
+
if (!band) return null;
|
|
17382
17404
|
const sds = calculateMeanSDBasedSDS(xValue, band.median, band.sd);
|
|
17383
|
-
const percentile = sdsToPercentile(sds);
|
|
17384
17405
|
return {
|
|
17385
17406
|
xValue,
|
|
17386
|
-
|
|
17387
|
-
|
|
17407
|
+
site,
|
|
17408
|
+
sds: Number.isFinite(sds) ? sds : null,
|
|
17409
|
+
percentile: Number.isFinite(sds) ? sdsToPercentile(sds) : null,
|
|
17388
17410
|
referenceMedian: band.median,
|
|
17389
17411
|
referenceSd: band.sd,
|
|
17390
17412
|
ageBandRange: `${band.start}\u2013${band.end}`
|
|
@@ -24896,26 +24918,6 @@ function findPercentileAndSDS(measuredBP, percentileCurve) {
|
|
|
24896
24918
|
sdsDisplay: sds.toFixed(2)
|
|
24897
24919
|
};
|
|
24898
24920
|
}
|
|
24899
|
-
function classifyBP(age, measured, percentile, p95, type) {
|
|
24900
|
-
if (age >= 13) {
|
|
24901
|
-
if (type === "systolic") {
|
|
24902
|
-
if (measured < 120) return "normal";
|
|
24903
|
-
if (measured < 130) return "elevated";
|
|
24904
|
-
if (measured < 140) return "stage1";
|
|
24905
|
-
return "stage2";
|
|
24906
|
-
} else {
|
|
24907
|
-
if (measured < 80) return "normal";
|
|
24908
|
-
if (measured < 80) return "elevated";
|
|
24909
|
-
if (measured < 90) return "stage1";
|
|
24910
|
-
return "stage2";
|
|
24911
|
-
}
|
|
24912
|
-
} else {
|
|
24913
|
-
if (percentile < 90) return "normal";
|
|
24914
|
-
if (percentile < 95 || measured < 120) return "elevated";
|
|
24915
|
-
if (measured < p95 + 12 || type === "systolic" && measured < 140 || type === "diastolic" && measured < 90) return "stage1";
|
|
24916
|
-
return "stage2";
|
|
24917
|
-
}
|
|
24918
|
-
}
|
|
24919
24921
|
function calculateRosner2008BP(sex, ageYears, heightCm, systolicMeasured, diastolicMeasured) {
|
|
24920
24922
|
if (!(ageYears > 0) || !(heightCm > 0)) return null;
|
|
24921
24923
|
if (ageYears > 17) return null;
|
|
@@ -24960,13 +24962,6 @@ function calculateRosner2008BP(sex, ageYears, heightCm, systolicMeasured, diasto
|
|
|
24960
24962
|
const diastolic75 = dbpCurve.find((p) => p.percentile === 75)?.bp || 73;
|
|
24961
24963
|
const diastolic90 = dbpCurve.find((p) => p.percentile === 90)?.bp || 76;
|
|
24962
24964
|
const diastolic95 = dbpCurve.find((p) => p.percentile === 95)?.bp || 80;
|
|
24963
|
-
const systolicCategory = classifyBP(ageYears, systolicMeasured, systolicResult.percentile, systolic95, "systolic");
|
|
24964
|
-
const diastolicCategory = classifyBP(ageYears, diastolicMeasured, diastolicResult.percentile, diastolic95, "diastolic");
|
|
24965
|
-
const categoryOrder = ["normal", "elevated", "stage1", "stage2"];
|
|
24966
|
-
const overallCategory = categoryOrder[Math.max(
|
|
24967
|
-
categoryOrder.indexOf(systolicCategory),
|
|
24968
|
-
categoryOrder.indexOf(diastolicCategory)
|
|
24969
|
-
)];
|
|
24970
24965
|
return {
|
|
24971
24966
|
systolic: {
|
|
24972
24967
|
measured: Math.floor(systolicMeasured),
|
|
@@ -24981,9 +24976,8 @@ function calculateRosner2008BP(sex, ageYears, heightCm, systolicMeasured, diasto
|
|
|
24981
24976
|
p75: Math.floor(systolic75),
|
|
24982
24977
|
p90: Math.floor(systolic90),
|
|
24983
24978
|
p95: Math.floor(systolic95),
|
|
24984
|
-
p95Plus12: Math.floor(systolic95) + 12
|
|
24979
|
+
p95Plus12: Math.floor(systolic95) + 12
|
|
24985
24980
|
// Floor p95 first, then add 12
|
|
24986
|
-
category: systolicCategory
|
|
24987
24981
|
},
|
|
24988
24982
|
diastolic: {
|
|
24989
24983
|
measured: Math.floor(diastolicMeasured),
|
|
@@ -24998,11 +24992,9 @@ function calculateRosner2008BP(sex, ageYears, heightCm, systolicMeasured, diasto
|
|
|
24998
24992
|
p75: Math.floor(diastolic75),
|
|
24999
24993
|
p90: Math.floor(diastolic90),
|
|
25000
24994
|
p95: Math.floor(diastolic95),
|
|
25001
|
-
p95Plus12: Math.floor(diastolic95) + 12
|
|
24995
|
+
p95Plus12: Math.floor(diastolic95) + 12
|
|
25002
24996
|
// Floor p95 first, then add 12
|
|
25003
|
-
category: diastolicCategory
|
|
25004
24997
|
},
|
|
25005
|
-
overallCategory,
|
|
25006
24998
|
modelDetails: {
|
|
25007
24999
|
ageHeightInteraction,
|
|
25008
25000
|
heightSpline,
|
|
@@ -27882,28 +27874,13 @@ function executeBloodPressure(args) {
|
|
|
27882
27874
|
const diastolic = Number(args.diastolic);
|
|
27883
27875
|
const result = calculateRosner2008BP(sex, ageYears, heightCm, systolic, diastolic);
|
|
27884
27876
|
if (!result) return [{ label: "Error", value: "Could not calculate BP percentiles. Age must be 1-18 years.", severity: "severe" }];
|
|
27885
|
-
const categoryLabel = (cat) => {
|
|
27886
|
-
switch (cat) {
|
|
27887
|
-
case "normal":
|
|
27888
|
-
return "Normal";
|
|
27889
|
-
case "elevated":
|
|
27890
|
-
return "Elevated";
|
|
27891
|
-
case "stage1":
|
|
27892
|
-
return "Stage 1 HTN";
|
|
27893
|
-
case "stage2":
|
|
27894
|
-
return "Stage 2 HTN";
|
|
27895
|
-
default:
|
|
27896
|
-
return cat;
|
|
27897
|
-
}
|
|
27898
|
-
};
|
|
27899
27877
|
return [
|
|
27900
27878
|
patientRow({ age: ageYears, sex }),
|
|
27901
27879
|
{ label: "Height", value: heightCm.toFixed(1), unit: "cm" },
|
|
27902
27880
|
{ label: "Systolic", value: `${systolic} mmHg \u2014 ${result.systolic.percentileDisplay}p (SDS ${result.systolic.sdsDisplay})` },
|
|
27903
27881
|
{ label: "SBP Thresholds", value: `P50: ${result.systolic.p50} | P90: ${result.systolic.p90} | P95: ${result.systolic.p95} | P95+12: ${result.systolic.p95Plus12}` },
|
|
27904
27882
|
{ label: "Diastolic", value: `${diastolic} mmHg \u2014 ${result.diastolic.percentileDisplay}p (SDS ${result.diastolic.sdsDisplay})` },
|
|
27905
|
-
{ label: "DBP Thresholds", value: `P50: ${result.diastolic.p50} | P90: ${result.diastolic.p90} | P95: ${result.diastolic.p95} | P95+12: ${result.diastolic.p95Plus12}` }
|
|
27906
|
-
{ label: "Classification", value: categoryLabel(result.overallCategory) }
|
|
27883
|
+
{ label: "DBP Thresholds", value: `P50: ${result.diastolic.p50} | P90: ${result.diastolic.p90} | P95: ${result.diastolic.p95} | P95+12: ${result.diastolic.p95Plus12}` }
|
|
27907
27884
|
];
|
|
27908
27885
|
}
|
|
27909
27886
|
function executeABPM(args) {
|
|
@@ -29703,13 +29680,21 @@ var visibleToolsMetadata = [
|
|
|
29703
29680
|
"type": "calcs",
|
|
29704
29681
|
"titleKey": "tools.corrected-bmd.title",
|
|
29705
29682
|
"subtitleKey": "tools.corrected-bmd.subtitle",
|
|
29706
|
-
"titleFallback": "Corrected
|
|
29707
|
-
"subtitleFallback": "
|
|
29683
|
+
"titleFallback": "Corrected Volumetric BMD",
|
|
29684
|
+
"subtitleFallback": "Lumbar spine (L1\u2013L4) volumetric BMD correction, Katzman formula",
|
|
29708
29685
|
"searchKeywords": [
|
|
29709
29686
|
"Katzman",
|
|
29687
|
+
"Carter",
|
|
29710
29688
|
"vBMD",
|
|
29711
29689
|
"volumetrik",
|
|
29712
29690
|
"volumetric",
|
|
29691
|
+
"vol\xFCmetrik",
|
|
29692
|
+
"BMAD",
|
|
29693
|
+
"L1-L4",
|
|
29694
|
+
"lomber",
|
|
29695
|
+
"lumbar",
|
|
29696
|
+
"spine",
|
|
29697
|
+
"omurga",
|
|
29713
29698
|
"kemik boyutu",
|
|
29714
29699
|
"bone size"
|
|
29715
29700
|
]
|
|
@@ -30209,7 +30194,7 @@ var cyan2 = (s) => useColor2 ? `\x1B[36m${s}\x1B[0m` : s;
|
|
|
30209
30194
|
var green = (s) => useColor2 ? `\x1B[32m${s}\x1B[0m` : s;
|
|
30210
30195
|
var yellow2 = (s) => useColor2 ? `\x1B[33m${s}\x1B[0m` : s;
|
|
30211
30196
|
var magenta = (s) => useColor2 ? `\x1B[35m${s}\x1B[0m` : s;
|
|
30212
|
-
var VERSION = true ? "0.3.
|
|
30197
|
+
var VERSION = true ? "0.3.1" : "0.0.0-dev";
|
|
30213
30198
|
var BIN = process.argv[1]?.replace(/.*[\\/]/, "").replace(/\.\w+$/, "") === "childmetrics" ? "childmetrics" : "childmetrics";
|
|
30214
30199
|
var visibleSchemas = visibleToolSchemas;
|
|
30215
30200
|
function findMeta(schemaId) {
|