Skip to content

Commit 7fdd87b

Browse files
fix(sr): avoid injecting options into Template ContentSequences (#494)
1 parent 4427728 commit 7fdd87b

2 files changed

Lines changed: 31 additions & 5 deletions

File tree

src/sr/templates.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ class MeasurementStatisticalProperties extends Template {
319319

320320
class NormalRangeProperties extends Template {
321321
constructor(options) {
322-
super(options);
322+
super();
323323
if (options.values === undefined) {
324324
throw new Error(
325325
"Option 'values' is required for NormalRangeProperties."
@@ -796,7 +796,7 @@ class SubjectContextSpecimen extends Template {
796796

797797
class SubjectContextDevice extends Template {
798798
constructor(options) {
799-
super(options);
799+
super();
800800
if (options.name === undefined) {
801801
throw new Error(
802802
"Option 'name' is required for SubjectContextDevice."
@@ -1164,7 +1164,7 @@ class VolumetricROIMeasurementsAndQualitativeEvaluations extends _ROIMeasurement
11641164

11651165
class MeasurementsDerivedFromMultipleROIMeasurements extends Template {
11661166
constructor(options) {
1167-
super(options);
1167+
super();
11681168
if (options.derivation === undefined) {
11691169
throw new Error(
11701170
"Option 'derivation' is required for " +
@@ -1433,7 +1433,7 @@ class MeasurementReport extends Template {
14331433

14341434
class TimePointContext extends Template {
14351435
constructor(options) {
1436-
super(options);
1436+
super();
14371437
if (options.timePoint === undefined) {
14381438
throw new Error(
14391439
"Option 'timePoint' is required for TimePointContext."
@@ -1588,7 +1588,7 @@ class AlgorithmIdentification extends Template {
15881588

15891589
class TrackingIdentifier extends Template {
15901590
constructor(options) {
1591-
super(options);
1591+
super();
15921592
if (options.uid === undefined) {
15931593
throw new Error("Option 'uid' is required for TrackingIdentifier.");
15941594
}

test/TrackingIdentifier.test.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { TrackingIdentifier } from "../src/sr/templates.js";
2+
3+
/**
4+
* Regression for https://github.com/dcmjs-org/dcmjs/issues/434 — Template
5+
* subclasses must call super(), not super(options), or the options object is
6+
* inserted as the first array element (ContentSequence extends Array).
7+
*/
8+
describe("TrackingIdentifier", () => {
9+
it("contains only DICOM content items, not the raw options object", () => {
10+
const id = new TrackingIdentifier({
11+
identifier: "ROI #1",
12+
uid: "1.2.3.4.5.6.7.8.9"
13+
});
14+
expect(id).toHaveLength(2);
15+
expect(id[0].ValueType).toBe("TEXT");
16+
expect(id[1].ValueType).toBe("UIDREF");
17+
});
18+
19+
it("with only uid is a single UIDREF item", () => {
20+
const id = new TrackingIdentifier({
21+
uid: "1.2.3.4.5.6.7.8.9"
22+
});
23+
expect(id).toHaveLength(1);
24+
expect(id[0].ValueType).toBe("UIDREF");
25+
});
26+
});

0 commit comments

Comments
 (0)