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

Adding Period_prior_to_index function #35

Merged
merged 31 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
01cc575
Intiaial dispatch for period_prior_to_index function
Jay-sanjay Jun 5, 2024
6c6780c
trying to debug
Jay-sanjay Jun 5, 2024
b239985
Added the second dispatch
Jay-sanjay Jun 7, 2024
9039db8
Tests added for the second dispatch
Jay-sanjay Jun 7, 2024
a0a64b1
debugging
Jay-sanjay Jun 8, 2024
a3e1c10
debugging
Jay-sanjay Jun 8, 2024
ec9d500
print
Jay-sanjay Jun 8, 2024
f90444d
print
Jay-sanjay Jun 8, 2024
ce88cd5
Docs Strings added
Jay-sanjay Jun 12, 2024
57a4ab1
Added to api.md
Jay-sanjay Jun 12, 2024
d989ab3
Added to api.md
Jay-sanjay Jun 12, 2024
01ac533
added to api.md
Jay-sanjay Jun 12, 2024
6ce8bd3
Update preprocessing.jl
Jay-sanjay Jun 12, 2024
96f8457
Create cohort on Eunomia for testing
TheCedarPrince Jun 14, 2024
6b1e001
Merge branch 'dev' into period_prior_to_index
TheCedarPrince Jun 14, 2024
bb3856c
Update preprocessing.jl
Jay-sanjay Jun 24, 2024
3cdc4e3
added requested changes
Jay-sanjay Jun 24, 2024
65cfe3e
added more changes
Jay-sanjay Jun 24, 2024
e23dab5
added requested changes
Jay-sanjay Jun 28, 2024
0488869
Merge branch 'dev' into period_prior_to_index
Jay-sanjay Jun 30, 2024
13b1f45
Update api.md
Jay-sanjay Jun 30, 2024
f446cbc
Update preprocessing.jl
Jay-sanjay Jul 1, 2024
6fe7490
Update preprocessing.jl
Jay-sanjay Jul 1, 2024
c929d81
bug fixed
Jay-sanjay Jul 1, 2024
ac4410a
Update preprocessing.jl
Jay-sanjay Jul 1, 2024
a5f59dd
Merge branch 'dev' into period_prior_to_index
Jay-sanjay Jul 17, 2024
1432c24
Update preprocessing.jl
Jay-sanjay Jul 17, 2024
98ba8c1
Update preprocessing.jl
Jay-sanjay Aug 23, 2024
fb58fed
Update preprocessing.jl
Jay-sanjay Aug 23, 2024
b3cfdb0
Update preprocessing.jl
Jay-sanjay Aug 23, 2024
b84243c
Update preprocessing.jl
Jay-sanjay Aug 23, 2024
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
Next Next commit
Intiaial dispatch for period_prior_to_index function
  • Loading branch information
Jay-sanjay authored Jun 5, 2024
commit 01cc575a46e143fa17dbb0f96afae9e63cf2e0ed
27 changes: 26 additions & 1 deletion src/preprocessing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,29 @@ function Dummy(

end

export Dummy

"""
TODO: Add Doc-Strings.
"""
Jay-sanjay marked this conversation as resolved.
Show resolved Hide resolved
function period_prior_to_index(cohort_id::Vector, conn; date_prior=Day(100), tab=cohort)

# Construct the SQL query
sql = From(tab) |>
Where(Fun.in(Get.cohort_definition_id, cohort_id...)) |>
Select(Get.cohort_definition_id, Get.subject_id, Get.cohort_start_date) |>
q -> render(q, dialect=dialect)

# Execute the SQL query and fetch the result into a DataFrame
df = DBInterface.execute(conn, String(sql)) |> DataFrame

# Check if the DataFrame is not empty
# TODO: Is it really necessary to add this check ??
Jay-sanjay marked this conversation as resolved.
Show resolved Hide resolved
if nrow(df) > 0
# Convert the cohort_start_date to DateTime and subtract the date_prior
df.cohort_start_date = DateTime.(df.cohort_start_date) .- date_prior
end

return df
end

export Dummy, period_prior_to_index
18 changes: 18 additions & 0 deletions test/Data-Preprocessing/preprocessing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,22 @@ using Test
@test test_drug_exposure_start_date == result.drug_exposure_start_date[1:4]
@test test_drug_exposure_ids == result.drug_exposure_id[1:4]

end



@testset "Period Prior to Index Tests" begin
MakeTables(sqlite_conn, :sqlite, "main")

test_person_ids = [1, 1, 1, 1, 1]
test_subject_ids = [1.0, 5.0, 9.0, 11.0, 12.0]
test_cohort_start_date = [-3.7273e8, 2.90304e7, -5.33347e8, -8.18208e7, 1.32918e9]

test_df2 = DataFrame(person_id = test_person_ids, cohort_start_date = test_cohort_start_date)

result = period_prior_to_index(test_person_ids, sqlite_conn)

@test test_person_ids == result.cohort_definition_id[1:5]
@test test_subject_ids == result.subject_id[1:5]
Jay-sanjay marked this conversation as resolved.
Show resolved Hide resolved

end
Loading