Skip to content

Commit

Permalink
minor changes from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
rithviknishad committed Nov 27, 2023
1 parent 4918308 commit b6dc207
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
5 changes: 1 addition & 4 deletions care/facility/api/serializers/bed.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
)
Expand Down
12 changes: 7 additions & 5 deletions care/facility/api/serializers/patient_consultation.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,13 @@ def validate_create_diagnoses(self, value):

return value

def validate_encounter_date(self, value):
if value > now():
raise ValidationError(

Check warning on line 478 in care/facility/api/serializers/patient_consultation.py

View check run for this annotation

Codecov / codecov/patch

care/facility/api/serializers/patient_consultation.py#L478

Added line #L478 was not covered by tests
{"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
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit b6dc207

Please sign in to comment.