@ubercode/dcmtk 0.1.1 → 0.2.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.
Files changed (41) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +18 -15
  3. package/dist/DicomInstance-By9zd7GM.d.cts +625 -0
  4. package/dist/DicomInstance-CQEIuF_x.d.ts +625 -0
  5. package/dist/{dcmodify-CTXBWKU9.d.cts → dcmodify-B-_uUIKB.d.ts} +4 -2
  6. package/dist/{dcmodify-Daeafqrm.d.ts → dcmodify-Gds9u5Vj.d.cts} +4 -2
  7. package/dist/dicom.cjs +329 -51
  8. package/dist/dicom.cjs.map +1 -1
  9. package/dist/dicom.d.cts +368 -3
  10. package/dist/dicom.d.ts +368 -3
  11. package/dist/dicom.js +329 -51
  12. package/dist/dicom.js.map +1 -1
  13. package/dist/index.cjs +1460 -419
  14. package/dist/index.cjs.map +1 -1
  15. package/dist/index.d.cts +8 -7
  16. package/dist/index.d.ts +8 -7
  17. package/dist/index.js +1432 -413
  18. package/dist/index.js.map +1 -1
  19. package/dist/servers.cjs +2379 -196
  20. package/dist/servers.cjs.map +1 -1
  21. package/dist/servers.d.cts +1654 -3
  22. package/dist/servers.d.ts +1654 -3
  23. package/dist/servers.js +2305 -145
  24. package/dist/servers.js.map +1 -1
  25. package/dist/tools.cjs +97 -50
  26. package/dist/tools.cjs.map +1 -1
  27. package/dist/tools.d.cts +21 -4
  28. package/dist/tools.d.ts +21 -4
  29. package/dist/tools.js +97 -51
  30. package/dist/tools.js.map +1 -1
  31. package/dist/{types-zHhxS7d2.d.cts → types-Cgumy1N4.d.cts} +1 -24
  32. package/dist/{types-zHhxS7d2.d.ts → types-Cgumy1N4.d.ts} +1 -24
  33. package/dist/utils.cjs.map +1 -1
  34. package/dist/utils.d.cts +1 -1
  35. package/dist/utils.d.ts +1 -1
  36. package/dist/utils.js.map +1 -1
  37. package/package.json +8 -8
  38. package/dist/index-BZxi4104.d.ts +0 -826
  39. package/dist/index-CapkWqxy.d.ts +0 -1295
  40. package/dist/index-DX4C3zbo.d.cts +0 -826
  41. package/dist/index-r7AvpkCE.d.cts +0 -1295
@@ -1,826 +0,0 @@
1
- import { R as Result } from './types-zHhxS7d2.cjs';
2
- import { b as DicomJsonElement, T as TagModification } from './dcmodify-CTXBWKU9.cjs';
3
-
4
- /**
5
- * Branded types for domain primitives.
6
- *
7
- * Branded types use TypeScript's structural type system to prevent accidental
8
- * mixing of semantically different values that share the same underlying type.
9
- * A `DicomTag` cannot be used where an `AETitle` is expected, even though both
10
- * are strings at runtime.
11
- *
12
- * @module brands
13
- */
14
-
15
- declare const __brand: unique symbol;
16
- /** Intersects a base type with a phantom brand property for nominal typing. */
17
- type Brand<T, TBrand extends string> = T & {
18
- readonly [__brand]: TBrand;
19
- };
20
- /**
21
- * A validated DICOM tag string, e.g. `"(0010,0010)"`.
22
- *
23
- * @remarks
24
- * Branded types enforce type safety when passing values between functions.
25
- * They are not required for direct API calls (which validate internally via Zod).
26
- * Use {@link createDicomTag} to obtain a branded value from a raw string.
27
- */
28
- type DicomTag = Brand<string, 'DicomTag'>;
29
- /**
30
- * A validated AE Title (1-16 chars: uppercase letters, digits, spaces, hyphens).
31
- *
32
- * @remarks
33
- * Branded types enforce type safety when passing values between functions.
34
- * They are not required for direct API calls (which validate internally via Zod).
35
- * Use {@link createAETitle} to obtain a branded value from a raw string.
36
- */
37
- type AETitle = Brand<string, 'AETitle'>;
38
- /**
39
- * A validated DICOM tag path, e.g. `"(0040,A730)[0].(0010,0010)"`.
40
- *
41
- * @remarks
42
- * Branded types enforce type safety when passing values between functions.
43
- * They are not required for direct API calls (which validate internally via Zod).
44
- * Use {@link createDicomTagPath} to obtain a branded value from a raw string.
45
- */
46
- type DicomTagPath = Brand<string, 'DicomTagPath'>;
47
- /**
48
- * A validated SOP Class UID (dotted numeric OID, 1-64 chars).
49
- *
50
- * @remarks
51
- * Branded types enforce type safety when passing values between functions.
52
- * They are not required for direct API calls (which validate internally via Zod).
53
- * Use {@link createSOPClassUID} to obtain a branded value from a raw string.
54
- */
55
- type SOPClassUID = Brand<string, 'SOPClassUID'>;
56
- /**
57
- * A validated Transfer Syntax UID (dotted numeric OID, 1-64 chars).
58
- *
59
- * @remarks
60
- * Branded types enforce type safety when passing values between functions.
61
- * They are not required for direct API calls (which validate internally via Zod).
62
- * Use {@link createTransferSyntaxUID} to obtain a branded value from a raw string.
63
- */
64
- type TransferSyntaxUID = Brand<string, 'TransferSyntaxUID'>;
65
- /**
66
- * A validated filesystem path to a DICOM file.
67
- *
68
- * @remarks
69
- * Branded types enforce type safety when passing values between functions.
70
- * They are not required for direct API calls (which validate internally via Zod).
71
- * Use {@link createDicomFilePath} to obtain a branded value from a raw string.
72
- */
73
- type DicomFilePath = Brand<string, 'DicomFilePath'>;
74
- /**
75
- * A validated network port number (1-65535).
76
- *
77
- * @remarks
78
- * Branded types enforce type safety when passing values between functions.
79
- * They are not required for direct API calls (which validate internally via Zod).
80
- * Use {@link createPort} to obtain a branded value from a raw number.
81
- */
82
- type Port = Brand<number, 'Port'>;
83
- /**
84
- * Creates a validated DicomTag from a raw string.
85
- *
86
- * @param input - A string expected to be in format `(XXXX,XXXX)` where X is a hex digit
87
- * @returns A Result containing the branded DicomTag or an error
88
- */
89
- declare function createDicomTag(input: string): Result<DicomTag>;
90
- /**
91
- * Creates a validated AETitle from a raw string.
92
- *
93
- * @param input - A string expected to be 1-16 chars of letters, digits, spaces, or hyphens
94
- * @returns A Result containing the branded AETitle or an error
95
- */
96
- declare function createAETitle(input: string): Result<AETitle>;
97
- /**
98
- * Creates a validated DicomTagPath from a raw string.
99
- *
100
- * @param input - A dot-separated path of DICOM tags with optional array indices
101
- * @returns A Result containing the branded DicomTagPath or an error
102
- */
103
- declare function createDicomTagPath(input: string): Result<DicomTagPath>;
104
- /**
105
- * Creates a validated SOPClassUID from a raw string.
106
- *
107
- * @param input - A dotted numeric OID string, 1-64 characters
108
- * @returns A Result containing the branded SOPClassUID or an error
109
- */
110
- declare function createSOPClassUID(input: string): Result<SOPClassUID>;
111
- /**
112
- * Creates a validated TransferSyntaxUID from a raw string.
113
- *
114
- * @param input - A dotted numeric OID string, 1-64 characters
115
- * @returns A Result containing the branded TransferSyntaxUID or an error
116
- */
117
- declare function createTransferSyntaxUID(input: string): Result<TransferSyntaxUID>;
118
- /**
119
- * Creates a branded DicomFilePath from a raw string.
120
- * Validates that the path is non-empty and does not contain path traversal sequences.
121
- *
122
- * @param input - A filesystem path string
123
- * @returns A Result containing the branded DicomFilePath or an error
124
- */
125
- declare function createDicomFilePath(input: string): Result<DicomFilePath>;
126
- /**
127
- * Creates a validated Port from a raw number.
128
- *
129
- * @param input - A number expected to be an integer between 1 and 65535
130
- * @returns A Result containing the branded Port or an error
131
- */
132
- declare function createPort(input: number): Result<Port>;
133
-
134
- /**
135
- * DICOM Value Representation (VR) definitions, categories, and metadata.
136
- *
137
- * Provides a complete catalogue of all 34 standard DICOM VRs with their
138
- * constraints (max length, padding, fixed-length) and category classification.
139
- *
140
- * @module dicom/vr
141
- */
142
- /**
143
- * All 34 standard DICOM Value Representation codes.
144
- *
145
- * @see DICOM PS3.5 Section 6.2
146
- */
147
- declare const VR: {
148
- /** Application Entity — 16 bytes max, leading/trailing spaces significant */
149
- readonly AE: "AE";
150
- /** Age String — 4 bytes fixed, e.g. "032Y" */
151
- readonly AS: "AS";
152
- /** Attribute Tag — 4 bytes fixed */
153
- readonly AT: "AT";
154
- /** Code String — 16 bytes max */
155
- readonly CS: "CS";
156
- /** Date — 8 bytes fixed, YYYYMMDD */
157
- readonly DA: "DA";
158
- /** Decimal String — 16 bytes max per value */
159
- readonly DS: "DS";
160
- /** Date Time — 26 bytes max */
161
- readonly DT: "DT";
162
- /** Floating Point Double — 8 bytes fixed */
163
- readonly FD: "FD";
164
- /** Floating Point Single — 4 bytes fixed */
165
- readonly FL: "FL";
166
- /** Integer String — 12 bytes max */
167
- readonly IS: "IS";
168
- /** Long String — 64 chars max */
169
- readonly LO: "LO";
170
- /** Long Text — 10240 chars max */
171
- readonly LT: "LT";
172
- /** Other Byte — no max */
173
- readonly OB: "OB";
174
- /** Other Double — no max */
175
- readonly OD: "OD";
176
- /** Other Float — no max */
177
- readonly OF: "OF";
178
- /** Other Long — no max */
179
- readonly OL: "OL";
180
- /** Other 64-bit Very Long — no max */
181
- readonly OV: "OV";
182
- /** Other Word — no max */
183
- readonly OW: "OW";
184
- /** Person Name — 64 chars max per component group */
185
- readonly PN: "PN";
186
- /** Short String — 16 chars max */
187
- readonly SH: "SH";
188
- /** Signed Long — 4 bytes fixed */
189
- readonly SL: "SL";
190
- /** Sequence of Items — no max */
191
- readonly SQ: "SQ";
192
- /** Signed Short — 2 bytes fixed */
193
- readonly SS: "SS";
194
- /** Short Text — 1024 chars max */
195
- readonly ST: "ST";
196
- /** Signed 64-bit Very Long — 8 bytes fixed */
197
- readonly SV: "SV";
198
- /** Time — 14 bytes max */
199
- readonly TM: "TM";
200
- /** Unlimited Characters — no max */
201
- readonly UC: "UC";
202
- /** Unique Identifier (UID) — 64 bytes max */
203
- readonly UI: "UI";
204
- /** Unsigned Long — 4 bytes fixed */
205
- readonly UL: "UL";
206
- /** Unknown — no max */
207
- readonly UN: "UN";
208
- /** Universal Resource Identifier/Locator — no max */
209
- readonly UR: "UR";
210
- /** Unsigned Short — 2 bytes fixed */
211
- readonly US: "US";
212
- /** Unlimited Text — no max */
213
- readonly UT: "UT";
214
- /** Unsigned 64-bit Very Long — 8 bytes fixed */
215
- readonly UV: "UV";
216
- };
217
- /** A valid DICOM Value Representation code. */
218
- type VRValue = (typeof VR)[keyof typeof VR];
219
- /** Names for the five VR categories. */
220
- declare const VR_CATEGORY_NAME: {
221
- readonly STRING: "STRING";
222
- readonly NUMERIC: "NUMERIC";
223
- readonly BINARY: "BINARY";
224
- readonly SEQUENCE: "SEQUENCE";
225
- readonly TAG: "TAG";
226
- };
227
- /** A VR category name. */
228
- type VRCategoryName = (typeof VR_CATEGORY_NAME)[keyof typeof VR_CATEGORY_NAME];
229
- /**
230
- * VR codes grouped by category.
231
- *
232
- * - STRING: text-based VRs that hold character data
233
- * - NUMERIC: VRs that hold numeric data (integer or float)
234
- * - BINARY: VRs that hold raw binary/byte data
235
- * - SEQUENCE: the SQ VR for nested datasets
236
- * - TAG: the AT VR for attribute tag references
237
- */
238
- declare const VR_CATEGORY: {
239
- readonly STRING: readonly ["AE", "AS", "CS", "DA", "DS", "DT", "IS", "LO", "LT", "PN", "SH", "ST", "TM", "UC", "UI", "UR", "UT"];
240
- readonly NUMERIC: readonly ["FD", "FL", "SL", "SS", "SV", "UL", "US", "UV"];
241
- readonly BINARY: readonly ["OB", "OD", "OF", "OL", "OV", "OW", "UN"];
242
- readonly SEQUENCE: readonly ["SQ"];
243
- readonly TAG: readonly ["AT"];
244
- };
245
- /** Metadata describing the constraints of a single VR. */
246
- interface VRMetadata {
247
- /** Maximum value length in bytes/chars, or null if unlimited. */
248
- readonly maxLength: number | null;
249
- /** Character used for padding to even length, or null if no padding. */
250
- readonly paddingChar: ' ' | '\0' | null;
251
- /** Whether this VR has a fixed (non-variable) length. */
252
- readonly fixed: boolean;
253
- /** The category this VR belongs to. */
254
- readonly category: VRCategoryName;
255
- }
256
- /**
257
- * Complete metadata for all 34 standard DICOM VRs.
258
- *
259
- * @see DICOM PS3.5 Table 6.2-1
260
- */
261
- declare const VR_META: Readonly<Record<VRValue, VRMetadata>>;
262
- /**
263
- * Type guard: checks whether a string is a valid DICOM VR code.
264
- *
265
- * @param vr - The string to check
266
- * @returns True if `vr` is one of the 34 standard VR codes
267
- */
268
- declare function isStringVR(vr: string): vr is VRValue;
269
- /**
270
- * Checks whether a VR code represents a numeric value representation.
271
- *
272
- * @param vr - The VR code to check
273
- * @returns True if the VR is FD, FL, SL, SS, SV, UL, US, or UV
274
- */
275
- declare function isNumericVR(vr: string): boolean;
276
- /**
277
- * Checks whether a VR code represents a binary value representation.
278
- *
279
- * @param vr - The VR code to check
280
- * @returns True if the VR is OB, OD, OF, OL, OV, OW, or UN
281
- */
282
- declare function isBinaryVR(vr: string): boolean;
283
- /**
284
- * Returns the category name for a given VR code.
285
- *
286
- * @param vr - A valid VR code
287
- * @returns The category name (STRING, NUMERIC, BINARY, SEQUENCE, or TAG)
288
- */
289
- declare function getVRCategory(vr: VRValue): VRCategoryName;
290
-
291
- /**
292
- * DICOM tag dictionary with O(1) lookup by tag and lazy reverse lookup by name.
293
- *
294
- * Uses the shipped `src/data/dictionary.json` generated from `_configs/dicom.dic.json`.
295
- *
296
- * @module dicom/dictionary
297
- */
298
-
299
- /** A single entry from the DICOM data dictionary. */
300
- interface DictionaryEntry {
301
- /** The Value Representation code (e.g. "PN", "LO", "US"). */
302
- readonly vr: VRValue;
303
- /** The standard keyword name (e.g. "PatientName"). */
304
- readonly name: string;
305
- /** Value multiplicity as [min, max], where max is null if unbounded. */
306
- readonly vm: readonly [number, number | null];
307
- /** Whether this tag is retired in the current DICOM standard. */
308
- readonly retired: boolean;
309
- }
310
- /**
311
- * Looks up a DICOM tag in the data dictionary.
312
- *
313
- * Accepts tags in either branded `DicomTag` format `"(0010,0010)"` or
314
- * raw 8-char hex format `"00100010"`.
315
- *
316
- * @param tag - A DicomTag or 8-char hex string
317
- * @returns The dictionary entry, or undefined if the tag is not in the dictionary
318
- */
319
- declare function lookupTag(tag: DicomTag | string): DictionaryEntry | undefined;
320
- /**
321
- * Looks up a DICOM tag by its standard keyword name.
322
- *
323
- * @param name - The standard keyword (e.g. "PatientName", "Modality")
324
- * @returns An object with the 8-char hex tag and dictionary entry, or undefined
325
- */
326
- declare function lookupTagByName(name: string): {
327
- readonly tag: string;
328
- readonly entry: DictionaryEntry;
329
- } | undefined;
330
- /**
331
- * Looks up a DICOM tag by its standard keyword, returning just the branded DicomTag.
332
- *
333
- * @param keyword - The standard keyword (e.g. "PatientName")
334
- * @returns The DicomTag in `(XXXX,XXXX)` format, or undefined if not found
335
- */
336
- declare function lookupTagByKeyword(keyword: string): DicomTag | undefined;
337
-
338
- /**
339
- * Curated list of common DICOM SOP Class UIDs.
340
- *
341
- * This is not exhaustive — DICOM defines hundreds of SOP classes.
342
- * This file covers the ~70 most commonly encountered SOP classes
343
- * in clinical and research imaging workflows.
344
- *
345
- * @see DICOM PS3.4 Annex B — SOP Class definitions
346
- * @module data/sopClasses
347
- */
348
- /**
349
- * Common DICOM SOP Class UIDs.
350
- *
351
- * Keys are PascalCase names matching the DICOM standard keyword.
352
- * Values are the dotted-numeric UID strings.
353
- */
354
- declare const SOP_CLASSES: {
355
- readonly Verification: "1.2.840.10008.1.1";
356
- readonly ComputedRadiographyImageStorage: "1.2.840.10008.5.1.4.1.1.1";
357
- readonly DigitalXRayImageStorageForPresentation: "1.2.840.10008.5.1.4.1.1.1.1";
358
- readonly DigitalXRayImageStorageForProcessing: "1.2.840.10008.5.1.4.1.1.1.1.1";
359
- readonly DigitalMammographyXRayImageStorageForPresentation: "1.2.840.10008.5.1.4.1.1.1.2";
360
- readonly DigitalMammographyXRayImageStorageForProcessing: "1.2.840.10008.5.1.4.1.1.1.2.1";
361
- readonly CTImageStorage: "1.2.840.10008.5.1.4.1.1.2";
362
- readonly EnhancedCTImageStorage: "1.2.840.10008.5.1.4.1.1.2.1";
363
- readonly UltrasoundMultiFrameImageStorage: "1.2.840.10008.5.1.4.1.1.3.1";
364
- readonly MRImageStorage: "1.2.840.10008.5.1.4.1.1.4";
365
- readonly EnhancedMRImageStorage: "1.2.840.10008.5.1.4.1.1.4.1";
366
- readonly MRSpectroscopyStorage: "1.2.840.10008.5.1.4.1.1.4.2";
367
- readonly EnhancedMRColorImageStorage: "1.2.840.10008.5.1.4.1.1.4.3";
368
- readonly UltrasoundImageStorage: "1.2.840.10008.5.1.4.1.1.6.1";
369
- readonly EnhancedUSVolumeStorage: "1.2.840.10008.5.1.4.1.1.6.2";
370
- readonly SecondaryCaptureImageStorage: "1.2.840.10008.5.1.4.1.1.7";
371
- readonly MultiFrameSingleBitSecondaryCaptureImageStorage: "1.2.840.10008.5.1.4.1.1.7.1";
372
- readonly MultiFrameGrayscaleByteSecondaryCaptureImageStorage: "1.2.840.10008.5.1.4.1.1.7.2";
373
- readonly MultiFrameGrayscaleWordSecondaryCaptureImageStorage: "1.2.840.10008.5.1.4.1.1.7.3";
374
- readonly MultiFrameTrueColorSecondaryCaptureImageStorage: "1.2.840.10008.5.1.4.1.1.7.4";
375
- readonly XRayAngiographicImageStorage: "1.2.840.10008.5.1.4.1.1.12.1";
376
- readonly EnhancedXAImageStorage: "1.2.840.10008.5.1.4.1.1.12.1.1";
377
- readonly XRayRadiofluoroscopicImageStorage: "1.2.840.10008.5.1.4.1.1.12.2";
378
- readonly EnhancedXRFImageStorage: "1.2.840.10008.5.1.4.1.1.12.2.1";
379
- readonly NuclearMedicineImageStorage: "1.2.840.10008.5.1.4.1.1.20";
380
- readonly VLEndoscopicImageStorage: "1.2.840.10008.5.1.4.1.1.77.1.1";
381
- readonly VLMicroscopicImageStorage: "1.2.840.10008.5.1.4.1.1.77.1.2";
382
- readonly VLSlideCoordinatesMicroscopicImageStorage: "1.2.840.10008.5.1.4.1.1.77.1.3";
383
- readonly VLPhotographicImageStorage: "1.2.840.10008.5.1.4.1.1.77.1.4";
384
- readonly OphthalmicPhotography8BitImageStorage: "1.2.840.10008.5.1.4.1.1.77.1.5.1";
385
- readonly OphthalmicPhotography16BitImageStorage: "1.2.840.10008.5.1.4.1.1.77.1.5.2";
386
- readonly VLWholeSlideMicroscopyImageStorage: "1.2.840.10008.5.1.4.1.1.77.1.6";
387
- readonly PositronEmissionTomographyImageStorage: "1.2.840.10008.5.1.4.1.1.128";
388
- readonly EnhancedPETImageStorage: "1.2.840.10008.5.1.4.1.1.130";
389
- readonly RTImageStorage: "1.2.840.10008.5.1.4.1.1.481.1";
390
- readonly RTDoseStorage: "1.2.840.10008.5.1.4.1.1.481.2";
391
- readonly RTStructureSetStorage: "1.2.840.10008.5.1.4.1.1.481.3";
392
- readonly RTBeamsTreatmentRecordStorage: "1.2.840.10008.5.1.4.1.1.481.4";
393
- readonly RTPlanStorage: "1.2.840.10008.5.1.4.1.1.481.5";
394
- readonly RTBrachyTreatmentRecordStorage: "1.2.840.10008.5.1.4.1.1.481.6";
395
- readonly RTTreatmentSummaryRecordStorage: "1.2.840.10008.5.1.4.1.1.481.7";
396
- readonly RTIonPlanStorage: "1.2.840.10008.5.1.4.1.1.481.8";
397
- readonly RTIonBeamsTreatmentRecordStorage: "1.2.840.10008.5.1.4.1.1.481.9";
398
- readonly BasicTextSRStorage: "1.2.840.10008.5.1.4.1.1.88.11";
399
- readonly EnhancedSRStorage: "1.2.840.10008.5.1.4.1.1.88.22";
400
- readonly ComprehensiveSRStorage: "1.2.840.10008.5.1.4.1.1.88.33";
401
- readonly Comprehensive3DSRStorage: "1.2.840.10008.5.1.4.1.1.88.34";
402
- readonly KeyObjectSelectionDocumentStorage: "1.2.840.10008.5.1.4.1.1.88.59";
403
- readonly GrayscaleSoftcopyPresentationStateStorage: "1.2.840.10008.5.1.4.1.1.11.1";
404
- readonly ColorSoftcopyPresentationStateStorage: "1.2.840.10008.5.1.4.1.1.11.2";
405
- readonly EncapsulatedPDFStorage: "1.2.840.10008.5.1.4.1.1.104.1";
406
- readonly EncapsulatedCDAStorage: "1.2.840.10008.5.1.4.1.1.104.2";
407
- readonly RawDataStorage: "1.2.840.10008.5.1.4.1.1.66";
408
- readonly SpatialRegistrationStorage: "1.2.840.10008.5.1.4.1.1.66.1";
409
- readonly SpatialFiducialsStorage: "1.2.840.10008.5.1.4.1.1.66.2";
410
- readonly DeformableSpatialRegistrationStorage: "1.2.840.10008.5.1.4.1.1.66.3";
411
- readonly SegmentationStorage: "1.2.840.10008.5.1.4.1.1.66.4";
412
- readonly SurfaceSegmentationStorage: "1.2.840.10008.5.1.4.1.1.66.5";
413
- readonly TwelveLeadECGWaveformStorage: "1.2.840.10008.5.1.4.1.1.9.1.1";
414
- readonly GeneralECGWaveformStorage: "1.2.840.10008.5.1.4.1.1.9.1.2";
415
- readonly AmbulatoryECGWaveformStorage: "1.2.840.10008.5.1.4.1.1.9.1.3";
416
- readonly HemodynamicWaveformStorage: "1.2.840.10008.5.1.4.1.1.9.2.1";
417
- readonly BasicVoiceAudioWaveformStorage: "1.2.840.10008.5.1.4.1.1.9.4.1";
418
- readonly PatientRootQueryRetrieveInformationModelFind: "1.2.840.10008.5.1.4.1.2.1.1";
419
- readonly PatientRootQueryRetrieveInformationModelMove: "1.2.840.10008.5.1.4.1.2.1.2";
420
- readonly PatientRootQueryRetrieveInformationModelGet: "1.2.840.10008.5.1.4.1.2.1.3";
421
- readonly StudyRootQueryRetrieveInformationModelFind: "1.2.840.10008.5.1.4.1.2.2.1";
422
- readonly StudyRootQueryRetrieveInformationModelMove: "1.2.840.10008.5.1.4.1.2.2.2";
423
- readonly StudyRootQueryRetrieveInformationModelGet: "1.2.840.10008.5.1.4.1.2.2.3";
424
- readonly ModalityWorklistInformationModelFind: "1.2.840.10008.5.1.4.31";
425
- readonly StorageCommitmentPushModel: "1.2.840.10008.1.20.1";
426
- };
427
- /** A SOP class name key from the curated list. */
428
- type SOPClassName = keyof typeof SOP_CLASSES;
429
- /**
430
- * Looks up the SOP class name for a given UID string.
431
- *
432
- * @param uid - A DICOM SOP Class UID string
433
- * @returns The SOP class name, or undefined if not in the curated list
434
- */
435
- declare function sopClassNameFromUID(uid: string): SOPClassName | undefined;
436
-
437
- /**
438
- * DICOM tag path parser and serializer.
439
- *
440
- * Provides iterative (no recursion) parsing of DICOM tag paths like
441
- * `(0040,A730)[0].(0040,A160)` into structured segments, and conversion
442
- * back to dcmodify-compatible strings.
443
- *
444
- * Supports wildcard indices `[*]` for use with DicomDataset.findValues.
445
- *
446
- * @module dicom/tagPath
447
- */
448
-
449
- /** A single segment of a parsed DICOM tag path. */
450
- interface TagSegment {
451
- /** The DICOM tag for this segment. */
452
- readonly tag: DicomTag;
453
- /** The array index for sequence items, or undefined for non-sequence tags. */
454
- readonly index?: number | undefined;
455
- /** Whether this segment uses a wildcard index `[*]`. */
456
- readonly isWildcard?: boolean | undefined;
457
- }
458
- /**
459
- * Parses a DICOM tag path into an array of segments.
460
- *
461
- * Uses iterative parsing with bounded loop (Rule 8.2: no recursion).
462
- *
463
- * @param path - A branded DicomTagPath string
464
- * @returns An array of TagSegment objects
465
- * @throws Error if the path is malformed or exceeds MAX_TRAVERSAL_DEPTH
466
- *
467
- * @example
468
- * ```ts
469
- * tagPathToSegments('(0040,A730)[0].(0040,A160)' as DicomTagPath)
470
- * // => [
471
- * // { tag: '(0040,A730)' as DicomTag, index: 0 },
472
- * // { tag: '(0040,A160)' as DicomTag }
473
- * // ]
474
- * ```
475
- */
476
- declare function tagPathToSegments(path: DicomTagPath): ReadonlyArray<TagSegment>;
477
- /**
478
- * Converts tag segments back to a dcmodify-compatible path string.
479
- *
480
- * Format: `(0040,A730)[0].(0040,A160)`
481
- *
482
- * @param segments - An array of TagSegment objects
483
- * @returns A dcmodify-compatible path string
484
- */
485
- declare function segmentsToModifyPath(segments: ReadonlyArray<TagSegment>): string;
486
- /**
487
- * Converts tag segments to a canonical display string.
488
- *
489
- * Same format as dcmodify path: `(0040,A730)[0].(0040,A160)`
490
- *
491
- * @param segments - An array of TagSegment objects
492
- * @returns A human-readable path string
493
- */
494
- declare function segmentsToString(segments: ReadonlyArray<TagSegment>): string;
495
-
496
- /**
497
- * Immutable DICOM dataset wrapper with type-safe accessors.
498
- *
499
- * Wraps DICOM JSON Model data (PS3.18 F.2) from dcm2json/dcm2xml with
500
- * convenient read-only accessors. No setters — mutations go through ChangeSet.
501
- *
502
- * @module dicom/DicomDataset
503
- */
504
-
505
- /**
506
- * Immutable wrapper around DICOM JSON Model data.
507
- *
508
- * Provides type-safe read-only accessors for DICOM tag values.
509
- * Construct via the static {@link DicomDataset.fromJson} factory.
510
- *
511
- * @example
512
- * ```ts
513
- * const result = DicomDataset.fromJson(jsonData);
514
- * if (result.ok) {
515
- * const ds = result.value;
516
- * console.log(ds.patientName);
517
- * console.log(ds.modality);
518
- * }
519
- * ```
520
- */
521
- declare class DicomDataset {
522
- private readonly data;
523
- private constructor();
524
- /**
525
- * Creates a DicomDataset from a DICOM JSON Model object.
526
- *
527
- * Performs structural validation only — verifies the input is a non-null object.
528
- *
529
- * @param json - A DICOM JSON Model object (typically from dcm2json)
530
- * @returns A Result containing the DicomDataset or an error
531
- */
532
- static fromJson(json: unknown): Result<DicomDataset>;
533
- /**
534
- * Gets the full DICOM JSON element for a tag.
535
- *
536
- * @param tag - A DicomTag `(0010,0010)` or hex string `00100010`
537
- * @returns Result containing the element or an error if not found
538
- */
539
- getElement(tag: DicomTag | string): Result<DicomJsonElement>;
540
- /**
541
- * Gets the Value array for a tag.
542
- *
543
- * @param tag - A DicomTag `(0010,0010)` or hex string `00100010`
544
- * @returns Result containing the readonly Value array or an error
545
- */
546
- getValue(tag: DicomTag | string): Result<ReadonlyArray<unknown>>;
547
- /**
548
- * Gets the first element of the Value array for a tag.
549
- *
550
- * @param tag - A DicomTag `(0010,0010)` or hex string `00100010`
551
- * @returns Result containing the first value or an error
552
- */
553
- getFirstValue(tag: DicomTag | string): Result<unknown>;
554
- /**
555
- * Gets a tag value as a string with optional fallback.
556
- *
557
- * Returns the fallback (default empty string) if the tag is missing or has no value.
558
- * Handles PN (PersonName) values by extracting the Alphabetic component.
559
- *
560
- * @param tag - A DicomTag `(0010,0010)` or hex string `00100010`
561
- * @param fallback - Value to return if tag is missing (default: `''`)
562
- * @returns The string value or the fallback
563
- */
564
- getString(tag: DicomTag | string, fallback?: string): string;
565
- /**
566
- * Gets a tag value as a validated number.
567
- *
568
- * @param tag - A DicomTag `(0010,0010)` or hex string `00100010`
569
- * @returns Result containing the number or an error
570
- */
571
- getNumber(tag: DicomTag | string): Result<number>;
572
- /**
573
- * Gets all values of a tag as strings.
574
- *
575
- * Useful for multi-valued tags like CS (Code String).
576
- *
577
- * @param tag - A DicomTag `(0010,0010)` or hex string `00100010`
578
- * @returns Result containing the readonly string array or an error
579
- */
580
- getStrings(tag: DicomTag | string): Result<ReadonlyArray<string>>;
581
- /**
582
- * Checks whether a tag exists in the dataset.
583
- *
584
- * @param tag - A DicomTag `(0010,0010)` or hex string `00100010`
585
- * @returns `true` if the tag is present
586
- */
587
- hasTag(tag: DicomTag | string): boolean;
588
- /**
589
- * Gets an element by traversing a dotted tag path through sequences.
590
- *
591
- * @param path - A branded DicomTagPath, e.g. `(0040,A730)[0].(0040,A160)`
592
- * @returns Result containing the element at the path or an error
593
- */
594
- getElementAtPath(path: DicomTagPath): Result<DicomJsonElement>;
595
- /**
596
- * Finds all values matching a path with wildcard `[*]` indices.
597
- *
598
- * Traverses all items in wildcard sequence positions using an iterative BFS queue.
599
- * The traversal is bounded to {@link MAX_TRAVERSAL_DEPTH} * 100 iterations (5 000).
600
- * For extremely large datasets this may truncate results silently; callers
601
- * needing completeness guarantees should verify dataset size independently.
602
- *
603
- * @param path - A branded DicomTagPath, e.g. `(0040,A730)[*].(0040,A160)`
604
- * @returns A readonly array of all matching values (may be empty)
605
- */
606
- findValues(path: DicomTagPath): ReadonlyArray<unknown>;
607
- /** Accession Number (0008,0050). */
608
- get accession(): string;
609
- /** Patient's Name (0010,0010). */
610
- get patientName(): string;
611
- /** Patient ID (0010,0020). */
612
- get patientID(): string;
613
- /** Study Date (0008,0020). */
614
- get studyDate(): string;
615
- /** Modality (0008,0060). */
616
- get modality(): string;
617
- /** SOP Class UID (0008,0016) as a branded SOPClassUID, or undefined if missing/invalid. */
618
- get sopClassUID(): SOPClassUID | undefined;
619
- /** Study Instance UID (0020,000D). */
620
- get studyInstanceUID(): string;
621
- /** Series Instance UID (0020,000E). */
622
- get seriesInstanceUID(): string;
623
- /** SOP Instance UID (0008,0018). */
624
- get sopInstanceUID(): string;
625
- /** Transfer Syntax UID (0002,0010). */
626
- get transferSyntaxUID(): string;
627
- }
628
-
629
- /**
630
- * Immutable mutation tracking for DICOM datasets.
631
- *
632
- * Every mutation method returns a new ChangeSet instance, preserving immutability.
633
- * Bridge methods produce dcmodify-compatible arguments for applying changes to files.
634
- *
635
- * @module dicom/ChangeSet
636
- */
637
-
638
- /**
639
- * Immutable mutation tracker for DICOM datasets.
640
- *
641
- * Every mutation method returns a **new** ChangeSet — the original is never modified.
642
- * Use {@link ChangeSet.toModifications} and {@link ChangeSet.toErasureArgs} to bridge
643
- * to the dcmodify tool wrapper.
644
- *
645
- * @example
646
- * ```ts
647
- * const cs = ChangeSet.empty()
648
- * .setTag('(0010,0010)' as DicomTagPath, 'Anonymous')
649
- * .eraseTag('(0010,0020)' as DicomTagPath)
650
- * .erasePrivateTags();
651
- * ```
652
- */
653
- declare class ChangeSet {
654
- private readonly mods;
655
- private readonly erased;
656
- private constructor();
657
- /** Creates an empty ChangeSet with no modifications or erasures. */
658
- static empty(): ChangeSet;
659
- /**
660
- * Sets a tag value, returning a new ChangeSet.
661
- *
662
- * Control characters (except LF/CR) are stripped from the value.
663
- * If the tag was previously erased, it is removed from the erasure set.
664
- *
665
- * @param path - The DICOM tag path to set
666
- * @param value - The new value for the tag
667
- * @returns A new ChangeSet with the modification applied
668
- * @throws Error if operation count would exceed MAX_CHANGESET_OPERATIONS
669
- */
670
- setTag(path: DicomTagPath, value: string): ChangeSet;
671
- /**
672
- * Marks a tag for erasure, returning a new ChangeSet.
673
- *
674
- * If the tag was previously set, the modification is removed.
675
- *
676
- * @param path - The DICOM tag path to erase
677
- * @returns A new ChangeSet with the erasure applied
678
- * @throws Error if operation count would exceed MAX_CHANGESET_OPERATIONS
679
- */
680
- eraseTag(path: DicomTagPath): ChangeSet;
681
- /**
682
- * Marks all private tags for erasure, returning a new ChangeSet.
683
- *
684
- * @returns A new ChangeSet with the erase-private flag set
685
- * @throws Error if operation count would exceed MAX_CHANGESET_OPERATIONS
686
- */
687
- erasePrivateTags(): ChangeSet;
688
- /** All pending tag modifications as a readonly map of path → value. */
689
- get modifications(): ReadonlyMap<string, string>;
690
- /** All pending tag erasures as a readonly set of paths. */
691
- get erasures(): ReadonlySet<string>;
692
- /** Total number of operations (modifications + erasures) in this ChangeSet. */
693
- get operationCount(): number;
694
- /** Whether the ChangeSet has no modifications and no erasures. */
695
- get isEmpty(): boolean;
696
- /** Whether the erase-all-private-tags flag is set. */
697
- get erasePrivate(): boolean;
698
- /**
699
- * Merges another ChangeSet into this one, returning a new ChangeSet.
700
- *
701
- * The `other` ChangeSet wins on conflicts: if the same tag is modified in both,
702
- * `other`'s value is used. Erasures from both sets are unioned. An erasure in
703
- * `other` removes a modification from `base`.
704
- *
705
- * @param other - The ChangeSet to merge in
706
- * @returns A new ChangeSet with merged modifications and erasures
707
- */
708
- merge(other: ChangeSet): ChangeSet;
709
- /**
710
- * Converts modifications to dcmodify-compatible TagModification array.
711
- *
712
- * @returns A readonly array of TagModification objects
713
- */
714
- toModifications(): ReadonlyArray<TagModification>;
715
- /**
716
- * Converts erasures to dcmodify-compatible argument strings.
717
- *
718
- * The erase-private sentinel is excluded — use {@link erasePrivate} to check
719
- * whether `-ep` should be passed.
720
- *
721
- * @returns A readonly array of tag path strings for `-e` arguments
722
- */
723
- toErasureArgs(): ReadonlyArray<string>;
724
- }
725
-
726
- /**
727
- * DICOM file I/O combining DicomDataset + ChangeSet + file path.
728
- *
729
- * Provides a high-level API for reading, modifying, and saving DICOM files.
730
- * All mutations are tracked immutably via ChangeSet and applied through dcmodify.
731
- *
732
- * @module dicom/DicomFile
733
- */
734
-
735
- /** Options for DicomFile I/O operations. */
736
- interface DicomFileOptions {
737
- /** Timeout in milliseconds. Defaults to DEFAULT_TIMEOUT_MS. */
738
- readonly timeoutMs?: number | undefined;
739
- /** AbortSignal for external cancellation. */
740
- readonly signal?: AbortSignal | undefined;
741
- }
742
- /**
743
- * High-level DICOM file wrapper combining dataset, change tracking, and file I/O.
744
- *
745
- * Create via {@link DicomFile.open}. Accumulate changes with {@link withChanges},
746
- * then apply with {@link applyChanges} or write to a new path with {@link writeAs}.
747
- *
748
- * @example
749
- * ```ts
750
- * const file = await DicomFile.open('/path/to/study.dcm');
751
- * if (file.ok) {
752
- * const modified = file.value
753
- * .withChanges(ChangeSet.empty().setTag(tag, 'Anonymous'));
754
- * await modified.applyChanges();
755
- * }
756
- * ```
757
- */
758
- declare class DicomFile {
759
- /** The immutable DICOM dataset read from the file. */
760
- readonly dataset: DicomDataset;
761
- /** The branded file path. */
762
- readonly filePath: DicomFilePath;
763
- /** The accumulated pending changes. */
764
- readonly changes: ChangeSet;
765
- private constructor();
766
- /**
767
- * Opens a DICOM file and reads its dataset.
768
- *
769
- * @param path - Filesystem path to the DICOM file
770
- * @param options - Timeout and abort options
771
- * @returns A Result containing the DicomFile or an error
772
- */
773
- static open(path: string, options?: DicomFileOptions): Promise<Result<DicomFile>>;
774
- /**
775
- * Returns a new DicomFile with the given changes merged into the pending changes.
776
- *
777
- * @param changes - A ChangeSet to merge with existing pending changes
778
- * @returns A new DicomFile with accumulated changes
779
- */
780
- withChanges(changes: ChangeSet): DicomFile;
781
- /**
782
- * Returns a new DicomFile with a different file path.
783
- *
784
- * Preserves the dataset and pending changes.
785
- *
786
- * @param newPath - The new branded file path
787
- * @returns A new DicomFile pointing to the new path
788
- */
789
- withFilePath(newPath: DicomFilePath): DicomFile;
790
- /**
791
- * Applies pending changes to the file in-place using dcmodify.
792
- *
793
- * If there are no pending changes, this is a no-op that returns success.
794
- * After applying, the dataset is NOT refreshed — call {@link DicomFile.open}
795
- * again if you need fresh data.
796
- *
797
- * @param options - Timeout and abort options
798
- * @returns A Result indicating success or failure
799
- */
800
- applyChanges(options?: DicomFileOptions): Promise<Result<void>>;
801
- /**
802
- * Copies the file to a new path and applies pending changes to the copy.
803
- *
804
- * If there are no pending changes, only the copy is performed.
805
- * On dcmodify failure, the copy is cleaned up.
806
- *
807
- * @param outputPath - Destination filesystem path
808
- * @param options - Timeout and abort options
809
- * @returns A Result containing the branded output path or an error
810
- */
811
- writeAs(outputPath: string, options?: DicomFileOptions): Promise<Result<DicomFilePath>>;
812
- /**
813
- * Gets the file size in bytes.
814
- *
815
- * @returns A Result containing the size or an error
816
- */
817
- fileSize(): Promise<Result<number>>;
818
- /**
819
- * Deletes the file from the filesystem.
820
- *
821
- * @returns A Result indicating success or failure
822
- */
823
- unlink(): Promise<Result<void>>;
824
- }
825
-
826
- export { type AETitle as A, type Brand as B, ChangeSet as C, type DicomTag as D, lookupTag as E, lookupTagByKeyword as F, lookupTagByName as G, segmentsToModifyPath as H, segmentsToString as I, sopClassNameFromUID as J, tagPathToSegments as K, type Port as P, type SOPClassUID as S, type TransferSyntaxUID as T, VR as V, type DicomTagPath as a, DicomDataset as b, DicomFile as c, type DicomFileOptions as d, type DicomFilePath as e, type DictionaryEntry as f, type SOPClassName as g, SOP_CLASSES as h, type TagSegment as i, type VRCategoryName as j, type VRMetadata as k, type VRValue as l, VR_CATEGORY as m, VR_CATEGORY_NAME as n, VR_META as o, createAETitle as p, createDicomFilePath as q, createDicomTag as r, createDicomTagPath as s, createPort as t, createSOPClassUID as u, createTransferSyntaxUID as v, getVRCategory as w, isBinaryVR as x, isNumericVR as y, isStringVR as z };