Hi,
here is code that uses DcmSCU and does the following:
Negotiating Verification (echo), as well as FIND (query) and MOVE (retrieve) SOP Classes with the PACS. Then, send ECHO, send FIND and retrieve all studies that were found within the FIND step by sending a MOVE for each study. Then, release the association.
Best regards,
Michael
Code:
/*
*
* Copyright (C) 2011, OFFIS e.V.
* All rights reserved. See COPYRIGHT file for details.
*
* This software and supporting documentation were developed by
*
* OFFIS e.V.
* R&D Division Health
* Escherweg 2
* D-26121 Oldenburg, Germany
*
*
* Module: dcmnet
*
* Author: Michael Onken
*
* Purpose: Test for move feature of the DcmSCU class
*
* Last Update: $Author: joergr $
* Update Date: $Date: 2011-03-17 09:46:02 $
* CVS/RCS Revision: $Revision: 1.54 $
* Status: $State: Exp $
*
* CVS/RCS Log at end of file
*
*/
#include "dcmtk/config/osconfig.h" /* make sure OS specific configuration is included first */
#include "dcmtk/dcmnet/testscu.h"
#include "dcmtk/dcmnet/diutil.h"
#define OFFIS_CONSOLE_APPLICATION "testscu"
static OFLogger echoscuLogger = OFLog::getLogger("dcmtk.apps." OFFIS_CONSOLE_APPLICATION);
static char rcsid[] = "$dcmtk: " OFFIS_CONSOLE_APPLICATION " v"
OFFIS_DCMTK_VERSION " " OFFIS_DCMTK_RELEASEDATE " $";
// our application entity title used for calling the peer machine
#define APPLICATIONTITLE "TEST-SCU"
// host name of the peer machine
#define PEERHOSTNAME "www.dicomserver.co.uk"
// TCP/IP port to connect to on peer machine
#define PEERPORT 11112
// application entity title of the peer machine
#define PEERAPPLICATIONTITLE "MOVESCP"
// MOVE target AE Title
#define MOVEAPPLICATIONTITLE "TEST-SCU"
static Uint8 findUncompressedPC(const OFString& sopClass,
DcmSCU& scu)
{
Uint8 pc;
pc = scu.findPresentationContextID(sopClass, UID_LittleEndianExplicitTransferSyntax);
if (pc == 0)
scu.findPresentationContextID(sopClass, UID_BigEndianExplicitTransferSyntax);
if (pc == 0)
scu.findPresentationContextID(sopClass, UID_LittleEndianImplicitTransferSyntax);
return pc;
}
// ********************************************
int main(int argc, char *argv[])
{
/* Setup DICOM connection parameters */
OFLog::configure(OFLogger::DEBUG_LOG_LEVEL);
DcmTestSCU scu;
// set AE titles
scu.setAETitle(APPLICATIONTITLE);
scu.setPeerHostName(PEERHOSTNAME);
scu.setPeerPort(PEERPORT);
scu.setPeerAETitle(PEERAPPLICATIONTITLE);
// Use presentation context for FIND/MOVE in study root, propose all uncompressed transfer syntaxes
OFList<OFString> ts;
ts.push_back(UID_LittleEndianExplicitTransferSyntax);
ts.push_back(UID_BigEndianExplicitTransferSyntax);
ts.push_back(UID_LittleEndianImplicitTransferSyntax);
scu.addPresentationContext(UID_FINDStudyRootQueryRetrieveInformationModel, ts);
scu.addPresentationContext(UID_MOVEStudyRootQueryRetrieveInformationModel, ts);
scu.addPresentationContext(UID_VerificationSOPClass, ts);
/* Initialize network */
OFCondition result = scu.initNetwork();
if (result.bad())
{
DCMNET_ERROR("Unable to set up the network: " << result.text());
return 1;
}
/* Negotiate Association */
result = scu.negotiateAssociation();
if (result.bad())
{
DCMNET_ERROR("Unable to negotiate association: " << result.text());
return 1;
}
/* Let's look whether the server is listening:
Assemble and send C-ECHO request
*/
result = scu.sendECHORequest(0);
if (result.bad())
{
DCMNET_ERROR("Could not process C-ECHO with the server: " << result.text());
return 1;
}
/* Assemble and send C-FIND request */
FINDResponses findResponses;
DcmDataset req;
req.putAndInsertOFStringArray(DCM_QueryRetrieveLevel, "STUDY");
req.putAndInsertOFStringArray(DCM_StudyInstanceUID, "");
T_ASC_PresentationContextID presID = findUncompressedPC(UID_FINDStudyRootQueryRetrieveInformationModel, scu);
if (presID == 0)
{
DCMNET_ERROR("There is no uncompressed presentation context for Study Root FIND");
return 1;
}
result = scu.sendFINDRequest(presID, &req, &findResponses);
if (result.bad())
return 1;
else
DCMNET_INFO("There are " << findResponses.numResults() << " studies available");
/* Assemble and send C-MOVE request, for each study identified above*/
presID = findUncompressedPC(UID_MOVEStudyRootQueryRetrieveInformationModel, scu);
if (presID == 0)
{
DCMNET_ERROR("There is no uncompressed presentation context for Study Root MOVE");
return 1;
}
OFListIterator(FINDResponse*) study = findResponses.begin();
Uint32 studyCount = 1;
OFBool failed = OFFalse;
while (study != findResponses.end() && result.good())
{
// Every loop run will get all image for a specific study
MOVEResponses moveResponses;
// be sure we are not in the last response which does not have a dataset
if ( (*study)->m_dataset != NULL)
{
OFString studyInstanceUID;
result = (*study)->m_dataset->findAndGetOFStringArray(DCM_StudyInstanceUID, studyInstanceUID);
// only try to get study if we actually have study instance uid, otherwise skip it
if (result.good())
{
req.putAndInsertOFStringArray(DCM_StudyInstanceUID, studyInstanceUID);
// fetches all images of this particular study
result = scu.sendMOVERequest(presID, MOVEAPPLICATIONTITLE, &req, &moveResponses);
if (result.good())
{
DCMNET_INFO("Received study #" << std::setw(7) << studyCount << ": " << studyInstanceUID);
studyCount++;
}
}
}
study++;
}
if (result.bad())
{
DCMNET_ERROR("Unable to retrieve all studies: " << result.text());
}
/* Release association */
scu.closeAssociation(DCMSCU_RELEASE_ASSOCIATION);
return 0;
}
P.S: The header file would be trivial:
Code:
#ifndef TESTSCU_H
#define TESTSCU_H
#include "dcmtk/config/osconfig.h" /* make sure OS specific configuration is included first */
#include "dcmtk/dcmnet/scu.h" /* Covers most common dcmdata classes */
class DcmTestSCU : public DcmSCU
{
public:
DcmTestSCU() {}
~DcmTestSCU() {}
};
#endif // TESTSCU_H
相关推荐
### DCMTK的生成及加载和一些使用的例子 #### 一、DCMTK简介与功能 DCMTK是由德国OFFIS公司提供的一款开源项目,它主要用于实现DICOM(Digital Imaging and Communications in Medicine)协议,该协议是医疗成像...
专栏博文“DICOM:基于DCMTK实现C-FIND SCU”中对应的源代码。基于dcmtk开源库中的findscu工程,实现的简单的C-FIND SCU,用于示范如何使用dcmtk操作实现具体的DICOM应用。
DCMTK(DICOM Toolkit)是一个开源软件库,它提供了处理DICOM数据所需的工具和API,使得开发者能够创建与DICOM兼容的应用程序。本压缩包“dicom.rar”包含了DCMTK的版本3.6.0,这是一个广泛使用的版本,适用于医疗...
**Windows Qt环境下的DCMTK库** DCMTK(DICOM Toolkit)是一个开源软件库,专为处理DICOM(Digital Imaging and Communications in Medicine)标准而设计。DICOM是医学成像领域广泛使用的通信协议和数据格式标准。...
dcmtk使用手册,医学领域的东东,有学习的可以下载看看,没学过,不知道好不好学
DCMTK(Digital Imaging and Communications in Medicine Toolkit)是开源软件库,主要用于开发医学影像通信标准(DICOM)的软件。这个3.6.0版本的官方帮助文档是开发者和使用者理解DCMTK的重要资源,提供了详尽的...
DCMTK(DICOM ToolKit)是一个开源的C++库,专门用于处理DICOM(Digital Imaging and Communications in Medicine)标准的医学图像数据。DICOM是医疗影像设备之间交换数据的标准格式,广泛应用于医疗成像领域,如CT...
DCMTK(DICOM ToolKit)是一套开源的软件库,专门用于开发处理DICOM(Digital Imaging and Communications in Medicine)标准的应用程序。DICOM是一种广泛应用于医疗成像领域的国际标准,它定义了医学图像和相关数据...
DCMTK攻略 DCMTK(DICOM Toolkit)是德国Offis公司开发的开源项目,旨在提供一个实现DICOM协议的平台,为开发者提供了一个便捷的开发环境。DCMTK提供了所有的源代码、支持库和帮助文档,支持多种操作系统,包括...
DCMTK 新手使用指南 DCMTK 是一个 DICOM 工具包,提供了 DICOM 协议的实现和DICOM 文件处理功能。作为新手,使用 DCMTK 可能会遇到很多疑惑之处。本文总结了 DCMTK 新手使用指南,旨在帮助大家快速上手 PACS 事业。...
### DCMTK调试攻略——vc6.0中DCMTK环境搭建 #### 一、前言 DCMTK(Digital Imaging and Communications in Medicine ToolKit)是DICOM标准的一个开源实现库,广泛应用于医疗图像处理领域。对于刚接触DCMTK的新手...
**Linux系统下的DCMTK-3.6.0详解** DCMTK(DICOM Toolkit)是一套开源的软件库和工具集,专为处理DICOM(Digital Imaging and Communications in Medicine)标准而设计,广泛应用于医学图像通信、医学影像处理和...
DCMTK(Digital Imaging and Communications in Medicine Toolkit)是一款开源的医学图像处理库,主要用于医疗影像数据的处理、传输和解析。这个压缩包提供的是已经针对Windows 10操作系统编译好的DCMTK工具集,意味...
DCMTK库是一个开源的医学图像处理工具包,主要用于DICOM(Digital Imaging and Communications in Medicine)标准的实现。DICOM是医疗领域广泛采用的数据交换、存储和通信的标准格式。DCMTK库提供了丰富的API,可以...
DCMTK(DICOM ToolKit)是一个开源软件库,专门用于处理医学图像数据,符合DICOM(Digital Imaging and Communications in Medicine)标准。该标准定义了医学影像设备之间的通信协议、数据格式以及存储和交换的方式...
DCMTK,全称为"Digital Imaging and Communications in Medicine - Toolkit",是一个开源软件工具包,专为处理DICOM(Digital Imaging and Communications in Medicine)标准而设计。DICOM是一种广泛应用于医疗影像...
【标题】"基于DCMTK的DICOM图像查看器"是一个专门为医学图像处理设计的应用程序,它利用了开源的DCMTK库来实现对DICOM格式图像的读取、显示和解析。DICOM(Digital Imaging and Communications in Medicine)是医疗...
DCMTK(DICOM Medical Connectivity Toolkit)是一款开源的C++库,主要用于处理DICOM(Digital Imaging and Communications in Medicine)标准的医学图像数据。这个“dcmtk-3.6.5-win64已编译工具包”是专为64位...
DCMTK(Digital Imaging and Communications in Medicine - Toolkit)是一套开源的软件工具包,主要用于开发医学影像处理和通信的应用程序。这个工具集是基于DICOM(Digital Imaging and Communications in Medicine...
**DCMTK编译安装详解** DCMTK(DICOM Toolkit)是一个开源的C++类库,用于处理DICOM(Digital Imaging and Communications in Medicine)标准的医学图像和数据。本教程将详细介绍如何在CentOS环境下编译并安装DCMTK...