Skip to content

Commit

Permalink
#109 Condition matching to override blank condition (#886)
Browse files Browse the repository at this point in the history
* #3384 fixed discordance weekly email table heading

* #109 condition override blank condition
  • Loading branch information
Bharath-kandula authored and TheMadBug committed Sep 12, 2023
1 parent 0f468ff commit 5a1937b
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from django.core.management.base import BaseCommand
from classification.models import Classification
from library.guardian_utils import admin_bot


class Command(BaseCommand):

def handle(self, *args, **options):
user = admin_bot()
classifications = Classification.objects.filter(
condition_resolution__isnull=False,
evidence__condition__validation__icontains="error"
)
print(f"Found {classifications.count()} in database")
for classification in classifications:
print(f"Revalidating {classification}")
classification.revalidate(user=user)
self.stdout.write(self.style.SUCCESS("Revalidation completed to override blank condition."))
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 4.2.2 on 2023-08-14 23:42
from django.db import migrations
from manual.operations.manual_operations import ManualOperation


def _override_blank_condition(apps):
Classification = apps.get_model("classification", "Classification")
condition_check = Classification.objects.filter(
condition_resolution__isnull=False,
evidence__condition__validation__icontains="error")
return condition_check.exists()


class Migration(migrations.Migration):

dependencies = [
('classification', '0108_discordancereporttriage'),
]

operations = [
ManualOperation(task_id=ManualOperation.task_id_manage(["condition_matching_to_override_blank_condition"]),
test=_override_blank_condition)
]
10 changes: 7 additions & 3 deletions classification/models/classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -1086,9 +1086,13 @@ def process_entry(self, cell: VCDataCell, source: str):
value = value.replace('&gt;', '>').replace('&lt;', '<')

if value is None and e_key.mandatory and not e_key.exclude_namespace:
# only provide mandatory validation for internal labs
# don't want to dirty up imported read only classifications with errors
cell.add_validation(code=ValidationCode.MANDATORY, severity='error', message='Missing mandatory value')
if e_key.key == SpecialEKeys.CONDITION and self.condition_resolution_obj:
# Gene condition is not mandatory if we have a condition resolution
pass
else:
# only provide mandatory validation for internal labs
# don't want to dirty up imported read only classifications with errors
cell.add_validation(code=ValidationCode.MANDATORY, severity='error', message='Missing mandatory value')

# if we got an array of values
if isinstance(value, list):
Expand Down

0 comments on commit 5a1937b

Please sign in to comment.