1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358
|
/*
Copyright (C) 1993, 1994, RSNA and Washington University
The software and supporting documentation for the Radiological
Society of North America (RSNA) 1993, 1994 Digital Imaging and
Communications in Medicine (DICOM) Demonstration were developed
at the
Electronic Radiology Laboratory
Mallinckrodt Institute of Radiology
Washington University School of Medicine
510 S. Kingshighway Blvd.
St. Louis, MO 63110
as part of the 1993, 1994 DICOM Central Test Node project for, and
under contract with, the Radiological Society of North America.
THIS SOFTWARE IS MADE AVAILABLE, AS IS, AND NEITHER RSNA NOR
WASHINGTON UNIVERSITY MAKE ANY WARRANTY ABOUT THE SOFTWARE, ITS
PERFORMANCE, ITS MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR
USE, FREEDOM FROM ANY COMPUTER DISEASES OR ITS CONFORMITY TO ANY
SPECIFICATION. THE ENTIRE RISK AS TO QUALITY AND PERFORMANCE OF
THE SOFTWARE IS WITH THE USER.
Copyright of the software and supporting documentation is
jointly owned by RSNA and Washington University, and free access
is hereby granted as a license to use this software, copy this
software and prepare derivative works based upon this software.
However, any distribution of this software source code or
supporting documentation or derivative works (source code and
supporting documentation) must include the three paragraphs of
the copyright notice.
*/
/* Copyright marker. Copyright will be inserted above. Do not remove */
/*
** DINPACS 97
** Electronic Radiology Laboratory
** Mallinckrodt Institute of Radiology
** Washington University School of Medicine
**
** Module Name(s):
** Author, Date: Stephen Moore, 23-Mar-1993
** Intent: Handles DICOM N-Action requests as part of the image
** archive.
**
** Last Update: $Author: smm $, $Date: 2001-12-21 16:43:43 $
** Source File: $RCSfile: nevent.c,v $
** Revision: $Revision: 1.2 $
** Status: $State: Exp $
*/
static char rcsid[] = "$Revision: 1.2 $ $RCSfile: nevent.c,v $";
#include "ctn_os.h"
#if 0
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#endif
#include "dicom.h"
#include "condition.h"
#include "tbl.h"
#include "lst.h"
#include "dicom_uids.h"
#include "dulprotocol.h"
#include "dicom_objects.h"
#include "dicom_messages.h"
#include "dicom_services.h"
#include "tbl.h"
#include "manage.h"
#include "idb.h"
#include "fis.h"
#include "dicom_sq.h"
#include "storage_commit.h"
#include "nevent.h"
typedef struct {
char *abstractSyntax;
FIS_HANDLE **fis;
IDB_HANDLE **idb;
DUL_ASSOCIATESERVICEPARAMETERS *params;
} CALLBACK_CTX;
typedef struct {
DCM_TAG tag;
unsigned long flag;
} TAG_MAP;
#if 0
static CONDITION
insertWorkQueueRecord(FIS_HANDLE ** fis,
const char *transactionUID)
{
FIS_WORKQUEUERECORD workQueue;
CONDITION cond;
memset(&workQueue, 0, sizeof(workQueue));
workQueue.Type = FIS_K_WORKQUEUE;
workQueue.Flag = FIS_K_WORKQUEUE_TASNAM | FIS_K_WORKQUEUE_TASID;
strcpy(workQueue.TasNam, FIS_WQ_STORAGECOMMIT);
strcpy(workQueue.TasID, transactionUID);
cond = FIS_Insert(fis, FIS_K_WORKQUEUE, &workQueue);
if (cond != FIS_NORMAL)
return 0;
else
return APP_NORMAL;
}
#endif
static CONDITION
storageCommitmentRequest(MSG_N_EVENT_REPORT_REQ * request,
MSG_N_EVENT_REPORT_RESP * response,
CALLBACK_CTX * ctx)
{
CONDITION cond;
static FIS_STORAGECOMMITREQRECORD storageCommit;
long flag;
response->dataSetType = DCM_CMDDATANULL;
strcpy(response->classUID, request->classUID);
strcpy(response->affectedInstanceUID, request->affectedInstanceUID);
response->conditionalFields = MSG_K_N_EVENTREPORTRESP_REQUESTEDINSTANCEUID;
response->status = MSG_K_SUCCESS;
if (request->dataSetType != DCM_CMDDATANULL) {
(void) DCM_DumpElements(&request->dataSet, 0);
} else {
response->status = MSG_K_PROCESSINGFAILURE;
goto ExitPoint;
}
memset(&storageCommit, 0, sizeof(storageCommit));
storageCommit.Type = FIS_K_STORAGECOMMITREQ;
{
DCM_ELEMENT e = {DCM_IDTRANSACTIONUID, DCM_UI, "", 1,
sizeof(storageCommit.TraUID),
(void *) storageCommit.TraUID};
cond = DCM_ParseObject(&request->dataSet, &e, 1, NULL, 0, NULL);
if (cond != DCM_NORMAL) {
response->status = MSG_K_PROCESSINGFAILURE;
goto ExitPoint;
}
}
/* First look for the successes. There may not be any */
{
LST_HEAD *l;
DCM_ELEMENT e;
SQ_TYPE type;
SQ_REFERENCEDSOPSEQUENCE *ref;
e.tag = DCM_IDREFERENCEDSOPSEQUENCE;
l = LST_Create();
cond = DCM_GetSequenceList(&request->dataSet,
e.tag, &e.d.sq);
if (cond == DCM_NORMAL) {
cond = SQ_ParseSequence(&e, &type, &l);
if (cond != SQ_NORMAL) {
response->status = MSG_K_PROCESSINGFAILURE;
goto ExitPoint;
}
printf("Transaction UID: %s\n SOP Instances committed: %d\n",
storageCommit.TraUID,
LST_Count(&l));
ref = LST_Head(&l);
LST_Position(&l, ref);
while (ref != NULL) {
FIS_COMMITSOPREFRECORD sopReference;
memset(&sopReference, 0, sizeof(sopReference));
sopReference.Type = FIS_K_COMMITSOPREF;
strcpy(sopReference.TraUID, storageCommit.TraUID);
strcpy(sopReference.SOPClaUID, ref->referencedSOPClassUID);
strcpy(sopReference.SOPInsUID, ref->referencedSOPInstanceUID);
ref = LST_Next(&l);
}
} else if (cond == DCM_ELEMENTNOTFOUND) {
(void) COND_PopCondition(FALSE);
} else {
response->status = MSG_K_PROCESSINGFAILURE;
goto ExitPoint;
}
}
/* Now look for the failures. There may not be any */
{
LST_HEAD *l;
DCM_ELEMENT e;
SQ_TYPE type;
SQ_FAILEDSOPSEQUENCE *ref;
e.tag = DCM_IDFAILEDSOPSEQUENCE;
l = LST_Create();
cond = DCM_GetSequenceList(&request->dataSet,
e.tag, &e.d.sq);
if (cond == DCM_NORMAL) {
cond = SQ_ParseSequence(&e, &type, &l);
if (cond != SQ_NORMAL) {
response->status = MSG_K_PROCESSINGFAILURE;
goto ExitPoint;
}
printf("Transaction UID: %s\n SOP Instances failed: %d\n",
storageCommit.TraUID,
LST_Count(&l));
ref = LST_Head(&l);
LST_Position(&l, ref);
while (ref != NULL) {
FIS_COMMITSOPREFRECORD sopReference;
memset(&sopReference, 0, sizeof(sopReference));
sopReference.Type = FIS_K_COMMITSOPREF;
strcpy(sopReference.TraUID, storageCommit.TraUID);
strcpy(sopReference.SOPClaUID, ref->referencedSOPClassUID);
strcpy(sopReference.SOPInsUID, ref->referencedSOPInstanceUID);
ref = LST_Next(&l);
}
} else if (cond == DCM_ELEMENTNOTFOUND) {
(void) COND_PopCondition(FALSE);
} else {
response->status = MSG_K_PROCESSINGFAILURE;
goto ExitPoint;
}
}
UTL_GetDicomDate(storageCommit.ResDat);
UTL_GetDicomTime(storageCommit.ResTim);
storageCommit.Flag = FIS_K_SCOMMIT_RESDAT | FIS_K_SCOMMIT_RESTIM;
cond = FIS_Update(ctx->fis, FIS_K_STORAGECOMMITREQ, &storageCommit);
if (cond != FIS_NORMAL) {
response->status = MSG_K_PROCESSINGFAILURE;
COND_DumpConditions();
goto ExitPoint;
}
ExitPoint:
COND_DumpConditions();
return 1;
}
/* neventReportRequestCallback
**
** Purpose:
**
** Parameter Dictionary:
**
** Return Values:
**
** SRV_NORMAL
**
** Algorithm:
** Description of the algorithm (optional) and any other notes.
*/
static CONDITION
neventReportRequestCallback(MSG_N_EVENT_REPORT_REQ * request,
MSG_N_EVENT_REPORT_RESP * response,
void *ctxPtr, DUL_PRESENTATIONCONTEXT * pc)
{
CONDITION cond = 0;
/* Following definition and assignment satisfy prototypes for dicom_services.h*/
CALLBACK_CTX *ctx;
ctx = (CALLBACK_CTX *) ctxPtr;
strcpy(response->classUID, request->classUID);
response->messageIDRespondedTo = request->messageID;
if (strcmp(ctx->abstractSyntax, DICOM_SOPCLASSSTORAGECOMMITMENTPUSHMODEL) == 0) {
cond = storageCommitmentRequest(request, response, ctx);
} else
return SRV_UNSUPPORTEDSERVICE;
if (cond == 1)
return SRV_NORMAL;
else
return 0;
}
#if 0
static void
addToSuccesses(FIS_COMMITSOPREFRECORD * sopRefRecord,
LST_HEAD ** successes)
{
SQ_REFERENCEDSOPSEQUENCE *sq;
sq = calloc(1, sizeof(*sq));
sq->type = SQ_K_REFERENCEDSOPSEQUENCE;
strcpy(sq->referencedSOPClassUID, sopRefRecord->SOPClaUID);
strcpy(sq->referencedSOPInstanceUID, sopRefRecord->SOPInsUID);
LST_Enqueue(successes, sq);
}
static void
addToFailures(FIS_COMMITSOPREFRECORD * sopRefRecord,
LST_HEAD ** failures)
{
SQ_FAILEDSOPSEQUENCE *failedSOPSeq;
failedSOPSeq = calloc(1, sizeof(*failedSOPSeq));
failedSOPSeq->type = SQ_K_FAILEDSOPSEQUENCE;
strcpy(failedSOPSeq->referencedSOPClassUID, sopRefRecord->SOPClaUID);
strcpy(failedSOPSeq->referencedSOPInstanceUID, sopRefRecord->SOPInsUID);
LST_Enqueue(failures, failedSOPSeq);
}
#endif
/* Entry points for public functions start here.
*/
/* neventReportRequest
**
*/
CONDITION
neventReportRequest(DUL_ASSOCIATESERVICEPARAMETERS * params,
DUL_ASSOCIATIONKEY ** association, DMAN_HANDLE ** dman,
DUL_PRESENTATIONCONTEXT * ctx, MSG_N_EVENT_REPORT_REQ ** request,
FIS_HANDLE ** fis)
{
MSG_N_EVENT_REPORT_RESP response;
CONDITION cond;
CALLBACK_CTX cb;
memset(&response, 0, sizeof(response));
response.type = MSG_K_N_EVENT_REPORT_RESP;
response.conditionalFields = 0;
response.dataSetType = DCM_CMDDATANULL;
cb.abstractSyntax = ctx->abstractSyntax;
cb.fis = fis;
cb.idb = NULL;
cb.params = params;
(void) MSG_DumpMessage(*request, stdout);
cond = SRV_NEventReportResponse(association, ctx, request, &response,
neventReportRequestCallback, &cb, "");
if (cond != SRV_NORMAL)
return 0;
return APP_NORMAL;
}
|