# HG changeset patch # User Sebastien Jodogne # Date 1393345448 -3600 # Node ID 55b945749beddb58f1810652535d89f66fbc2467 # Parent a0a05f9dcd5ad94fa46b455c94c19e82c93e991e# Parent b79eda29896da95d89d9050f9cc0eb97630c0181 mainline -> mac integration diff -r a0a05f9dcd5a -r 55b945749bed Core/DicomFormat/DicomMap.cpp --- a/Core/DicomFormat/DicomMap.cpp Mon Feb 24 17:41:17 2014 +0100 +++ b/Core/DicomFormat/DicomMap.cpp Tue Feb 25 17:24:08 2014 +0100 @@ -199,7 +199,7 @@ } else { - throw OrthancException("Inexistent tag"); + throw OrthancException(ErrorCode_InexistentTag); } } diff -r a0a05f9dcd5a -r 55b945749bed Core/Enumerations.h --- a/Core/Enumerations.h Mon Feb 24 17:41:17 2014 +0100 +++ b/Core/Enumerations.h Tue Feb 25 17:24:08 2014 +0100 @@ -67,7 +67,8 @@ ErrorCode_UnknownResource, ErrorCode_IncompatibleDatabaseVersion, ErrorCode_FullStorage, - ErrorCode_CorruptedFile + ErrorCode_CorruptedFile, + ErrorCode_InexistentTag }; /** diff -r a0a05f9dcd5a -r 55b945749bed Core/OrthancException.cpp --- a/Core/OrthancException.cpp Mon Feb 24 17:41:17 2014 +0100 +++ b/Core/OrthancException.cpp Tue Feb 25 17:24:08 2014 +0100 @@ -108,6 +108,9 @@ case ErrorCode_CorruptedFile: return "Corrupted file (inconsistent MD5 hash)"; + case ErrorCode_InexistentTag: + return "Inexistent tag"; + case ErrorCode_Custom: default: return "???"; diff -r a0a05f9dcd5a -r 55b945749bed NEWS --- a/NEWS Mon Feb 24 17:41:17 2014 +0100 +++ b/NEWS Tue Feb 25 17:24:08 2014 +0100 @@ -1,6 +1,8 @@ Pending changes in the mainline =============================== +* Better logging about nonexistent tags +* Dcm4Chee manufacturer Version 0.7.3 (2014/02/14) diff -r a0a05f9dcd5a -r 55b945749bed OrthancServer/DicomProtocol/DicomUserConnection.cpp --- a/OrthancServer/DicomProtocol/DicomUserConnection.cpp Mon Feb 24 17:41:17 2014 +0100 +++ b/OrthancServer/DicomProtocol/DicomUserConnection.cpp Tue Feb 25 17:24:08 2014 +0100 @@ -340,7 +340,8 @@ break; case FindRootModel_Instance: - if (manufacturer_ == ModalityManufacturer_ClearCanvas) + if (manufacturer_ == ModalityManufacturer_ClearCanvas || + manufacturer_ == ModalityManufacturer_Dcm4Chee) { // This is a particular case for ClearCanvas, thanks to Peter Somlo . // https://groups.google.com/d/msg/orthanc-users/j-6C3MAVwiw/iolB9hclom8J diff -r a0a05f9dcd5a -r 55b945749bed OrthancServer/Internals/StoreScp.cpp --- a/OrthancServer/Internals/StoreScp.cpp Mon Feb 24 17:41:17 2014 +0100 +++ b/OrthancServer/Internals/StoreScp.cpp Tue Feb 25 17:24:08 2014 +0100 @@ -33,6 +33,7 @@ #include "StoreScp.h" #include "../FromDcmtkBridge.h" +#include "../ServerToolbox.h" #include "../ToDcmtkBridge.h" #include "../../Core/OrthancException.h" @@ -57,7 +58,7 @@ uint32_t messageID; }; - + static void storeScpCallback( void *callbackData, @@ -155,7 +156,15 @@ catch (OrthancException& e) { rsp->DimseStatus = STATUS_STORE_Refused_OutOfResources; - LOG(ERROR) << "Exception while storing DICOM: " << e.What(); + + if (e.GetErrorCode() == ErrorCode_InexistentTag) + { + LogMissingRequiredTag(summary); + } + else + { + LOG(ERROR) << "Exception while storing DICOM: " << e.What(); + } } } } diff -r a0a05f9dcd5a -r 55b945749bed OrthancServer/ServerContext.cpp --- a/OrthancServer/ServerContext.cpp Mon Feb 24 17:41:17 2014 +0100 +++ b/OrthancServer/ServerContext.cpp Tue Feb 25 17:24:08 2014 +0100 @@ -238,19 +238,31 @@ DicomMap dicomSummary; FromDcmtkBridge::Convert(dicomSummary, *dicomInstance.getDataset()); - DicomInstanceHasher hasher(dicomSummary); - resultPublicId = hasher.HashInstance(); + try + { + DicomInstanceHasher hasher(dicomSummary); + resultPublicId = hasher.HashInstance(); - Json::Value dicomJson; - FromDcmtkBridge::ToJson(dicomJson, *dicomInstance.getDataset()); + Json::Value dicomJson; + FromDcmtkBridge::ToJson(dicomJson, *dicomInstance.getDataset()); - StoreStatus status = StoreStatus_Failure; - if (dicomSize > 0) + StoreStatus status = StoreStatus_Failure; + if (dicomSize > 0) + { + status = Store(dicomBuffer, dicomSize, dicomSummary, dicomJson, ""); + } + + return status; + } + catch (OrthancException& e) { - status = Store(dicomBuffer, dicomSize, dicomSummary, dicomJson, ""); - } + if (e.GetErrorCode() == ErrorCode_InexistentTag) + { + LogMissingRequiredTag(dicomSummary); + } - return status; + throw e; + } } diff -r a0a05f9dcd5a -r 55b945749bed OrthancServer/ServerEnumerations.cpp --- a/OrthancServer/ServerEnumerations.cpp Mon Feb 24 17:41:17 2014 +0100 +++ b/OrthancServer/ServerEnumerations.cpp Tue Feb 25 17:24:08 2014 +0100 @@ -282,6 +282,9 @@ case ModalityManufacturer_MedInria: return "MedInria"; + + case ModalityManufacturer_Dcm4Chee: + return "Dcm4Chee"; default: throw OrthancException(ErrorCode_ParameterOutOfRange); @@ -335,6 +338,10 @@ { return ModalityManufacturer_MedInria; } + else if (manufacturer == "Dcm4Chee") + { + return ModalityManufacturer_Dcm4Chee; + } else { throw OrthancException(ErrorCode_ParameterOutOfRange); diff -r a0a05f9dcd5a -r 55b945749bed OrthancServer/ServerEnumerations.h --- a/OrthancServer/ServerEnumerations.h Mon Feb 24 17:41:17 2014 +0100 +++ b/OrthancServer/ServerEnumerations.h Tue Feb 25 17:24:08 2014 +0100 @@ -57,7 +57,8 @@ { ModalityManufacturer_Generic, ModalityManufacturer_ClearCanvas, - ModalityManufacturer_MedInria + ModalityManufacturer_MedInria, + ModalityManufacturer_Dcm4Chee }; enum DicomRequestType diff -r a0a05f9dcd5a -r 55b945749bed OrthancServer/ServerToolbox.cpp --- a/OrthancServer/ServerToolbox.cpp Mon Feb 24 17:41:17 2014 +0100 +++ b/OrthancServer/ServerToolbox.cpp Tue Feb 25 17:24:08 2014 +0100 @@ -35,6 +35,7 @@ #include "../Core/OrthancException.h" #include +#include namespace Orthanc { @@ -82,4 +83,71 @@ } } } + + + void LogMissingRequiredTag(const DicomMap& summary) + { + std::string s, t; + + if (summary.HasTag(DICOM_TAG_PATIENT_ID)) + { + if (t.size() > 0) + t += ", "; + t += "PatientID=" + summary.GetValue(DICOM_TAG_PATIENT_ID).AsString(); + } + else + { + if (s.size() > 0) + s += ", "; + s += "PatientID"; + } + + if (summary.HasTag(DICOM_TAG_STUDY_INSTANCE_UID)) + { + if (t.size() > 0) + t += ", "; + t += "StudyInstanceUID=" + summary.GetValue(DICOM_TAG_STUDY_INSTANCE_UID).AsString(); + } + else + { + if (s.size() > 0) + s += ", "; + s += "StudyInstanceUID"; + } + + if (summary.HasTag(DICOM_TAG_SERIES_INSTANCE_UID)) + { + if (t.size() > 0) + t += ", "; + t += "SeriesInstanceUID=" + summary.GetValue(DICOM_TAG_SERIES_INSTANCE_UID).AsString(); + } + else + { + if (s.size() > 0) + s += ", "; + s += "SeriesInstanceUID"; + } + + if (summary.HasTag(DICOM_TAG_SOP_INSTANCE_UID)) + { + if (t.size() > 0) + t += ", "; + t += "SOPInstanceUID=" + summary.GetValue(DICOM_TAG_SOP_INSTANCE_UID).AsString(); + } + else + { + if (s.size() > 0) + s += ", "; + s += "SOPInstanceUID"; + } + + if (t.size() == 0) + { + LOG(ERROR) << "Store has failed because all the required tags (" << s << ") are missing (is it a DICOMDIR file?)"; + } + else + { + LOG(ERROR) << "Store has failed because required tags (" << s << ") are missing for the following instance: " << t; + } + } } diff -r a0a05f9dcd5a -r 55b945749bed OrthancServer/ServerToolbox.h --- a/OrthancServer/ServerToolbox.h Mon Feb 24 17:41:17 2014 +0100 +++ b/OrthancServer/ServerToolbox.h Tue Feb 25 17:24:08 2014 +0100 @@ -32,10 +32,14 @@ #pragma once +#include "../Core/DicomFormat/DicomMap.h" + #include namespace Orthanc { void SimplifyTags(Json::Value& target, const Json::Value& source); + + void LogMissingRequiredTag(const DicomMap& summary); } diff -r a0a05f9dcd5a -r 55b945749bed OrthancServer/main.cpp --- a/OrthancServer/main.cpp Mon Feb 24 17:41:17 2014 +0100 +++ b/OrthancServer/main.cpp Tue Feb 25 17:24:08 2014 +0100 @@ -46,6 +46,7 @@ #include "ServerContext.h" #include "OrthancFindRequestHandler.h" #include "OrthancMoveRequestHandler.h" +#include "ServerToolbox.h" using namespace Orthanc; diff -r a0a05f9dcd5a -r 55b945749bed Resources/Configuration.json --- a/Resources/Configuration.json Mon Feb 24 17:41:17 2014 +0100 +++ b/Resources/Configuration.json Tue Feb 25 17:24:08 2014 +0100 @@ -100,8 +100,8 @@ /** * A fourth parameter is available to enable patches for a * specific PACS manufacturer. The allowed values are currently - * "Generic" (default value), "ClearCanvas" and "MedInria". This - * parameter is case-sensitive. + * "Generic" (default value), "ClearCanvas", "MedInria" and + * "Dcm4Chee". This parameter is case-sensitive. **/ // "clearcanvas" : [ "CLEARCANVAS", "192.168.1.1", 104, "ClearCanvas" ] },