Documentation ¶
Overview ¶
Package gdt provides methods for working with GDT (Geräte-Date-Träger) files as specified by QMS (Qualitätsring Medizinische Software) in version 2.1.
Index ¶
- Variables
- func MustRegister(ft FieldType, fn ParseFieldFunc)
- func Register(ft FieldType, fn ParseFieldFunc) error
- type Decoder
- type DecoderOption
- type FieldDesc
- type FieldID
- type FieldType
- type File
- func (file *File) Field(desc FieldDesc) (interface{}, error)
- func (file *File) Fields(desc FieldDesc) ([]interface{}, error)
- func (file *File) FloatField(desc FieldDesc) (float64, error)
- func (file *File) IntField(desc FieldDesc) (int, error)
- func (file *File) StringField(desc FieldDesc) (string, error)
- type Line
- type Lines
- type ParseFieldFunc
- type TypeRegistry
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidLength = errors.New("field has invalid length") ErrUnknownType = errors.New("unknown field type") ErrFieldNotFound = errors.New("field not found") ErrInvalidType = errors.New("invalid type for field") )
Common error definitions
var ( FieldSoftwareResponsible = FieldDesc{ ID: 102, MaxLength: 60, Type: FieldTypeText, } FieldSoftware = FieldDesc{ ID: 103, MaxLength: 60, Type: FieldTypeText, } FieldSoftwareRelease = FieldDesc{ ID: 132, MaxLength: 60, Type: FieldTypeText, } FieldPatientID = FieldDesc{ ID: 3000, MaxLength: 10, Type: FieldTypeText, } FieldPatientNameSuffix = FieldDesc{ ID: 3100, MaxLength: 15, Type: FieldTypeText, } FieldPatientName = FieldDesc{ ID: 3101, MaxLength: 28, Type: FieldTypeText, } FieldPatientGivenName = FieldDesc{ ID: 3102, MaxLength: 28, Type: FieldTypeText, } FieldPatientBrithday = FieldDesc{ ID: 3103, Length: 8, Type: FieldTypeText, } FieldPatientTitel = FieldDesc{ ID: 3104, MaxLength: 15, Type: FieldTypeText, } FieldPatientInsuranceNumber = FieldDesc{ ID: 3105, MaxLength: 12, Type: FieldTypeText, } FieldPatientCity = FieldDesc{ ID: 3106, MaxLength: 30, Type: FieldTypeText, } FieldPatientStreet = FieldDesc{ ID: 3107, MaxLength: 28, Type: FieldTypeText, } FieldPatientInsuranceType = FieldDesc{ ID: 3108, Length: 1, Type: FieldTypeNumber, } FieldPatientGender = FieldDesc{ ID: 3110, Length: 1, Type: FieldTypeNumber, } FieldPatientSize = FieldDesc{ ID: 3622, Type: FieldTypeFloat, } FieldPatientWeight = FieldDesc{ ID: 3623, Type: FieldTypeFloat, } FieldPatientNativeLanguage = FieldDesc{ ID: 3628, MaxLength: 60, Type: FieldTypeText, } FieldStudyDate = FieldDesc{ ID: 6200, Length: 8, Type: FieldTypeText, } FieldStudyTime = FieldDesc{ ID: 6201, Length: 6, Type: FieldTypeText, } FieldDiagnose = FieldDesc{ ID: 6205, MaxLength: 60, Type: FieldTypeText, } FieldFindings = FieldDesc{ ID: 6220, MaxLength: 60, Type: FieldTypeText, } FieldExternalFindings = FieldDesc{ ID: 6221, MaxLength: 60, Type: FieldTypeText, } FieldResultTextLength = FieldDesc{ ID: 6226, MaxLength: 60, Type: FieldTypeText, } FieldComment = FieldDesc{ ID: 6227, MaxLength: 60, Type: FieldTypeText, } FieldResultTableText = FieldDesc{ ID: 6228, Type: FieldTypeText, } FieldArchiveID = FieldDesc{ ID: 6302, MaxLength: 60, Type: FieldTypeText, } FieldFileFormat = FieldDesc{ ID: 6303, MaxLength: 60, Type: FieldTypeText, } FieldFileContent = FieldDesc{ ID: 6304, MaxLength: 60, Type: FieldTypeText, } FieldFileURL = FieldDesc{ ID: 6305, MaxLength: 60, Type: FieldTypeText, } FieldFreeCategoryName = FieldDesc{ ID: 6330, MaxLength: 60, Type: FieldTypeText, } FieldFreeCategoryContent = FieldDesc{ ID: 6331, MaxLength: 60, Type: FieldTypeText, } FieldRecordType = FieldDesc{ ID: 8000, Type: FieldTypeText, Length: 4, } FieldRecordLength = FieldDesc{ ID: 8100, Length: 5, Type: FieldTypeNumber, } FieldReceiverID = FieldDesc{ ID: 8315, Type: FieldTypeText, Length: 8, } FieldSenderID = FieldDesc{ ID: 8316, Type: FieldTypeText, Length: 8, } FieldProcedureID = FieldDesc{ ID: 8402, MaxLength: 6, Type: FieldTypeText, } FieldTestIdent = FieldDesc{ ID: 8410, MaxLength: 20, Type: FieldTypeText, } FieldTestDescription = FieldDesc{ ID: 8411, MaxLength: 60, Type: FieldTypeText, } FieldTestStatus = FieldDesc{ ID: 8418, MaxLength: 1, Type: FieldTypeText, } FieldResultValue = FieldDesc{ ID: 8420, Type: FieldTypeFloat, } FieldUnit = FieldDesc{ ID: 8421, MaxLength: 60, Type: FieldTypeText, } FieldSampleMaterialIdent = FieldDesc{ ID: 8428, MaxLength: 8, Type: FieldTypeText, } FieldSampleMaterialIndex = FieldDesc{ ID: 8429, Length: 2, Type: FieldTypeNumber, } FieldSampleMaterialDescription = FieldDesc{ ID: 8430, MaxLength: 60, Type: FieldTypeText, } FieldSampleMaterialSpecificatoin = FieldDesc{ ID: 8431, MaxLength: 60, Type: FieldTypeText, } FieldAcceptanceDate = FieldDesc{ ID: 8432, Type: FieldTypeText, Length: 8, } FieldDataUnit = FieldDesc{ ID: 8437, MaxLength: 60, Type: FieldTypeText, } FieldData = FieldDesc{ ID: 8438, MaxLength: 60, Type: FieldTypeText, } FieldAcceptanceTime = FieldDesc{ ID: 8439, Type: FieldTypeText, Length: 6, } FieldNormalValueText = FieldDesc{ ID: 8460, MaxLength: 60, Type: FieldTypeText, } FieldNormalValueLowerBoundary = FieldDesc{ ID: 8461, Type: FieldTypeFloat, } FieldNormalValueUpperBoundary = FieldDesc{ ID: 8462, Type: FieldTypeFloat, } FieldTestAnnotation = FieldDesc{ ID: 8470, MaxLength: 60, Type: FieldTypeText, } FieldResultText = FieldDesc{ ID: 8480, MaxLength: 60, Type: FieldTypeText, } FieldSignature = FieldDesc{ ID: 8990, MaxLength: 60, Type: FieldTypeText, } FieldCharacterSet = FieldDesc{ ID: 9206, Length: 1, Type: FieldTypeNumber, } FieldVersion = FieldDesc{ ID: 9218, Type: FieldTypeText, } )
var DefaultRegistry = new(TypeRegistry)
DefaultRegistry is the default type registry.
Functions ¶
func MustRegister ¶
func MustRegister(ft FieldType, fn ParseFieldFunc)
MustRegister is like Register but panics in case of an error.
func Register ¶
func Register(ft FieldType, fn ParseFieldFunc) error
Register registeres a new field type at the DefaultRegistry.
Types ¶
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
Decoder is capable of decoding GDT data.
func NewDecoder ¶
func NewDecoder(r io.Reader, options ...DecoderOption) (*Decoder, error)
type DecoderOption ¶
DecoderOption can be passed to NewParser to configure different aspects of the GDT Parser.
func WithDefaultCharset ¶
func WithDefaultCharset(m *charmap.Charmap) DecoderOption
WithDefaultChartset configures the default character set used by the decoder. Without this option, the decoder is configured to use IBM-8bit encoding (Codepage 437)A.
func WithTypeRegistry ¶
func WithTypeRegistry(reg *TypeRegistry) DecoderOption
WithTypeRegistry configures the type registry that should be used by the GDT decoder. Without this option, the Decoder defautls to DefaultRegistry.
type FieldType ¶
type FieldType string
FieldType describes the type of a record field.
var ( // alnum, float and num are defined by the specification FieldTypeText FieldType = "alnum" FieldTypeFloat FieldType = "float" FieldTypeNumber FieldType = "num" // date and time are "virtual" types that are defined as "alnum" but // enforce a rather hard set of rules on how the value is structured. // Thus, we represent them as dedicated types here to enforce consistent // Date (DDMMYYYY) and Time (HHMMSS) handling. FieldTypeDate FieldType = "date" // is parsed as time.Time FieldTypeTime FieldType = "time" // is parsed as time.Duration so you can use FieldTypeDate (time.Time) .Add(duration). )
All known fields.
type File ¶
type File struct { // Lines holds all lines of the file. Lines []Line // contains filtered or unexported fields }
func NewFile ¶
NewFile creates a File from lines by parsing important ones like 9206 which specify the character set to use.
func NewFileWithRegistry ¶
func NewFileWithRegistry(lines Lines, reg *TypeRegistry) *File
NewFileWithRegistry creates a new GDT file representation that uses reg for known types. Users most commonly only need to use NewFile instead of NewFileWithRegistry.
func (*File) Field ¶
Field returns the decoded value of the field record described by desc. The first line that matches is decoded and returned. Use Fields() to get a slice of all lines that match.
func (*File) Fields ¶
Fields is like Field but returns a slice containing the value for each occurance of desc in file.
func (*File) FloatField ¶
FloatField is like Field() but casts the returned interface to float64.
type ParseFieldFunc ¶
ParseFieldFunc parses the encoded value according to desc.
type TypeRegistry ¶
type TypeRegistry struct {
// contains filtered or unexported fields
}
TypeRegistry keeps track of registered and known types.
func (*TypeRegistry) ParseValue ¶
func (tr *TypeRegistry) ParseValue(value []byte, desc *FieldDesc) (interface{}, error)
ParseValue parses the data encoded in value using the type definition of desc.
func (*TypeRegistry) Register ¶
func (tr *TypeRegistry) Register(ft FieldType, fn ParseFieldFunc) error
Register registeres a new field type ft using fn to parse and validate the type.