@radicalimaging/static-wado-creator 0.6.5 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,119 +0,0 @@
1
- const dcmjs = require("dcmjs");
2
- const dataDictionary = require("./dataDictionary");
3
-
4
- const { naturalizeDataset, denaturalizeDataset } = dcmjs.data.DicomMetaDictionary;
5
-
6
- /** Find the actual tag for a private value */
7
- const findPrivate = (item, tagObject, create) => {
8
- if (typeof tagObject === "string") return tagObject;
9
- if (typeof tagObject === "number") return `00000000${tagObject.toString(16)}`.slice(-8);
10
- const { creator, tag } = tagObject;
11
- if (!creator) return tag;
12
- const start = tag.substring(0, 4);
13
- const end = tag.substring(6, 8);
14
- // Should technically go all the way up, but for now only test 0x30 items
15
- let assignPosition;
16
- for (let offset = 0x10; offset < 0x40; offset++) {
17
- const testTag = `${start}00${offset.toString(16)}`;
18
- const testCreator = item[testTag];
19
- if (testCreator === undefined && assignPosition === undefined) assignPosition = offset;
20
- if (testCreator && testCreator.Value && testCreator.Value[0] === creator) {
21
- return `${start}${offset.toString(16)}${end}`;
22
- }
23
- }
24
- if (create) {
25
- if (!assignPosition) throw new Error(`Couldn't find any assign positions for ${creator} ${tag} in ${item}`);
26
- const creatorTag = `${start}00${assignPosition.toString(16)}`;
27
- item[creatorTag] = { Value: [creator], vr: "CS" };
28
- return `${start}${assignPosition.toString(16)}${end}`;
29
- }
30
- };
31
-
32
- const DeduppedCreator = "dedupped";
33
-
34
- const Tags = {
35
- // Raw tags have the x before them, not parsed yet
36
- RawMinTag: "x00000000",
37
- RawFirstBodyTag: "x00080000",
38
- RawTransferSyntaxUID: "x00020010",
39
- RawSopInstanceUID: "x00080018",
40
-
41
- // This one isn't defined in the dataDictionary
42
- AvailableTransferSyntaxUID: "00083002",
43
-
44
- DeduppedCreator,
45
-
46
- // The references to extract data included in this object, 1..n values
47
- DeduppedRef: { creator: DeduppedCreator, tag: "00091010" },
48
-
49
- // The hash value of THIS object
50
- DeduppedHash: { creator: DeduppedCreator, tag: "00091011" },
51
-
52
- // Type of hash instance
53
- DeduppedType: { creator: DeduppedCreator, tag: "00091012" },
54
- InstanceType: "instance",
55
- InfoType: "info",
56
-
57
- naturalizeDataset,
58
- denaturalizeDataset,
59
-
60
- setValue: (item, tag, value) => {
61
- const actualTag = findPrivate(item, tag, true);
62
- item[actualTag] = { Value: Array.isArray(value) ? value : [value] };
63
- return actualTag;
64
- },
65
-
66
- setList: (item, tag, value) => {
67
- const actualTag = findPrivate(item, tag, true);
68
- item[actualTag] = { Value: Array.isArray(value) ? value : [value] };
69
- return actualTag;
70
- },
71
-
72
- pushList: (item, tag, value) => {
73
- const actualTag = findPrivate(item, tag, true);
74
- if (!item[actualTag]) item[actualTag] = { Value: [] };
75
- item[actualTag].Value.push(value);
76
- return actualTag;
77
- },
78
-
79
- getValue: (item, tag) => {
80
- const actualTag = findPrivate(item, tag);
81
- if (!actualTag) return undefined;
82
- const value = item[actualTag];
83
- if (value === undefined) return undefined;
84
- if (Array.isArray(value)) {
85
- if (value.length == 1) return value[0];
86
- return value.length === 0 ? "" : value;
87
- }
88
- if (value.Value) {
89
- if (value.Value.length == 1) return value.Value[0];
90
- return value.Value.length === 0 ? "" : value.Value;
91
- }
92
- return value;
93
- },
94
-
95
- getList: (item, tag) => {
96
- const actualTag = findPrivate(item, tag);
97
- if (!actualTag) return undefined;
98
- const value = item[actualTag];
99
- if (value === undefined) return undefined;
100
- if (Array.isArray(value)) return value;
101
- if (value.Value) return value.Value;
102
- return [value];
103
- },
104
-
105
- removeValue: (item, tag) => {
106
- const actualTag = findPrivate(item, tag);
107
- if (actualTag) delete item[actualTag];
108
- // TODO, remove creator tag if not used any longer
109
- },
110
-
111
- findPrivate,
112
- };
113
-
114
- Object.keys(dataDictionary).forEach((key) => {
115
- const value = dataDictionary[key];
116
- Tags[value.name] = key;
117
- });
118
-
119
- module.exports = Tags;