Mercurial > hg > orthanc
comparison OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp @ 4934:94a7b681b340 more-tags
added configuration for extra main dicom tags + save signature in metadata + show warning if inconsistent main dicom tags
author | Alain Mazy <am@osimis.io> |
---|---|
date | Thu, 10 Mar 2022 09:03:24 +0100 |
parents | b7ce2bb6b881 |
children | acd3f72e2a21 |
comparison
equal
deleted
inserted
replaced
4933:312c6f4da888 | 4934:94a7b681b340 |
---|---|
939 | 939 |
940 default: | 940 default: |
941 throw OrthancException(ErrorCode_InternalError); | 941 throw OrthancException(ErrorCode_InternalError); |
942 } | 942 } |
943 | 943 |
944 // check the main dicom tags list has not changed since the resource was stored | |
945 std::string resourceMainDicomTagsSignature = DicomMap::GetDefaultMainDicomTagsSignature(type); | |
946 LookupStringMetadata(resourceMainDicomTagsSignature, metadata, MetadataType_MainDicomTagsSignature); | |
947 | |
948 if (resourceMainDicomTagsSignature != DicomMap::GetMainDicomTagsSignature(type)) | |
949 { | |
950 OrthancConfiguration::ReaderLock lock; | |
951 if (lock.GetConfiguration().IsInconsistentDicomTagsLogsEnabled()) | |
952 { | |
953 LOG(WARNING) << Orthanc::GetResourceTypeText(type, false , false) << " has been stored with another version of Main Dicom Tags list, you should POST to /" << Orthanc::GetResourceTypeText(type, true, false) << "/" << tuple.get<2>() << "/reconstruct to update the list of tags saved in DB. Some tags might be missing from this answer."; | |
954 } | |
955 } | |
956 | |
957 | |
944 // Record the remaining information | 958 // Record the remaining information |
945 target["ID"] = tuple.get<2>(); | 959 target["ID"] = tuple.get<2>(); |
946 MainDicomTagsToJson(transaction, target, internalId, type, tuple.get<4>()); | 960 MainDicomTagsToJson(transaction, target, internalId, type, tuple.get<4>()); |
947 | 961 |
948 std::string tmp; | 962 std::string tmp; |
2698 ResourcesContent content(false /* prevent the setting of metadata */); | 2712 ResourcesContent content(false /* prevent the setting of metadata */); |
2699 content.AddResource(patient, ResourceType_Patient, summary_); | 2713 content.AddResource(patient, ResourceType_Patient, summary_); |
2700 content.AddResource(study, ResourceType_Study, summary_); | 2714 content.AddResource(study, ResourceType_Study, summary_); |
2701 content.AddResource(series, ResourceType_Series, summary_); | 2715 content.AddResource(series, ResourceType_Series, summary_); |
2702 content.AddResource(instance, ResourceType_Instance, summary_); | 2716 content.AddResource(instance, ResourceType_Instance, summary_); |
2717 | |
2703 transaction.SetResourcesContent(content); | 2718 transaction.SetResourcesContent(content); |
2719 | |
2720 ReplaceMetadata(transaction, patient, MetadataType_MainDicomTagsSignature, DicomMap::GetMainDicomTagsSignature(ResourceType_Patient)); // New in Orthanc 1.11.0 | |
2721 ReplaceMetadata(transaction, study, MetadataType_MainDicomTagsSignature, DicomMap::GetMainDicomTagsSignature(ResourceType_Study)); // New in Orthanc 1.11.0 | |
2722 ReplaceMetadata(transaction, series, MetadataType_MainDicomTagsSignature, DicomMap::GetMainDicomTagsSignature(ResourceType_Series)); // New in Orthanc 1.11.0 | |
2723 ReplaceMetadata(transaction, instance, MetadataType_MainDicomTagsSignature, DicomMap::GetMainDicomTagsSignature(ResourceType_Instance)); // New in Orthanc 1.11.0 | |
2704 } | 2724 } |
2705 | 2725 |
2706 if (hasTransferSyntax_) | 2726 if (hasTransferSyntax_) |
2707 { | 2727 { |
2708 ReplaceMetadata(transaction, instance, MetadataType_Instance_TransferSyntax, GetTransferSyntaxUid(transferSyntax_)); | 2728 ReplaceMetadata(transaction, instance, MetadataType_Instance_TransferSyntax, GetTransferSyntaxUid(transferSyntax_)); |
2713 !value->IsNull() && | 2733 !value->IsNull() && |
2714 !value->IsBinary()) | 2734 !value->IsBinary()) |
2715 { | 2735 { |
2716 ReplaceMetadata(transaction, instance, MetadataType_Instance_SopClassUid, value->GetContent()); | 2736 ReplaceMetadata(transaction, instance, MetadataType_Instance_SopClassUid, value->GetContent()); |
2717 } | 2737 } |
2738 | |
2718 } | 2739 } |
2719 }; | 2740 }; |
2720 | 2741 |
2721 Operations operations(dicom); | 2742 Operations operations(dicom); |
2722 Apply(operations); | 2743 Apply(operations); |
3079 ResourcesContent content(true /* new resource, metadata can be set */); | 3100 ResourcesContent content(true /* new resource, metadata can be set */); |
3080 | 3101 |
3081 // Populate the tags of the newly-created resources | 3102 // Populate the tags of the newly-created resources |
3082 | 3103 |
3083 content.AddResource(instanceId, ResourceType_Instance, dicomSummary_); | 3104 content.AddResource(instanceId, ResourceType_Instance, dicomSummary_); |
3105 content.AddMetadata(instanceId, MetadataType_MainDicomTagsSignature, DicomMap::GetMainDicomTagsSignature(ResourceType_Instance)); // New in Orthanc 1.11.0 | |
3084 | 3106 |
3085 if (status.isNewSeries_) | 3107 if (status.isNewSeries_) |
3086 { | 3108 { |
3087 content.AddResource(status.seriesId_, ResourceType_Series, dicomSummary_); | 3109 content.AddResource(status.seriesId_, ResourceType_Series, dicomSummary_); |
3110 content.AddMetadata(status.seriesId_, MetadataType_MainDicomTagsSignature, DicomMap::GetMainDicomTagsSignature(ResourceType_Series)); // New in Orthanc 1.11.0 | |
3088 } | 3111 } |
3089 | 3112 |
3090 if (status.isNewStudy_) | 3113 if (status.isNewStudy_) |
3091 { | 3114 { |
3092 content.AddResource(status.studyId_, ResourceType_Study, dicomSummary_); | 3115 content.AddResource(status.studyId_, ResourceType_Study, dicomSummary_); |
3116 content.AddMetadata(status.studyId_, MetadataType_MainDicomTagsSignature, DicomMap::GetMainDicomTagsSignature(ResourceType_Study)); // New in Orthanc 1.11.0 | |
3093 } | 3117 } |
3094 | 3118 |
3095 if (status.isNewPatient_) | 3119 if (status.isNewPatient_) |
3096 { | 3120 { |
3097 content.AddResource(status.patientId_, ResourceType_Patient, dicomSummary_); | 3121 content.AddResource(status.patientId_, ResourceType_Patient, dicomSummary_); |
3122 content.AddMetadata(status.patientId_, MetadataType_MainDicomTagsSignature, DicomMap::GetMainDicomTagsSignature(ResourceType_Patient)); // New in Orthanc 1.11.0 | |
3098 } | 3123 } |
3099 | 3124 |
3100 | 3125 |
3101 // Attach the user-specified metadata | 3126 // Attach the user-specified metadata |
3102 // MORE_TAGS: TODO store the mainDicomTags list in metadata | |
3103 | 3127 |
3104 for (MetadataMap::const_iterator | 3128 for (MetadataMap::const_iterator |
3105 it = metadata_.begin(); it != metadata_.end(); ++it) | 3129 it = metadata_.begin(); it != metadata_.end(); ++it) |
3106 { | 3130 { |
3107 switch (it->first.first) | 3131 switch (it->first.first) |