Mercurial > hg > orthanc
annotate OrthancServer/Sources/ServerToolbox.cpp @ 5621:732ec9feeea8 find-refactoring
introduction of FindRequest::ChildrenRetrieveSpecification
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Sat, 11 May 2024 15:43:07 +0200 |
parents | c1ed59a5bdc2 |
children | f7adfb22e20e |
rev | line source |
---|---|
213
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 /** |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 * Orthanc - A Lightweight, RESTful DICOM Store |
1900 | 3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
1288
6e7e5ed91c2d
upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
5485
48b8dae6dc77
upgrade to year 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5286
diff
changeset
|
5 * Copyright (C) 2017-2024 Osimis S.A., Belgium |
48b8dae6dc77
upgrade to year 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5286
diff
changeset
|
6 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
213
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
7 * |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 * This program is free software: you can redistribute it and/or |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 * modify it under the terms of the GNU General Public License as |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 * published by the Free Software Foundation, either version 3 of the |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 * License, or (at your option) any later version. |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 * |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 * This program is distributed in the hope that it will be useful, but |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 * WITHOUT ANY WARRANTY; without even the implied warranty of |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 * General Public License for more details. |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 * |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 * You should have received a copy of the GNU General Public License |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
19 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 **/ |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 |
831
84513f2ee1f3
pch for unit tests and server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
824
diff
changeset
|
23 #include "PrecompiledHeadersServer.h" |
213
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 #include "ServerToolbox.h" |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 |
4045 | 26 #include "../../OrthancFramework/Sources/DicomParsing/ParsedDicomFile.h" |
27 #include "../../OrthancFramework/Sources/FileStorage/StorageAccessor.h" | |
4792
434843934307
Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents:
4640
diff
changeset
|
28 #include "../../OrthancFramework/Sources/FileStorage/StorageCache.h" |
4045 | 29 #include "../../OrthancFramework/Sources/Logging.h" |
30 #include "../../OrthancFramework/Sources/OrthancException.h" | |
3093
2e1808b6146a
reorganization of folders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3089
diff
changeset
|
31 #include "Database/IDatabaseWrapper.h" |
3099
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3094
diff
changeset
|
32 #include "Database/ResourcesContent.h" |
4140
0ddc5297a8ab
centralization of default parameters for JSON/DicomMap conversions from DCMTK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4139
diff
changeset
|
33 #include "OrthancConfiguration.h" |
3083
683d572424b6
IDatabaseWrapper::SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3061
diff
changeset
|
34 #include "ServerContext.h" |
213
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
35 |
234 | 36 #include <cassert> |
37 | |
213
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
38 namespace Orthanc |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
39 { |
3083
683d572424b6
IDatabaseWrapper::SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3061
diff
changeset
|
40 static const DicomTag PATIENT_IDENTIFIERS[] = |
683d572424b6
IDatabaseWrapper::SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3061
diff
changeset
|
41 { |
683d572424b6
IDatabaseWrapper::SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3061
diff
changeset
|
42 DICOM_TAG_PATIENT_ID, |
683d572424b6
IDatabaseWrapper::SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3061
diff
changeset
|
43 DICOM_TAG_PATIENT_NAME, |
683d572424b6
IDatabaseWrapper::SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3061
diff
changeset
|
44 DICOM_TAG_PATIENT_BIRTH_DATE |
683d572424b6
IDatabaseWrapper::SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3061
diff
changeset
|
45 }; |
683d572424b6
IDatabaseWrapper::SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3061
diff
changeset
|
46 |
683d572424b6
IDatabaseWrapper::SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3061
diff
changeset
|
47 static const DicomTag STUDY_IDENTIFIERS[] = |
683d572424b6
IDatabaseWrapper::SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3061
diff
changeset
|
48 { |
683d572424b6
IDatabaseWrapper::SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3061
diff
changeset
|
49 DICOM_TAG_PATIENT_ID, |
683d572424b6
IDatabaseWrapper::SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3061
diff
changeset
|
50 DICOM_TAG_PATIENT_NAME, |
683d572424b6
IDatabaseWrapper::SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3061
diff
changeset
|
51 DICOM_TAG_PATIENT_BIRTH_DATE, |
683d572424b6
IDatabaseWrapper::SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3061
diff
changeset
|
52 DICOM_TAG_STUDY_INSTANCE_UID, |
683d572424b6
IDatabaseWrapper::SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3061
diff
changeset
|
53 DICOM_TAG_ACCESSION_NUMBER, |
683d572424b6
IDatabaseWrapper::SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3061
diff
changeset
|
54 DICOM_TAG_STUDY_DESCRIPTION, |
683d572424b6
IDatabaseWrapper::SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3061
diff
changeset
|
55 DICOM_TAG_STUDY_DATE |
683d572424b6
IDatabaseWrapper::SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3061
diff
changeset
|
56 }; |
683d572424b6
IDatabaseWrapper::SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3061
diff
changeset
|
57 |
683d572424b6
IDatabaseWrapper::SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3061
diff
changeset
|
58 static const DicomTag SERIES_IDENTIFIERS[] = |
683d572424b6
IDatabaseWrapper::SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3061
diff
changeset
|
59 { |
683d572424b6
IDatabaseWrapper::SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3061
diff
changeset
|
60 DICOM_TAG_SERIES_INSTANCE_UID |
683d572424b6
IDatabaseWrapper::SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3061
diff
changeset
|
61 }; |
683d572424b6
IDatabaseWrapper::SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3061
diff
changeset
|
62 |
683d572424b6
IDatabaseWrapper::SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3061
diff
changeset
|
63 static const DicomTag INSTANCE_IDENTIFIERS[] = |
683d572424b6
IDatabaseWrapper::SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3061
diff
changeset
|
64 { |
683d572424b6
IDatabaseWrapper::SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3061
diff
changeset
|
65 DICOM_TAG_SOP_INSTANCE_UID |
683d572424b6
IDatabaseWrapper::SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3061
diff
changeset
|
66 }; |
683d572424b6
IDatabaseWrapper::SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3061
diff
changeset
|
67 |
683d572424b6
IDatabaseWrapper::SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3061
diff
changeset
|
68 |
2120 | 69 namespace ServerToolbox |
213
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
70 { |
1668
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
71 bool FindOneChildInstance(int64_t& result, |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4498
diff
changeset
|
72 IDatabaseWrapper::ITransaction& transaction, |
1668
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
73 int64_t resource, |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
74 ResourceType type) |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
75 { |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
76 for (;;) |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
77 { |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
78 if (type == ResourceType_Instance) |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
79 { |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
80 result = resource; |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
81 return true; |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
82 } |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
83 |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
84 std::list<int64_t> children; |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4498
diff
changeset
|
85 transaction.GetChildrenInternalId(children, resource); |
1668
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
86 if (children.empty()) |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
87 { |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
88 return false; |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
89 } |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
90 |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
91 resource = children.front(); |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
92 type = GetChildResourceType(type); |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
93 } |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
94 } |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
95 |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
96 |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4498
diff
changeset
|
97 void ReconstructMainDicomTags(IDatabaseWrapper::ITransaction& transaction, |
1668
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
98 IStorageArea& storageArea, |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
99 ResourceType level) |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
100 { |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
101 // WARNING: The database should be locked with a transaction! |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
102 |
2129
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2123
diff
changeset
|
103 // TODO: This function might consume much memory if level == |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2123
diff
changeset
|
104 // ResourceType_Instance. To improve this, first download the |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2123
diff
changeset
|
105 // list of studies, then remove the instances for each single |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2123
diff
changeset
|
106 // study (check out OrthancRestApi::InvalidateTags for an |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2123
diff
changeset
|
107 // example). Take this improvement into consideration for the |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2123
diff
changeset
|
108 // next upgrade of the database schema. |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2123
diff
changeset
|
109 |
4934
94a7b681b340
added configuration for extra main dicom tags + save signature in metadata + show warning if inconsistent main dicom tags
Alain Mazy <am@osimis.io>
parents:
4932
diff
changeset
|
110 const char* plural = Orthanc::GetResourceTypeText(level, true, true); |
1669
a412ad57f0f9
refactoring of sample plugins, OrthancPluginReconstructMainDicomTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
111 |
a412ad57f0f9
refactoring of sample plugins, OrthancPluginReconstructMainDicomTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
112 LOG(WARNING) << "Upgrade: Reconstructing the main DICOM tags of all the " << plural << "..."; |
a412ad57f0f9
refactoring of sample plugins, OrthancPluginReconstructMainDicomTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
113 |
1668
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
114 std::list<std::string> resources; |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4498
diff
changeset
|
115 transaction.GetAllPublicIds(resources, level); |
1668
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
116 |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
117 for (std::list<std::string>::const_iterator |
1847 | 118 it = resources.begin(); it != resources.end(); ++it) |
1668
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
119 { |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
120 // Locate the resource and one of its child instances |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
121 int64_t resource, instance; |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
122 ResourceType tmp; |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
123 |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4498
diff
changeset
|
124 if (!transaction.LookupResource(resource, tmp, *it) || |
1668
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
125 tmp != level || |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4498
diff
changeset
|
126 !FindOneChildInstance(instance, transaction, resource, level)) |
1668
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
127 { |
2955 | 128 throw OrthancException(ErrorCode_InternalError, |
129 "Cannot find an instance for " + | |
130 std::string(EnumerationToString(level)) + | |
131 " with identifier " + *it); | |
1668
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
132 } |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
133 |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
134 // Get the DICOM file attached to some instances in the resource |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
135 FileInfo attachment; |
4627
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
136 int64_t revision; |
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4623
diff
changeset
|
137 if (!transaction.LookupAttachment(attachment, revision, instance, FileContentType_Dicom)) |
1668
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
138 { |
2955 | 139 throw OrthancException(ErrorCode_InternalError, |
140 "Cannot retrieve the DICOM file associated with instance " + | |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4498
diff
changeset
|
141 transaction.GetPublicId(instance)); |
1668
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
142 } |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
143 |
1870
a6c431193c79
Improved logging information if upgrade fails
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1860
diff
changeset
|
144 try |
a6c431193c79
Improved logging information if upgrade fails
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1860
diff
changeset
|
145 { |
a6c431193c79
Improved logging information if upgrade fails
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1860
diff
changeset
|
146 // Read and parse the content of the DICOM file |
5184
dd085f7e7e71
cleaning new constructors of StorageAccessor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5048
diff
changeset
|
147 StorageAccessor accessor(storageArea); // no cache |
1673
0bbcfd9695e5
UpgradeDatabase in the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1669
diff
changeset
|
148 |
1870
a6c431193c79
Improved logging information if upgrade fails
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1860
diff
changeset
|
149 std::string content; |
a6c431193c79
Improved logging information if upgrade fails
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1860
diff
changeset
|
150 accessor.Read(content, attachment); |
a6c431193c79
Improved logging information if upgrade fails
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1860
diff
changeset
|
151 |
a6c431193c79
Improved logging information if upgrade fails
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1860
diff
changeset
|
152 ParsedDicomFile dicom(content); |
1668
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
153 |
1870
a6c431193c79
Improved logging information if upgrade fails
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1860
diff
changeset
|
154 // Update the tags of this resource |
a6c431193c79
Improved logging information if upgrade fails
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1860
diff
changeset
|
155 DicomMap dicomSummary; |
4140
0ddc5297a8ab
centralization of default parameters for JSON/DicomMap conversions from DCMTK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4139
diff
changeset
|
156 OrthancConfiguration::DefaultExtractDicomSummary(dicomSummary, dicom); |
1668
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
157 |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4498
diff
changeset
|
158 transaction.ClearMainDicomTags(resource); |
3083
683d572424b6
IDatabaseWrapper::SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3061
diff
changeset
|
159 |
4623
95ffe3b6ef7c
handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4591
diff
changeset
|
160 ResourcesContent tags(false /* prevent the setting of metadata */); |
4934
94a7b681b340
added configuration for extra main dicom tags + save signature in metadata + show warning if inconsistent main dicom tags
Alain Mazy <am@osimis.io>
parents:
4932
diff
changeset
|
161 tags.AddResource(resource, level, dicomSummary); |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4498
diff
changeset
|
162 transaction.SetResourcesContent(tags); |
4934
94a7b681b340
added configuration for extra main dicom tags + save signature in metadata + show warning if inconsistent main dicom tags
Alain Mazy <am@osimis.io>
parents:
4932
diff
changeset
|
163 |
94a7b681b340
added configuration for extra main dicom tags + save signature in metadata + show warning if inconsistent main dicom tags
Alain Mazy <am@osimis.io>
parents:
4932
diff
changeset
|
164 transaction.DeleteMetadata(resource, MetadataType_MainDicomTagsSignature); |
94a7b681b340
added configuration for extra main dicom tags + save signature in metadata + show warning if inconsistent main dicom tags
Alain Mazy <am@osimis.io>
parents:
4932
diff
changeset
|
165 transaction.SetMetadata(resource, MetadataType_MainDicomTagsSignature, DicomMap::GetMainDicomTagsSignature(level), 0); |
1870
a6c431193c79
Improved logging information if upgrade fails
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1860
diff
changeset
|
166 } |
a6c431193c79
Improved logging information if upgrade fails
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1860
diff
changeset
|
167 catch (OrthancException&) |
a6c431193c79
Improved logging information if upgrade fails
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1860
diff
changeset
|
168 { |
a6c431193c79
Improved logging information if upgrade fails
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1860
diff
changeset
|
169 LOG(ERROR) << "Cannot decode the DICOM file with UUID " << attachment.GetUuid() |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4498
diff
changeset
|
170 << " associated with instance " << transaction.GetPublicId(instance); |
1870
a6c431193c79
Improved logging information if upgrade fails
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1860
diff
changeset
|
171 throw; |
a6c431193c79
Improved logging information if upgrade fails
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1860
diff
changeset
|
172 } |
213
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
173 } |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
174 } |
2121 | 175 |
176 | |
177 void LoadIdentifiers(const DicomTag*& tags, | |
178 size_t& size, | |
179 ResourceType level) | |
180 { | |
181 switch (level) | |
182 { | |
183 case ResourceType_Patient: | |
3083
683d572424b6
IDatabaseWrapper::SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3061
diff
changeset
|
184 tags = PATIENT_IDENTIFIERS; |
683d572424b6
IDatabaseWrapper::SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3061
diff
changeset
|
185 size = sizeof(PATIENT_IDENTIFIERS) / sizeof(DicomTag); |
2121 | 186 break; |
187 | |
188 case ResourceType_Study: | |
3083
683d572424b6
IDatabaseWrapper::SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3061
diff
changeset
|
189 tags = STUDY_IDENTIFIERS; |
683d572424b6
IDatabaseWrapper::SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3061
diff
changeset
|
190 size = sizeof(STUDY_IDENTIFIERS) / sizeof(DicomTag); |
2121 | 191 break; |
192 | |
193 case ResourceType_Series: | |
3083
683d572424b6
IDatabaseWrapper::SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3061
diff
changeset
|
194 tags = SERIES_IDENTIFIERS; |
683d572424b6
IDatabaseWrapper::SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3061
diff
changeset
|
195 size = sizeof(SERIES_IDENTIFIERS) / sizeof(DicomTag); |
2121 | 196 break; |
197 | |
198 case ResourceType_Instance: | |
3083
683d572424b6
IDatabaseWrapper::SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3061
diff
changeset
|
199 tags = INSTANCE_IDENTIFIERS; |
683d572424b6
IDatabaseWrapper::SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3061
diff
changeset
|
200 size = sizeof(INSTANCE_IDENTIFIERS) / sizeof(DicomTag); |
2121 | 201 break; |
202 | |
203 default: | |
204 throw OrthancException(ErrorCode_ParameterOutOfRange); | |
205 } | |
206 } | |
207 | |
208 | |
209 std::string NormalizeIdentifier(const std::string& value) | |
210 { | |
211 std::string t; | |
212 t.reserve(value.size()); | |
213 | |
5284
56cd3444a2d8
NormalizeIdentifier: suggestion for future implementations
Alain Mazy <am@osimis.io>
parents:
5277
diff
changeset
|
214 #if 0 |
56cd3444a2d8
NormalizeIdentifier: suggestion for future implementations
Alain Mazy <am@osimis.io>
parents:
5277
diff
changeset
|
215 // This version solves some indexing issue (https://discourse.orthanc-server.org/t/postgress-index-effectively-disabled-when-searching-for-greek-names/3371) |
56cd3444a2d8
NormalizeIdentifier: suggestion for future implementations
Alain Mazy <am@osimis.io>
parents:
5277
diff
changeset
|
216 // and seems functional: I could run the integration tests with both SQLite and PG + the DicomWeb tests with PG. |
56cd3444a2d8
NormalizeIdentifier: suggestion for future implementations
Alain Mazy <am@osimis.io>
parents:
5277
diff
changeset
|
217 // However, it can not go into production because NormalizeIdentifier is used both at ingest time and at search time; |
56cd3444a2d8
NormalizeIdentifier: suggestion for future implementations
Alain Mazy <am@osimis.io>
parents:
5277
diff
changeset
|
218 // therefore, if we change it while we have an already populated DB, the searches won't work anymore and, on very large |
56cd3444a2d8
NormalizeIdentifier: suggestion for future implementations
Alain Mazy <am@osimis.io>
parents:
5277
diff
changeset
|
219 // systems, running the Housekeeper to rebuild the indexes might take months ... |
56cd3444a2d8
NormalizeIdentifier: suggestion for future implementations
Alain Mazy <am@osimis.io>
parents:
5277
diff
changeset
|
220 // We keep it here because it might be handy once we refactor the DicomIdentifier searches in the future. |
2121 | 221 for (size_t i = 0; i < value.size(); i++) |
222 { | |
223 if (value[i] == '%' || | |
224 value[i] == '_') | |
225 { | |
226 t.push_back(' '); // These characters might break wildcard queries in SQL | |
227 } | |
5284
56cd3444a2d8
NormalizeIdentifier: suggestion for future implementations
Alain Mazy <am@osimis.io>
parents:
5277
diff
changeset
|
228 else if (//isascii(value[i]) && |
2121 | 229 !iscntrl(value[i]) && |
230 (!isspace(value[i]) || value[i] == ' ')) | |
231 { | |
232 t.push_back(value[i]); | |
233 } | |
234 } | |
235 | |
5284
56cd3444a2d8
NormalizeIdentifier: suggestion for future implementations
Alain Mazy <am@osimis.io>
parents:
5277
diff
changeset
|
236 //Toolbox::ToUpperCase(t); |
56cd3444a2d8
NormalizeIdentifier: suggestion for future implementations
Alain Mazy <am@osimis.io>
parents:
5277
diff
changeset
|
237 t = Toolbox::ToUpperCaseWithAccents(t); |
56cd3444a2d8
NormalizeIdentifier: suggestion for future implementations
Alain Mazy <am@osimis.io>
parents:
5277
diff
changeset
|
238 #else |
56cd3444a2d8
NormalizeIdentifier: suggestion for future implementations
Alain Mazy <am@osimis.io>
parents:
5277
diff
changeset
|
239 for (size_t i = 0; i < value.size(); i++) |
56cd3444a2d8
NormalizeIdentifier: suggestion for future implementations
Alain Mazy <am@osimis.io>
parents:
5277
diff
changeset
|
240 { |
56cd3444a2d8
NormalizeIdentifier: suggestion for future implementations
Alain Mazy <am@osimis.io>
parents:
5277
diff
changeset
|
241 if (value[i] == '%' || |
56cd3444a2d8
NormalizeIdentifier: suggestion for future implementations
Alain Mazy <am@osimis.io>
parents:
5277
diff
changeset
|
242 value[i] == '_') |
56cd3444a2d8
NormalizeIdentifier: suggestion for future implementations
Alain Mazy <am@osimis.io>
parents:
5277
diff
changeset
|
243 { |
56cd3444a2d8
NormalizeIdentifier: suggestion for future implementations
Alain Mazy <am@osimis.io>
parents:
5277
diff
changeset
|
244 t.push_back(' '); // These characters might break wildcard queries in SQL |
56cd3444a2d8
NormalizeIdentifier: suggestion for future implementations
Alain Mazy <am@osimis.io>
parents:
5277
diff
changeset
|
245 } |
5285
bb07c12e3472
re-enabled the old NormalizeIdentifier code
Alain Mazy <am@osimis.io>
parents:
5284
diff
changeset
|
246 else if (isascii(value[i]) && |
bb07c12e3472
re-enabled the old NormalizeIdentifier code
Alain Mazy <am@osimis.io>
parents:
5284
diff
changeset
|
247 !iscntrl(value[i]) && |
5284
56cd3444a2d8
NormalizeIdentifier: suggestion for future implementations
Alain Mazy <am@osimis.io>
parents:
5277
diff
changeset
|
248 (!isspace(value[i]) || value[i] == ' ')) |
56cd3444a2d8
NormalizeIdentifier: suggestion for future implementations
Alain Mazy <am@osimis.io>
parents:
5277
diff
changeset
|
249 { |
56cd3444a2d8
NormalizeIdentifier: suggestion for future implementations
Alain Mazy <am@osimis.io>
parents:
5277
diff
changeset
|
250 t.push_back(value[i]); |
56cd3444a2d8
NormalizeIdentifier: suggestion for future implementations
Alain Mazy <am@osimis.io>
parents:
5277
diff
changeset
|
251 } |
56cd3444a2d8
NormalizeIdentifier: suggestion for future implementations
Alain Mazy <am@osimis.io>
parents:
5277
diff
changeset
|
252 } |
56cd3444a2d8
NormalizeIdentifier: suggestion for future implementations
Alain Mazy <am@osimis.io>
parents:
5277
diff
changeset
|
253 |
5286 | 254 Toolbox::ToUpperCase(t); |
5284
56cd3444a2d8
NormalizeIdentifier: suggestion for future implementations
Alain Mazy <am@osimis.io>
parents:
5277
diff
changeset
|
255 #endif |
2121 | 256 |
257 return Toolbox::StripSpaces(t); | |
258 } | |
259 | |
260 | |
261 bool IsIdentifier(const DicomTag& tag, | |
262 ResourceType level) | |
263 { | |
264 const DicomTag* tags; | |
265 size_t size; | |
266 | |
267 LoadIdentifiers(tags, size, level); | |
268 | |
269 for (size_t i = 0; i < size; i++) | |
270 { | |
271 if (tag == tags[i]) | |
272 { | |
273 return true; | |
274 } | |
275 } | |
276 | |
277 return false; | |
278 } | |
2209
e3fd5bc429a2
URI to reconstruct the main DICOM tags, the JSON summary and the metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2129
diff
changeset
|
279 |
e3fd5bc429a2
URI to reconstruct the main DICOM tags, the JSON summary and the metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2129
diff
changeset
|
280 |
e3fd5bc429a2
URI to reconstruct the main DICOM tags, the JSON summary and the metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2129
diff
changeset
|
281 void ReconstructResource(ServerContext& context, |
4988
8fba26292a9f
Housekeeper plugin: finalizing + integration tests ok
Alain Mazy <am@osimis.io>
parents:
4934
diff
changeset
|
282 const std::string& resource, |
5558
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5485
diff
changeset
|
283 bool reconstructFiles, |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5485
diff
changeset
|
284 bool limitToThisLevelDicomTags, |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5485
diff
changeset
|
285 ResourceType limitToLevel) |
2209
e3fd5bc429a2
URI to reconstruct the main DICOM tags, the JSON summary and the metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2129
diff
changeset
|
286 { |
e3fd5bc429a2
URI to reconstruct the main DICOM tags, the JSON summary and the metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2129
diff
changeset
|
287 LOG(WARNING) << "Reconstructing resource " << resource; |
e3fd5bc429a2
URI to reconstruct the main DICOM tags, the JSON summary and the metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2129
diff
changeset
|
288 |
e3fd5bc429a2
URI to reconstruct the main DICOM tags, the JSON summary and the metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2129
diff
changeset
|
289 std::list<std::string> instances; |
e3fd5bc429a2
URI to reconstruct the main DICOM tags, the JSON summary and the metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2129
diff
changeset
|
290 context.GetIndex().GetChildInstances(instances, resource); |
e3fd5bc429a2
URI to reconstruct the main DICOM tags, the JSON summary and the metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2129
diff
changeset
|
291 |
5558
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5485
diff
changeset
|
292 |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5485
diff
changeset
|
293 if (limitToThisLevelDicomTags && instances.size() > 0) // in this case, we only need to rebuild one instance ! |
2209
e3fd5bc429a2
URI to reconstruct the main DICOM tags, the JSON summary and the metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2129
diff
changeset
|
294 { |
5558
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5485
diff
changeset
|
295 ServerContext::DicomCacheLocker locker(context, instances.front()); |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5485
diff
changeset
|
296 context.GetIndex().ReconstructInstance(locker.GetDicom(), true, limitToLevel); |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5485
diff
changeset
|
297 } |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5485
diff
changeset
|
298 else |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5485
diff
changeset
|
299 { |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5485
diff
changeset
|
300 for (std::list<std::string>::const_iterator |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5485
diff
changeset
|
301 it = instances.begin(); it != instances.end(); ++it) |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5485
diff
changeset
|
302 { |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5485
diff
changeset
|
303 ServerContext::DicomCacheLocker locker(context, *it); |
2209
e3fd5bc429a2
URI to reconstruct the main DICOM tags, the JSON summary and the metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2129
diff
changeset
|
304 |
5558
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5485
diff
changeset
|
305 // Delay the reconstruction of DICOM-as-JSON to its next access through "ServerContext" |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5485
diff
changeset
|
306 context.GetIndex().DeleteAttachment(*it, FileContentType_DicomAsJson, false /* no revision */, |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5485
diff
changeset
|
307 -1 /* dummy revision */, "" /* dummy MD5 */); |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5485
diff
changeset
|
308 |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5485
diff
changeset
|
309 context.GetIndex().ReconstructInstance(locker.GetDicom(), false, ResourceType_Instance /* dummy */); |
4988
8fba26292a9f
Housekeeper plugin: finalizing + integration tests ok
Alain Mazy <am@osimis.io>
parents:
4934
diff
changeset
|
310 |
5558
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5485
diff
changeset
|
311 if (reconstructFiles) |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5485
diff
changeset
|
312 { |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5485
diff
changeset
|
313 std::string resultPublicId; // ignored |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5485
diff
changeset
|
314 std::unique_ptr<DicomInstanceToStore> dicomInstancetoStore(DicomInstanceToStore::CreateFromParsedDicomFile(locker.GetDicom())); |
4988
8fba26292a9f
Housekeeper plugin: finalizing + integration tests ok
Alain Mazy <am@osimis.io>
parents:
4934
diff
changeset
|
315 |
5558
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5485
diff
changeset
|
316 // TODO: TranscodeAndStore and specifically ServerIndex::Store have been "poluted" by the isReconstruct parameter |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5485
diff
changeset
|
317 // we should very likely refactor it |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5485
diff
changeset
|
318 context.TranscodeAndStore(resultPublicId, dicomInstancetoStore.get(), StoreInstanceMode_OverwriteDuplicate, true); |
c1ed59a5bdc2
new LimitToThisLevelMainDicomTags reconstruct mode + * Housekeeper plugin: Added an option LimitMainDicomTagsReconstructLevel
Alain Mazy <am@orthanc.team>
parents:
5485
diff
changeset
|
319 } |
4988
8fba26292a9f
Housekeeper plugin: finalizing + integration tests ok
Alain Mazy <am@osimis.io>
parents:
4934
diff
changeset
|
320 } |
2209
e3fd5bc429a2
URI to reconstruct the main DICOM tags, the JSON summary and the metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2129
diff
changeset
|
321 } |
e3fd5bc429a2
URI to reconstruct the main DICOM tags, the JSON summary and the metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2129
diff
changeset
|
322 } |
5244
72dfa0ac84eb
lookup for labels in orthanc explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5224
diff
changeset
|
323 |
72dfa0ac84eb
lookup for labels in orthanc explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5224
diff
changeset
|
324 |
72dfa0ac84eb
lookup for labels in orthanc explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5224
diff
changeset
|
325 bool IsValidLabel(const std::string& label) |
72dfa0ac84eb
lookup for labels in orthanc explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5224
diff
changeset
|
326 { |
72dfa0ac84eb
lookup for labels in orthanc explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5224
diff
changeset
|
327 if (label.empty()) |
72dfa0ac84eb
lookup for labels in orthanc explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5224
diff
changeset
|
328 { |
72dfa0ac84eb
lookup for labels in orthanc explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5224
diff
changeset
|
329 return false; |
72dfa0ac84eb
lookup for labels in orthanc explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5224
diff
changeset
|
330 } |
5247
eb2684260c19
support labels for mysql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5244
diff
changeset
|
331 |
eb2684260c19
support labels for mysql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5244
diff
changeset
|
332 if (label.size() > 64) |
eb2684260c19
support labels for mysql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5244
diff
changeset
|
333 { |
eb2684260c19
support labels for mysql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5244
diff
changeset
|
334 // This limitation is for MySQL, which cannot use a TEXT |
eb2684260c19
support labels for mysql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5244
diff
changeset
|
335 // column of undefined length as a primary key |
eb2684260c19
support labels for mysql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5244
diff
changeset
|
336 return false; |
eb2684260c19
support labels for mysql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5244
diff
changeset
|
337 } |
5244
72dfa0ac84eb
lookup for labels in orthanc explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5224
diff
changeset
|
338 |
72dfa0ac84eb
lookup for labels in orthanc explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5224
diff
changeset
|
339 for (size_t i = 0; i < label.size(); i++) |
72dfa0ac84eb
lookup for labels in orthanc explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5224
diff
changeset
|
340 { |
5250 | 341 if (!(label[i] == '_' || |
5244
72dfa0ac84eb
lookup for labels in orthanc explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5224
diff
changeset
|
342 label[i] == '-' || |
72dfa0ac84eb
lookup for labels in orthanc explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5224
diff
changeset
|
343 (label[i] >= 'a' && label[i] <= 'z') || |
72dfa0ac84eb
lookup for labels in orthanc explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5224
diff
changeset
|
344 (label[i] >= 'A' && label[i] <= 'Z') || |
72dfa0ac84eb
lookup for labels in orthanc explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5224
diff
changeset
|
345 (label[i] >= '0' && label[i] <= '9'))) |
72dfa0ac84eb
lookup for labels in orthanc explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5224
diff
changeset
|
346 { |
72dfa0ac84eb
lookup for labels in orthanc explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5224
diff
changeset
|
347 return false; |
72dfa0ac84eb
lookup for labels in orthanc explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5224
diff
changeset
|
348 } |
72dfa0ac84eb
lookup for labels in orthanc explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5224
diff
changeset
|
349 } |
72dfa0ac84eb
lookup for labels in orthanc explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5224
diff
changeset
|
350 |
72dfa0ac84eb
lookup for labels in orthanc explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5224
diff
changeset
|
351 return true; |
72dfa0ac84eb
lookup for labels in orthanc explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5224
diff
changeset
|
352 } |
72dfa0ac84eb
lookup for labels in orthanc explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5224
diff
changeset
|
353 |
72dfa0ac84eb
lookup for labels in orthanc explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5224
diff
changeset
|
354 |
72dfa0ac84eb
lookup for labels in orthanc explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5224
diff
changeset
|
355 void CheckValidLabel(const std::string& label) |
72dfa0ac84eb
lookup for labels in orthanc explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5224
diff
changeset
|
356 { |
72dfa0ac84eb
lookup for labels in orthanc explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5224
diff
changeset
|
357 if (!IsValidLabel(label)) |
72dfa0ac84eb
lookup for labels in orthanc explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5224
diff
changeset
|
358 { |
72dfa0ac84eb
lookup for labels in orthanc explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5224
diff
changeset
|
359 throw OrthancException(ErrorCode_ParameterOutOfRange, |
72dfa0ac84eb
lookup for labels in orthanc explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5224
diff
changeset
|
360 "A label must be a non-empty, alphanumeric string, " |
5250 | 361 "possibly with '_' or '-' characters, " |
5247
eb2684260c19
support labels for mysql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5244
diff
changeset
|
362 "with maximum 64 characters, but got: " + label); |
5244
72dfa0ac84eb
lookup for labels in orthanc explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5224
diff
changeset
|
363 } |
72dfa0ac84eb
lookup for labels in orthanc explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5224
diff
changeset
|
364 } |
213
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
365 } |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
366 } |