Add Consent to ODM export (repeating Common event, whitelist-only) - #24
Merged
Conversation
The consent document holds sensitive data, so export ONLY an explicit, non-PII whitelist of fields (subject_identifier, consent_datetime, model_name, version, consent_definition_name) — never the admin fieldsets. Reusable "explicit item list per model" facility: - CONSENT_EXPORT_FIELDS / WHITELIST_FIELDS in constants; get_whitelist_fields() resolves the consent model from settings.SUBJECT_CONSENT_MODEL. - iter_crf_sections() short-circuits to iter_whitelist_fields() for whitelisted models, so a model with sensitive data needs no admin registered and exports only the vetted list. - Safety floor: iter_whitelist_fields() still drops encrypted (PII) and EXCLUDED_FIELD_NAMES fields even if whitelisted, emitting a warning — a sensitive field cannot be re-exposed by adding it to a whitelist. Consent is unique on subject_identifier + version, so it is a *repeating* Common event (Repeating="Yes", Alias event_category="consent", OID CE.<consent_model>); data emits one StudyEventData per consent row with StudyEventRepeatKey=version. Centralized common/screening/consent into iter_subject_level_events() (single source for StudyEventDefs, catalog, and Protocol refs). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds the consent model (
settings.SUBJECT_CONSENT_MODEL) to the CDISC ODM export. Because the consent document holds sensitive data, only an explicit, non-PII whitelist of fields is exported — never the admin fieldsets.Whitelist:
subject_identifier, consent_datetime, model_name, version, consent_definition_name(all real model fields).Reusable "explicit item list per model" facility
CONSENT_EXPORT_FIELDS/WHITELIST_FIELDSinconstants.py;get_whitelist_fields()resolves the consent model from settings.iter_crf_sections()short-circuits toiter_whitelist_fields()for whitelisted models — so a model holding sensitive data needs no admin registered and exports only the vetted list.Safety: a sensitive field can't be re-exposed via the whitelist
iter_whitelist_fields()applies the same PII floor as everywhere else: an encrypted field or anEXCLUDED_FIELD_NAMESfield is dropped even if whitelisted, with aUserWarning. The whitelist is restrictive, intersected with the hard rules — it can add non-sensitive fields but cannot bypass the no-encrypted-fields rule. Plaintext-sensitive additions are caught by review; lists are kept tiny and explicit.Repeating event
Consent is unique on
subject_identifier + version, so it's a repeating Common event:StudyEventDefType="Common",Repeating="Yes",Alias Context="clinicedc.event_category" Name="consent", OIDCE.<consent_model>.StudyEventDataper consent row withStudyEventRepeatKey=<version>.Common/screening/consent are centralized into
iter_subject_level_events()— a single source for the StudyEventDefs, the definition catalog, and the Protocol StudyEventRefs.Tests
12 tests pass (4 new): consent def is repeating + category alias; consent StudyEventData present with repeat key; encrypted PII (
first_name) absent from both metadata and data whileversionis present; whitelist floor drops an encrypted field even when whitelisted.validate_odm(snapshot) == [].🤖 Generated with Claude Code