gdt

package
v0.0.0-...-e7bba4f Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2021 License: MIT Imports: 9 Imported by: 0

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

Constants

This section is empty.

Variables

View Source
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

View Source
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,
	}
)
View Source
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)

func (*Decoder) NextLine

func (dec *Decoder) NextLine() (*Line, error)

NextLine reads the next line from the underlying reader.

func (*Decoder) ReadLines

func (dec *Decoder) ReadLines() (File, error)

ReadLines reads all GDT lines stored in the underlying reader. Note that the line data returned is not decoded.

type DecoderOption

type DecoderOption func(p *Decoder) error

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 FieldDesc

type FieldDesc struct {
	ID        FieldID
	Type      FieldType
	Name      string
	Length    int
	MaxLength int
}

FieldDesc describes fields specified in GDT 2.10

type FieldID

type FieldID uint

func (FieldID) String

func (f FieldID) String() string

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

func NewFile(lines Lines) *File

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

func (file *File) Field(desc FieldDesc) (interface{}, error)

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

func (file *File) Fields(desc FieldDesc) ([]interface{}, error)

Fields is like Field but returns a slice containing the value for each occurance of desc in file.

func (*File) FloatField

func (file *File) FloatField(desc FieldDesc) (float64, error)

FloatField is like Field() but casts the returned interface to float64.

func (*File) IntField

func (file *File) IntField(desc FieldDesc) (int, error)

IntField is like Field() but casts the returned interface to int.

func (*File) StringField

func (file *File) StringField(desc FieldDesc) (string, error)

StringField is like Field() but casts the returned interface to string.

type Line

type Line struct {
	FieldID FieldID
	Content []byte
}

type Lines

type Lines []Line

Lines is a slice of lines and provides utility methods.

type ParseFieldFunc

type ParseFieldFunc func(value []byte, desc *FieldDesc) (interface{}, error)

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.

Jump to

Keyboard shortcuts

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