Documentation
¶
Overview ¶
Package generator provides code generation tools for creating version-specific HL7v2 Go structures from schema specifications.
Index ¶
- func CommentLines(s string) string
- func PackageName(ver string) string
- func SanitizeIdentifier(s string) string
- type DatatypeFieldModel
- type DatatypeModel
- type DatatypesFileData
- type Deduper
- type Generator
- func (g *Generator) GenerateAll(outputBase string) error
- func (g *Generator) GenerateDatatypes(targetDir, pkgName string) error
- func (g *Generator) GenerateMessageTests(targetDir, pkgName string) error
- func (g *Generator) GenerateMessages(targetDir, pkgName string) error
- func (g *Generator) GenerateRegistry(targetDir, pkgName string) error
- func (g *Generator) GenerateSegments(targetDir, pkgName string) error
- func (g *Generator) GenerateTables(targetDir, pkgName string) error
- type GroupModel
- type MSHInitModel
- type MessageFieldModel
- type MessageModel
- type MessageTestsFileData
- type MessagesFileData
- type Option
- type Options
- type ParamDeduper
- type RegistryFileData
- type SegmentFieldModel
- type SegmentModel
- type SegmentsFileData
- type SpecType
- type TableEntryModel
- type TableModel
- type TablesFileData
- type Template
- func NewTemplate(typ SpecType, t *template.Template, output string) *Template
- func ParseTemplate(typ SpecType, name, content, output string) (*Template, error)
- func ReadTemplate(typ SpecType, path, output string) (*Template, error)
- func ReadTemplateFS(typ SpecType, fs fs.FS, output string) (*Template, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CommentLines ¶
CommentLines formats a multi-line string into Go comment lines prefixed with //.
func PackageName ¶
PackageName converts a version string like "v2.5.1" into a Go package name like "v251".
func SanitizeIdentifier ¶
SanitizeIdentifier cleans and formats a raw string into a valid exported Go identifier.
Types ¶
type DatatypeFieldModel ¶
type DatatypeFieldModel struct {
GoName string
GoType string
Tag string
ParamType string
InitExpr string
MethodName string
IsRequired bool
IsPrimitive bool
IsSlice bool
}
DatatypeFieldModel holds template data for a field within a data type.
type DatatypeModel ¶
type DatatypeModel struct {
ID string
Name string
Description string
IsPrimitive bool
Fields []DatatypeFieldModel
}
DatatypeModel holds template data for an HL7v2 data type definition.
type DatatypesFileData ¶
type DatatypesFileData struct {
PackageName string
Datatypes []DatatypeModel
HasComplexDatatypes bool
}
DatatypesFileData holds template rendering data for a datatypes.go file.
type Deduper ¶
type Deduper struct {
// contains filtered or unexported fields
}
Deduper tracks generated struct field and type names to avoid name collisions.
type Generator ¶
type Generator struct {
// contains filtered or unexported fields
}
Generator handles code generation for a specific HL7v2 version schema.
func (*Generator) GenerateAll ¶
GenerateAll generates all Go source files for the configured version under outputBase.
func (*Generator) GenerateDatatypes ¶
GenerateDatatypes generates the datatypes.go file for a target directory and package.
func (*Generator) GenerateMessageTests ¶
GenerateMessageTests generates the messages_test.go file for a target directory and package.
func (*Generator) GenerateMessages ¶
GenerateMessages generates the messages.go file for a target directory and package.
func (*Generator) GenerateRegistry ¶
GenerateRegistry generates the registry.go file for a target directory and package.
func (*Generator) GenerateSegments ¶
GenerateSegments generates the segments.go file for a target directory and package.
func (*Generator) GenerateTables ¶
GenerateTables generates the tables.go file for a target directory and package.
type GroupModel ¶
type GroupModel struct {
StructName string
Fields []MessageFieldModel
}
GroupModel holds template data for a message group structure.
type MSHInitModel ¶
type MSHInitModel struct {
FieldSeparatorName string
EncodingCharactersName string
DateTimeName string
DateTimeExpr string
MessageTypeName string
MessageTypeParamType string
MessageControlIDName string
ProcessingIDName string
ProcessingIDExpr string
VersionIDName string
VersionIDExpr string
}
MSHInitModel holds template data for MSH segment initialization logic.
type MessageFieldModel ¶
type MessageFieldModel struct {
GoName string
GoType string
Tag string
IsSlice bool
IsRequired bool
ElemType string
MethodName string
}
MessageFieldModel holds template data for a field within a message.
type MessageModel ¶
type MessageModel struct {
ID string
Name string
Description string
Groups []GroupModel
Fields []MessageFieldModel
MSHInitExpr string
}
MessageModel holds template data for an HL7v2 message definition.
type MessageTestsFileData ¶
MessageTestsFileData holds template rendering data for a messages_test.go file.
type MessagesFileData ¶
type MessagesFileData struct {
PackageName string
Messages []MessageModel
}
MessagesFileData holds template rendering data for a messages.go file.
type Option ¶
type Option func(*Options)
Option defines a functional option for configuring Options.
type Options ¶
Options configures code generation parameters.
func NewOptions ¶
NewOptions constructs an Options instance by applying option functions.
type ParamDeduper ¶
type ParamDeduper struct {
// contains filtered or unexported fields
}
ParamDeduper manages parameter name deduplication.
func NewParamDeduper ¶
func NewParamDeduper() *ParamDeduper
NewParamDeduper creates a new ParamDeduper instance.
func (*ParamDeduper) Name ¶
func (d *ParamDeduper) Name(raw string) string
Name returns a unique parameter name by appending a numeric suffix if repeated.
type RegistryFileData ¶
RegistryFileData holds template rendering data for a registry.go file.
type SegmentFieldModel ¶
type SegmentFieldModel struct {
GoName string
GoType string
Tag string
IsSlice bool
IsPrimitive bool
IsRequired bool
ElemType string
MethodName string
}
SegmentFieldModel holds template data for a field within a segment.
type SegmentModel ¶
type SegmentModel struct {
ID string
Name string
Description string
Fields []SegmentFieldModel
IsMSH bool
MSHInit MSHInitModel
}
SegmentModel holds template data for an HL7v2 segment definition.
type SegmentsFileData ¶
type SegmentsFileData struct {
PackageName string
Segments []SegmentModel
}
SegmentsFileData holds template rendering data for a segments.go file.
type SpecType ¶
type SpecType int
SpecType represents the type of HL7v2 schema specification entity.
const ( // SpecTypeUnknown indicates an unspecified schema entity type. SpecTypeUnknown SpecType = iota // SpecTypeDatatype indicates a data type schema entity. SpecTypeDatatype // SpecTypeTable indicates a table schema entity. SpecTypeTable // SpecTypeSegment indicates a segment schema entity. SpecTypeSegment // SpecTypeMessage indicates a message schema entity. SpecTypeMessage )
type TableEntryModel ¶
type TableEntryModel struct {
ConstName string
Value string
Description string
DescriptionEscaped string
Comment string
}
TableEntryModel holds template data for an entry within a table.
type TableModel ¶
type TableModel struct {
ID string
TypeName string
Name string
Description string
Entries []TableEntryModel
}
TableModel holds template data for an HL7v2 table definition.
type TablesFileData ¶
type TablesFileData struct {
PackageName string
Tables []TableModel
HasIS bool
HasID bool
HasST bool
HasCE bool
HasCWE bool
HasCNE bool
}
TablesFileData holds template rendering data for a tables.go file.
type Template ¶
type Template struct {
// contains filtered or unexported fields
}
Template wraps a parsed text template associated with a SpecType.
func NewTemplate ¶
NewTemplate creates a new Template instance for a SpecType and output name.
func ParseTemplate ¶
ParseTemplate parses a template content string and returns a new Template.
func ReadTemplate ¶
ReadTemplate reads and parses a template file from disk.