Health Cloud Apex Extensions
This skill activates when a practitioner needs to extend Salesforce Health Cloud behavior through Apex, specifically using the HealthCloudGA managed-package namespace, Health Cloud invocable actions for care plan automation, Industries Common Components for referral processing, or when governance of PHI-containing Apex debug logs is required.
Before Starting
Gather this context before working on anything in this domain:
- Confirm the
HealthCloudGA managed package is installed and the version number. Interface signatures and available invocable actions vary across package releases.
- Determine whether the org uses the Integrated Care Management (ICM) data model or the legacy
CarePlanTemplate__c model. Extension points differ between the two.
- Identify whether Apex debug logs are enabled in production. Logs containing
EhrPatientMedication, PatientHealthCondition, or similar clinical objects constitute PHI and require governance.
- Confirm the org has
AuthorizationFormConsent properly configured — bypassing consent enforcement through direct DML is a compliance and data integrity risk.
Core Concepts
HealthCloudGA Namespace and Managed-Package Interfaces
Health Cloud ships as a managed package under the HealthCloudGA namespace. Extension points are provided as Apex interfaces and abstract classes within this namespace. The most critical is HealthCloudGA.CarePlanProcessorCallback, which exposes lifecycle hooks for care plan creation, activation, and closure. Implementing this interface requires your class to be declared globally, and the implementation must be registered in Health Cloud Setup — simply deploying the class is insufficient. Interface method signatures are enforced by the managed package; mismatched signatures fail at deploy time.
Care Plan Invocable Actions vs. Raw DML
Health Cloud provides built-in invocable actions — CreateCarePlan, AddCarePlanGoal, AddCarePlanProblem — that encapsulate the full automation logic for care plan records. These actions enforce consent checks via AuthorizationFormConsent, trigger care plan lifecycle events, and maintain data integrity within the Health Cloud data model. Using raw insert or update DML on CarePlanTemplate__c, CarePlan, or related objects bypasses all of this automation. The result is care plan records in an inconsistent state: goals created without the proper problem linkages, consent not evaluated, and lifecycle callbacks not fired. Always invoke care plan changes through the provided invocable actions or the HealthCloudGA Apex service layer.
Industries Common Components — Referral Processing
The Industries Common Components (ICC) framework powers referral processing in Health Cloud. Referrals are represented as ReferralRequest and ReferralResponse records. The framework exposes Apex invocable actions for referral submission, status updates, and routing logic. Apex classes that need to trigger referral workflows must call these invocable actions rather than performing DML on ReferralRequest directly, for the same reasons as care plan invocable actions: the framework enforces business rules, consent, and notification logic at the action layer.
HIPAA Apex Logging Governance
Salesforce Apex debug logs are not subject to field-level security or sharing rules — a log entry that captures a SOQL query result or a variable inspect for EhrPatientMedication, PatientHealthCondition, ClinicalEncounterCode, or similar clinical objects writes PHI as plain text to the debug log store. Under HIPAA, this constitutes a data exposure risk. Production debug logging must be disabled or tightly scoped (specific user, short duration), logs must be purged after use, and no automated process should retain clinical-field variable dumps in long-lived log stores. This applies equally to System.debug() calls in trigger handlers and to Flow-launched Apex actions.
Common Patterns
Implementing CarePlanProcessorCallback
When to use: You need to execute custom logic when a care plan transitions state — e.g., notifying a care coordinator when a care plan is activated, or creating a Task when a care plan closes.
How it works:
- Declare a
global Apex class implementing HealthCloudGA.CarePlanProcessorCallback.
- Implement the required interface methods:
onCarePlanCreate, onCarePlanActivate, onCarePlanClose (exact method signatures depend on the installed package version — always reference the installed namespace documentation).
- Register the class name in Health Cloud Setup > Care Plan Settings > Custom Apex Callback.
- Keep callback logic lightweight: avoid synchronous callouts, limit SOQL to selective queries, and delegate heavy work to
@future or Queueable Apex to stay within governor limits.
Why not the alternative: Adding an Apex trigger on the CarePlan object fires outside the Health Cloud lifecycle framework. It cannot reliably intercept all state transitions and misses events triggered by managed-package automation.
Referral Invocable Action Pattern
When to use: An Apex class or Flow needs to create or update a referral programmatically — e.g., when a clinical intake process determines that an external specialist referral is required.
How it works:
- Use
Invocable.Action to invoke the industries_referral_mgmt__CreateReferral or equivalent ICC invocable action from Apex rather than performing insert new ReferralRequest__c(...).
- Populate the input
ReferralRequest wrapper object with patient context, referring provider, and target specialty.
- Evaluate the
ReferralResponse output for status and any error messages before proceeding.
- If the referral fails validation, surface the error to the user via a platform event or record status field — do not silently swallow the response.
Why not the alternative: Direct DML on ReferralRequest__c skips the ICC business rules engine, consent checks, and provider matching logic. The resulting record may be technically valid in the database but functionally broken in the referral management UI and reporting.
Decision Guidance
| Situation |
Recommended Approach |
Reason |
| Execute logic when a care plan is activated |
Implement HealthCloudGA.CarePlanProcessorCallback and register it in Health Cloud Setup |
Fires reliably within the managed-package lifecycle; Apex trigger on CarePlan does not catch all transitions |
| Create a care plan from Apex |
Call the CreateCarePlan invocable action via Invocable.Action |
Enforces consent evaluation and lifecycle hooks; raw DML bypasses both |
| Process an inbound referral |
Use ICC industries_referral_mgmt__CreateReferral invocable action |
Applies provider matching, consent, and routing rules from the ICC framework |
| Add a goal to an existing care plan |
Call AddCarePlanGoal invocable action |
Maintains data model integrity; direct DML on CarePlanGoal may produce orphaned records |
| Log debug info in a class touching clinical objects |
Use conditional debug logging gated by a Custom Setting or Custom Metadata flag |
Prevents PHI from entering debug logs in production; gate on environment type |
| Validate care plan Apex in a scratch org |
Use a Health Cloud scratch org definition with Health Cloud features enabled |
Ensures HealthCloudGA namespace and test data factories are available |
Recommended Workflow
Step-by-step instructions for an AI agent or practitioner working on this task:
- Confirm the installed
HealthCloudGA package version and identify the specific extension point needed (callback interface, invocable action, or ICC action). Pull the interface signature from the namespace documentation or by inspecting the installed package in Setup > Installed Packages.
- Determine whether the request involves care plan lifecycle, referral processing, or general clinical data automation. Route to the appropriate pattern:
CarePlanProcessorCallback for lifecycle hooks, CreateCarePlan/AddCarePlanGoal invocable actions for care plan data, or ICC actions for referrals.
- Implement the Apex class: declare it
global if it implements a HealthCloudGA interface, use Invocable.Action for action-based calls, and ensure all DML on Health Cloud clinical objects is routed through the appropriate service layer rather than direct DML.
- Audit all
System.debug() calls and SOQL result references in the class — remove or gate any statements that would dump clinical object fields (EhrPatientMedication, PatientHealthCondition, ClinicalEncounterCode, AuthorizationFormConsent) into debug logs. Add a Custom Metadata-based debug gate.
- Register the callback class in Health Cloud Setup if using
CarePlanProcessorCallback, write unit tests using @IsTest with Health Cloud test data factories, and verify that no direct DML on CarePlan, CarePlanTemplate__c, or ReferralRequest__c remains in the code path.
Review Checklist
Run through these before marking work in this area complete:
Salesforce-Specific Gotchas
Non-obvious platform behaviors that cause real production problems:
- CarePlanProcessorCallback requires Setup registration — Deploying a class that implements
HealthCloudGA.CarePlanProcessorCallback is not sufficient. The class name must be explicitly registered in Health Cloud Setup > Care Plan Settings. An unregistered callback silently does nothing; there is no deploy-time or runtime error.
- Direct DML on clinical objects bypasses consent enforcement — Inserting or updating
CarePlan, CarePlanGoal, or CarePlanProblem directly bypasses AuthorizationFormConsent evaluation. The record is created, but the consent check never fires. This is both a compliance gap and a functional gap — Health Cloud UI features that depend on consent state will behave inconsistently.
- Apex debug logs containing clinical fields are PHI —
EhrPatientMedication, PatientHealthCondition, ClinicalEncounterCode, and similar objects contain protected health information. Debug logs are stored in plaintext and are accessible to any system administrator. Production debug logging on clinical Apex classes must be disabled by default, time-limited when enabled for troubleshooting, and purged immediately after use.
Output Artifacts
| Artifact |
Description |
| Compliant HealthCloudGA Apex extension class |
A global Apex class implementing the target HealthCloudGA interface with correct method signatures and Setup registration instructions |
| Invocable action call pattern |
Apex snippet using Invocable.Action to call CreateCarePlan, AddCarePlanGoal, or ICC referral actions with input/output handling |
| Debug logging governance checklist |
List of System.debug() statements audited for PHI exposure with recommended Custom Metadata gate pattern |
| Unit test scaffold |
@IsTest class covering callback methods and action calls, using Health Cloud test data factories where available |
Related Skills
admin/care-plan-configuration — Required prerequisite: care plan templates and ICM configuration must be in place before Apex extensions can be effectively implemented or tested
apex/apex-security-patterns — Security patterns for FLS, CRUD, and sharing enforcement that also apply to clinical Apex classes
apex/clinical-decision-support — Clinical decision logic patterns that frequently interact with care plan and referral Apex extension points
1---2name: health-cloud-apex-extensions3description: Use this skill when extending Health Cloud via Apex: implementing HealthCloudGA managed-package interfaces, automating care plan lifecycle hooks, processing referrals using Industries Common Components invocable actions, or enforcing HIPAA-compliant logging governance for clinical Apex code. Trigger keywords: CarePlanProcessorCallback, HealthCloudGA namespace, ReferralRequest, ReferralResponse, care plan invocable actions, clinical Apex extension, Health Cloud Apex API. NOT for standard Apex triggers or generic Apex development unrelated to Health Cloud managed-package extension points. NOT for creating ClinicalAlert or CareGap decision-support records — use apex/clinical-decision-support. NOT for HealthCloudGA package install order, PSL assignment, or post-deploy setup — use devops/health-cloud-deployment-patterns.4---56# Health Cloud Apex Extensions78This skill activates when a practitioner needs to extend Salesforce Health Cloud behavior through Apex, specifically using the `HealthCloudGA` managed-package namespace, Health Cloud invocable actions for care plan automation, Industries Common Components for referral processing, or when governance of PHI-containing Apex debug logs is required.910---1112## Before Starting1314Gather this context before working on anything in this domain:1516- Confirm the `HealthCloudGA` managed package is installed and the version number. Interface signatures and available invocable actions vary across package releases.17- Determine whether the org uses the Integrated Care Management (ICM) data model or the legacy `CarePlanTemplate__c` model. Extension points differ between the two.18- Identify whether Apex debug logs are enabled in production. Logs containing `EhrPatientMedication`, `PatientHealthCondition`, or similar clinical objects constitute PHI and require governance.19- Confirm the org has `AuthorizationFormConsent` properly configured — bypassing consent enforcement through direct DML is a compliance and data integrity risk.2021---2223## Core Concepts2425### HealthCloudGA Namespace and Managed-Package Interfaces2627Health Cloud ships as a managed package under the `HealthCloudGA` namespace. Extension points are provided as Apex interfaces and abstract classes within this namespace. The most critical is `HealthCloudGA.CarePlanProcessorCallback`, which exposes lifecycle hooks for care plan creation, activation, and closure. Implementing this interface requires your class to be declared globally, and the implementation must be registered in Health Cloud Setup — simply deploying the class is insufficient. Interface method signatures are enforced by the managed package; mismatched signatures fail at deploy time.2829### Care Plan Invocable Actions vs. Raw DML3031Health Cloud provides built-in invocable actions — `CreateCarePlan`, `AddCarePlanGoal`, `AddCarePlanProblem` — that encapsulate the full automation logic for care plan records. These actions enforce consent checks via `AuthorizationFormConsent`, trigger care plan lifecycle events, and maintain data integrity within the Health Cloud data model. Using raw `insert` or `update` DML on `CarePlanTemplate__c`, `CarePlan`, or related objects bypasses all of this automation. The result is care plan records in an inconsistent state: goals created without the proper problem linkages, consent not evaluated, and lifecycle callbacks not fired. Always invoke care plan changes through the provided invocable actions or the `HealthCloudGA` Apex service layer.3233### Industries Common Components — Referral Processing3435The Industries Common Components (ICC) framework powers referral processing in Health Cloud. Referrals are represented as `ReferralRequest` and `ReferralResponse` records. The framework exposes Apex invocable actions for referral submission, status updates, and routing logic. Apex classes that need to trigger referral workflows must call these invocable actions rather than performing DML on `ReferralRequest` directly, for the same reasons as care plan invocable actions: the framework enforces business rules, consent, and notification logic at the action layer.3637### HIPAA Apex Logging Governance3839Salesforce Apex debug logs are not subject to field-level security or sharing rules — a log entry that captures a SOQL query result or a variable inspect for `EhrPatientMedication`, `PatientHealthCondition`, `ClinicalEncounterCode`, or similar clinical objects writes PHI as plain text to the debug log store. Under HIPAA, this constitutes a data exposure risk. Production debug logging must be disabled or tightly scoped (specific user, short duration), logs must be purged after use, and no automated process should retain clinical-field variable dumps in long-lived log stores. This applies equally to `System.debug()` calls in trigger handlers and to Flow-launched Apex actions.4041---4243## Common Patterns4445### Implementing CarePlanProcessorCallback4647**When to use:** You need to execute custom logic when a care plan transitions state — e.g., notifying a care coordinator when a care plan is activated, or creating a Task when a care plan closes.4849**How it works:**501. Declare a `global` Apex class implementing `HealthCloudGA.CarePlanProcessorCallback`.512. Implement the required interface methods: `onCarePlanCreate`, `onCarePlanActivate`, `onCarePlanClose` (exact method signatures depend on the installed package version — always reference the installed namespace documentation).523. Register the class name in Health Cloud Setup > Care Plan Settings > Custom Apex Callback.534. Keep callback logic lightweight: avoid synchronous callouts, limit SOQL to selective queries, and delegate heavy work to `@future` or Queueable Apex to stay within governor limits.5455**Why not the alternative:** Adding an Apex trigger on the `CarePlan` object fires outside the Health Cloud lifecycle framework. It cannot reliably intercept all state transitions and misses events triggered by managed-package automation.5657### Referral Invocable Action Pattern5859**When to use:** An Apex class or Flow needs to create or update a referral programmatically — e.g., when a clinical intake process determines that an external specialist referral is required.6061**How it works:**621. Use `Invocable.Action` to invoke the `industries_referral_mgmt__CreateReferral` or equivalent ICC invocable action from Apex rather than performing `insert new ReferralRequest__c(...)`.632. Populate the input `ReferralRequest` wrapper object with patient context, referring provider, and target specialty.643. Evaluate the `ReferralResponse` output for status and any error messages before proceeding.654. If the referral fails validation, surface the error to the user via a platform event or record status field — do not silently swallow the response.6667**Why not the alternative:** Direct DML on `ReferralRequest__c` skips the ICC business rules engine, consent checks, and provider matching logic. The resulting record may be technically valid in the database but functionally broken in the referral management UI and reporting.6869---7071## Decision Guidance7273| Situation | Recommended Approach | Reason |74|---|---|---|75| Execute logic when a care plan is activated | Implement `HealthCloudGA.CarePlanProcessorCallback` and register it in Health Cloud Setup | Fires reliably within the managed-package lifecycle; Apex trigger on CarePlan does not catch all transitions |76| Create a care plan from Apex | Call the `CreateCarePlan` invocable action via `Invocable.Action` | Enforces consent evaluation and lifecycle hooks; raw DML bypasses both |77| Process an inbound referral | Use ICC `industries_referral_mgmt__CreateReferral` invocable action | Applies provider matching, consent, and routing rules from the ICC framework |78| Add a goal to an existing care plan | Call `AddCarePlanGoal` invocable action | Maintains data model integrity; direct DML on CarePlanGoal may produce orphaned records |79| Log debug info in a class touching clinical objects | Use conditional debug logging gated by a Custom Setting or Custom Metadata flag | Prevents PHI from entering debug logs in production; gate on environment type |80| Validate care plan Apex in a scratch org | Use a Health Cloud scratch org definition with Health Cloud features enabled | Ensures HealthCloudGA namespace and test data factories are available |8182---8384## Recommended Workflow8586Step-by-step instructions for an AI agent or practitioner working on this task:87881. Confirm the installed `HealthCloudGA` package version and identify the specific extension point needed (callback interface, invocable action, or ICC action). Pull the interface signature from the namespace documentation or by inspecting the installed package in Setup > Installed Packages.892. Determine whether the request involves care plan lifecycle, referral processing, or general clinical data automation. Route to the appropriate pattern: `CarePlanProcessorCallback` for lifecycle hooks, `CreateCarePlan`/`AddCarePlanGoal` invocable actions for care plan data, or ICC actions for referrals.903. Implement the Apex class: declare it `global` if it implements a HealthCloudGA interface, use `Invocable.Action` for action-based calls, and ensure all DML on Health Cloud clinical objects is routed through the appropriate service layer rather than direct DML.914. Audit all `System.debug()` calls and SOQL result references in the class — remove or gate any statements that would dump clinical object fields (`EhrPatientMedication`, `PatientHealthCondition`, `ClinicalEncounterCode`, `AuthorizationFormConsent`) into debug logs. Add a Custom Metadata-based debug gate.925. Register the callback class in Health Cloud Setup if using `CarePlanProcessorCallback`, write unit tests using `@IsTest` with Health Cloud test data factories, and verify that no direct DML on `CarePlan`, `CarePlanTemplate__c`, or `ReferralRequest__c` remains in the code path.9394---9596## Review Checklist9798Run through these before marking work in this area complete:99100- [ ] Apex class implementing a HealthCloudGA interface is declared `global` and registered in Health Cloud Setup101- [ ] All care plan creation and modification routes through `CreateCarePlan` / `AddCarePlanGoal` invocable actions, not direct DML102- [ ] All referral creation routes through ICC invocable actions, not direct DML on `ReferralRequest__c`103- [ ] `System.debug()` calls referencing clinical object fields are removed or gated by a Custom Metadata debug flag104- [ ] Production debug log retention policy reviewed — no persistent logs containing PHI105- [ ] Unit tests cover callback interface methods and invocable action calls with mock responses106- [ ] Consent enforcement via `AuthorizationFormConsent` is not bypassed by any code path107108---109110## Salesforce-Specific Gotchas111112Non-obvious platform behaviors that cause real production problems:1131141. **CarePlanProcessorCallback requires Setup registration** — Deploying a class that implements `HealthCloudGA.CarePlanProcessorCallback` is not sufficient. The class name must be explicitly registered in Health Cloud Setup > Care Plan Settings. An unregistered callback silently does nothing; there is no deploy-time or runtime error.1152. **Direct DML on clinical objects bypasses consent enforcement** — Inserting or updating `CarePlan`, `CarePlanGoal`, or `CarePlanProblem` directly bypasses `AuthorizationFormConsent` evaluation. The record is created, but the consent check never fires. This is both a compliance gap and a functional gap — Health Cloud UI features that depend on consent state will behave inconsistently.1163. **Apex debug logs containing clinical fields are PHI** — `EhrPatientMedication`, `PatientHealthCondition`, `ClinicalEncounterCode`, and similar objects contain protected health information. Debug logs are stored in plaintext and are accessible to any system administrator. Production debug logging on clinical Apex classes must be disabled by default, time-limited when enabled for troubleshooting, and purged immediately after use.117118---119120## Output Artifacts121122| Artifact | Description |123|---|---|124| Compliant HealthCloudGA Apex extension class | A `global` Apex class implementing the target HealthCloudGA interface with correct method signatures and Setup registration instructions |125| Invocable action call pattern | Apex snippet using `Invocable.Action` to call `CreateCarePlan`, `AddCarePlanGoal`, or ICC referral actions with input/output handling |126| Debug logging governance checklist | List of `System.debug()` statements audited for PHI exposure with recommended Custom Metadata gate pattern |127| Unit test scaffold | `@IsTest` class covering callback methods and action calls, using Health Cloud test data factories where available |128129---130131## Related Skills132133- `admin/care-plan-configuration` — Required prerequisite: care plan templates and ICM configuration must be in place before Apex extensions can be effectively implemented or tested134- `apex/apex-security-patterns` — Security patterns for FLS, CRUD, and sharing enforcement that also apply to clinical Apex classes135- `apex/clinical-decision-support` — Clinical decision logic patterns that frequently interact with care plan and referral Apex extension points