@@ -25,24 +25,6 @@ const DICOM_DICTIONARY = {
25
25
}
26
26
27
27
class DICOMEntity {
28
- constructor ( ) {
29
- this . checkTagsValidity ( ) // could it be a static assertion instead?
30
- }
31
-
32
- checkTagsValidity ( ) {
33
- const name = this . constructor . name
34
- const tags = this . constructor . tags
35
- const primaryTag = this . constructor . primaryTag
36
- if ( ! tags . includes ( primaryTag ) ) {
37
- throw Error ( `The primary tag of the ${ name } class ("${ primaryTag } ") is not included in its list of tags ([${ tags } ]).` )
38
- }
39
- tags . forEach ( ( tag ) => {
40
- if ( ! ( tag in DICOM_DICTIONARY ) ) {
41
- throw Error ( `The tag "${ tag } " associated with the ${ name } class is not defined in DICOM_DICTIONARY.` )
42
- }
43
- } )
44
- }
45
-
46
28
extractTags ( dicomMetaData ) {
47
29
const name = this . constructor . name
48
30
const tags = this . constructor . tags
@@ -156,6 +138,23 @@ class DICOMSerie extends DICOMEntity {
156
138
}
157
139
}
158
140
141
+ function checkTagsValidity ( klass ) {
142
+ const name = klass . name
143
+ const tags = klass . tags
144
+ const primaryTag = klass . primaryTag
145
+ if ( ! tags . includes ( primaryTag ) ) {
146
+ throw Error ( `The primary tag of the ${ name } class ("${ primaryTag } ") is not included in its list of tags ([${ tags } ]).` )
147
+ }
148
+ tags . forEach ( ( tag ) => {
149
+ if ( ! ( tag in DICOM_DICTIONARY ) ) {
150
+ throw Error ( `The tag "${ tag } " associated with the ${ name } class is not defined in DICOM_DICTIONARY.` )
151
+ }
152
+ } )
153
+ }
154
+ checkTagsValidity ( DICOMPatient )
155
+ checkTagsValidity ( DICOMStudy )
156
+ checkTagsValidity ( DICOMSerie )
157
+
159
158
class ParseDicomError extends Error {
160
159
constructor ( failures ) {
161
160
const message =
0 commit comments