SfSkills Domains Docs GitHub

Home / data / consent-data-model-health

consent-data-model-health

Designing, querying, or troubleshooting the Health Cloud consent data model — the five-object HIPAA authorization hierarchy (DataUsePurpose → AuthorizationForm → AuthorizationFormText → AuthorizationFormDataUse → AuthorizationFormConsent).

Open the skill folder on GitHub


Consent Data Model Health

This skill activates when building or auditing the authorization-form consent records a Health Cloud implementation relies on: which records make up the chain, which fields an auditor will read, how to check consent for a specific purpose before using patient data, and why the consent records and the sharing model must be designed separately.


Before Starting

Gather this context before working on anything in this domain:


Questions to Ask Before Configuring

AskWhy it mattersWhat a good answer adds
"Which object is the consent giver in every query and every intake path?"ConsentGiverId is polymorphic; a Contact Id saves fine but won't match a check written for Individual Ids (Gotcha 2)One documented giver type, enforced in the intake automation
"Which purposes does each form cover?"AuthorizationFormDataUse links a form (not a form text) to a DataUsePurpose (Gotcha 6)A purpose map per form, and a check that filters on the purpose
"How is a new legal version of the form introduced?"Consents point at the form text they were given against; editing that text in place rewrites history (Gotcha 4)A new AuthorizationFormText per version
"What counts as consent: Signed only, and how is a rejection recorded?"Status is a restricted picklist with Rejected, Seen, and Signed (Gotcha 5)A rule per form, and rejections stored as Rejected rather than deleted
"Must enrollment be blocked until consent exists?"Nothing in the data model stops a CareProgramEnrollee from being activated without consent (Gotcha 3)A before-save gate on enrollment
"Who should see a patient's clinical records, independent of consent?"Consent records don't change sharing (Gotcha 1)A separate sharing design for PHI objects
"What evidence will an auditor ask for?"ConsentCapturedDateTime, ConsentCapturedSource, and ConsentCapturedSourceType are required fields (Gotcha 7)Intake that fills all three, plus the form text Id

A proper consent design adds a single giver type, purpose-specific checks, versioned form texts, and an enforced gate; "just storing a consent record" produces records no query can find and enrollments nobody can defend.


Core Concepts

The objects and the fields that matter

ObjectPurposeKey fields
DataUsePurposeWhy data is used (Treatment, Research)Name, CanDataSubjectOptOut, LegalBasisId
AuthorizationFormA form, with effective datesIsSignatureRequired, DefaultAuthFormTextId, EffectiveFromDate, EffectiveToDate, RevisionNumber
AuthorizationFormTextA form's text and languageAuthorizationFormId, ContentDocumentId, DetailAuthorizationFormText, FullAuthorizationFormUrl, Locale
AuthorizationFormDataUseLinks a form to a purposeAuthorizationFormId, DataUsePurposeId
AuthorizationFormConsentOne person's consent to one form textConsentGiverId, AuthorizationFormTextId, Status, ConsentCapturedDateTime, ConsentCapturedSource, ConsentCapturedSourceType, DocumentVersionId, RelatedRecordId

Status values are Rejected, Seen, and Signed (restricted picklist). ConsentCapturedSourceType is a restricted picklist (Email, InPerson, MailingAddress, Phone, Social, Video, Web); ConsentCapturedSource is free text such as an email address or URL.

AuthorizationFormConsent is a record of what a person agreed to. Each consent object has its own sharing (...Share objects and owner sharing rules), but no field on it changes who can see clinical records. PHI access is designed with OWDs, sharing rules, and permission sets.

ContactPointTypeConsent (consent for a contact point type, such as email or phone) and ContactPointConsent (consent to be contacted through a specific email address or phone number) record communication preferences. They are not authorization-form consents and don't satisfy a check written against AuthorizationFormConsent.

<?xml version="1.0" encoding="UTF-8"?>
<!-- permissionsets/Consent_Intake.permissionset-meta.xml: intake users can record consent but not edit or delete it -->
<PermissionSet xmlns="http://soap.sforce.com/2006/04/metadata">
    <label>Consent Intake</label>
    <objectPermissions>
        <object>AuthorizationFormConsent</object>
        <allowCreate>true</allowCreate>
        <allowRead>true</allowRead>
        <allowEdit>false</allowEdit>
        <allowDelete>false</allowDelete>
        <viewAllRecords>false</viewAllRecords>
        <modifyAllRecords>false</modifyAllRecords>
    </objectPermissions>
    <objectPermissions>
        <object>AuthorizationFormText</object>
        <allowCreate>false</allowCreate>
        <allowRead>true</allowRead>
        <allowEdit>false</allowEdit>
        <allowDelete>false</allowDelete>
        <viewAllRecords>false</viewAllRecords>
        <modifyAllRecords>false</modifyAllRecords>
    </objectPermissions>
</PermissionSet>

Common Patterns

  1. Create (or reuse) DataUsePurpose Treatment.
  2. Create AuthorizationForm General Patient Consent with IsSignatureRequired = true and effective dates.
  3. Create AuthorizationFormText v1 (AuthorizationFormId, the document or text, Locale), and set it as the form's DefaultAuthFormTextId.
  4. Create AuthorizationFormDataUse linking the form to Treatment.
  5. At intake, create AuthorizationFormConsent with ConsentGiverId = the patient's Individual Id, AuthorizationFormTextId = the text shown, Status = Signed, and all three captured fields.
public with sharing class ConsentCheck {
    public static Boolean hasSignedConsent(Id individualId, String purposeName) {
        Set<Id> formIds = new Set<Id>();
        for (AuthorizationFormDataUse du : [
            SELECT AuthorizationFormId FROM AuthorizationFormDataUse
            WHERE DataUsePurpose.Name = :purposeName
        ]) {
            formIds.add(du.AuthorizationFormId);
        }
        if (formIds.isEmpty()) {
            return false;
        }
        return ![
            SELECT Id FROM AuthorizationFormConsent
            WHERE ConsentGiverId = :individualId
            AND Status = 'Signed'
            AND AuthorizationFormText.AuthorizationFormId IN :formIds
            ORDER BY ConsentCapturedDateTime DESC
            LIMIT 1
        ].isEmpty();
    }
}

The purpose hangs off the form, so the check finds the forms for the purpose first, then a signed consent to any text of those forms.


Decision Guidance

SituationRecommended approachReason
Enrollment must wait for consentBefore-save Flow or Apex on CareProgramEnrollee using Pattern 2The data model doesn't enforce it
New legal wordingNew AuthorizationFormText; update DefaultAuthFormTextIdExisting consents keep pointing at the text they were given against
Patient declines or withdrawsNew AuthorizationFormConsent with Status = RejectedKeeps the earlier record as history
Restrict PHI after withdrawalChange sharing or permission set assignmentsConsent status doesn't alter visibility
Communication preferencesContactPointTypeConsent / ContactPointConsentSeparate model for contact preferences

  1. Export the hierarchy (SELECT Id, Name FROM DataUsePurpose, forms, texts, data uses) and record the giver-type decision and the purpose map in templates/consent-data-model-health-template.md.
  2. Build or fix the hierarchy top-down (purpose, form, text, data use), one text per legal version.
  3. Instrument intake so every consent row gets the Individual Id, the text Id, Status, and the three captured fields; add the enrollment gate.
  4. Export consent rows with ConsentGiver.Type (SELECT Id, ConsentGiverId, ConsentGiver.Type, Status, ConsentCapturedSource, ConsentCapturedSourceType, ConsentCapturedDateTime, AuthorizationFormTextId FROM AuthorizationFormConsent) as JSON into a folder with the metadata export.
  5. Run python3 skills/data/consent-data-model-health/scripts/check_consent_data_model_health.py --manifest-dir <export folder> and fix every ERROR; references/consent-audit-worked-example.md walks through one audit.
  6. Review sharing for PHI objects separately and record the result.

Review Checklist


Salesforce-Specific Gotchas

Full write-ups are in references/gotchas.md:

#Gotcha
1Consent records don't change who can see clinical records
2ConsentGiverId accepts five object types
3The enrollment gate isn't in the data model
4Editing form text in place rewrites what patients appear to have signed
5Status is a restricted picklist with three values
6Purposes attach to the form, not the form text
7Source and source type are different fields

Output Artifacts

ArtifactDescription
Consent hierarchyPurposes, forms, versioned texts, and data uses, linked correctly
Intake changesAutomation that writes complete consent rows
Purpose-specific checkApex or Flow implementing Pattern 2
Enrollment gateBefore-save automation on CareProgramEnrollee
Audit reportChecker output and the filled template

Package files