Skip to content

Add automatic Enrollment Date intervention for new studies#462

Open
tillahoffmann wants to merge 1 commit into
onnela-lab:staged-updatesfrom
tillahoffmann:feature/automatic-enrollment-date-intervention
Open

Add automatic Enrollment Date intervention for new studies#462
tillahoffmann wants to merge 1 commit into
onnela-lab:staged-updatesfrom
tillahoffmann:feature/automatic-enrollment-date-intervention

Conversation

@tillahoffmann

Copy link
Copy Markdown

Summary

  • Automatically creates an "Enrollment Date" intervention when a new study is created
  • Sets the enrollment date when a participant first registers via the mobile app (using the study's timezone)
  • Existing studies are unaffected - no intervention is created on-the-fly

Changes

File Changes
libs/intervention_utils.py Add ENROLLMENT_DATE_INTERVENTION_NAME constant, create_enrollment_date_intervention_for_study(), and set_enrollment_date() functions
endpoints/study_endpoints.py Create intervention on study creation
endpoints/mobile_endpoints.py Set enrollment date on first registration
tests/test_study_endpoints.py Add test for intervention creation
tests/test_mobile_endpoints.py Add 3 tests for enrollment date behavior

Behavior

  • New studies: Automatically get an "Enrollment Date" intervention
  • First registration: Participant's enrollment date is set to today (in study timezone)
  • Re-registration: No change to enrollment date
  • Existing studies: Unaffected (no intervention created retroactively)

Test plan

  • test_create_study_creates_enrollment_date_intervention - Verify intervention created on study creation
  • test_first_registration_sets_enrollment_date - Verify date set on first registration
  • test_subsequent_registration_does_not_change_enrollment_date - Verify re-registration doesn't change date
  • test_registration_without_intervention_does_nothing - Verify existing studies unaffected

🤖 Generated with Claude Code

@biblicabeebli biblicabeebli changed the base branch from main to staged-updates February 6, 2026 19:37
@biblicabeebli

Copy link
Copy Markdown
Member

(December 18? I completely missed this when it came in)

@biblicabeebli

Copy link
Copy Markdown
Member

Likely minor conflicts with bug fix code I'm working on on the file-processing-updates.

@biblicabeebli

Copy link
Copy Markdown
Member

Need to think about a migration that will add the existing first registration date as a new first-registration intervention date.

@hydawo we/I need to think about that in the context of the open source support. Do we need to not have that occur for our own users?

When a new study is created, an "Enrollment Date" intervention is automatically
created. When a participant first registers via the mobile app, their enrollment
date is set to the current date in the study's timezone.

This provides researchers with a built-in intervention date that can be used for
relative scheduling of surveys without manual data entry.

Key changes:
- Add create_enrollment_date_intervention_for_study() and set_enrollment_date()
  helper functions in libs/intervention_utils.py
- Call intervention creation on study creation in study_endpoints.py
- Set enrollment date on first mobile registration in mobile_endpoints.py
- Add tests for both study creation and mobile registration scenarios

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: hydawo <hydawo@gmail.com>
Co-Authored-By: Claude <noreply@anthropic.com>
@tillahoffmann tillahoffmann force-pushed the feature/automatic-enrollment-date-intervention branch from 87b796a to f9def4f Compare February 6, 2026 22:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants