Skip to main content
Version: v0.0.4

Function: defineConformanceProfile()

defineConformanceProfile(profile): ConformanceProfile

The fail-fast authoring gate for a conformance profile: a malformed profile raises a typed ProfileDefinitionError at build time, before any validation runs. Runs collectProfileDefects; on any defect, throws a single ProfileDefinitionError listing every defect. On success, returns the profile typed as ConformanceProfile.

This is optional: validateAgainstProfile tolerates a raw profile object and never throws: but it lets an author catch a typo when the profile is written rather than when it is run.

Parameters

profile

unknown

Returns

ConformanceProfile

Throws

when the profile is structurally malformed.

Example

import { defineConformanceProfile } from "@cosyte/hl7";
const profile = defineConformanceProfile({
name: "example-adt-min",
segments: [{ segment: "PID", usage: "R" }],
});
// A typo throws at authoring time:
// defineConformanceProfile({ name: "x", segments: [{ segment: "pid" }] });
// → ProfileDefinitionError: segments[0].segment must be a valid segment name…