comparison OrthancServer/ServerIndex.cpp @ 1004:a226e0959d8b lua-scripting

DicomInstanceToStore
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 08 Jul 2014 14:06:05 +0200
parents b067017a8a5b
children 649d47854314
comparison
equal deleted inserted replaced
1003:1d35281d967c 1004:a226e0959d8b
383 383
384 384
385 StoreStatus ServerIndex::Store(const DicomMap& dicomSummary, 385 StoreStatus ServerIndex::Store(const DicomMap& dicomSummary,
386 const Attachments& attachments, 386 const Attachments& attachments,
387 const std::string& remoteAet, 387 const std::string& remoteAet,
388 const MetadataMap* metadata) 388 MetadataMap* metadata)
389 { 389 {
390 boost::mutex::scoped_lock lock(mutex_); 390 boost::mutex::scoped_lock lock(mutex_);
391 listener_->Reset(); 391 listener_->Reset();
392 392
393 DicomInstanceHasher hasher(dicomSummary); 393 DicomInstanceHasher hasher(dicomSummary);
548 throw OrthancException(ErrorCode_ParameterOutOfRange); 548 throw OrthancException(ErrorCode_ParameterOutOfRange);
549 } 549 }
550 } 550 }
551 } 551 }
552 552
553 // Attach the auto-computer metadata 553 // Attach the auto-computed metadata for the patient/study/series levels
554 std::string now = Toolbox::GetNowIsoString(); 554 std::string now = Toolbox::GetNowIsoString();
555 db_->SetMetadata(instance, MetadataType_Instance_ReceptionDate, now);
556 db_->SetMetadata(series, MetadataType_LastUpdate, now); 555 db_->SetMetadata(series, MetadataType_LastUpdate, now);
557 db_->SetMetadata(study, MetadataType_LastUpdate, now); 556 db_->SetMetadata(study, MetadataType_LastUpdate, now);
558 db_->SetMetadata(patient, MetadataType_LastUpdate, now); 557 db_->SetMetadata(patient, MetadataType_LastUpdate, now);
558
559 // Attach the auto-computed metadata for the instance level,
560 // reflecting these additions into the input metadata map
561 db_->SetMetadata(instance, MetadataType_Instance_ReceptionDate, now);
559 db_->SetMetadata(instance, MetadataType_Instance_RemoteAet, remoteAet); 562 db_->SetMetadata(instance, MetadataType_Instance_RemoteAet, remoteAet);
563
564 if (metadata)
565 {
566 (*metadata) [std::make_pair(ResourceType_Instance, MetadataType_Instance_ReceptionDate)] = now;
567 (*metadata) [std::make_pair(ResourceType_Instance, MetadataType_Instance_RemoteAet)] = remoteAet;
568 }
560 569
561 const DicomValue* value; 570 const DicomValue* value;
562 if ((value = dicomSummary.TestAndGetValue(DICOM_TAG_INSTANCE_NUMBER)) != NULL || 571 if ((value = dicomSummary.TestAndGetValue(DICOM_TAG_INSTANCE_NUMBER)) != NULL ||
563 (value = dicomSummary.TestAndGetValue(DICOM_TAG_IMAGE_INDEX)) != NULL) 572 (value = dicomSummary.TestAndGetValue(DICOM_TAG_IMAGE_INDEX)) != NULL)
564 { 573 {
565 db_->SetMetadata(instance, MetadataType_Instance_IndexInSeries, value->AsString()); 574 db_->SetMetadata(instance, MetadataType_Instance_IndexInSeries, value->AsString());
566 } 575
567 576 if (metadata)
577 {
578 (*metadata) [std::make_pair(ResourceType_Instance, MetadataType_Instance_IndexInSeries)] = value->AsString();
579 }
580 }
581
582 // Check whether the series of this new instance is now completed
568 if (isNewSeries) 583 if (isNewSeries)
569 { 584 {
570 ComputeExpectedNumberOfInstances(*db_, series, dicomSummary); 585 ComputeExpectedNumberOfInstances(*db_, series, dicomSummary);
571 } 586 }
572 587
573 // Check whether the series of this new instance is now completed
574 SeriesStatus seriesStatus = GetSeriesStatus(series); 588 SeriesStatus seriesStatus = GetSeriesStatus(series);
575 if (seriesStatus == SeriesStatus_Complete) 589 if (seriesStatus == SeriesStatus_Complete)
576 { 590 {
577 db_->LogChange(ChangeType_CompletedSeries, series, ResourceType_Series); 591 db_->LogChange(ChangeType_CompletedSeries, series, ResourceType_Series);
578 } 592 }