Skip to content

Clamp HbA1c to a physiological floor after diabetes medication impacts - #1723

Open
developer-rpai wants to merge 1 commit into
synthetichealth:masterfrom
developer-rpai:fix-hba1c-physiological-floor-1693
Open

developer-rpai wants to merge 1 commit into
synthetichealth:masterfrom
developer-rpai:fix-hba1c-physiological-floor-1693

Conversation

@developer-rpai

Copy link
Copy Markdown

Summary

LifecycleModule.calculateVitalSigns subtracts a fixed HbA1c impact for every active diabetes medication with no lower bound. A diabetic patient on several drugs (e.g. basal + prandial insulin + metformin) is assigned an HbA1c that cannot occur in a living person -- observed as low as 2.39% in generated data, with negative values arithmetically possible (see #1693). The defect only affects treated patients, which makes it easy to miss: untreated patients look entirely plausible, while the patients whose HbA1c matters most are wrong.

Fix

Implements option 1 from the issue's proposed fixes: clamp the post-medication HbA1c to a physiological floor of 4.0% (MIN_HBA1C). Below roughly 4.0%, HbA1c does not occur in living people; via the ADAG equation (Nathan et al., Diabetes Care 2008: eAG = 28.7 x A1C - 46.7 mg/dL), 4.0% implies an average glucose of ~68 mg/dL, just below the ADA hypoglycemia threshold of 70 mg/dL.

Interaction with #1699

PR #1699 (which reworks diabetes medication modeling) explicitly states it does not address #1693. This PR targets #1693 directly on current master; if #1699 merges first, the clamp should be re-evaluated against the new model.

Testing

  • New regression test testHbA1cMedicationImpactsDoNotGoBelowPhysiologicalFloor in LifecycleModuleTest: activates every drug in DIABETES_DRUG_HBA1C_IMPACTS on a diabetic patient (baseline 6.6, total impact -11.5, unclamped result -4.9) and asserts the recorded HbA1c equals the 4.0 floor. Verified the test fails without the fix (expected:<4.0> but was:<-4.9>) and passes with it.
  • Full LifecycleModuleTest suite: 9/9 tests pass.
  • Environment note: the Gradle wrapper could not run in this sandbox (distribution download failed on a TLS error; a manually installed Gradle hit corrupted daemon IPC), so the test was compiled and run directly with javac/java (JUnit 4) against Maven Central dependencies instead of via ./gradlew test. The repo's checkstyle config also cannot execute under the declared checkstyle 10.17.0 (it nests LineLength inside TreeWalker, which that version rejects) -- a pre-existing issue on master; the changed files introduce no new violations relative to master under the same rules.

Fixes #1693

LifecycleModule subtracted a fixed HbA1c impact for every active diabetes
medication with no lower bound, so patients on several drugs could receive
HbA1c values that cannot occur in a living person (observed as low as 2.39%,
with negative values arithmetically possible).

Clamp the post-medication HbA1c to 4.0%, the physiological floor described in
the issue: below roughly 4% HbA1c does not occur in living people, and via
the ADAG equation (Nathan et al.) 4.0% implies an average glucose of ~68 mg/dL,
just below the ADA hypoglycemia threshold of 70 mg/dL. This implements option 1
(clamp the result) from the issue's proposed fixes.

Adds a regression test that activates every drug in DIABETES_DRUG_HBA1C_IMPACTS
on a diabetic patient (baseline 6.6, total impact -11.5, unclamped -4.9) and
asserts the recorded HbA1c equals the 4.0 floor.

Fixes synthetichealth#1693

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Medication impacts drive HbA1c below physiological limits (values as low as 2.39%, theoretically negative)

1 participant