Skip to content

Commit

Permalink
Update JSON schema validations of Daily Round fields (#2386)
Browse files Browse the repository at this point in the history
---------

Co-authored-by: Aakash Singh <mail@singhaakash.dev>
  • Loading branch information
rithviknishad and sainak authored Sep 21, 2024
1 parent 857fe7e commit 2788679
Show file tree
Hide file tree
Showing 5 changed files with 795 additions and 49 deletions.
7 changes: 7 additions & 0 deletions care/facility/api/serializers/daily_round.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,13 @@ class Meta:
)
exclude = ("deleted",)

def validate_bp(self, value):
if value is not None:
sys, dia = value.get("systolic"), value.get("diastolic")
if sys is not None and dia is not None and sys < dia:
raise ValidationError("Systolic must be greater than diastolic")
return value

def update(self, instance, validated_data):
instance.last_edited_by = self.context["request"].user

Expand Down
Loading

0 comments on commit 2788679

Please sign in to comment.