# HG changeset patch # User Sebastien Jodogne # Date 1539857031 -7200 # Node ID 5dd649de253dd9099ee71d0a1e473349e9161056 # Parent e5e3253a11646c297180168e6e4a0ee4e09bd766 POST-ing a DICOM file to "/instances" also answers the patient/study/series ID diff -r e5e3253a1164 -r 5dd649de253d NEWS --- a/NEWS Thu Oct 18 11:44:17 2018 +0200 +++ b/NEWS Thu Oct 18 12:03:51 2018 +0200 @@ -18,6 +18,7 @@ * New URI: "/studies/.../merge" to merge a study * New URI: "/studies/.../split" to split a study +* POST-ing a DICOM file to "/instances" also answers the patient/study/series ID Maintenance ----------- diff -r e5e3253a1164 -r 5dd649de253d OrthancServer/OrthancRestApi/OrthancRestAnonymizeModify.cpp --- a/OrthancServer/OrthancRestApi/OrthancRestAnonymizeModify.cpp Thu Oct 18 11:44:17 2018 +0200 +++ b/OrthancServer/OrthancRestApi/OrthancRestAnonymizeModify.cpp Thu Oct 18 12:03:51 2018 +0200 @@ -208,7 +208,8 @@ static void StoreCreatedInstance(std::string& id /* out */, RestApiPostCall& call, - ParsedDicomFile& dicom) + ParsedDicomFile& dicom, + bool sendAnswer) { DicomInstanceToStore toStore; toStore.SetOrigin(DicomInstanceOrigin::FromRest(call)); @@ -221,6 +222,11 @@ { throw OrthancException(ErrorCode_CannotStoreInstance); } + + if (sendAnswer) + { + OrthancRestApi::GetApi(call).AnswerStoredInstance(call, toStore, status); + } } @@ -356,7 +362,7 @@ dicom->ReplacePlainString(DICOM_TAG_INSTANCE_NUMBER, boost::lexical_cast(i + 1)); dicom->ReplacePlainString(DICOM_TAG_IMAGE_INDEX, boost::lexical_cast(i + 1)); - StoreCreatedInstance(someInstance, call, *dicom); + StoreCreatedInstance(someInstance, call, *dicom, false); } } catch (OrthancException&) @@ -583,10 +589,7 @@ } std::string id; - StoreCreatedInstance(id, call, dicom); - OrthancRestApi::GetApi(call).AnswerStoredResource(call, id, ResourceType_Instance, StoreStatus_Success); - - return; + StoreCreatedInstance(id, call, dicom, true); } @@ -610,8 +613,7 @@ CreateDicomV1(dicom, call, request); std::string id; - StoreCreatedInstance(id, call, dicom); - OrthancRestApi::GetApi(call).AnswerStoredResource(call, id, ResourceType_Instance, StoreStatus_Success); + StoreCreatedInstance(id, call, dicom, true); } } diff -r e5e3253a1164 -r 5dd649de253d OrthancServer/OrthancRestApi/OrthancRestApi.cpp --- a/OrthancServer/OrthancRestApi/OrthancRestApi.cpp Thu Oct 18 11:44:17 2018 +0200 +++ b/OrthancServer/OrthancRestApi/OrthancRestApi.cpp Thu Oct 18 12:03:51 2018 +0200 @@ -40,20 +40,46 @@ namespace Orthanc { - void OrthancRestApi::AnswerStoredResource(RestApiPostCall& call, - const std::string& publicId, - ResourceType resourceType, - StoreStatus status) const + static void SetupResourceAnswer(Json::Value& result, + const std::string& publicId, + ResourceType resourceType, + StoreStatus status) { - Json::Value result = Json::objectValue; + result = Json::objectValue; if (status != StoreStatus_Failure) { result["ID"] = publicId; result["Path"] = GetBasePath(resourceType, publicId); } + + result["Status"] = EnumerationToString(status); + } - result["Status"] = EnumerationToString(status); + + void OrthancRestApi::AnswerStoredInstance(RestApiPostCall& call, + DicomInstanceToStore& instance, + StoreStatus status) const + { + Json::Value result; + SetupResourceAnswer(result, instance.GetHasher().HashInstance(), + ResourceType_Instance, status); + + result["ParentPatient"] = instance.GetHasher().HashPatient(); + result["ParentStudy"] = instance.GetHasher().HashStudy(); + result["ParentSeries"] = instance.GetHasher().HashSeries(); + + call.GetOutput().AnswerJson(result); + } + + + void OrthancRestApi::AnswerStoredResource(RestApiPostCall& call, + const std::string& publicId, + ResourceType resourceType, + StoreStatus status) const + { + Json::Value result; + SetupResourceAnswer(result, publicId, resourceType, status); call.GetOutput().AnswerJson(result); } @@ -100,7 +126,7 @@ std::string publicId; StoreStatus status = context.Store(publicId, toStore); - OrthancRestApi::GetApi(call).AnswerStoredResource(call, publicId, ResourceType_Instance, status); + OrthancRestApi::GetApi(call).AnswerStoredInstance(call, toStore, status); } diff -r e5e3253a1164 -r 5dd649de253d OrthancServer/OrthancRestApi/OrthancRestApi.h --- a/OrthancServer/OrthancRestApi/OrthancRestApi.h Thu Oct 18 11:44:17 2018 +0200 +++ b/OrthancServer/OrthancRestApi/OrthancRestApi.h Thu Oct 18 12:03:51 2018 +0200 @@ -44,6 +44,7 @@ { class ServerContext; class ServerIndex; + class DicomInstanceToStore; class OrthancRestApi : public RestApi { @@ -93,6 +94,10 @@ static ServerIndex& GetIndex(RestApiCall& call); + void AnswerStoredInstance(RestApiPostCall& call, + DicomInstanceToStore& instance, + StoreStatus status) const; + void AnswerStoredResource(RestApiPostCall& call, const std::string& publicId, ResourceType resourceType,