From e7707a21306af51641b4c16d7cc848efef0aa9d7 Mon Sep 17 00:00:00 2001 From: Tamara Slosarek Date: Thu, 17 Oct 2024 13:05:10 +0200 Subject: [PATCH] feat(#639): add overwrites for implication severity check --- pharme.code-workspace | 1 + scripts/README.md | 2 +- .../checks/fully_annotated_staged.py | 10 +------- .../checks/metabolization_severity.py | 24 ++++++++++++++++++- scripts/analyze_functions/constants.py | 23 ++++++++++++++++++ 5 files changed, 49 insertions(+), 11 deletions(-) diff --git a/pharme.code-workspace b/pharme.code-workspace index dfacf5c0..2bd98956 100644 --- a/pharme.code-workspace +++ b/pharme.code-workspace @@ -122,6 +122,7 @@ "screendocs", "sertraline", "simvastatin", + "siponimod", "SLCO", "statin", "Statins", diff --git a/scripts/README.md b/scripts/README.md index f3df3d36..aa995669 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -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. | ❌ | ❌ | diff --git a/scripts/analyze_functions/checks/fully_annotated_staged.py b/scripts/analyze_functions/checks/fully_annotated_staged.py index abba352d..c35a3783 100644 --- a/scripts/analyze_functions/checks/fully_annotated_staged.py +++ b/scripts/analyze_functions/checks/fully_annotated_staged.py @@ -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 diff --git a/scripts/analyze_functions/checks/metabolization_severity.py b/scripts/analyze_functions/checks/metabolization_severity.py index 77e24dac..836f4423 100644 --- a/scripts/analyze_functions/checks/metabolization_severity.py +++ b/scripts/analyze_functions/checks/metabolization_severity.py @@ -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(): @@ -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 \ No newline at end of file + return should_have_much == implication_has_much \ No newline at end of file diff --git a/scripts/analyze_functions/constants.py b/scripts/analyze_functions/constants.py index 88da27d0..01c8f2d1 100644 --- a/scripts/analyze_functions/constants.py +++ b/scripts/analyze_functions/constants.py @@ -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 = [