@openmrs/esm-fast-data-entry-app 1.0.0-pre.36 → 1.0.0-pre.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/120.js +2 -0
- package/dist/{147.js.LICENSE.txt → 120.js.LICENSE.txt} +6 -0
- package/dist/574.js +1 -1
- package/dist/61.js +1 -0
- package/dist/804.js +1 -1
- package/dist/84.js +1 -0
- package/dist/990.js +1 -0
- package/dist/openmrs-esm-fast-data-entry-app.js +1 -1
- package/dist/openmrs-esm-fast-data-entry-app.js.buildmanifest.json +72 -72
- package/dist/openmrs-esm-fast-data-entry-app.old +1 -1
- package/package.json +1 -1
- package/src/FormBootstrap.tsx +2 -0
- package/src/Root.tsx +6 -9
- package/src/context/FormWorkflowContext.tsx +43 -15
- package/src/context/FormWorkflowReducer.ts +41 -0
- package/src/form-entry-workflow/FormEntryWorkflow.tsx +116 -54
- package/src/form-entry-workflow/styles.scss +13 -6
- package/src/form-review-card/FormReviewCard.tsx +50 -0
- package/src/form-review-card/index.ts +3 -0
- package/src/form-review-card/styles.scss +38 -0
- package/src/hooks/index.ts +3 -1
- package/src/hooks/useFormState.ts +23 -0
- package/src/hooks/useGetEncounter.ts +22 -0
- package/src/patient-banner/PatientBanner.test.tsx +1 -1
- package/src/patient-banner/PatientBanner.tsx +51 -105
- package/src/patient-banner/styles.scss +13 -28
- package/src/patient-card/PatientCard.tsx +2 -2
- package/src/patient-card/styles.scss +6 -5
- package/src/patient-search-header/PatientSearchHeader.tsx +3 -1
- package/src/patient-search-header/styles.scss +6 -2
- package/src/workflow-review/WorkflowReview.tsx +36 -0
- package/src/workflow-review/index.ts +3 -0
- package/src/workflow-review/styles.scss +34 -0
- package/translations/en.json +1 -0
- package/dist/147.js +0 -2
- package/dist/508.js +0 -1
- package/dist/634.js +0 -2
- package/dist/634.js.LICENSE.txt +0 -5
- package/dist/954.js +0 -1
|
@@ -1,28 +1,80 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
ExtensionSlot,
|
|
3
|
+
getGlobalStore,
|
|
4
|
+
useStore,
|
|
5
|
+
} from "@openmrs/esm-framework";
|
|
2
6
|
import { Button } from "carbon-components-react";
|
|
3
|
-
import React, { useContext
|
|
4
|
-
import { useHistory
|
|
7
|
+
import React, { useContext } from "react";
|
|
8
|
+
import { useHistory } from "react-router-dom";
|
|
5
9
|
import FormBootstrap from "../FormBootstrap";
|
|
6
10
|
import PatientCard from "../patient-card/PatientCard";
|
|
7
11
|
import PatientBanner from "../patient-banner";
|
|
8
12
|
import styles from "./styles.scss";
|
|
9
13
|
import PatientSearchHeader from "../patient-search-header";
|
|
10
14
|
import { useTranslation } from "react-i18next";
|
|
11
|
-
import FormWorkflowContext
|
|
15
|
+
import FormWorkflowContext, {
|
|
16
|
+
FormWorkflowProvider,
|
|
17
|
+
} from "../context/FormWorkflowContext";
|
|
18
|
+
import WorkflowReview from "../workflow-review";
|
|
12
19
|
|
|
13
20
|
interface ParamTypes {
|
|
14
21
|
formUuid: string;
|
|
15
22
|
}
|
|
16
23
|
|
|
17
|
-
const
|
|
18
|
-
|
|
24
|
+
const formStore = getGlobalStore("ampath-form-state");
|
|
25
|
+
|
|
26
|
+
const WorkflowNavigationButtons = () => {
|
|
27
|
+
const {
|
|
28
|
+
formUuid,
|
|
29
|
+
submitForReview,
|
|
30
|
+
submitForNext,
|
|
31
|
+
workflowState,
|
|
32
|
+
goToReview,
|
|
33
|
+
} = useContext(FormWorkflowContext);
|
|
19
34
|
const history = useHistory();
|
|
35
|
+
const store = useStore(formStore);
|
|
36
|
+
const formState = store[formUuid];
|
|
37
|
+
const navigationDisabled = formState !== "ready";
|
|
38
|
+
const { t } = useTranslation();
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<div className={styles.rightPanelActionButtons}>
|
|
42
|
+
<Button
|
|
43
|
+
kind="primary"
|
|
44
|
+
onClick={() => submitForNext()}
|
|
45
|
+
disabled={navigationDisabled || workflowState === "NEW_PATIENT"}
|
|
46
|
+
>
|
|
47
|
+
{t("nextPatient", "Next Patient")}
|
|
48
|
+
</Button>
|
|
49
|
+
<Button
|
|
50
|
+
kind="secondary"
|
|
51
|
+
disabled={navigationDisabled}
|
|
52
|
+
onClick={
|
|
53
|
+
workflowState === "NEW_PATIENT"
|
|
54
|
+
? () => goToReview()
|
|
55
|
+
: () => submitForReview()
|
|
56
|
+
}
|
|
57
|
+
>
|
|
58
|
+
{t("reviewSave", "Review & Save")}
|
|
59
|
+
</Button>
|
|
60
|
+
<Button
|
|
61
|
+
kind="tertiary"
|
|
62
|
+
onClick={() => history.push("/")}
|
|
63
|
+
disabled={navigationDisabled}
|
|
64
|
+
>
|
|
65
|
+
{t("cancel", "Cancel")}
|
|
66
|
+
</Button>
|
|
67
|
+
</div>
|
|
68
|
+
);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const FormWorkspace = () => {
|
|
20
72
|
const {
|
|
21
73
|
patientUuids,
|
|
22
74
|
activePatientUuid,
|
|
23
75
|
activeEncounterUuid,
|
|
24
|
-
openPatientSearch,
|
|
25
76
|
saveEncounter,
|
|
77
|
+
formUuid,
|
|
26
78
|
} = useContext(FormWorkflowContext);
|
|
27
79
|
const { t } = useTranslation();
|
|
28
80
|
|
|
@@ -33,56 +85,66 @@ const FormEntryWorkflow = () => {
|
|
|
33
85
|
};
|
|
34
86
|
|
|
35
87
|
return (
|
|
36
|
-
<div>
|
|
37
|
-
|
|
38
|
-
<
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
<div className={styles.
|
|
44
|
-
{
|
|
45
|
-
<
|
|
46
|
-
{
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
</div>
|
|
61
|
-
<div className={styles.rightPanel}>
|
|
62
|
-
<h4>Forms filled</h4>
|
|
63
|
-
<div className={styles.patientCardsSection}>
|
|
64
|
-
{patientUuids.map((patientUuid) => (
|
|
65
|
-
<PatientCard patientUuid={patientUuid} key={patientUuid} />
|
|
66
|
-
))}
|
|
67
|
-
</div>
|
|
68
|
-
<div className={styles.rightPanelActionButtons}>
|
|
69
|
-
<Button kind="primary" onClick={() => openPatientSearch()}>
|
|
70
|
-
{t("nextPatient", "Next Patient")}
|
|
71
|
-
</Button>
|
|
72
|
-
<Button kind="secondary" disabled>
|
|
73
|
-
{t("reviewSave", "Review & Save")}
|
|
74
|
-
</Button>
|
|
75
|
-
<Button kind="tertiary" onClick={() => history.push("/")}>
|
|
76
|
-
{t("cancel", "Cancel")}
|
|
77
|
-
</Button>
|
|
78
|
-
</div>
|
|
79
|
-
</div>
|
|
88
|
+
<div className={styles.workspace}>
|
|
89
|
+
{!patientUuids.length && (
|
|
90
|
+
<div className={styles.selectPatientMessage}>
|
|
91
|
+
{t("selectPatientFirst", "Please select a patient first")}
|
|
92
|
+
</div>
|
|
93
|
+
)}
|
|
94
|
+
{!!patientUuids.length && (
|
|
95
|
+
<div className={styles.formMainContent}>
|
|
96
|
+
<div className={styles.formContainer}>
|
|
97
|
+
<FormBootstrap
|
|
98
|
+
patientUuid={activePatientUuid}
|
|
99
|
+
encounterUuid={activeEncounterUuid}
|
|
100
|
+
{...{
|
|
101
|
+
formUuid,
|
|
102
|
+
handlePostResponse,
|
|
103
|
+
}}
|
|
104
|
+
/>
|
|
105
|
+
</div>
|
|
106
|
+
<div className={styles.rightPanel}>
|
|
107
|
+
<h4>Forms filled</h4>
|
|
108
|
+
<div className={styles.patientCardsSection}>
|
|
109
|
+
{patientUuids.map((patientUuid) => (
|
|
110
|
+
<PatientCard patientUuid={patientUuid} key={patientUuid} />
|
|
111
|
+
))}
|
|
80
112
|
</div>
|
|
81
|
-
|
|
113
|
+
<WorkflowNavigationButtons />
|
|
114
|
+
</div>
|
|
82
115
|
</div>
|
|
83
|
-
|
|
116
|
+
)}
|
|
84
117
|
</div>
|
|
85
118
|
);
|
|
86
119
|
};
|
|
87
120
|
|
|
88
|
-
|
|
121
|
+
const FormEntryWorkflow = () => {
|
|
122
|
+
const { workflowState } = useContext(FormWorkflowContext);
|
|
123
|
+
return (
|
|
124
|
+
<>
|
|
125
|
+
<div className={styles.breadcrumbsContainer}>
|
|
126
|
+
<ExtensionSlot extensionSlotName="breadcrumbs-slot" />
|
|
127
|
+
</div>
|
|
128
|
+
{workflowState === "REVIEW" && <WorkflowReview />}
|
|
129
|
+
{workflowState !== "REVIEW" && (
|
|
130
|
+
<>
|
|
131
|
+
<PatientSearchHeader />
|
|
132
|
+
<PatientBanner />
|
|
133
|
+
<div className={styles.workspaceWrapper}>
|
|
134
|
+
<FormWorkspace />
|
|
135
|
+
</div>
|
|
136
|
+
</>
|
|
137
|
+
)}
|
|
138
|
+
</>
|
|
139
|
+
);
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
const FormEntryWorkflowWrapper = () => {
|
|
143
|
+
return (
|
|
144
|
+
<FormWorkflowProvider>
|
|
145
|
+
<FormEntryWorkflow />
|
|
146
|
+
</FormWorkflowProvider>
|
|
147
|
+
);
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
export default FormEntryWorkflowWrapper;
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
.breadcrumbsContainer > div > div > nav {
|
|
7
|
-
background-color:
|
|
8
|
-
padding:
|
|
9
|
-
|
|
7
|
+
background-color: $ui-02;
|
|
8
|
+
padding: $spacing-04 $spacing-05;
|
|
9
|
+
height: $spacing-08;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
.workspaceWrapper {
|
|
@@ -27,28 +27,35 @@
|
|
|
27
27
|
.formMainContent {
|
|
28
28
|
display: flex;
|
|
29
29
|
text-align: center;
|
|
30
|
-
margin-top:
|
|
30
|
+
margin-top: $spacing-05;
|
|
31
|
+
column-gap: $spacing-05;
|
|
31
32
|
}
|
|
32
33
|
|
|
33
34
|
.formContainer {
|
|
34
35
|
flex-grow: 1;
|
|
35
36
|
max-height: calc(100vh - 14rem);
|
|
37
|
+
overflow-y: scroll;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.formContainer :global(.bx--form-item) :global(.question-area) {
|
|
41
|
+
max-width: 100%;
|
|
36
42
|
}
|
|
37
43
|
|
|
38
44
|
.rightPanel {
|
|
39
45
|
width: 13rem;
|
|
40
46
|
text-align: left;
|
|
47
|
+
overflow-y: scroll;
|
|
41
48
|
}
|
|
42
49
|
|
|
43
50
|
.patientCardsSection {
|
|
44
|
-
margin:
|
|
51
|
+
margin: $spacing-05 0;
|
|
45
52
|
border-bottom: 1px solid $carbon--gray-10;
|
|
46
53
|
}
|
|
47
54
|
|
|
48
55
|
.rightPanelActionButtons {
|
|
49
56
|
display: flex;
|
|
50
57
|
flex-direction: column;
|
|
51
|
-
row-gap:
|
|
58
|
+
row-gap: $spacing-03;
|
|
52
59
|
& button {
|
|
53
60
|
width: 100%;
|
|
54
61
|
text-decoration: "none";
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Accordion, AccordionItem, Button } from "carbon-components-react";
|
|
2
|
+
import React, { useContext } from "react";
|
|
3
|
+
import { useTranslation } from "react-i18next";
|
|
4
|
+
import FormWorkflowContext from "../context/FormWorkflowContext";
|
|
5
|
+
import { useGetPatient, useGetEncounter } from "../hooks";
|
|
6
|
+
import styles from "./styles.scss";
|
|
7
|
+
|
|
8
|
+
const FormReviewCard = ({ patientUuid }) => {
|
|
9
|
+
const { encounters, editEncounter } = useContext(FormWorkflowContext);
|
|
10
|
+
const patient = useGetPatient(patientUuid);
|
|
11
|
+
const givenName = patient?.name?.[0]?.given?.[0];
|
|
12
|
+
const familyName = patient?.name?.[0]?.family;
|
|
13
|
+
const identifier = patient?.identifier?.[0]?.value;
|
|
14
|
+
const encounterUuid = encounters?.[patientUuid];
|
|
15
|
+
const { encounter } = useGetEncounter(encounterUuid);
|
|
16
|
+
const { t } = useTranslation();
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<div className={styles.formReviewCard}>
|
|
20
|
+
<Accordion align="start">
|
|
21
|
+
<AccordionItem
|
|
22
|
+
title={
|
|
23
|
+
<>
|
|
24
|
+
<span className={styles.identifier}>{identifier}</span>
|
|
25
|
+
<span className={styles.displayName}>
|
|
26
|
+
{givenName} {familyName}
|
|
27
|
+
</span>
|
|
28
|
+
</>
|
|
29
|
+
}
|
|
30
|
+
className={styles.accordionItem}
|
|
31
|
+
>
|
|
32
|
+
{encounter && encounter?.obs && encounter.obs?.length && (
|
|
33
|
+
<div className={styles.dataField}>
|
|
34
|
+
<ul>
|
|
35
|
+
{encounter.obs.map((obs, index) => (
|
|
36
|
+
<li key={index}>{obs.display}</li>
|
|
37
|
+
))}
|
|
38
|
+
</ul>
|
|
39
|
+
</div>
|
|
40
|
+
)}
|
|
41
|
+
<Button kind="primary" onClick={() => editEncounter(patientUuid)}>
|
|
42
|
+
{t("goToForm", "Go To Form")}
|
|
43
|
+
</Button>
|
|
44
|
+
</AccordionItem>
|
|
45
|
+
</Accordion>
|
|
46
|
+
</div>
|
|
47
|
+
);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export default FormReviewCard;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
@import "~@openmrs/esm-styleguide/src/vars";
|
|
2
|
+
@import "~carbon-components/src/globals/scss/vars";
|
|
3
|
+
@import "~carbon-components/src/globals/scss/mixins";
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
.formReviewCard {
|
|
7
|
+
background-color: $ui-02;
|
|
8
|
+
padding: $spacing-02;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.formReviewCard :global(.bx--accordion) :global(.bx--accordion__item) {
|
|
12
|
+
border: none;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.formReviewCard :global(.bx--accordion__title) {
|
|
16
|
+
display: flex;
|
|
17
|
+
align-items: baseline;
|
|
18
|
+
column-gap: $spacing-05;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.formReviewCard :global(.bx--accordion__content) {
|
|
22
|
+
padding: $spacing-03;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.dataField {
|
|
26
|
+
@include carbon--type-style('code-02');
|
|
27
|
+
background-color: $ui-01;
|
|
28
|
+
padding: $spacing-03;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.displayName {
|
|
32
|
+
@include carbon--type-style('productive-heading-02');
|
|
33
|
+
font-weight: bold;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.identifier {
|
|
37
|
+
@include carbon--type-style('body-short-01')
|
|
38
|
+
}
|
package/src/hooks/index.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import useGetAllForms from "./useGetAllForms";
|
|
2
2
|
import useGetPatient from "./useGetPatient";
|
|
3
|
+
import useFormState from "./useFormState";
|
|
4
|
+
import useGetEncounter from "./useGetEncounter";
|
|
3
5
|
|
|
4
|
-
export { useGetAllForms, useGetPatient };
|
|
6
|
+
export { useGetAllForms, useGetPatient, useFormState, useGetEncounter };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
|
|
3
|
+
const useFormState = (formUuid) => {
|
|
4
|
+
const [state, setState] = useState(null);
|
|
5
|
+
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
const handler = (e) => {
|
|
8
|
+
if (e.detail?.formUuid === formUuid) {
|
|
9
|
+
setState(e.detail?.state);
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
window.addEventListener("ampath-form-state", handler);
|
|
14
|
+
|
|
15
|
+
return () => {
|
|
16
|
+
window.removeEventListener("ampath-form-state", handler);
|
|
17
|
+
};
|
|
18
|
+
}, [formUuid]);
|
|
19
|
+
|
|
20
|
+
return state;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export default useFormState;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { fetchCurrentPatient, openmrsFetch } from "@openmrs/esm-framework";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
import useSWR from "swr";
|
|
4
|
+
|
|
5
|
+
const encounterUrl = "/ws/rest/v1/encounter/";
|
|
6
|
+
|
|
7
|
+
const useGetEncounter = (encounterUuid) => {
|
|
8
|
+
const url = `${encounterUrl}${encounterUuid}`;
|
|
9
|
+
const { data, error } = useSWR(url, async () => {
|
|
10
|
+
const res = await openmrsFetch(url);
|
|
11
|
+
const encounter = res.data || null;
|
|
12
|
+
return encounter;
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
return {
|
|
16
|
+
encounter: data,
|
|
17
|
+
isLoading: !error && data,
|
|
18
|
+
error,
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export default useGetEncounter;
|
|
@@ -1,76 +1,51 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
formatDate,
|
|
5
|
-
parseDate,
|
|
6
|
-
} from "@openmrs/esm-framework";
|
|
7
|
-
import {
|
|
8
|
-
Button,
|
|
9
|
-
SkeletonPlaceholder,
|
|
10
|
-
SkeletonText,
|
|
11
|
-
} from "carbon-components-react";
|
|
12
|
-
import React, { useState } from "react";
|
|
1
|
+
import { age, ExtensionSlot } from "@openmrs/esm-framework";
|
|
2
|
+
import { SkeletonPlaceholder, SkeletonText } from "carbon-components-react";
|
|
3
|
+
import React, { useContext } from "react";
|
|
13
4
|
import styles from "./styles.scss";
|
|
14
|
-
import ChevronDown16 from "@carbon/icons-react/es/chevron--down/16";
|
|
15
|
-
import ChevronUp16 from "@carbon/icons-react/es/chevron--up/16";
|
|
16
5
|
import { useTranslation } from "react-i18next";
|
|
17
6
|
import useGetPatient from "../hooks/useGetPatient";
|
|
18
|
-
|
|
19
|
-
patientUuid: string;
|
|
20
|
-
}
|
|
7
|
+
import FormWorkflowContext from "../context/FormWorkflowContext";
|
|
21
8
|
|
|
22
9
|
const SkeletonPatientInfo = () => {
|
|
23
10
|
return (
|
|
24
11
|
<div className={styles.container}>
|
|
25
|
-
<
|
|
26
|
-
|
|
27
|
-
<div className={styles.
|
|
28
|
-
<
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
<SkeletonText />
|
|
43
|
-
</span>
|
|
44
|
-
</div>
|
|
45
|
-
</div>
|
|
46
|
-
<div className={styles.patientInfoRow}>
|
|
47
|
-
<span className={styles.identifier}>
|
|
48
|
-
<SkeletonText />
|
|
49
|
-
</span>
|
|
50
|
-
</div>
|
|
12
|
+
<SkeletonPlaceholder className={styles.photoPlaceholder} />
|
|
13
|
+
<div className={styles.patientInfoContent}>
|
|
14
|
+
<div className={styles.patientInfoRow}>
|
|
15
|
+
<SkeletonText width="7rem" lineCount={1} />
|
|
16
|
+
</div>
|
|
17
|
+
<div className={styles.patientInfoRow}>
|
|
18
|
+
<span>
|
|
19
|
+
<SkeletonText width="1rem" lineCount={1} />
|
|
20
|
+
</span>
|
|
21
|
+
<span>·</span>
|
|
22
|
+
<span>
|
|
23
|
+
<SkeletonText width="1rem" lineCount={1} />
|
|
24
|
+
</span>
|
|
25
|
+
<span>·</span>
|
|
26
|
+
<span>
|
|
27
|
+
<SkeletonText width="1rem" lineCount={1} />
|
|
28
|
+
</span>
|
|
51
29
|
</div>
|
|
52
30
|
</div>
|
|
53
31
|
</div>
|
|
54
32
|
);
|
|
55
33
|
};
|
|
56
34
|
|
|
57
|
-
const
|
|
58
|
-
const
|
|
35
|
+
const PatientBanner = () => {
|
|
36
|
+
const { activePatientUuid, workflowState } = useContext(FormWorkflowContext);
|
|
37
|
+
const patient = useGetPatient(activePatientUuid);
|
|
59
38
|
const { t } = useTranslation();
|
|
60
|
-
const [showContactDetails, setShowContactDetails] = useState<boolean>(false);
|
|
61
39
|
const patientName = `${patient?.name?.[0].given?.join(" ")} ${
|
|
62
40
|
patient?.name?.[0]?.family
|
|
63
41
|
}`;
|
|
64
42
|
|
|
65
43
|
const patientPhotoSlotState = React.useMemo(
|
|
66
|
-
() => ({ patientUuid: patient?.id, patientName }),
|
|
44
|
+
() => ({ patientUuid: patient?.id, patientName, size: "small" }),
|
|
67
45
|
[patient?.id, patientName]
|
|
68
46
|
);
|
|
69
47
|
|
|
70
|
-
|
|
71
|
-
e.stopPropagation();
|
|
72
|
-
setShowContactDetails((prevState) => !prevState);
|
|
73
|
-
};
|
|
48
|
+
if (workflowState === "NEW_PATIENT") return null;
|
|
74
49
|
|
|
75
50
|
if (!patient) {
|
|
76
51
|
return <SkeletonPatientInfo />;
|
|
@@ -78,63 +53,34 @@ const PatientInfo: React.FC<PatientInfoProps> = ({ patientUuid }) => {
|
|
|
78
53
|
|
|
79
54
|
return (
|
|
80
55
|
<div className={styles.container}>
|
|
81
|
-
<
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
<
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
(
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
<span>{age(patient.birthDate)} · </span>
|
|
106
|
-
<span>
|
|
107
|
-
{formatDate(parseDate(patient.birthDate), {
|
|
108
|
-
mode: "wide",
|
|
109
|
-
time: false,
|
|
110
|
-
})}
|
|
111
|
-
</span>
|
|
112
|
-
</div>
|
|
113
|
-
</div>
|
|
114
|
-
<div className={styles.patientInfoRow}>
|
|
115
|
-
<span className={styles.identifier}>
|
|
116
|
-
{patient.identifier.length
|
|
117
|
-
? patient.identifier
|
|
118
|
-
.map((identifier) => identifier.value)
|
|
119
|
-
.join(", ")
|
|
120
|
-
: "--"}
|
|
121
|
-
</span>
|
|
122
|
-
<Button
|
|
123
|
-
kind="ghost"
|
|
124
|
-
renderIcon={showContactDetails ? ChevronUp16 : ChevronDown16}
|
|
125
|
-
iconDescription="Toggle contact details"
|
|
126
|
-
onClick={(e) => toggleShowMore(e)}
|
|
127
|
-
disabled
|
|
128
|
-
>
|
|
129
|
-
{showContactDetails
|
|
130
|
-
? t("showLess", "Show less")
|
|
131
|
-
: t("showAllDetails", "Show all details")}
|
|
132
|
-
</Button>
|
|
133
|
-
</div>
|
|
56
|
+
<ExtensionSlot
|
|
57
|
+
extensionSlotName="patient-photo-slot"
|
|
58
|
+
state={patientPhotoSlotState}
|
|
59
|
+
/>
|
|
60
|
+
<div className={styles.patientInfoContent}>
|
|
61
|
+
<div className={styles.patientInfoRow}>
|
|
62
|
+
<span className={styles.patientName}>{patientName}</span>
|
|
63
|
+
</div>
|
|
64
|
+
<div className={styles.patientInfoRow}>
|
|
65
|
+
<span>
|
|
66
|
+
{(patient.gender ?? t("unknown", "Unknown")).replace(/^\w/, (c) =>
|
|
67
|
+
c.toUpperCase()
|
|
68
|
+
)}
|
|
69
|
+
</span>
|
|
70
|
+
<span>·</span>
|
|
71
|
+
<span>{age(patient.birthDate)}</span>
|
|
72
|
+
<span>·</span>
|
|
73
|
+
<span>
|
|
74
|
+
{patient.identifier.length
|
|
75
|
+
? patient.identifier
|
|
76
|
+
.map((identifier) => identifier.value)
|
|
77
|
+
.join(", ")
|
|
78
|
+
: "--"}
|
|
79
|
+
</span>
|
|
134
80
|
</div>
|
|
135
81
|
</div>
|
|
136
82
|
</div>
|
|
137
83
|
);
|
|
138
84
|
};
|
|
139
85
|
|
|
140
|
-
export default
|
|
86
|
+
export default PatientBanner;
|
|
@@ -3,54 +3,39 @@
|
|
|
3
3
|
@import '~carbon-components/src/globals/scss/mixins';
|
|
4
4
|
|
|
5
5
|
.container {
|
|
6
|
-
|
|
7
|
-
background-color: $ui-02;
|
|
8
|
-
padding: 0;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
.patientInfoContainer {
|
|
12
|
-
padding: 0 0 0 $spacing-05;
|
|
6
|
+
height: $spacing-11;
|
|
13
7
|
display: flex;
|
|
14
8
|
align-items: center;
|
|
15
|
-
|
|
9
|
+
background-color: $ui-02;
|
|
10
|
+
border-top: 0.0125rem solid $ui-03;
|
|
11
|
+
border-bottom: 0.0125rem solid $ui-03;
|
|
12
|
+
padding: 0 $spacing-05;
|
|
16
13
|
}
|
|
17
14
|
|
|
18
|
-
.
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
display: flex;
|
|
22
|
-
align-items: center;
|
|
23
|
-
min-height: 7rem;
|
|
15
|
+
.photoPlaceholder {
|
|
16
|
+
height: 48px;
|
|
17
|
+
width: 48px;
|
|
24
18
|
}
|
|
25
19
|
|
|
26
20
|
.patientName {
|
|
27
21
|
@include carbon--type-style('productive-heading-03');
|
|
22
|
+
font-weight: 600;
|
|
28
23
|
}
|
|
29
24
|
|
|
30
25
|
.patientInfoContent {
|
|
31
|
-
margin: $spacing-05 0 0 $spacing-05;
|
|
32
26
|
width: 100%;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
.demographics {
|
|
36
|
-
@include carbon--type-style('body-short-02');
|
|
37
|
-
color: $text-02;
|
|
38
|
-
margin-top: $spacing-02;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
.identifier {
|
|
42
|
-
@include carbon--type-style('body-short-02');
|
|
43
|
-
color: $ui-04;
|
|
27
|
+
margin-left: 1rem;
|
|
44
28
|
}
|
|
45
29
|
|
|
46
30
|
.patientInfoRow {
|
|
47
31
|
display: flex;
|
|
48
|
-
justify-content: space-between;
|
|
49
32
|
align-items: center;
|
|
50
|
-
|
|
51
33
|
& > button {
|
|
52
34
|
min-height: 2rem;
|
|
53
35
|
}
|
|
36
|
+
@include carbon--type-style('body-short-02');
|
|
37
|
+
color: $text-02;
|
|
38
|
+
column-gap: 0.8rem;
|
|
54
39
|
}
|
|
55
40
|
|
|
56
41
|
.patientEditBtn {
|