Mercurial > hg > orthanc
comparison OrthancServer/OrthancRestApi/OrthancRestAnonymizeModify.cpp @ 2899:5dd649de253d
POST-ing a DICOM file to "/instances" also answers the patient/study/series ID
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 18 Oct 2018 12:03:51 +0200 |
parents | 2bd87764709c |
children | 4b3929668358 |
comparison
equal
deleted
inserted
replaced
2898:e5e3253a1164 | 2899:5dd649de253d |
---|---|
206 } | 206 } |
207 | 207 |
208 | 208 |
209 static void StoreCreatedInstance(std::string& id /* out */, | 209 static void StoreCreatedInstance(std::string& id /* out */, |
210 RestApiPostCall& call, | 210 RestApiPostCall& call, |
211 ParsedDicomFile& dicom) | 211 ParsedDicomFile& dicom, |
212 bool sendAnswer) | |
212 { | 213 { |
213 DicomInstanceToStore toStore; | 214 DicomInstanceToStore toStore; |
214 toStore.SetOrigin(DicomInstanceOrigin::FromRest(call)); | 215 toStore.SetOrigin(DicomInstanceOrigin::FromRest(call)); |
215 toStore.SetParsedDicomFile(dicom); | 216 toStore.SetParsedDicomFile(dicom); |
216 | 217 |
218 StoreStatus status = context.Store(id, toStore); | 219 StoreStatus status = context.Store(id, toStore); |
219 | 220 |
220 if (status == StoreStatus_Failure) | 221 if (status == StoreStatus_Failure) |
221 { | 222 { |
222 throw OrthancException(ErrorCode_CannotStoreInstance); | 223 throw OrthancException(ErrorCode_CannotStoreInstance); |
224 } | |
225 | |
226 if (sendAnswer) | |
227 { | |
228 OrthancRestApi::GetApi(call).AnswerStoredInstance(call, toStore, status); | |
223 } | 229 } |
224 } | 230 } |
225 | 231 |
226 | 232 |
227 static void CreateDicomV1(ParsedDicomFile& dicom, | 233 static void CreateDicomV1(ParsedDicomFile& dicom, |
354 | 360 |
355 dicom->EmbedContent(payload->asString()); | 361 dicom->EmbedContent(payload->asString()); |
356 dicom->ReplacePlainString(DICOM_TAG_INSTANCE_NUMBER, boost::lexical_cast<std::string>(i + 1)); | 362 dicom->ReplacePlainString(DICOM_TAG_INSTANCE_NUMBER, boost::lexical_cast<std::string>(i + 1)); |
357 dicom->ReplacePlainString(DICOM_TAG_IMAGE_INDEX, boost::lexical_cast<std::string>(i + 1)); | 363 dicom->ReplacePlainString(DICOM_TAG_IMAGE_INDEX, boost::lexical_cast<std::string>(i + 1)); |
358 | 364 |
359 StoreCreatedInstance(someInstance, call, *dicom); | 365 StoreCreatedInstance(someInstance, call, *dicom, false); |
360 } | 366 } |
361 } | 367 } |
362 catch (OrthancException&) | 368 catch (OrthancException&) |
363 { | 369 { |
364 // Error: Remove the newly-created series | 370 // Error: Remove the newly-created series |
581 throw OrthancException(ErrorCode_CreateDicomUseDataUriScheme); | 587 throw OrthancException(ErrorCode_CreateDicomUseDataUriScheme); |
582 } | 588 } |
583 } | 589 } |
584 | 590 |
585 std::string id; | 591 std::string id; |
586 StoreCreatedInstance(id, call, dicom); | 592 StoreCreatedInstance(id, call, dicom, true); |
587 OrthancRestApi::GetApi(call).AnswerStoredResource(call, id, ResourceType_Instance, StoreStatus_Success); | |
588 | |
589 return; | |
590 } | 593 } |
591 | 594 |
592 | 595 |
593 static void CreateDicom(RestApiPostCall& call) | 596 static void CreateDicom(RestApiPostCall& call) |
594 { | 597 { |
608 // Compatibility with Orthanc <= 0.9.3 | 611 // Compatibility with Orthanc <= 0.9.3 |
609 ParsedDicomFile dicom(true); | 612 ParsedDicomFile dicom(true); |
610 CreateDicomV1(dicom, call, request); | 613 CreateDicomV1(dicom, call, request); |
611 | 614 |
612 std::string id; | 615 std::string id; |
613 StoreCreatedInstance(id, call, dicom); | 616 StoreCreatedInstance(id, call, dicom, true); |
614 OrthancRestApi::GetApi(call).AnswerStoredResource(call, id, ResourceType_Instance, StoreStatus_Success); | |
615 } | 617 } |
616 } | 618 } |
617 | 619 |
618 | 620 |
619 static void SplitStudy(RestApiPostCall& call) | 621 static void SplitStudy(RestApiPostCall& call) |