Skip to content

Commit

Permalink
feat(#639): add slow titration check
Browse files Browse the repository at this point in the history
  • Loading branch information
tamslo committed Oct 15, 2024
1 parent 525de49 commit a44c22c
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
2 changes: 2 additions & 0 deletions scripts/analyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 = {
Expand Down
3 changes: 2 additions & 1 deletion scripts/analyze_functions/checks/normal_side_effect_risk.py
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
11 changes: 11 additions & 0 deletions scripts/analyze_functions/checks/slow_titration.py
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions scripts/analyze_functions/data_helpers.py
Original file line number Diff line number Diff line change
@@ -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:
Expand Down

0 comments on commit a44c22c

Please sign in to comment.