Skip to content

Commit bc330d4

Browse files
Merge branch 'update-check-date-within-study-period' into develop
2 parents 89cbb1d + 2606fed commit bc330d4

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

edc_consent/consent_definition.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,16 +174,21 @@ def check_date_within_study_period(self) -> None:
174174
protocol = ResearchProtocolConfig()
175175
study_open_datetime = protocol.study_open_datetime
176176
study_close_datetime = protocol.study_close_datetime
177-
for index, attr in enumerate(["start", "end"]):
177+
for attr in ["start", "end"]:
178178
if not (
179179
floor_secs(study_open_datetime)
180180
<= getattr(self, attr)
181181
<= ceil_secs(study_close_datetime)
182182
):
183-
date_string = formatted_datetime(getattr(self, attr))
183+
open_date_string = formatted_datetime(study_open_datetime)
184+
close_date_string = formatted_datetime(study_close_datetime)
185+
attr_date_string = formatted_datetime(getattr(self, attr))
184186
raise ConsentDefinitionError(
185-
f"Invalid {attr} date. Cannot be before study start date. "
186-
f"See {self}. Got {date_string}."
187+
f"Invalid {attr} date. "
188+
f"Must be within the opening and closing dates of the protocol. "
189+
f"See {self}. "
190+
f"Got {open_date_string=}, {close_date_string=}, "
191+
f"{attr=}, {attr_date_string=}."
187192
)
188193

189194
def get_previous_consent(

0 commit comments

Comments
 (0)