comparison OrthancServer/ServerToolbox.cpp @ 1717:3926e6317a43 db-changes

SetIdentifierTagInternal
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 19 Oct 2015 17:45:34 +0200
parents 2ca7888f8600
children a7c05bbfaf6a
comparison
equal deleted inserted replaced
1716:2ca7888f8600 1717:3926e6317a43
180 { 180 {
181 const DicomValue* value = tags.TestAndGetValue(tag); 181 const DicomValue* value = tags.TestAndGetValue(tag);
182 if (value != NULL && 182 if (value != NULL &&
183 !value->IsNull()) 183 !value->IsNull())
184 { 184 {
185 database.SetIdentifierTag(resource, tag, value->AsString()); 185 std::string s = value->AsString();
186 } 186
187 if (!tag.IsIdentifier())
188 {
189 s = NormalizeIdentifierTag(s);
190 }
191
192 database.SetIdentifierTag(resource, tag, s);
193 }
194 }
195
196
197 static void AttachPatientInformation(IDatabaseWrapper& database,
198 int64_t resource,
199 const DicomMap& dicomSummary)
200 {
201 DicomMap tags;
202 dicomSummary.ExtractPatientInformation(tags);
203 SetIdentifierTagInternal(database, resource, tags, DICOM_TAG_PATIENT_ID);
204 SetIdentifierTagInternal(database, resource, tags, DICOM_TAG_PATIENT_NAME);
205 SetIdentifierTagInternal(database, resource, tags, DICOM_TAG_PATIENT_BIRTH_DATE);
206 SetMainDicomTagsInternal(database, resource, tags);
187 } 207 }
188 208
189 209
190 void SetMainDicomTags(IDatabaseWrapper& database, 210 void SetMainDicomTags(IDatabaseWrapper& database,
191 int64_t resource, 211 int64_t resource,
197 DicomMap tags; 217 DicomMap tags;
198 218
199 switch (level) 219 switch (level)
200 { 220 {
201 case ResourceType_Patient: 221 case ResourceType_Patient:
202 dicomSummary.ExtractPatientInformation(tags); 222 AttachPatientInformation(database, resource, dicomSummary);
203 SetIdentifierTagInternal(database, resource, tags, DICOM_TAG_PATIENT_ID);
204 break; 223 break;
205 224
206 case ResourceType_Study: 225 case ResourceType_Study:
226 // Duplicate the patient tags at the study level (new in Orthanc 0.9.5 - db v6)
227 AttachPatientInformation(database, resource, dicomSummary);
228
207 dicomSummary.ExtractStudyInformation(tags); 229 dicomSummary.ExtractStudyInformation(tags);
208 SetIdentifierTagInternal(database, resource, tags, DICOM_TAG_STUDY_INSTANCE_UID); 230 SetIdentifierTagInternal(database, resource, tags, DICOM_TAG_STUDY_INSTANCE_UID);
209 SetIdentifierTagInternal(database, resource, tags, DICOM_TAG_STUDY_DESCRIPTION); // ??? 231 SetIdentifierTagInternal(database, resource, tags, DICOM_TAG_ACCESSION_NUMBER);
210 SetIdentifierTagInternal(database, resource, tags, DICOM_TAG_STUDY_DATE); // ??? 232 SetIdentifierTagInternal(database, resource, tags, DICOM_TAG_STUDY_DESCRIPTION);
233 SetIdentifierTagInternal(database, resource, tags, DICOM_TAG_STUDY_DATE);
211 break; 234 break;
212 235
213 case ResourceType_Series: 236 case ResourceType_Series:
214 dicomSummary.ExtractSeriesInformation(tags); 237 dicomSummary.ExtractSeriesInformation(tags);
215 SetIdentifierTagInternal(database, resource, tags, DICOM_TAG_SERIES_INSTANCE_UID); 238 SetIdentifierTagInternal(database, resource, tags, DICOM_TAG_SERIES_INSTANCE_UID);
223 default: 246 default:
224 throw OrthancException(ErrorCode_InternalError); 247 throw OrthancException(ErrorCode_InternalError);
225 } 248 }
226 249
227 SetMainDicomTagsInternal(database, resource, tags); 250 SetMainDicomTagsInternal(database, resource, tags);
228
229 // Duplicate the patient tags at the study level (new in Orthanc 0.9.5 - db v6)
230 if (level == ResourceType_Study)
231 {
232 dicomSummary.ExtractPatientInformation(tags);
233 SetMainDicomTagsInternal(database, resource, tags);
234 SetIdentifierTagInternal(database, resource, tags, DICOM_TAG_PATIENT_NAME); // ???
235 SetIdentifierTagInternal(database, resource, tags, DICOM_TAG_PATIENT_BIRTH_DATE); // ???
236 }
237 } 251 }
238 252
239 253
240 bool FindOneChildInstance(int64_t& result, 254 bool FindOneChildInstance(int64_t& result,
241 IDatabaseWrapper& database, 255 IDatabaseWrapper& database,
333 347
334 database.ClearMainDicomTags(resource); 348 database.ClearMainDicomTags(resource);
335 Toolbox::SetMainDicomTags(database, resource, level, dicomSummary); 349 Toolbox::SetMainDicomTags(database, resource, level, dicomSummary);
336 } 350 }
337 } 351 }
352
353
354 std::string NormalizeIdentifierTag(const std::string& value)
355 {
356 std::string s = Toolbox::ConvertToAscii(Toolbox::StripSpaces(value));
357 Toolbox::ToUpperCase(s);
358 return s;
359 }
338 } 360 }
339 } 361 }