Skip to content

Commit

Permalink
Now uses numeric_value for predicates (#139)
Browse files Browse the repository at this point in the history
Closes #138
  • Loading branch information
justin13601 authored Oct 1, 2024
1 parent e826a7b commit 89291a0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
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

0 comments on commit 89291a0

Please sign in to comment.