clinical-data-quality

Use this skill when configuring duplicate detection for Health Cloud patient records, managing Person Account merges in a clinical org, or designing pre-merge clinical record reassignment strategies. Trigger keywords: patient deduplication, MPI, duplicate patients, merge person accounts Health Cloud, clinical record orphan, EpisodeOfCare orphan, PatientMedication orphan. NOT for generic Salesforce data quality or standard deduplication outside Health Cloud.

Best use case

clinical-data-quality is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Use this skill when configuring duplicate detection for Health Cloud patient records, managing Person Account merges in a clinical org, or designing pre-merge clinical record reassignment strategies. Trigger keywords: patient deduplication, MPI, duplicate patients, merge person accounts Health Cloud, clinical record orphan, EpisodeOfCare orphan, PatientMedication orphan. NOT for generic Salesforce data quality or standard deduplication outside Health Cloud.

Teams using clinical-data-quality should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/clinical-data-quality/SKILL.md --create-dirs "https://raw.githubusercontent.com/PranavNagrecha/AwesomeSalesforceSkills/main/skills/data/clinical-data-quality/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/clinical-data-quality/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How clinical-data-quality Compares

Feature / Agentclinical-data-qualityStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Use this skill when configuring duplicate detection for Health Cloud patient records, managing Person Account merges in a clinical org, or designing pre-merge clinical record reassignment strategies. Trigger keywords: patient deduplication, MPI, duplicate patients, merge person accounts Health Cloud, clinical record orphan, EpisodeOfCare orphan, PatientMedication orphan. NOT for generic Salesforce data quality or standard deduplication outside Health Cloud.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# Clinical Data Quality

Use this skill when working with duplicate patient detection, Person Account merges, or clinical record integrity in a Salesforce Health Cloud org. It activates whenever a practitioner needs to configure Duplicate/Matching Rules for patients, perform Account merges while preserving clinical data, or evaluate MPI alternatives.

---

## Before Starting

Gather this context before working on anything in this domain:

- Confirm Person Accounts are enabled in the org — Health Cloud requires Person Accounts for its clinical components; the standard Contact merge flow does not apply.
- Identify which clinical objects are in scope: EpisodeOfCare, PatientMedication, ClinicalEncounter, CarePlanTemplate assignments, and any custom objects with Account lookups pointing to patient records.
- Confirm whether a third-party MPI or ISV deduplication solution is licensed. Salesforce Health Cloud has no native Master Patient Index — all deduplication relies on standard Duplicate Rules and Matching Rules configured for the Account (Person Account) object.
- Clarify merge volume. The platform enforces a two-at-a-time limit for Account merges via the standard UI/merge API. Bulk merge scenarios require Apex orchestration that calls the merge DML statement in batches of pairs.

---

## Core Concepts

### No Native Master Patient Index (MPI)

Health Cloud does not ship with a native MPI. There is no out-of-the-box enterprise patient identity resolution engine. Duplicate detection relies entirely on standard Salesforce Duplicate Management: Duplicate Rules scoped to the Account object (which covers Person Accounts) backed by fuzzy or exact Matching Rules on fields such as FirstName, LastName, BirthDate, and SSN-equivalent custom fields. For healthcare organizations at enterprise scale or with complex identity-matching requirements (probabilistic matching, cross-system record linkage), a third-party ISV — such as Veeva, ReltioConnect, or Informatica MDM for Salesforce — is the only path to true MPI capability.

### Person Account Merge Is Account Merge, Not Contact Merge

Person Accounts are Accounts with IsPersonAccount = true. The merge flow for Person Accounts is the **Account merge flow**, not the Contact merge flow. Attempting to invoke a Contact merge on the underlying Contact record of a Person Account is unsupported and will produce errors. The standard Salesforce UI (and the Merge Accounts API) merges exactly two Account records at a time: you select a master record, and the losing record is deleted after related records are reparented. This two-at-a-time constraint is a hard platform limit for the standard merge action.

### Clinical Records Are NOT Automatically Reparented on Merge

This is the highest-risk behavior in Health Cloud deduplication work. When two Person Account records are merged, standard Salesforce reparenting logic moves related records that belong to the **winning** record. However, Health Cloud clinical objects — including `EpisodeOfCare`, `PatientMedication`, `ClinicalEncounter`, and custom objects with explicit Account lookup fields — are **not** automatically reparented. They remain associated with the losing (deleted) Account and become orphaned records. Orphaned clinical records are not surfaced on the winning patient's timeline, care plan, or clinical summary, creating silent patient data loss that is difficult to detect post-merge without explicit audit queries.

---

## Common Patterns

### Pattern 1: Configure Matching and Duplicate Rules for Person Account Patient Detection

**When to use:** Every Health Cloud org that stores patient records should have at least one Matching Rule and one Duplicate Rule scoped to the Account object to detect potential duplicates at record creation time.

**How it works:**
1. Navigate to Setup > Duplicate Management > Matching Rules.
2. Create a new Matching Rule on the **Account** object (not Contact — Person Account deduplication runs on Account).
3. Add match criteria on `FirstName`, `LastName`, `PersonBirthdate`, and any identity field (e.g., `MedicalRecordNumber__c`). Use Fuzzy matching for name fields to catch typos. Use Exact matching for identifier fields.
4. Activate the Matching Rule.
5. Navigate to Setup > Duplicate Management > Duplicate Rules.
6. Create a Duplicate Rule on Account, reference the Matching Rule, and set the action for matching records to **Alert** (not Block) during the initial rollout to avoid disrupting intake workflows. Switch to **Block** after validating match quality.
7. Test by creating two Person Account records with overlapping fields and confirming the duplicate alert fires.

**Why not the alternative:** Applying a Duplicate Rule to the Contact object instead of Account does not cover Person Accounts. Person Account deduplication must be targeted at Account.

---

### Pattern 2: Pre-Merge Clinical Record Reassignment via Apex Batch

**When to use:** Before merging any two Patient (Person Account) records, reassign all clinical records from the losing account to the winning account. This must happen before the merge DML — not after — because after the merge the losing Account ID no longer exists.

**How it works:**
1. Identify all clinical objects with Account/Patient lookups (see references/examples.md for a full list).
2. Write a pre-merge Apex batch that queries each clinical object for records pointing to the losing Account ID and updates them to point to the winning Account ID.
3. Call the batch synchronously (or chain it) before invoking the merge DML statement.
4. After batch completion, execute `merge masterAccount duplicateAccount;` in Apex.
5. Run post-merge audit queries to confirm zero records remain on the deleted Account ID.

**Why not the alternative:** Performing the merge first and trying to reassign clinical records afterward is not possible — the losing Account record no longer exists after merge, and its ID is tombstoned. Queries against the deleted Account ID will return no rows.

---

## Decision Guidance

| Situation | Recommended Approach | Reason |
|---|---|---|
| Small org, low duplicate volume, single source of truth | Native Duplicate Rules + Matching Rules on Account | Sufficient for controlled intake; no ISV cost |
| Enterprise scale, multi-source patient data, probabilistic matching needed | Third-party MPI ISV (ReltioConnect, Veeva, Informatica) | Native rules only support field-level exact/fuzzy; no cross-system record linkage |
| Merging 2 known duplicates interactively | Standard Account Merge UI or Apex `merge` DML | Supported path for Person Accounts |
| Bulk merge of hundreds of duplicate pairs | Apex Batch with pre-reassignment loop + `merge` DML pairs | Only way to handle volume; two-at-a-time limit applies per DML call |
| Clinical records already orphaned post-merge | Apex data fix script querying by known losing Account IDs | No platform-native fix; must reassign via code |

---

## Recommended Workflow

Step-by-step instructions for an AI agent or practitioner working on this task:

1. **Identify clinical objects in scope.** Query the org schema for all objects that have a lookup to Account (or a field named PatientId, MemberId, or IndividualId). Include Health Cloud standard objects: EpisodeOfCare, PatientMedication, ClinicalEncounter, CareObservation, CoveredBenefit, and any custom objects. This list drives the pre-merge reassignment batch.
2. **Configure Duplicate and Matching Rules on Account.** Build at minimum one Matching Rule on Account covering FirstName, LastName, and PersonBirthdate. Attach a Duplicate Rule set to Alert mode. Activate both. Do NOT target the Contact object for Person Account deduplication.
3. **Build and test the pre-merge clinical record reassignment batch.** The batch must accept a losing Account ID and a winning Account ID, query each clinical object in scope, and bulk-update the lookup fields before merge. Test in a sandbox with realistic patient data including all clinical object types.
4. **Execute merge in the correct order.** Run pre-merge reassignment batch first — confirm zero errors and zero remaining records on losing Account — then execute the Account merge DML. Never reverse this order.
5. **Run post-merge audit queries.** For each clinical object, confirm record count on the winning Account equals the expected sum of both pre-merge counts. If any discrepancy exists, investigate before releasing the patient record as clean.

---

## Review Checklist

Run through these before marking work in this area complete:

- [ ] Duplicate Rule and Matching Rule are scoped to the Account object, not Contact
- [ ] Matching Rule covers at minimum FirstName, LastName, and PersonBirthdate
- [ ] All clinical objects with Account lookups are included in the pre-merge reassignment batch
- [ ] Pre-reassignment batch runs and completes with zero errors before merge DML is invoked
- [ ] Post-merge audit queries confirm zero orphaned clinical records on deleted Account IDs
- [ ] Merge approach uses Account merge flow (not Contact merge) for Person Accounts
- [ ] If volume is >100 duplicate pairs, a third-party MPI or bulk merge orchestration pattern is in place

---

## Salesforce-Specific Gotchas

Non-obvious platform behaviors that cause real production problems:

1. **Clinical records orphaned silently on merge** — Health Cloud clinical objects (EpisodeOfCare, PatientMedication, ClinicalEncounter) are NOT reparented when Person Accounts are merged. They remain on the deleted Account ID and disappear from the winning patient's record permanently unless explicitly reassigned before the merge DML executes.
2. **Person Account merge is two-at-a-time only** — The standard Salesforce merge operation (UI and Apex `merge` DML) merges exactly two Account records per call. There is no bulk merge API. Attempting to merge three-way or pass a list of duplicates to a single merge call will throw a compile or runtime error.
3. **Duplicate Rules on Contact do not cover Person Accounts** — Person Accounts are hybrid records. Their deduplication must be configured on the Account object, not the Contact object. A practitioner who creates a Contact Duplicate Rule expecting it to catch duplicate Person Account patients will find it has no effect.

---

## Output Artifacts

| Artifact | Description |
|---|---|
| Matching Rule + Duplicate Rule configuration | Account-scoped matching with fuzzy name + exact identifier fields, set to Alert mode for initial rollout |
| Pre-merge clinical record reassignment batch | Apex batch class that accepts losing/winning Account IDs and reassigns all clinical object records before merge |
| Post-merge audit SOQL queries | Per-object queries to confirm zero orphaned records after a merge operation |

---

## Related Skills

- data/large-scale-deduplication — for high-volume duplicate resolution patterns and bulk merge orchestration strategies applicable when the clinical dedup list is in the thousands
- data/record-merge-implications — for the general Salesforce record merge model, reparenting rules, and field-value winner logic
- admin/health-cloud-patient-setup — for Person Account configuration prerequisites that must be in place before deduplication rules are meaningful

Related Skills

sandbox-data-masking

8
from PranavNagrecha/AwesomeSalesforceSkills

Use this skill when configuring or reviewing Salesforce Data Mask to protect PII/PHI in partial or full copy sandboxes after a refresh. Trigger keywords: data mask, sandbox masking, PII in sandbox, GDPR sandbox, HIPAA non-production, mask contacts, obfuscate fields non-production. NOT for sandbox refresh mechanics (use sandbox-refresh-and-templates), NOT for production data anonymization, NOT for Shield Platform Encryption at rest.

gdpr-data-privacy

8
from PranavNagrecha/AwesomeSalesforceSkills

Use this skill when implementing GDPR or CCPA data privacy controls in Salesforce: Individual sObject linkage, consent tracking, Right to Be Forgotten (RTBF) requests, data subject request handling, and Privacy Center configuration. Trigger keywords: GDPR, data privacy, consent management, right to erasure, Individual object, ContactPointConsent, ShouldForget, data subject request, Privacy Center, data portability. NOT for general data quality cleanup, duplicate management, field-level encryption (see platform-encryption skill), or sandbox data masking (see sandbox-data-masking skill).

data-classification-labels

8
from PranavNagrecha/AwesomeSalesforceSkills

Classify Salesforce fields by data sensitivity and compliance category using the four built-in classification attributes (SecurityClassification, ComplianceGroup, BusinessOwnerId, BusinessStatus). Covers Metadata API deployment, Tooling API querying, and Einstein Data Detect recommendations. NOT for data masking, Shield Platform Encryption, or runtime access control enforcement.

customer-data-request-workflow

8
from PranavNagrecha/AwesomeSalesforceSkills

Implement GDPR/CCPA data subject rights (access, deletion, rectification) using Salesforce Privacy Center and/or custom workflow. NOT for general backup or org-level data retention policy.

omnistudio-deployment-datapacks

8
from PranavNagrecha/AwesomeSalesforceSkills

Use when exporting, importing, or version-controlling OmniStudio components using DataPacks via the OmniStudio DataPacks tool or vlocity CLI. Covers DataPack export/import, Git version control integration, CI/CD for OmniStudio. NOT for SFDX-based metadata deployment of non-OmniStudio components.

omnistudio-asynchronous-data-operations

8
from PranavNagrecha/AwesomeSalesforceSkills

Use Integration Procedures queues, DataRaptor Chain, and Remote Actions with async patterns for long-running OmniStudio flows. NOT for simple DataRaptor reads.

dataraptor-transform-optimization

8
from PranavNagrecha/AwesomeSalesforceSkills

Use when DataRaptor Transform operations are slow, hit governor limits, or use Apex where formula fields would suffice. Covers formula vs Apex expressions, bulk transform sizing, and chained transform composition. Triggers: 'dataraptor transform slow', 'dataraptor formula vs apex', 'dataraptor bulk transform', 'dr governor limit'. NOT for DataRaptor Extract or Load performance.

dataraptor-patterns

8
from PranavNagrecha/AwesomeSalesforceSkills

Use when designing or reviewing OmniStudio DataRaptors, especially Extract versus Turbo Extract versus Transform versus Load, field mapping strategy, performance tradeoffs, and when to move work into Integration Procedures or Apex. Triggers: 'DataRaptor Extract', 'Turbo Extract', 'DataRaptor Load', 'DataRaptor Transform', 'OmniStudio data mapping'. NOT for overall OmniScript journey design or Integration Procedure sequencing when the main question is not the DataRaptor shape itself.

lwc-datatable-advanced

8
from PranavNagrecha/AwesomeSalesforceSkills

Advanced lightning-datatable patterns — inline edit + draftValues, custom cell types via extending LightningDatatable, sortable columns, infinite scroll with onloadmore, row-level errors, and the cost of large data sets. NOT for read-only display of small lists (plain lightning-datatable suffices) or fully custom grids (use a third-party library).

lwc-data-table

8
from PranavNagrecha/AwesomeSalesforceSkills

Use when designing or reviewing `lightning-datatable` usage in Lightning Web Components, including column configuration, stable `key-field` values, inline editing, row actions, infinite loading, and custom cell types. Triggers: 'lightning datatable inline edit', 'row actions in lwc datatable', 'key field missing', 'infinite loading in datatable'. NOT for highly custom virtualized grids or broad page-performance work outside the datatable boundary.

lwc-custom-datatable-types

8
from PranavNagrecha/AwesomeSalesforceSkills

Use when you need to extend `lightning-datatable` with custom cell renderings: status pills, progress bars, image thumbnails, action cells, editable pickliststo, rich-text, or any column that `lightning-datatable` does not ship out of the box. Triggers: 'custom cell type lightning datatable', 'progress bar column', 'image column', 'inline edit picklist in datatable', 'rich text column'. NOT for basic datatable usage (see `lwc-data-table`) and NOT for tree-grid or large-dataset virtualization (see `virtualized-lists`).

salesforce-data-pipeline-etl

8
from PranavNagrecha/AwesomeSalesforceSkills

Export large Salesforce datasets to a lakehouse via Bulk API 2.0, CDC streams, or Salesforce Data Pipelines. NOT for ad-hoc exports.