comparison Core/DicomFormat/DicomMap.cpp @ 2380:96b3ec054b69

reorganization in macros
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 29 Aug 2017 16:49:44 +0200
parents a3a65de1840f
children cad393b41bc3
comparison
equal deleted inserted replaced
2379:4900688827a8 2380:96b3ec054b69
34 #include "../PrecompiledHeaders.h" 34 #include "../PrecompiledHeaders.h"
35 #include "DicomMap.h" 35 #include "DicomMap.h"
36 36
37 #include <stdio.h> 37 #include <stdio.h>
38 #include <memory> 38 #include <memory>
39
39 #include "../Endianness.h" 40 #include "../Endianness.h"
41 #include "../Logging.h"
40 #include "../OrthancException.h" 42 #include "../OrthancException.h"
41 43
42 44
43 namespace Orthanc 45 namespace Orthanc
44 { 46 {
779 } 781 }
780 } 782 }
781 783
782 return true; 784 return true;
783 } 785 }
786
787
788 static std::string ValueAsString(const DicomMap& summary,
789 const DicomTag& tag)
790 {
791 const DicomValue& value = summary.GetValue(tag);
792 if (value.IsNull())
793 {
794 return "(null)";
795 }
796 else
797 {
798 return value.GetContent();
799 }
800 }
801
802
803 void DicomMap::LogMissingTagsForStore() const
804 {
805 std::string s, t;
806
807 if (HasTag(DICOM_TAG_PATIENT_ID))
808 {
809 if (t.size() > 0)
810 t += ", ";
811 t += "PatientID=" + ValueAsString(*this, DICOM_TAG_PATIENT_ID);
812 }
813 else
814 {
815 if (s.size() > 0)
816 s += ", ";
817 s += "PatientID";
818 }
819
820 if (HasTag(DICOM_TAG_STUDY_INSTANCE_UID))
821 {
822 if (t.size() > 0)
823 t += ", ";
824 t += "StudyInstanceUID=" + ValueAsString(*this, DICOM_TAG_STUDY_INSTANCE_UID);
825 }
826 else
827 {
828 if (s.size() > 0)
829 s += ", ";
830 s += "StudyInstanceUID";
831 }
832
833 if (HasTag(DICOM_TAG_SERIES_INSTANCE_UID))
834 {
835 if (t.size() > 0)
836 t += ", ";
837 t += "SeriesInstanceUID=" + ValueAsString(*this, DICOM_TAG_SERIES_INSTANCE_UID);
838 }
839 else
840 {
841 if (s.size() > 0)
842 s += ", ";
843 s += "SeriesInstanceUID";
844 }
845
846 if (HasTag(DICOM_TAG_SOP_INSTANCE_UID))
847 {
848 if (t.size() > 0)
849 t += ", ";
850 t += "SOPInstanceUID=" + ValueAsString(*this, DICOM_TAG_SOP_INSTANCE_UID);
851 }
852 else
853 {
854 if (s.size() > 0)
855 s += ", ";
856 s += "SOPInstanceUID";
857 }
858
859 if (t.size() == 0)
860 {
861 LOG(ERROR) << "Store has failed because all the required tags (" << s << ") are missing (is it a DICOMDIR file?)";
862 }
863 else
864 {
865 LOG(ERROR) << "Store has failed because required tags (" << s << ") are missing for the following instance: " << t;
866 }
867 }
784 } 868 }