From 2c790ff674a42626e6c59fa77c1c2bfe5a14aa4e Mon Sep 17 00:00:00 2001 From: Erik Ziegler Date: Wed, 13 Jun 2018 16:43:53 +0200 Subject: [PATCH] fix(studylist) Fix DICOM Patient Name formatting (#35) --- .../ohif-viewerbase/client/lib/helpers/formatPN.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Packages/ohif-viewerbase/client/lib/helpers/formatPN.js b/Packages/ohif-viewerbase/client/lib/helpers/formatPN.js index 06d72a44a..e7ee7c7b9 100644 --- a/Packages/ohif-viewerbase/client/lib/helpers/formatPN.js +++ b/Packages/ohif-viewerbase/client/lib/helpers/formatPN.js @@ -7,7 +7,15 @@ const formatPN = context => { return; } - return context.replace('^', ', '); + // Convert the first ^ to a ', '. String.replace() only affects + // the first appearance of the character. + const commaBetweenFirstAndLast = context.replace('^', ', '); + + // Replace any remaining '^' characters with spaces + const cleaned = commaBetweenFirstAndLast.replace(/\^/g, ' '); + + // Trim any extraneous whitespace + return cleaned.trim(); }; /**