@synanetics/fhir-name-formatter
v1.0.0-beta
Published
> TODO: description
Downloads
4
Maintainers
Keywords
Readme
@synanetics/fhir-name-formatter
Formats primitive strings or FHIR HumanName data types into strings, formatted according to the supplied options.
The default options format HumanNames according to NHS standards so, in many cases, it's not necessary to pass in any options
Usage
import formatName from '@synanetics/fhir-name-formatter';
const patient = {
resourceType: 'Patient',
name: [{
use: 'maiden',
family: 'Doe',
given: ['Jane'],
}, {
use: 'official',
family: 'Smith',
given: ['Jane'],
}]
};
const patientName = formatName(patient.name);
console.log(patientName); // 'Jane SMITH'
const organisation = {
resourceType: 'Organization',
name: 'Synanetics Ltd',
};
const organisationName = formatName(organisation.name);
console.log(organisationName); // 'Synanetics Ltd' -- this just returns the string, so you don't have to think about using it.Options
It is worth noting that the options described below only apply to HumanNames (or arrays thereof).
If empty selection options are supplied, for an array of HumanNames, the first element will be formatted.
| Option | Type | Description | Default |
| ----------------- | --------- | ----------- | ------- |
| includePrefixes | boolean | If true, prefixes (e.g. "Mrs", "Dr", "Lord") will be included in the returned formatted string. | false |
| includeSuffixes | boolean | If true, suffixes (e.g. "esq.", "MPhys", "BA") will be included in the returned formatted string. | false |
| upperCaseFamilyName | boolean | If true, the "family" part of the HumanName will be made upper case. | true |
| preferUse | string[] | If this property is set, the function will iterate through these preferences, in order, and select the first matching "use" as the HumanName to format and return. | ['official', 'usual'] |
| dispreferUse | string[] | If this property is set, the fuction will attempt not to use names whose "use" matches these values. Values earlier in the list are least preferred. So, using the supplied defaults, if a supplied HumanName array contains only a "maiden" and a "temp" name, the "temp" will be chosen. Names with no "use" defined are chosen ahead of all of these values. | ['old', 'maiden', 'temp', 'nickname'] |
| removeUse | string[] | Names matching these "use" types are removed from the HumanName array completely. | undefined |
| allowExpired | boolean | Allow expired names, that is, names where the "end" of the period has elapsed. | false |
| allowFuture | boolean | Allow future names, that is, names where the "start" of the period has not yet occurred. | false |
