Skip to content

Add ConditionRole and RiskBasis: optional vocabularies for how a group stands to a condition - #63

Merged
jdkent merged 1 commit into
mainfrom
feat/condition-role-risk-basis
Nov 27, 2026
Merged

jdkent merged 1 commit into
mainfrom
feat/condition-role-risk-basis

Conversation

@jdkent

@jdkent jdkent commented Nov 27, 2026

Copy link
Copy Markdown
Member

Adds the vocabularies for how a group stands to each condition it names, including being at risk of one. These are the study_schema part of the high-risk design (decisions 2026-11-27).

Both are optional. They are enums for normalized entries on Group.medical_condition, never slots. A record carries none of them until a normalizer writes them, and every existing record stays valid. test_condition_role.py checks that no model field ranges over either.

ConditionRole: none | primary | comorbid | at_risk

  • Written per condition, not per item. "MDD with a family history of bipolar disorder" carries MDD primary and bipolar disorder at_risk. One condition may carry more than one role.
  • It succeeds the pipeline's astra medical role (manifest medical_role: none, comorbid, primary, one per item) and adds at_risk. The manifest entry stays, so records written with the old string still read, and its notes now say what replaced it.

RiskBasis: familial | genetic | clinical | biomarker | condition | exposure | behavioral | trait

  • One entry per basis the source states, so a mutation carrier from an affected family carries familial and genetic. Where the source states none, there is no entry.
  • Coded by the evidence, not the wording: "high genetic risk because of a close family history" is familial.
  • Where the values come from: a survey of the 75,904 synced papers' texts, 2,377 of which define an at-risk sample. Share of those papers by basis:
basis share
familial 21%
clinical 12%
genetic 10%
condition 9%
exposure 6%
behavioral 6%
biomarker 3%
trait 2%

Age and sex appeared only as matching variables, so there is no demographic value.

  • No unstated value. pondie's checks.linkml refuses an enum value for missingness, because the schema's one encoding of it is extraction_status: not_reported. A missing basis entry already says the source gave none.

is_healthy

  • The new rule: true when every entry is an absence or a risk. A group only at risk of a condition (unaffected relatives, presymptomatic carriers, clinical high risk with attenuated symptoms) is healthy, with the risk recorded beside it.
  • Where it's stated: the storage description, the extraction deviation's description and the header's invariant (which used to read "requires medical_condition to be empty") say so.
  • Code still to change: pondie's normalization.is_healthy implements the rule in a later PR.

Generated

  • models/storage.py, models/extraction.py and both JSON Schemas are regenerated.
  • The extraction projection's group.yaml is regenerated with pondie.schema.generate, for the is_healthy wording. The enums aren't projected: no extracted field reaches them, as with AgeUnit.

Checks

In a fresh venv with CI's install:

  • pytest: 324 passed.
  • tools/generate_models.py --check passes.
  • pondie's five schema checks against this branch (generate --check, field_provenance, linkml, extraction_to_storage_map, storage_parameter_priorities) all pass.

Overlap and what follows

  • study_schema#62 (condition_extension) edits the same Normalization.vocabulary description and the same generated files. Whichever merges second needs a small merge and a regenerate.
  • When the pins move:
    • pondie writes these entries and the new is_healthy;
    • ns-pond writes roles per condition;
    • Neurostore reads ConditionRole and keeps at-risk conditions in their own columns. Its review golden schemas change with the pin.

🤖 Generated with Claude Code

…p stands to a condition

Two enums for `normalized` entries on `Group.medical_condition`, never slots, so a record carries
none until a normalizer writes them (James, 2026-11-27):

- ConditionRole: none | primary | comorbid | at_risk, per condition rather than per item, and
  more than one where they hold. Succeeds the pipeline's `astra medical role` (manifest
  `medical_role`, kept to read old records), adding at_risk.
- RiskBasis: familial | genetic | clinical | biomarker | condition | exposure | behavioral | trait,
  one entry per basis the source states and none where it states none. The kinds a survey of
  2,377 papers defining an at-risk sample found; no `unstated`, since a missing entry already
  says so and the schema has one encoding of missingness.

`is_healthy` is true for a group only at risk of a condition, and the header's invariant now
says so. The extraction projection and the generated models are regenerated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@jdkent jdkent left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jdkent
jdkent merged commit eba2e11 into main Nov 27, 2026
6 checks passed
jdkent added a commit that referenced this pull request Nov 28, 2026
Keeps both vocabulary lists in Normalization.vocabulary's description:
condition_extension from this branch, ConditionRole and RiskBasis from #63.
Generated models regenerated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant