Skip to content

Commit

Permalink
refactor(scripts): move checks and corrections to files
Browse files Browse the repository at this point in the history
  • Loading branch information
tamslo committed Oct 10, 2024
1 parent 2f6a11b commit 9079c7b
Show file tree
Hide file tree
Showing 12 changed files with 335 additions and 318 deletions.
1 change: 1 addition & 0 deletions pharme.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
"LTRB",
"maxdepth",
"MedlinePlus",
"metabolization",
"Metabolizer",
"metabolizers",
"mirabegron",
Expand Down
6 changes: 3 additions & 3 deletions scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,14 @@ Run `python clean.py` to remove the `scripts/temp` directory and all files in

## Analyze (and correct) annotations

Run `python analyze.py <PATH_TO_BACKUP> [--correct]` to analyze annotations and
optionally correct what can be corrected easily in
Run `python run_analysis.py <PATH_TO_BACKUP> [--correct]` to analyze annotations
and optionally correct what can be corrected easily in
`<PATH_TO_BACKUP>_corrected_<TIMESTAMP>.base64.json`.

| Check | Description | `--correct`ed | Only for single-gene results* |
| ----- | ----------- | ------------- | ----------------------------- |
| `has_consult` | Is "consult your pharmacist..." included in recommendation? |||
| `implication_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. |||
| `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. |||
Expand Down
315 changes: 0 additions & 315 deletions scripts/analyze.py

This file was deleted.

8 changes: 8 additions & 0 deletions scripts/analyze/checks/brand_name_whitespace.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
def check_brand_name_whitespace(_, annotations):
check_applies = True
for brand_name in annotations['brand_names']:
trimmed_name = brand_name.strip()
if trimmed_name != brand_name:
check_applies = False
break
return check_applies
1 change: 1 addition & 0 deletions scripts/analyze/checks/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CONSULT_TEXT = 'consult your pharmacist or doctor'
4 changes: 4 additions & 0 deletions scripts/analyze/checks/consult.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from analyze.checks.constants import CONSULT_TEXT

def has_consult(_, annotations):
return CONSULT_TEXT in annotations['recommendation']
Loading

0 comments on commit 9079c7b

Please sign in to comment.