Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uses numeric_value in MEDS for predicates with numerical criteria #139

Merged
merged 1 commit into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/source/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ on its source format.

1. If the source data is in [MEDS](https://github.com/Medical-Event-Data-Standard/meds) format
(recommended), then the `code` will be checked directly against MEDS' `code` field and the `value_min`
and `value_max` constraints will be compared against MEDS' `numerical_value` field.
and `value_max` constraints will be compared against MEDS' `numeric_value` field.

**Note**: This syntax does not currently support defining predicates that also rely on matching other,
optional fields in the MEDS syntax; if this is a desired feature for you, please let us know by filing a
Expand Down
16 changes: 8 additions & 8 deletions src/aces/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,17 @@ def MEDS_eval_expr(self) -> pl.Expr:
Examples:
>>> expr = PlainPredicateConfig("BP//systolic", 120, 140, True, False).MEDS_eval_expr()
>>> print(expr) # doctest: +NORMALIZE_WHITESPACE
[(col("code")) == (String(BP//systolic))].all_horizontal([[(col("numerical_value")) >=
(dyn int: 120)], [(col("numerical_value")) < (dyn int: 140)]])
[(col("code")) == (String(BP//systolic))].all_horizontal([[(col("numeric_value")) >=
(dyn int: 120)], [(col("numeric_value")) < (dyn int: 140)]])
>>> cfg = PlainPredicateConfig("BP//systolic", value_min=120, value_min_inclusive=False)
>>> expr = cfg.MEDS_eval_expr()
>>> print(expr) # doctest: +NORMALIZE_WHITESPACE
[(col("code")) == (String(BP//systolic))].all_horizontal([[(col("numerical_value")) >
[(col("code")) == (String(BP//systolic))].all_horizontal([[(col("numeric_value")) >
(dyn int: 120)]])
>>> cfg = PlainPredicateConfig("BP//systolic", value_max=140, value_max_inclusive=True)
>>> expr = cfg.MEDS_eval_expr()
>>> print(expr) # doctest: +NORMALIZE_WHITESPACE
[(col("code")) == (String(BP//systolic))].all_horizontal([[(col("numerical_value")) <=
[(col("code")) == (String(BP//systolic))].all_horizontal([[(col("numeric_value")) <=
(dyn int: 140)]])
>>> cfg = PlainPredicateConfig("BP//diastolic")
>>> expr = cfg.MEDS_eval_expr()
Expand Down Expand Up @@ -136,14 +136,14 @@ def MEDS_eval_expr(self) -> pl.Expr:

if self.value_min is not None:
if self.value_min_inclusive:
criteria.append(pl.col("numerical_value") >= self.value_min)
criteria.append(pl.col("numeric_value") >= self.value_min)
else:
criteria.append(pl.col("numerical_value") > self.value_min)
criteria.append(pl.col("numeric_value") > self.value_min)
if self.value_max is not None:
if self.value_max_inclusive:
criteria.append(pl.col("numerical_value") <= self.value_max)
criteria.append(pl.col("numeric_value") <= self.value_max)
else:
criteria.append(pl.col("numerical_value") < self.value_max)
criteria.append(pl.col("numeric_value") < self.value_max)

if self.other_cols:
criteria.extend([pl.col(col) == value for col, value in self.other_cols.items()])
Expand Down
Loading