Skip to content

Commit

Permalink
Merge 952cbce into e3b93f0
Browse files Browse the repository at this point in the history
  • Loading branch information
fredkingham committed Apr 7, 2020
2 parents e3b93f0 + 952cbce commit 59b4fb3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion elcid/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ def to_dict(self, *args, **kwargs):
if MicroInputICURoundRelation.objects.filter(microbiology_input_id=self.id).exists():
result["micro_input_icu_round_relation"] = self.microinputicuroundrelation.to_dict(*args, **kwargs)
else:
result["micro_input_icu_round_relation"] = {}
result["micro_input_icu_round_relation"] = MicroInputICURoundRelation().to_dict()
return result

def update_from_dict(self, data, *args, **kwargs):
Expand Down
9 changes: 9 additions & 0 deletions elcid/test/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,15 @@ def test_to_dict(self):
as_dict["micro_input_icu_round_relation"]["icu_round"]["sofa_score"]
)

def test_to_dict_for_no_icu_round(self):
micro_input = emodels.MicrobiologyInput.objects.create(
episode=self.episode,
clinical_discussion="some discussion"
)
as_dict = micro_input.to_dict(None)
self.assertEqual(as_dict["micro_input_icu_round_relation"]["observation"], {})
self.assertEqual(as_dict["micro_input_icu_round_relation"]["icu_round"], {})

def test_delete_with_icu_round(self):
micro_input = emodels.MicrobiologyInput.objects.create(
episode=self.episode,
Expand Down

0 comments on commit 59b4fb3

Please sign in to comment.