/** * Reference Target Type Validator * ------------------------------- * * For every element declared as `Reference(Type1|Type2|...)` in the * active StructureDefinition, verify that the actual reference points * at a resource of one of the permitted types. This closes the Phase A * corpus miss for `reference-wrong-target-type.json` — Records used to * only check reference-string *format*, never the target-type * semantics. * * Scope (Phase B.1): * - Relative references (`Patient/123`) — extract type from the * first path segment and match against the element's targetProfile * canonical set. * - Absolute references (`https://fhir.example.com/Patient/123`) — * extract type from the penultimate segment. * * Phase B.2 (partial): * - Contained references (`#id`, `#`) — resolved against * `resource.contained` and checked with the same base-type logic. * - URN (`urn:uuid:`) / cross-bundle references — resolved via an * optional reference resolver (the enclosing Bundle's fullUrl/relative * index) so their target type can be checked too. * * Still deferred: * - Full targetProfile *profile* conformance — only the base resource * type is enforced, not that the target conforms to the named profile * (needs a recursive profile-validation pass). * - Logical references (`identifier` only, no `reference`) — no * target-type check is meaningful. */ import type { ValidationIssue } from '../types'; import type { StructureDefinition } from '../core/structure-definition-types'; /** Callback to resolve a profile canonical URL to its base resource type from the SD cache */ export type ProfileTypeResolver = (canonicalUrl: string) => string | null; /** Callback to resolve a reference string to its target resource (contained / bundle entry). */ export type ReferenceResolver = (reference: string) => any; /** A reference hit together with the profiled targetProfiles its element declares. */ export interface ProfiledTargetHit { path: string; reference: string; profiles: string[]; } export declare class ReferenceTargetValidator { private profileTypeResolver?; /** Inject an optional resolver that maps profile canonical URLs to base resource types */ setProfileTypeResolver(resolver: ProfileTypeResolver): void; /** * Validate that every Reference in `resource` points at a resource * type the StructureDefinition permits for that path. */ validate(resource: any, structureDef: StructureDefinition, resolveReference?: ReferenceResolver): ValidationIssue[]; /** * Enumerate reference hits whose element declares one or more *profiled* * targetProfiles (e.g. `us-core-patient`, not bare `Patient`). Used by the * opt-in target-profile-conformance pass — base-type-only references are * already covered by {@link validate}. */ collectProfiledTargetHits(resource: any, structureDef: StructureDefinition): ProfiledTargetHit[]; /** * Walk the resource for every Reference object at the given * element definition path. Returns each reference with its concrete * path (including array indices). */ private collectReferencesAtPath; } //# sourceMappingURL=reference-target-validator.d.ts.map