@openmrs/esm-fast-data-entry-app 1.0.0-pre.17 → 1.0.0-pre.23
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/147.js +2 -0
- package/dist/{767.js.LICENSE.txt → 147.js.LICENSE.txt} +0 -0
- package/dist/247.js +1 -0
- package/dist/508.js +1 -0
- package/dist/536.js +2 -0
- package/dist/{338.js.LICENSE.txt → 536.js.LICENSE.txt} +0 -0
- package/dist/574.js +1 -1
- package/dist/595.js +1 -1
- package/dist/595.js.LICENSE.txt +2 -0
- package/dist/634.js +2 -0
- package/dist/634.js.LICENSE.txt +5 -0
- package/dist/671.js +1 -0
- package/dist/804.js +1 -1
- package/dist/906.js +1 -2
- package/dist/openmrs-esm-fast-data-entry-app.js +1 -1
- package/dist/openmrs-esm-fast-data-entry-app.js.buildmanifest.json +74 -113
- package/dist/openmrs-esm-fast-data-entry-app.old +1 -1
- package/package.json +1 -3
- package/src/FormBootstrap.tsx +142 -0
- package/src/Root.tsx +4 -4
- package/src/empty-state/EmptyDataIllustration.tsx +51 -0
- package/src/empty-state/EmptyState.tsx +29 -0
- package/src/empty-state/styles.scss +55 -0
- package/src/form-entry-workflow/FormEntryWorkflow.tsx +98 -0
- package/src/form-entry-workflow/index.ts +3 -0
- package/src/form-entry-workflow/styles.scss +59 -0
- package/src/forms-page/FormsPage.tsx +54 -0
- package/src/forms-page/index.ts +3 -0
- package/src/forms-page/styles.scss +11 -0
- package/src/{forms → forms-table}/FormsTable.tsx +51 -23
- package/src/forms-table/index.ts +3 -0
- package/src/forms-table/styles.scss +20 -0
- package/src/hooks/index.ts +4 -0
- package/src/hooks/useGetAllForms.ts +31 -0
- package/src/{forms → hooks}/useGetPatient.ts +0 -0
- package/src/{forms/PatientInfo.test.tsx → patient-banner/PatientBanner.test.tsx} +3 -3
- package/src/{forms/PatientInfo.tsx → patient-banner/PatientBanner.tsx} +2 -2
- package/src/patient-banner/index.ts +3 -0
- package/src/{forms/patient-info.scss → patient-banner/styles.scss} +0 -0
- package/src/{forms → patient-card}/PatientCard.tsx +1 -1
- package/src/patient-card/index.ts +3 -0
- package/src/patient-search-header/PatientSearchHeader.tsx +49 -0
- package/src/patient-search-header/index.ts +3 -0
- package/src/patient-search-header/styles.scss +17 -0
- package/translations/en.json +13 -4
- package/dist/338.js +0 -2
- package/dist/350.js +0 -1
- package/dist/418.js +0 -1
- package/dist/482.js +0 -1
- package/dist/666.js +0 -1
- package/dist/767.js +0 -2
- package/dist/906.js.LICENSE.txt +0 -27
- package/src/FormEntry.tsx +0 -42
- package/src/Loader.tsx +0 -16
- package/src/forms/FormWorkflow.tsx +0 -135
- package/src/forms/FormsRoot.tsx +0 -73
- package/src/forms/mockData.ts +0 -20
- package/src/forms/styles.scss +0 -13
- package/src/loader.scss +0 -9
package/src/Root.tsx
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { BrowserRouter, Route, Switch } from "react-router-dom";
|
|
3
3
|
import { appPath } from "./constant";
|
|
4
|
-
const
|
|
5
|
-
const
|
|
4
|
+
const FormsPage = React.lazy(() => import("./forms-page"));
|
|
5
|
+
const FormEntryWorkflow = React.lazy(() => import("./form-entry-workflow"));
|
|
6
6
|
|
|
7
7
|
const Root = () => {
|
|
8
8
|
return (
|
|
9
9
|
<main>
|
|
10
10
|
<BrowserRouter basename={appPath}>
|
|
11
11
|
<Switch>
|
|
12
|
-
<Route exact path="/" children={<
|
|
13
|
-
<Route path="/:formUuid?" children={<
|
|
12
|
+
<Route exact path="/" children={<FormsPage />} />
|
|
13
|
+
<Route path="/:formUuid?" children={<FormEntryWorkflow />} />
|
|
14
14
|
</Switch>
|
|
15
15
|
</BrowserRouter>
|
|
16
16
|
</main>
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
export const EmptyDataIllustration = ({ width = "64", height = "64" }) => {
|
|
4
|
+
return (
|
|
5
|
+
<svg width={width} height={height} viewBox="0 0 64 64">
|
|
6
|
+
<title>Empty data illustration</title>
|
|
7
|
+
<g fill="none" fillRule="evenodd">
|
|
8
|
+
<path
|
|
9
|
+
d="M38.133 13.186H21.947c-.768.001-1.39.623-1.39 1.391V50.55l-.186.057-3.97 1.216a.743.743 0 01-.927-.493L3.664 12.751a.742.742 0 01.492-.926l6.118-1.874 17.738-5.43 6.119-1.873a.741.741 0 01.926.492L38.076 13l.057.186z"
|
|
10
|
+
fill="#F4F4F4"
|
|
11
|
+
/>
|
|
12
|
+
<path
|
|
13
|
+
d="M41.664 13L38.026 1.117A1.576 1.576 0 0036.056.07l-8.601 2.633-17.737 5.43-8.603 2.634a1.578 1.578 0 00-1.046 1.97l12.436 40.616a1.58 1.58 0 001.969 1.046l5.897-1.805.185-.057v-.194l-.185.057-5.952 1.822a1.393 1.393 0 01-1.737-.923L.247 12.682a1.39 1.39 0 01.923-1.738L9.772 8.31 27.51 2.881 36.112.247a1.393 1.393 0 011.737.923L41.47 13l.057.186h.193l-.057-.185z"
|
|
14
|
+
fill="#8D8D8D"
|
|
15
|
+
/>
|
|
16
|
+
<path
|
|
17
|
+
d="M11.378 11.855a.836.836 0 01-.798-.59L9.385 7.361a.835.835 0 01.554-1.042l16.318-4.996a.836.836 0 011.042.554l1.195 3.902a.836.836 0 01-.554 1.043l-16.318 4.995a.831.831 0 01-.244.037z"
|
|
18
|
+
fill="#C6C6C6"
|
|
19
|
+
/>
|
|
20
|
+
<circle fill="#C6C6C6" cx={17.636} cy={2.314} r={1.855} />
|
|
21
|
+
<circle
|
|
22
|
+
fill="#FFF"
|
|
23
|
+
fillRule="nonzero"
|
|
24
|
+
cx={17.636}
|
|
25
|
+
cy={2.314}
|
|
26
|
+
r={1.175}
|
|
27
|
+
/>
|
|
28
|
+
<path
|
|
29
|
+
d="M55.893 53.995H24.544a.79.79 0 01-.788-.789V15.644a.79.79 0 01.788-.788h31.349a.79.79 0 01.788.788v37.562a.79.79 0 01-.788.789z"
|
|
30
|
+
fill="#F4F4F4"
|
|
31
|
+
/>
|
|
32
|
+
<path
|
|
33
|
+
d="M41.47 13H21.948a1.579 1.579 0 00-1.576 1.577V52.4l.185-.057V14.577c.001-.768.623-1.39 1.391-1.39h19.581L41.471 13zm17.02 0H21.947a1.579 1.579 0 00-1.576 1.577v42.478c0 .87.706 1.576 1.576 1.577H58.49a1.579 1.579 0 001.576-1.577V14.577a1.579 1.579 0 00-1.576-1.576zm1.39 44.055c0 .768-.622 1.39-1.39 1.392H21.947c-.768-.001-1.39-.624-1.39-1.392V14.577c0-.768.622-1.39 1.39-1.39H58.49c.768 0 1.39.622 1.39 1.39v42.478z"
|
|
34
|
+
fill="#8D8D8D"
|
|
35
|
+
/>
|
|
36
|
+
<path
|
|
37
|
+
d="M48.751 17.082H31.686a.836.836 0 01-.835-.835v-4.081c0-.46.374-.834.835-.835H48.75c.461 0 .834.374.835.835v4.08c0 .462-.374.835-.835.836z"
|
|
38
|
+
fill="#C6C6C6"
|
|
39
|
+
/>
|
|
40
|
+
<circle fill="#C6C6C6" cx={40.218} cy={9.755} r={1.855} />
|
|
41
|
+
<circle
|
|
42
|
+
fill="#FFF"
|
|
43
|
+
fillRule="nonzero"
|
|
44
|
+
cx={40.218}
|
|
45
|
+
cy={9.755}
|
|
46
|
+
r={1.13}
|
|
47
|
+
/>
|
|
48
|
+
</g>
|
|
49
|
+
</svg>
|
|
50
|
+
);
|
|
51
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Tile } from "carbon-components-react";
|
|
3
|
+
import styles from "./styles.scss";
|
|
4
|
+
import { useLayoutType } from "@openmrs/esm-framework";
|
|
5
|
+
import { EmptyDataIllustration } from "./EmptyDataIllustration";
|
|
6
|
+
|
|
7
|
+
export interface EmptyStateProps {
|
|
8
|
+
headerTitle: string;
|
|
9
|
+
displayText: string;
|
|
10
|
+
}
|
|
11
|
+
const EmptyState: React.FC<EmptyStateProps> = ({
|
|
12
|
+
headerTitle,
|
|
13
|
+
displayText,
|
|
14
|
+
}) => {
|
|
15
|
+
const isTablet = useLayoutType() === "tablet";
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<Tile light className={styles.tile}>
|
|
19
|
+
<div className={isTablet ? styles.tabletHeading : styles.desktopHeading}>
|
|
20
|
+
<h4>{headerTitle}</h4>
|
|
21
|
+
</div>
|
|
22
|
+
<EmptyDataIllustration />
|
|
23
|
+
<p className={styles.content}>{displayText}</p>
|
|
24
|
+
</Tile>
|
|
25
|
+
);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export default EmptyState;
|
|
29
|
+
export { EmptyState };
|
|
@@ -0,0 +1,55 @@
|
|
|
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
|
+
.action {
|
|
6
|
+
margin-bottom: $spacing-03;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.content {
|
|
10
|
+
@include carbon--type-style("productive-heading-01");
|
|
11
|
+
color: $text-02;
|
|
12
|
+
margin-top: $spacing-05;
|
|
13
|
+
margin-bottom: $spacing-03;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.desktopHeading {
|
|
17
|
+
h4 {
|
|
18
|
+
@include carbon--type-style('productive-heading-02');
|
|
19
|
+
color: $text-02;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.tabletHeading {
|
|
24
|
+
h4 {
|
|
25
|
+
@include carbon--type-style('productive-heading-03');
|
|
26
|
+
color: $text-02;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.desktopHeading, .tabletHeading {
|
|
31
|
+
text-align: left;
|
|
32
|
+
text-transform: capitalize;
|
|
33
|
+
margin-bottom: $spacing-05;
|
|
34
|
+
|
|
35
|
+
h4:after {
|
|
36
|
+
content: "";
|
|
37
|
+
display: block;
|
|
38
|
+
width: 2rem;
|
|
39
|
+
padding-top: 0.188rem;
|
|
40
|
+
border-bottom: 0.375rem solid var(--brand-03);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.heading:after {
|
|
45
|
+
content: "";
|
|
46
|
+
display: block;
|
|
47
|
+
width: 2rem;
|
|
48
|
+
padding-top: 0.188rem;
|
|
49
|
+
border-bottom: 0.375rem solid var(--brand-03);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.tile {
|
|
53
|
+
text-align: center;
|
|
54
|
+
border: 1px solid $ui-03;
|
|
55
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { Add20, Close20 } from "@carbon/icons-react";
|
|
2
|
+
import { ExtensionSlot } from "@openmrs/esm-framework";
|
|
3
|
+
import { Button } from "carbon-components-react";
|
|
4
|
+
import React, { useState } from "react";
|
|
5
|
+
import { Link, useHistory, useParams } from "react-router-dom";
|
|
6
|
+
import FormBootstrap from "../FormBootstrap";
|
|
7
|
+
import PatientCard from "../patient-card/PatientCard";
|
|
8
|
+
import PatientBanner from "../patient-banner";
|
|
9
|
+
import styles from "./styles.scss";
|
|
10
|
+
import PatientSearchHeader from "../patient-search-header";
|
|
11
|
+
import { useTranslation } from "react-i18next";
|
|
12
|
+
|
|
13
|
+
interface ParamTypes {
|
|
14
|
+
formUuid: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const FormEntryWorkflow = () => {
|
|
18
|
+
const { formUuid } = useParams() as ParamTypes;
|
|
19
|
+
const history = useHistory();
|
|
20
|
+
const [patientUuids, setPatientUuids] = useState([]);
|
|
21
|
+
const [activePatientUuid, setActivePatientUuid] = useState(null);
|
|
22
|
+
const [encounterUuids, setEncounterUuids] = useState([]);
|
|
23
|
+
const { t } = useTranslation();
|
|
24
|
+
|
|
25
|
+
const saveEncounter = (uuid) => {
|
|
26
|
+
setEncounterUuids((encounterUuids) => [...encounterUuids, uuid]);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const handlePostResponse = (encounter) => {
|
|
30
|
+
if (
|
|
31
|
+
encounter &&
|
|
32
|
+
encounter.uuid &&
|
|
33
|
+
!encounterUuids.includes(encounter.uuid)
|
|
34
|
+
) {
|
|
35
|
+
saveEncounter(encounter.uuid);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<div>
|
|
41
|
+
<div className={styles.breadcrumbsContainer}>
|
|
42
|
+
<ExtensionSlot extensionSlotName="breadcrumbs-slot" />
|
|
43
|
+
</div>
|
|
44
|
+
{!activePatientUuid && (
|
|
45
|
+
<PatientSearchHeader
|
|
46
|
+
{...{ patientUuids, setPatientUuids, setActivePatientUuid }}
|
|
47
|
+
/>
|
|
48
|
+
)}
|
|
49
|
+
{activePatientUuid && <PatientBanner patientUuid={activePatientUuid} />}
|
|
50
|
+
<div className={styles.workspaceWrapper}>
|
|
51
|
+
<div className={styles.workspace}>
|
|
52
|
+
{!patientUuids.length && (
|
|
53
|
+
<div className={styles.selectPatientMessage}>
|
|
54
|
+
{t("selectPatientFirst", "Please select a patient first")}
|
|
55
|
+
</div>
|
|
56
|
+
)}
|
|
57
|
+
{!!patientUuids.length && (
|
|
58
|
+
<div className={styles.formMainContent}>
|
|
59
|
+
<div className={styles.formContainer}>
|
|
60
|
+
<FormBootstrap
|
|
61
|
+
patientUuid={activePatientUuid}
|
|
62
|
+
{...{
|
|
63
|
+
formUuid,
|
|
64
|
+
handlePostResponse,
|
|
65
|
+
}}
|
|
66
|
+
/>
|
|
67
|
+
</div>
|
|
68
|
+
<div className={styles.rightPanel}>
|
|
69
|
+
<h4>Forms filled</h4>
|
|
70
|
+
<div className={styles.patientCardsSection}>
|
|
71
|
+
{patientUuids.map((patientUuid) => (
|
|
72
|
+
<PatientCard patientUuid={patientUuid} key={patientUuid} />
|
|
73
|
+
))}
|
|
74
|
+
</div>
|
|
75
|
+
<div className={styles.rightPanelActionButtons}>
|
|
76
|
+
<Button
|
|
77
|
+
kind="primary"
|
|
78
|
+
onClick={() => setActivePatientUuid(null)}
|
|
79
|
+
>
|
|
80
|
+
{t("nextPatient", "Next Patient")}
|
|
81
|
+
</Button>
|
|
82
|
+
<Button kind="secondary" disabled>
|
|
83
|
+
{t("reviewSave", "Review & Save")}
|
|
84
|
+
</Button>
|
|
85
|
+
<Button kind="tertiary" onClick={() => history.push("/")}>
|
|
86
|
+
{t("cancel", "Cancel")}
|
|
87
|
+
</Button>
|
|
88
|
+
</div>
|
|
89
|
+
</div>
|
|
90
|
+
</div>
|
|
91
|
+
)}
|
|
92
|
+
</div>
|
|
93
|
+
</div>
|
|
94
|
+
</div>
|
|
95
|
+
);
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
export default FormEntryWorkflow;
|
|
@@ -0,0 +1,59 @@
|
|
|
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
|
+
.breadcrumbsContainer > div > div > nav {
|
|
7
|
+
background-color: white;
|
|
8
|
+
padding: 0.5rem;
|
|
9
|
+
border-bottom: 1px solid $openmrs-background-grey;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.workspaceWrapper {
|
|
13
|
+
display: flex;
|
|
14
|
+
justify-content: center;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.workspace {
|
|
18
|
+
width: 1100px;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.selectPatientMessage {
|
|
22
|
+
@include carbon--type-style('productive-heading-03');
|
|
23
|
+
margin: $spacing-07;
|
|
24
|
+
text-align: center;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.formMainContent {
|
|
28
|
+
display: flex;
|
|
29
|
+
text-align: center;
|
|
30
|
+
margin-top: 1rem;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.formContainer {
|
|
34
|
+
flex-grow: 1;
|
|
35
|
+
max-height: calc(100vh - 14rem);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.rightPanel {
|
|
39
|
+
width: 13rem;
|
|
40
|
+
text-align: left;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.patientCardsSection {
|
|
44
|
+
margin: 1rem 0;
|
|
45
|
+
border-bottom: 1px solid $carbon--gray-10;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.rightPanelActionButtons {
|
|
49
|
+
display: flex;
|
|
50
|
+
flex-direction: column;
|
|
51
|
+
row-gap: 0.5rem;
|
|
52
|
+
& button {
|
|
53
|
+
width: 100%;
|
|
54
|
+
text-decoration: "none";
|
|
55
|
+
& :hover {
|
|
56
|
+
background-color: $carbon--gray-30;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { useConfig } from "@openmrs/esm-framework";
|
|
2
|
+
import { Tab, Tabs } from "carbon-components-react";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { Config } from "../config-schema";
|
|
5
|
+
import { useGetAllForms } from "../hooks";
|
|
6
|
+
import FormsTable from "../forms-table";
|
|
7
|
+
import styles from "./styles.scss";
|
|
8
|
+
import { useTranslation } from "react-i18next";
|
|
9
|
+
|
|
10
|
+
const cleanForms = (rawFormData) => {
|
|
11
|
+
if (rawFormData) {
|
|
12
|
+
return rawFormData?.map((form) => ({
|
|
13
|
+
...form,
|
|
14
|
+
id: form.uuid,
|
|
15
|
+
}));
|
|
16
|
+
}
|
|
17
|
+
return null;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const FormsPage = () => {
|
|
21
|
+
const config = useConfig() as Config;
|
|
22
|
+
const { t } = useTranslation();
|
|
23
|
+
const { formCategories, formCategoriesToShow } = config;
|
|
24
|
+
const { forms, isLoading, error } = useGetAllForms();
|
|
25
|
+
const cleanRows = cleanForms(forms);
|
|
26
|
+
|
|
27
|
+
const categoryRows = formCategoriesToShow.map((name) => {
|
|
28
|
+
const category = formCategories.find((category) => category.name === name);
|
|
29
|
+
let rows = [];
|
|
30
|
+
if (category && cleanRows && cleanRows.length) {
|
|
31
|
+
const uuids = category.forms?.map((form) => form.formUUID);
|
|
32
|
+
rows = cleanRows.filter((row) => uuids.includes(row.uuid));
|
|
33
|
+
}
|
|
34
|
+
return { ...{ name, rows } };
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<div className={styles.mainContent}>
|
|
39
|
+
<h3 className={styles.pageTitle}>{t("forms", "Forms")}</h3>
|
|
40
|
+
<Tabs type="container">
|
|
41
|
+
<Tab label={t("allForms", "All Forms")}>
|
|
42
|
+
<FormsTable rows={cleanRows} {...{ error, isLoading }} />
|
|
43
|
+
</Tab>
|
|
44
|
+
{categoryRows?.map((category, index) => (
|
|
45
|
+
<Tab label={category.name} key={index}>
|
|
46
|
+
<FormsTable rows={category.rows} {...{ error, isLoading }} />
|
|
47
|
+
</Tab>
|
|
48
|
+
))}
|
|
49
|
+
</Tabs>
|
|
50
|
+
</div>
|
|
51
|
+
);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export default FormsPage;
|
|
@@ -13,26 +13,61 @@ import {
|
|
|
13
13
|
TableToolbarSearch,
|
|
14
14
|
} from "carbon-components-react";
|
|
15
15
|
import React from "react";
|
|
16
|
+
import { useTranslation } from "react-i18next";
|
|
16
17
|
import { Link } from "react-router-dom";
|
|
18
|
+
import EmptyState from "../empty-state/EmptyState";
|
|
19
|
+
import styles from "./styles.scss";
|
|
17
20
|
|
|
18
|
-
const
|
|
19
|
-
{
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
const FormsTable = ({ rows, error, isLoading }) => {
|
|
22
|
+
const { t } = useTranslation();
|
|
23
|
+
|
|
24
|
+
const formsHeader = [
|
|
25
|
+
{
|
|
26
|
+
key: "name",
|
|
27
|
+
header: t("formName", "Form Name"),
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
key: "actions",
|
|
31
|
+
header: t("actions", "Actions"),
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
key: "actions2",
|
|
35
|
+
header: "",
|
|
36
|
+
},
|
|
37
|
+
];
|
|
28
38
|
|
|
29
|
-
const FormsTable = ({ rows }) => {
|
|
30
39
|
const augmenteRows = rows?.map((row) => ({
|
|
31
40
|
...row,
|
|
32
|
-
actions: <Link to={row.uuid}>Fill Form</Link>,
|
|
41
|
+
actions: <Link to={row.uuid}>{t("fillForm", "Fill Form")}</Link>,
|
|
42
|
+
actions2: (
|
|
43
|
+
<Link to="#" className={styles.inactiveLink}>
|
|
44
|
+
{t("startGroupSession", "Start Group Session")}
|
|
45
|
+
</Link>
|
|
46
|
+
),
|
|
33
47
|
}));
|
|
34
|
-
|
|
35
|
-
|
|
48
|
+
|
|
49
|
+
if (isLoading) return <DataTableSkeleton />;
|
|
50
|
+
if (error) {
|
|
51
|
+
return (
|
|
52
|
+
<EmptyState
|
|
53
|
+
headerTitle={t("errorLoadingData", "Error Loading Data")}
|
|
54
|
+
displayText={`${t(
|
|
55
|
+
"dataErrorMessage",
|
|
56
|
+
"Something went wrong loading data from the server."
|
|
57
|
+
)} "${error?.response?.status}: ${error?.response?.statusText}"`}
|
|
58
|
+
/>
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
if (augmenteRows.length === 0) {
|
|
62
|
+
return (
|
|
63
|
+
<EmptyState
|
|
64
|
+
headerTitle={t("noFormsFound", "No Forms To Show")}
|
|
65
|
+
displayText={t(
|
|
66
|
+
"noFormsFoundMessage",
|
|
67
|
+
"No forms could be found for this category. Please double check the form concept uuids and access permissions."
|
|
68
|
+
)}
|
|
69
|
+
/>
|
|
70
|
+
);
|
|
36
71
|
}
|
|
37
72
|
return (
|
|
38
73
|
<DataTable rows={augmenteRows} headers={formsHeader} isSortable>
|
|
@@ -46,15 +81,8 @@ const FormsTable = ({ rows }) => {
|
|
|
46
81
|
}) => {
|
|
47
82
|
return (
|
|
48
83
|
<TableContainer>
|
|
49
|
-
<div
|
|
50
|
-
|
|
51
|
-
position: "relative",
|
|
52
|
-
display: "flex",
|
|
53
|
-
height: "3rem",
|
|
54
|
-
justifyContent: "flex-end",
|
|
55
|
-
}}
|
|
56
|
-
>
|
|
57
|
-
<TableToolbar style={{ width: "20%", minWidth: "200px" }}>
|
|
84
|
+
<div className={styles.toolbarWrapper}>
|
|
85
|
+
<TableToolbar className={styles.tableToolbar}>
|
|
58
86
|
<TableToolbarContent>
|
|
59
87
|
<TableToolbarSearch onChange={onInputChange} />
|
|
60
88
|
</TableToolbarContent>
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
.toolbarWrapper {
|
|
6
|
+
position: relative;
|
|
7
|
+
display: flex;
|
|
8
|
+
height: $spacing-09;
|
|
9
|
+
justify-content: flex-end;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.tableToolbar {
|
|
13
|
+
width: 20%;
|
|
14
|
+
min-width: 12.5rem;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.inactiveLink {
|
|
18
|
+
color: $carbon--gray-40;
|
|
19
|
+
cursor: not-allowed;
|
|
20
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { openmrsFetch } from "@openmrs/esm-framework";
|
|
2
|
+
import useSWR from "swr";
|
|
3
|
+
|
|
4
|
+
const customFormRepresentation =
|
|
5
|
+
"(uuid,name,display,encounterType:(uuid,name,viewPrivilege,editPrivilege),version,published,retired,resources:(uuid,name,dataType,valueReference))";
|
|
6
|
+
|
|
7
|
+
const formEncounterUrl = `/ws/rest/v1/form?v=custom:${customFormRepresentation}`;
|
|
8
|
+
const formEncounterUrlPoc = `/ws/rest/v1/form?v=custom:${customFormRepresentation}&q=poc`;
|
|
9
|
+
|
|
10
|
+
export function useGetAllForms(cachedOfflineFormsOnly = false) {
|
|
11
|
+
const showHtmlFormEntryForms = true;
|
|
12
|
+
const url = showHtmlFormEntryForms ? formEncounterUrl : formEncounterUrlPoc;
|
|
13
|
+
const { data, error } = useSWR([url, cachedOfflineFormsOnly], async () => {
|
|
14
|
+
const res = await openmrsFetch(url);
|
|
15
|
+
// show published forms and hide component forms
|
|
16
|
+
const forms =
|
|
17
|
+
res.data?.results?.filter(
|
|
18
|
+
(form) => form.published && !/component/i.test(form.name)
|
|
19
|
+
) ?? [];
|
|
20
|
+
|
|
21
|
+
return forms;
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
forms: data,
|
|
26
|
+
isLoading: !error && !data,
|
|
27
|
+
error,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export default useGetAllForms;
|
|
File without changes
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { render } from "@testing-library/react";
|
|
3
|
-
import
|
|
3
|
+
import PatientBanner from "./PatientBanner";
|
|
4
4
|
|
|
5
|
-
describe("
|
|
5
|
+
describe("PatientBanner", () => {
|
|
6
6
|
it("renders placeholder information when no data is present", () => {
|
|
7
|
-
render(<
|
|
7
|
+
render(<PatientBanner patientUuid={null} />);
|
|
8
8
|
});
|
|
9
9
|
});
|
|
@@ -10,11 +10,11 @@ import {
|
|
|
10
10
|
SkeletonText,
|
|
11
11
|
} from "carbon-components-react";
|
|
12
12
|
import React, { useState } from "react";
|
|
13
|
-
import styles from "./
|
|
13
|
+
import styles from "./styles.scss";
|
|
14
14
|
import ChevronDown16 from "@carbon/icons-react/es/chevron--down/16";
|
|
15
15
|
import ChevronUp16 from "@carbon/icons-react/es/chevron--up/16";
|
|
16
16
|
import { useTranslation } from "react-i18next";
|
|
17
|
-
import useGetPatient from "
|
|
17
|
+
import useGetPatient from "../hooks/useGetPatient";
|
|
18
18
|
interface PatientInfoProps {
|
|
19
19
|
patientUuid: string;
|
|
20
20
|
}
|
|
File without changes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SkeletonText } from "carbon-components-react";
|
|
2
2
|
import React from "react";
|
|
3
|
-
import useGetPatient from "
|
|
3
|
+
import useGetPatient from "../hooks/useGetPatient";
|
|
4
4
|
|
|
5
5
|
const CardContainer = ({ children }) => {
|
|
6
6
|
return <div style={{ padding: "1rem" }}>{children}</div>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Add20, Close20 } from "@carbon/icons-react";
|
|
2
|
+
import { ExtensionSlot } from "@openmrs/esm-framework";
|
|
3
|
+
import { Button } from "carbon-components-react";
|
|
4
|
+
import React from "react";
|
|
5
|
+
import { Link } from "react-router-dom";
|
|
6
|
+
import styles from "./styles.scss";
|
|
7
|
+
|
|
8
|
+
const PatientSearchHeader = ({
|
|
9
|
+
patientUuids,
|
|
10
|
+
setPatientUuids,
|
|
11
|
+
setActivePatientUuid,
|
|
12
|
+
}) => {
|
|
13
|
+
const handleSelectPatient = (uuid) => {
|
|
14
|
+
setPatientUuids([...patientUuids, uuid]), setActivePatientUuid(uuid);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<div className={styles.searchHeaderContainer}>
|
|
19
|
+
<span className={styles.padded}>Next patient:</span>
|
|
20
|
+
<span className={styles.searchBarWrapper}>
|
|
21
|
+
<ExtensionSlot
|
|
22
|
+
extensionSlotName="patient-search-bar-slot"
|
|
23
|
+
state={{
|
|
24
|
+
selectPatientAction: handleSelectPatient,
|
|
25
|
+
buttonProps: {
|
|
26
|
+
kind: "primary",
|
|
27
|
+
},
|
|
28
|
+
}}
|
|
29
|
+
/>
|
|
30
|
+
</span>
|
|
31
|
+
<span className={styles.padded}>or</span>
|
|
32
|
+
<span>
|
|
33
|
+
<Button disabled>
|
|
34
|
+
Create new patient <Add20 />
|
|
35
|
+
</Button>
|
|
36
|
+
</span>
|
|
37
|
+
<span style={{ flexGrow: 1 }} />
|
|
38
|
+
<span>
|
|
39
|
+
<Link to="">
|
|
40
|
+
<Button kind="ghost">
|
|
41
|
+
Cancel <Close20 />
|
|
42
|
+
</Button>
|
|
43
|
+
</Link>
|
|
44
|
+
</span>
|
|
45
|
+
</div>
|
|
46
|
+
);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export default PatientSearchHeader;
|