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.
This commit is contained in:
Joe Boccanfuso authored and GitHub committed 2023-02-16 13:50:59 -05:00
1 parent b67c7b23e8
commit ae4183852f
3 files changed
+6 -2

No files matched your search

+3 -1
View File
@@ -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, ' ');