1 /*
2  *
3  *  Copyright (C) 2015-2020, J. Riesmeier, Oldenburg, Germany
4  *  All rights reserved.  See COPYRIGHT file for details.
5  *
6  *  Source file for class CID4031_CommonAnatomicRegions
7  *
8  *  Generated automatically from DICOM PS 3.16-2020e
9  *  File created on 2020-11-25 11:12:59 by J. Riesmeier
10  *
11  */
12 
13 
14 #include "dcmtk/config/osconfig.h"    /* make sure OS specific configuration is included first */
15 
16 #include "dcmtk/dcmsr/cmr/cid4031.h"
17 
18 
19 // general information on CID 4031 (Common Anatomic Regions)
20 #define CONTEXT_GROUP_NUMBER  "4031"
21 #define CONTEXT_GROUP_VERSION "20200704"
22 #define CONTEXT_GROUP_UID     "1.2.840.10008.6.1.308"
23 #define CONTEXT_GROUP_TYPE    OFTrue  /* extensible */
24 
25 // initialize global/static variable
26 CID4031_CommonAnatomicRegions::CodeList *CID4031_CommonAnatomicRegions::Codes = NULL;
27 
28 
CID4031_CommonAnatomicRegions(const DSRCodedEntryValue & selectedValue)29 CID4031_CommonAnatomicRegions::CID4031_CommonAnatomicRegions(const DSRCodedEntryValue &selectedValue)
30   : DSRContextGroup(CONTEXT_GROUP_NUMBER, "DCMR", CONTEXT_GROUP_VERSION, CONTEXT_GROUP_UID, selectedValue)
31 {
32     setExtensible(CONTEXT_GROUP_TYPE);
33 }
34 
35 
CID4031_CommonAnatomicRegions(const EnumType selectedValue,const OFBool enhancedEncodingMode)36 CID4031_CommonAnatomicRegions::CID4031_CommonAnatomicRegions(const EnumType selectedValue,
37                                                              const OFBool enhancedEncodingMode)
38   : DSRContextGroup(CONTEXT_GROUP_NUMBER, "DCMR", CONTEXT_GROUP_VERSION, CONTEXT_GROUP_UID, getCodedEntry(selectedValue, enhancedEncodingMode))
39 {
40     setExtensible(CONTEXT_GROUP_TYPE);
41 }
42 
43 
selectValue(const EnumType selectedValue,const OFBool enhancedEncodingMode)44 OFCondition CID4031_CommonAnatomicRegions::selectValue(const EnumType selectedValue,
45                                                        const OFBool enhancedEncodingMode)
46 {
47     /* never check the coded entry */
48     return DSRContextGroup::selectValue(getCodedEntry(selectedValue, enhancedEncodingMode), OFFalse /*check*/, OFFalse /*definedContextGroup*/);
49 }
50 
51 
findCodedEntry(const DSRCodedEntryValue & searchForCodedEntry,DSRCodedEntryValue * foundCodedEntry,const OFBool enhancedEncodingMode) const52 OFCondition CID4031_CommonAnatomicRegions::findCodedEntry(const DSRCodedEntryValue &searchForCodedEntry,
53                                                           DSRCodedEntryValue *foundCodedEntry,
54                                                           const OFBool enhancedEncodingMode) const
55 {
56     OFCondition result = SR_EC_CodedEntryNotInContextGroup;
57     /* first, search for standard codes */
58     CodeList::const_iterator iter = getCodes().begin();
59     CodeList::const_iterator last = getCodes().end();
60     /* iterate over coded entry list */
61     while (iter != last)
62     {
63         /* if found, exit loop */
64         if (searchForCodedEntry == iter->second)
65         {
66             /* return coded entry (if requested) */
67             if (foundCodedEntry != NULL)
68             {
69                 *foundCodedEntry = iter->second;
70                 /* also set enhanced encoding mode (if enabled) */
71                 if (!foundCodedEntry->isEmpty() && enhancedEncodingMode)
72                     setEnhancedEncodingMode(*foundCodedEntry);
73             }
74             result = SR_EC_CodedEntryInStandardContextGroup;
75             break;
76         }
77         ++iter;
78     }
79     /* if not, continue with extended codes */
80     if (result.bad())
81     {
82         result = DSRContextGroup::findCodedEntry(searchForCodedEntry, foundCodedEntry);
83         /* tbd: set "enhanced encoding mode" to mark a local/extended version? */
84     }
85     return result;
86 }
87 
88 
printCodes(STD_NAMESPACE ostream & stream) const89 void CID4031_CommonAnatomicRegions::printCodes(STD_NAMESPACE ostream &stream) const
90 {
91     /* print standard codes */
92     stream << "Standard codes:" << OFendl;
93     CodeList::const_iterator iter = getCodes().begin();
94     CodeList::const_iterator last = getCodes().end();
95     /* iterate over coded entry list */
96     while (iter != last)
97     {
98         stream << "  ";
99         /* print coded entry */
100         DSRCodedEntryValue(iter->second).print(stream);
101         stream << OFendl;
102         ++iter;
103     }
104     /* print extended codes */
105     DSRContextGroup::printCodes(stream);
106 }
107 
108 
109 // static functions
110 
initialize()111 void CID4031_CommonAnatomicRegions::initialize()
112 {
113     /* create and initialize code list */
114     getCodes();
115 }
116 
117 
cleanup()118 void CID4031_CommonAnatomicRegions::cleanup()
119 {
120     /* delete code list, it will be recreated automatically when needed */
121     delete Codes;
122     Codes = NULL;
123 }
124 
125 
getCodedEntry(const EnumType value,const OFBool enhancedEncodingMode)126 DSRCodedEntryValue CID4031_CommonAnatomicRegions::getCodedEntry(const EnumType value,
127                                                                 const OFBool enhancedEncodingMode)
128 {
129     DSRCodedEntryValue codedEntry;
130     /* search for given enumerated value */
131     CodeList::iterator iter = getCodes().find(value);
132     /* if found, set the coded entry */
133     if (iter != getCodes().end())
134     {
135         codedEntry = iter->second;
136         /* also set enhanced encoding mode (if enabled) */
137         if (!codedEntry.isEmpty() && enhancedEncodingMode)
138             setEnhancedEncodingMode(codedEntry);
139     }
140     return codedEntry;
141 }
142 
143 
getCodes()144 CID4031_CommonAnatomicRegions::CodeList &CID4031_CommonAnatomicRegions::getCodes()
145 {
146     /* check whether code list has already been created and initialized */
147     if (Codes == NULL)
148     {
149         /* create a new code list (should never fail) */
150         Codes = new CodeList();
151         /* and initialize it by adding the coded entries */
152         Codes->insert(OFMake_pair(Abdomen, DSRBasicCodedEntry("818981001", "SCT", "Abdomen")));
153         Codes->insert(OFMake_pair(AbdomenAndPelvis, DSRBasicCodedEntry("818982008", "SCT", "Abdomen and Pelvis")));
154         Codes->insert(OFMake_pair(AcromioclavicularJoint, DSRBasicCodedEntry("85856004", "SCT", "Acromioclavicular joint")));
155         Codes->insert(OFMake_pair(AnkleJoint, DSRBasicCodedEntry("70258002", "SCT", "Ankle joint")));
156         Codes->insert(OFMake_pair(Anus, DSRBasicCodedEntry("53505006", "SCT", "Anus")));
157         Codes->insert(OFMake_pair(ApexOfLung, DSRBasicCodedEntry("86598002", "SCT", "Apex of Lung")));
158         Codes->insert(OFMake_pair(BileDuct, DSRBasicCodedEntry("28273000", "SCT", "Bile duct")));
159         Codes->insert(OFMake_pair(Bladder, DSRBasicCodedEntry("89837001", "SCT", "Bladder")));
160         Codes->insert(OFMake_pair(BoneOfLowerLimb, DSRBasicCodedEntry("72001000", "SCT", "Bone of lower limb")));
161         Codes->insert(OFMake_pair(BoneOfUpperLimb, DSRBasicCodedEntry("371195002", "SCT", "Bone of upper limb")));
162         Codes->insert(OFMake_pair(Breast, DSRBasicCodedEntry("76752008", "SCT", "Breast")));
163         Codes->insert(OFMake_pair(Bronchus, DSRBasicCodedEntry("955009", "SCT", "Bronchus")));
164         Codes->insert(OFMake_pair(Calcaneus, DSRBasicCodedEntry("80144004", "SCT", "Calcaneus")));
165         Codes->insert(OFMake_pair(CervicalSpine, DSRBasicCodedEntry("122494005", "SCT", "Cervical spine")));
166         Codes->insert(OFMake_pair(CervicoThoracicSpine, DSRBasicCodedEntry("297171002", "SCT", "Cervico-thoracic spine")));
167         Codes->insert(OFMake_pair(Chest, DSRBasicCodedEntry("816094009", "SCT", "Chest")));
168         Codes->insert(OFMake_pair(ChestAndAbdomen, DSRBasicCodedEntry("416550000", "SCT", "Chest and Abdomen")));
169         Codes->insert(OFMake_pair(ChestAbdomenAndPelvis, DSRBasicCodedEntry("416775004", "SCT", "Chest, Abdomen and Pelvis")));
170         Codes->insert(OFMake_pair(Clavicle, DSRBasicCodedEntry("51299004", "SCT", "Clavicle")));
171         Codes->insert(OFMake_pair(Coccyx, DSRBasicCodedEntry("64688005", "SCT", "Coccyx")));
172         Codes->insert(OFMake_pair(Colon, DSRBasicCodedEntry("71854001", "SCT", "Colon")));
173         Codes->insert(OFMake_pair(CommonBileDuct, DSRBasicCodedEntry("79741001", "SCT", "Common bile duct")));
174         Codes->insert(OFMake_pair(Duodenum, DSRBasicCodedEntry("38848004", "SCT", "Duodenum")));
175         Codes->insert(OFMake_pair(ElbowJoint, DSRBasicCodedEntry("16953009", "SCT", "Elbow joint")));
176         Codes->insert(OFMake_pair(EntireBody, DSRBasicCodedEntry("38266002", "SCT", "Entire body")));
177         Codes->insert(OFMake_pair(Esophagus, DSRBasicCodedEntry("32849002", "SCT", "Esophagus")));
178         Codes->insert(OFMake_pair(EsophagusStomachAndDuodenum, DSRBasicCodedEntry("110861005", "SCT", "Esophagus, stomach and duodenum")));
179         Codes->insert(OFMake_pair(Extremity, DSRBasicCodedEntry("66019005", "SCT", "Extremity")));
180         Codes->insert(OFMake_pair(Eye, DSRBasicCodedEntry("81745001", "SCT", "Eye")));
181         Codes->insert(OFMake_pair(EyeRegion, DSRBasicCodedEntry("371398005", "SCT", "Eye region")));
182         Codes->insert(OFMake_pair(FacialBones, DSRBasicCodedEntry("91397008", "SCT", "Facial bones")));
183         Codes->insert(OFMake_pair(Femur, DSRBasicCodedEntry("71341001", "SCT", "Femur")));
184         Codes->insert(OFMake_pair(Fibula, DSRBasicCodedEntry("87342007", "SCT", "Fibula")));
185         Codes->insert(OFMake_pair(Finger, DSRBasicCodedEntry("7569003", "SCT", "Finger")));
186         Codes->insert(OFMake_pair(Foot, DSRBasicCodedEntry("56459004", "SCT", "Foot")));
187         Codes->insert(OFMake_pair(Forearm, DSRBasicCodedEntry("14975008", "SCT", "Forearm")));
188         Codes->insert(OFMake_pair(Gallbladder, DSRBasicCodedEntry("28231008", "SCT", "Gallbladder")));
189         Codes->insert(OFMake_pair(Hand, DSRBasicCodedEntry("85562004", "SCT", "Hand")));
190         Codes->insert(OFMake_pair(Head, DSRBasicCodedEntry("69536005", "SCT", "Head")));
191         Codes->insert(OFMake_pair(HeadAndNeck, DSRBasicCodedEntry("774007", "SCT", "Head and Neck")));
192         Codes->insert(OFMake_pair(Heart, DSRBasicCodedEntry("80891009", "SCT", "Heart")));
193         Codes->insert(OFMake_pair(Hip, DSRBasicCodedEntry("29836001", "SCT", "Hip")));
194         Codes->insert(OFMake_pair(HipJoint, DSRBasicCodedEntry("24136001", "SCT", "Hip Joint")));
195         Codes->insert(OFMake_pair(Humerus, DSRBasicCodedEntry("85050009", "SCT", "Humerus")));
196         Codes->insert(OFMake_pair(Ileum, DSRBasicCodedEntry("34516001", "SCT", "Ileum")));
197         Codes->insert(OFMake_pair(Ilium, DSRBasicCodedEntry("22356005", "SCT", "Ilium")));
198         Codes->insert(OFMake_pair(InternalAuditoryCanal, DSRBasicCodedEntry("361078006", "SCT", "Internal Auditory Canal")));
199         Codes->insert(OFMake_pair(JawRegion, DSRBasicCodedEntry("661005", "SCT", "Jaw region")));
200         Codes->insert(OFMake_pair(Jejunum, DSRBasicCodedEntry("21306003", "SCT", "Jejunum")));
201         Codes->insert(OFMake_pair(Knee, DSRBasicCodedEntry("72696002", "SCT", "Knee")));
202         Codes->insert(OFMake_pair(LargeIntestine, DSRBasicCodedEntry("14742008", "SCT", "Large intestine")));
203         Codes->insert(OFMake_pair(Larynx, DSRBasicCodedEntry("4596009", "SCT", "Larynx")));
204         Codes->insert(OFMake_pair(LiverAndBiliaryStructure, DSRBasicCodedEntry("303270005", "SCT", "Liver and biliary structure")));
205         Codes->insert(OFMake_pair(LowerLeg, DSRBasicCodedEntry("30021000", "SCT", "Lower leg")));
206         Codes->insert(OFMake_pair(LowerLimb, DSRBasicCodedEntry("61685007", "SCT", "Lower limb")));
207         Codes->insert(OFMake_pair(LumbarSpine, DSRBasicCodedEntry("122496007", "SCT", "Lumbar spine")));
208         Codes->insert(OFMake_pair(LumboSacralSpine, DSRBasicCodedEntry("297173004", "SCT", "Lumbo-sacral spine")));
209         Codes->insert(OFMake_pair(Mandible, DSRBasicCodedEntry("91609006", "SCT", "Mandible")));
210         Codes->insert(OFMake_pair(MastoidBone, DSRBasicCodedEntry("59066005", "SCT", "Mastoid bone")));
211         Codes->insert(OFMake_pair(Maxilla, DSRBasicCodedEntry("70925003", "SCT", "Maxilla")));
212         Codes->insert(OFMake_pair(Mediastinum, DSRBasicCodedEntry("72410000", "SCT", "Mediastinum")));
213         Codes->insert(OFMake_pair(MuscleOfLowerLimb, DSRBasicCodedEntry("102292000", "SCT", "Muscle of lower limb")));
214         Codes->insert(OFMake_pair(MuscleOfUpperLimb, DSRBasicCodedEntry("30608006", "SCT", "Muscle of upper limb")));
215         Codes->insert(OFMake_pair(NasalBone, DSRBasicCodedEntry("74386004", "SCT", "Nasal bone")));
216         Codes->insert(OFMake_pair(Neck, DSRBasicCodedEntry("45048000", "SCT", "Neck")));
217         Codes->insert(OFMake_pair(NeckAndChest, DSRBasicCodedEntry("417437006", "SCT", "Neck and Chest")));
218         Codes->insert(OFMake_pair(NeckChestAndAbdomen, DSRBasicCodedEntry("416152001", "SCT", "Neck, Chest and Abdomen")));
219         Codes->insert(OFMake_pair(NeckChestAbdomenAndPelvis, DSRBasicCodedEntry("416319003", "SCT", "Neck, Chest, Abdomen and Pelvis")));
220         Codes->insert(OFMake_pair(OpticCanal, DSRBasicCodedEntry("55024004", "SCT", "Optic canal")));
221         Codes->insert(OFMake_pair(OrbitalStructure, DSRBasicCodedEntry("363654007", "SCT", "Orbital structure")));
222         Codes->insert(OFMake_pair(Pancreas, DSRBasicCodedEntry("15776009", "SCT", "Pancreas")));
223         Codes->insert(OFMake_pair(PancreaticDuct, DSRBasicCodedEntry("69930009", "SCT", "Pancreatic duct")));
224         Codes->insert(OFMake_pair(PancreaticDuctAndBileDuctSystems, DSRBasicCodedEntry("110621006", "SCT", "Pancreatic duct and bile duct systems")));
225         Codes->insert(OFMake_pair(ParanasalSinus, DSRBasicCodedEntry("2095001", "SCT", "Paranasal sinus")));
226         Codes->insert(OFMake_pair(ParotidGland, DSRBasicCodedEntry("45289007", "SCT", "Parotid gland")));
227         Codes->insert(OFMake_pair(Patella, DSRBasicCodedEntry("64234005", "SCT", "Patella")));
228         Codes->insert(OFMake_pair(Pelvis, DSRBasicCodedEntry("816092008", "SCT", "Pelvis")));
229         Codes->insert(OFMake_pair(PelvisAndLowerExtremities, DSRBasicCodedEntry("416631005", "SCT", "Pelvis and lower extremities")));
230         Codes->insert(OFMake_pair(Phantom, DSRBasicCodedEntry("113681", "DCM", "Phantom")));
231         Codes->insert(OFMake_pair(Prostate, DSRBasicCodedEntry("41216001", "SCT", "Prostate")));
232         Codes->insert(OFMake_pair(Rectum, DSRBasicCodedEntry("34402009", "SCT", "Rectum")));
233         Codes->insert(OFMake_pair(Rib, DSRBasicCodedEntry("113197003", "SCT", "Rib")));
234         Codes->insert(OFMake_pair(SacroCoccygealSpine, DSRBasicCodedEntry("297174005", "SCT", "Sacro-coccygeal Spine")));
235         Codes->insert(OFMake_pair(SacroiliacJoint, DSRBasicCodedEntry("39723000", "SCT", "Sacroiliac joint")));
236         Codes->insert(OFMake_pair(Sacrum, DSRBasicCodedEntry("54735007", "SCT", "Sacrum")));
237         Codes->insert(OFMake_pair(Scapula, DSRBasicCodedEntry("79601000", "SCT", "Scapula")));
238         Codes->insert(OFMake_pair(SellaTurcica, DSRBasicCodedEntry("42575006", "SCT", "Sella turcica")));
239         Codes->insert(OFMake_pair(SesamoidBonesOfFoot, DSRBasicCodedEntry("58742003", "SCT", "Sesamoid bones of foot")));
240         Codes->insert(OFMake_pair(Shoulder, DSRBasicCodedEntry("16982005", "SCT", "Shoulder")));
241         Codes->insert(OFMake_pair(Skull, DSRBasicCodedEntry("89546000", "SCT", "Skull")));
242         Codes->insert(OFMake_pair(SmallIntestine, DSRBasicCodedEntry("30315005", "SCT", "Small intestine")));
243         Codes->insert(OFMake_pair(Spine, DSRBasicCodedEntry("421060004", "SCT", "Spine")));
244         Codes->insert(OFMake_pair(SternoclavicularJoint, DSRBasicCodedEntry("7844006", "SCT", "Sternoclavicular joint")));
245         Codes->insert(OFMake_pair(Sternum, DSRBasicCodedEntry("56873002", "SCT", "Sternum")));
246         Codes->insert(OFMake_pair(Stomach, DSRBasicCodedEntry("69695003", "SCT", "Stomach")));
247         Codes->insert(OFMake_pair(SubmandibularGland, DSRBasicCodedEntry("54019009", "SCT", "Submandibular gland")));
248         Codes->insert(OFMake_pair(TarsalJoint, DSRBasicCodedEntry("27949001", "SCT", "Tarsal joint")));
249         Codes->insert(OFMake_pair(TemporomandibularJoint, DSRBasicCodedEntry("53620006", "SCT", "Temporomandibular joint")));
250         Codes->insert(OFMake_pair(Thigh, DSRBasicCodedEntry("68367000", "SCT", "Thigh")));
251         Codes->insert(OFMake_pair(ThoracicSpine, DSRBasicCodedEntry("122495006", "SCT", "Thoracic spine")));
252         Codes->insert(OFMake_pair(ThoracoLumbarSpine, DSRBasicCodedEntry("297172009", "SCT", "Thoraco-lumbar spine")));
253         Codes->insert(OFMake_pair(Thumb, DSRBasicCodedEntry("76505004", "SCT", "Thumb")));
254         Codes->insert(OFMake_pair(Toe, DSRBasicCodedEntry("29707007", "SCT", "Toe")));
255         Codes->insert(OFMake_pair(Trachea, DSRBasicCodedEntry("44567001", "SCT", "Trachea")));
256         Codes->insert(OFMake_pair(UpperArm, DSRBasicCodedEntry("40983000", "SCT", "Upper arm")));
257         Codes->insert(OFMake_pair(UpperLimb, DSRBasicCodedEntry("53120007", "SCT", "Upper limb")));
258         Codes->insert(OFMake_pair(UpperUrinaryTract, DSRBasicCodedEntry("431491007", "SCT", "Upper urinary tract")));
259         Codes->insert(OFMake_pair(Ureter, DSRBasicCodedEntry("87953007", "SCT", "Ureter")));
260         Codes->insert(OFMake_pair(Urethra, DSRBasicCodedEntry("13648007", "SCT", "Urethra")));
261         Codes->insert(OFMake_pair(UterusAndFallopianTubes, DSRBasicCodedEntry("110639002", "SCT", "Uterus and fallopian tubes")));
262         Codes->insert(OFMake_pair(VertebralColumnAndCranium, DSRBasicCodedEntry("110517009", "SCT", "Vertebral column and cranium")));
263         Codes->insert(OFMake_pair(WristJoint, DSRBasicCodedEntry("74670003", "SCT", "Wrist joint")));
264         Codes->insert(OFMake_pair(Zygoma, DSRBasicCodedEntry("13881006", "SCT", "Zygoma")));
265     }
266     /* should never be NULL */
267     return *Codes;
268 }
269 
270 
setEnhancedEncodingMode(DSRCodedEntryValue & codedEntryValue)271 OFCondition CID4031_CommonAnatomicRegions::setEnhancedEncodingMode(DSRCodedEntryValue &codedEntryValue)
272 {
273     return codedEntryValue.setEnhancedEncodingMode(CONTEXT_GROUP_NUMBER, "DCMR", CONTEXT_GROUP_VERSION, CONTEXT_GROUP_UID);
274 }
275