-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanonymize.cxx
2721 lines (2571 loc) · 147 KB
/
anonymize.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*=========================================================================
Program: Anonymization using gdcm
Copyright (c) 2024 Hauke Bartsch
For debugging use:
cmake -DCMAKE_BUILD_TYPE=Release ..
to build gdcm.
// DumpSiemensBase64.cxx - add CSA header information
=========================================================================*/
#include "SHA-256.hpp"
#include "dateprocessing.h"
#include "gdcmAnonymizer.h"
#include "gdcmAttribute.h"
#include "gdcmDefs.h"
#include "gdcmDirectory.h"
#include "gdcmGlobal.h"
#include "gdcmImageReader.h"
#include "gdcmReader.h"
#include "gdcmStringFilter.h"
#include "gdcmSystem.h"
#include "gdcmWriter.h"
#include "gdcmPrivateTag.h"
#include "gdcmDataSetHelper.h"
#include "json.hpp"
#include "optionparser.h"
#include <gdcmUIDGenerator.h>
#include <dirent.h>
#include <errno.h>
#include <exception>
#include <stdexcept>
#include <sys/stat.h>
#include <sys/types.h>
#include <time.h>
#include <chrono>
#include <map>
#include <unordered_set>
#include <pthread.h>
#include <regex>
#include <stdio.h>
#include <thread>
#include <filesystem> // needs C++-17 (we are now on c++20)
namespace fs = std::filesystem;
#cmakedefine VERSION_DATE "@VERSION_DATE@"
struct threadparams {
const char **filenames;
size_t nfiles;
char *scalarpointer;
std::string outputdir;
std::string patientid;
std::string projectname;
std::string sitename;
std::string eventname;
std::string siteid;
int dateincrement;
bool byseries;
int thread; // number of the thread
bool old_style_uid;
// each thread will store here the study instance uid (original and mapped)
std::map<std::string, std::string> byThreadStudyInstanceUID;
std::map<std::string, std::string> byThreadSeriesInstanceUID;
};
int debug_level = 0;
// Coding Scheme Designator Code Value Code Meaning Body Part Examined
nlohmann::json allowedBodyParts = nlohmann::json::array({{"XXX", "XXXXXXXX", "BODYPART", "BODYPART"}, // this top element is only a fallback, not in the standard!
{"SCT", "818981001", "Abdomen", "ABDOMEN"},
{"SCT", "818982008", "Abdomen and Pelvis", "ABDOMENPELVIS"},
{"SCT", "7832008", "Abdominal aorta", "ABDOMINALAORTA"},
{"SCT", "85856004", "Acromioclavicular joint", "ACJOINT"},
{"SCT", "23451007", "Adrenal gland", "ADRENAL"},
{"SCT", "77012006", "Amniotic fluid", "AMNIOTICFLUID"},
{"SCT", "70258002", "Ankle joint", "ANKLE"},
{"SCT", "128585006", "Anomalous pulmonary vein", ""},
{"SCT", "128553008", "Antecubital vein", "ANTECUBITALV"},
{"SCT", "194996006", "Anterior cardiac vein", "ANTCARDIACV"},
{"SCT", "60176003", "Anterior cerebral artery", "ACA"},
{"SCT", "8012006", "Anterior communicating artery", "ANTCOMMA"},
{"SCT", "17388009", "Anterior spinal artery", "ANTSPINALA"},
{"SCT", "68053000", "Anterior tibial artery", "ANTTIBIALA"},
{"SCT", "53505006", "Anus", ""},
{"SCT", "110612005", "Anus, rectum and sigmoid colon", "ANUSRECTUMSIGMD"},
{"SCT", "15825003", "Aorta", "AORTA"},
{"SCT", "57034009", "Aortic arch", "AORTICARCH"},
{"SCT", "128551005", "Aortic fistula", ""},
{"SCT", "128564006", "Apex of left ventricle", ""},
{"SCT", "86598002", "Apex of Lung", ""},
{"SCT", "128565007", "Apex of right ventricle", ""},
{"SCT", "66754008", "Appendix", "APPENDIX"},
{"SCT", "51114001", "Artery", "ARTERY"},
{"SCT", "54247002", "Ascending aorta", "ASCAORTA"},
{"SCT", "9040008", "Ascending colon", "ASCENDINGCOLON"},
{"SCT", "59652004", "Atrium", ""},
{"SCT", "91470000", "Axilla", "AXILLA"},
{"SCT", "67937003", "Axillary Artery", "AXILLARYA"},
{"SCT", "68705008", "Axillary vein", "AXILLARYV"},
{"SCT", "72107004", "Azygos vein", "AZYGOSVEIN"},
{"SCT", "77568009", "Back", "BACK"},
{"SCT", "128981007", "Baffle", ""},
{"SCT", "59011009", "Basilar artery", "BASILARA"},
{"SCT", "28273000", "Bile duct", "BILEDUCT"},
{"SCT", "34707002", "Biliary tract", "BILIARYTRACT"},
{"SCT", "89837001", "Bladder", "BLADDER"},
{"SCT", "110837003", "Bladder and urethra", "BLADDERURETHRA"},
{"SCT", "91830000", "Body conduit", ""},
{"SCT", "72001000", "Bone of lower limb", ""},
{"SCT", "371195002", "Bone of upper limb", ""},
{"SCT", "128548003", "Boyd's perforating vein", ""},
{"SCT", "17137000", "Brachial artery", "BRACHIALA"},
{"SCT", "20115005", "Brachial vein", "BRACHIALV"},
{"SCT", "12738006", "Brain", "BRAIN"},
{"SCT", "76752008", "Breast", "BREAST"},
{"SCT", "34411009", "Broad ligament", ""},
{"SCT", "955009", "Bronchus", "BRONCHUS"},
{"SCT", "60819002", "Buccal region of face", ""},
{"SCT", "46862004", "Buttock", "BUTTOCK"},
{"SCT", "80144004", "Calcaneus", "CALCANEUS"},
{"SCT", "53840002", "Calf of leg", "CALF"},
{"SCT", "2334006", "Calyx", ""},
{"SCT", "69105007", "Carotid Artery", "CAROTID"},
{"SCT", "21479005", "Carotid bulb", "BULB"},
{"SCT", "57850000", "Celiac artery", "CELIACA"},
{"SCT", "20699002", "Cephalic vein", "CEPHALICV"},
{"SCT", "113305005", "Cerebellum", "CEREBELLUM"},
{"SCT", "88556005", "Cerebral artery", "CEREBRALA"},
{"SCT", "372073000", "Cerebral hemisphere", "CEREBHEMISPHERE"},
{"SCT", "122494005", "Cervical spine", "CSPINE"},
{"SCT", "1217257000", "Cervico-thoracic spine", "CTSPINE"},
{"SCT", "71252005", "Cervix", "CERVIX"},
{"SCT", "60819002", "Cheek", "CHEEK"},
{"SCT", "43799004", "Chest", "CHEST"},
{"SCT", "416775004", "Chest, Abdomen and Pelvis", "CHESTABDPELVIS"},
{"SCT", "416550000", "Chest and Abdomen", "CHESTABDOMEN"},
{"SCT", "80621003", "Choroid plexus", "CHOROIDPLEXUS"},
{"SCT", "11279006", "Circle of Willis", "CIRCLEOFWILLIS"},
{"SCT", "51299004", "Clavicle", "CLAVICLE"},
{"SCT", "64688005", "Coccyx", "COCCYX"},
{"SCT", "71854001", "Colon", "COLON"},
{"SCT", "253276007", "Common atrium", ""},
{"SCT", "79741001", "Common bile duct", "COMMONBILEDUCT"},
{"SCT", "32062004", "Common carotid artery", "CCA"},
{"SCT", "181347005", "Common femoral artery", "CFA"},
{"SCT", "397363009", "Common femoral vein", "CFV"},
{"SCT", "73634005", "Common iliac artery", "COMILIACA"},
{"SCT", "46027005", "Common iliac vein", "COMILIACV"},
{"SCT", "45503006", "Common ventricle", ""},
{"SCT", "128555001", "Congenital coronary artery fistula to left atrium", ""},
{"SCT", "128556000", "Congenital coronary artery fistula to left ventricle", ""},
{"SCT", "128557009", "Congenital coronary artery fistula to right atrium", ""},
{"SCT", "128558004", "Congenital coronary artery fistula to right ventricle", ""},
{"SCT", "111289009", "Pulmonary arteriovenous fistula", ""},
{"SCT", "28726007", "Cornea", "CORNEA"},
{"SCT", "41801008", "Coronary artery", "CORONARYARTERY"},
{"SCT", "90219004", "Coronary sinus", "CORONARYSINUS"},
{"SCT", "128320002", "Cranial venous system", ""},
{"SCT", "32672002", "Descending aorta", "DESCAORTA"},
{"SCT", "32622004", "Descending colon", "DESCENDINGCOLON"},
{"SCT", "128554002", "Dodd's perforating vein", ""},
{"SCT", "38848004", "Duodenum", "DUODENUM"},
{"SCT", "117590005", "Ear", "EAR"},
{"SCT", "16953009", "Elbow joint", "ELBOW"},
{"SCT", "51114001", "Endo-arterial", "ENDOARTERIAL"},
{"SCT", "80891009", "Endo-cardiac", "ENDOCARDIAC"},
{"SCT", "32849002", "Endo-esophageal", "ENDOESOPHAGEAL"},
{"SCT", "2739003", "Endometrium", "ENDOMETRIUM"},
{"SCT", "53342003", "Endo-nasal", "ENDONASAL"},
{"SCT", "18962004", "Endo-nasopharyngeal", "ENDONASOPHARYNYX"},
{"SCT", "34402009", "Endo-rectal", "ENDORECTAL"},
{"SCT", "64033007", "Endo-renal", "ENDORENAL"},
{"SCT", "87953007", "Endo-ureteric", "ENDOURETERIC"},
{"SCT", "13648007", "Endo-urethral", "ENDOURETHRAL"},
{"SCT", "76784001", "Endo-vaginal", "ENDOVAGINAL"},
{"SCT", "59820001", "Endo-vascular", "ENDOVASCULAR"},
{"SCT", "29092000", "Endo-venous", "ENDOVENOUS"},
{"SCT", "48367006", "Endo-vesical", "ENDOVESICAL"},
{"SCT", "38266002", "Entire body", "WHOLEBODY"},
{"SCT", "87644002", "Epididymis", "EPIDIDYMIS"},
{"SCT", "27947004", "Epigastric region", "EPIGASTRIC"},
{"SCT", "32849002", "Esophagus", "ESOPHAGUS"},
{"SCT", "110861005", "Esophagus, stomach and duodenum", ""},
{"SCT", "84301002", "External auditory canal", "EAC"},
{"SCT", "22286001", "External carotid artery", "ECA"},
{"SCT", "113269004", "External iliac artery", "EXTILIACA"},
{"SCT", "63507001", "External iliac vein", "EXTILIACV"},
{"SCT", "71585003", "External jugular vein", "EXTJUGV"},
{"SCT", "66019005", "Extremity", "EXTREMITY"},
{"SCT", "81745001", "Eye", "EYE"},
{"SCT", "80243003", "Eyelid", "EYELID"},
{"SCT", "371398005", "Eye region", ""},
{"SCT", "89545001", "Face", "FACE"},
{"SCT", "23074001", "Facial artery", "FACIALA"},
{"SCT", "91397008", "Facial bones", ""},
{"SCT", "7657000", "Femoral artery", "FEMORALA"},
{"SCT", "83419000", "Femoral vein", "FEMORALV"},
{"SCT", "71341001", "Femur", "FEMUR"},
{"", "", "Fetal arm", "FETALARM"},
{"", "", "Fetal digit", "FETALDIGIT"},
{"", "", "Fetal heart", "FETALHEART"},
{"", "", "Fetal leg", "FETALLEG"},
{"", "", "Fetal pole", "FETALPOLE"},
{"SCT", "87342007", "Fibula", "FIBULA"},
{"SCT", "7569003", "Finger", "FINGER"},
{"SCT", "58602004", "Flank", "FLANK"},
{"SCT", "79361005", "Fontanel of skull", "FONTANEL"},
{"SCT", "56459004", "Foot", "FOOT"},
{"SCT", "14975008", "Forearm", "FOREARM"},
{"SCT", "35918002", "Fourth ventricle", "4THVENTRICLE"},
{"SCT", "28231008", "Gallbladder", "GALLBLADDER"},
{"SCT", "110568007", "Gastric vein", "GASTRICV"},
{"SCT", "128559007", "Genicular artery", "GENICULARA"},
{"SCT", "300571009", "Gestational sac", "GESTSAC"},
{"SCT", "46862004", "Gluteal region", "GLUTEAL"},
{"SCT", "5928000", "Great cardiac vein", ""},
{"SCT", "60734001", "Great saphenous vein", "GSV"},
{"SCT", "85562004", "Hand", "HAND"},
{"SCT", "69536005", "Head", "HEAD"},
{"SCT", "774007", "Head and Neck", "HEADNECK"},
{"SCT", "80891009", "Heart", "HEART"},
{"SCT", "76015000", "Hepatic artery", "HEPATICA"},
{"SCT", "8993003", "Hepatic vein", "HEPATICV"},
{"SCT", "24136001", "Hip joint", "HIP"},
{"SCT", "85050009", "Humerus", "HUMERUS"},
{"SCT", "128560002", "Hunterian perforating vein", ""},
{"SCT", "11708003", "Hypogastric region", "HYPOGASTRIC"},
{"SCT", "81502006", "Hypopharynx", "HYPOPHARYNX"},
{"SCT", "34516001", "Ileum", "ILEUM"},
{"SCT", "299716001", "Iliac and/or femoral artery", ""},
{"SCT", "10293006", "Iliac artery", "ILIACA"},
{"SCT", "244411005", "Iliac vein", "ILIACV"},
{"SCT", "22356005", "Ilium", "ILIUM"},
{"SCT", "195416006", "Inferior cardiac vein", ""},
{"SCT", "51249003", "Inferior left pulmonary vein", ""},
{"SCT", "33795007", "Inferior mesenteric artery", "INFMESA"},
{"SCT", "113273001", "Inferior right pulmonary vein", ""},
{"SCT", "64131007", "Inferior vena cava", "INFVENACAVA"},
{"SCT", "26893007", "Inguinal region", "INGUINAL"},
{"SCT", "12691009", "Innominate artery", "INNOMINATEA"},
{"SCT", "8887007", "Innominate vein", "INNOMINATEV"},
{"SCT", "361078006", "Internal Auditory Canal", "IAC"},
{"SCT", "86117002", "Internal carotid artery", "ICA"},
{"SCT", "90024005", "Internal iliac artery", "INTILIACA"},
{"SCT", "12123001", "Internal jugular vein", "INTJUGULARV"},
{"SCT", "69327007", "Internal mammary artery", "INTMAMMARYA"},
{"SCT", "818987002", "Intra-abdominopelvic", ""},
{"SCT", "131183008", "Intra-articular", ""},
{"SCT", "1101003", "Intracranial", "INTRACRANIAL"},
{"SCT", "32849002", "Intra-esophageal", ""},
{"SCT", "816989007", "Intra-pelvic", ""},
{"SCT", "43799004", "Intra-thoracic", ""},
{"SCT", "661005", "Jaw region", "JAW"},
{"SCT", "21306003", "Jejunum", "JEJUNUM"},
{"SCT", "39352004", "Joint", "JOINT"},
{"SCT", "128563000", "Juxtaposed atrial appendage", ""},
{"SCT", "64033007", "Kidney", "KIDNEY"},
{"SCT", "72696002", "Knee", "KNEE"},
{"SCT", "59749000", "Lacrimal artery", "LACRIMALA"},
{"SCT", "128979005", "Lacrimal artery of right eye", ""},
{"SCT", "14742008", "Large intestine", "LARGEINTESTINE"},
{"SCT", "4596009", "Larynx", "LARYNX"},
{"SCT", "66720007", "Lateral Ventricle", "LATVENTRICLE"},
{"SCT", "82471001", "Left atrium", "LATRIUM"},
{"SCT", "33626005", "Left auricular appendage", ""},
{"SCT", "113270003", "Left femoral artery", "LFEMORALA"},
{"SCT", "273202007", "Left hepatic vein", "LHEPATICV"},
{"SCT", "133945003", "Left hypochondriac region", "LHYPOCHONDRIAC"},
{"SCT", "85119005", "Left inguinal region", "LINGUINAL"},
{"SCT", "68505006", "Left lower quadrant of abdomen", "LLQ"},
{"SCT", "1017210004", "Left lumbar region", "LLUMBAR"},
{"SCT", "70253006", "Left portal vein", "LPORTALV"},
{"SCT", "50408007", "Left pulmonary artery", "LPULMONARYA"},
{"SCT", "86367003", "Left upper quadrant of abdomen", "LUQ"},
{"SCT", "87878005", "Left ventricle", "LVENTRICLE"},
{"SCT", "70238003", "Left ventricle inflow", ""},
{"SCT", "13418002", "Left ventricle outflow tract", ""},
{"SCT", "113264009", "Lingual artery", "LINGUALA"},
{"SCT", "10200004", "Liver", "LIVER"},
{"SCT", "19100000", "Lower inner quadrant of breast", ""},
{"SCT", "30021000", "Lower leg", "LOWERLEG"},
{"SCT", "61685007", "Lower limb", "LOWERLIMB"},
{"SCT", "33564002", "Lower outer quadrant of breast", ""},
{"SCT", "34635009", "Lumbar artery", "LUMBARA"},
{"SCT", "52612000", "Lumbar region", "LUMBAR"},
{"SCT", "122496007", "Lumbar spine", "LSPINE"},
{"SCT", "1217253001", "Lumbo-sacral spine", "LSSPINE"},
{"SCT", "91747007", "Lumen of blood vessel", "LUMEN"},
{"SCT", "39607008", "Lung", "LUNG"},
{"SCT", "91609006", "Mandible", "MANDIBLE"},
{"SCT", "59066005", "Mastoid bone", "MASTOID"},
{"SCT", "70925003", "Maxilla", "MAXILLA"},
{"SCT", "72410000", "Mediastinum", "MEDIASTINUM"},
{"SCT", "86570000", "Mesenteric artery", "MESENTRICA"},
{"SCT", "128583004", "Mesenteric vein", "MESENTRICV"},
{"SCT", "17232002", "Middle cerebral artery", "MCA"},
{"SCT", "273099000", "Middle hepatic vein", "MIDHEPATICV"},
{"SCT", "243977002", "Morisons pouch", "MORISONSPOUCH"},
{"SCT", "123851003", "Mouth", "MOUTH"},
{"SCT", "102292000", "Muscle of lower limb", ""},
{"SCT", "30608006", "Muscle of upper limb", ""},
{"SCT", "74386004", "Nasal bone", ""},
{"SCT", "360955006", "Nasopharynx", "NASOPHARYNX"},
{"SCT", "45048000", "Neck", "NECK"},
{"SCT", "416319003", "Neck, Chest, Abdomen and Pelvis", "NECKCHESTABDPELV"},
{"SCT", "416152001", "Neck, Chest and Abdomen", "NECKCHESTABDOMEN"},
{"SCT", "417437006", "Neck and Chest", "NECKCHEST"},
{"SCT", "45206002", "Nose", "NOSE"},
{"SCT", "31145008", "Occipital artery", "OCCPITALA"},
{"SCT", "32114007", "Occipital vein", "OCCIPTALV"},
{"SCT", "113346000", "Omental bursa", ""},
{"SCT", "27398004", "Omentum", ""},
{"SCT", "53549008", "Ophthalmic artery", "OPHTHALMICA"},
{"SCT", "55024004", "Optic canal", "OPTICCANAL"},
{"SCT", "363654007", "Orbital structure", "ORBIT"},
{"SCT", "15497006", "Ovary", "OVARY"},
{"SCT", "15776009", "Pancreas", "PANCREAS"},
{"SCT", "69930009", "Pancreatic duct", "PANCREATICDUCT"},
{"SCT", "110621006", "Pancreatic duct and bile duct systems", "PANCBILEDUCT"},
{"SCT", "2095001", "Paranasal sinus", ""},
{"SCT", "91691001", "Parasternal", "PARASTERNAL"},
{"SCT", "111002", "Parathyroid", "PARATHYROID"},
{"SCT", "45289007", "Parotid gland", "PAROTID"},
{"SCT", "64234005", "Patella", "PATELLA"},
{"SCT", "83330001", "Patent ductus arteriosus", ""},
{"SCT", "816092008", "Pelvis", "PELVIS"},
{"SCT", "1231522001", "Pelvis and lower extremities", "PELVISLOWEXTREMT"},
{"SCT", "282044005", "Penile artery", "PENILEA"},
{"SCT", "18911002", "Penis", "PENIS"},
{"SCT", "38864007", "Perineum", "PERINEUM"},
{"SCT", "8821006", "Peroneal artery", "PERONEALA"},
{"SCT", "706342009", "Phantom", "PHANTOM"},
{"SCT", "54066008", "Pharynx", "PHARYNX"},
{"SCT", "312535008", "Pharynx and larynx", "PHARYNXLARYNX"},
{"SCT", "78067005", "Placenta", "PLACENTA"},
{"SCT", "43899006", "Popliteal artery", "POPLITEALA"},
{"SCT", "32361000", "Popliteal fossa", "POPLITEALFOSSA"},
{"SCT", "56849005", "Popliteal vein", "POPLITEALV"},
{"SCT", "32764006", "Portal vein", "PORTALV"},
{"SCT", "70382005", "Posterior cerebral artery", "PCA"},
{"SCT", "43119007", "Posterior communicating artery", "POSCOMMA"},
{"SCT", "128569001", "Posterior medial tributary", ""},
{"SCT", "13363002", "Posterior tibial artery", "POSTIBIALA"},
{"SCT", "14944004", "Primitive aorta", ""},
{"SCT", "91707000", "Primitive pulmonary artery", ""},
{"SCT", "31677005", "Profunda femoris artery", "PROFFEMA"},
{"SCT", "23438002", "Profunda femoris vein", "PROFFEMV"},
{"SCT", "41216001", "Prostate", "PROSTATE"},
{"SCT", "81040000", "Pulmonary artery", "PULMONARYA"},
{"SCT", "128584005", "Pulmonary artery conduit", ""},
{"SCT", "128586007", "Pulmonary chamber of cor triatriatum", ""},
{"SCT", "122972007", "Pulmonary vein", "PULMONARYV"},
{"SCT", "128566008", "Pulmonary vein confluence", ""},
{"SCT", "128567004", "Pulmonary venous atrium", ""},
{"SCT", "45631007", "Radial artery", "RADIALA"},
{"SCT", "62413002", "Radius", "RADIUS"},
{"SCT", "110535000", "Radius and ulna", "RADIUSULNA"},
{"SCT", "53843000", "Rectouterine pouch", "CULDESAC"},
{"SCT", "34402009", "Rectum", "RECTUM"},
{"SCT", "2841007", "Renal artery", "RENALA"},
{"SCT", "25990002", "Renal pelvis", ""},
{"SCT", "56400007", "Renal vein", "RENALV"},
{"SCT", "82849001", "Retroperitoneum", "RETROPERITONEUM"},
{"SCT", "113197003", "Rib", "RIB"},
{"SCT", "73829009", "Right atrium", "RATRIUM"},
{"SCT", "68300000", "Right auricular appendage", ""},
{"SCT", "69833005", "Right femoral artery", "RFEMORALA"},
{"SCT", "272998002", "Right hepatic vein", "RHEPATICV"},
{"SCT", "133946002", "Right hypochondriac region", "RHYPOCHONDRIAC"},
{"SCT", "37117007", "Right inguinal region", "RINGUINAL"},
{"SCT", "48544008", "Right lower quadrant of abdomen", "RLQ"},
{"SCT", "1017211000", "Right lumbar region", "RLUMBAR"},
{"SCT", "73931004", "Right portal vein", "RPORTALV"},
{"SCT", "78480002", "Right pulmonary artery", "RPULMONARYA"},
{"SCT", "50519007", "Right upper quadrant of abdomen", "RUQ"},
{"SCT", "53085002", "Right ventricle", "RVENTRICLE"},
{"SCT", "8017000", "Right ventricle inflow", ""},
{"SCT", "44627009", "Right ventricle outflow tract", ""},
{"SCT", "39723000", "Sacroiliac joint", "SIJOINT"},
{"SCT", "54735007", "Sacrum", "SSPINE"},
{"SCT", "128587003", "Saphenofemoral junction", "SFJ"},
{"SCT", "362072009", "Saphenous vein", "SAPHENOUSV"},
{"SCT", "41695006", "Scalp", "SCALP"},
{"SCT", "79601000", "Scapula", "SCAPULA"},
{"SCT", "18619003", "Sclera", "SCLERA"},
{"SCT", "20233005", "Scrotum", "SCROTUM"},
{"SCT", "42575006", "Sella turcica", "SELLA"},
{"SCT", "64739004", "Seminal vesicle", "SEMVESICLE"},
{"SCT", "58742003", "Sesamoid bones of foot", "SESAMOID"},
{"SCT", "16982005", "Shoulder", "SHOULDER"},
{"SCT", "60184004", "Sigmoid colon", "SIGMOID"},
{"SCT", "89546000", "Skull", "SKULL"},
{"SCT", "30315005", "Small intestine", "SMALLINTESTINE"},
{"SCT", "2748008", "Spinal cord", "SPINALCORD"},
{"SCT", "421060004", "Spine", "SPINE"},
{"SCT", "78961009", "Spleen", "SPLEEN"},
{"SCT", "22083002", "Splenic artery", "SPLENICA"},
{"SCT", "35819009", "Splenic vein", "SPLENICV"},
{"SCT", "7844006", "Sternoclavicular joint", "SCJOINT"},
{"SCT", "56873002", "Sternum", "STERNUM"},
{"SCT", "69695003", "Stomach", "STOMACH"},
{"SCT", "36765005", "Subclavian artery", "SUBCLAVIANA"},
{"SCT", "9454009", "Subclavian vein", "SUBCLAVIANV"},
{"SCT", "19695001", "Subcostal", "SUBCOSTAL"},
{"SCT", "5713008", "Submandibular area", ""},
{"SCT", "54019009", "Submandibular gland", "SUBMANDIBULAR"},
{"SCT", "170887008", "Submental", ""},
{"SCT", "5076001", "Subxiphoid", ""},
{"SCT", "181349008", "Superficial femoral artery", "SFA"},
{"SCT", "397364003", "Superficial femoral vein", "SFV"},
{"SCT", "15672000", "Superficial temporal artery", ""},
{"SCT", "43863001", "Superior left pulmonary vein", "LSUPPULMONARYV"},
{"SCT", "42258001", "Superior mesenteric artery", "SMA"},
{"SCT", "8629005", "Superior right pulmonary vein", "RSUPPULMONARYV"},
{"SCT", "72021004", "Superior thyroid artery", "SUPTHYROIDA"},
{"SCT", "48345005", "Superior vena cava", "SVC"},
{"SCT", "77621008", "Supraclavicular region of neck", "SUPRACLAVICULAR"},
{"SCT", "11708003", "Suprapubic region", "SUPRAPUBIC"},
{"SCT", "26493002", "Suprasternal notch", ""},
{"SCT", "128589000", "Systemic collateral artery to lung", ""},
{"SCT", "128568009", "Systemic venous atrium", ""},
{"SCT", "27949001", "Tarsal joint", ""},
{"SCT", "53620006", "Temporomandibular joint", "TMJ"},
{"SCT", "40689003", "Testis", "TESTIS"},
{"SCT", "42695009", "Thalamus", "THALAMUS"},
{"SCT", "68367000", "Thigh", "THIGH"},
{"SCT", "49841001", "Third ventricle", "3RDVENTRICLE"},
{"SCT", "113262008", "Thoracic aorta", "THORACICAORTA"},
{"SCT", "122495006", "Thoracic spine", "TSPINE"},
{"SCT", "1217256009", "Thoraco-lumbar spine", "TLSPINE"},
{"SCT", "43799004", "Thorax", "THORAX"},
{"SCT", "76505004", "Thumb", "THUMB"},
{"SCT", "9875009", "Thymus", "THYMUS"},
{"SCT", "69748006", "Thyroid", "THYROID"},
{"SCT", "12611008", "Tibia", "TIBIA"},
{"SCT", "110536004", "Tibia and fibula", "TIBIAFIBULA"},
{"SCT", "29707007", "Toe", "TOE"},
{"SCT", "21974007", "Tongue", "TONGUE"},
{"SCT", "44567001", "Trachea", "TRACHEA"},
{"SCT", "110726009", "Trachea and bronchus", "TRACHEABRONCHUS"},
{"SCT", "485005", "Transverse colon", "TRANSVERSECOLON"},
{"SCT", "61959006", "Truncus arteriosus communis", ""},
{"SCT", "57850000", "Truncus coeliacus", ""},
{"SCT", "23416004", "Ulna", "ULNA"},
{"SCT", "44984001", "Ulnar artery", "ULNARA"},
{"SCT", "50536004", "Umbilical artery", "UMBILICALA"},
{"SCT", "90290004", "Umbilical region", "UMBILICAL"},
{"SCT", "284639000", "Umbilical vein", "UMBILICALV"},
{"SCT", "40983000", "Upper arm", "UPPERARM"},
{"SCT", "77831004", "Upper inner quadrant of breast", ""},
{"SCT", "53120007", "Upper limb", "UPPERLIMB"},
{"SCT", "76365002", "Upper outer quadrant of breast", ""},
{"SCT", "431491007", "Upper urinary tract", "UPRURINARYTRACT"},
{"SCT", "87953007", "Ureter", "URETER"},
{"SCT", "13648007", "Urethra", "URETHRA"},
{"SCT", "35039007", "Uterus", "UTERUS"},
{"SCT", "110639002", "Uterus and fallopian tubes", ""},
{"SCT", "76784001", "Vagina", "VAGINA"},
{"SCT", "118375008", "Vascular graft", ""},
{"SCT", "29092000", "Vein", "VEIN"},
{"SCT", "34340008", "Venous network", ""},
{"SCT", "21814001", "Ventricle", ""},
{"SCT", "85234005", "Vertebral artery", "VERTEBRALA"},
{"SCT", "110517009", "Vertebral column and cranium", ""},
{"SCT", "45292006", "Vulva", "VULVA"},
{"SCT", "74670003", "Wrist joint", "WRIST"},
{"SCT", "13881006", "Zygoma", "ZYGOMA"},
{"SCT", "818981001", "Abdomen", "ABDOMEN"},
{"SCT", "42694008", "All legs", "LEGS"},
{"SCT", "62555009", "Atlantal-axial joint", "ATLANTOAXIAL"},
{"SCT", "20292002", "Atlanto-occipital joint", "ATLANTOOCCIPITAL"},
{"SCT", "89837001", "Bladder", "BLADDER"},
{"SCT", "82474009", "Calcaneal tubercle", ""},
{"SCT", "8205005", "Carpus", "CARPUS"},
{"SCT", "122494005", "Cervical spine", "CSPINE"},
{"SCT", "1217257000", "Cervico-thoracic spine", "CTSPINE"},
{"SCT", "816094009", "Chest", "CHEST"},
{"SCT", "416550000", "Chest and Abdomen", "CHESTABDOMEN"},
{"SCT", "18149002", "Coccygeal vertrebrae", "TAIL"},
{"SCT", "71854001", "Colon", "COLON"},
{"SCT", "82680008", "Digit", "DIGIT"},
{"UMLS", "C3669027", "Distal phalanx", "DISTALPHALANX"},
{"SCT", "16953009", "Elbow joint", "ELBOW"},
{"SCT", "38266002", "Entire body", "WHOLEBODY"},
{"SCT", "32849002", "Esophagus", "ESOPHAGUS"},
{"SCT", "71341001", "Femur", "FEMUR"},
{"SCT", "13190002", "Fetlock of forelimb", "FOREFETLOCK"},
{"SCT", "113351006", "Fetlock of hindlimb", "HINDFETLOCK"},
{"SCT", "87342007", "Fibula", "FIBULA"},
{"SCT", "419176008", "Forefoot", "FOREFOOT"},
{"SCT", "55060009", "Frontal sinus", "FRONTALSINUS"},
{"SCT", "416804009", "Hindfoot", "HINDFOOT"},
{"SCT", "24136001", "Hip joint", "HIP"},
{"SCT", "85050009", "Humerus", "HUMERUS"},
{"SCT", "122496007", "Lumbar spine", "LSPINE"},
{"SCT", "1217253001", "Lumbo-sacral spine", "LSSPINE"},
{"SCT", "91609006", "Mandible", "JAW"},
{"SCT", "88176008", "Mandibular dental arch", ""},
{"SCT", "442274007", "Mandibular incisor teeth", ""},
{"SCT", "39481002", "Maxillary dental arch", ""},
{"SCT", "442100006", "Maxillary incisor teeth", ""},
{"SCT", "36455000", "Metacarpus", "METACARPUS"},
{"SCT", "280711000", "Metatarsus", "METATARSUS"},
{"SCT", "2095001", "Nasal sinus", ""},
{"SCT", "30518006", "Navicular of forefoot", "FORENAVICULAR"},
{"SCT", "75772009", "Navicular of hindfoot", "HINDNAVICULAR"},
{"SCT", "363654007", "Orbital structure", "ORBIT"},
{"SCT", "31329001", "Pastern of forefoot", "FOREPASTERN"},
{"SCT", "18525008", "Pastern of hindfoot", "HINDPASTERN"},
{"SCT", "64234005", "Patella", "PATELLA"},
{"SCT", "816092008", "Pelvis", "PELVIS"},
{"SCT", "62413002", "Radius", "RADIUS"},
{"SCT", "110535000", "Radius and ulna", "RADIUSULNA"},
{"SCT", "54735007", "Sacrum", "SSPINE"},
{"SCT", "16982005", "Shoulder", "SHOULDER"},
{"SCT", "89546000", "Skull", "SKULL"},
{"SCT", "116010006", "Stiffle", "STIFLE"},
{"SCT", "108371006", "Tarsus", "TARSUS"},
{"SCT", "122495006", "Thoracic spine", "TSPINE"},
{"SCT", "1217256009", "Thoraco-lumbar spine", "TLSPINE"},
{"SCT", "12611008", "Tibia", "TIBIA"},
{"SCT", "110536004", "Tibia and fibula", "TIBIAFIBULA"},
{"SCT", "62834003", "Upper gastro-intestinal tract", "UGITRACT"},
{"SCT", "23416004", "Ulna", "ULNA"},
{"SCT", "13648007", "Urethra", "URETHRA"},
{"SCT", "431938005", "Urinary tract", "URINARYTRACT"},
{"SCT", "53036007", "Wing", "WING"},
{"SCT", "23451007", "Adrenal gland", "ADRENAL"},
{"SCT", "70258002", "Ankle joint", "ANKLE"},
{"SCT", "15825003", "Aorta", "AORTA"},
{"SCT", "89837001", "Bladder", "BLADDER"},
{"SCT", "12738006", "Brain", "BRAIN"},
{"SCT", "76752008", "Breast", "BREAST"},
{"SCT", "955009", "Bronchus", "BRONCHUS"},
{"SCT", "60819002", "Buccal region of face", "CHEEK"},
{"SCT", "80144004", "Calcaneus", "CALCANEUS"},
{"SCT", "69105007", "Carotid Artery", "CAROTID"},
{"SCT", "113305005", "Cerebellum", "CEREBELLUM"},
{"SCT", "71252005", "Cervix", "CERVIX"},
{"SCT", "51299004", "Clavicle", "CLAVICLE"},
{"SCT", "64688005", "Coccyx", "COCCYX"},
{"SCT", "71854001", "Colon", "COLON"},
{"SCT", "28726007", "Cornea", "CORNEA"},
{"SCT", "41801008", "Coronary artery", "CORONARYARTERY"},
{"SCT", "82680008", "Digit", "DIGIT"},
{"SCT", "38848004", "Duodenum", "DUODENUM"},
{"SCT", "16953009", "Elbow joint", "ELBOW"},
{"SCT", "32849002", "Esophagus", "ESOPHAGUS"},
{"SCT", "66019005", "Extremity", "EXTREMITY"},
{"SCT", "81745001", "Eye", "EYE"},
{"SCT", "80243003", "Eyelid", "EYELID"},
{"SCT", "89545001", "Face", "FACE"},
{"SCT", "71341001", "Femur", "FEMUR"},
{"SCT", "87342007", "Fibula", "FIBULA"},
{"SCT", "7569003", "Finger", "FINGER"},
{"SCT", "56459004", "Foot", "FOOT"},
{"SCT", "55060009", "Frontal sinus", "FRONTALSINUS"},
{"SCT", "28231008", "Gallbladder", "GALLBLADDER"},
{"SCT", "85562004", "Hand", "HAND"},
{"SCT", "69536005", "Head", "HEAD"},
{"SCT", "774007", "Head and Neck", "HEADNECK"},
{"SCT", "80891009", "Heart", "HEART"},
{"SCT", "24136001", "Hip joint", "HIP"},
{"SCT", "85050009", "Humerus", "HUMERUS"},
{"SCT", "34516001", "Ileum", "ILEUM"},
{"SCT", "22356005", "Ilium", "ILIUM"},
{"SCT", "661005", "Jaw region", "JAW"},
{"SCT", "21306003", "Jejunum", "JEJUNUM"},
{"SCT", "64033007", "Kidney", "KIDNEY"},
{"SCT", "10200004", "Liver", "LIVER"},
{"SCT", "30021000", "Lower leg", "LEG"},
{"SCT", "39607008", "Lung", "LUNG"},
{"SCT", "91609006", "Mandible", "JAW"},
{"SCT", "70925003", "Maxilla", "MAXILLA"},
{"SCT", "30518006", "Navicular of forefoot", "FORENAVICULAR"},
{"SCT", "45048000", "Neck", "NECK"},
{"SCT", "363654007", "Orbital structure", "ORBIT"},
{"SCT", "15497006", "Ovary", "OVARY"},
{"SCT", "15776009", "Pancreas", "PANCREAS"},
{"SCT", "45289007", "Parotid gland", "PAROTID"},
{"SCT", "64234005", "Patella", "PATELLA"},
{"SCT", "816092008", "Pelvis", "PELVIS"},
{"SCT", "18911002", "Penis", "PENIS"},
{"SCT", "54066008", "Pharynx", "PHARYNX"},
{"SCT", "62413002", "Radius", "RADIUS"},
{"SCT", "34402009", "Rectum", "RECTUM"},
{"SCT", "113197003", "Rib", "RIB"},
{"SCT", "79601000", "Scapula", "SCAPULA"},
{"SCT", "18619003", "Sclera", "SCLERA"},
{"SCT", "20233005", "Scrotum", "SCROTUM"},
{"SCT", "16982005", "Shoulder", "SHOULDER"},
{"SCT", "89546000", "Skull", "SKULL"},
{"SCT", "78961009", "Spleen", "SPLEEN"},
{"SCT", "56873002", "Sternum", "STERNUM"},
{"SCT", "53620006", "Temporomandibular joint", "TMJ"},
{"SCT", "40689003", "Testis", "TESTIS"},
{"SCT", "68367000", "Thigh", "THIGH"},
{"SCT", "76505004", "Thumb", "THUMB"},
{"SCT", "9875009", "Thymus", "THYMUS"},
{"SCT", "69748006", "Thyroid", "THYROID"},
{"SCT", "12611008", "Tibia", "TIBIA"},
{"SCT", "29707007", "Toe", "TOE"},
{"SCT", "21974007", "Tongue", "TONGUE"},
{"SCT", "23416004", "Ulna", "ULNA"},
{"SCT", "40983000", "Upper arm", "ARM"},
{"SCT", "87953007", "Ureter", "URETER"},
{"SCT", "13648007", "Urethra", "URETHRA"},
{"SCT", "35039007", "Uterus", "UTERUS"},
{"SCT", "76784001", "Vagina", "VAGINA"},
{"SCT", "45292006", "Vulva", "VULVA"}});
// https://wiki.cancerimagingarchive.net/display/Public/De-identification+Knowledge+Base
nlohmann::json work = nlohmann::json::array({
{"0008", "0050", "AccessionNumber", "hash"},
{"0018", "4000", "AcquisitionComments", "keep"},
{"0040", "0555", "AcquisitionContextSeq", "remove"},
{"0008", "0022", "AcquisitionDate", "incrementdate"},
{"0008", "002a", "AcquisitionDateTime", "incrementdatetime"},
{"0018", "1400", "AcquisitionDeviceProcessingDescription", "keep"},
{"0018", "9424", "AcquisitionProtocolDescription", "keep"},
{"0008", "0032", "AcquisitionTime", "keep"},
{"0040", "4035", "ActualHumanPerformersSequence", "remove"},
{"0010", "21b0", "AdditionalPatientHistory", "keep"},
{"0038", "0010", "AdmissionID", "remove"},
{"0038", "0020", "AdmittingDate", "incrementdate"},
{"0008", "1084", "AdmittingDiagnosesCodeSeq", "keep"},
{"0008", "1080", "AdmittingDiagnosesDescription", "keep"},
{"0038", "0021", "AdmittingTime", "keep"},
{"0010", "2110", "Allergies", "keep"},
{"4000", "0010", "Arbitrary", "remove"},
{"0040", "a078", "AuthorObserverSequence", "remove"},
{"0013", "0010", "BlockOwner", "CTP"},
{"0018", "0015", "BodyPartExamined", "BODYPART"},
{"0010", "1081", "BranchOfService", "remove"},
{"0028", "0301", "BurnedInAnnotation", "keep"},
{"0018", "1007", "CassetteID", "keep"},
{"0040", "0280", "CommentsOnPPS", "keep"},
{"0020", "9161", "ConcatenationUID", "hashuid"},
{"0040", "3001", "ConfidentialityPatientData", "remove"},
{"0070", "0086", "ContentCreatorsIdCodeSeq", "remove"},
{"0070", "0084", "ContentCreatorsName", "empty"},
{"0008", "0023", "ContentDate", "incrementdate"},
{"0040", "a730", "ContentSeq", "remove"},
{"0008", "0033", "ContentTime", "keep"},
{"0008", "010d", "ContextGroupExtensionCreatorUID", "hashuid"},
{"0018", "0010", "ContrastBolusAgent", "keep"},
{"0018", "a003", "ContributionDescription", "keep"},
{"0010", "2150", "CountryOfResidence", "remove"},
{"0008", "9123", "CreatorVersionUID", "hashuid"},
{"0038", "0300", "CurrentPatientLocation", "remove"},
{"0008", "0025", "CurveDate", "incrementdate"},
{"0008", "0035", "CurveTime", "keep"},
{"0040", "a07c", "CustodialOrganizationSeq", "remove"},
{"fffc", "fffc", "DataSetTrailingPadding", "remove"},
{"0018", "1200", "DateofLastCalibration", "incrementdate"},
{"0018", "700c", "DateofLastDetectorCalibration", "incrementdate"},
{"0018", "1012", "DateOfSecondaryCapture", "incrementdate", "", "createIfMissing"},
{"0012", "0063", "DeIdentificationMethod", "{Per DICOM PS 3.15 AnnexE}", "", "createIfMissing"},
{"0012", "0064", "DeIdentificationMethodCodeSequence", "113100/113101/113105/113107/113108/113109/113111", "",
"createIfMissing"}, // TODO: this has to be written as SQ? We don't need this field if DeIdentificationMethod is there...
{"0012", "0062", "PatientIdentityRemoved", "YES", "", "createIfMissing"},
{"0012", "0020", "Clinical Trial Protocol ID", "ProjectName", "", "createIfMissing"},
{"0012", "0021", "Clinical Trial Protocol Name", "ProjectName", "", "createIfMissing"},
{"0012", "0040", "Clinical Trial Subject ID", "PatientID", "", "createIfMissing"},
{"0012", "0050", "Clinical Trial Time Point ID", "EventName", "", "createIfMissing"},
{"0012", "0051", "Clinical Trial Time Point Description", "EventName", "", "createIfMissing"},
{"0008", "2111", "DerivationDescription", "keep"},
{"0018", "700a", "DetectorID", "keep"},
{"0018", "1000", "DeviceSerialNumber", "keep"},
{"0018", "1002", "DeviceUID", "keep"},
{"fffa", "fffa", "DigitalSignaturesSeq", "remove"},
{"0400", "0100", "DigitalSignatureUID", "remove"},
{"0020", "9164", "DimensionOrganizationUID", "hashuid"},
{"0038", "0040", "DischargeDiagnosisDescription", "keep"},
{"4008", "011a", "DistributionAddress", "remove"},
{"4008", "0119", "DistributionName", "remove"},
{"300a", "0013", "DoseReferenceUID", "hashuid"},
{"0010", "2160", "EthnicGroup", "keep"},
{"0008", "0058", "FailedSOPInstanceUIDList", "hashuid"},
{"0070", "031a", "FiducialUID", "hashuid"},
{"0040", "2017", "FillerOrderNumber", "empty"},
{"0020", "9158", "FrameComments", "keep"},
{"0020", "0052", "FrameOfReferenceUID", "hashuid+PROJECTNAME"},
{"0018", "1008", "GantryID", "keep"},
{"0018", "1005", "GeneratorID", "keep"},
//{"0070", "0001", "GraphicAnnotationSequence", "remove"},
{"0040", "4037", "HumanPerformersName", "remove"},
{"0040", "4036", "HumanPerformersOrganization", "remove"},
{"0088", "0200", "IconImageSequence", "remove"},
{"0008", "4000", "IdentifyingComments", "keep"},
{"0020", "4000", "ImageComments", "keep"},
{"0028", "4000", "ImagePresentationComments", "remove"},
{"0040", "2400", "ImagingServiceRequestComments", "keep"},
{"4008", "0300", "Impressions", "keep"},
{"0008", "0012", "InstanceCreationDate", "incrementdate"},
{"0008", "0014", "InstanceCreatorUID", "hashuid"},
{"0008", "0081", "InstitutionAddress", "remove"},
{"0008", "1040", "InstitutionalDepartmentName", "remove"},
{"0008", "0082", "InstitutionCodeSequence", "remove"},
{"0008", "0080", "InstitutionName", "ProjectName", "", "createIfMissing"},
{"0010", "1050", "InsurancePlanIdentification", "remove"},
{"0040", "1011", "IntendedRecipientsOfResultsIDSequence", "remove"},
{"4008", "0111", "InterpretationApproverSequence", "remove"},
{"4008", "010c", "InterpretationAuthor", "remove"},
{"4008", "0115", "InterpretationDiagnosisDescription", "keep"},
{"4008", "0202", "InterpretationIdIssuer", "remove"},
{"4008", "0102", "InterpretationRecorder", "remove"},
{"4008", "010b", "InterpretationText", "keep"},
{"4008", "010a", "InterpretationTranscriber", "remove"},
{"0008", "3010", "IrradiationEventUID", "hashuid"},
{"0038", "0011", "IssuerOfAdmissionID", "remove"},
{"0010", "0021", "IssuerOfPatientID", "remove"},
{"0038", "0061", "IssuerOfServiceEpisodeId", "remove"},
{"0028", "1214", "LargePaletteColorLUTUid", "hashuid"},
{"0010", "21d0", "LastMenstrualDate", "incrementdate"},
{"0028", "0303", "LongitudinalTemporalInformationModified", "MODIFIED"},
{"0400", "0404", "MAC", "remove"},
{"0008", "0070", "Manufacturer", "keep"},
{"0008", "1090", "ManufacturerModelName", "keep"},
{"0010", "2000", "MedicalAlerts", "keep"},
{"0010", "1090", "MedicalRecordLocator", "remove"},
{"0010", "1080", "MilitaryRank", "remove"},
{"0400", "0550", "ModifiedAttributesSequence", "remove"},
{"0020", "3406", "ModifiedImageDescription", "remove"},
{"0020", "3401", "ModifyingDeviceID", "remove"},
{"0020", "3404", "ModifyingDeviceManufacturer", "remove"},
{"0008", "1060", "NameOfPhysicianReadingStudy", "remove"},
{"0040", "1010", "NamesOfIntendedRecipientsOfResults", "remove"},
{"0010", "2180", "Occupation", "keep"},
{"0008", "1070", "OperatorName", "remove"},
{"0008", "1072", "OperatorsIdentificationSeq", "remove"},
{"0040", "2010", "OrderCallbackPhoneNumber", "remove"},
{"0040", "2008", "OrderEnteredBy", "remove"},
{"0040", "2009", "OrderEntererLocation", "remove"},
{"0400", "0561", "OriginalAttributesSequence", "remove"},
{"0010", "1000", "OtherPatientIDs", "remove"},
{"0010", "1002", "OtherPatientIDsSeq", "remove"},
{"0010", "1001", "OtherPatientNames", "remove"},
{"0008", "0024", "OverlayDate", "incrementdate"},
{"0008", "0034", "OverlayTime", "keep"},
{"0028", "1199", "PaletteColorLUTUID", "hashuid"},
{"0040", "a07a", "ParticipantSequence", "remove"},
{"0010", "1040", "PatientAddress", "remove"},
{"0010", "1010", "PatientAge", "keep"},
{"0010", "0030", "PatientBirthDate", "empty"},
{"0010", "1005", "PatientBirthName", "remove"},
{"0010", "0032", "PatientBirthTime", "remove"},
{"0010", "4000", "PatientComments", "keep"},
{"0010", "0020", "PatientID", "Re-Mapped", "", "createIfMissing"},
{"0038", "0400", "PatientInstitutionResidence", "remove"},
{"0010", "0050", "PatientInsurancePlanCodeSeq", "remove"},
{"0010", "1060", "PatientMotherBirthName", "remove"},
{"0010", "0010", "PatientName", "Re-Mapped", "", "createIfMissing"},
{"0010", "2154", "PatientPhoneNumbers", "remove"},
{"0010", "0101", "PatientPrimaryLanguageCodeSeq", "remove"},
{"0010", "0102", "PatientPrimaryLanguageModifierCodeSeq", "remove"},
{"0010", "21f0", "PatientReligiousPreference", "remove"},
{"0010", "0040", "PatientSex", "keep"},
{"0010", "2203", "PatientSexNeutered", "keep"},
{"0010", "1020", "PatientSize", "keep"},
{"0038", "0500", "PatientState", "keep"},
{"0040", "1004", "PatientTransportArrangements", "remove"},
{"0010", "1030", "PatientWeight", "keep"},
{"0040", "0243", "PerformedLocation", "remove"},
{"0040", "0241", "PerformedStationAET", "keep"},
{"0040", "0244", "PerformedProcedureStepStartDate", "incrementdate"},
{"0040", "4030", "PerformedStationGeoLocCodeSeq", "keep"},
{"0040", "0242", "PerformedStationName", "keep"},
{"0040", "4028", "PerformedStationNameCodeSeq", "keep"},
{"0008", "1052", "PerformingPhysicianIdSeq", "remove"},
{"0008", "1050", "PerformingPhysicianName", "remove"},
{"0040", "0250", "PerformProcedureStepEndDate", "incrementdate"},
{"0040", "1102", "PersonAddress", "remove"},
{"0040", "1101", "PersonIdCodeSequence", "remove"},
{"0040", "a123", "PersonName", "empty"},
{"0040", "1103", "PersonTelephoneNumbers", "remove"},
{"4008", "0114", "PhysicianApprovingInterpretation", "remove"},
{"0008", "1048", "PhysicianOfRecord", "remove"},
{"0008", "1049", "PhysicianOfRecordIdSeq", "remove"},
{"0008", "1062", "PhysicianReadingStudyIdSeq", "remove"},
{"0040", "2016", "PlaceOrderNumberOfImagingServiceReq", "empty"},
{"0018", "1004", "PlateID", "keep"},
{"0040", "0254", "PPSDescription", "keep"},
{"0040", "0253", "PPSID", "remove"},
{"0040", "0244", "PPSStartDate", "incrementdate"},
{"0040", "0245", "PPSStartTime", "keep"},
{"0010", "21c0", "PregnancyStatus", "keep"},
{"0040", "0012", "PreMedication", "keep"},
{"0013", "1010", "ProjectName", "always"},
{"0018", "1030", "ProtocolName", "keep"},
{"0054", "0016", "Radiopharmaceutical Information Sequence", "process"},
{"0018", "1078", "Radiopharmaceutical Start DateTime", "incrementdatetime"},
{"0018", "1079", "Radiopharmaceutical Stop DateTime", "incrementdatetime"},
{"0040", "2001", "ReasonForImagingServiceRequest", "keep"},
{"0032", "1030", "ReasonforStudy", "keep"},
{"0400", "0402", "RefDigitalSignatureSeq", "remove"},
{"3006", "0024", "ReferencedFrameOfReferenceUID", "hashuid+PROJECTNAME"},
{"0038", "0004", "ReferencedPatientAliasSeq", "remove"},
{"0008", "0092", "ReferringPhysicianAddress", "remove"},
{"0008", "0090", "ReferringPhysicianName", "empty", "", "createIfMissing"},
{"0008", "0094", "ReferringPhysicianPhoneNumbers", "remove"},
{"0008", "0096", "ReferringPhysiciansIDSeq", "remove"},
{"0040", "4023", "RefGenPurposeSchedProcStepTransUID", "hashuid"},
//{"0008", "1140", "RefImageSeq", "remove"},
{"0008", "1120", "RefPatientSeq", "remove"},
{"0008", "1111", "RefPPSSeq", "remove"},
{"0008", "1150", "RefSOPClassUID", "keep"},
{"0400", "0403", "RefSOPInstanceMACSeq", "remove"},
{"0008", "1155", "RefSOPInstanceUID", "hashuid+PROJECTNAME"},
//{"0008", "1110", "RefStudySeq", "remove"},
{"0010", "2152", "RegionOfResidence", "remove"},
{"3006", "00c2", "RelatedFrameOfReferenceUID", "hashuid+PROJECTNAME"},
{"0040", "0275", "RequestAttributesSeq", "remove"},
{"0032", "1070", "RequestedContrastAgent", "keep"},
{"0040", "1400", "RequestedProcedureComments", "keep"},
{"0032", "1060", "RequestedProcedureDescription", "keep"},
{"0040", "1001", "RequestedProcedureID", "remove"},
{"0040", "1005", "RequestedProcedureLocation", "remove"},
{"0032", "1032", "RequestingPhysician", "remove"},
{"0032", "1033", "RequestingService", "remove"},
{"0010", "2299", "ResponsibleOrganization", "remove"},
{"0010", "2297", "ResponsiblePerson", "remove"},
{"4008", "4000", "ResultComments", "keep"},
{"4008", "0118", "ResultsDistributionListSeq", "remove"},
{"4008", "0042", "ResultsIDIssuer", "remove"},
{"300e", "0008", "ReviewerName", "remove"},
{"0040", "4034", "ScheduledHumanPerformersSeq", "remove"},
{"0038", "001e", "ScheduledPatientInstitutionResidence", "remove"},
{"0040", "000b", "ScheduledPerformingPhysicianIDSeq", "remove"},
{"0040", "0006", "ScheduledPerformingPhysicianName", "remove"},
{"0040", "0001", "ScheduledStationAET", "keep"},
{"0040", "4027", "ScheduledStationGeographicLocCodeSeq", "keep"},
{"0040", "0010", "ScheduledStationName", "keep"},
{"0040", "4025", "ScheduledStationNameCodeSeq", "keep"},
{"0032", "1020", "ScheduledStudyLocation", "keep"},
{"0032", "1021", "ScheduledStudyLocationAET", "keep"},
{"0032", "1000", "ScheduledStudyStartDate", "incrementdate"},
{"0008", "0021", "SeriesDate", "incrementdate"},
{"0008", "103e", "SeriesDescription", "keep"},
{"0020", "000e", "SeriesInstanceUID", "hashuid+PROJECTNAME"},
{"0008", "0031", "SeriesTime", "keep"},
{"0038", "0062", "ServiceEpisodeDescription", "keep"},
{"0038", "0060", "ServiceEpisodeID", "remove"},
{"0013", "1013", "SiteID", "SITEID"},
{"0013", "1012", "SiteName", "SITENAME"},
{"0010", "21a0", "SmokingStatus", "keep"},
{"0018", "1020", "SoftwareVersion", "keep"},
{"0008", "0018", "SOPInstanceUID", "hashuid+PROJECTNAME"},
{"0008", "2112", "SourceImageSeq", "remove"},
{"0038", "0050", "SpecialNeeds", "keep"},
{"0040", "0007", "SPSDescription", "keep"},
{"0040", "0004", "SPSEndDate", "incrementdate"},
{"0040", "0005", "SPSEndTime", "keep"},
{"0040", "0011", "SPSLocation", "keep"},
{"0040", "0002", "SPSStartDate", "incrementdate"},
{"0040", "0003", "SPSStartTime", "keep"},
{"0008", "1010", "StationName", "remove"},
{"0088", "0140", "StorageMediaFilesetUID", "hashuid"},
{"3006", "0008", "StructureSetDate", "incrementdate"},
{"0032", "1040", "StudyArrivalDate", "incrementdate"},
{"0032", "4000", "StudyComments", "keep"},
{"0032", "1050", "StudyCompletionDate", "incrementdate"},
{"0008", "0020", "StudyDate", "incrementdate", "", "createIfMissing"},
{"0008", "1030", "StudyDescription", "keep"},
{"0020", "0010", "StudyID", "hash"},
{"0032", "0012", "StudyIDIssuer", "remove"},
{"0020", "000d", "StudyInstanceUID", "hashuid+PROJECTNAME"},
{"0008", "0030", "StudyTime", "keep", "", "createIfMissing"},
{"0020", "0200", "SynchronizationFrameOfReferenceUID", "hashuid"},
{"0040", "db0d", "TemplateExtensionCreatorUID", "hashuid"},
{"0040", "db0c", "TemplateExtensionOrganizationUID", "hashuid"},
{"4000", "4000", "TextComments", "remove"},
{"2030", "0020", "TextString", "remove"},
{"0008", "0201", "TimezoneOffsetFromUTC", "remove"},
{"0088", "0910", "TopicAuthor", "remove"},
{"0088", "0912", "TopicKeyWords", "remove"},
{"0088", "0906", "TopicSubject", "remove"},
{"0088", "0904", "TopicTitle", "remove"},
{"0008", "1195", "TransactionUID", "hashuid"},
{"0013", "1011", "TrialName", "PROJECTNAME"},
{"0040", "a124", "UID", "hashuid"},
{"0040", "a088", "VerifyingObserverIdentificationCodeSeq", "remove"},
{"0040", "a075", "VerifyingObserverName", "empty"},
{"0040", "a073", "VerifyingObserverSequence", "remove"},
{"0040", "a027", "VerifyingOrganization", "remove"},
{"0038", "4000", "VisitComments", "keep"},
{"0033", "1013", "MITRA OBJECT UTF8 ATTRIBUTES 1.0",/*"SomeSiemensMITRA",*/ "remove"},
{"0033", "1016", "MITRA OBJECT UTF8 ATTRIBUTES 1.0",/*"SomeSiemensMITRA",*/ "remove"},
{"0033", "1019", "MITRA OBJECT UTF8 ATTRIBUTES 1.0",/*"SomeSiemensMITRA",*/ "remove"},
{"0033", "101c", "MITRA OBJECT UTF8 ATTRIBUTES 1.0",/*"SomeSiemensMITRA",*/ "remove"},
{"0009", "1001", "SectraIdentRequestID", "remove"}, // if 0009,0010 is SECTRA_Ident_01
{"0009", "1002", "SectraIdentExaminationID", "remove"}, // if 0009,0010 is SECTRA_Ident_01
{"0071", "1022", "SIEMENS MED PT", "incrementdatetime"},
});
std::map<std::string, int> workCache;
void createWorkCache() {
for (int i = 0; i < work.size(); i++) {
std::string key = std::string(work[i][0]) + std::string(work[i][1]);
if (workCache.find(key) == workCache.end()) {
// add this entry
workCache.insert(std::pair<std::string, int>{key,i});
}
}
}
std::string limitToMaxLength(gdcm::Tag t, std::string& str_in, const gdcm::DataSet& ds) {
const gdcm::DataElement& de = ds.GetDataElement(t);
gdcm::VR vr = de.GetVR();
std::string VRName = gdcm::VR::GetVRString(vr);
if (VRName == "??") // don't know, do nothing
return std::string(str_in);
/*if (str_in.size()%2!=0) { // odd length for this value, make even length by adding null or space
if (VRName != "UI") {
str_in += " ";
} else { // but what about binary, this is only if its isASCII
str_in += '\0';
}
}*/
std::unordered_map<std::string, uint32_t> max_lengths = {
{"AE", 16},
{"AS", 4},
{"AT", 4},
{"CS", 16},
{"DA", 8},
{"DS", 16},
{"DT", 26},
{"FL", 4},
{"FD", 8},
{"IS", 12},
{"LO", 64},
{"LT", 10240},
{"SH", 16},
{"SL", 4},
{"SS", 2},
{"ST", 1024},
{"TM", 16},
{"UI", 64},
{"UL", 4},
{"US", 2}
};
auto max_length_it = max_lengths.find(VRName);
if (max_length_it == max_lengths.end())
return std::string(str_in); // do nothing
// some elements need a space to get to even length, some need a null byte
// see: https://dicom.nema.org/dicom/2013/output/chtml/part05/sect_6.2.html
uint32_t max_l = max_length_it->second;
if (max_l == 0)
return std::string(str_in); // should never happen
if (str_in.length() > max_l) {
std::string str_limited = str_in.substr(0, max_l);
if (debug_level > 2)
fprintf(stderr, "Warning: tag (%04x,%04x) value too long (%zu), max: %u for VR: %s, will be truncated.\n",
t.GetGroup(), t.GetElement(), str_in.length(), max_l, gdcm::VR::GetVRString(vr));
return str_limited;
}
return std::string(str_in);
}
/*std::string limitToMaxLength(gdcm::Tag t, std::string str_in, gdcm::DataSet &ds) {
// what is the value representation?
const gdcm::DataElement& de = ds.GetDataElement( t );
gdcm::VR vr = de.GetVR();
std::string VRName = gdcm::VR::GetVRString(vr);
if (VRName == "??") // don't know, do nothing
return str_in;
uint32_t max_l = 0;
if (VRName == "AE")
max_l = 16;
else if (VRName == "AS")
max_l = 4;
else if (VRName == "AT")
max_l = 4;
else if (VRName == "CS")
max_l = 16;
else if (VRName == "DA")
max_l = 8;
else if (VRName == "DS")
max_l = 16;
else if (VRName == "DT")
max_l = 26;
else if (VRName == "FL")
max_l = 4;
else if (VRName == "FD")
max_l = 8;