comparison OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp @ 4697:569d9ef165b1

Added "short", "simplify" and/or "full" options to control the format of DICOM tags wherever possible
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 18 Jun 2021 16:08:35 +0200
parents da1edb7d6332
children f0038043fb97 23aeffecb8cb
comparison
equal deleted inserted replaced
4696:dd6274412ff4 4697:569d9ef165b1
722 } 722 }
723 723
724 724
725 bool StatelessDatabaseOperations::ExpandResource(Json::Value& target, 725 bool StatelessDatabaseOperations::ExpandResource(Json::Value& target,
726 const std::string& publicId, 726 const std::string& publicId,
727 ResourceType level) 727 ResourceType level,
728 DicomToJsonFormat format)
728 { 729 {
729 class Operations : public ReadOnlyOperationsT4<bool&, Json::Value&, const std::string&, ResourceType> 730 class Operations : public ReadOnlyOperationsT5<
731 bool&, Json::Value&, const std::string&, ResourceType, DicomToJsonFormat>
730 { 732 {
731 private: 733 private:
732 static void MainDicomTagsToJson(ReadOnlyTransaction& transaction, 734 static void MainDicomTagsToJson(ReadOnlyTransaction& transaction,
733 Json::Value& target, 735 Json::Value& target,
734 int64_t resourceId, 736 int64_t resourceId,
735 ResourceType resourceType) 737 ResourceType resourceType,
736 { 738 DicomToJsonFormat format)
739 {
740 static const char* const MAIN_DICOM_TAGS = "MainDicomTags";
741 static const char* const PATIENT_MAIN_DICOM_TAGS = "PatientMainDicomTags";
742
737 DicomMap tags; 743 DicomMap tags;
738 transaction.GetMainDicomTags(tags, resourceId); 744 transaction.GetMainDicomTags(tags, resourceId);
739 745
740 if (resourceType == ResourceType_Study) 746 if (resourceType == ResourceType_Study)
741 { 747 {
742 DicomMap t1, t2; 748 DicomMap t1, t2;
743 tags.ExtractStudyInformation(t1); 749 tags.ExtractStudyInformation(t1);
744 tags.ExtractPatientInformation(t2); 750 tags.ExtractPatientInformation(t2);
745 751
746 target["MainDicomTags"] = Json::objectValue; 752 target[MAIN_DICOM_TAGS] = Json::objectValue;
747 FromDcmtkBridge::ToJson(target["MainDicomTags"], t1, true); 753 FromDcmtkBridge::ToJson(target[MAIN_DICOM_TAGS], t1, format);
748 754
749 target["PatientMainDicomTags"] = Json::objectValue; 755 target[PATIENT_MAIN_DICOM_TAGS] = Json::objectValue;
750 FromDcmtkBridge::ToJson(target["PatientMainDicomTags"], t2, true); 756 FromDcmtkBridge::ToJson(target[PATIENT_MAIN_DICOM_TAGS], t2, format);
751 } 757 }
752 else 758 else
753 { 759 {
754 target["MainDicomTags"] = Json::objectValue; 760 target[MAIN_DICOM_TAGS] = Json::objectValue;
755 FromDcmtkBridge::ToJson(target["MainDicomTags"], tags, true); 761 FromDcmtkBridge::ToJson(target[MAIN_DICOM_TAGS], tags, format);
756 } 762 }
757 } 763 }
758 764
759 765
760 static bool LookupStringMetadata(std::string& result, 766 static bool LookupStringMetadata(std::string& result,
947 throw OrthancException(ErrorCode_InternalError); 953 throw OrthancException(ErrorCode_InternalError);
948 } 954 }
949 955
950 // Record the remaining information 956 // Record the remaining information
951 target["ID"] = tuple.get<2>(); 957 target["ID"] = tuple.get<2>();
952 MainDicomTagsToJson(transaction, target, internalId, type); 958 MainDicomTagsToJson(transaction, target, internalId, type, tuple.get<4>());
953 959
954 std::string tmp; 960 std::string tmp;
955 961
956 if (LookupStringMetadata(tmp, metadata, MetadataType_AnonymizedFrom)) 962 if (LookupStringMetadata(tmp, metadata, MetadataType_AnonymizedFrom))
957 { 963 {
980 } 986 }
981 }; 987 };
982 988
983 bool found; 989 bool found;
984 Operations operations; 990 Operations operations;
985 operations.Apply(*this, found, target, publicId, level); 991 operations.Apply(*this, found, target, publicId, level, format);
986 return found; 992 return found;
987 } 993 }
988 994
989 995
990 void StatelessDatabaseOperations::GetAllMetadata(std::map<MetadataType, std::string>& target, 996 void StatelessDatabaseOperations::GetAllMetadata(std::map<MetadataType, std::string>& target,