comparison OrthancServer/ServerIndex.cpp @ 433:aa50783f9550

cardiopet
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 15 May 2013 14:19:09 +0200
parents 2b09d4ee86c6
children ccf3a0a43dac
comparison
equal deleted inserted replaced
432:2b09d4ee86c6 433:aa50783f9550
238 db->FlushToDisk(); 238 db->FlushToDisk();
239 } 239 }
240 } 240 }
241 241
242 242
243 static void ComputeExpectedNumberOfInstances(DatabaseWrapper& db,
244 int64_t series,
245 const DicomMap& dicomSummary)
246 {
247 const DicomValue* value;
248 const DicomValue* value2;
249
250 try
251 {
252 if ((value = dicomSummary.TestAndGetValue(DICOM_TAG_IMAGES_IN_ACQUISITION)) != NULL &&
253 (value2 = dicomSummary.TestAndGetValue(DICOM_TAG_NUMBER_OF_TEMPORAL_POSITIONS)) != NULL)
254 {
255 // Patch for series with temporal positions thanks to Will Ryder
256 int64_t imagesInAcquisition = boost::lexical_cast<int64_t>(value->AsString());
257 int64_t countTemporalPositions = boost::lexical_cast<int64_t>(value2->AsString());
258 std::string expected = boost::lexical_cast<std::string>(imagesInAcquisition * countTemporalPositions);
259 db.SetMetadata(series, MetadataType_Series_ExpectedNumberOfInstances, expected);
260 }
261
262 else if ((value = dicomSummary.TestAndGetValue(DICOM_TAG_NUMBER_OF_SLICES)) != NULL &&
263 (value2 = dicomSummary.TestAndGetValue(DICOM_TAG_NUMBER_OF_TIME_SLICES)) != NULL)
264 {
265 // Support of Cardio-PET images
266 int64_t numberOfSlices = boost::lexical_cast<int64_t>(value->AsString());
267 int64_t numberOfTimeSlices = boost::lexical_cast<int64_t>(value2->AsString());
268 std::string expected = boost::lexical_cast<std::string>(numberOfSlices * numberOfTimeSlices);
269 db.SetMetadata(series, MetadataType_Series_ExpectedNumberOfInstances, expected);
270 }
271
272 else if ((value = dicomSummary.TestAndGetValue(DICOM_TAG_CARDIAC_NUMBER_OF_IMAGES)) != NULL)
273 {
274 db.SetMetadata(series, MetadataType_Series_ExpectedNumberOfInstances, value->AsString());
275 }
276 }
277 catch (boost::bad_lexical_cast)
278 {
279 }
280 }
281
282
243 ServerIndex::ServerIndex(ServerContext& context, 283 ServerIndex::ServerIndex(ServerContext& context,
244 const std::string& dbPath) : 284 const std::string& dbPath) :
245 maximumStorageSize_(0), 285 maximumStorageSize_(0),
246 maximumPatients_(0) 286 maximumPatients_(0)
247 { 287 {
447 db_->SetMetadata(instance, MetadataType_Instance_IndexInSeries, value->AsString()); 487 db_->SetMetadata(instance, MetadataType_Instance_IndexInSeries, value->AsString());
448 } 488 }
449 489
450 if (isNewSeries) 490 if (isNewSeries)
451 { 491 {
452 if ((value = dicomSummary.TestAndGetValue(DICOM_TAG_NUMBER_OF_SLICES)) != NULL || 492 ComputeExpectedNumberOfInstances(*db_, series, dicomSummary);
453 (value = dicomSummary.TestAndGetValue(DICOM_TAG_IMAGES_IN_ACQUISITION)) != NULL ||
454 (value = dicomSummary.TestAndGetValue(DICOM_TAG_CARDIAC_NUMBER_OF_IMAGES)) != NULL)
455 {
456 db_->SetMetadata(series, MetadataType_Series_ExpectedNumberOfInstances, value->AsString());
457 }
458 } 493 }
459 494
460 // Check whether the series of this new instance is now completed 495 // Check whether the series of this new instance is now completed
461 SeriesStatus seriesStatus = GetSeriesStatus(series); 496 SeriesStatus seriesStatus = GetSeriesStatus(series);
462 if (seriesStatus == SeriesStatus_Complete) 497 if (seriesStatus == SeriesStatus_Complete)