# HG changeset patch # User Sebastien Jodogne # Date 1587052787 -7200 # Node ID 281045a1e6db82fb22f7648537fc7080710dbcd3 # Parent c9c34bb50f0a8f90cd81b6b51c022daf045bf910 new "info" field in "ReceivedInstanceFilter()" callback diff -r c9c34bb50f0a -r 281045a1e6db NEWS --- a/NEWS Thu Apr 16 17:27:18 2020 +0200 +++ b/NEWS Thu Apr 16 17:59:47 2020 +0200 @@ -10,6 +10,11 @@ - "/modalities/{id}/store-straight": Synchronously send the DICOM instance in POST body to another modality (alternative to command-line tools such as "storescu") +Lua +--- + +* New "info" field in "ReceivedInstanceFilter()" callback, containing + "HasPixelData" and "TransferSyntaxUID" information Maintenance ----------- diff -r c9c34bb50f0a -r 281045a1e6db OrthancServer/DicomInstanceToStore.cpp --- a/OrthancServer/DicomInstanceToStore.cpp Thu Apr 16 17:27:18 2020 +0200 +++ b/OrthancServer/DicomInstanceToStore.cpp Thu Apr 16 17:59:47 2020 +0200 @@ -169,6 +169,26 @@ private: std::unique_ptr hasher_; + void ParseDicomFile() + { + if (!parsed_.HasContent()) + { + if (!hasBuffer_) + { + throw OrthancException(ErrorCode_InternalError); + } + + if (ownBuffer_.get() != NULL) + { + parsed_.TakeOwnership(new ParsedDicomFile(*ownBuffer_)); + } + else + { + parsed_.TakeOwnership(new ParsedDicomFile(bufferData_, bufferSize_)); + } + } + } + void ComputeMissingInformation() { if (hasBuffer_ && @@ -217,18 +237,8 @@ // memory buffer, but that its summary or its JSON version is // missing - assert(hasBuffer_); - if (!parsed_.HasContent()) - { - if (ownBuffer_.get() != NULL) - { - parsed_.TakeOwnership(new ParsedDicomFile(*ownBuffer_)); - } - else - { - parsed_.TakeOwnership(new ParsedDicomFile(bufferData_, bufferSize_)); - } - } + ParseDicomFile(); + assert(parsed_.HasContent()); // At this point, we have parsed the DICOM file @@ -369,6 +379,22 @@ return false; } + + + bool HasPixelData() + { + ComputeMissingInformation(); + ParseDicomFile(); + + if (parsed_.HasContent()) + { + return parsed_.GetContent().HasTag(DICOM_TAG_PIXEL_DATA); + } + else + { + throw OrthancException(ErrorCode_InternalError); + } + } }; @@ -459,9 +485,9 @@ } - bool DicomInstanceToStore::LookupTransferSyntax(std::string& result) + bool DicomInstanceToStore::LookupTransferSyntax(std::string& result) const { - return pimpl_->LookupTransferSyntax(result); + return const_cast(*pimpl_).LookupTransferSyntax(result); } @@ -469,4 +495,9 @@ { return pimpl_->GetHasher(); } + + bool DicomInstanceToStore::HasPixelData() const + { + return const_cast(*pimpl_).HasPixelData(); + } } diff -r c9c34bb50f0a -r 281045a1e6db OrthancServer/DicomInstanceToStore.h --- a/OrthancServer/DicomInstanceToStore.h Thu Apr 16 17:27:18 2020 +0200 +++ b/OrthancServer/DicomInstanceToStore.h Thu Apr 16 17:59:47 2020 +0200 @@ -87,8 +87,10 @@ const Json::Value& GetJson(); - bool LookupTransferSyntax(std::string& result); + bool LookupTransferSyntax(std::string& result) const; DicomInstanceHasher& GetHasher(); + + bool HasPixelData() const; }; } diff -r c9c34bb50f0a -r 281045a1e6db OrthancServer/LuaScripting.cpp --- a/OrthancServer/LuaScripting.cpp Thu Apr 16 17:27:18 2020 +0200 +++ b/OrthancServer/LuaScripting.cpp Thu Apr 16 17:59:47 2020 +0200 @@ -874,6 +874,17 @@ instance.GetOrigin().Format(origin); call.PushJson(origin); + Json::Value info = Json::objectValue; + info["HasPixelData"] = instance.HasPixelData(); + + std::string s; + if (instance.LookupTransferSyntax(s)) + { + info["TransferSyntaxUID"] = s; + } + + call.PushJson(info); + if (!call.ExecutePredicate()) { return false;