Skip to content

Commit

Permalink
Excluded rules summary (#24)
Browse files Browse the repository at this point in the history
* Excluded rules summary

This adds a series of tables designed to help debug study configs
by providing a list of rules that were excluded, but were
considered potential candidates for exclusion.

This adds a new study arg, debug, which is used to enable these
tables. They are off by default.

* PR feedback
  • Loading branch information
dogversioning authored Aug 5, 2024
1 parent 5a92728 commit e213e34
Show file tree
Hide file tree
Showing 9 changed files with 717 additions and 361 deletions.
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

0 comments on commit e213e34

Please sign in to comment.