Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Inconsistent Handling of Patient Name Tag #4703

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@ const contentItemFormatters = {
return `${NumericValue} ${CodeValue}`;
},
PNAME: contentItem => {
const personName = contentItem.PersonName?.[0]?.Alphabetic;
const personName = contentItem.PersonName?.[0];
return personName ? utils.formatPN(personName) : undefined;
},
DATE: contentItem => {
Original file line number Diff line number Diff line change
@@ -5,12 +5,14 @@ import { metaData, Enums, utilities } from '@cornerstonejs/core';
import type { ImageSliceData } from '@cornerstonejs/core/types';
import { ViewportOverlay } from '@ohif/ui';
import type { InstanceMetadata } from '@ohif/core/src/types';
import { formatPN, formatDICOMDate, formatDICOMTime, formatNumberPrecision } from './utils';
import { formatDICOMDate, formatDICOMTime, formatNumberPrecision } from './utils';
import { utils } from '@ohif/core';
import { StackViewportData, VolumeViewportData } from '../../types/CornerstoneCacheService';

import './CustomizableViewportOverlay.css';

const EPSILON = 1e-4;
const { formatPN } = utils;

type ViewportData = StackViewportData | VolumeViewportData;

25 changes: 0 additions & 25 deletions extensions/cornerstone/src/Viewport/Overlays/utils.ts
Original file line number Diff line number Diff line change
@@ -52,31 +52,6 @@ export function formatDICOMTime(time, strFormat = 'HH:mm:ss') {
return moment(time, 'HH:mm:ss').format(strFormat);
}

/**
* Formats a patient name for display purposes
*
* @param {string} name
* @returns {string} formatted name.
*/
export function formatPN(name) {
if (!name) {
return '';
}
if (typeof name === 'object') {
name = name.Alphabetic;
if (!name) {
return '';
}
}

const cleaned = name
.split('^')
.filter(s => !!s)
.join(', ')
.trim();
return cleaned === ',' || cleaned === '' ? '' : cleaned;
}

/**
* Gets compression type
*
3 changes: 2 additions & 1 deletion extensions/default/src/hooks/usePatientInfo.tsx
Original file line number Diff line number Diff line change
@@ -36,9 +36,10 @@ function usePatientInfo(servicesManager: AppTypes.ServicesManager) {
if (!instance) {
return;
}

setPatientInfo({
PatientID: instance.PatientID || null,
PatientName: instance.PatientName ? formatPN(instance.PatientName.Alphabetic) : null,
PatientName: instance.PatientName ? formatPN(instance.PatientName ) : null,
PatientSex: instance.PatientSex || null,
PatientDOB: formatDate(instance.PatientBirthDate) || null,
});
Original file line number Diff line number Diff line change
@@ -3,7 +3,10 @@ import classnames from 'classnames';

import listComponentGenerator from './listComponentGenerator';
import './ViewportOverlay.css';
import { formatDICOMDate, formatDICOMTime, formatNumberPrecision, formatPN } from './utils';
import { formatDICOMDate, formatDICOMTime, formatNumberPrecision } from './utils';
import { utils } from '@ohif/core';

const { formatPN } = utils;

interface OverlayItem {
id: string;
Original file line number Diff line number Diff line change
@@ -52,28 +52,6 @@ export function formatDICOMTime(time, strFormat = 'HH:mm:ss') {
return moment(time, 'HH:mm:ss').format(strFormat);
}

/**
* Formats a patient name for display purposes
*
* @param {string} name
* @returns {string} formatted name.
*/
export function formatPN(name) {
if (!name) {
return;
}

// Convert the first ^ to a ', '. String.replace() only affects
// the first appearance of the character.
const commaBetweenFirstAndLast = name.replace('^', ', ');

// Replace any remaining '^' characters with spaces
const cleaned = commaBetweenFirstAndLast.replace(/\^/g, ' ');

// Trim any extraneous whitespace
return cleaned.trim();
}

/**
* Gets compression type
*
4 changes: 3 additions & 1 deletion extensions/tmtv/src/commandsModule.ts
Original file line number Diff line number Diff line change
@@ -10,8 +10,10 @@ import dicomRTAnnotationExport from './utils/dicomRTAnnotationExport/RTStructure

import { getWebWorkerManager } from '@cornerstonejs/core';
import { Enums } from '@cornerstonejs/tools';
import { utils } from '@ohif/core';

const { SegmentationRepresentations } = Enums;
const { formatPN } = utils;

const metadataProvider = classes.MetadataProvider;
const ROI_THRESHOLD_MANUAL_TOOL_IDS = [
@@ -596,7 +598,7 @@ const commandsModule = ({ servicesManager, commandsManager, extensionManager }:
report[id] = {
...segReport,
PatientID: instance.PatientID ?? '000000',
PatientName: instance.PatientName.Alphabetic,
PatientName: formatPN(instance.PatientName),
StudyInstanceUID: instance.StudyInstanceUID,
SeriesInstanceUID: instance.SeriesInstanceUID,
StudyDate: instance.StudyDate,
3 changes: 2 additions & 1 deletion platform/core/src/classes/MetadataProvider.ts
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@ import DicomMetadataStore from '../services/DicomMetadataStore';
import fetchPaletteColorLookupTableData from '../utils/metadataProvider/fetchPaletteColorLookupTableData';
import toNumber from '../utils/toNumber';
import combineFrameInstance from '../utils/combineFrameInstance';
import formatPN from '../utils/formatPN';

class MetadataProvider {
private readonly imageURIToUIDs: Map<string, any> = new Map();
@@ -345,7 +346,7 @@ class MetadataProvider {

let patientName;
if (PatientName) {
patientName = PatientName.Alphabetic;
patientName = formatPN(PatientName);
}

metadata = {
3 changes: 2 additions & 1 deletion platform/core/src/utils/downloadCSVReport.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { DicomMetadataStore } from '../services/DicomMetadataStore/DicomMetadataStore';
import formatPN from './formatPN';

export default function downloadCSVReport(measurementData) {
if (measurementData.length === 0) {
@@ -86,7 +87,7 @@ function _getCommonRowItems(measurement, seriesMetadata) {

return {
'Patient ID': firstInstance.PatientID, // Patient ID
'Patient Name': firstInstance.PatientName?.Alphabetic || '', // Patient Name
'Patient Name': formatPN(firstInstance.PatientName) || '', // Patient Name
StudyInstanceUID: measurement.referenceStudyUID, // StudyInstanceUID
SeriesInstanceUID: measurement.referenceSeriesUID, // SeriesInstanceUID
SOPInstanceUID: measurement.SOPInstanceUID, // SOPInstanceUID
Original file line number Diff line number Diff line change
@@ -46,9 +46,10 @@ function usePatientInfo(servicesManager: AppTypes.ServicesManager) {
if (!instance) {
return;
}

setPatientInfo({
PatientID: instance.PatientID || null,
PatientName: instance.PatientName ? formatPN(instance.PatientName.Alphabetic) : null,
PatientName: instance.PatientName ? formatPN(instance.PatientName) : null,
PatientSex: instance.PatientSex || null,
PatientDOB: formatDate(instance.PatientBirthDate) || null,
});
Loading