@openmrs/esm-fast-data-entry-app 1.0.0-pre.21 → 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.
Files changed (41) hide show
  1. package/dist/508.js +1 -0
  2. package/dist/574.js +1 -1
  3. package/dist/671.js +1 -0
  4. package/dist/804.js +1 -1
  5. package/dist/openmrs-esm-fast-data-entry-app.js +1 -1
  6. package/dist/openmrs-esm-fast-data-entry-app.js.buildmanifest.json +40 -40
  7. package/dist/openmrs-esm-fast-data-entry-app.old +1 -1
  8. package/package.json +1 -1
  9. package/src/FormBootstrap.tsx +142 -0
  10. package/src/Root.tsx +4 -4
  11. package/src/form-entry-workflow/FormEntryWorkflow.tsx +98 -0
  12. package/src/form-entry-workflow/index.ts +3 -0
  13. package/src/form-entry-workflow/styles.scss +59 -0
  14. package/src/forms-page/FormsPage.tsx +54 -0
  15. package/src/forms-page/index.ts +3 -0
  16. package/src/forms-page/styles.scss +11 -0
  17. package/src/{forms → forms-table}/FormsTable.tsx +37 -26
  18. package/src/forms-table/index.ts +3 -0
  19. package/src/forms-table/styles.scss +20 -0
  20. package/src/hooks/index.ts +4 -0
  21. package/src/hooks/useGetAllForms.ts +31 -0
  22. package/src/{forms → hooks}/useGetPatient.ts +0 -0
  23. package/src/{forms/PatientInfo.test.tsx → patient-banner/PatientBanner.test.tsx} +3 -3
  24. package/src/{forms/PatientInfo.tsx → patient-banner/PatientBanner.tsx} +2 -2
  25. package/src/patient-banner/index.ts +3 -0
  26. package/src/{forms/patient-info.scss → patient-banner/styles.scss} +0 -0
  27. package/src/{forms → patient-card}/PatientCard.tsx +1 -1
  28. package/src/patient-card/index.ts +3 -0
  29. package/src/patient-search-header/PatientSearchHeader.tsx +49 -0
  30. package/src/patient-search-header/index.ts +3 -0
  31. package/src/patient-search-header/styles.scss +17 -0
  32. package/translations/en.json +13 -4
  33. package/dist/852.js +0 -1
  34. package/dist/947.js +0 -1
  35. package/src/FormEntry.tsx +0 -42
  36. package/src/Loader.tsx +0 -16
  37. package/src/forms/FormWorkflow.tsx +0 -135
  38. package/src/forms/FormsRoot.tsx +0 -79
  39. package/src/forms/mockData.ts +0 -20
  40. package/src/forms/styles.scss +0 -13
  41. package/src/loader.scss +0 -9
package/src/FormEntry.tsx DELETED
@@ -1,42 +0,0 @@
1
- import React from "react";
2
- import { ExtensionSlot } from "@openmrs/esm-framework";
3
- import useGetPatient from "./forms/useGetPatient";
4
- interface FormParams {
5
- formUuid: string;
6
- patientUuid: string;
7
- visitUuid?: string;
8
- visitTypeUuid?: string;
9
- encounterUuid?: string;
10
- }
11
-
12
- const FormEntry = ({
13
- formUuid,
14
- patientUuid,
15
- visitUuid,
16
- visitTypeUuid,
17
- encounterUuid,
18
- }: FormParams) => {
19
- const patient = useGetPatient(patientUuid);
20
-
21
- return (
22
- <div>
23
- {formUuid && patientUuid && patient && (
24
- <ExtensionSlot
25
- extensionSlotName="form-widget-slot"
26
- state={{
27
- view: "form",
28
- formUuid,
29
- visitUuid: visitUuid ?? "",
30
- visitTypeUuid: visitTypeUuid ?? "",
31
- patientUuid,
32
- patient,
33
- encounterUuid: encounterUuid ?? "",
34
- closeWorkspace: () => {},
35
- }}
36
- />
37
- )}
38
- </div>
39
- );
40
- };
41
-
42
- export default FormEntry;
package/src/Loader.tsx DELETED
@@ -1,16 +0,0 @@
1
- import React from "react";
2
- import styles from "./loader.scss";
3
- import { InlineLoading } from "carbon-components-react";
4
- import { useTranslation } from "react-i18next";
5
-
6
- const Loader: React.FC = () => {
7
- const { t } = useTranslation();
8
- return (
9
- <InlineLoading
10
- className={styles.loading}
11
- description={`${t("loading", "Loading")} ...`}
12
- />
13
- );
14
- };
15
-
16
- export default Loader;
@@ -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 { Link, 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" href={`${window.spaBase}/forms`}>
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,79 +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
- const { data, error } = useSWR([url, cachedOfflineFormsOnly], async () => {
18
- const res = await openmrsFetch(url);
19
- // show published forms and hide component forms
20
- const forms =
21
- res.data?.results?.filter(
22
- (form) => form.published && !/component/i.test(form.name)
23
- ) ?? [];
24
-
25
- return forms;
26
- });
27
-
28
- return {
29
- forms: data,
30
- isLoading: !error && !data,
31
- error,
32
- };
33
- }
34
-
35
- const cleanForms = (rawFormData) => {
36
- if (rawFormData) {
37
- return rawFormData?.map((form) => ({
38
- ...form,
39
- id: form.uuid,
40
- }));
41
- }
42
- return null;
43
- };
44
-
45
- const FormsRoot = () => {
46
- const config = useConfig() as Config;
47
- const { formCategories, formCategoriesToShow } = config;
48
- const { forms, isLoading, error } = useFormEncounters();
49
- const cleanRows = cleanForms(forms);
50
-
51
- const categoryRows = formCategoriesToShow.map((name) => {
52
- const category = formCategories.find((category) => category.name === name);
53
- let rows = [];
54
- if (category && cleanRows && cleanRows.length) {
55
- const uuids = category.forms?.map((form) => form.formUUID);
56
- rows = cleanRows.filter((row) => uuids.includes(row.uuid));
57
- }
58
- return { ...{ name, rows } };
59
- });
60
-
61
- return (
62
- <div style={{ padding: "2rem" }}>
63
- <h3 style={{ marginBottom: "1.5rem" }}>Forms</h3>
64
- <Tabs type="container">
65
- <Tab label="All Forms">
66
- <FormsTable rows={cleanRows} {...{ error, isLoading }} />
67
- </Tab>
68
- {categoryRows?.map((category) => (
69
- <Tab label={category.name}>
70
- <FormsTable rows={category.rows} {...{ error, isLoading }} />
71
- </Tab>
72
- ))}
73
- </Tabs>
74
- </div>
75
- );
76
- };
77
-
78
- export default FormsRoot;
79
- export { FormsRoot };
@@ -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
- }