Skip to content

Commit

Permalink
fix formatting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Craig Berry committed Feb 3, 2025
1 parent 8cb9389 commit 6a89297
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/DicomMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ class DicomMessage {
originalValue = tagObject._rawValue.map(val =>
vr.applyFormatting(val)
);
} else {
} else {
originalValue = vr.applyFormatting(tagObject._rawValue);
}

Expand Down
2 changes: 1 addition & 1 deletion src/ValueRepresentation.js
Original file line number Diff line number Diff line change
Expand Up @@ -967,7 +967,7 @@ class PersonName extends EncodedStringRepresentation {
}

readBytes(stream, length) {
return this.readPaddedEncodedString(stream, length)
return this.readPaddedEncodedString(stream, length);
}

applyFormatting(value) {
Expand Down
22 changes: 14 additions & 8 deletions test/lossless-read-write.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import dcmjs from "../src/index.js";
import { deepEqual } from "../src/utilities/deepEqual";

import { getTestDataset } from "./testUtils";
import {DicomMetaDictionary} from "../src/DicomMetaDictionary";
import { DicomMetaDictionary } from "../src/DicomMetaDictionary";

const { DicomDict, DicomMessage } = dcmjs.data;

Expand Down Expand Up @@ -978,28 +978,34 @@ describe("lossless-read-write", () => {
deepEqual(dicomDict.dict, outputDicomDict.dict);
});

test('0 length PN tag should be retained following naturalize and de-naturalize', () => {
test("0 length PN tag should be retained following naturalize and de-naturalize", () => {
const file = fs.readFileSync("test/empty-person-name.dcm");
const origDicomDict = DicomMessage.readFile(file.buffer);
const origNaturalizedDataset = DicomMetaDictionary.naturalizeDataset(origDicomDict.dict);
const origNaturalizedDataset = DicomMetaDictionary.naturalizeDataset(
origDicomDict.dict
);

// confirm starting dataset contains empty tag value for referring physician person name
expect(origDicomDict.dict["00080090"]._rawValue).toEqual("")
expect(origDicomDict.dict["00080090"]._rawValue).toEqual("");
expect(origNaturalizedDataset.ReferringPhysicianName).toEqual([]);

// re-encode the unnaturalized object
origDicomDict.dict = DicomMetaDictionary.denaturalizeDataset(origNaturalizedDataset);
origDicomDict.dict = DicomMetaDictionary.denaturalizeDataset(
origNaturalizedDataset
);
const outputBuffer = origDicomDict.write();
const newDicomDict = DicomMessage.readFile(outputBuffer);
const newNaturalizedDataset = DicomMetaDictionary.naturalizeDataset(origDicomDict.dict);
const newNaturalizedDataset = DicomMetaDictionary.naturalizeDataset(
origDicomDict.dict
);

// confirm output referring physican name remains the same
expect(newDicomDict.dict["00080090"]._rawValue).toEqual("")
expect(newDicomDict.dict["00080090"]._rawValue).toEqual("");
expect(newNaturalizedDataset.ReferringPhysicianName).toEqual([]);

// confirm no other changes to the rest of the file
deepEqual(origDicomDict, newDicomDict);
})
});
});

const getDcmjsDataFile = async (release, fileName) => {
Expand Down

0 comments on commit 6a89297

Please sign in to comment.