Skip to content

Commit

Permalink
O3-2642 Add configurable link to patient chart on the relationship na…
Browse files Browse the repository at this point in the history
…me in the relationships widget
  • Loading branch information
CynthiaKamau committed Dec 7, 2023
1 parent 9f15df7 commit d0b46ae
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
6 changes: 6 additions & 0 deletions packages/esm-patient-banner-app/src/config-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ export const configSchema = {
_default: {},
},
},
useRelationshipNameLink: {
_type: Type.Boolean,
_description: 'Enable the use of a link to the patient chart in relationship names',
_default: false,
},
};

export interface ConfigObject {
Expand All @@ -34,4 +39,5 @@ export interface ConfigObject {
enabled: boolean;
customAddressLabel: Object;
};
useRelationshipNameLink: boolean;
}
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ const Contact: React.FC<{ telecom: Array<fhir.ContactPoint>; patientUuid: string
const Relationships: React.FC<{ patientId: string }> = ({ patientId }) => {
const { t } = useTranslation();
const { data: relationships, isLoading } = useRelationships(patientId);
const config = useConfig();

const extractName = (display: string) => {
const pattern = /-\s*(.*)$/;
Expand All @@ -174,7 +175,17 @@ const Relationships: React.FC<{ patientId: string }> = ({ patientId }) => {
<>
{relationships.map((r) => (
<li key={r.uuid} className={styles.relationship}>
<div>{extractName(r.display)}</div>
{config.useRelationshipNameLink ? (
<ConfigurableLink
style={{ textDecoration: 'none', maxWidth: '50%' }}
to={`${window.getOpenmrsSpaBase()}patient/${r.relativeUuid}/chart`}
>
{r.display}
</ConfigurableLink>
) : (
<div>{extractName(r.display)}</div>
)}

<div>{r.relationshipType}</div>
<div>
{`${r.relativeAge ? r.relativeAge : '--'} ${
Expand Down

0 comments on commit d0b46ae

Please sign in to comment.