@cosyte/dicom 0.0.4 → 0.0.6
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.
- package/CHANGELOG.md +495 -182
- package/README.md +32 -21
- package/dist/index.cjs +275 -142
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +40 -11
- package/dist/index.d.ts +40 -11
- package/dist/index.mjs +276 -143
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -401,6 +401,7 @@ declare const WARNING_CODES: {
|
|
|
401
401
|
readonly DICOM_ODD_LENGTH_VALUE_PADDED: "DICOM_ODD_LENGTH_VALUE_PADDED";
|
|
402
402
|
readonly DICOM_PIXEL_DATA_LENGTH_MISMATCH: "DICOM_PIXEL_DATA_LENGTH_MISMATCH";
|
|
403
403
|
readonly DICOM_PRIVATE_TAG_NO_CREATOR: "DICOM_PRIVATE_TAG_NO_CREATOR";
|
|
404
|
+
readonly DICOM_SQ_NOT_DESCENDED: "DICOM_SQ_NOT_DESCENDED";
|
|
404
405
|
readonly DICOM_UN_PARSED_AS_SQ: "DICOM_UN_PARSED_AS_SQ";
|
|
405
406
|
readonly DICOM_UNDEFINED_LENGTH_IN_EXPLICIT_VR: "DICOM_UNDEFINED_LENGTH_IN_EXPLICIT_VR";
|
|
406
407
|
readonly DICOM_VR_MISMATCH: "DICOM_VR_MISMATCH";
|
|
@@ -1624,12 +1625,21 @@ declare function decodeElementValue(element: Element): DicomValue;
|
|
|
1624
1625
|
|
|
1625
1626
|
/**
|
|
1626
1627
|
* Parse a `(0008,0005)` Specific Character Set value (a `CS`, possibly
|
|
1627
|
-
* multi-valued via `\`) into its trimmed defined terms
|
|
1628
|
+
* multi-valued via `\`) into its trimmed **defined terms**.
|
|
1628
1629
|
*
|
|
1629
1630
|
* The first value may be empty (the ISO-2022 "G0 starts as ISO_IR 6" rule);
|
|
1630
1631
|
* it is preserved as `""` rather than dropped so {@link resolveDecoderLabel}
|
|
1631
1632
|
* can apply the default-repertoire fallback.
|
|
1632
1633
|
*
|
|
1634
|
+
* A component this closed table does not name is not a defined term, and it is
|
|
1635
|
+
* **withheld** rather than returned. This value is multi-valued on the
|
|
1636
|
+
* backslash, every component is a string a sender authored, and the result
|
|
1637
|
+
* lands on `Element.specificCharacterSet`, where it presents itself as an
|
|
1638
|
+
* identifier a downstream package may interpolate: that is the field, and the
|
|
1639
|
+
* delimiter, this package's measured PHI leak ran through. Decoding is
|
|
1640
|
+
* unaffected, because {@link resolveDecoderLabel} already skipped any term it
|
|
1641
|
+
* could not map and skips the withheld marker for the same reason.
|
|
1642
|
+
*
|
|
1633
1643
|
* @example
|
|
1634
1644
|
* ```ts
|
|
1635
1645
|
* import { parseSpecificCharacterSet } from "@cosyte/dicom";
|
|
@@ -2339,9 +2349,15 @@ interface DeidentifiedAttribute {
|
|
|
2339
2349
|
readonly repeatingGroup?: string;
|
|
2340
2350
|
}
|
|
2341
2351
|
/**
|
|
2342
|
-
* The audit trail returned alongside the de-identified dataset.
|
|
2343
|
-
*
|
|
2344
|
-
*
|
|
2352
|
+
* The audit trail returned alongside the de-identified dataset.
|
|
2353
|
+
*
|
|
2354
|
+
* Every field except one is composed from static tables: tags, Part 6 keywords,
|
|
2355
|
+
* Annex E action codes, structural `TAG[index]` sequence paths, and registry
|
|
2356
|
+
* warning messages. **`uidMap` is the exception, and it is not value-free.** Its
|
|
2357
|
+
* keys are the source UIDs read out of the file, kept so a caller can make UID
|
|
2358
|
+
* replacement consistent across a study or an archive. A Study or SOP Instance
|
|
2359
|
+
* UID is a unique identifying number, so treat `uidMap` as PHI: the rest of the
|
|
2360
|
+
* report is safe to log, and that field is not.
|
|
2345
2361
|
*
|
|
2346
2362
|
* @example
|
|
2347
2363
|
* ```ts
|
|
@@ -2356,7 +2372,11 @@ interface DeidentifyReport {
|
|
|
2356
2372
|
readonly attributes: readonly DeidentifiedAttribute[];
|
|
2357
2373
|
/** Private tags removed under the Basic Profile (kept ones are omitted). */
|
|
2358
2374
|
readonly removedPrivateTags: readonly Tag[];
|
|
2359
|
-
/**
|
|
2375
|
+
/**
|
|
2376
|
+
* Source UID → replacement UID, for cross-file consistency. The **keys are
|
|
2377
|
+
* document values**, not composed identifiers: this is the one field of the
|
|
2378
|
+
* report that carries PHI.
|
|
2379
|
+
*/
|
|
2360
2380
|
readonly uidMap: ReadonlyMap<string, string>;
|
|
2361
2381
|
/** Safety warnings - notably burned-in-pixel annotation that cannot be cleaned. */
|
|
2362
2382
|
readonly warnings: readonly DicomParseWarning[];
|
|
@@ -2470,7 +2490,8 @@ declare class DeidentifyError extends Error {
|
|
|
2470
2490
|
* nine *metadata-affecting* Annex E Options, driven by the generated Table E.1-1
|
|
2471
2491
|
* action map ({@link annexE}). It is a **pure** function: the input {@link Dataset}
|
|
2472
2492
|
* is never mutated; a fresh `Dataset` (with a rebuilt element map and File Meta)
|
|
2473
|
-
* is returned alongside a
|
|
2493
|
+
* is returned alongside a {@link DeidentifyReport} that is value-free except for
|
|
2494
|
+
* `uidMap`, whose keys are the file's own source UIDs.
|
|
2474
2495
|
*
|
|
2475
2496
|
* **What it does**
|
|
2476
2497
|
* - Resolves each attribute's action (basic profile, overridden by an active
|
|
@@ -2508,9 +2529,15 @@ declare class DeidentifyError extends Error {
|
|
|
2508
2529
|
* - A private data element kept under `RetainSafePrivate` is kept *verbatim* - if
|
|
2509
2530
|
* it is itself a sequence carrying standard PHI attributes, that nested content
|
|
2510
2531
|
* is not recursed. The profile vouches the element is safe; nest accordingly.
|
|
2511
|
-
* - A sequence whose `items` the parser did not materialize
|
|
2512
|
-
*
|
|
2513
|
-
*
|
|
2532
|
+
* - A sequence whose `items` the parser did not materialize is kept verbatim
|
|
2533
|
+
* rather than recursed, so any nested listed attributes are not de-identified.
|
|
2534
|
+
* That is now a **narrow and announced** set: an undefined-length `UN` value the
|
|
2535
|
+
* CP-246 descent could not read as a sequence, and a defined-length Implicit VR
|
|
2536
|
+
* LE value whose resolved `SQ` turned out not to be an item stream - the latter
|
|
2537
|
+
* carrying `DICOM_SQ_NOT_DESCENDED` on `ds.warnings`. It used to include
|
|
2538
|
+
* **every** defined-length sequence under Implicit VR LE, silently
|
|
2539
|
+
* (`DICOM-IMPLICIT-SQ-NOT-DESCENDED`, fixed after `0.0.5`). Check
|
|
2540
|
+
* `ds.warnings` before treating a report as complete.
|
|
2514
2541
|
*
|
|
2515
2542
|
* @module
|
|
2516
2543
|
*/
|
|
@@ -2519,8 +2546,10 @@ declare class DeidentifyError extends Error {
|
|
|
2519
2546
|
* De-identify a {@link Dataset} per PS3.15 Annex E - the Basic Application Level
|
|
2520
2547
|
* Confidentiality Profile, plus any Retain/Clean Options passed in `retain`.
|
|
2521
2548
|
*
|
|
2522
|
-
* Pure: `ds` is never mutated. Returns a fresh dataset and a
|
|
2523
|
-
* {@link DeidentifyReport}
|
|
2549
|
+
* Pure: `ds` is never mutated. Returns a fresh dataset and a
|
|
2550
|
+
* {@link DeidentifyReport} of tags, keywords, action codes, warnings and the UID
|
|
2551
|
+
* map. Everything in it is composed from static tables except `uidMap`, whose
|
|
2552
|
+
* keys are the source UIDs the file carried: treat that field as PHI.
|
|
2524
2553
|
*
|
|
2525
2554
|
* @throws {@link DeidentifyError} (`INVALID_OPTIONS`) for an unknown Retain option
|
|
2526
2555
|
* or a malformed `uidRoot`.
|
package/dist/index.d.ts
CHANGED
|
@@ -401,6 +401,7 @@ declare const WARNING_CODES: {
|
|
|
401
401
|
readonly DICOM_ODD_LENGTH_VALUE_PADDED: "DICOM_ODD_LENGTH_VALUE_PADDED";
|
|
402
402
|
readonly DICOM_PIXEL_DATA_LENGTH_MISMATCH: "DICOM_PIXEL_DATA_LENGTH_MISMATCH";
|
|
403
403
|
readonly DICOM_PRIVATE_TAG_NO_CREATOR: "DICOM_PRIVATE_TAG_NO_CREATOR";
|
|
404
|
+
readonly DICOM_SQ_NOT_DESCENDED: "DICOM_SQ_NOT_DESCENDED";
|
|
404
405
|
readonly DICOM_UN_PARSED_AS_SQ: "DICOM_UN_PARSED_AS_SQ";
|
|
405
406
|
readonly DICOM_UNDEFINED_LENGTH_IN_EXPLICIT_VR: "DICOM_UNDEFINED_LENGTH_IN_EXPLICIT_VR";
|
|
406
407
|
readonly DICOM_VR_MISMATCH: "DICOM_VR_MISMATCH";
|
|
@@ -1624,12 +1625,21 @@ declare function decodeElementValue(element: Element): DicomValue;
|
|
|
1624
1625
|
|
|
1625
1626
|
/**
|
|
1626
1627
|
* Parse a `(0008,0005)` Specific Character Set value (a `CS`, possibly
|
|
1627
|
-
* multi-valued via `\`) into its trimmed defined terms
|
|
1628
|
+
* multi-valued via `\`) into its trimmed **defined terms**.
|
|
1628
1629
|
*
|
|
1629
1630
|
* The first value may be empty (the ISO-2022 "G0 starts as ISO_IR 6" rule);
|
|
1630
1631
|
* it is preserved as `""` rather than dropped so {@link resolveDecoderLabel}
|
|
1631
1632
|
* can apply the default-repertoire fallback.
|
|
1632
1633
|
*
|
|
1634
|
+
* A component this closed table does not name is not a defined term, and it is
|
|
1635
|
+
* **withheld** rather than returned. This value is multi-valued on the
|
|
1636
|
+
* backslash, every component is a string a sender authored, and the result
|
|
1637
|
+
* lands on `Element.specificCharacterSet`, where it presents itself as an
|
|
1638
|
+
* identifier a downstream package may interpolate: that is the field, and the
|
|
1639
|
+
* delimiter, this package's measured PHI leak ran through. Decoding is
|
|
1640
|
+
* unaffected, because {@link resolveDecoderLabel} already skipped any term it
|
|
1641
|
+
* could not map and skips the withheld marker for the same reason.
|
|
1642
|
+
*
|
|
1633
1643
|
* @example
|
|
1634
1644
|
* ```ts
|
|
1635
1645
|
* import { parseSpecificCharacterSet } from "@cosyte/dicom";
|
|
@@ -2339,9 +2349,15 @@ interface DeidentifiedAttribute {
|
|
|
2339
2349
|
readonly repeatingGroup?: string;
|
|
2340
2350
|
}
|
|
2341
2351
|
/**
|
|
2342
|
-
* The audit trail returned alongside the de-identified dataset.
|
|
2343
|
-
*
|
|
2344
|
-
*
|
|
2352
|
+
* The audit trail returned alongside the de-identified dataset.
|
|
2353
|
+
*
|
|
2354
|
+
* Every field except one is composed from static tables: tags, Part 6 keywords,
|
|
2355
|
+
* Annex E action codes, structural `TAG[index]` sequence paths, and registry
|
|
2356
|
+
* warning messages. **`uidMap` is the exception, and it is not value-free.** Its
|
|
2357
|
+
* keys are the source UIDs read out of the file, kept so a caller can make UID
|
|
2358
|
+
* replacement consistent across a study or an archive. A Study or SOP Instance
|
|
2359
|
+
* UID is a unique identifying number, so treat `uidMap` as PHI: the rest of the
|
|
2360
|
+
* report is safe to log, and that field is not.
|
|
2345
2361
|
*
|
|
2346
2362
|
* @example
|
|
2347
2363
|
* ```ts
|
|
@@ -2356,7 +2372,11 @@ interface DeidentifyReport {
|
|
|
2356
2372
|
readonly attributes: readonly DeidentifiedAttribute[];
|
|
2357
2373
|
/** Private tags removed under the Basic Profile (kept ones are omitted). */
|
|
2358
2374
|
readonly removedPrivateTags: readonly Tag[];
|
|
2359
|
-
/**
|
|
2375
|
+
/**
|
|
2376
|
+
* Source UID → replacement UID, for cross-file consistency. The **keys are
|
|
2377
|
+
* document values**, not composed identifiers: this is the one field of the
|
|
2378
|
+
* report that carries PHI.
|
|
2379
|
+
*/
|
|
2360
2380
|
readonly uidMap: ReadonlyMap<string, string>;
|
|
2361
2381
|
/** Safety warnings - notably burned-in-pixel annotation that cannot be cleaned. */
|
|
2362
2382
|
readonly warnings: readonly DicomParseWarning[];
|
|
@@ -2470,7 +2490,8 @@ declare class DeidentifyError extends Error {
|
|
|
2470
2490
|
* nine *metadata-affecting* Annex E Options, driven by the generated Table E.1-1
|
|
2471
2491
|
* action map ({@link annexE}). It is a **pure** function: the input {@link Dataset}
|
|
2472
2492
|
* is never mutated; a fresh `Dataset` (with a rebuilt element map and File Meta)
|
|
2473
|
-
* is returned alongside a
|
|
2493
|
+
* is returned alongside a {@link DeidentifyReport} that is value-free except for
|
|
2494
|
+
* `uidMap`, whose keys are the file's own source UIDs.
|
|
2474
2495
|
*
|
|
2475
2496
|
* **What it does**
|
|
2476
2497
|
* - Resolves each attribute's action (basic profile, overridden by an active
|
|
@@ -2508,9 +2529,15 @@ declare class DeidentifyError extends Error {
|
|
|
2508
2529
|
* - A private data element kept under `RetainSafePrivate` is kept *verbatim* - if
|
|
2509
2530
|
* it is itself a sequence carrying standard PHI attributes, that nested content
|
|
2510
2531
|
* is not recursed. The profile vouches the element is safe; nest accordingly.
|
|
2511
|
-
* - A sequence whose `items` the parser did not materialize
|
|
2512
|
-
*
|
|
2513
|
-
*
|
|
2532
|
+
* - A sequence whose `items` the parser did not materialize is kept verbatim
|
|
2533
|
+
* rather than recursed, so any nested listed attributes are not de-identified.
|
|
2534
|
+
* That is now a **narrow and announced** set: an undefined-length `UN` value the
|
|
2535
|
+
* CP-246 descent could not read as a sequence, and a defined-length Implicit VR
|
|
2536
|
+
* LE value whose resolved `SQ` turned out not to be an item stream - the latter
|
|
2537
|
+
* carrying `DICOM_SQ_NOT_DESCENDED` on `ds.warnings`. It used to include
|
|
2538
|
+
* **every** defined-length sequence under Implicit VR LE, silently
|
|
2539
|
+
* (`DICOM-IMPLICIT-SQ-NOT-DESCENDED`, fixed after `0.0.5`). Check
|
|
2540
|
+
* `ds.warnings` before treating a report as complete.
|
|
2514
2541
|
*
|
|
2515
2542
|
* @module
|
|
2516
2543
|
*/
|
|
@@ -2519,8 +2546,10 @@ declare class DeidentifyError extends Error {
|
|
|
2519
2546
|
* De-identify a {@link Dataset} per PS3.15 Annex E - the Basic Application Level
|
|
2520
2547
|
* Confidentiality Profile, plus any Retain/Clean Options passed in `retain`.
|
|
2521
2548
|
*
|
|
2522
|
-
* Pure: `ds` is never mutated. Returns a fresh dataset and a
|
|
2523
|
-
* {@link DeidentifyReport}
|
|
2549
|
+
* Pure: `ds` is never mutated. Returns a fresh dataset and a
|
|
2550
|
+
* {@link DeidentifyReport} of tags, keywords, action codes, warnings and the UID
|
|
2551
|
+
* map. Everything in it is composed from static tables except `uidMap`, whose
|
|
2552
|
+
* keys are the source UIDs the file carried: treat that field as PHI.
|
|
2524
2553
|
*
|
|
2525
2554
|
* @throws {@link DeidentifyError} (`INVALID_OPTIONS`) for an unknown Retain option
|
|
2526
2555
|
* or a malformed `uidRoot`.
|