OHIF-163: Patient Name is displayed in correct format "Last Name, First Name" (#1820)

* Add util to formatpn

* Format patient name in patient information tab
This commit is contained in:
Igor Octaviano 2020-06-26 11:11:00 -03:00 committed by GitHub
parent 101efa4cf4
commit 5180eb127d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 24 additions and 4 deletions

View File

@ -22,7 +22,7 @@
* | limit | {number} |
* | offset | {number} |
*/
import { DICOMWeb } from '@ohif/core';
import { DICOMWeb, utils } from '@ohif/core';
const { getString, getName, getModalities } = DICOMWeb;
@ -50,7 +50,7 @@ function processResults(qidoStudies) {
time: getString(qidoStudy['00080030']), // HHmmss.SSS (24-hour, minutes, seconds, fractional seconds)
accession: getString(qidoStudy['00080050']) || '', // short string, probably a number?
mrn: getString(qidoStudy['00100020']) || '', // medicalRecordNumber
patientName: getName(qidoStudy['00100010']) || '',
patientName: utils.formatPN(getName(qidoStudy['00100010'])) || '',
instances: Number(getString(qidoStudy['00201208'])) || 0, // number
description: getString(qidoStudy['00081030']) || '',
modalities:

View File

@ -250,7 +250,7 @@ function OHIFCornerstoneSRViewport({
seriesDescription: SeriesDescription,
modality: Modality,
patientInformation: {
patientName: PatientName ? PatientName.Alphabetic || '' : '',
patientName: PatientName ? OHIF.utils.formatPN(PatientName.Alphabetic) : '',
patientSex: PatientSex || '',
patientAge: PatientAge || '',
MRN: PatientID || '',

View File

@ -233,7 +233,7 @@ function TrackedCornerstoneViewport({
seriesDescription: SeriesDescription,
modality: Modality,
patientInformation: {
patientName: PatientName ? PatientName.Alphabetic || '' : '',
patientName: PatientName ? OHIF.utils.formatPN(PatientName.Alphabetic) : '',
patientSex: PatientSex || '',
patientAge: PatientAge || '',
MRN: PatientID || '',

View File

@ -0,0 +1,18 @@
/**
* Formats a patient name for display purposes
*/
export default 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();
}

View File

@ -15,6 +15,7 @@ import makeCancelable from './makeCancelable';
import hotkeys from './hotkeys';
import Queue from './Queue';
import isDicomUid from './isDicomUid';
import formatPN from './formatPN';
import resolveObjectPath from './resolveObjectPath';
import * as hierarchicalListUtils from './hierarchicalListUtils';
import * as progressTrackingUtils from './progressTrackingUtils';
@ -26,6 +27,7 @@ const utils = {
addServers,
sortBy,
writeScript,
formatPN,
b64toBlob,
StackManager,
studyMetadataManager,