From ae4183852ffa4a89f5af5595be37a889e3ac2a4a Mon Sep 17 00:00:00 2001 From: Joe Boccanfuso <109477394+jbocce@users.noreply.github.com> Date: Thu, 16 Feb 2023 13:50:59 -0500 Subject: [PATCH] fix: Patient name handling as either Alphabetic object or simply string object - formatPN should accept a string person name as well as an object with a Alphabetic field. - For DICOM JSON data sources, spread in the patient data from the study object into the instance. --- extensions/default/src/DicomJSONDataSource/index.js | 2 ++ .../src/viewports/TrackedCornerstoneViewport.tsx | 2 +- platform/core/src/utils/formatPN.js | 4 +++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/extensions/default/src/DicomJSONDataSource/index.js b/extensions/default/src/DicomJSONDataSource/index.js index faf120985..241d430af 100644 --- a/extensions/default/src/DicomJSONDataSource/index.js +++ b/extensions/default/src/DicomJSONDataSource/index.js @@ -206,8 +206,10 @@ function createDicomJSONApi(dicomJsonConfig) { url: instance.url, imageId: instance.url, ...series, + ...study, }; delete obj.instances; + delete obj.series; return obj; }); storeInstances(instances); diff --git a/extensions/measurement-tracking/src/viewports/TrackedCornerstoneViewport.tsx b/extensions/measurement-tracking/src/viewports/TrackedCornerstoneViewport.tsx index 6d0971f43..c732215f4 100644 --- a/extensions/measurement-tracking/src/viewports/TrackedCornerstoneViewport.tsx +++ b/extensions/measurement-tracking/src/viewports/TrackedCornerstoneViewport.tsx @@ -211,7 +211,7 @@ function TrackedCornerstoneViewport(props) { seriesDescription: SeriesDescription, patientInformation: { patientName: PatientName - ? OHIF.utils.formatPN(PatientName.Alphabetic) + ? OHIF.utils.formatPN(PatientName) : '', patientSex: PatientSex || '', patientAge: PatientAge || '', diff --git a/platform/core/src/utils/formatPN.js b/platform/core/src/utils/formatPN.js index fb019ab5e..5e6f26a02 100644 --- a/platform/core/src/utils/formatPN.js +++ b/platform/core/src/utils/formatPN.js @@ -6,9 +6,11 @@ export default function formatPN(name) { return; } + const nameToUse = name.Alphabetic ?? name; + // Convert the first ^ to a ', '. String.replace() only affects // the first appearance of the character. - const commaBetweenFirstAndLast = name.replace('^', ', '); + const commaBetweenFirstAndLast = nameToUse.replace('^', ', '); // Replace any remaining '^' characters with spaces const cleaned = commaBetweenFirstAndLast.replace(/\^/g, ' ');