# HG changeset patch # User Sebastien Jodogne # Date 1410359908 -7200 # Node ID f167b672db9413c32ebe63472cd7428250f7f048 # Parent 4c4fdee093de2dc49d8f88f845c66398f107fa08 /tools/lookup URI to map DICOM UIDs to Orthanc identifiers diff -r 4c4fdee093de -r f167b672db94 NEWS --- a/NEWS Wed Sep 10 13:16:08 2014 +0200 +++ b/NEWS Wed Sep 10 16:38:28 2014 +0200 @@ -7,6 +7,7 @@ * Creation of ZIP archives for media storage, with DICOMDIR * Support of index-only mode (using the "StoreDicom" option) * Plugins can implement a custom storage area +* "/tools/lookup" URI to map DICOM UIDs to Orthanc identifiers Minor ----- diff -r 4c4fdee093de -r f167b672db94 OrthancServer/OrthancRestApi/OrthancRestResources.cpp --- a/OrthancServer/OrthancRestApi/OrthancRestResources.cpp Wed Sep 10 13:16:08 2014 +0200 +++ b/OrthancServer/OrthancRestApi/OrthancRestResources.cpp Wed Sep 10 16:38:28 2014 +0200 @@ -781,6 +781,35 @@ } + static void Lookup(RestApiPostCall& call) + { + typedef std::list< std::pair > Resources; + + std::string tag = call.GetPostBody(); + Resources resources; + + OrthancRestApi::GetIndex(call).LookupTagValue(resources, tag); + + Json::Value result = Json::arrayValue; + + for (Resources::const_iterator it = resources.begin(); + it != resources.end(); it++) + { + ResourceType type = it->first; + const std::string& id = it->second; + + Json::Value item = Json::objectValue; + item["Type"] = EnumerationToString(type); + item["ID"] = id; + item["Path"] = GetBasePath(type, id); + + result.append(item); + } + + call.GetOutput().AnswerJson(result); + } + + void OrthancRestApi::RegisterResources() { Register("/instances", ListResources); @@ -849,6 +878,8 @@ Register("/{resourceType}/{id}/attachments/{name}/verify-md5", VerifyAttachment); Register("/{resourceType}/{id}/attachments/{name}", UploadAttachment); + Register("/tools/lookup", Lookup); + Register("/instances/{id}/content/*", GetRawContent); } } diff -r 4c4fdee093de -r f167b672db94 OrthancServer/ServerIndex.cpp --- a/OrthancServer/ServerIndex.cpp Wed Sep 10 13:16:08 2014 +0200 +++ b/OrthancServer/ServerIndex.cpp Wed Sep 10 16:38:28 2014 +0200 @@ -1663,7 +1663,7 @@ } - void ServerIndex::LookupTagValue(std::list& result, + void ServerIndex::LookupTagValue(std::list< std::pair >& result, const std::string& value) { result.clear(); @@ -1676,7 +1676,8 @@ for (std::list::const_iterator it = id.begin(); it != id.end(); ++it) { - result.push_back(db_->GetPublicId(*it)); + result.push_back(std::make_pair(db_->GetResourceType(*it), + db_->GetPublicId(*it))); } } diff -r 4c4fdee093de -r f167b672db94 OrthancServer/ServerIndex.h --- a/OrthancServer/ServerIndex.h Wed Sep 10 13:16:08 2014 +0200 +++ b/OrthancServer/ServerIndex.h Wed Sep 10 16:38:28 2014 +0200 @@ -225,7 +225,7 @@ DicomTag tag, const std::string& value); - void LookupTagValue(std::list& result, + void LookupTagValue(std::list< std::pair >& result, const std::string& value); StoreStatus AddAttachment(const FileInfo& attachment,