comparison OrthancServer/OrthancRestApi.cpp @ 214:03817919169b

list of frames
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 29 Nov 2012 11:11:53 +0100
parents 4ce7fdcc8879
children c07170f3f4f7
comparison
equal deleted inserted replaced
213:4ce7fdcc8879 214:03817919169b
373 } 373 }
374 374
375 375
376 // Get the DICOM or the JSON file of one instance --------------------------- 376 // Get the DICOM or the JSON file of one instance ---------------------------
377 377
378 else if (uri.size() == 3 &&
379 uri[0] == "instances" &&
380 (uri[2] == "file" ||
381 uri[2] == "tags" ||
382 uri[2] == "simplified-tags"))
383 {
384 CompressionType compressionType;
385 std::string fileUuid, contentType, filename;
386 if (uri[2] == "file")
387 {
388 existingResource = index_.GetFile(fileUuid, compressionType, uri[1], AttachedFileType_Dicom);
389 contentType = "application/dicom";
390 filename = fileUuid + ".dcm";
391 }
392 else if (uri[2] == "tags" ||
393 uri[2] == "simplified-tags")
394 {
395 existingResource = index_.GetFile(fileUuid, compressionType, uri[1], AttachedFileType_Json);
396 contentType = "application/json";
397 filename = fileUuid + ".json";
398 }
399
400 if (existingResource)
401 {
402 if (uri[2] == "simplified-tags")
403 {
404 Json::Value simplified, full;
405 ReadJson(full, storage_, fileUuid);
406 SimplifyTags(simplified, full);
407 SendJson(output, simplified);
408 return;
409 }
410 else
411 {
412 output.AnswerFile(storage_, fileUuid, contentType, filename.c_str());
413 return;
414 }
415 }
416 }
417
418
419 else if (uri.size() == 3 &&
420 uri[0] == "instances" &&
421 uri[2] == "frames")
422 {
423 Json::Value instance(Json::objectValue);
424 existingResource = index_.LookupResource(instance, uri[1], ResourceType_Instance);
425
426 if (existingResource)
427 {
428 result = Json::arrayValue;
429
430 unsigned int numberOfFrames = 1;
431 try
432 {
433 Json::Value tmp = instance["MainDicomTags"]["NumberOfFrames"];
434 numberOfFrames = boost::lexical_cast<unsigned int>(tmp.asString());
435 }
436 catch (boost::bad_lexical_cast)
437 {
438 }
439
440 for (unsigned int i = 0; i < numberOfFrames; i++)
441 {
442 result.append(i);
443 }
444 }
445 }
446
447
448 else if (uri[0] == "instances" && 378 else if (uri[0] == "instances" &&
449 ((uri.size() == 3 && 379 ((uri.size() == 3 &&
450 (uri[2] == "preview" || 380 (uri[2] == "preview" ||
451 uri[2] == "image-uint8" || 381 uri[2] == "image-uint8" ||
452 uri[2] == "image-uint16")) || 382 uri[2] == "image-uint16")) ||