multival
Lists of values with a constructor that coerces each element: the shape of a multi-valued attribute (VM > 1) such as ORIGINAL\PRIMARY\AXIAL.
import "github.com/amrshadid/go-dicom/multival" · pkg.go.dev
When to use it
When you want a backslash-separated value as a list that keeps coercing what you append to it, for example upper-casing CS values. Nothing else in the module uses it; data elements hold their values as strings, byte slices or numbers.
For the values of an element, use GetStringByKeyword and strings.Split on
\, or the typed accessors of dataelem and values.
Key types and functions
| Name | What it is for |
|---|---|
ConstrainedList, New | A list that passes each value through a constructor. |
ParseDICOMString | Split a \-separated value into a list. |
MultiValueToString | Join a list back with a separator. |
GetConstructorForVR | The constructor for a VR name: CS, DS, IS, LO, SH, ST, or plain strings. |
CSConstructor, DSConstructor, ISConstructor | Single constructors. |
NewCSList, NewDSList, NewISList | Lists with a constructor set. |
StringList, IntList, FloatList | Typed lists without a constructor. |
DatasetMultiValue | A list labelled with a tag and VR. |
Example
// Split a backslash-separated value, normalized by VR, and join it again.
package main
import (
"fmt"
"log"
"github.com/amrshadid/go-dicom/multival"
)
func main() {
list, err := multival.ParseDICOMString(`ORIGINAL\PRIMARY\AXIAL`, multival.GetConstructorForVR("CS"))
if err != nil {
log.Fatal(err)
}
fmt.Println("values:", list.Length(), list.Items())
if err := list.Append("helical"); err != nil {
log.Fatal(err)
}
fmt.Println(multival.MultiValueToString(list, `\`))
}It prints values: 3 [ORIGINAL PRIMARY AXIAL] and then
ORIGINAL\PRIMARY\AXIAL\HELICAL: the CS constructor upper-cased the appended
value.
Notes
- The constructors coerce; they do not validate. For VR rules use
valuerep.ValidateValue(valuerep). - A
ConstrainedListholdsinterface{}values; read them back with type assertions.
See also
matching
Decides whether a C-FIND query identifier matches a data set, and builds the answer a match is sent as, by the rules of PS3.4 C.2.2.2.
network
The DICOM upper layer protocol and DIMSE services: an SCU that associates and sends C-ECHO, C-STORE, C-FIND, C-MOVE, C-GET and the N- services, and an SCP that accepts associations and passes each request to a handler.