Mercurial > hg > orthanc
comparison OrthancServer/ServerIndex.cpp @ 1744:b3de74dec2d5 db-changes
integration mainline->db-changes
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 26 Oct 2015 12:30:34 +0100 |
parents | 4941494b5dd8 ec66a16aa398 |
children | d143db00a794 |
comparison
equal
deleted
inserted
replaced
1729:54d78925cbb6 | 1744:b3de74dec2d5 |
---|---|
392 | 392 |
393 if ((value = dicomSummary.TestAndGetValue(DICOM_TAG_IMAGES_IN_ACQUISITION)) != NULL && | 393 if ((value = dicomSummary.TestAndGetValue(DICOM_TAG_IMAGES_IN_ACQUISITION)) != NULL && |
394 (value2 = dicomSummary.TestAndGetValue(DICOM_TAG_NUMBER_OF_TEMPORAL_POSITIONS)) != NULL) | 394 (value2 = dicomSummary.TestAndGetValue(DICOM_TAG_NUMBER_OF_TEMPORAL_POSITIONS)) != NULL) |
395 { | 395 { |
396 // Patch for series with temporal positions thanks to Will Ryder | 396 // Patch for series with temporal positions thanks to Will Ryder |
397 int64_t imagesInAcquisition = boost::lexical_cast<int64_t>(value->AsString()); | 397 int64_t imagesInAcquisition = boost::lexical_cast<int64_t>(value->GetContent()); |
398 int64_t countTemporalPositions = boost::lexical_cast<int64_t>(value2->AsString()); | 398 int64_t countTemporalPositions = boost::lexical_cast<int64_t>(value2->GetContent()); |
399 std::string expected = boost::lexical_cast<std::string>(imagesInAcquisition * countTemporalPositions); | 399 std::string expected = boost::lexical_cast<std::string>(imagesInAcquisition * countTemporalPositions); |
400 db.SetMetadata(series, MetadataType_Series_ExpectedNumberOfInstances, expected); | 400 db.SetMetadata(series, MetadataType_Series_ExpectedNumberOfInstances, expected); |
401 } | 401 } |
402 | 402 |
403 else if ((value = dicomSummary.TestAndGetValue(DICOM_TAG_NUMBER_OF_SLICES)) != NULL && | 403 else if ((value = dicomSummary.TestAndGetValue(DICOM_TAG_NUMBER_OF_SLICES)) != NULL && |
404 (value2 = dicomSummary.TestAndGetValue(DICOM_TAG_NUMBER_OF_TIME_SLICES)) != NULL) | 404 (value2 = dicomSummary.TestAndGetValue(DICOM_TAG_NUMBER_OF_TIME_SLICES)) != NULL) |
405 { | 405 { |
406 // Support of Cardio-PET images | 406 // Support of Cardio-PET images |
407 int64_t numberOfSlices = boost::lexical_cast<int64_t>(value->AsString()); | 407 int64_t numberOfSlices = boost::lexical_cast<int64_t>(value->GetContent()); |
408 int64_t numberOfTimeSlices = boost::lexical_cast<int64_t>(value2->AsString()); | 408 int64_t numberOfTimeSlices = boost::lexical_cast<int64_t>(value2->GetContent()); |
409 std::string expected = boost::lexical_cast<std::string>(numberOfSlices * numberOfTimeSlices); | 409 std::string expected = boost::lexical_cast<std::string>(numberOfSlices * numberOfTimeSlices); |
410 db.SetMetadata(series, MetadataType_Series_ExpectedNumberOfInstances, expected); | 410 db.SetMetadata(series, MetadataType_Series_ExpectedNumberOfInstances, expected); |
411 } | 411 } |
412 | 412 |
413 else if ((value = dicomSummary.TestAndGetValue(DICOM_TAG_CARDIAC_NUMBER_OF_IMAGES)) != NULL) | 413 else if ((value = dicomSummary.TestAndGetValue(DICOM_TAG_CARDIAC_NUMBER_OF_IMAGES)) != NULL) |
414 { | 414 { |
415 db.SetMetadata(series, MetadataType_Series_ExpectedNumberOfInstances, value->AsString()); | 415 db.SetMetadata(series, MetadataType_Series_ExpectedNumberOfInstances, value->GetContent()); |
416 } | 416 } |
417 } | 417 } |
418 catch (boost::bad_lexical_cast) | 418 catch (OrthancException&) |
419 { | |
420 } | |
421 catch (boost::bad_lexical_cast&) | |
419 { | 422 { |
420 } | 423 } |
421 } | 424 } |
422 | 425 |
423 | 426 |
766 | 769 |
767 const DicomValue* value; | 770 const DicomValue* value; |
768 if ((value = dicomSummary.TestAndGetValue(DICOM_TAG_INSTANCE_NUMBER)) != NULL || | 771 if ((value = dicomSummary.TestAndGetValue(DICOM_TAG_INSTANCE_NUMBER)) != NULL || |
769 (value = dicomSummary.TestAndGetValue(DICOM_TAG_IMAGE_INDEX)) != NULL) | 772 (value = dicomSummary.TestAndGetValue(DICOM_TAG_IMAGE_INDEX)) != NULL) |
770 { | 773 { |
771 db_.SetMetadata(instance, MetadataType_Instance_IndexInSeries, value->AsString()); | 774 if (!value->IsNull() && |
772 instanceMetadata[MetadataType_Instance_IndexInSeries] = value->AsString(); | 775 !value->IsBinary()) |
776 { | |
777 db_.SetMetadata(instance, MetadataType_Instance_IndexInSeries, value->GetContent()); | |
778 instanceMetadata[MetadataType_Instance_IndexInSeries] = value->GetContent(); | |
779 } | |
773 } | 780 } |
774 | 781 |
775 // Check whether the series of this new instance is now completed | 782 // Check whether the series of this new instance is now completed |
776 if (isNewSeries) | 783 if (isNewSeries) |
777 { | 784 { |
1195 db_.GetMainDicomTags(map, currentId); | 1202 db_.GetMainDicomTags(map, currentId); |
1196 | 1203 |
1197 switch (currentType) | 1204 switch (currentType) |
1198 { | 1205 { |
1199 case ResourceType_Patient: | 1206 case ResourceType_Patient: |
1200 patientId = map.GetValue(DICOM_TAG_PATIENT_ID).AsString(); | 1207 patientId = map.GetValue(DICOM_TAG_PATIENT_ID).GetContent(); |
1201 done = true; | 1208 done = true; |
1202 break; | 1209 break; |
1203 | 1210 |
1204 case ResourceType_Study: | 1211 case ResourceType_Study: |
1205 studyInstanceUid = map.GetValue(DICOM_TAG_STUDY_INSTANCE_UID).AsString(); | 1212 studyInstanceUid = map.GetValue(DICOM_TAG_STUDY_INSTANCE_UID).GetContent(); |
1206 currentType = ResourceType_Patient; | 1213 currentType = ResourceType_Patient; |
1207 break; | 1214 break; |
1208 | 1215 |
1209 case ResourceType_Series: | 1216 case ResourceType_Series: |
1210 seriesInstanceUid = map.GetValue(DICOM_TAG_SERIES_INSTANCE_UID).AsString(); | 1217 seriesInstanceUid = map.GetValue(DICOM_TAG_SERIES_INSTANCE_UID).GetContent(); |
1211 currentType = ResourceType_Study; | 1218 currentType = ResourceType_Study; |
1212 break; | 1219 break; |
1213 | 1220 |
1214 case ResourceType_Instance: | 1221 case ResourceType_Instance: |
1215 sopInstanceUid = map.GetValue(DICOM_TAG_SOP_INSTANCE_UID).AsString(); | 1222 sopInstanceUid = map.GetValue(DICOM_TAG_SOP_INSTANCE_UID).GetContent(); |
1216 currentType = ResourceType_Series; | 1223 currentType = ResourceType_Series; |
1217 break; | 1224 break; |
1218 | 1225 |
1219 default: | 1226 default: |
1220 throw OrthancException(ErrorCode_InternalError); | 1227 throw OrthancException(ErrorCode_InternalError); |