Function: defineDeidProfile()
defineDeidProfile(
spec):DeidProfile
Derive a per-site DeidProfile from a base profile (Safe Harbor by default), enforcing the widen-never-narrow contract: every override must move its category to an equal-or-stronger transform than the base's. A weakening override - or reclaiming a reserved standard label - is rejected (FATAL_CODES.DEID_PROFILE_INVALID), so a site preset can only tighten, never loosen, the base standard's protection.
Parameters
spec
The profile name, base, per-category overrides, and optional redactor.
Returns
A frozen DeidProfile.
Throws
DeidError DEID_PROFILE_INVALID if an override weakens a category or the name
reclaims a reserved standard label; DEID_POLICY_INVALID if the derived policy violates the
key/label contract (e.g. a safe-harbor-labelled policy that date-shifts).
Example
import { defineDeidProfile, SAFE_HARBOR_CATEGORIES } from "@cosyte/deid";
const strict = defineDeidProfile({
name: "site-strict",
transforms: { [SAFE_HARBOR_CATEGORIES.MRN]: "redact" }, // pseudonymize -> redact (stronger): OK
});
strict.policy.transforms[SAFE_HARBOR_CATEGORIES.MRN]; // => "redact"