diff --git a/care/facility/api/serializers/bed.py b/care/facility/api/serializers/bed.py index ca3c885d29..832a0a01dd 100644 --- a/care/facility/api/serializers/bed.py +++ b/care/facility/api/serializers/bed.py @@ -235,10 +235,7 @@ def validate(self, attrs): raise ValidationError( {"end_date": "End date cannot be before the start date"} ) - if ( - consultation.encounter_date - and consultation.encounter_date > current_start_date - ): + if consultation.encounter_date > current_start_date: raise ValidationError( {"start_date": "Start date cannot be before the admission date"} ) diff --git a/care/facility/api/serializers/patient_consultation.py b/care/facility/api/serializers/patient_consultation.py index f3528998fa..712d85882d 100644 --- a/care/facility/api/serializers/patient_consultation.py +++ b/care/facility/api/serializers/patient_consultation.py @@ -473,6 +473,13 @@ def validate_create_diagnoses(self, value): return value + def validate_encounter_date(self, value): + if value > now(): + raise ValidationError( + {"encounter_date": "This field value cannot be in the future."} + ) + return value + def validate(self, attrs): validated = super().validate(attrs) # TODO Add Bed Authorisation Validation @@ -525,11 +532,6 @@ def validate(self, attrs): elif validated.get("referred_to"): validated["referred_to_external"] = None - if "encounter_date" in validated and validated["encounter_date"] > now(): - raise ValidationError( - {"encounter_date": "This field value cannot be in the future."} - ) - if "action" in validated: if validated["action"] == PatientRegistration.ActionEnum.REVIEW: if "review_interval" not in validated: