Skip to content

Commit

Permalink
Merge pull request #1951 from coronasafe/staging
Browse files Browse the repository at this point in the history
Merge Staging into Master
  • Loading branch information
gigincg authored Mar 11, 2024
2 parents bd161ef + a5bdee2 commit 90565c2
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 7 deletions.
7 changes: 5 additions & 2 deletions care/facility/api/serializers/daily_round.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,11 @@ def create(self, validated_data):
)
# Authorisation Checks End

# Patient needs to have a bed assigned
if not consultation.current_bed:
# Patient needs to have a bed assigned for admission
if (
not consultation.current_bed
and consultation.suggestion == SuggestionChoices.A
):
raise ValidationError(
{
"bed": "Patient does not have a bed assigned. Please assign a bed first"
Expand Down
26 changes: 22 additions & 4 deletions care/facility/tests/test_patient_daily_rounds_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from rest_framework.test import APITestCase

from care.facility.models import PatientRegistration
from care.facility.models.patient_consultation import PatientConsultation
from care.utils.tests.test_utils import TestUtils


Expand All @@ -19,8 +20,15 @@ def setUpTestData(cls) -> None:
cls.patient = cls.create_patient(district=cls.district, facility=cls.facility)
cls.asset_location = cls.create_asset_location(cls.facility)
cls.bed = cls.create_bed(facility=cls.facility, location=cls.asset_location)
cls.consultation_without_bed = cls.create_consultation(
facility=cls.facility, patient=cls.patient
cls.admission_consultation_no_bed = cls.create_consultation(
facility=cls.facility,
patient=cls.patient,
suggestion=PatientConsultation.SUGGESTION_CHOICES[1][0], # ADMISSION
)
cls.domiciliary_consultation_no_bed = cls.create_consultation(
facility=cls.facility,
patient=cls.patient,
suggestion=PatientConsultation.SUGGESTION_CHOICES[4][0], # DOMICILIARY CARE
)
cls.consultation_with_bed = cls.create_consultation(
facility=cls.facility, patient=cls.patient
Expand Down Expand Up @@ -65,11 +73,11 @@ def test_action_in_log_update(
patient.action, PatientRegistration.ActionEnum.DISCHARGE_RECOMMENDED.value
)

def test_log_update_without_bed(
def test_log_update_without_bed_for_admission(
self,
):
response = self.client.post(
f"/api/v1/consultation/{self.consultation_without_bed.external_id}/daily_rounds/",
f"/api/v1/consultation/{self.admission_consultation_no_bed.external_id}/daily_rounds/",
data=self.log_update,
format="json",
)
Expand All @@ -78,3 +86,13 @@ def test_log_update_without_bed(
response.data["bed"],
"Patient does not have a bed assigned. Please assign a bed first",
)

def test_log_update_without_bed_for_domiciliary(
self,
):
response = self.client.post(
f"/api/v1/consultation/{self.domiciliary_consultation_no_bed.external_id}/daily_rounds/",
data=self.log_update,
format="json",
)
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
4 changes: 3 additions & 1 deletion care/utils/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,9 @@ def get_consultation_data(cls):
"examination_details": "examination_details",
"history_of_present_illness": "history_of_present_illness",
"treatment_plan": "treatment_plan",
"suggestion": PatientConsultation.SUGGESTION_CHOICES[0][0],
"suggestion": PatientConsultation.SUGGESTION_CHOICES[0][
0
], # HOME ISOLATION
"referred_to": None,
"encounter_date": make_aware(datetime(2020, 4, 7, 15, 30)),
"discharge_date": None,
Expand Down

0 comments on commit 90565c2

Please sign in to comment.