comparison OrthancServer/UnitTestsSources/ServerIndexTests.cpp @ 4505:97d103b57cd1

removed cached dicom summary from DicomInstanceToStore
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 10 Feb 2021 12:07:03 +0100
parents 6f99949b2878
children ac69c9f76c71
comparison
equal deleted inserted replaced
4504:7d1eabfac6e0 4505:97d103b57cd1
38 #include "../../OrthancFramework/Sources/FileStorage/FilesystemStorage.h" 38 #include "../../OrthancFramework/Sources/FileStorage/FilesystemStorage.h"
39 #include "../../OrthancFramework/Sources/FileStorage/MemoryStorageArea.h" 39 #include "../../OrthancFramework/Sources/FileStorage/MemoryStorageArea.h"
40 #include "../../OrthancFramework/Sources/Logging.h" 40 #include "../../OrthancFramework/Sources/Logging.h"
41 41
42 #include "../Sources/Database/SQLiteDatabaseWrapper.h" 42 #include "../Sources/Database/SQLiteDatabaseWrapper.h"
43 #include "../Sources/OrthancConfiguration.h"
43 #include "../Sources/Search/DatabaseLookup.h" 44 #include "../Sources/Search/DatabaseLookup.h"
44 #include "../Sources/ServerContext.h" 45 #include "../Sources/ServerContext.h"
45 #include "../Sources/ServerToolbox.h" 46 #include "../Sources/ServerToolbox.h"
46 47
47 #include <ctype.h> 48 #include <ctype.h>
722 instance.SetValue(DICOM_TAG_STUDY_INSTANCE_UID, "study-" + id, false); 723 instance.SetValue(DICOM_TAG_STUDY_INSTANCE_UID, "study-" + id, false);
723 instance.SetValue(DICOM_TAG_SERIES_INSTANCE_UID, "series-" + id, false); 724 instance.SetValue(DICOM_TAG_SERIES_INSTANCE_UID, "series-" + id, false);
724 instance.SetValue(DICOM_TAG_SOP_INSTANCE_UID, "instance-" + id, false); 725 instance.SetValue(DICOM_TAG_SOP_INSTANCE_UID, "instance-" + id, false);
725 instance.SetValue(DICOM_TAG_SOP_CLASS_UID, "1.2.840.10008.5.1.4.1.1.1", false); // CR image 726 instance.SetValue(DICOM_TAG_SOP_CLASS_UID, "1.2.840.10008.5.1.4.1.1.1", false); // CR image
726 727
728 ParsedDicomFile dicom(instance, GetDefaultDicomEncoding(), false /* be strict */);
729
727 std::map<MetadataType, std::string> instanceMetadata; 730 std::map<MetadataType, std::string> instanceMetadata;
728 DicomInstanceToStore toStore; 731 DicomInstanceToStore toStore;
729 toStore.SetSummary(instance); 732 toStore.SetParsedDicomFile(dicom);
730 ASSERT_EQ(StoreStatus_Success, index.Store(instanceMetadata, toStore, attachments, 733
731 false /* don't overwrite */, true /* pixel data offset */, 42)); 734 {
735 DicomMap summary;
736 OrthancConfiguration::DefaultExtractDicomSummary(summary, toStore.GetParsedDicomFile());
737
738 DicomInstanceHasher hasher(summary);
739 ASSERT_EQ(StoreStatus_Success, index.Store(instanceMetadata, toStore, summary, hasher, attachments,
740 false /* don't overwrite */, true /* pixel data offset */, 42));
741 }
742
732 ASSERT_EQ(6u, instanceMetadata.size()); 743 ASSERT_EQ(6u, instanceMetadata.size());
733 ASSERT_TRUE(instanceMetadata.find(MetadataType_RemoteAet) != instanceMetadata.end()); 744 ASSERT_TRUE(instanceMetadata.find(MetadataType_RemoteAet) != instanceMetadata.end());
734 ASSERT_TRUE(instanceMetadata.find(MetadataType_Instance_ReceptionDate) != instanceMetadata.end()); 745 ASSERT_TRUE(instanceMetadata.find(MetadataType_Instance_ReceptionDate) != instanceMetadata.end());
735 ASSERT_TRUE(instanceMetadata.find(MetadataType_Instance_TransferSyntax) != instanceMetadata.end()); 746 ASSERT_TRUE(instanceMetadata.find(MetadataType_Instance_TransferSyntax) != instanceMetadata.end());
736 ASSERT_TRUE(instanceMetadata.find(MetadataType_Instance_SopClassUid) != instanceMetadata.end()); 747 ASSERT_TRUE(instanceMetadata.find(MetadataType_Instance_SopClassUid) != instanceMetadata.end());
748 DicomInstanceHasher hasher(instance); 759 DicomInstanceHasher hasher(instance);
749 ids.push_back(hasher.HashPatient()); 760 ids.push_back(hasher.HashPatient());
750 ids.push_back(hasher.HashStudy()); 761 ids.push_back(hasher.HashStudy());
751 ids.push_back(hasher.HashSeries()); 762 ids.push_back(hasher.HashSeries());
752 ids.push_back(hasher.HashInstance()); 763 ids.push_back(hasher.HashInstance());
753
754 ASSERT_EQ(hasher.HashPatient(), toStore.GetHasher().HashPatient());
755 ASSERT_EQ(hasher.HashStudy(), toStore.GetHasher().HashStudy());
756 ASSERT_EQ(hasher.HashSeries(), toStore.GetHasher().HashSeries());
757 ASSERT_EQ(hasher.HashInstance(), toStore.GetHasher().HashInstance());
758 } 764 }
759 765
760 index.GetGlobalStatistics(diskSize, uncompressedSize, countPatients, 766 index.GetGlobalStatistics(diskSize, uncompressedSize, countPatients,
761 countStudies, countSeries, countInstances); 767 countStudies, countSeries, countInstances);
762 ASSERT_EQ(10u, countPatients); 768 ASSERT_EQ(10u, countPatients);
818 824
819 ASSERT_EQ(0u, countInstances); 825 ASSERT_EQ(0u, countInstances);
820 ASSERT_EQ(0u, diskSize); 826 ASSERT_EQ(0u, diskSize);
821 827
822 { 828 {
829 ParsedDicomFile dicom(instance, GetDefaultDicomEncoding(), false /* be strict */);
830
831 DicomInstanceHasher hasher(instance);
832
823 DicomInstanceToStore toStore; 833 DicomInstanceToStore toStore;
824 toStore.SetSummary(instance); 834 toStore.SetParsedDicomFile(dicom);
825 toStore.SetOrigin(DicomInstanceOrigin::FromPlugins()); 835 toStore.SetOrigin(DicomInstanceOrigin::FromPlugins());
826 ASSERT_EQ(id, toStore.GetHasher().HashInstance()); 836 ASSERT_EQ(id, hasher.HashInstance());
827 837
828 std::string id2; 838 std::string id2;
829 ASSERT_EQ(StoreStatus_Success, context.Store(id2, toStore, StoreInstanceMode_Default)); 839 ASSERT_EQ(StoreStatus_Success, context.Store(id2, toStore, StoreInstanceMode_Default));
830 ASSERT_EQ(id, id2); 840 ASSERT_EQ(id, id2);
831 } 841 }
854 { 864 {
855 DicomMap instance2; 865 DicomMap instance2;
856 instance2.Assign(instance); 866 instance2.Assign(instance);
857 instance2.SetValue(DICOM_TAG_PATIENT_NAME, "overwritten", false); 867 instance2.SetValue(DICOM_TAG_PATIENT_NAME, "overwritten", false);
858 868
869 ParsedDicomFile dicom(instance2, GetDefaultDicomEncoding(), false /* be strict */);
870
859 DicomInstanceToStore toStore; 871 DicomInstanceToStore toStore;
860 toStore.SetSummary(instance2); 872 toStore.SetParsedDicomFile(dicom);
861 toStore.SetOrigin(DicomInstanceOrigin::FromPlugins()); 873 toStore.SetOrigin(DicomInstanceOrigin::FromPlugins());
862 874
863 std::string id2; 875 std::string id2;
864 ASSERT_EQ(overwrite ? StoreStatus_Success : StoreStatus_AlreadyStored, 876 ASSERT_EQ(overwrite ? StoreStatus_Success : StoreStatus_AlreadyStored,
865 context.Store(id2, toStore, StoreInstanceMode_Default)); 877 context.Store(id2, toStore, StoreInstanceMode_Default));