diff --git a/scripts/README.md b/scripts/README.md index 0caa3898..324979b7 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -113,6 +113,7 @@ and optionally correct what can be corrected easily in | `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 an annotation uses "normal risk" if not mentioned in external data. | ❌ | ❌ | | `non_metabolizer` | Warns if an annotation uses "break down" or "activate" but is for `NON_METABOLIZERS`. | ❌ | ❌ | +| `slow_titration` | If otherwise standard dose, "slow titration" and "cautiously and slowly" should be used together. | ❌ | ❌ | \* 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 8b15ddcd..fd8d950e 100644 --- a/scripts/analyze.py +++ b/scripts/analyze.py @@ -6,6 +6,7 @@ from analyze_functions.checks.fallback_guidelines import check_single_any_fallback_guideline, check_single_lookup_fallback_guideline from analyze_functions.checks.non_metabolizer import check_non_metabolizer from analyze_functions.checks.normal_side_effect_risk import check_normal_side_effect_risk +from analyze_functions.checks.slow_titration import check_slow_titration from analyze_functions.checks.warning_levels import check_green_warning_level, \ check_none_warning_level, check_red_warning_level, \ check_yellow_warning_level @@ -43,6 +44,7 @@ 'annotated_but_not_staged': check_if_fully_annotated_staged, 'should_not_have_normal_risk': check_normal_side_effect_risk, 'non_metabolizer': check_non_metabolizer, + 'slow_titration': check_slow_titration, } GUIDELINE_CORRECTIONS = { diff --git a/scripts/analyze_functions/checks/normal_side_effect_risk.py b/scripts/analyze_functions/checks/normal_side_effect_risk.py index ec494834..4d3964f1 100644 --- a/scripts/analyze_functions/checks/normal_side_effect_risk.py +++ b/scripts/analyze_functions/checks/normal_side_effect_risk.py @@ -1,11 +1,12 @@ from analyze_functions.constants import IGNORED_PHENOTYPES, NORMAL_RISK_TEXTS +from analyze_functions.data_helpers import joint_annotation_text 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(), + joint_annotation_text(guideline), NORMAL_RISK_TEXTS, )) or all(map( lambda gene: diff --git a/scripts/analyze_functions/checks/slow_titration.py b/scripts/analyze_functions/checks/slow_titration.py new file mode 100644 index 00000000..224e1caf --- /dev/null +++ b/scripts/analyze_functions/checks/slow_titration.py @@ -0,0 +1,11 @@ +import analyze_functions.constants as constants +from analyze_functions.data_helpers import get_guideline_content + +def check_slow_titration(args): + guideline = args['item'] + annotations = args['annotations'] + guideline_recommendation = get_guideline_content(guideline, 'recommendation') + should_have_slow_titration = 'slower titration' in guideline_recommendation \ + and not 'lower dose' in annotations['recommendation'] + has_slow_titration = 'cautiously and slowly' in annotations['recommendation'] + return not should_have_slow_titration or has_slow_titration \ No newline at end of file diff --git a/scripts/analyze_functions/data_helpers.py b/scripts/analyze_functions/data_helpers.py index c6edf6ed..5c59dcfe 100644 --- a/scripts/analyze_functions/data_helpers.py +++ b/scripts/analyze_functions/data_helpers.py @@ -1,5 +1,11 @@ from common.constants import BRICK_COLLECTION_NAME +def get_guideline_content(guideline, key): + return guideline['externalData'][0][key] + +def joint_annotation_text(guideline): + return '–'.join(get_guideline_content(guideline, 'implications').values()).lower() + def ensure_unique_item(item_filter, field_name, value): item = list(item_filter) if len(item) != 1: