forked from openmrs/openmrs-esm-patient-management
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #53 from its-kios09/hie-dependants
feat: added dependant view UI
- Loading branch information
Showing
5 changed files
with
117 additions
and
18 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
...istration-app/src/client-registry/hie-client-registry/dependants/dependants.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,48 @@ | ||
import React from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import styles from '../modal/confirm-hie.scss'; | ||
import PatientInfo from '../patient-info/patient-info.component'; | ||
|
||
const DependentInfo: React.FC<{ dependents: any[] }> = ({ dependents }) => { | ||
const { t } = useTranslation(); | ||
|
||
if (dependents && dependents.length > 0) { | ||
return ( | ||
<div> | ||
<span className={styles.header}>{t('dependants', 'Dependants')}</span> | ||
{dependents.map((dependent, index) => { | ||
const name = dependent?.name?.text; | ||
const relationship = | ||
dependent?.relationship?.[0]?.coding?.[0]?.display || t('unknownRelationship', 'Unknown'); | ||
const nationalID = dependent?.extension?.find( | ||
(ext) => | ||
ext.url === 'http://cr.tiberbu.app/fhir/StructureDefinition/dependants-id-number' && | ||
ext.valueIdentifier?.type?.coding?.[0]?.code === 'national-id', | ||
)?.valueIdentifier?.value; | ||
const birthCertificate = dependent?.extension?.find( | ||
(ext) => | ||
ext.url === 'http://cr.tiberbu.app/fhir/StructureDefinition/dependants-id-number' && | ||
ext.valueIdentifier?.type?.coding?.[0]?.code === 'birth-certificate-number', | ||
)?.valueIdentifier?.value; | ||
|
||
const primaryIdentifier = nationalID || birthCertificate; | ||
const identifierLabel = nationalID | ||
? t('nationalID', 'National ID') | ||
: t('birthCertificate', 'Birth Certificate'); | ||
|
||
return ( | ||
<div key={index} className={styles.dependentInfo}> | ||
<PatientInfo label={t('name', 'Name')} value={name} /> | ||
<PatientInfo label={t('relationship', 'Relationship')} value={relationship} /> | ||
<PatientInfo label={identifierLabel} value={primaryIdentifier} /> | ||
</div> | ||
); | ||
})} | ||
</div> | ||
); | ||
} | ||
|
||
return null; | ||
}; | ||
|
||
export default DependentInfo; |
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
17 changes: 17 additions & 0 deletions
17
...ation-app/src/client-registry/hie-client-registry/patient-info/patient-info.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,17 @@ | ||
import React from 'react'; | ||
import styles from '../modal/confirm-hie.scss'; | ||
|
||
const PatientInfo: React.FC<{ label: string; value?: string; customValue?: JSX.Element }> = ({ | ||
label, | ||
value, | ||
customValue, | ||
}) => { | ||
return ( | ||
<div className={styles.patientInfo}> | ||
<span className={styles.patientInfoLabel}>{label}</span> | ||
<span>{value || customValue || '--'}</span> | ||
</div> | ||
); | ||
}; | ||
|
||
export default PatientInfo; |
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