-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c391b4f
commit 4f270e1
Showing
5 changed files
with
174 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
title: Third party software citations | ||
parent: Library | ||
nav_order: 8 | ||
# audience: Clinical researchers interested in publications | ||
# type: reference | ||
--- | ||
|
||
# Third party software citations | ||
|
||
This file contains a list of third party software libraries associated with | ||
publications that are used by Cumulus library. These are generally domain | ||
specific to clinical research. | ||
|
||
## (PsmPy)[https://github.com/adriennekline/psmpy] | ||
|
||
A. Kline and Y. Luo, PsmPy: A Package for Retrospective Cohort Matching in Python, 2022 44th Annual International Conference of the IEEE Engineering in Medicine & Biology Society (EMBC), 2022, pp. 1354-1357, doi: 10.1109/EMBC48229.2022.9871333. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
from contextlib import nullcontext as does_not_raise | ||
|
||
import pytest | ||
|
||
from cumulus_library.errors import CumulusLibraryError | ||
from cumulus_library.template_sql.statistics.psm_templates import ( | ||
get_distinct_ids, | ||
get_create_covariate_table, | ||
) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"columns,source_table,join_id,filter_table,expected,raises", | ||
[ | ||
( | ||
["a", "b"], | ||
"source", | ||
"ref_id", | ||
"filter", | ||
"""SELECT DISTINCT | ||
"source"."a", | ||
"source"."b" | ||
FROM source | ||
WHERE "source"."ref_id" NOT IN ( | ||
SELECT "filter"."ref_id" | ||
FROM filter | ||
)""", | ||
does_not_raise(), | ||
), | ||
( | ||
["a", "b"], | ||
"source", | ||
None, | ||
None, | ||
"""SELECT DISTINCT | ||
"source"."a", | ||
"source"."b" | ||
FROM source""", | ||
does_not_raise(), | ||
), | ||
(["a", "b"], "source", "ref_id", None, "", pytest.raises(CumulusLibraryError)), | ||
], | ||
) | ||
def test_get_distinct_ids( | ||
columns, source_table, join_id, filter_table, expected, raises | ||
): | ||
with raises: | ||
query = get_distinct_ids(columns, source_table, join_id, filter_table) | ||
assert query == expected | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"target,pos_source,neg_source,primary_ref,dep_var,join_cols_by_table,count_ref,count_table,expected,raises", | ||
[ | ||
( | ||
"target", | ||
"pos_table", | ||
"neg_table", | ||
"subject_id", | ||
"has_flu", | ||
{}, | ||
None, | ||
None, | ||
"""CREATE TABLE target AS ( | ||
SELECT | ||
DISTINCT sample_cohort."subject_id", | ||
sample_cohort."has_flu", | ||
neg_table.code | ||
FROM "pos_table_sampled_ids" AS sample_cohort, | ||
"neg_table", | ||
WHERE sample_cohort."subject_id" = "neg_table"."subject_id" | ||
-- AND c.recordeddate <= sample_cohort.enc_end_date | ||
ORDER BY sample_cohort."subject_id" | ||
)""", | ||
does_not_raise(), | ||
), | ||
( | ||
"target", | ||
"pos_table", | ||
"neg_table", | ||
"subject_id", | ||
"has_flu", | ||
{ | ||
"join_table": { | ||
"join_id": "enc_ref", | ||
"included_cols": [["a"], ["b", "c"]], | ||
} | ||
}, | ||
"enc_ref", | ||
"join_table", | ||
"""CREATE TABLE target AS ( | ||
SELECT | ||
DISTINCT sample_cohort."subject_id", | ||
sample_cohort."has_flu", | ||
( | ||
SELECT COUNT( DISTINCT subject_id ) | ||
FROM "join_table" | ||
WHERE sample_cohort."enc_ref" = "join_table"."enc_ref" | ||
--AND sample_cohort.enc_end_date >= "join_table".recordeddate | ||
) AS instance_count, | ||
"join_table"."a", | ||
"join_table"."b" AS "c", | ||
neg_table.code | ||
FROM "pos_table_sampled_ids" AS sample_cohort, | ||
"neg_table", | ||
"join_table" | ||
WHERE sample_cohort."subject_id" = "neg_table"."subject_id" | ||
AND sample_cohort."enc_ref" = "join_table"."enc_ref" | ||
-- AND c.recordeddate <= sample_cohort.enc_end_date | ||
ORDER BY sample_cohort."subject_id" | ||
)""", | ||
does_not_raise(), | ||
), | ||
( | ||
"target", | ||
"pos_table", | ||
"neg_table", | ||
"subject_id", | ||
"has_flu", | ||
{}, | ||
"join_table", | ||
None, | ||
"", | ||
pytest.raises(CumulusLibraryError), | ||
), | ||
], | ||
) | ||
def test_create_covariate_table( | ||
target, | ||
pos_source, | ||
neg_source, | ||
primary_ref, | ||
dep_var, | ||
join_cols_by_table, | ||
count_ref, | ||
count_table, | ||
expected, | ||
raises, | ||
): | ||
with raises: | ||
query = get_create_covariate_table( | ||
target, | ||
pos_source, | ||
neg_source, | ||
primary_ref, | ||
dep_var, | ||
join_cols_by_table, | ||
count_ref, | ||
count_table, | ||
) | ||
with open("output.sql", "w") as f: | ||
f.write(query) | ||
assert query == expected |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters