feat: add computed therapy score to session detail#105
Open
kilo-WATT wants to merge 3 commits into
Open
Conversation
Contributor
Author
|
Added a follow-up commit to make manufacturer handling safer. The score is no longer ResMed-only and no longer assumes missing manufacturer data means ResMed. AHI, duration, and SpO2 still score normally for unknown/non-ResMed manufacturers, while leak scoring is only applied when the manufacturer is explicitly ResMed. For unknown or unconfirmed manufacturers, the leak component is marked unavailable and its weight is redistributed. Validation:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a computed therapy score to the session detail response and displays it on the session detail page.
The score is calculated at request time from existing session fields. No therapy-score data is persisted.
Changes
therapy_scoreto the session detail API response.score_vs_30d_avgto compare the current night against the user’s prior 30-day average.api/therapy_score.py.api/routers/sessions.py.SessionDetail.tsx.Scoring Logic
The score is a computed 0–100 integer with an A–F grade.
Default component weights:
Unavailable components are excluded and their weight is redistributed across available components.
ResMed leak scoring uses the 24 L/min large-leak threshold. Sessions that are not parser-validated still receive a score but are marked as low confidence.
30-Day Comparison
score_vs_30d_avgis computed from existing rows in thesessionstable.The calculation:
folder_dateto avoid double-counting multi-block nights.Files Changed