dimse

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2025 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CommandFieldCStoreRq  uint16 = 0x0001
	CommandFieldCStoreRsp uint16 = 0x8001
	CommandFieldCFindRq   uint16 = 0x0020
	CommandFieldCFindRsp  uint16 = 0x8020
	CommandFieldCGetRq    uint16 = 0x0010
	CommandFieldCGetRsp   uint16 = 0x8010
	CommandFieldCMoveRq   uint16 = 0x0021
	CommandFieldCMoveRsp  uint16 = 0x8021
	CommandFieldCEchoRq   uint16 = 0x0030
	CommandFieldCEchoRsp  uint16 = 0x8030
)
View Source
const (
	RequiredElement isOptionalElement = iota
	OptionalElement
)

Variables

Success is an OK status for a call.

Functions

func EncodeElements

func EncodeElements(e io.Writer, elems []*dicom.Element) error

Encode the given elements. The elements are sorted in ascending tag order.

func EncodeMessage

func EncodeMessage(out io.Writer, v Message) error

EncodeMessage serializes the given message. Errors are reported through e.Error()

func NewElement

func NewElement(tag tag.Tag, value any) (*dicom.Element, error)

Types

type CEchoRq

type CEchoRq struct {
	MessageID          MessageID
	CommandDataSetType CommandDataSetType
	Extra              []*dicom.Element // Unparsed elements
}

func (*CEchoRq) CommandField

func (v *CEchoRq) CommandField() uint16

func (*CEchoRq) Encode

func (v *CEchoRq) Encode(e io.Writer) error

func (*CEchoRq) GetMessageID

func (v *CEchoRq) GetMessageID() MessageID

func (*CEchoRq) GetStatus

func (v *CEchoRq) GetStatus() *Status

func (*CEchoRq) HasData

func (v *CEchoRq) HasData() bool

func (*CEchoRq) String

func (v *CEchoRq) String() string

type CEchoRsp

type CEchoRsp struct {
	MessageIDBeingRespondedTo MessageID
	CommandDataSetType        CommandDataSetType
	Status                    Status
	Extra                     []*dicom.Element // Unparsed elements
}

func (*CEchoRsp) CommandField

func (v *CEchoRsp) CommandField() uint16

func (*CEchoRsp) Encode

func (v *CEchoRsp) Encode(e io.Writer) error

func (*CEchoRsp) GetMessageID

func (v *CEchoRsp) GetMessageID() MessageID

func (*CEchoRsp) GetStatus

func (v *CEchoRsp) GetStatus() *Status

func (*CEchoRsp) HasData

func (v *CEchoRsp) HasData() bool

func (*CEchoRsp) String

func (v *CEchoRsp) String() string

type CFindRq

type CFindRq struct {
	AffectedSOPClassUID string
	MessageID           MessageID
	Priority            uint16
	CommandDataSetType  CommandDataSetType
	Extra               []*dicom.Element // Unparsed elements
}

func (*CFindRq) CommandField

func (v *CFindRq) CommandField() uint16

func (*CFindRq) Encode

func (v *CFindRq) Encode(e io.Writer) error

func (*CFindRq) GetMessageID

func (v *CFindRq) GetMessageID() MessageID

func (*CFindRq) GetStatus

func (v *CFindRq) GetStatus() *Status

func (*CFindRq) HasData

func (v *CFindRq) HasData() bool

func (*CFindRq) String

func (v *CFindRq) String() string

type CFindRsp

type CFindRsp struct {
	AffectedSOPClassUID       string
	MessageIDBeingRespondedTo MessageID
	CommandDataSetType        CommandDataSetType
	Status                    Status
	Extra                     []*dicom.Element // Unparsed elements
}

func (*CFindRsp) CommandField

func (v *CFindRsp) CommandField() uint16

func (*CFindRsp) Encode

func (v *CFindRsp) Encode(e io.Writer) error

func (*CFindRsp) GetMessageID

func (v *CFindRsp) GetMessageID() MessageID

func (*CFindRsp) GetStatus

func (v *CFindRsp) GetStatus() *Status

func (*CFindRsp) HasData

func (v *CFindRsp) HasData() bool

func (*CFindRsp) String

func (v *CFindRsp) String() string

type CGetRq

type CGetRq struct {
	AffectedSOPClassUID string
	MessageID           MessageID
	Priority            uint16
	CommandDataSetType  CommandDataSetType
	Extra               []*dicom.Element // Unparsed elements
}

func (*CGetRq) CommandField

func (v *CGetRq) CommandField() uint16

func (*CGetRq) Encode

func (v *CGetRq) Encode(e io.Writer) error

func (*CGetRq) GetMessageID

func (v *CGetRq) GetMessageID() MessageID

func (*CGetRq) GetStatus

func (v *CGetRq) GetStatus() *Status

func (*CGetRq) HasData

func (v *CGetRq) HasData() bool

func (*CGetRq) String

func (v *CGetRq) String() string

type CGetRsp

type CGetRsp struct {
	AffectedSOPClassUID            string
	MessageIDBeingRespondedTo      MessageID
	CommandDataSetType             CommandDataSetType
	NumberOfRemainingSuboperations uint16
	NumberOfCompletedSuboperations uint16
	NumberOfFailedSuboperations    uint16
	NumberOfWarningSuboperations   uint16
	Status                         Status
	Extra                          []*dicom.Element // Unparsed elements
}

func (*CGetRsp) CommandField

func (v *CGetRsp) CommandField() uint16

func (*CGetRsp) Encode

func (v *CGetRsp) Encode(e io.Writer) error

func (*CGetRsp) GetMessageID

func (v *CGetRsp) GetMessageID() MessageID

func (*CGetRsp) GetStatus

func (v *CGetRsp) GetStatus() *Status

func (*CGetRsp) HasData

func (v *CGetRsp) HasData() bool

func (*CGetRsp) String

func (v *CGetRsp) String() string

type CMoveRq

type CMoveRq struct {
	AffectedSOPClassUID string
	MessageID           MessageID
	Priority            uint16
	MoveDestination     string
	CommandDataSetType  CommandDataSetType
	Extra               []*dicom.Element // Unparsed elements
}

func (*CMoveRq) CommandField

func (v *CMoveRq) CommandField() uint16

func (*CMoveRq) Encode

func (v *CMoveRq) Encode(e io.Writer) error

func (*CMoveRq) GetMessageID

func (v *CMoveRq) GetMessageID() MessageID

func (*CMoveRq) GetStatus

func (v *CMoveRq) GetStatus() *Status

func (*CMoveRq) HasData

func (v *CMoveRq) HasData() bool

func (*CMoveRq) String

func (v *CMoveRq) String() string

type CMoveRsp

type CMoveRsp struct {
	AffectedSOPClassUID            string
	MessageIDBeingRespondedTo      MessageID
	CommandDataSetType             CommandDataSetType
	NumberOfRemainingSuboperations uint16
	NumberOfCompletedSuboperations uint16
	NumberOfFailedSuboperations    uint16
	NumberOfWarningSuboperations   uint16
	Status                         Status
	Extra                          []*dicom.Element // Unparsed elements
}

func (*CMoveRsp) CommandField

func (v *CMoveRsp) CommandField() uint16

func (*CMoveRsp) Encode

func (v *CMoveRsp) Encode(e io.Writer) error

func (*CMoveRsp) GetMessageID

func (v *CMoveRsp) GetMessageID() MessageID

func (*CMoveRsp) GetStatus

func (v *CMoveRsp) GetStatus() *Status

func (*CMoveRsp) HasData

func (v *CMoveRsp) HasData() bool

func (*CMoveRsp) String

func (v *CMoveRsp) String() string

type CStoreRq

type CStoreRq struct {
	AffectedSOPClassUID                  string
	MessageID                            MessageID
	Priority                             uint16
	CommandDataSetType                   CommandDataSetType
	AffectedSOPInstanceUID               string
	MoveOriginatorApplicationEntityTitle string
	MoveOriginatorMessageID              MessageID
	Extra                                []*dicom.Element // Unparsed elements
}

func (*CStoreRq) CommandField

func (v *CStoreRq) CommandField() uint16

func (*CStoreRq) Encode

func (v *CStoreRq) Encode(e io.Writer) error

func (*CStoreRq) GetMessageID

func (v *CStoreRq) GetMessageID() MessageID

func (*CStoreRq) GetStatus

func (v *CStoreRq) GetStatus() *Status

func (*CStoreRq) HasData

func (v *CStoreRq) HasData() bool

func (*CStoreRq) String

func (v *CStoreRq) String() string

type CStoreRsp

type CStoreRsp struct {
	AffectedSOPClassUID       string
	MessageIDBeingRespondedTo MessageID
	CommandDataSetType        CommandDataSetType
	AffectedSOPInstanceUID    string
	Status                    Status
	Extra                     []*dicom.Element // Unparsed elements
}

func (*CStoreRsp) CommandField

func (v *CStoreRsp) CommandField() uint16

func (*CStoreRsp) Encode

func (v *CStoreRsp) Encode(e io.Writer) error

func (*CStoreRsp) GetMessageID

func (v *CStoreRsp) GetMessageID() MessageID

func (*CStoreRsp) GetStatus

func (v *CStoreRsp) GetStatus() *Status

func (*CStoreRsp) HasData

func (v *CStoreRsp) HasData() bool

func (*CStoreRsp) String

func (v *CStoreRsp) String() string

type CommandAssembler

type CommandAssembler struct {
	// contains filtered or unexported fields
}

CommandAssembler is a helper that assembles a DIMSE command message and data payload from a sequence of P_DATA_TF PDUs.

func (*CommandAssembler) AddDataPDU

func (commandAssembler *CommandAssembler) AddDataPDU(pdu *pdu.PDataTf) (byte, Message, *DimseCommand, error)

AddDataPDU is to be called for each P_DATA_TF PDU received from the network. If the fragment is marked as the last one, AddDataPDU returns <SOPUID, TransferSyntaxUID, payload, nil>. If it needs more fragments, it returns <"", "", nil, nil>. On error, it returns a non-nil error.

type CommandDataSetType

type CommandDataSetType uint16
const (
	// CommandDataSetTypeNull indicates that the DIMSE message has no data payload,
	// when set in dicom.TagCommandDataSetType. Any other value indicates the
	// existence of a payload.
	CommandDataSetTypeNull CommandDataSetType = 0x101

	// CommandDataSetTypeNonNull indicates that the DIMSE message has a data
	// payload, when set in dicom.TagCommandDataSetType.
	CommandDataSetTypeNonNull CommandDataSetType = 1
)

type DimseCommand

type DimseCommand struct {
	// contains filtered or unexported fields
}

func NewDimseCommand

func NewDimseCommand(fpath string) *DimseCommand

func (*DimseCommand) Ack

func (dc *DimseCommand) Ack() error

func (*DimseCommand) AppendData

func (dc *DimseCommand) AppendData(data []byte) error

func (*DimseCommand) Close

func (dc *DimseCommand) Close() error

func (*DimseCommand) Read

func (dc *DimseCommand) Read(p []byte) (int, error)

Read implements io.Reader by delegating to an internal *os.File reader.

func (*DimseCommand) ReadData

func (dc *DimseCommand) ReadData() io.Reader

func (*DimseCommand) Size

func (dc *DimseCommand) Size() int64

Size returns the current size of the underlying file. Returns -1 on error.

type Message

type Message interface {
	fmt.Stringer // Print human-readable description for debugging.
	Encode(io.Writer) error
	// GetMessageID extracts the message ID field.
	GetMessageID() MessageID
	// CommandField returns the command field value of this message.
	CommandField() uint16
	// GetStatus returns the the response status value. It is nil for request message
	// types, and non-nil for response message types.
	GetStatus() *Status
	// HasData is true if we expect P_DATA_TF packets after the command packets.
	HasData() bool
}

Message defines the common interface for all DIMSE message types.

func ReadMessage

func ReadMessage(dataset *dicom.Dataset) (message Message, err error)

type MessageDecoder

type MessageDecoder struct {
	// contains filtered or unexported fields
}

Helper class for extracting values from a list of DicomElement.

func (*MessageDecoder) Decode

func (d *MessageDecoder) Decode(commandField uint16) (Message, error)

func (*MessageDecoder) GetCommandDataSetType

func (d *MessageDecoder) GetCommandDataSetType() (CommandDataSetType, error)

func (*MessageDecoder) GetStatus

func (d *MessageDecoder) GetStatus() (s Status, err error)

func (*MessageDecoder) GetString

func (d *MessageDecoder) GetString(tag dicomtag.Tag, optional isOptionalElement) (string, error)

func (*MessageDecoder) GetUInt16

func (d *MessageDecoder) GetUInt16(tag dicomtag.Tag, optional isOptionalElement) (uint16, error)

Find an element with "tag", and extract a uint16 from it. Errors are reported in d.err.

func (*MessageDecoder) UnparsedElements

func (d *MessageDecoder) UnparsedElements() []*dicom.Element

type MessageID

type MessageID = uint16

type Status

type Status struct {
	// Status==StatusSuccess on success. A non-zero value on error.
	Status StatusCode

	// Optional error payloads.
	ErrorComment string // Encoded as (0000,0902)
}

Status represents a result of a DIMSE call. P3.7 C defines list of status codes and error payloads.

func (*Status) ToElements

func (s *Status) ToElements() ([]*dicom.Element, error)

type StatusCode

type StatusCode uint16

StatusCode represents a DIMSE service response code, as defined in P3.7

const (
	StatusSuccess               StatusCode = 0
	StatusCancel                StatusCode = 0xFE00
	StatusSOPClassNotSupported  StatusCode = 0x0112
	StatusInvalidArgumentValue  StatusCode = 0x0115
	StatusInvalidAttributeValue StatusCode = 0x0106
	StatusInvalidObjectInstance StatusCode = 0x0117
	StatusUnrecognizedOperation StatusCode = 0x0211
	StatusNotAuthorized         StatusCode = 0x0124
	StatusPending               StatusCode = 0xff00

	// C-STORE-specific status codes. P3.4 GG4-1
	CStoreOutOfResources              StatusCode = 0xa700
	CStoreCannotUnderstand            StatusCode = 0xc000
	CStoreDataSetDoesNotMatchSOPClass StatusCode = 0xa900

	// C-FIND-specific status codes.
	CFindUnableToProcess StatusCode = 0xc000

	// C-MOVE/C-GET-specific status codes.
	CMoveOutOfResourcesUnableToCalculateNumberOfMatches StatusCode = 0xa701
	CMoveOutOfResourcesUnableToPerformSubOperations     StatusCode = 0xa702
	CMoveMoveDestinationUnknown                         StatusCode = 0xa801
	CMoveDataSetDoesNotMatchSOPClass                    StatusCode = 0xa900

	// Warning codes.
	StatusAttributeValueOutOfRange StatusCode = 0x0116
	StatusAttributeListError       StatusCode = 0x0107
)

func (StatusCode) String

func (i StatusCode) String() string

Jump to

Keyboard shortcuts

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