Skip to content

Commit

Permalink
Merge pull request #3449 from broadinstitute/actually-save-mondo-id
Browse files Browse the repository at this point in the history
Save mondo ID updates
  • Loading branch information
hanars authored Jun 22, 2023
2 parents fed5eed + b9377db commit ffbb828
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
4 changes: 2 additions & 2 deletions seqr/views/apis/individual_api_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -669,8 +669,8 @@ def _send_request_data(data):
self.assertEqual(len(response_json['familiesByGuid']), 1)
family_guid = next(iter(response_json['familiesByGuid'].keys()))
self.assertEqual(response_json['familiesByGuid'][family_guid]['familyId'], 'PED073')
self.assertEqual(response_json['familiesByGuid'][family_guid]['codedPhenotype'], None)
self.assertEqual(response_json['familiesByGuid'][family_guid]['mondoId'], None)
self.assertEqual(response_json['familiesByGuid'][family_guid]['codedPhenotype'], 'Perinatal death')
self.assertEqual(response_json['familiesByGuid'][family_guid]['mondoId'], 'MONDO:0100086')
self.assertSetEqual(set(
response_json['familiesByGuid'][family_guid]['individualGuids']),
set(response_json['individualsByGuid'].keys())
Expand Down
11 changes: 10 additions & 1 deletion seqr/views/utils/individual_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
from matchmaker.models import MatchmakerSubmission, MatchmakerResult
from seqr.models import Sample, IgvSample, Individual, Family, FamilyNote
from seqr.utils.middleware import ErrorsWarningsException
from seqr.views.utils.json_to_orm_utils import update_individual_from_json, update_individual_parents, create_model_from_json
from seqr.views.utils.json_to_orm_utils import update_individual_from_json, update_individual_parents, create_model_from_json, \
update_family_from_json
from seqr.views.utils.orm_to_json_utils import _get_json_for_individuals, _get_json_for_families, get_json_for_family_notes
from seqr.views.utils.pedigree_info_utils import JsonConstants

Expand Down Expand Up @@ -143,6 +144,14 @@ def _update_from_record(record, user, families_by_id, individual_lookup, updated
note = create_model_from_json(FamilyNote, {'note': family_notes, 'note_type': 'C', 'family': family}, user)
updated_note_ids.append(note.id)

family_record = {
k: record.pop(k) for k in [JsonConstants.CODED_PHENOTYPE_COLUMN, JsonConstants.MONDO_ID_COLUMN] if k in record
}
if family_record:
is_updated = update_family_from_json(family, family_record, user=user)
if is_updated:
updated_family_ids.add(family.id)

is_updated = update_individual_from_json(individual, record, user=user, allow_unknown_keys=True)
if is_updated:
updated_individuals.add(individual)
Expand Down
2 changes: 1 addition & 1 deletion seqr/views/utils/json_to_orm_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def update_family_from_json(family, json, user, allow_unknown_keys=False, immuta

immutable_keys = (immutable_keys or []) + ['pedigree_image', 'assigned_analyst', 'case_review_summary', 'case_review_notes', 'guid']

update_model_from_json(
return update_model_from_json(
family, json, user=user, allow_unknown_keys=allow_unknown_keys, immutable_keys=immutable_keys,
)

Expand Down

0 comments on commit ffbb828

Please sign in to comment.