@openmrs/esm-fast-data-entry-app 1.0.0-pre.19 → 1.0.0-pre.25

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.
Files changed (58) hide show
  1. package/dist/147.js +2 -0
  2. package/dist/{737.js.LICENSE.txt → 147.js.LICENSE.txt} +0 -0
  3. package/dist/247.js +1 -0
  4. package/dist/508.js +1 -0
  5. package/dist/574.js +1 -1
  6. package/dist/595.js +1 -1
  7. package/dist/595.js.LICENSE.txt +2 -0
  8. package/dist/634.js +2 -0
  9. package/dist/{900.js.LICENSE.txt → 634.js.LICENSE.txt} +0 -0
  10. package/dist/804.js +1 -1
  11. package/dist/954.js +1 -0
  12. package/dist/openmrs-esm-fast-data-entry-app.js +1 -1
  13. package/dist/openmrs-esm-fast-data-entry-app.js.buildmanifest.json +74 -74
  14. package/dist/openmrs-esm-fast-data-entry-app.old +1 -1
  15. package/package.json +1 -1
  16. package/src/FormBootstrap.tsx +142 -0
  17. package/src/Root.tsx +11 -8
  18. package/src/context/FormWorkflowContext.tsx +40 -0
  19. package/src/context/FormWorkflowReducer.ts +38 -0
  20. package/src/empty-state/EmptyDataIllustration.tsx +51 -0
  21. package/src/empty-state/EmptyState.tsx +29 -0
  22. package/src/empty-state/styles.scss +55 -0
  23. package/src/form-entry-workflow/FormEntryWorkflow.tsx +88 -0
  24. package/src/form-entry-workflow/index.ts +3 -0
  25. package/src/form-entry-workflow/styles.scss +59 -0
  26. package/src/forms-page/FormsPage.tsx +54 -0
  27. package/src/forms-page/index.ts +3 -0
  28. package/src/forms-page/styles.scss +11 -0
  29. package/src/{forms → forms-table}/FormsTable.tsx +51 -23
  30. package/src/forms-table/index.ts +3 -0
  31. package/src/forms-table/styles.scss +20 -0
  32. package/src/hooks/index.ts +4 -0
  33. package/src/hooks/useGetAllForms.ts +31 -0
  34. package/src/{forms → hooks}/useGetPatient.ts +0 -0
  35. package/src/{forms/PatientInfo.test.tsx → patient-banner/PatientBanner.test.tsx} +3 -3
  36. package/src/{forms/PatientInfo.tsx → patient-banner/PatientBanner.tsx} +2 -2
  37. package/src/patient-banner/index.ts +3 -0
  38. package/src/{forms/patient-info.scss → patient-banner/styles.scss} +0 -0
  39. package/src/patient-card/PatientCard.tsx +51 -0
  40. package/src/patient-card/index.ts +3 -0
  41. package/src/patient-card/styles.scss +30 -0
  42. package/src/patient-search-header/PatientSearchHeader.tsx +47 -0
  43. package/src/patient-search-header/index.ts +3 -0
  44. package/src/patient-search-header/styles.scss +17 -0
  45. package/translations/en.json +13 -4
  46. package/dist/375.js +0 -1
  47. package/dist/418.js +0 -1
  48. package/dist/737.js +0 -2
  49. package/dist/900.js +0 -2
  50. package/dist/947.js +0 -1
  51. package/src/FormEntry.tsx +0 -42
  52. package/src/Loader.tsx +0 -16
  53. package/src/forms/FormWorkflow.tsx +0 -135
  54. package/src/forms/FormsRoot.tsx +0 -73
  55. package/src/forms/PatientCard.tsx +0 -37
  56. package/src/forms/mockData.ts +0 -20
  57. package/src/forms/styles.scss +0 -13
  58. package/src/loader.scss +0 -9
@@ -1,135 +0,0 @@
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 { useParams } from "react-router-dom";
6
- import FormEntry from "../FormEntry";
7
- import PatientCard from "./PatientCard";
8
- import PatientInfo from "./PatientInfo";
9
- import styles from "./styles.scss";
10
-
11
- const PatientSearchHeader = ({
12
- patientUuids,
13
- setPatientUuids,
14
- setActivePatientUuid,
15
- }) => {
16
- const handleSelectPatient = (uuid) => {
17
- setPatientUuids([...patientUuids, uuid]), setActivePatientUuid(uuid);
18
- };
19
-
20
- return (
21
- <div
22
- style={{
23
- display: "flex",
24
- backgroundColor: "white",
25
- padding: "2rem 1rem",
26
- }}
27
- >
28
- <span style={{ padding: "1rem" }}>Next patient:</span>
29
- <span style={{ minWidth: "35rem" }}>
30
- <ExtensionSlot
31
- extensionSlotName="patient-search-bar-slot"
32
- state={{
33
- selectPatientAction: handleSelectPatient,
34
- buttonProps: {
35
- kind: "primary",
36
- },
37
- }}
38
- />
39
- </span>
40
- <span style={{ padding: "1rem" }}>or</span>
41
- <span>
42
- <Button disabled>
43
- Create new patient <Add20 />
44
- </Button>
45
- </span>
46
- <span style={{ flexGrow: 1 }} />
47
- <span>
48
- <Button kind="ghost" disabled>
49
- Cancel <Close20 />
50
- </Button>
51
- </span>
52
- </div>
53
- );
54
- };
55
-
56
- interface ParamTypes {
57
- formUuid: string;
58
- }
59
-
60
- const FormWorkflow = () => {
61
- const { formUuid } = useParams() as ParamTypes;
62
- const [patientUuids, setPatientUuids] = useState([]);
63
- const [activePatientUuid, setActivePatientUuid] = useState(null);
64
-
65
- return (
66
- <div>
67
- <div className={styles.breadcrumbsContainer}>
68
- <ExtensionSlot extensionSlotName="breadcrumbs-slot" />
69
- </div>
70
- {!activePatientUuid && (
71
- <PatientSearchHeader
72
- {...{ patientUuids, setPatientUuids, setActivePatientUuid }}
73
- />
74
- )}
75
- {activePatientUuid && <PatientInfo patientUuid={activePatientUuid} />}
76
- <div style={{ display: "flex", justifyContent: "center" }}>
77
- <div style={{ width: "1100px" }}>
78
- {!patientUuids.length && (
79
- <div style={{ margin: "2rem", textAlign: "center" }}>
80
- Please select a patient first
81
- </div>
82
- )}
83
- {!!patientUuids.length && (
84
- <div className={styles.formContainer}>
85
- <div style={{ flexGrow: 1 }}>
86
- <FormEntry
87
- patientUuid={activePatientUuid}
88
- {...{
89
- formUuid,
90
- }}
91
- />
92
- </div>
93
- <div style={{ width: "13rem", textAlign: "left" }}>
94
- <h4>Forms filled</h4>
95
- <div
96
- style={{
97
- margin: "1rem 0",
98
- borderBottom: "1px solid #f4f4f4",
99
- }}
100
- >
101
- {patientUuids.map((patientUuid) => (
102
- <PatientCard patientUuid={patientUuid} key={patientUuid} />
103
- ))}
104
- </div>
105
- <div
106
- style={{
107
- display: "flex",
108
- flexDirection: "column",
109
- rowGap: "0.5rem",
110
- }}
111
- >
112
- <Button
113
- kind="primary"
114
- onClick={() => setActivePatientUuid(null)}
115
- style={{ width: "100%" }}
116
- >
117
- Next Patient
118
- </Button>
119
- <Button kind="secondary" disabled style={{ width: "100%" }}>
120
- Review & Save
121
- </Button>
122
- <Button kind="tertiary" disabled style={{ width: "100%" }}>
123
- Cancel
124
- </Button>
125
- </div>
126
- </div>
127
- </div>
128
- )}
129
- </div>
130
- </div>
131
- </div>
132
- );
133
- };
134
-
135
- export default FormWorkflow;
@@ -1,73 +0,0 @@
1
- import { openmrsFetch, useConfig } from "@openmrs/esm-framework";
2
- import { Tab, Tabs } from "carbon-components-react";
3
- import React from "react";
4
- import useSWR from "swr";
5
- import { Config } from "../config-schema";
6
- import FormsTable from "./FormsTable";
7
-
8
- export const customFormRepresentation =
9
- "(uuid,name,display,encounterType:(uuid,name,viewPrivilege,editPrivilege),version,published,retired,resources:(uuid,name,dataType,valueReference))";
10
-
11
- export const formEncounterUrl = `/ws/rest/v1/form?v=custom:${customFormRepresentation}`;
12
- export const formEncounterUrlPoc = `/ws/rest/v1/form?v=custom:${customFormRepresentation}&q=poc`;
13
-
14
- export function useFormEncounters(cachedOfflineFormsOnly = false) {
15
- const showHtmlFormEntryForms = true;
16
- const url = showHtmlFormEntryForms ? formEncounterUrl : formEncounterUrlPoc;
17
-
18
- return useSWR([url, cachedOfflineFormsOnly], async () => {
19
- const res = await openmrsFetch(url);
20
- // show published forms and hide component forms
21
- const forms =
22
- res.data?.results?.filter(
23
- (form) => form.published && !/component/i.test(form.name)
24
- ) ?? [];
25
-
26
- return forms;
27
- });
28
- }
29
-
30
- const cleanForms = (rawFormData) => {
31
- if (rawFormData) {
32
- return rawFormData?.map((form) => ({
33
- ...form,
34
- id: form.uuid,
35
- }));
36
- }
37
- };
38
-
39
- const FormsRoot = () => {
40
- const config = useConfig() as Config;
41
- const { formCategories, formCategoriesToShow } = config;
42
- const { data: forms } = useFormEncounters();
43
- const cleanRows = cleanForms(forms);
44
-
45
- const categoryRows = formCategoriesToShow.map((name) => {
46
- const category = formCategories.find((category) => category.name === name);
47
- let rows = [];
48
- if (category && cleanRows && cleanRows.length) {
49
- const uuids = category.forms?.map((form) => form.formUUID);
50
- rows = cleanRows.filter((row) => uuids.includes(row.uuid));
51
- }
52
- return { ...{ name, rows } };
53
- });
54
-
55
- return (
56
- <div style={{ padding: "2rem" }}>
57
- <h3 style={{ marginBottom: "1.5rem" }}>Forms</h3>
58
- <Tabs type="container">
59
- <Tab label="All Forms">
60
- <FormsTable rows={cleanRows} />
61
- </Tab>
62
- {categoryRows?.map((category) => (
63
- <Tab label={category.name}>
64
- <FormsTable rows={category.rows} />
65
- </Tab>
66
- ))}
67
- </Tabs>
68
- </div>
69
- );
70
- };
71
-
72
- export default FormsRoot;
73
- export { FormsRoot };
@@ -1,37 +0,0 @@
1
- import { SkeletonText } from "carbon-components-react";
2
- import React from "react";
3
- import useGetPatient from "./useGetPatient";
4
-
5
- const CardContainer = ({ children }) => {
6
- return <div style={{ padding: "1rem" }}>{children}</div>;
7
- };
8
-
9
- const PatientCard = ({ patientUuid }) => {
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
-
15
- if (!patient) {
16
- return (
17
- <CardContainer>
18
- <SkeletonText style={{ maxWidth: "8rem" }} />
19
- </CardContainer>
20
- );
21
- }
22
-
23
- return (
24
- <CardContainer>
25
- <div
26
- style={{ fontWeight: 300, fontSize: "0.8rem", lineHeight: "0.9rem" }}
27
- >
28
- {identifier}
29
- </div>
30
- <div style={{ fontWeight: "bold" }}>
31
- {givenName} {familyName}
32
- </div>
33
- </CardContainer>
34
- );
35
- };
36
-
37
- export default PatientCard;
@@ -1,20 +0,0 @@
1
- const rows = [
2
- {
3
- id: "admission-form",
4
- name: "Admission form",
5
- },
6
- {
7
- id: "dass-form",
8
- name: "DASS 21",
9
- },
10
- {
11
- id: "follow-up-form",
12
- name: "Follow-up form",
13
- },
14
- {
15
- id: "closure-form",
16
- name: "Closure form",
17
- },
18
- ];
19
-
20
- export const tableData = { ...{ rows } };
@@ -1,13 +0,0 @@
1
- @import "~@openmrs/esm-styleguide/src/vars";
2
-
3
- .breadcrumbsContainer > div > div > nav {
4
- background-color: white;
5
- padding: 0.5rem;
6
- border-bottom: 1px solid $openmrs-background-grey;
7
- }
8
-
9
- .formContainer {
10
- display: flex;
11
- text-align: center;
12
- margin-top: 1rem;
13
- }
package/src/loader.scss DELETED
@@ -1,9 +0,0 @@
1
- @import "~@openmrs/esm-styleguide/src/vars";
2
- @import "~carbon-components/src/globals/scss/vars";
3
-
4
- .loading {
5
- display: flex;
6
- background-color: $openmrs-background-grey;
7
- justify-content: center;
8
- min-height: $spacing-09;
9
- }