fix: Inconsistent Handling of Patient Name Tag (#4703)

This commit is contained in:
Jaseel-trenser 2025-01-21 19:37:30 +05:30 committed by GitHub
parent cbe926f52b
commit 8aedb2ec54
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 19 additions and 55 deletions

View File

@ -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 => {

View File

@ -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;

View File

@ -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
*

View File

@ -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,
});

View File

@ -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;

View File

@ -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
*

View File

@ -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,

View File

@ -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 = {

View File

@ -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

View File

@ -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,
});