Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge Staging into Master #1951

Merged
merged 5 commits into from Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions care/facility/api/serializers/daily_round.py
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
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
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