1 /*=========================================================================
2 
3   Program: GDCM (Grassroots DICOM). A DICOM library
4 
5   Copyright (c) 2006-2011 Mathieu Malaterre
6   All rights reserved.
7   See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
8 
9      This software is distributed WITHOUT ANY WARRANTY; without even
10      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11      PURPOSE.  See the above copyright notice for more information.
12 
13 =========================================================================*/
14 #include "gdcmEquipmentManufacturer.h"
15 
16 #include "gdcmAttribute.h"
17 #include "gdcmSystem.h"
18 
19 namespace gdcm
20 {
21 
22 struct Mapping
23 {
24   EquipmentManufacturer::Type type;
25   size_t nstrings;
26   const char* const *strings;
27 };
28 
29 static const char* const fuji[] = {"FUJI", "FUJI PHOTO FILM Co., ltd.","FUJIFILM Corporation","FUJI PHOTO FILM CO. LTD."};
30 static const char* const gems[] = {"GE MEDICAL SYSTEMS", "GE_MEDICAL_SYSTEMS", "GE Healthcare", "G.E. Medical Systems","GE Vingmed Ultrasound","\"GE Healthcare\""/*sigh*/};
31 static const char* const hitachi[] = {"Hitachi Medical Corporation","ALOKA CO., LTD."};
32 static const char* const kodak[] = {"Kodak"};
33 static const char* const pms[] = { "Philips Medical Systems", "Philips Healthcare", "Philips Medical Systems, Inc.","Philips","Picker International, Inc." };
34 static const char* const siemens[] = { "SIEMENS", "Siemens HealthCare GmbH", "Siemens Health Services","Acuson" };
35 static const char* const marconi[] = { "Marconi Medical Systems, Inc." };
36 static const char* const toshiba[] = { "TOSHIBA_MEC", "Toshiba" };
37 
38 #define ARRAY_SIZE( X ) \
39   sizeof(X) / sizeof(*X)
40 
41 #define MAPPING(X, Y) \
42   { X, ARRAY_SIZE(Y), Y }
43 
44 static const Mapping mappings[] = {
45   MAPPING( EquipmentManufacturer::FUJI, fuji ),
46   MAPPING( EquipmentManufacturer::GEMS, gems ),
47   MAPPING( EquipmentManufacturer::HITACHI, hitachi ),
48   MAPPING( EquipmentManufacturer::KODAK, kodak ),
49   MAPPING( EquipmentManufacturer::PMS, pms ),
50   MAPPING( EquipmentManufacturer::SIEMENS, siemens ),
51   MAPPING( EquipmentManufacturer::MARCONI, marconi ),
52   MAPPING( EquipmentManufacturer::TOSHIBA, toshiba )
53 };
54 
Compute(DataSet const & ds)55 EquipmentManufacturer::Type EquipmentManufacturer::Compute( DataSet const & ds )
56 {
57   // proper anonymizer should not touch Manufacturer attribute value:
58   // http://dicom.nema.org/medical/dicom/current/output/chtml/part15/chapter_E.html#table_E.1-1
59   gdcm::Attribute<0x0008,0x0070> manu = { "" }; // Manufacturer
60   manu.SetFromDataSet( ds );
61   const std::string manufacturer = manu.GetValue().Trim();
62   for( const Mapping * mapping = mappings; mapping != mappings + ARRAY_SIZE(mappings); ++mapping )
63   {
64     for( size_t i = 0; i < mapping->nstrings; ++i )
65     {
66       // case insensitive to handle: "GE MEDICAL SYSTEMS" vs "GE Medical Systems"
67       if( System::StrCaseCmp( mapping->strings[i], manufacturer.c_str() ) == 0 )
68         return mapping->type;
69     }
70   }
71 
72   // try against with well known private tag:
73   gdcm::Tag gems_iden_01(0x0009,0x0010);
74   if( ds.FindDataElement( gems_iden_01 ) )
75   {
76     const gdcm::DataElement & de = ds.GetDataElement( gems_iden_01 );
77     gdcm::Element<VR::LO, VM::VM1> priv_creator;
78     priv_creator.SetFromDataElement( de );
79     if( priv_creator.GetValue() == "GEMS_IDEN_01" ) return GEMS;
80   }
81 
82   gdcm::PrivateTag siemens_manu(0x0021,0x0022,"SIEMENS MR SDS 01");
83   if( ds.FindDataElement( siemens_manu ) )
84   {
85     const gdcm::DataElement & de = ds.GetDataElement( siemens_manu );
86     gdcm::Element<VR::SH, VM::VM1> value;
87     value.SetFromDataElement( de );
88     if( value.GetValue().Trim() == "SIEMENS" ) return SIEMENS;
89   }
90 
91   gdcm::Tag elscint1(0x00e1,0x0010);
92   if( ds.FindDataElement( elscint1 ) )
93   {
94     const gdcm::DataElement & de = ds.GetDataElement( elscint1 );
95     gdcm::Element<VR::LO, VM::VM1> priv_creator;
96     priv_creator.SetFromDataElement( de );
97     if( priv_creator.GetValue() == "ELSCINT1" ) return GEMS;
98   }
99 
100   return UNKNOWN;
101 }
102 
103 } // end namespace gdcm
104