Skip to content

Commit

Permalink
Merge branch 'release/0.3.10' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
erikvw committed Feb 19, 2024
2 parents ac45091 + 5743e83 commit 955b77d
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions edc_he/rule_groups/predicates.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from django.core.exceptions import ObjectDoesNotExist
from edc_constants.constants import YES

Expand All @@ -11,6 +13,10 @@


class Predicates:

def is_required_by_date(self, visit) -> bool:
return True

@staticmethod
def get_household_head(visit):
try:
Expand All @@ -21,10 +27,10 @@ def get_household_head(visit):
obj = None
return obj

@staticmethod
def household_head_required(visit, **kwargs) -> bool:
def household_head_required(self, visit, **kwargs) -> bool:
return (
not get_household_head_model_cls()
self.is_required_by_date(visit)
and not get_household_head_model_cls()
.objects.filter(subject_visit__subject_identifier=visit.subject_identifier)
.exists()
)
Expand All @@ -37,29 +43,30 @@ def patient_required(self, visit, **kwargs) -> bool:
.objects.filter(subject_visit__subject_identifier=visit.subject_identifier)
.exists()
):
required = hoh_obj.hoh == YES
required = hoh_obj.hoh == YES and self.is_required_by_date(visit)

return required

@staticmethod
def assets_required(visit, **kwargs) -> bool:
def assets_required(self, visit, **kwargs) -> bool:
return (
not get_assets_model_cls()
self.is_required_by_date(visit)
and not get_assets_model_cls()
.objects.filter(subject_visit__subject_identifier=visit.subject_identifier)
.exists()
)

@staticmethod
def property_required(visit, **kwargs) -> bool:
def property_required(self, visit, **kwargs) -> bool:
return (
not get_property_model_cls()
self.is_required_by_date(visit)
and not get_property_model_cls()
.objects.filter(subject_visit__subject_identifier=visit.subject_identifier)
.exists()
)

@staticmethod
def income_required(visit, **kwargs) -> bool:
def income_required(self, visit, **kwargs) -> bool:
return (
not get_income_model_cls()
self.is_required_by_date(visit)
and not get_income_model_cls()
.objects.filter(subject_visit__subject_identifier=visit.subject_identifier)
.exists()
)

0 comments on commit 955b77d

Please sign in to comment.