reference

package
v1.11.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 1, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package reference validates FHIR Reference elements.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateBundleFullUrls added in v1.4.0

func ValidateBundleFullUrls(bundle map[string]any, result *issue.Result)

ValidateBundleFullUrls validates that fullUrl is consistent with resource.id for all entries. Per FHIR spec: "fullUrl SHALL NOT disagree with the id in the resource" This applies when fullUrl is a URL (not urn:uuid or urn:oid).

Types

type BundleContext

type BundleContext struct {
	// FullURLIndex maps fullUrl values to their resource types.
	// e.g., "urn:uuid:abc-123" -> "Patient"
	FullURLIndex map[string]string
}

BundleContext holds information about a Bundle for reference validation.

func NewBundleContext

func NewBundleContext(bundle map[string]any) *BundleContext

NewBundleContext creates a BundleContext from a Bundle resource. It indexes all entry.fullUrl values for reference resolution.

type ContainedContext added in v1.9.1

type ContainedContext struct {
	// IDIndex maps contained resource IDs to their resource types.
	IDIndex map[string]string
}

ContainedContext holds the index of contained resource IDs for the current resource scope. This enables validation that fragment references (#id) resolve to actual contained resources.

func NewContainedContext added in v1.9.1

func NewContainedContext(resource map[string]any) *ContainedContext

NewContainedContext creates a ContainedContext by indexing all contained resources within the given resource data.

type Validator

type Validator struct {
	// contains filtered or unexported fields
}

Validator validates Reference elements.

func New

func New(reg *registry.Registry) *Validator

New creates a new reference Validator.

func (*Validator) Validate

func (v *Validator) Validate(resourceData json.RawMessage, sd *registry.StructureDefinition, result *issue.Result)

Validate validates all Reference elements in a resource. Deprecated: Use ValidateData for better performance when JSON is already parsed.

func (*Validator) ValidateData

func (v *Validator) ValidateData(resource map[string]any, sd *registry.StructureDefinition, result *issue.Result)

ValidateData validates all Reference elements in a pre-parsed FHIR resource. This is the preferred method when JSON has already been parsed to avoid redundant parsing.

func (*Validator) ValidateDataWithBundle

func (v *Validator) ValidateDataWithBundle(resource map[string]any, sd *registry.StructureDefinition, bundleCtx *BundleContext, result *issue.Result)

ValidateDataWithBundle validates all Reference elements in a pre-parsed FHIR resource within the context of a Bundle. This enables validation of urn:uuid references.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL