Mercurial > hg > orthanc
diff Core/DicomNetworking/Internals/CommandDispatcher.cpp @ 3736:0540b54324f1 storage-commitment
StorageCommitmentReports
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 10 Mar 2020 17:43:49 +0100 |
parents | 56f2397f027a |
children | c6658187e4b1 |
line wrap: on
line diff
--- a/Core/DicomNetworking/Internals/CommandDispatcher.cpp Tue Mar 10 13:59:14 2020 +0100 +++ b/Core/DicomNetworking/Internals/CommandDispatcher.cpp Tue Mar 10 17:43:49 2020 +0100 @@ -928,15 +928,22 @@ } - static void ReadSopSequence(std::vector<std::string>& sopClassUids, - std::vector<std::string>& sopInstanceUids, - DcmDataset& dataset, - const DcmTagKey& tag, - bool mandatory) + static void ReadSopSequence( + std::vector<std::string>& sopClassUids, + std::vector<std::string>& sopInstanceUids, + std::vector<StorageCommitmentFailureReason>* failureReasons, // Can be NULL + DcmDataset& dataset, + const DcmTagKey& tag, + bool mandatory) { sopClassUids.clear(); sopInstanceUids.clear(); + if (failureReasons) + { + failureReasons->clear(); + } + DcmSequenceOfItems* sequence = NULL; if (!dataset.findAndGetSequence(tag, sequence).good() || sequence == NULL) @@ -957,6 +964,11 @@ sopClassUids.reserve(sequence->card()); sopInstanceUids.reserve(sequence->card()); + if (failureReasons) + { + failureReasons->reserve(sequence->card()); + } + for (unsigned long i = 0; i < sequence->card(); i++) { const char* a = NULL; @@ -968,11 +980,24 @@ { throw OrthancException(ErrorCode_NetworkProtocol, "Missing Referenced SOP Class/Instance UID " - "in storage commitment request"); + "in storage commitment dataset"); } sopClassUids.push_back(a); sopInstanceUids.push_back(b); + + if (failureReasons != NULL) + { + Uint16 reason; + if (!sequence->getItem(i)->findAndGetUint16(DCM_FailureReason, reason).good()) + { + throw OrthancException(ErrorCode_NetworkProtocol, + "Missing Failure Reason (0008,1197) " + "in storage commitment dataset"); + } + + failureReasons->push_back(static_cast<StorageCommitmentFailureReason>(reason)); + } } } @@ -1034,7 +1059,7 @@ std::string transactionUid = ReadString(*dataset, DCM_TransactionUID); std::vector<std::string> sopClassUid, sopInstanceUid; - ReadSopSequence(sopClassUid, sopInstanceUid, + ReadSopSequence(sopClassUid, sopInstanceUid, NULL, *dataset, DCM_ReferencedSOPSequence, true /* mandatory */); LOG(INFO) << "Incoming storage commitment request, with transaction UID: " << transactionUid; @@ -1157,15 +1182,16 @@ std::string transactionUid = ReadString(*dataset, DCM_TransactionUID); std::vector<std::string> successSopClassUid, successSopInstanceUid; - ReadSopSequence(successSopClassUid, successSopInstanceUid, + ReadSopSequence(successSopClassUid, successSopInstanceUid, NULL, *dataset, DCM_ReferencedSOPSequence, (report.EventTypeID == 1) /* mandatory in the case of success */); std::vector<std::string> failedSopClassUid, failedSopInstanceUid; + std::vector<StorageCommitmentFailureReason> failureReasons; if (report.EventTypeID == 2 /* failures exist */) { - ReadSopSequence(failedSopClassUid, failedSopInstanceUid, + ReadSopSequence(failedSopClassUid, failedSopInstanceUid, &failureReasons, *dataset, DCM_FailedSOPSequence, true); } @@ -1200,7 +1226,7 @@ ConstructStorageCommitmentRequestHandler()); handler->HandleReport(transactionUid, successSopClassUid, successSopInstanceUid, - failedSopClassUid, failedSopInstanceUid, + failedSopClassUid, failedSopInstanceUid, failureReasons, remoteIp_, remoteAet_, calledAet_); dimseStatus = 0; // Success