diff --git a/smash/web/api_views/subject.py b/smash/web/api_views/subject.py index 5652f8bd26257ddd474a35e83d627347948dcb08..c4a0fa3c8bf0a75fada9c2dd91f8141e6bcaa9ab 100644 --- a/smash/web/api_views/subject.py +++ b/smash/web/api_views/subject.py @@ -308,27 +308,37 @@ def get_subjects_filtered(subjects_to_be_filtered, filters): result = result.filter(endpoint_reached=(value == "true")) elif column == "virus_test_1": if value == "null": - result = result.filter(virus_test_1__isnull=True) + result = result.filter(virus_test_1__isnull=True, virus_test_1_updated__isnull=True) + elif value == "inconclusive": + result = result.filter(virus_test_1__isnull=True, virus_test_1_updated__isnull=False) else: result = result.filter(virus_test_1=(value == "true")) elif column == "virus_test_2": if value == "null": - result = result.filter(virus_test_2__isnull=True) + result = result.filter(virus_test_2__isnull=True, virus_test_2_updated__isnull=True) + elif value == "inconclusive": + result = result.filter(virus_test_2__isnull=True, virus_test_2_updated__isnull=False) else: result = result.filter(virus_test_2=(value == "true")) elif column == "virus_test_3": if value == "null": - result = result.filter(virus_test_3__isnull=True) + result = result.filter(virus_test_3__isnull=True, virus_test_3_updated__isnull=True) + elif value == "inconclusive": + result = result.filter(virus_test_3__isnull=True, virus_test_3_updated__isnull=False) else: result = result.filter(virus_test_3=(value == "true")) elif column == "virus_test_4": if value == "null": - result = result.filter(virus_test_4__isnull=True) + result = result.filter(virus_test_4__isnull=True, virus_test_4_updated__isnull=True) + elif value == "inconclusive": + result = result.filter(virus_test_4__isnull=True, virus_test_4_updated__isnull=False) else: result = result.filter(virus_test_4=(value == "true")) elif column == "virus_test_5": if value == "null": - result = result.filter(virus_test_5__isnull=True) + result = result.filter(virus_test_5__isnull=True, virus_test_5_updated__isnull=True) + elif value == "inconclusive": + result = result.filter(virus_test_5__isnull=True, virus_test_5_updated__isnull=False) else: result = result.filter(virus_test_5=(value == "true")) elif column == "brain_donation_agreement": @@ -496,11 +506,11 @@ def serialize_subject(study_subject): "dead": bool_to_yes_no(study_subject.subject.dead), "resigned": bool_to_yes_no(study_subject.resigned), "endpoint_reached": bool_to_yes_no(study_subject.endpoint_reached), - "virus_test_1": bool_to_yes_no_null(study_subject.virus_test_1), - "virus_test_2": bool_to_yes_no_null(study_subject.virus_test_2), - "virus_test_3": bool_to_yes_no_null(study_subject.virus_test_3), - "virus_test_4": bool_to_yes_no_null(study_subject.virus_test_4), - "virus_test_5": bool_to_yes_no_null(study_subject.virus_test_5), + "virus_test_1": virus_test_to_str(study_subject.virus_test_1, study_subject.virus_test_1_updated), + "virus_test_2": virus_test_to_str(study_subject.virus_test_2, study_subject.virus_test_2_updated), + "virus_test_3": virus_test_to_str(study_subject.virus_test_3, study_subject.virus_test_3_updated), + "virus_test_4": virus_test_to_str(study_subject.virus_test_4, study_subject.virus_test_4_updated), + "virus_test_5": virus_test_to_str(study_subject.virus_test_5, study_subject.virus_test_5_updated), "virus_test_1_updated": study_subject.virus_test_1_updated, "virus_test_2_updated": study_subject.virus_test_2_updated, "virus_test_3_updated": study_subject.virus_test_3_updated,