Merge: DICOM Toolkit V. 5.11.0
Merge: DICOM Toolkit V. 5.11.0
Merge: DICOM Toolkit V. 5.11.0
V. 5.11.0
C/C++ SAMPLE APPLICATION GUIDE
Merge Healthcare
900 Walnut Ridge Drive
Hartland, WI 53029
USA
•
Contents
OVERVIEW .......................................................................................................... 10
Documentation Road Map................................................................................ 10
Conventions...................................................................................................... 11
GENERAL ............................................................................................................ 12
Environment ..................................................................................................... 12
Files .................................................................................................................. 12
THE STORAGE AND STORAGE COMMITMENT SERVICE CLASSES ........... 14
Service Definition ............................................................................................. 14
Storage Service Class User Requirements .................................................. 14
Storage Service Class Provider Requirements ............................................ 15
Storage Commitment Service Class User Requirements ............................ 15
Storage Commitment Service Class Provider Requirements....................... 16
Summary....................................................................................................... 16
Composite Services Supported ........................................................................ 16
Commands Supported ..................................................................................... 24
C_STORE_RQ ............................................................................................. 24
C_STORE_RSP ........................................................................................... 24
Valid Messages ................................................................................................ 24
STORAGE SERVICE CLASS SAMPLE APPLICATIONS ................................... 26
Configuration .................................................................................................... 26
SCU Configuration ........................................................................................ 26
SCP Configuration ........................................................................................ 26
General Configuration................................................................................... 27
Sample SCU ..................................................................................................... 27
Overview of Program Operation ................................................................... 27
Asynchronous Operations ............................................................................ 31
Sample SCP ..................................................................................................... 32
Overview of Program Operation ................................................................... 32
Asynchronous Operations ............................................................................ 35
THE QUERY/RETRIEVE SERVICE CLASS ....................................................... 35
Service Definition ............................................................................................. 35
Commands Supported ..................................................................................... 37
C-FIND Command ........................................................................................ 37
C-MOVE Command ...................................................................................... 37
C-GET Command ......................................................................................... 37
Extended Negotiation for Relational Queries ................................................... 37
Valid Messages ................................................................................................ 37
QUERY/RETRIEVE SERVICE CLASS SAMPLE APPLICATIONS .................... 38
Configuration .................................................................................................... 39
3
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
4
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
5
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
6
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
7
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
8
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
9
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
Overview
This manual is designed to give the user of the Merge DICOM Toolkit an
example of how to implement several of the DICOM Service Classes. Each
DICOM 3.0 Service Class is defined and thoroughly explained in the Digital
Imaging and Communications in Medicine (DICOM) standard Version 3.0, Part 4.
Although only the Storage, Query/Retrieve, Print, Modality Worklist and Media
Service Classes are discussed in this guide, Merge DICOM Toolkit supports
other DICOM service classes.
The examples described herein use the ANSI-C programming language along
with the Merge DICOM Toolkit library of ANSI-C functions to implement each of
the Service Classes in a limited yet instructional fashion.
Read Me FIRST! The User’s Manual is the foundation for all other documentation because it
explains the concepts of DICOM and the DICOM Toolkit. Before plunging into
the Reference Manual or Sample Application Guides you should be comfortable
with the material in the User’s Manual.
The Reference Manual is where you go for detailed information on the DICOM
Toolkit. This includes the Application Programming Interface (API), toolkit
configuration, the runtime object database, and status logging. The Reference
Manual also includes a general DICOM conformance statement for the toolkit.
The DICOM Message Dictionary Specification and Generation Manual is an
optional extension that describes how to privately extend, and generate, Merge
DICOM Toolkit DICOM dictionary and message information binary files. This
manual is provided along with the executables for your specific platform that
generate the binary files.
10
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
User’s
Manual
Conventions
This manual follows a few formatting conventions.
Terms that are being defined are presented in boldface.
Sample Margin Note Margin notes (in the left margin) are used to highlight important points or sections
of the document.
Performance Portions of the document that can relate directly to the performance of your
Tuning application are marked with the special margin note Performance Tuning.
Sample commands appear in bold courier font, while sample output, source
code, and function calls appear in standard courier font.
Note: Notes are used to indicate information which may be helpful or of special
interest to the reader.
11
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
General
Environment
All Merge DICOM Toolkit applications require an environment variable named
MERGE_INI to be defined and set. This variable informs the application as to the
name of the initialization file discussed below.
How MERGE_INI is set depends on which shell is being used. If the user is
running the Bourne or Korn shell, the command,
$ MERGE_INI=./merge.ini; export MERGE_INI
will accomplish this assuming that merge.ini is the name of the initialization
file. If the user is running the C shell, the command
% setenv MERGE_INI ./merge.ini
will accomplish the same. The general formats for the above two commands are:
$ MERGE_INI=./fname.ini; export MERGE_INI (Bourne Shell)
where fname is the name of the file containing the initialization information.
Files
The following is a description of the files used to implement the toolkit sample
applications:
Table 1: Source Code Files
Filename Description
makefile The makefile used to generate all Merge DICOM Toolkit sample
applications.
mc3msg.h The header file that contains definitions for the message objects
functionality.
mcstatus.h The header file that contains definitions for statuses and return
codes.
mergecom.h The header file that contains definitions for the merge library
network functionality.
stor_scp.c The C source code file that contains the source code for
implementation of the Storage and Storage Commitment Service
Class Provider.
12
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
Filename Description
stor_scu.c The C source code file that contains the source code for
implementation of the Storage and Storage Commitment Service
Class User.
prnt_svc.h The header file that contains definitions for the Print applications.
prnt_scp.c The C source code file that contains the source code for
implementation of the Print Service Class Provider.
prnt_scu.c The C source code file that contains the source code for
implementation of the Print Service Class User.
med_fsu.c The C source code file that contains the source code for
implementation of the Media File Set Updator.
qr.h The header file that contains definitions for the Modality Worklist
and Query/Retrieve applications.
qr_scp.c The C source code file that contains the source code for
implementation of the Query/Retrieve Service Class Provider.
qr_scu.c The C source code file that contains the source code for
implementation of the Query/Retrieve Service Class User.
work_scp.c The C source code file that contains the source code for the
implementation of the Modality Worklist and Performed Procedure
Step Service Class Provider.
work_scu.c The C source code file that contains the source code for the
implementation of the Modality Worklist and Performed Procedure
Step Service Class User.
workdata.h The header file that contains definitions for the Modality Worklist
and Performed Procedure database functions.
qr_util.c The C source code file that contains the source code for utility
functions used by the Query/Retrieve implementation and the
Modality Worklist implementation.
13
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
Filename Description
Service Definition
The service definition can be broken down into the actions of Service Class
Users (SCU’s) and Service Class Providers (SCP’s). An SCU sends
messages to an SCP. Note that DICOM Storage SOP Instances are defined for
both image and non-image objects. In client/server terminology, the SCU’s role
is that of a client; the SCP’s role is that of a server. DICOM does not specify the
application in which the Storage Service Class is used. It only defines a
transport mechanism for exchanging Storage Service Class objects.
Now we will look more closely at the behavior of SCUs and SCPs for the Storage
and Storage Commitment Service classes.
14
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
SUCCESS
15
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
Summary
As can be seen from these simple descriptions of SCU and SCP behavior, Merge
DICOM Toolkit transparently handles the majority of the DICOM implementation
details. The sample application code described in this manual demonstrates how
to use the Merge DICOM Toolkit to implement SCUs and SCPs within the
Storage and Storage Commitment Service Classes.
Merge DICOM Toolkit Service Name SOP Class Name SOP Class UID
16
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
Merge DICOM Toolkit Service Name SOP Class Name SOP Class UID
17
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
Merge DICOM Toolkit Service Name SOP Class Name SOP Class UID
18
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
Merge DICOM Toolkit Service Name SOP Class Name SOP Class UID
19
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
Merge DICOM Toolkit Service Name SOP Class Name SOP Class UID
20
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
Merge DICOM Toolkit Service Name SOP Class Name SOP Class UID
21
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
Merge DICOM Toolkit Service Name SOP Class Name SOP Class UID
22
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
Merge DICOM Toolkit Service Name SOP Class Name SOP Class UID
23
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
Merge DICOM Toolkit Service Name SOP Class Name SOP Class UID
Commands Supported
When an SCU or SCP implementing the DICOM Storage Service Class sends or
receives a message, the following Merge DICOM Toolkit defined commands will
be a encoded within the message:
C_STORE_RQ
An SCU will encode store request messages with the C_STORE_RQ command.
An SCP will receive store request messages encoded with the C_STORE_RQ
command.
C_STORE_RSP
An SCP will encode store response messages with the C_STORE_RSP
command. An SCU will receive store response messages encoded with the
C_STORE_RSP command.
Valid Messages
Valid DICOM messages are defined in terms of a composite service and
command. The file “message.txt”, which is included with your Merge DICOM
Toolkit, contains the DICOM message formats. Below is an excerpt from the
“message.txt” file for the STANDARD_CR composite service, C_STORE_RQ
command. For instance, the example shows that attribute 0008,0020
representing STUDY_DATE, with a DA value representation, is present in this
message.
##################################################################
STANDARD_CR - C_STORE_RQ
##################################################################
0008,0005 Specific Character set CS 1C
Condition: EXPANDED_OR_REPLACEMENT_CHARACTER_SET_USED
Defined Terms: ISO-IR 100, ISO-IR 101, ISO-IR 109, ISO-IR 110,
ISO-IR144, ISO-IR 127, ISO-IR 126, ISO-IR 138, ISO-IR 148
0008,0008 Image Type CS 3
Defined Terms: (ORIGINAL, DERIVED) (PRIMARY, SECONDARY)
0008,0012 Instance Creation Date DA 3
0008,0013 Instance Creation Time TM 3
0008,0014 Instance Creator UID UI 3
0008,0016 SOP Class UID UI 1
0008,0018 SOP Instance UID UI 1
0008,0020 Study Date DA 2
0008,0021 Series Date DA 3
0008,0022 Acquisition Date DA 3
24
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
25
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
Configuration
Both the SCU and the SCP sample Storage Service Class applications require
configuration files which define communication parameters, levels of message
logging, etc. Please see the “Configuration Parameters” appendix of the Merge
DICOM Toolkit Reference Manual for complete descriptions of the configuration
files. Some important points to remember for these sample applications are as
follows:
SCU Configuration
Since the sample SCU will be opening a Storage Service Class association with
the sample SCP, there is a section for the SCP in the Application Profile
(“mergecom.app”).
The Application Entity Title for the sample SCP is MERGE_STORE_SCP.
Ensure that the PORT_NUMBER matches the value configured for
TCPIP_LISTEN_PORT in the SCP Configuration section below.
You must change the HOST_NAME to be the host name of the machine on
which the SCP will be running.
If utilizing the Storage Commitment Service Class, you should configure the
TCPIP_LISTEN_PORT in the System Profile (“mergecom.pro”) to an unused
TCP/IP port. Make sure the PORT_NUMBER in the “mergecom.app” for the
MERGE_STORE_SCU matches this value. This value is used by the SCP to
connect to the SCU.
SCP Configuration
You should configure the TCPIP_LISTEN_PORT in the System Profile
(“mergecom.pro”) to an unused TCP/IP port. Make sure the PORT_NUMBER in
“mergecom.app” for MERGE_STORE_SCP matches this value. This value is
used by the SCU to connect to the SCP.
If utilizing the Storage Commitment Service Class, the sample SCP will be
opening a Storage Commitment Service Class association with the sample SCU,
there is a section for the SCU in the Application Profile (“mergecom.app”).
26
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
If utilizing the Storage Commitment Service Class, you must change the
HOST_NAME to be the host name of the machine on which the SCU will be
running. Also, ensure that the PORT_NUMBER matches the value configured
for TCPIP_LISTEN_PORT in the SCU Configuration section above.
General Configuration
Don’t forget to place the license number you received when you purchased the
toolkit into the [ASSOC_PARMS] section of the System Profile (“mergecom.pro”).
Note: The sample Storage Service Class programs are shipped with a single
set of configuration files: merge.ini, mergecom.app, mergecom.pro, and
mergecom.srv. When utilizing Storage Commitment, both the SCU and
SCP must listen for associations, requiring separate configuration files
for both the SCU and SCP.
Sample SCU
Overview of Program Operation
The sample SCU sends a variable number of images, to a Storage Service Class
SCP. A list of the images to be sent can be placed in a file, or the images must
have been previously named “1.img”, “2.img”, etc. The sample SCU is invoked
with command line arguments which determine the operation of the program.
These arguments take the form:
stor_scu -a local_ae –b local_port -n remote_host -p
remote_port -l service_list –f filename –c -e -v –u
username –w password –q [remote_application] [start_image]
[stop_image]
Parameter Description
-p remote_port This optional argument specifies the listen port of the remote
SCP application. This argument overrides the listen port
specified in the remote_application section of the
mergecom.app file.
27
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
Parameter Description
-l service_list This optional argument specifies the service list to use when
negotiating with the remote SCP application. This argument
overrides the service list specified in the
remote_application section of the mergecom.app file.
-b local_port This optional argument specifies the port that the sample
application will listen on during storage commitment. This
argument overrides the built in default of 1115.
28
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
The general flow of the sample Storage Service Class SCU can be charted as in
Figure 2.
Start
1
Validate Command
Line Arguments
2
Register Application
3
Determine list of files
or images to transfer.
4 Open Association
with SCP
5
Determine image file
format and send images
6
Close Association
7
If configured, handle
Storage Commitment
End
29
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
30
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
Asynchronous Operations
The Storage SCU sample application has been written to take advantage of
when an association allowing asynchronous DICOM operations has been
negotiated. Note that by default the Storage SCU does not support
asynchronous DICOM operations. The mergecom.app configuration file must be
modified to enable this support.
The use of DICOM asynchronous operations allows an SCU to send multiple
request messages to an SCP without receiving a response message. Also, the
SCP can send the response messages out of order. During association
negotiation, the SCU and SCP negotiate how many outstanding operations (i.e.,
request messages) are allowed over the association at any time.
The following aspects of the SCU’s code are specific to asynchronous
communications:
• The application maintains a linked list of all of the messages sent over the
association. This list is used to maintain which request messages have been
sent over the network and if response messages have been received for
these request messages.
• The SCU polls for response messages after sending its request message. If
the max operations will not be exceeded by sending another request, the
SCU will simply move on to send the next request message.
• After sending all its request messages, the SCU waits for any remaining
response messages until it has received responses for all of them.
31
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
Sample SCP
Overview of Program Operation
The sample SCP handles associations and receives images from Storage
Service Class SCUs. The sample SCP is invoked with a command line argument
which determines what is to be done with received images. These arguments
take the form:
stor_scp [options]
Option Description
-a local_ae This optional argument sets the storage SCP’s local Application
Entity Title.
-p listen_port This optional argument sets the storage SCP’s listen port. This
value overrides the configured value in the mergecom.pro file.
-t <il, el, eb> Specify the transfer syntax to store the images in where il =
Implicit VR Little Endian, el = Explicit VR Little Endian, and eb
= Explicit VR Big Endian. This option is used in conjunction with
the –F and –M options to specify the file format.
The general flow of the sample Storage Service Class SCP can be charted as in
Figure 3.
32
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
Start
1
Validate Command
Line Arguments
2
Wait for an Association
3
Handle Association
33
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
34
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
Please Note! It is important in multi-tasking (not multi-threading) applications that the parent
process call MC_Release_Parent_Association after starting a child process
to handle the association, so that the parent’s resources for the association are
released.
Asynchronous Operations
The Storage SCP sample application does not have any specific changes
implemented to support asynchronous communications. Note that by default the
Storage SCP does not support asynchronous DICOM operations. The
mergecom.app configuration file must be modified to enable this support.
Service Definition
The Query/Retrieve (Q/R) Service Class is implemented using two applications:
the Service Class Provider (SCP) and the Service Class User (SCU). The
SCP accepts find requests from the SCU and performs searches using a simple
search algorithm to find the images specified in the find command. The SCU then
requests that the SCP move those images that were found to a specified
application entity. The following tables detail the composite services supported
by the SCP and the SCU.
Table 6: Composite Services Supported by the SCP
35
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
36
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
Commands Supported
C-FIND Command
The C-FIND command is the mechanism used in DICOM to conduct a query.
This implementation of the C-FIND command for the Q/R Service Class is
intended as an example. Only the baseline behavior has been implemented. The
full behavior has been left for the application developer.
C-MOVE Command
Application Entity The C-MOVE command is the mechanism used in DICOM to initiate the transfer
Tiles should be of SOP instances between application entities. A C-MOVE-RQ instructs an SCP
configurable to move a SOP instance to a specified application entity (and not hostname and
TCP/IP port). Thus, application entity titles within a DICOM network should be
unique because they identify applications within the scope of a network. It is
recommended that application entity titles be configurable to help solve this
problem.
C-GET Command
C-GET not widely This example does not use the DIMSE C-GET service in this implementation of
implemented! the Q/R Service Class. Note that the DICOM Standard indicates that a DIMSE-C
C-GET may also be used to implement the Q/R Service Class. Currently, most
implementations of the Query/Retrieve Service Class use the C-MOVE command
to initiate transfers of images.
Valid Messages
Valid DICOM messages are defined in terms of a composite service and
command. The file “message.txt”, which is included with your Merge DICOM
Toolkit, contains DICOM message formats. Below is an excerpt from the
“message.txt” file.
##################################################################
#####
PATIENT_ROOT_QR_FIND - C_FIND_RQ
##################################################################
#####
0008,0005 Specific Character Set CS 3
Defined Terms: ISO-IR 100, ISO-IR 101, ISO-IR 109, ISO-IR 110,
ISO-IR144, ISO-IR 127, ISO-IR 126, ISO-IR 138, ISO-IR 148
0008,0008 Image Type CS 3
Enumerated Values: (ORIGINAL, DERIVED)(PRIMARY,SECONDARY)(SINGLE
PLANE, BIPLANE A, BIPLANE B,BIPLANE)
0008,0012 Instance Creation Date DA 3
0008,0013 Instance Creation Time TM 3
0008,0014 Instance Creator UID UI 3
0008,0016 SOP Class UID UI 3
37
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
38
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
3. The SCU receives each response message and interprets the status and
data. The SCU reads C-FIND responses from the SCP until a status of
SUCCESS is received.
6. When the C-STORE operation finishes, the SCP sends the SCU an
additional C-MOVE response message containing the final status of the
operation.
7. In addition, the SCU can generate a frame level retrieval by specifying a
list of frame numbers in a multi frame image. The SCP can handle a C-
MOVE request based on this frame level retrieval as specified by the
SCU.
Configuration
Configuration information for the sample applications are kept in configuration
files. These files contain initialization and startup information used by the sample
applications as they execute. There are 4 different configuration files necessary
for execution by any one application. They are: the Initialization file (referred to
as "the dot ini file"), the Network Profile (referred to as "the dot pro file"), the
Application Profile (referred to as "the dot app file") and the Service file (referred
to as "the dot S-R-V file).
The configuration files follow the same format: a section starts with a label
delimited with square brackets. Each item belonging to a section is then listed.
The list is constructed of a variable followed by the equal sign ( "=" ) followed by
the value of the variable.
For a more detailed discussion of the configuration files distributed with the
DICOM Toolkit please see the files on the distribution itself and see the DICOM
Toolkit Reference Manual. Each file is fully documented and explained in detail.
39
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
where remote_ae is the Q/R SCP and options are described below.
Note: The above command assumes that you are in the proper directory and
that your MERGE_INI environment variable has been set properly.
Note: The listen port has to be changed in the mergecom.pro file of the Q/R
SCU to match the Q/R SCP’s port number found in the mergecom.app
file.
-p ListenPort This option specifies the port that this application will
listen on during retrieval from the remote application, i.e.
moves to the default destination. This option overrides
the built in default of 1115, and will be used when Dest is
not provided.
-1 ServList1 This option specifies the name of the service list that will
be used as the Q/R service list. ServList1 may be any
user defined string with a length of no greater than 16
40
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
-2 ServList2 This option specifies the name of the service list that will
be used as the C-STORE service list. ServList2 may be
any user defined string with a length of no greater that 16
characters. Currently this option is not implemented
since the service list is obtained from the “dot app” file.
The service list for the Dest parameter is used.
Note: The default model and level, Patient Study Only, is the only model
and level that is handled by the sample SCP.
The Enter Data option allows data to be entered in the following manner. Type
the option followed by the data (e.g. to enter a name type “2 Jones^B”).
41
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
CFINDOption
CFINDOption checks to make sure the list of query results is freed up, and then
proceeds to send a C-FIND message by calling SendCFINDMessage. The now
empty list is used to hold the data that is returned from the SCP.
SendCFINDMessage
Next, a new message is opened by calling MC_Open_Message. The message is
filled in with the items the SCU would like the SCP to return. This includes the
Q/R level. The message is sent on its way by calling
MC_Send_Request_Message.
After the message has been sent to the SCP, the SCU waits for a response by
calling MC_Read_Message. When a message arrives, the status is checked to
determine whether more data is coming (C_FIND_PENDING) or whether the last
data item has been returned (C_FIND_SUCCESS). If the status is pending, the
unique ID returned to the SCU is stored in the ReturnedData array and
MC_Read_Message is called again to wait for the next message. If success is
returned, the final data item has been sent to the SCU and the final patient ID is
stored in the patient ID array.
CMOVEOption
CMOVEOption establishes an association with the SCP in order to move the
selected item. It establishes the connection by calling MC_Open_Association.
If successful, SendCMOVEMessage is called to send the move request to the
SCP.
SendCMOVEMessage
SendCMOVEMessage is used to handle sending of C-MOVE request messages
and to accept the C-MOVE responses. This function does the following:
42
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
ProcessCSTOREAssociation
ProcessCSTOREAssociation processes a storage association that is initated
by a C-MOVE message. It begins by posting a MC_Wait_For_Association.
This initial “wait” gets the listen socket started, which avoids a possible problem
with timing. If no association is received it just returns, if one is received it is dealt
with.
While the association proceeds with the remote application (the SCP), three
events can occur concurrently:
1. The association could be closed, the association could be aborted or the
network could shut down. If one of these happens it will handle the
association closing and return with no error.
2. There could be some sort of abnormal response which would cause a
return with an error.
3. There could be a successful C-STORE message in which case we are
ready to receive the information. A file is opened and given to
MC_Message_To_Stream along with the callback function
MessageToFile. The data is then written to the file. If there is some
sort of problem with writing the data to file, CancelCMOVERQ is called to
cancel the sending of any more information. If there were no problems,
a C-STORE response is then given to the associated application for the
successfull receipt of the message.
To clean up, the message object is released by calling MC_Close_Message.
Also, the second association is closed (if it was opened) by calling
MC_Close_Association. This is continued until the function returns because
of one of the above conditions.
MessageToFile
MessageToFile processes a C-STORE request from a remote application. After
determining the modality of the service, MessageToFile streams the entire
message into a file and sends a successful response.
BuildCFINDMessage
Once the user has input all the necessary data in ChooseModel and
GetLevelData, it is passed to this function. The proper message is then built
and returned so that the message can be sent by SendCFINDMessage.
BuildCMOVEMessage
Once the C-FIND responses have been received from the SCP the SCU can
begin to generate C-MOVE requests. Once a user indicates that they want a
particular Patient ID, Study Instance UID, Series Instance UID, or SOP Instance
to be moved this function creates the C-MOVE request.
43
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
ReadCFINDMessage
This function decodes a C-FIND response and places the data into a data
structure. This data is later used by PrintCFINDResults to be displayed to
the user.
CancelCMOVERQ
This routine simply sends a C-CANCEL-MOVE-RQ to the SCP to stop the MOVE
request that was started.
CancelCFINDRQ
This routine sends a C-CANCEL-FIND-RQ to the SCP to store the FIND that
request that was started.
SetValue
Simplifies the MC_Set_Value_From_String call since it takes care of all error
handling, default values, and required values.
GetValue
Simplifies the MC_Get_Value_To_String call since it takes care of all error
handling and default values.
EditQuery
EditQuery will, depending on the option you choose, allow you to edit the fields
of the root query by calling GetLevelData. After editing of the root level
information is complete, EditQuery will call CFINDOption which opens a new
association to the SCP. If the association negotiation finishes properly and
without any errors, SendCFINDMessage is called to send a DIMSE C-FIND
message to the SCP. The user now possesses the results of the C-FIND
command. EditQuery now calls CMOVEOption which calles
SendCMOVEMessage to construct the C-MOVE message and send it to the SCP.
Finally, MC_Close_Association is called to break the communication between
the processes.
GetLevelData
GetLevelData is used to modify the parameters of the query. It displays a user
interface that will allow the user to modify the fields of the query. The fields that
the user may edit depend on the model and the level of the query. When editing
is finished it returns the new information back so that it can be used in creating a
C-FIND message.
44
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
OKtoMove
Once the SCU receives all the C-FIND responses for the SCP this function lists
the data and allows the user to select the data to be moved.
SelectRecord
This function displays the C-FIND responses from a previous query and allows
the user to select a specific response for continuing the query to the next level.
PrintCFINDResults
Prints the results list from a query that was received from the SCP. It will print out
the fields that are relevant to the particular level that the query was done on. It
may prompt to select, move, continue, or quit a query.
MainMenu
Gives a user interface similar to what is seen in the scenario mentioned earlier.
NextMenu
Gives other user interface menus to allow changing from level to level and
continuing the search independently of what model is chosen.
ShowOptions
Shows the user a list of application configuration variables that may be modified
at run-time.
SetOptions
Allows the user to configure the program during runtime and change
communication options and time-outs.
ChangeAheadLevel
Changes the query level of the query after an instance is selected from the list
that was received from the SCP. It is transparent to the user that they have
changed to a different level of the query.
ChangeBackLevel
Changes the query level back to the root level of the current model. This
happens when querying is complete and it is desired to start over.
AddToList
Adds an element to the list of elements that were received in a query. This is an
extremely simple implementation of a list.
EmptyList
Empties the list of query results. This is an extremely simple implementation of a
list.
GetOptions
Takes care of all command line arguments given to the SCU, and sets the values
accordingly.
45
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
SetProgramDefaults
Takes care of the initialization of many variables that the SCU needs set before it
can start running. It is called to set the defaults before the command line
arguments are taken into consideration.
where options are described below. Please note that the above command
assumes that you are in the proper directory and that your MERGE_INI
environment variable has been set properly (or that your merge.ini file is stored in
the local directory from which you’re running the application).
The options supported by qr_scp are described in the following table.
46
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
47
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
HandleAssociation
The HandleAssociation function call processes a newly opened DICOM
association. It reads a message from the open association and processes it by
calling the appropriate processing routine: ProcessCFINDRQ,
ProcessCMOVERQ, or ProcessCSTORERQ. It returns QR_SUCCESS if the
function finishes properly or QR_FAILURE if it detects an error.
ProcessCFINDRQ
The ProcessCFINDRQ determines the query model being used and the query
level for the C-FIND-RQ it is processing. It then calls a number of routines that
search the internal database of the sample application and send matching
response messages back to the SCU.
ProcessCFINDRQ will call SearchDBPatientLevel, SearchDBStudyLevel,
SearchDBSeriesLevel, or SearchDBImageLevel to search the internal
database for matching information. These routines search the hierarchical data
structure to find the matching records at the appropriate query level. When the
routine has found a matching record, it calls SendCFINDReply to send the
actual C-FIND-RSP message back to the SCU.
Finally, after each response message has been sent back to the SCU, a final
response message with a status of C_FIND_SUCCESS is sent back to the SCU
signaling the end of the transaction. This is done through the
SendCFINDComplete function.
SendCFINDReply
SendCFINDReply is the routine that allocates, constructs and sends response
messages back to the SCU.
48
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
ProcessCMOVERQ
The ProcessCMOVERQ function is responsible for processing a DIMSE C-MOVE
request from the SCU. Because of implementation decisions, this routine was
designed to handle two open associations at the same time. The DICOM
standard states the C-STORE DIMSE service shall be implemented and executed
over a separate association than that of the C-MOVE. Thus, ProcessCMOVERQ
needs to handle two open associations at the same time.
Q/R SCP becomes Please note that although the SCP is a provider, at this point in the code, the
Store SCU! SCP turns into a C-STORE SCU.
ProcessCMOVERQ begins by calling MC_Open_Association to establish a
new association on which the C-STORE will be performed. It then loops through
the internal database to find matching image information to transfer. As each
match is found, the location of the matching DICOM Part 10 format file is
retrieved from the databases.
Once the file is known, the MC_Create_Empty_Message function is used to
create an empty file and MC_Open_File is used to read the file from disk and
place it into a Merge DICOM Toolkit file object. Before transferring over the
network, the file must be changed into a Merge DICOM Toolkit’s message
format, by calling MC_File_To_Message. The message is then sent back to
the SCU by calling MC_Send_Request_Message. The routine then waits for
the SCU to respond by calling MC_Read_Message with a -1 as the time-out
parameter. The -1 instructs the Merge DICOM Toolkit system to wait for a
message until one arrives. When a message arrives, the routine checks to be
sure it is a C_STORE_RSP. If it is, ProcessCMOVERQ makes sure the C-STORE
command completed successfully. It finally frees the message object and cleans
up the second association.
ProcessCompInstRootRetRQ
This function composes a response message based on frame level retrieve
request specified by COMPOSITE_INSTANCE_ROOT_RET_MOVE service. It
uses MC_Get_Frame_To_Function to retrieve frames from a multi frame image
and constructs a new SOP instance.
49
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
ProcessCSTORERQ
The ProcessCSTORERQ function is responsible for processing a DIMSE C-
STORE Request. The Storage SCU sample application, as described earlier in
this manual, can be used to send C-STORE Request messages to the SCP.
Note that the Application Profile (mergecom.app) may have to be updated for the
Storage SCU to communicate with the Query/Retrieve SCP. The default entry
for MERGE_QR_SCP in the Application Profile does not include Storage
Services in its service list. This service list may have to be updated to include
storage services. Note also that a different service list can be specified on the
command line of the Storage SCU to address this problem.
The ProcessCSTORERQ function first reads data needed for the SCP’s database
from the C-STORE-RQ message. This information includes tags that are needed
for later responding to C-FIND Request messages. ProcessCSTORERQ calls
the CreateDataFolder function for creating a folder to store the incoming
image. A folder structure is created based on the Study and Series Instance
UIDs contained in the C-STORE Request:
<Storage Folder>\<Study Instance UID>\<Series Instance UID>
The C-STORE Request is then stored as a DICOM Part 10 format file within the
created directory. The file name is the SOP Instance UID for the file with a
“.dcm” file extension. ProcessCSTORERQ calls WriteToMedia to write the
DICOM Part 10 format file. If writing this file to disk is successful,
ProcessCSTORERQ will insert information about the file into its internal data
structures, and send a subsequent C-STORE Response message back to the
Storage SCU application. Inserting into the internal data structures is done by
calling the InsertInstance function.
WriteToMedia
This function is called by ProcessCSTORERQ to save incoming C-STORE
Request messages as DICOM Part 10 format files. WriteToMedia calls Merge
DICOM Toolkit’s MC_Message_To_File to convert the incoming message into
Merge DICOM Toolkit’s file representation, it then adds the File Meta information
to the file through the use of the AddGroup2Elements function. Finally, it writes
the file to disk through the use of Merge DICOM Toolkit’s MC_Write_File
routine.
Other Functions
GetOptions
This function parses the command line options and sets the necessary program
variables. It takes care of all options that are given on the command line.
SetProgramDefaults
The default values for the program are set with this function. Every needed
program configuration variable is set to a default value. GetOptions is called
after SetProgramDefaults in order to change from default values to those
specified on the command line.
50
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
SearchDBPatientLevel
The internal database of the Query/Retrieve SCP application contains study,
series, and image records. The study records contain both study and patient
information. This routine performs a search through the list of study records and
finds records that match any search keys. Note that for a patient level search a
filter is used to ensure that duplicate patient records are not matched. It will then
call SendCFINDReply to send a response message for each matching record.
SearchDBStudyLevel
Performs a search of the Patient Level tags or the Study Level tags depending
on what request was for. The search is done through a list of study level records
stored in the application. It will then call SendCFINDReply to send a response
message for each matching record.
SearchDBSeriesLevel
Performs a search of the Series level tags that match the search criteria.
SearchDBSeriesLevel will search the list of Study records to find a matching
study. It will then search the list of series contained within the study to find a list
of records that match the search criteria in the C-FIND-RQ. It will then call
SendCFINDReply to send a response message for each matching record.
SearchDBImageLevel
Performs a search of the Image level tags that match the search criteria.
SearchDBImageLevel will search the list of Study records to find a matching
study. It will then search the list of series contained within the study to find a
matching series. It will then search the list of images within the found series for
records that match the search criteria in the C-FIND-RQ. It will then call
SendCFINDReply to send a response message for each matching record.
WildCardMatch
Performs a wildcard search as defined by DICOM. For a given tag, the search
value from a C-FIND Request and the corresponding tag’s value stored in the
internal database are passed to the routine. WildCardMatch will then check
these values to see if they match according to the wild card matching rules
defined in DICOM.
DateAndTimeMatch
Performs a Date or Time range search as defined by DICOM. For a given date
or time based tag, the search value from a C-FIND Request and the
corresponding tag’s value stored in the internal database are passed to the
routine. DateAndTimeMatch will then check these values to see if they match
according to the date and time range matching rules defined in DICOM.
InitDatabaseFromFolder
Performs a search of the configured storage folder looking for DICOM Part 10
format files. The GetFileList routine is used to traverse through the directory
and return a list of the files contained within the storage folder. These files are
then read into memory. GetDataFromMessage is used to retrieve patient,
study, series, and instance level information from the file. The data returned from
51
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
InsertInstance
InsertInstance performs an insert of information about a DICOM C-STORE
Request message into the internal data structures of the application. The routine
is used by both the ProcessCSTORERQ and InitDatabaseFromFolder
functions. The function traverses through the current internal database to see if
a Study, Series, or Instance level record already exists for the C-STORE Request
within the database. The routine will insert new information at the proper level
into the database as required.
52
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
The basic user-provider interaction scenario of the sample Q/R GET application
proceeds as follows. A more detailed description is given in the individual
program sections.
1. The SCU requests that the SCP perform a search on the information it
possesses. The SCU forms a message which contains a C-FIND request
and information pertaining to the data it would like the SCP to match.
2. The SCP searches through the data it possesses. It then generates
responses containing a unique key for each match it finds. The response
messages contain a PENDING command status and the information
which was requested by the SCU if the operation was successful.
Otherwise, a blank message is formed and an error status is returned to
the SCU. If no error exists, the SCP continues to send PENDING
response messages until the final match is found. The SCP then returns
SUCCESS.
3. The SCU receives each response message and interprets the status and
data. The SCU reads C-FIND responses from the SCP until a status of
SUCCESS is received.
4. The SCU then generates C-GET requests to the SCP by sending unique
key values to the SCP. The SCP reuses the original association with an
SCU and for each key value that the SCU sends to the SCP, the SCP
generates separate C-STORE operations to perform the actual move
from one place to another.
5. The SCP sends a response message with a status of PENDING to the
SCU during the processing of the C-STORE operation
6. When the C-STORE operation finishes, the SCP sends the SCU an
additional C-GET response message containing the final status of the
operation.
7. In addition, the SCU can generate a frame level retrieval by specifying a
list of frame numbers in a multi frame image. The SCP can handle a C-
GET request based on this frame level retrieval as specified by the SCU.
53
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
Note: The above command assumes that you are in the proper directory and
that your MERGE_INI environment variable has been set properly. Also
note that the listen port has to be changed in the mergecom.pro file of
the Q/R SCU to match the Q/R SCP’s port number found in the
mergecom.app file.
54
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
55
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
Note: The above command assumes that you are in the proper directory and
that your MERGE_INI environment variable has been set properly (or
that your merge.ini file is stored in the local directory from which you’re
running the application).
The implementation details for the Q/R GET SCP sample are covered in the
inline documentation of this sample.
Service Definition
The service definition can be broken down into the actions of Service Class
Users (SCU’s) and Service Class Providers (SCP’s). An SCU sends
information and requests to an SCP. In client/server terminology, the SCU’s role
is that of a client; the SCP’s role is that of a server. Now we will look more closely
at the behavior of SCUs and SCPs.
56
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
4. Table 13.
Table 11: Basic Film Session Service Class Status Response Codes
SUCCESS
FAILURE Unable to create Print Job SOP Instance; print queue is full
Image position collision : multiple images assigned to single
image position
Image size is larger than image box size (by using the specified
57
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
WARNING Film Box SOP Instance hierarchy does not contain Image Box
SOP Instances (empty page)
SUCCESS
SUCCESS
As can be seen from these simple descriptions of SCU and SCP behavior, Merge
DICOM Toolkit transparently handles the majority of the DICOM implementation
details. The sample application code described in this manual demonstrates how
to use the Merge DICOM Toolkit to implement SCUs and SCPs within the Basic
Print Service Classes.
Merge DICOM Toolkit Service SOP Class Name SOP Class UID
Name
58
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
Merge DICOM Toolkit Service SOP Class Name SOP Class UID
Name
Commands Supported
When an SCU or SCP implementing the DICOM Basic Print Service Classes
sends or receives a message, the following Merge DICOM Toolkit defined
commands will be used to encode the message:
N_CREATE_RQ
An SCU will use the N_CREATE_RQ command to create an instance of a SOP
Class object. An SCP will create the object requested in a received
N_CREATE_RQ message.
N_CREATE_RSP
An SCP will encode create response messages with the N_CREATE_RSP
command. An SCU will receive create response messages encoded with the
N_CREATE_RSP command.
N_SET_RQ
An SCU will use the N_SET_RQ command to update an instance of a SOP
Class object. An SCP will update the object requested in a received N_SET_RQ
message.
N_SET_RSP
An SCP will encode update response messages with the N_SET_RSP
command. An SCU will receive update response messages encoded with the
N_SET_RSP command.
59
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
N_GET_RQ
An SCU will use the N_GET_RQ command to get information from an instance of
a SOP Class object. An SCP will get information from the object requested in a
received N_GET_RQ message.
N_GET_RSP
An SCP will encode get response messages with the N_GET_RSP command.
An SCU will receive get response messages encoded with the N_GET_RSP
command.
N_DELETE_RQ
An SCU will use the N_DELETE_RQ command to delete an instance of a SOP
Class object. An SCP will delete the object requested in a received
N_DELETE_RQ message.
N_DELETE_RSP
An SCP will encode delete response messages with the N_DELETE_RSP
command. An SCU will receive delete response messages encoded with the
N_DELETE_RSP command.
N_ACTION_RQ
An SCU will use the N_ACTION_RQ command to create an instance of a SOP
Class object. An SCP will create the object requested in a received
N_ACTION_RQ message.
N_ACTION_RSP
An SCP will encode create response messages with the N_ACTION_RSP
command. An SCU will receive create response messages encoded with the
N_ACTION_RSP command.
N_EVENT_REPORT_RQ
An SCP will use the N_EVENT_REPORT_RQ command to report events related
to an instance of a SOP Class object. An SCU will receive the event report on the
object indicated in a received N_EVENT_REPORT_RQ message.
Note: The SCP is the originator of this message, not the SCU as in the other
messages.
N_EVENT_REPORT_RSP
An SCU will encode event report response messages with the
N_EVENT_REPORT_RSP command. An SCP will receive event report response
messages encoded with the N_EVENT_REPORT_RSP command.
60
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
Annotation Display Format (2010,0030) The use of this attribute is defined in the
ID printer's conformance statement.
61
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
>Pixel Aspect Ratio (0028,0034) Any pair of positive values (i.e. 1/1).
62
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
Note: The symbol '>' precedes the attribute name of the members of a
sequence of Items.
Note: Although Window Center and Window Width are optional in storage
objects, they are not included in the Preformatted Grayscale Image
Sequence.
Valid Messages
Valid DICOM messages are defined in terms of a normalized services and
commands. The file “message.txt”, which is included with your Merge DICOM
Toolkit, contains the DICOM message formats. Below is an excerpt from the
“message.txt” file for the BASIC_FILM_SESSION normalized service,
N_CREATE_RQ command. For instance, the example shows that attribute
(2000,0020) representing PRIORITY, with a CS value representation, is present
in this message and has three enumerated values: HIGH, MEDIUM, LOW.
===========================================================
=
Service Name: BASIC_FILM_SESSION
===========================================================
=
###########################################################
#
BASIC_FILM_SESSION - N_CREATE_RQ
###########################################################
#
63
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
Performance It should be noted that the use of MC_Validate_Message adversely affects the
Tuning application's performance. To improve application performance, the use of the
MC_Validate_Message function call should be limited in or omitted from the
application.
Configuration
Both the SCU and the SCP sample Basic Print Service Classes applications
require configuration files which define communication parameters, levels of
message logging, etc. Please see the “Configuration” section of the Merge
DICOM Toolkit User’s Manual for complete descriptions of the configuration files.
Some important points to remember for these sample applications are as follows:
SCU Configuration
• Since the sample SCU will be opening an association with the sample SCP,
there is a section for the SCP in the Application Profile (“mergecom.app”).
• You must change the HOST_NAME to be the host name of the machine on
which the SCP will be running.
64
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
SCP Configuration
• You should configure the TCPIP_LISTEN_PORT in the System Profile
(“mergecom.pro”) to an unused TCP/IP port. Make sure the PORT_NUMBER
in “mergecom.app” for MERGE_PRINT_SCP matches this value.
General Configuration
• Don’t forget to place the license number you received when you purchased
the toolkit into the [ASSOC_PARMS] section of the System Profile
(“mergecom.pro”).
Note: The sample Print Service Class programs are shipped with a single set
of configuration files: merge.ini, mergecom.app, mergecom.pro, and
mergecom.srv. After making the above changes, the configuration files
will be correct for use by either the SCU or SCP Print Service Class
sample programs.
Sample SCU
Overview of Program Operation
The sample SCU sends a variable number of images, a variable number of times
to a DICOM Basic Print SCP. These images must have been previously named
“1.img”, “2.img”, etc. The sample SCU is invoked with command line arguments
which determine the operation of the program. These arguments take the form:
prnt_scu -c [copies] -p [priority] -l [level]
[remote_application] [format] [start_image] [stop_image]
[loop_count]
Remote_app <none> This option specifies the TCP listening port that the
lication remote application is waiting for associations on.
65
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
Format <none> The image layout in the image box. For example, if
format would equal 2, two images would be
printed next to each other in the image box
Example:
prnt_scu -c 1 -p L -l B MERGE_PRINT_SCP 1 1 6 2
The general flow of the sample DICOM Basic Print SCU can be charted as in
Figure 6.
66
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
START
1
Validate Command
Line Arguments
2 Register Application
3 Open Empty
Message
5 Open Association
with SCP
8 Close Association
67
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
68
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
7. If there are outstanding print job instances, the application will wait for
N_EVENT_REPORT_RQ messages confirming the completion of all print
jobs before closing the application.
8. When the last image in the sequence has been sent, the application calls
MC_Close_Association to close the association with the SCP. The
loop count is then checked to determine if the sequence should be sent
again.
Sample SCP
Overview of Program Operation
The sample SCP handles associations and receives images from DICOM Basic
Print SCUs. The sample SCP is invoked as follows:
print_scp
The general flow of the sample DICOM Basic Print SCP can be charted as in
Figure 7.
Start
1
Validate Command
Line Arguments
2
Wait for an Association
3
Handle Association
69
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
70
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
Service Definition
The Modality Worklist Service Class is implemented using two applications: the
Service Class Provider (SCP) and the Service Class User (SCU). The SCP
accepts find requests from the SCU and performs searches using a simple
search algorithm to find the data specified in the find command. The SCP then
forms a response message that is then sent back to the SCU. The SCU then
receives the data that was found by the SCP.
Merge DICOM Toolkit Service SOP Class Name SOP Class UID
Name
Commands Supported
The SCP and SCU are implemented using the C-FIND DIMSE-C Service.
Also, this implementation of the Modality Worklist Service Class is intended as an
example. Only the baseline behavior has been implemented. The full behavior
has been left for the application developer.
71
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
Valid Messages
Valid DICOM messages are defined in terms of a composite service and
command. The file “message.txt”, which is included with your Merge DICOM
Toolkit, contains DICOM message formats. Below are excerpts from the
“message.txt” file.
#########################################################################
MODALITY_WORKLIST_FIND - C_FIND_RQ
#########################################################################
0008,0005 Specific Character Set CS 3
Defined Terms: ISO_IR 100, ISO_IR 101, ISO_IR 109, ISO_IR 110,
ISO_IR144, ISO_IR 127, ISO_IR 126, ISO_IR 138, ISO_IR 148
0008,0050 Accession Number SH 3
0008,0080 Institution Name LO 3
0008,0081 Institution Address ST 3
0008,0082 Institution Code Sequence SQ 3
Item Name(s): INSTITUTION_CODE
0008,0090 Referring Physician's Name PN 3
0008,0092 Referring Physician's Address ST 3
0008,0094 Referring Physician's Telephone Numbers SH 3
0008,1080 Admitting Diagnoses Description LO 3
0008,1084 Admitting Diagnosis Code Sequence SQ 3
Item Name(s): ADMITTING_DIAGNOSIS_CODE
0008,1110 Referenced Study Sequence SQ 3
Item Name(s): REF_STUDY
0008,1120 Referenced Patient Sequence SQ 3
Item Name(s): REF_PATIENT
0008,1125 Referenced Visit Sequence SQ 3
Item Name(s): REF_VISIT
0010,0010 Patient's Name PN 3
0010,0020 Patient ID LO 3
0010,0021 Issuer of Patient ID LO 3
0010,0030 Patient's Birth Date DA 3
0010,0032 Patient's Birth Time TM 3
0010,0040 Patient's Sex CS 3
Enumerated Values: M, F, O
#########################################################################
MODALITY_WORKLIST_FIND - C_FIND_RSP
#########################################################################
0008,0005 Specific Character Set CS 3
Defined Terms: ISO_IR 100, ISO_IR 101, ISO_IR 109, ISO_IR 110,
ISO_IR144,ISO_IR 127, ISO_IR 126, ISO_IR 138, ISO_IR 148
0008,0050 Accession Number SH 3
0008,0080 Institution Name LO 3
0008,0081 Institution Address ST 3
0008,0082 Institution Code Sequence SQ 3
Item Name(s): INSTITUTION_CODE
0008,0090 Referring Physician's Name PN 3
0008,0092 Referring Physician's Address ST 3
0008,0094 Referring Physician's Telephone Numbers SH 3
0008,1080 Admitting Diagnoses Description LO 3
0008,1084 Admitting Diagnosis Code Sequence SQ 3
Item Name(s): ADMITTING_DIAGNOSIS_CODE
0008,1110 Referenced Study Sequence SQ 3
Item Name(s): REF_STUDY
0008,1120 Referenced Patient Sequence SQ 3
Item Name(s): REF_PATIENT
0008,1125 Referenced Visit Sequence SQ 3
Item Name(s): REF_VISIT
0010,0010 Patient's Name PN 3
0010,0020 Patient ID LO 3
0010,0021 Issuer of Patient ID LO 3
72
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
73
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
3. The SCU receives each response message and interprets the status and
data. The SCU reads C-FIND responses from the SCP until a status of
SUCCESS is received, or the SCU receives more responses than it is
configured to handle. Should it receive more responses than it can
handle, the SCU sends a C_CANCEL request back to the SCU, and
continues with attempting to read responses.
4. The SCU then generates C-FIND requests to the SCP by sending
unique key values to the SCP. The SCP again formats response
PENDING and ultimately, SUCCESS messages, and sends them to the
SCU.
Configuration
Merge DICOM Toolkit Configuration information for the sample applications are
kept in configuration files. These files contain initialization and startup information
used by the sample applications as they execute. There are 4 different
configuration files necessary for execution by any one application. They are: the
Initialization file (referred to as "the dot ini file"), the Network Profile (referred to
as "the dot pro file"), the Application Profile (referred to as "the dot app file") and
the Service file (referred to as "the dot S-R-V file).
The configuration files follow the same format: a section starts with a label
delimited with square brackets. Each item belonging to a section is then listed.
The list is constructed of a variable followed by the equal sign (=) followed by the
value of the variable.
For a more detailed discussion of the configuration files distributed with the
DICOM Toolkit please see the files on the distribution itself and see the Merge
DICOM Toolkit Reference Manual. Each file is fully documented and explains
each item in detail.
74
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
Please note that the above command assumes that you are in the proper
directory and that your MERGE_INI environment variable has been set properly.
Also note that the listen port has to be changed in the mergecom.pro file for the
Modality Worklist SCU to match the Modality Worklist SCP’s port number.
The command line options supported by work_scu are described in the
following table.
Table 19: Optional command line parameters for the Modality Worklist SCU
-p PortNum This option specifies the TCP listening port that the
remote application is waiting for associations on.
==>
75
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
main
The main program begins by calling GetOptions to parse any command line
options. Next, the application is registered in Merge DICOM Toolkit by calling
PerformInitialization, which uses the Merge DICOM Toolkit library
functions to perform this task.
The main menu is displayed to the user. The user now enters the query data.
When finished with the data entry, the user can choose to perform a C-FIND.
Once the user chooses to construct the C-Find command, main calls
OpenAssociation in order to negotiate an association with the SCP. Main
then calls SetAndSendMsg to construct the C-FIND message and send it to the
SCP. After the C-FIND message is constructed and sent, main calls
ProcessReplyMsg to wait for the response messages from the SCP. After any
response messages are received and processed the initial association with the
SCP is closed. GatherMoreData is called to construct another C-FIND
message on a single patient, while opening another association with the SCP,
and closing that association when the second C-FIND has finished. Finally,
MC_Release_Application is called to release the application from the library,
once the user chooses to exit the program.
OpenAssociation
OpenAssociation is used to form an association with the Service Class
Provider. Its only purpose is to call MC_Open_Association.
OpenAssociation does, however, open the association using the passed in
command line parameters, if there were any specified.
SetAndSendMsg
SetAndSendMsg begins by opening a message. The message is constructed
from the data that the user entered via the user interface (main menu) and by
setting some of the other message parameters to the NULL value. Note that the
message sent to the SCP also contains a sequence of items. The sequence is
constructed by opening an item.
After the message has been created, it is sent to the SCP via a call to
MC_Send_Request_Message.
76
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
ProcessReplyMsg
ProcessReplyMessage processes a C-FIND response message. It begins by
attempting to read a message from the SCP. Once a message is obtained from
the SCP, it is examined to see if it is a PENDING message, or a
C_FIND_SUCCESS message. If the message is a C_FIND_SUCCESS message,
all of the “data” from the messages (if any) has been processed, and
ProcessReplyMsg can return to its caller.
SendCcancelRQ
The SendCcancelRQ function attempts to send a C_CANCEL_RQ message to
the SCP. This function is called when the SCU receives response messages,
greater in number than it is configured to accept. The threshold of messages is
configurable through the main menu of the SCU. Keep in mind the fact that the
SCP may still send a few messages after the SCU has sent the cancel request.
This may occur when the SCP isn’t able to process the cancel request in a timely
manner.
GatherMoreData
The GatherMoreData function works in a similar manner as the main menu. It
displays a list of patients and the patient ID that was obtained from the original C-
FIND request sent to the SCP. GatherMoreData starts by asking the user to
select a single patient from this list and then calls SetAndSendMsg and
ProcessReplyMsg again to perform another C-FIND request, followed by a wait
for a C-FIND reply from the server. This time, the SCP should provide a single
patient back to the SCU. The single patient data is displayed, and the user is
then able to return to the main function of the program.
77
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
where options are described below. Please note that the above command
assumes that you are in the proper directory and that your MERGE_INI
environment variable has been set properly.
The options supported by work_scp are described in the following table.
Table 20: Optional command line arguments for Modality Worklist SCP
main
The main program begins by setting all global options, parsing the command line
and printing a header message. Next, the application is registered in Merge
DICOM Toolkit by calling MC_Register_Application. This call provides
Merge DICOM Toolkit with the information necessary to identify the SCP from
other DICOM applications.
The SCP now goes into an "infinite" loop. Inside the loop, the SCP performs two
functions: it waits for an association to be received from the SCU, and while the
association is open, it waits for and replies to C-FIND request messages. The
SCP waits for an association by calling MC_Wait_For_Association. This
function is used to wait for another remote DICOM application to make a request
for service. The association is "broken" or "let go" by calling
MC_Close_Association. This function gracefully shuts down an open
association and releases any resources bound to that association. Note that in
multitasking environments, a “thread”, or a new process could be created to
handle the association activity.
78
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
ProcessCFINDRQ
The ProcessCFINDRQ is the function which performs most of the work for the
C-FIND command. ProcessCFINDRQ reads the query fields from the message
by calling MC_Get_Value_To_… for each of the fields.
After obtaining the information from the message, the function determines if there
is a match with any of the data the SCP possesses by calling
PerformWorkSearch. PerformWorkSearch is called in the following manner:
status = PerformWorkSearch ( SAE, station_ae, bIDarrayPS,
global_data_file );
SendCFINDReply
SendCFINDReply is the routine that allocates, constructs and sends the
response message back to the SCU.
SendCFINDReply begins by calling MC_Open_Message to obtain a new
message object. The object is opened to support MODALITY_WORKLIST_FIND
within the C-FIND Response object.
Next, the object is populated with data. This is done by calling the
MC_Set_Value… functions for each item the user has requested from the SCP.
Once the message has been populated, the reply message is sent off with a call
to MC_Send_Response_Message. The reply message is marked as a
PENDING reply. This process is repeated for each match found while querying
the data.
After each reply message is sent to the SCU, the SCU it polled to see if it has
sent any messages back to this SCP. In this implementation, the expected
message is a C_CANCEL_RQ message. As mentioned before, should the SCU
receive more responses than it can handle, it may sent a C_CANCEL_RQ
message to this SCP that needs to be handled. It the cancel message is waiting,
the processing loop that sends all of the reply messages back to the SCU is
exited.
Finally, after each response message has been sent back to the SCU or the
cancel message has been processed, a final response message with a status of
C_FIND_CANCEL_REQUEST_REVEIVED is sent back to the SCU signaling the
end of the transaction.
79
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
qr_util.c
This module contains the LogError function, as well as the linked list
manipulation functions. LogError is a general error logging function that is
used to report the Merge DICOM Toolkit error messages in a uniform manner to
the user. It can be used to report where the error has occurred, as well as define
a severity of the error that had occurred.
The linked list functions are a very simple implementation of a generic linked list.
By generic, it is meant that any data type, even user defined structures, can be
inserted into the linked list. The list is meant for only one purpose. The purpose
is to hold data in a sequential manner. There are currently eight functions that
are used to create, manipulate, and destroy the linked list objects.
This module also contains functions which are used by the Query / Retrieve
sample applications. Information on the use of any of these functions can be
obtained by examining the sample application manual that pertains to that
sample application.
In the case of the LogError and linked list functions, both of these will most
likely be replaced with the user’s own “in-house” functions. The purpose of these
functions is not to take the place of a user’s error logging and storage functions.
Service Definition
The service definition can be broken down into the operations summarized in the
following table.
Table 21: Media storage operations
80
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
81
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
Merge DICOM Toolkit Service SOP Class Name SOP Class UID
Command Pair
82
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
Merge DICOM Toolkit Service SOP Class Name SOP Class UID
Command Pair
83
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
Merge DICOM Toolkit Service SOP Class Name SOP Class UID
Command Pair
84
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
Merge DICOM Toolkit Service SOP Class Name SOP Class UID
Command Pair
Valid Messages
Valid DICOM messages are defined in terms of a composite service and
command. The file “message.txt”, which is included with your Merge DICOM
Toolkit, contains the DICOM message formats. Below is an excerpt from the
“message.txt” file for the STANDARD_CR composite service, C_STORE_RQ
command. For instance, the example shows that attribute 0008,0020
representing STUDY_DATE, with a DA value representation, is present in this
message.
##################################################################
STANDARD_CR - C_STORE_RQ
##################################################################
0008,0005 Specific Character set CS 1C
Condition: EXPANDED_OR_REPLACEMENT_CHARACTER_SET_USED
Defined Terms: ISO-IR 100, ISO-IR 101, ISO-IR 109, ISO-IR 110,
ISO-IR144, ISO-IR 127, ISO-IR 126, ISO-IR 138, ISO-IR 148
0008,0008 Image Type CS 3
Defined Terms: (ORIGINAL, DERIVED) (PRIMARY, SECONDARY)
0008,0012 Instance Creation Date DA 3
0008,0013 Instance Creation Time TM 3
0008,0014 Instance Creator UID UI 3
0008,0016 SOP Class UID UI 1
0008,0018 SOP Instance UID UI 1
0008,0020 Study Date DA 2
0008,0021 Series Date DA 3
0008,0022 Acquisition Date DA 3
85
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
Configuration
The FSU sample Media Storage Service Class application requires configuration
files which define communication parameters, levels of message logging, etc.
Please see the “Configuration” section of the Merge DICOM Toolkit User and
Reference Manuals for complete descriptions of the configuration files. Some
important points to remember for this sample application are as follows:
FSU Configuration
The Application Entity Title for the sample FSU is MERGE_MEDIA_FSU. This
Application Entity Title is hard programmed into the application itself.
You should configure the TCPIP_LISTEN_PORT in the System Profile
(“mergecom.pro”) to an unused TCP/IP port. This port number is used by the
Storage SCU application.
General Configuration
Don’t forget to place the license number you received when you purchased the
toolkit into the [ASSOC_PARMS] section of the System Profile (“mergecom.pro”).
Note: The sample Storage Service Class and Media Storage Service Class
programs are shipped with a single set of configuration files: merge.ini,
mergecom.app, mergecom.pro, and mergecom.srv.
Sample FSU
Overview of Program Operation
The sample FSU handles associations and receives images from Storage
Service Class SCUs. It will then place records of the images received within a
DICOMDIR. It also will read in an already existing DICOMDIR. The sample FSU
is invoked with command line arguments which determine where the DICOMDIR
file (File-set) is located. These arguments take the form:
med_fsu [-d <directory>]
86
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
-d is an optional parameter that specifies the directory in which to place the File-
set. Note that this directory can be the mount point of a file system.
The program also facilitates traversing the DICOMDIR and viewing directory
records based on the current record within the DICOMDIR tree structure. The
general flow of the sample Media Storage Service Class FSU can be charted as
in Figure 9. Each of the numbered steps is described below in greater detail:
1. The command line argument is checked for validity. The existence of a
DICOMDIR file within the current directory or in the directory specified by
the argument -d is checked.
3. The main process loops while waiting for a menu selection from the user.
4. Based on the user input, various actions are performed.
5. If the user selected to wait for an association, an association listener is
started.
6. When an association is received the code processes the C-STORE
requests.
7. For each C-STORE request the received instance is saved in a Part 10
file and new records that reference that instance are added to the
DICOMDIR file.
87
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
Start
1
Validate Command
Line Arguments and
check for DICOMDIR
2
Load in DICOMDIR
or intialize new
DICOMDIR
4 6
Handle User Input or Handle Association
Wait for Association
5
7
Wait for an Write Instance to
Association DICOMDIR and
Media
88
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
Configuration
The Duplicate Sample Application only requires general configuration since there
is no network communication.
General Configuration
Don’t forget to place the license number you received when you purchased the
toolkit into the [ASSOC_PARMS] section of the System Profile (“mergecom.pro”).
Note: The sample applications are shipped with a single set of configuration
files: merge.ini, mergecom.app, mergecom.pro, and mergecom.srv.
Sample Duplicate
Overview of Program Operation
The sample duplicate handles files or streams as input and creates a new file or
stream(<originalFileName>_out.<originalExtension>) of a different transfer
syntax. It can also "break out" multiple image files into separate image files. The
sample duplicate is invoked with command line arguments which determine what
is to be done with the input and output. These arguments take the form:
duplicate -f <filename> [-s <source format> -d <dest format> -v -b]
89
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
frame. The new file does not contain ANY DICOM tags or delimiters. It is strictly
the pixel data. Note, the full pixel data is still stored in the _out file. The "break
out" is in addition to the creation of the output. If the source format is the same
as dest format, this option will work on the source file.
The general flow of the sample duplicate can be charted as in Figure 10. Each of
the numbered steps is described below in greater detail:
1. The command line arguments are checked for validity. The source
format is checked for validity now, unless part 10 DICOM file.
2. A stream file is read into a message. A part 10 DICOM file is read from
file, transfer syntax checked for validity, and then is converted to a
message.
3. Check if the source format is the same as the destination. If it is not,
then proceed to step 4, otherwise go to step 7.
4. Callbacks must be registered for the source if the source message is
encapsulated. MC_Duplicate_Message will complain if we do not to this.
We will pass callbacks to MC_Duplicate_Message only if the destination
will be encapsulated. MC_Duplicate_Message automatically will register
these callbacks.
5. If we just created a new message with a lossy compression, the
message requires a new SOP Instance UID. A new SOP Instance UID
is REQUIRED when any part of a duplicated message is altered.
6. If the input was part 10 DICOM, then create the output file as part 10
DICOM. Otherwise, create a "stream" file.
7. If "break out" was selected as an option, get each image from the
message and store it in a separate file. If the transfer syntax is
JPEG_BASELINE or JPEG_EXTENDED_2_4, then the output will be of
the format <originalFileName>_frameX.jpg. If
JPEG_LOSSLESS_HIER_14, the extension is .ljp. These files will not
contain DICOM information or delimiters.
8. Clean up messages/files, and release library.
90
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
Start
1
Validate Command Line
Arguments and check
source format
2
Load in file. Convert it
to message if part 10
DICOM
3 not 4
Check if source format equal Possibly register source
equals destination compression callbacks,
format and duplicate
equal
7 5
If "breaking out", copy If lossy, set required
each image to separate attributes
file.
8 6
Clean up and terminate Create output file or
application stream
• MC_Set_Encapsulated_Value_From_Function
• MC_Get_Encapsulated_Value_To_Function
91
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
Note: This sample code uses hardcoded values for the MPEG image size as
512x512@fps to avoid parsing the MPEG header. The DICOM header
data is hardcoded as well.
Configuration
The MPEG Conversion Sample Application only requires general configuration
since there is no network communication.
General Configuration
Don’t forget to place the license number you received when you purchased the
toolkit into the [ASSOC_PARMS] section of the System Profile (“mergecom.pro”).
Note: The sample applications are shipped with a single set of configuration
files: merge.ini, mergecom.app, mergecom.pro, and mergecom.srv.
MPEG Conversion
Overview of Program Operation
The MPEG Conversion sample is invoked with command line arguments which
determine what is to be done with the input and output. These arguments take
the form:
mpeg2Dicom –p | -u <inputFile> <outputFile>
Configuration
The COMP Sample requires general standard Merge DICOM Toolkit
configuration and by default uses an evaluation copy of Accusoft's AIMTools™
compression/decompression toolkit.
92
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
Note: The sample applications are shipped with a single set of configuration
files: merge.ini, mergecom.app, mergecom.pro, and mergecom.srv.
As a result the sample will create in data folder a list of output compressed files
with various Transfer Syntax attributes.
Internally, the sample demonstrates how to use a set of callback function to
access a multi-frame pixel data using a callback technique.
1. The command line argument is checked for validity and displays a help
message in case of an error.
2. If a multi-frame input DICOM file was found, the sample loops through
various Transfer Syntax list and creates compressed DICOM files in a
data folder using MC_Duplicate_Message API.
5. Retrieves the offset table and multi-frame pixel data using API:
MC_Get_Encapsulated_Value_To_Function
MC_Get_Next_Encapsulated_Value_To_Function
MC_Get_Frame_To_Function
MC_Get_Offset_Table_To_Function
93
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
1. Implementation model
MERGE_STORE_SCU with Merge DICOM Toolkit input and output is, very
basically, an implementation of a DICOM Storage Service Class user (SCU)
which can send DICOM images to a DICOM Storage Service Class provider
(SCP).
L o c al R emo te
D IC O M S t an dard In t e rf ac e
94
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
2. AE specifications
MERGE_STORE_SCU, in conjunction with Merge DICOM Toolkit, provides
Standard Conformance to the following DICOM V3.0 Service Object Pair (SOP)
Classes as a Storage Service Class User (SCU).
Table A.1: Valid SCU Storage SOP Classes for MERGE_STORE_SCU
95
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
96
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
97
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
98
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
All these SOP classes conform to the standard Storage Services as specified in
the DICOM Standard.
3. Communication profiles
3.1 Supported Communication Stacks
MERGE_STORE_SCU, in conjunction with Merge DICOM Toolkit provides
DICOM V3.0 TCP/IP Network Communication Support as defined in PS 3.8.
99
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
4. Extensions/specializations/privatizations
4.1 Standard extended/specialized/private SOPs
None supported.
5. Configuration
The MERGE_STORE_SCU application references four configuration files. The
first, merge.ini, is found through the MERGE_INI environment variable. They are
as follows:
merge.ini Specifies the names of the other three configuration files
and also contains message logging parameters.
mergecom.pro Specifies run-time parameters for the
MERGE_STORE_SCU application.
mergecom.app Defines applications on other network nodes, to which
connections are possible.
mergecom.srv Service and sequence definitions.
Note: The host name maps to an IP address as specified by your host table.
100
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
1. Implementation model
MERGE_STORE_SCP with Merge DICOM Toolkit input and output is, very
basically, an implementation of a DICOM Storage Service Class provider (SCP)
which can receive DICOM images from a DICOM Storage Service Class
user (SCU).
Association Acceptance
DICOM Standard Interface
101
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
2. AE specifications
2.1 AE Specification for MERGE_STORE_SCP
MERGE_STORE_SCP with Merge DICOM Toolkit, provides Standard
Conformance to the following DICOM V3.0 Service Object Pair (SOP) Class as a
Verification Service Class Provider (SCP). As an SCP it sends out an Echo
response after it receives an Echo request from a remote AE.
Table B.1: Valid SCP Verification SOP Class for MERGE_STORE_SCP AE
102
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
103
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
104
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
105
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
106
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
107
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
ERROR Data Set does not match SOP A965 (0000,0901) contains a
Class - A required attribute is not listing of attribute tags
present in the message. The request missing.
was not processed.
(0000,0902) contains a
short description of the
condition.
108
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
When executing on a Big Endian machine, transfer syntaxes are accepted in the
following order:
3. Profiles
3.1 Supported Communication Stacks
MERGE_STORE_SCP, in conjunction with Merge DICOM Toolkit provides
DICOM V3.0 TCP/IP Network Communication Support as defined in PS 3.8.
4. Extensions/specializations/privatizations
4.1 Standard extended/specialized/private SOPs
None supported.
109
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
5. Configuration
5.1 MERGE_STORE_SCP Configuration files
The MERGE_STORE_SCP application references four configuration files. The
first, merge.ini, is found through the MERGE_INI environment variable. They are
as follows:
merge.ini Specifies the names of the other three configuration files and
also contains message logging parameters.
mergecom.pro Specifies run-time parameters for the MERGE_STORE_SCP
application.
mergecom.app Defines applications on other network nodes, to which
connections are possible.
mergecom.srv Service and sequence definitions.
110
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
1. Implementation Model
MERGE_QR_SCU with Merge DICOM Toolkit input and output is, very basically,
an implementation of a DICOM Query/Retrieve Service Class User (SCU) which
can send DICOM queries and move requests to a DICOM Storage Service Class
provider (SCP).
Association Initiation
Query/Retrieve
SCU FIN D
User query Remote Q/R
and retrieve. M OVE SCP
STORE
DICOM Standard
Interface
111
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
2. AE Specifications
2.1 AE specification for MERGE_QR_SCU
MERGE_QR_SCU, in conjunction with Merge DICOM Toolkit, provides Standard
Conformance to the following DICOM V3.0 Service Object Pair (SOP) Class as a
Query Retrieve Service Class User (SCU).
Table C.1: Valid SCP STORE SOP Classes for MERGE_QR_SCU AE
112
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
113
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
114
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
115
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
116
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
117
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
3. Profiles
3.1 Supported Communication Stacks
MERGE_QR_SCU, in conjunction with Merge DICOM Toolkit provides DICOM
V3.0 TCP/IP Network Communication Support as defined in PS 3.8.
4. Extensions/specializations/privatizations
4.1 Standard extended/specialized/private SOPs
None supported.
118
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
5. Configuration
5.1 MERGE_QR_SCU Configuration Files
The MERGE_QR_SCU applications references four configuration files. The first,
merge.ini, is found through the MERGE_INI environment variable. They are as
follows:
merge.ini Specifies the names of the other three configuration files and
also contains message logging parameters.
mergecom.pro Specifies run-time parameters for MERGE_QR_SCU
applications.
mergecom.app Defines applications on other network nodes, to which
connections are possible.
mergecom.srv Service and sequence definitions.
Note: The host name maps to an IP address as specified by your host table.
Also, port 104 should always be used for standard connectivity; since
this is the well-defined port for a DICOM server.
119
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
1. Implementation Model
MERGE_QR_SCP with Merge DICOM Toolkit input and output is, very basically,
an implementation of a DICOM Query/Retrieve Service Class Provider (SCP)
which can receive DICOM queries and move requests from a DICOM Storage
Service Class user (SCU). MERGE_QR_SCP responds to DICOM queries and
move requests based on DICOM Storage Service Class messages it has
received.
Association Initiation
Query/Retrieve FIN D
SCP
User Search, M OVE Remote Q/R
Select, M ove
SCU
from Remote
Storage STORE
STORE
DICOM Standard
Interface
120
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
responds with a list of SOP Class UIDs that it will accept. It then waits for an
Echo, Store, Find or Move request to determine what specific function it has to
perform. If an Echo is received, then an appropriate Echo response is sent back
to the initiator. If a Find request is received, then the archive is searched for the
requested information and a Find response is returned with all the found
information. If a Move request is received, it will initiate a transfer request of the
requested set of images to the desired location. If a Store request is received, it
will archive the Store request.
2. AE Specifications
2.1 AE specification for MERGE_QR_SCP
MERGE_QR_SCP, in conjunction with Merge DICOM Toolkit, provides Standard
Conformance to the following DICOM V3.0 Service Object Pair (SOP) Class as a
Verification Service Class User and Provider (SCU & SCP). As an SCP it sends
out an Echo response after it receives an Echo request from a remote AE.
Table D.1: Valid SCU/SCP Verification SOP Class for MERGE_QR_SCP AE
121
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
122
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
123
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
124
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
125
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
126
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
127
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
128
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
When executing on a Big Endian machine, transfer syntaxes are accepted in the
following order:
129
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
When executing on a Big Endian machine, transfer syntaxes are accepted in the
following order:
3. Profiles
3.1 Supported Communication Stacks
MERGE_QR_SCP, in conjunction with Merge DICOM Toolkit provides DICOM
V3.0 TCP/IP Network Communication Support as defined in PS 3.8.
4. Extensions/specializations/privatizations
4.1 Standard extended/specialized/private SOPs
None supported.
130
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
5. Configuration
5.1 MERGE_QR_SCP Configuration Files
The MERGE_QR_SCP applications references four configuration files. The first,
merge.ini, is found through the MERGE_INI environment variable. They are as
follows:
merge.ini Specifies the names of the other three configuration files
and also contains message logging parameters.
mergecom.pro Specifies run-time parameters for the MERGE_QR_SCP
applications.
mergecom.app Defines applications on other network nodes, to which
connections are possible.
mergecom.srv Service and sequence definitions.
Note: The host name maps to an IP address as specified by your host table.
Also, port 104 should always be used for standard connectivity; since
this is the well-defined port for a DICOM server.
131
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
1. Implementation model
MERGE_PRINT_SCU with Merge DICOM Toolkit input and output is, very
basically, an implementation of a DICOM Basic Print user (SCU) which can send
DICOM images to a DICOM Basic Print provider (SCP).
Format Association
printer via Acceptance
command Remote
line basic print
options SCP
Select
image(s) to
print via
command Remote
line options MERGE_PRINT_SCU basic print
job SCP
Accept
Printer and
Print Job
updates
DICOM Standard
Interface
Figure E.1: MERGE_PRINT_SCU application data flow diagram
132
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
2. AE specifications
2.1 AE Specification for MERGE_PRINT_SCU
MERGE_PRINT_SCU, in conjunction with Merge DICOM Toolkit, provides
Standard Conformance to the DICOM Basic Grayscale Print Management Meta
SOP class and Print Job SOP class as a DICOM Basic Print User (SCU).
Table E.1: Valid SOP Classes for MERGE_PRINT_SCU
133
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
134
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
135
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
136
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
Manufacturer * None
Manufacturer * None
Model Name
137
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
Originator * None
3. Profiles
3.1 Supported Communication Stacks
MERGE_PRINT_SCU, in conjunction with Merge DICOM Toolkit provides
DICOM V3.0 TCP/IP Network Communication Support as defined in PS 3.8.
4. Extensions/specializations/privatizations
4.1 Standard extended/specialized/private SOPs
None supported.
138
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
5. Configuration
5.1 MERGE_PRINT_SCU Configuration files
The MERGE_PRINT_SCU application references four configuration files. The
first, “merge.ini,” is found through the MERGE_INI environment variable. They
are as follows:
merge.ini Specifies the names of the other three configuration files and
also contains message logging parameters.
mergecom.pro Specifies run-time parameters for the MERGE_PRINT_SCU
application.
mergecom.app Defines applications on other network nodes, to which
connections are possible.
mergecom.srv Service and sequence definitions.
Note: The host name maps to an IP address as specified by your host table.
139
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
1. Implementation model
MERGE_PRINT_SCP with Merge DICOM Toolkit input and output is, very
basically, an implementation of a DICOM Basic Print provider (SCP) which can
receive DICOM images from a DICOM Basic Print user (SCU).
Local Remote
Association
Acceptance
Displays
Print Image Remote
data on Basic Print
Screen SCU
Reports MERGE_PRINT_SCP
Printer and Remote Basic
Print Job Print Job SCU
Status
DICOM Standard
Interface
140
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
2. AE specifications
2.1 AE Specification for MERGE_PRINT_SCP
2.1.1 Association Establishment Policies for
MERGE_PRINT_SCP AE
Not applicable.
2.1.1.1 General
The MERGE_PRINT_SCP application will wait for an association as an SCP of
Print Services. When a Print request is received, the corresponding image data is
printed to the screen. The maximum PDU size is configurable from a minimum of
4,096 bytes.
2.1.1.2 Number of associations
Under multi-tasking operating systems, the MERGE_PRINT_SCP AE allows
multiple simultaneous Print associations. The default number of associations is 5.
2.1.1.3 Asynchronous nature
The MERGE_PRINT_SCP AE does not support asynchronous communication
(multiple outstanding transactions over a single association).
2.1.1.4 Implementation Identifying information
The Implementation Class Unique Identifier (UID) for the MERGE_PRINT_SCP
Application Entity is:
2.16.840.1.113669.2.1.1 (place your Implementation Class UID here).
The Implementation Version Name for the MERGE_PRINT_SCP Application
Entity is:
MergeCOM3_222 (place your Implementation Version Name here).
141
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
142
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
143
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
144
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
145
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
Bits Allocated 8 8
Bit Stored 8 8
High Bit 7 7
Pixel 0000
Representation
146
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
147
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
When executing on a Big Endian machine, transfer syntaxes are accepted in the
following order:
3. Profiles
3.1 Supported Communication Stacks
MERGE_PRINT_SCP, in conjunction with Merge DICOM Toolkit provides
DICOM V3.0 TCP/IP Network Communication Support as defined in PS 3.8.
4. Extensions/specializations/privatizations
4.1 Standard extended/specialized/private SOPs
None supported.
5. Configuration
5.1 MERGE_PRINT_SCP Configuration Files
The MERGE_PRINT_SCP application references four configuration files. The
first, “merge.ini,” is found through the MERGE_INI environment variable. They
are as follows:
merge.ini Specifies the names of the other three configuration files and
also contains message logging parameters.
148
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
149
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
1. Implementation Model
MERGE_WORK_SCU with Merge DICOM Toolkit input and output is, very basically,
an implementation of a DICOM Modality Worklist Service Class User (SCU)
which can send DICOM queries to a DICOM Modality Worklist Service Class
provider (SCP).
Local Remote
Association Initiation
Modality
Worklist FIND
SCU Remote
User query Modality
Worklist SCP
Response
DICOM Standard
Interface
Figure G.1: Application data flow diagram for Modality Worklist SCU
150
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
2 AE Specifications
2.1 AE specification for MERGE_WORK_SCU
MERGE_WORK_SCU in conjunction with Merge DICOM Toolkit, provides Standard
Conformance to the following DICOM V3.0 Service Object Pair (SOP) Class as a
Modality Worklist Service Class User (SCU).
Table G.1: Valid SCU/SCP STORE SOP Classes for MERGE_WORK_SCU AE
151
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
152
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
3 Profiles
3.1 Supported Communication Stacks
MERGE_WORK_SCP, in conjunction with Merge DICOM Toolkit provides DICOM
V3.0 TCP/IP Network Communication Support as defined in PS 3.8.
4. Extensions/specializations/privatizations
4.1 Standard extended/specialized/private SOPs
None supported.
5. Configuration
5.1 MERGE_WORK_SCU AE Configuration Files
The MERGE_WORK_SCU applications references four configuration files. The first,
merge.ini, is found through the MERGE_INI environment variable. They are as
follows:
153
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
provider is specified by configuring the Listen Port in the mergecom.pro file, and
specifying the AE title for your SCP within the application itself.
Note: The host name maps to an IP address as specified by your host table.
Also, port 104 should always be used for standard connectivity; since
this is the well-defined port for a DICOM server.
154
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
1. Implementation Model
MERGE_WORK_SCP with Merge DICOM Toolkit input and output is, very basically,
an implementation of a DICOM Modality Worklist Service Class Provider (SCP)
which can receive DICOM queries from a DICOM Storage Service Class user
(SCU).
Local Remote
Association Initiation
Modality
Worklist Find
SCP Remote
User Search
Modality
Worklist SCU
Response
DICOM Standard
Interface
Figure H.1: Application Flow Diagram for Modality Worklist SCP
155
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
2 AE Specifications
2.1 AE specification for MERGE_WORK_SCP
MERGE_WORK_SCP in conjunction with Merge DICOM Toolkit, provides Standard
Conformance to the following DICOM V3.0 Service Object Pair (SOP) Class as a
Verification Service Class User and Provider (SCU & SCP). As an SCP it sends
out an Echo response after it receives an Echo request from a remote AE.
Table H.1: Valid SCU/SCP Verification SOP Class for MERGE_WORK_SCP AE
156
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
157
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
158
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
When executing on a Big Endian machine, transfer syntaxes are accepted in the
following order:
3. Profiles
3.1 Supported Communication Stacks
MERGE_WORK_SCP, in conjunction with Merge DICOM Toolkit provides
DICOM V3.0 TCP/IP Network Communication Support as defined in PS 3.8.
4. Extensions/specializations/privatizations
4.1 Standard extended/specialized/private SOPs
None supported.
5. Configuration
The MERGE_WORK_SCP application references four configuration files. The first,
merge.ini, is found through the MERGE_INI environment variable. They are as
follows:
merge.ini Specifies the names of the other three configuration
files and also contains message logging parameters.
mergecom.pro Specifies run-time parameters for the
MERGE_WORK_SCP application.
159
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
Note: The host name maps to an IP address as specified by your host table.
Also, port 104 should always be used for standard connectivity; since
this is the well-defined port for a DICOM server.
160
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
DICOM has been implemented by Merge Healthcare and is called Merge DICOM
Toolkit. Therefore, Merge DICOM Toolkit and DICOM can and are used
synonymously within this document.
1. Implementation Model
MERGE_MEDIA_FSU with Merge DICOM Toolkit input and output is, very
basically, an implementation of a DICOM File Set Updator (FSU) which can store
DICOM images to media with various DICOM SOP instances.
MERGE_MEDIA
Application STORE Remote Storage
Entity Service Class user
Association Acceptance
161
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
Display and
Update RWA
MERGE_MEDIA_FSU
DICOM Storage Application Entity
Medium
162
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
• It does not inquire the creation date and time of the files contained within the
File-set.
2. AE Specifications
Currently two DICOM application entities are present in the Merge media sample
application. The MERGE_MEDIA AE handles DICOM network services and the
MERGE_MEDIA_FSU handles DICOM media storage services.
All associations with the MERGE_MEDIA AE shall be established using the
DICOM 3.0 Application Context. A single DICOM Application Context Name is
defined for this version of the DICOM standard. The name is
“1.2.840.10008.3.1.1.1”.
163
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
164
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
165
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
166
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
167
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
ERROR Data Set does not match SOP A965 (0000,0901) contains a
Class - A required attribute is not listing of attribute tags
present in the message. The missing.
request was not processed.
(0000,0902) contains a
short description of the
condition.
When executing on a Big Endian machine, transfer syntaxes are accepted in the
following order:
168
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
3. Profiles
3.1 Supported Communication Stacks
MERGE_MEDIA_FSU, in conjunction with Merge DICOM Toolkit provides
DICOM V3.0 TCP/IP Network Communication Support as defined in PS 3.8.
169
C/C++ Sample Application Guide Merge DICOM ToolkitTM V. 5.11.0
5. Configuration
5.1 MERGE_MEDIA_FSU and MERGE_MEDIA Configuration
Files
The MERGE_MEDIA_FSU application references four configuration files. The
first, merge.ini, is found through the MERGE_INI environment variable. They are
as follows:
merge.ini Specifies the names of the other three configuration files
and also contains message logging parameters.
mergecom.pro Specifies run-time parameters for the
MERGE_MEDIA_FSU application.
mergecom.app Defines applications on other network nodes, to which are
possible.
mergecom.srv Service and sequence definitions.
The mergecom.pro configuration file can be used to set or modify other network
communication parameters. These parameters do not affect the media storage
class.
170
Merge DICOM ToolkitTM V. 5.11.0 C/C++ Sample Application Guide
171