Documentation
¶
Overview ¶
Package structuremap provides a minimal FHIR StructureMap execution engine for SDC questionnaire extraction.
The engine executes StructureMap group rules against Questionnaire and QuestionnaireResponse inputs and produces FHIR resources for transaction bundle entries. Full FHIR Mapping Language transform parity is not a goal; the supported transforms cover common SDC extraction patterns (create, copy, uuid, cc, evaluate).
The entry group is selected by matching StructureMap.name to a group name, otherwise the first group is executed. Helper groups are invoked through rule dependents.
Integrate with pkg/sdc via ExtractorRun or NewExtractor.
Index ¶
- func Canonical(m Map) string
- func ExtractorRun(cfg Config) ...
- func NewExtractor(cfg Config) sdc.StructureMapExtractor
- type CardinalityResolver
- type Config
- type Dependent
- type Engine
- type ExecuteInput
- type Group
- type Input
- type Map
- type Parameter
- type Resolver
- type ResourceCardinalityResolver
- type Rule
- type Source
- type StaticResolver
- type StoreCardinalityResolver
- type StoreResolver
- type Structure
- type Target
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractorRun ¶
func ExtractorRun(cfg Config) func(context.Context, sdc.Questionnaire, sdc.QuestionnaireResponse) ([]json.RawMessage, error)
ExtractorRun builds the Run hook used by sdc.StructureMapExtractor.
func NewExtractor ¶
func NewExtractor(cfg Config) sdc.StructureMapExtractor
NewExtractor returns a StructureMapExtractor backed by this runtime.
Types ¶
type CardinalityResolver ¶
type CardinalityResolver interface {
IsRepeating(ctx context.Context, fhirPath string) (bool, bool)
}
CardinalityResolver reports whether a FHIR element path allows multiple values.
type Engine ¶
type Engine struct {
FHIRPath fhirpath.Engine
// Strict reports an error when a rule declares sources but none match.
Strict bool
// Translator resolves translate transforms via ConceptMap resources.
Translator conceptmap.Translator
// Cardinality resolves repeating elements from StructureDefinitions.
Cardinality CardinalityResolver
}
Engine executes StructureMap group rules.
func (Engine) Execute ¶
func (e Engine) Execute(ctx context.Context, m Map, inputs ExecuteInput) ([]json.RawMessage, error)
Execute runs a StructureMap and returns produced FHIR resources.
type ExecuteInput ¶
ExecuteInput names resources available to the map by variable name.
type Map ¶
type Map struct {
ResourceType string `json:"resourceType"`
URL string `json:"url"`
Version string `json:"version,omitempty"`
Status string `json:"status,omitempty"`
Name string `json:"name,omitempty"`
Structure []Structure `json:"structure,omitempty"`
Group []Group `json:"group,omitempty"`
}
Map is the JSON representation of a FHIR StructureMap resource.
func ResolveEnvelope ¶
func ResolveEnvelope(env *types.ResourceEnvelope) (Map, error)
ResolveEnvelope parses a StructureMap envelope.
type ResourceCardinalityResolver ¶
type ResourceCardinalityResolver interface {
CardinalityResolver
IsRepeatingFor(ctx context.Context, root map[string]any, fhirPath string) (bool, bool)
}
ResourceCardinalityResolver resolves cardinality using resource instance metadata.
type StaticResolver ¶
StaticResolver resolves maps from an in-memory table keyed by canonical URL.
type StoreCardinalityResolver ¶
type StoreCardinalityResolver struct {
Store store.DefinitionStore
}
StoreCardinalityResolver resolves cardinality from StructureDefinition resources. Use cardinalityForMap during map execution for profile-aware, per-run indexes.
func (*StoreCardinalityResolver) IsRepeating ¶
type StoreResolver ¶
type StoreResolver struct {
Resources store.ResourceStore
Registry store.DefinitionStore
// contains filtered or unexported fields
}
StoreResolver resolves StructureMap resources from a ResourceStore and, when available, a DefinitionStore fallback. The resource-store index is rebuilt on each resolve so newly stored maps are visible immediately.