Skip to content

Commit

Permalink
Add helper functions
Browse files Browse the repository at this point in the history
  • Loading branch information
milanwiedemann committed Oct 14, 2024
1 parent 0d41fb8 commit 0a6dd7b
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions analysis/pf_variables_library.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Function to check status of a condition within a specified time window
def check_pregnancy_status(index_date, selected_events, codelist):
return (
selected_events.where(selected_events.snomedct_code.is_in(codelist))
.where(
selected_events.date.is_on_or_between(index_date - months(1), index_date)
)
.exists_for_patient()
)


# Function to count number of coded events within a specified time window
def count_past_events(index_date, selected_events, codelist, num_months):
return (
selected_events.where(selected_events.snomedct_code.is_in(codelist))
.where(
selected_events.date.is_on_or_between(
index_date - months(num_months), index_date
)
)
.count_for_patient()
)

0 comments on commit 0a6dd7b

Please sign in to comment.