Skip to content

Commit

Permalink
support condition_era
Browse files Browse the repository at this point in the history
  • Loading branch information
eroell committed Nov 22, 2024
1 parent 0525855 commit e4ad1db
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/ehrdata/io/omop/_check_arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"device_exposure",
"drug_era",
"dose_era",
"condition_era",
]
VALID_KEEP_DATES = ["start", "end", "interval"]

Expand Down
3 changes: 3 additions & 0 deletions src/ehrdata/io/omop/_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"device_exposure": "device",
"drug_era": "drug",
"dose_era": "drug",
"condition_era": "condition",
}

DATA_TABLE_DATE_KEYS = {
Expand All @@ -37,6 +38,7 @@
"device_exposure": "device_exposure_start_date",
"drug_era": "drug_era_start_date",
"dose_era": "dose_era_start_date",
"condition_era": "condition_era_start_date",
},
"end": {
"visit_occurrence": "visit_end_date",
Expand All @@ -48,6 +50,7 @@
"device_exposure": "device_exposure_end_date",
"drug_era": "drug_era_end_date",
"dose_era": "dose_era_end_date",
"condition_era": "condition_era_end_date",
},
}

Expand Down
10 changes: 10 additions & 0 deletions tests/data/toy_omop/vanilla/condition_era.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
condition_era_id,person_id,condition_concept_id,condition_era_start_date,condition_era_end_date,condition_occurrence_count
1,1,4140598,2100-01-01,2100-01-31,256
2,1,4140598,2100-02-01,2100-02-28,256
3,1,434610,2100-01-01,2100-01-31,1
4,2,4140598,2100-01-01,2100-01-31,256
5,2,4140598,2100-02-01,2100-02-28,256
6,2,434610,2100-01-01,2100-01-31,1
7,3,4140598,2100-01-01,2100-01-31,256
8,3,4140598,2100-02-01,2100-02-28,256
9,3,434610,2100-01-01,2100-01-31,1
61 changes: 61 additions & 0 deletions tests/test_io/test_omop.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"device_exposure": 2,
"drug_era": 2,
"dose_era": 2,
"condition_era": 2,
}

# constants for setup_variables
Expand Down Expand Up @@ -566,6 +567,66 @@ def test_setup_variables(
[[1, 1, 1, 1], [1, 1, 1, 1]],
],
),
(
["condition_era"],
["condition_occurrence_count"],
"start",
[
[[1, np.nan, np.nan, np.nan], [256, np.nan, np.nan, np.nan]],
[[1, np.nan, np.nan, np.nan], [256, np.nan, np.nan, np.nan]],
[[1, np.nan, np.nan, np.nan], [256, np.nan, np.nan, np.nan]],
],
),
(
["condition_era"],
["condition_occurrence_count"],
"end",
[
[[np.nan, np.nan, np.nan, np.nan], [np.nan, np.nan, np.nan, np.nan]],
[[np.nan, np.nan, np.nan, np.nan], [np.nan, np.nan, np.nan, np.nan]],
[[np.nan, np.nan, np.nan, np.nan], [np.nan, np.nan, np.nan, np.nan]],
],
),
(
["condition_era"],
["condition_occurrence_count"],
"interval",
[
[[1, 1, 1, 1], [256, 256, 256, 256]],
[[1, 1, 1, 1], [256, 256, 256, 256]],
[[1, 1, 1, 1], [256, 256, 256, 256]],
],
),
(
["condition_era"],
["is_present"],
"start",
[
[[1, np.nan, np.nan, np.nan], [1, np.nan, np.nan, np.nan]],
[[1, np.nan, np.nan, np.nan], [1, np.nan, np.nan, np.nan]],
[[1, np.nan, np.nan, np.nan], [1, np.nan, np.nan, np.nan]],
],
),
(
["condition_era"],
["is_present"],
"end",
[
[[np.nan, np.nan, np.nan, np.nan], [np.nan, np.nan, np.nan, np.nan]],
[[np.nan, np.nan, np.nan, np.nan], [np.nan, np.nan, np.nan, np.nan]],
[[np.nan, np.nan, np.nan, np.nan], [np.nan, np.nan, np.nan, np.nan]],
],
),
(
["condition_era"],
["is_present"],
"interval",
[
[[1, 1, 1, 1], [1, 1, 1, 1]],
[[1, 1, 1, 1], [1, 1, 1, 1]],
[[1, 1, 1, 1], [1, 1, 1, 1]],
],
),
],
)
@pytest.mark.parametrize(
Expand Down

0 comments on commit e4ad1db

Please sign in to comment.