Documentation
¶
Overview ¶
Package mapper suggests field mappings between systems with confidence scores.
This is a rules-based intelligent mapping engine. No LLM, no network calls, no external dependencies. It runs offline in the same binary and never sends patient data anywhere.
The engine combines multiple signals - fuzzy string matching on field names, healthcare identifier pattern recognition, code system lookups, and historical acceptance data - into a single confidence score per suggestion. When confidence is below a configurable threshold the mapper abstains rather than guessing wrong, because a wrong mapping in healthcare can route data to the wrong field and that is a patient-safety defect.
Abstention is the core design decision. A system that always produces an answer trains users to stop checking, and the one time it is wrong nobody notices until a lab result lands in a note field. A system that says "I don't know" forces a human decision exactly when the human is needed.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// Threshold is the minimum confidence (0-100) required to make a suggestion
// without abstaining. Default 70.
Threshold int
// HistoricalBoost is how many points a previously-accepted mapping gets added.
// Default 15.
HistoricalBoost int
}
Config controls the mapper's behavior.
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine is the mapping suggestion engine.
func New ¶
func New(targets []TargetField, config Config) *Engine
New creates a mapping engine with the given target fields and configuration.
func (*Engine) Suggest ¶
func (e *Engine) Suggest(src SourceField) []Suggestion
Suggest returns mapping suggestions for a source field, ordered by confidence descending.
If the best suggestion is below the configured threshold, all returned suggestions will have Abstained set to true. The suggestions are still returned so a UI can show them as grey/uncertain options, but the flag makes clear that the engine does not endorse them.
type PatternType ¶
type PatternType string
PatternType identifies a class of healthcare identifier or data format.
const ( PatternNPI PatternType = "npi" PatternSSN PatternType = "ssn" PatternMRN PatternType = "mrn" PatternPhone PatternType = "phone" PatternDate PatternType = "date" PatternEmail PatternType = "email" PatternNone PatternType = "" )
type SourceField ¶
type SourceField struct {
// Name is the display name of the field (e.g. "Patient MRN", "Date of Birth").
Name string
// Examples are sample values from real data that help pattern detection.
Examples []string
// CodeSystem is the terminology system if known (e.g. "http://loinc.org").
CodeSystem string
}
SourceField describes a field in the source system that needs to be mapped.
type Suggestion ¶
type Suggestion struct {
// Target is the recommended target field.
Target TargetField
// Confidence is 0-100 indicating how sure the engine is.
Confidence int
// Reasoning explains why this suggestion was made, for auditability.
Reasoning string
// Abstained is true when the engine's best guess was below the threshold.
// When true, Confidence reflects what the score would have been, and Reasoning
// explains why it was not good enough.
Abstained bool
}
Suggestion is a single mapping recommendation from the engine.
type TargetField ¶
type TargetField struct {
// Name is the display name of the target field.
Name string
// CodeSystem is the terminology system if known.
CodeSystem string
// Pattern is the expected data pattern (e.g. "npi", "date", "phone").
Pattern string
}
TargetField describes a candidate field in the target system.