From 9e02f3673eccbdbf83645d7503194ac237349670 Mon Sep 17 00:00:00 2001 From: Bharath Reddy Kandula <65353049+Bharath-kandula@users.noreply.github.com> Date: Tue, 12 Sep 2023 10:47:58 +1000 Subject: [PATCH] #109 Condition matching to override blank condition (#886) * #3384 fixed discordance weekly email table heading * #109 condition override blank condition --- ...on_matching_to_override_blank_condition.py | 18 +++++++++++++++ ...ition_matching_override_blank condition.py | 23 +++++++++++++++++++ classification/models/classification.py | 10 +++++--- 3 files changed, 48 insertions(+), 3 deletions(-) create mode 100644 classification/management/commands/condition_matching_to_override_blank_condition.py create mode 100644 classification/migrations/0109_condition_matching_override_blank condition.py diff --git a/classification/management/commands/condition_matching_to_override_blank_condition.py b/classification/management/commands/condition_matching_to_override_blank_condition.py new file mode 100644 index 000000000..404e252c7 --- /dev/null +++ b/classification/management/commands/condition_matching_to_override_blank_condition.py @@ -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.")) diff --git a/classification/migrations/0109_condition_matching_override_blank condition.py b/classification/migrations/0109_condition_matching_override_blank condition.py new file mode 100644 index 000000000..871f82a04 --- /dev/null +++ b/classification/migrations/0109_condition_matching_override_blank condition.py @@ -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) + ] diff --git a/classification/models/classification.py b/classification/models/classification.py index 84ab5bc46..39837b85c 100644 --- a/classification/models/classification.py +++ b/classification/models/classification.py @@ -1086,9 +1086,13 @@ def process_entry(self, cell: VCDataCell, source: str): value = value.replace('>', '>').replace('<', '<') 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):