Skip to content

Commit

Permalink
Merge branch 'update-check-date-within-study-period' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathanWillitts committed Sep 17, 2024
2 parents 89cbb1d + 2606fed commit bc330d4
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions edc_consent/consent_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,16 +174,21 @@ def check_date_within_study_period(self) -> None:
protocol = ResearchProtocolConfig()
study_open_datetime = protocol.study_open_datetime
study_close_datetime = protocol.study_close_datetime
for index, attr in enumerate(["start", "end"]):
for attr in ["start", "end"]:
if not (
floor_secs(study_open_datetime)
<= getattr(self, attr)
<= ceil_secs(study_close_datetime)
):
date_string = formatted_datetime(getattr(self, attr))
open_date_string = formatted_datetime(study_open_datetime)
close_date_string = formatted_datetime(study_close_datetime)
attr_date_string = formatted_datetime(getattr(self, attr))
raise ConsentDefinitionError(
f"Invalid {attr} date. Cannot be before study start date. "
f"See {self}. Got {date_string}."
f"Invalid {attr} date. "
f"Must be within the opening and closing dates of the protocol. "
f"See {self}. "
f"Got {open_date_string=}, {close_date_string=}, "
f"{attr=}, {attr_date_string=}."
)

def get_previous_consent(
Expand Down

0 comments on commit bc330d4

Please sign in to comment.