Skip to content

Commit

Permalink
feat(#639): add normal risk check
Browse files Browse the repository at this point in the history
  • Loading branch information
tamslo committed Oct 15, 2024
1 parent 704f6b8 commit 7e30f7e
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 2 deletions.
1 change: 1 addition & 0 deletions pharme.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
"Neoprofen",
"noto",
"NSAID",
"NUDT",
"omeprazole",
"oxcarbazepine",
"Oxtellar",
Expand Down
1 change: 1 addition & 0 deletions scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ and optionally correct what can be corrected easily in
| `none_warning` | None warning level should be applied in all not handled warning level cases. |||
| `metabolization_before_consequence` | Metabolization implications should come before consequences. |||
| `annotated_but_not_staged` | Warns if a guideline is annotated but not staged (ignored drugs in `IGNORE_STAGED_CHECK`) |||
| `should_not_have_normal_risk` | Warns if a guideline uses "normal risk" if not mentioned in external data. |||

\* Skips guidelines with multiple genes unless all results but one are missing
or indeterminate.
2 changes: 2 additions & 0 deletions scripts/analyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from analyze_functions.checks.brand_name_whitespace import check_brand_name_whitespace
from analyze_functions.checks.metabolization_before_consequence import check_metabolization_before_consequence
from analyze_functions.checks.fallback_guidelines import check_single_any_fallback_guideline, check_single_lookup_fallback_guideline
from analyze_functions.checks.normal_side_effect_risk import check_normal_side_effect_risk
from analyze_functions.checks.warning_levels import check_green_warning_level, \
check_none_warning_level, check_red_warning_level, \
check_yellow_warning_level
Expand Down Expand Up @@ -38,6 +39,7 @@
'none_warning_level': check_none_warning_level,
'metabolization_before_consequence': check_metabolization_before_consequence,
'annotated_but_not_staged': check_if_fully_annotated_staged,
'should_not_have_normal_risk': check_normal_side_effect_risk,
}

GUIDELINE_CORRECTIONS = {
Expand Down
3 changes: 1 addition & 2 deletions scripts/analyze_functions/checks/metabolization_severity.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
def check_metabolization_severity(args):
guideline = args['item']
annotations = args['annotations']
ignored_phenotypes = ['no result', 'indeterminate', 'normal metabolizer']
multiple_relevant_phenotypes = False
relevant_gene = None
for current_gene, current_phenotypes in guideline['phenotypes'].items():
if not current_phenotypes[0].lower() in ignored_phenotypes:
if not current_phenotypes[0].lower() in constants.IGNORED_PHENOTYPES:
if relevant_gene != None:
multiple_relevant_phenotypes = True
break
Expand Down
20 changes: 20 additions & 0 deletions scripts/analyze_functions/checks/normal_side_effect_risk.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from analyze_functions.constants import IGNORED_PHENOTYPES, NORMAL_RISK_TEXTS

def check_normal_side_effect_risk(args):
guideline = args['item']
annotations = args['annotations']
can_have_normal_risk = any(map(
lambda normal_risk_text: normal_risk_text in \
'–'.join(guideline['externalData'][0]['implications'].values()).lower(),
NORMAL_RISK_TEXTS,
)) or all(map(
lambda gene:
(gene == 'HLA-B' and 'negative' in guideline['phenotypes'][gene][0]) \
or guideline['phenotypes'][gene][0].lower() in IGNORED_PHENOTYPES,
guideline['phenotypes'].keys(),
))
has_normal_risk_text = any(map(
lambda normal_risk_text: normal_risk_text in annotations['implication'],
NORMAL_RISK_TEXTS,
))
return can_have_normal_risk or not has_normal_risk_text
8 changes: 8 additions & 0 deletions scripts/analyze_functions/constants.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
CONSULT_TEXT = 'consult your pharmacist or doctor'
WHOLE_CONSULT_TEXT = '{} for more information.'.format(CONSULT_TEXT)
NORMAL_RISK_TEXTS = [
'normal risk',
'low or reduced risk',
'typical myopathy risk',
'weak or no evidence for an increased risk',
'"normal" risk',
]
IGNORED_PHENOTYPES = ['no result', 'indeterminate', 'normal metabolizer']
RED_TEXT = 'not be the right medication'
NOT_RED_TEXTS = [
'if more than this dose is needed',
Expand Down

0 comments on commit 7e30f7e

Please sign in to comment.