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

Excluded rules summary #24

Merged
merged 2 commits into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions cumulus_library_opioid/manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ file_names = [
"vocab/static_builder.py",
"vocab/rxnorm_vsac_builder.py",
"vocab/additional_rules_builder.py",
"vocab/excluded_rules_builder.py",
]

# [sql_config]
Expand Down
130 changes: 130 additions & 0 deletions cumulus_library_opioid/reference_sql/excluded_rules_builder.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
-- noqa: disable=all
-- This sql was autogenerated as a reference example using the library
-- CLI. Its format is tied to the specific database it was run against,
-- and it may not be correct for all databases. Use the CLI's build
-- option to derive the best SQL for your dataset.

-- ###########################################################

CREATE TABLE opioid__acep_excluded_rules AS
SELECT
rxcui1,
rxcui2,
tty1,
tty2,
rui,
rel,
rela,
str1,
str2,
keyword
FROM
opioid__acep_potential_rules
WHERE rui NOT IN (SELECT DISTINCT rui from opioid__acep_combined_ruleset)
AND rxcui1 NOT IN (SELECT DISTINCT rxcui1 from opioid__acep_combined_ruleset)
AND rxcui2 NOT IN (SELECT DISTINCT rxcui2 from opioid__acep_combined_ruleset)

-- ###########################################################

CREATE VIEW opioid__acep_excluded_tradename AS
SELECT
rxcui1,
tty1,
rel,
rela,
rxcui2,
tty2,
str2
FROM
opioid__acep_excluded_rules
WHERE rela IN ('has_tradename','tradename_of')

-- ###########################################################

CREATE VIEW opioid__acep_excluded_consists AS
SELECT
rxcui1,
tty1,
rel,
rela,
rxcui2,
tty2,
str2
FROM
opioid__acep_excluded_rules
WHERE rela IN ('consists_of','constitutes')

-- ###########################################################

CREATE VIEW opioid__acep_excluded_is_a AS
SELECT
rxcui1,
tty1,
rel,
rela,
rxcui2,
tty2,
str2
FROM
opioid__acep_excluded_rules
WHERE rela IN ('isa','inverse_isa')

-- ###########################################################

CREATE VIEW opioid__acep_excluded_ingredient AS
SELECT
rxcui1,
tty1,
rel,
rela,
rxcui2,
tty2,
str2
FROM
opioid__acep_excluded_rules
WHERE rela IN ('has_ingredient','ingredient_of','has_precise_ingredient','precise_ingredient_of','has_ingredients','ingredients_of')

-- ###########################################################

CREATE VIEW opioid__acep_excluded_dose_form AS
SELECT
rxcui1,
tty1,
rel,
rela,
rxcui2,
tty2,
str2
FROM
opioid__acep_excluded_rules
WHERE rela IN ('dose_form_of','has_dose_form','doseformgroup_of','has_doseformgroup')

-- ###########################################################

CREATE VIEW opioid__acep_excluded_form AS
SELECT
rxcui1,
tty1,
rel,
rela,
rxcui2,
tty2,
str2
FROM
opioid__acep_excluded_rules
WHERE rela IN ('form_of','has_form')

-- ###########################################################

CREATE VIEW opioid__acep_excluded_other AS
SELECT
rxcui1,
tty1,
rel,
rela,
rxcui2,
tty2,
str2
FROM
opioid__acep_excluded_rules
WHERE rela NOT IN ('has_tradename','tradename_of','consists_of','constitutes','isa','inverse_isa','has_ingredient','ingredient_of','has_precise_ingredient','precise_ingredient_of','has_ingredients','ingredients_of','dose_form_of','has_dose_form','doseformgroup_of','has_doseformgroup','form_of','has_form')
Loading