-
Notifications
You must be signed in to change notification settings - Fork 213
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(chore) O3-4011 - refactor patient banner to have patient identifiers…
… component be reuseable (#1159)
- Loading branch information
Showing
6 changed files
with
116 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export * from './patient-info/patient-banner-patient-info.component'; | ||
export * from './patient-info/patient-banner-patient-identifiers.component'; | ||
export * from './actions-menu/patient-banner-actions-menu.component'; | ||
export * from './contact-details/patient-banner-toggle-contact-details-button.component'; | ||
export * from './contact-details/patient-banner-contact-details.component'; |
55 changes: 55 additions & 0 deletions
55
...yleguide/src/patient-banner/patient-info/patient-banner-patient-identifiers.component.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/** @module @category UI */ | ||
import { Tag } from '@carbon/react'; | ||
import { useConfig, usePrimaryIdentifierCode } from '@openmrs/esm-react-utils'; | ||
import React from 'react'; | ||
import styles from './patient-banner-patient-info.module.scss'; | ||
import { type StyleguideConfigObject } from '../../config-schema'; | ||
|
||
interface PatientBannerPatientIdentifierProps { | ||
identifier: fhir.Identifier[] | undefined; | ||
showIdentifierLabel: boolean; | ||
} | ||
|
||
export function PatientBannerPatientIdentifier({ | ||
identifier, | ||
showIdentifierLabel, | ||
}: PatientBannerPatientIdentifierProps) { | ||
const { excludePatientIdentifierCodeTypes } = useConfig<StyleguideConfigObject>(); | ||
const { primaryIdentifierCode } = usePrimaryIdentifierCode(); | ||
const filteredIdentifiers = | ||
identifier?.filter((identifier) => { | ||
const code = identifier.type?.coding?.[0]?.code; | ||
return code && !excludePatientIdentifierCodeTypes?.uuids.includes(code); | ||
}) ?? []; | ||
|
||
return ( | ||
<div className={styles.identifiers}> | ||
{filteredIdentifiers?.length | ||
? filteredIdentifiers.map(({ value, type }, index) => ( | ||
<span key={value} className={styles.identifierTag}> | ||
<div>{index > 0 && <span className={styles.separator}>·</span>}</div> | ||
{type?.coding?.[0]?.code === primaryIdentifierCode ? ( | ||
<div className={styles.primaryIdentifier}> | ||
{showIdentifierLabel && ( | ||
<Tag type="gray" title={type?.text}> | ||
{type?.text}: | ||
</Tag> | ||
)} | ||
<span>{value}</span> | ||
</div> | ||
) : ( | ||
<label htmlFor="identifier" className={styles.secondaryIdentifier}> | ||
{showIdentifierLabel && <span className={styles.label}>{type?.text}: </span>} | ||
<span id="identifier" className={styles.identifier}> | ||
{value} | ||
</span> | ||
</label> | ||
)} | ||
</span> | ||
)) | ||
: ''} | ||
</div> | ||
); | ||
} | ||
|
||
export default PatientBannerPatientIdentifier; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters