From 7e30f7eb55808dea006525080c711c0b87a2eade Mon Sep 17 00:00:00 2001 From: Tamara Slosarek Date: Tue, 15 Oct 2024 19:55:40 +0200 Subject: [PATCH] feat(#639): add normal risk check --- pharme.code-workspace | 1 + scripts/README.md | 1 + scripts/analyze.py | 2 ++ .../checks/metabolization_severity.py | 3 +-- .../checks/normal_side_effect_risk.py | 20 +++++++++++++++++++ scripts/analyze_functions/constants.py | 8 ++++++++ 6 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 scripts/analyze_functions/checks/normal_side_effect_risk.py diff --git a/pharme.code-workspace b/pharme.code-workspace index ff37c4ae..dfacf5c0 100644 --- a/pharme.code-workspace +++ b/pharme.code-workspace @@ -94,6 +94,7 @@ "Neoprofen", "noto", "NSAID", + "NUDT", "omeprazole", "oxcarbazepine", "Oxtellar", diff --git a/scripts/README.md b/scripts/README.md index 6a9aa64b..52f93ce5 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -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. diff --git a/scripts/analyze.py b/scripts/analyze.py index b29d9072..dcd129ac 100644 --- a/scripts/analyze.py +++ b/scripts/analyze.py @@ -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 @@ -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 = { diff --git a/scripts/analyze_functions/checks/metabolization_severity.py b/scripts/analyze_functions/checks/metabolization_severity.py index 73691909..77e24dac 100644 --- a/scripts/analyze_functions/checks/metabolization_severity.py +++ b/scripts/analyze_functions/checks/metabolization_severity.py @@ -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 diff --git a/scripts/analyze_functions/checks/normal_side_effect_risk.py b/scripts/analyze_functions/checks/normal_side_effect_risk.py new file mode 100644 index 00000000..ec494834 --- /dev/null +++ b/scripts/analyze_functions/checks/normal_side_effect_risk.py @@ -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 \ No newline at end of file diff --git a/scripts/analyze_functions/constants.py b/scripts/analyze_functions/constants.py index 59b58207..b4fa5dbe 100644 --- a/scripts/analyze_functions/constants.py +++ b/scripts/analyze_functions/constants.py @@ -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',