Skip to content

Commit

Permalink
feat(#639): add overwrites for implication severity check
Browse files Browse the repository at this point in the history
  • Loading branch information
tamslo committed Oct 17, 2024
1 parent 656871c commit e7707a2
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 11 deletions.
1 change: 1 addition & 0 deletions pharme.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
"screendocs",
"sertraline",
"simvastatin",
"siponimod",
"SLCO",
"statin",
"Statins",
Expand Down
2 changes: 1 addition & 1 deletion scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ and which bricks are not used in guidelines.
| Check | Description | `--correct`ed | Only for single-gene results* |
| ----- | ----------- | ------------- | ----------------------------- |
| `has_consult` | Is "consult your pharmacist..." included in recommendation? |||
| `check_metabolization_severity` | "Much" keyword, should only be used if reflected by guideline implication. |||
| `check_metabolization_severity` | "Much" keyword, should only be used if reflected by guideline implication (or guideline lookup in `METABOLIZATION_SEVERITY_OVERWRITES`). |||
| `red_warning` | Red warning level should be present with recommendation containing "may not be the right medication". |||
| `yellow_warning` | Yellow warning level should be present when the red warning level does not apply but the implication contains "may not work" or "side effects" or the recommendation contains non-standard dose. |||
| `green_warning` | Green warning level should be applied in all non-red and non-yellow cases and when the recommendation states "at standard dose" or similar formulations. |||
Expand Down
10 changes: 1 addition & 9 deletions scripts/analyze_functions/checks/fully_annotated_staged.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
IGNORE_STAGED_CHECK = [#
'amikacin',
'gentamicin',
'kanamycin',
'paromomycin',
'tobramycin',
'streptomycin',
'plazomicin',
]
from analyze_functions.constants import IGNORE_STAGED_CHECK

def check_if_fully_annotated_staged(args):
if args['drug_name'] in IGNORE_STAGED_CHECK: return None
Expand Down
24 changes: 23 additions & 1 deletion scripts/analyze_functions/checks/metabolization_severity.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,26 @@
import analyze_functions.constants as constants

def _get_severity_overwrite(drug_name, guideline):
severity_overwrite = None
guideline_lookup = guideline['lookupkey']
present_overwrites = list(filter(
lambda overwrite: overwrite['drug'] == drug_name and \
overwrite['lookup'] == guideline_lookup,
constants.METABOLIZATION_SEVERITY_OVERWRITES,
))
if len(present_overwrites) > 1:
print(
'WARNING: found multiple applying lookup overwrites for '
f'{drug_name}, {guideline_lookup}; only using first one'
)
if len(present_overwrites) > 0:
severity_overwrite = present_overwrites[0]['overwrite']
return severity_overwrite

def check_metabolization_severity(args):
guideline = args['item']
annotations = args['annotations']
drug_name = args['drug_name']
multiple_relevant_phenotypes = False
relevant_gene = None
for current_gene, current_phenotypes in guideline['phenotypes'].items():
Expand All @@ -22,10 +40,14 @@ def check_metabolization_severity(args):
constants.MUCH_IMPLYING_METABOLIZATION_FORMULATIONS,
)
)
severity_overwrite = _get_severity_overwrite(drug_name, guideline)
should_have_much = severity_overwrite \
if severity_overwrite != None \
else much_is_implied
implication_has_much = any(
map(
lambda much_formulation: much_formulation in annotations['implication'],
constants.MUCH_METABOLIZATION_FORMULATIONS,
)
)
return much_is_implied == implication_has_much
return should_have_much == implication_has_much
23 changes: 23 additions & 0 deletions scripts/analyze_functions/constants.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
METABOLIZATION_SEVERITY_OVERWRITES = [
{
'drug': 'voriconazole',
'lookup': {'CYP2C19': ['Ultrarapid Metabolizer']},
'overwrite': True,
},
{
'drug': 'siponimod',
'lookup': {'CYP2C9': ['0.0']},
'overwrite': True,
},
]

IGNORE_STAGED_CHECK = [
'amikacin',
'gentamicin',
'kanamycin',
'paromomycin',
'tobramycin',
'streptomycin',
'plazomicin',
]

CONSULT_TEXT = 'consult your pharmacist or doctor'
WHOLE_CONSULT_TEXT = '{} for more information.'.format(CONSULT_TEXT)
NORMAL_RISK_TEXTS = [
Expand Down

0 comments on commit e7707a2

Please sign in to comment.