@openmrs/esm-fast-data-entry-app 1.0.1-pre.17 → 1.0.1-pre.171
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/README.md +21 -2
- package/dist/101.js +1 -0
- package/dist/101.js.map +1 -0
- package/dist/132.js +1 -1
- package/dist/143.js +1 -0
- package/dist/143.js.map +1 -0
- package/dist/188.js +1 -0
- package/dist/188.js.map +1 -0
- package/dist/197.js +1 -0
- package/dist/219.js +1 -0
- package/dist/219.js.map +1 -0
- package/dist/221.js +1 -0
- package/dist/221.js.map +1 -0
- package/dist/259.js +1 -0
- package/dist/259.js.map +1 -0
- package/dist/29.js +2 -0
- package/dist/29.js.LICENSE.txt +3 -0
- package/dist/29.js.map +1 -0
- package/dist/300.js +1 -0
- package/dist/31.js +2 -0
- package/dist/{569.js.LICENSE.txt → 31.js.LICENSE.txt} +9 -6
- package/dist/31.js.map +1 -0
- package/dist/326.js +1 -0
- package/dist/326.js.map +1 -0
- package/dist/335.js +1 -0
- package/dist/367.js +1 -0
- package/dist/367.js.map +1 -0
- package/dist/480.js +1 -0
- package/dist/491.js +1 -0
- package/dist/491.js.map +1 -0
- package/dist/540.js +2 -0
- package/dist/540.js.map +1 -0
- package/dist/55.js +1 -0
- package/dist/564.js +1 -0
- package/dist/564.js.map +1 -0
- package/dist/602.js +1 -0
- package/dist/602.js.map +1 -0
- package/dist/626.js +2 -0
- package/dist/626.js.LICENSE.txt +9 -0
- package/dist/626.js.map +1 -0
- package/dist/652.js +1 -0
- package/dist/685.js +1 -0
- package/dist/685.js.map +1 -0
- package/dist/773.js +2 -0
- package/dist/{68.js.LICENSE.txt → 773.js.LICENSE.txt} +13 -2
- package/dist/773.js.map +1 -0
- package/dist/91.js +1 -0
- package/dist/91.js.map +1 -0
- package/dist/961.js +2 -0
- package/dist/961.js.map +1 -0
- package/dist/99.js +1 -0
- package/dist/99.js.map +1 -0
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -0
- package/dist/openmrs-esm-fast-data-entry-app.js +1 -1
- package/dist/openmrs-esm-fast-data-entry-app.js.buildmanifest.json +403 -136
- package/dist/openmrs-esm-fast-data-entry-app.js.map +1 -0
- package/dist/routes.json +1 -0
- package/jest.config.json +2 -1
- package/package.json +42 -37
- package/src/CancelModal.tsx +48 -0
- package/src/CompleteModal.tsx +46 -0
- package/src/FormBootstrap.tsx +32 -4
- package/src/add-group-modal/AddGroupModal.tsx +110 -60
- package/src/add-group-modal/styles.scss +7 -3
- package/src/config-schema.ts +62 -0
- package/src/context/FormWorkflowContext.tsx +13 -1
- package/src/context/FormWorkflowReducer.ts +13 -3
- package/src/context/GroupFormWorkflowContext.tsx +43 -6
- package/src/context/GroupFormWorkflowReducer.ts +160 -15
- package/src/declarations.d.ts +4 -0
- package/src/empty-state/styles.scss +14 -14
- package/src/form-entry-workflow/FormEntryWorkflow.tsx +74 -102
- package/src/form-entry-workflow/form-review-card/styles.scss +9 -11
- package/src/form-entry-workflow/patient-banner/styles.scss +11 -12
- package/src/form-entry-workflow/patient-search-header/PatientSearchHeader.tsx +2 -2
- package/src/form-entry-workflow/patient-search-header/styles.scss +13 -10
- package/src/form-entry-workflow/styles.scss +13 -14
- package/src/form-entry-workflow/workflow-review/WorkflowReview.tsx +5 -3
- package/src/form-entry-workflow/workflow-review/styles.scss +0 -4
- package/src/forms-page/FormsPage.tsx +10 -5
- package/src/forms-page/forms-table/FormsTable.tsx +11 -5
- package/src/forms-page/forms-table/styles.scss +4 -5
- package/src/forms-page/styles.scss +3 -5
- package/src/group-form-entry-workflow/GroupFormEntryWorkflow.tsx +12 -399
- package/src/group-form-entry-workflow/GroupSessionWorkspace.tsx +238 -0
- package/src/group-form-entry-workflow/SessionDetailsForm.tsx +177 -0
- package/src/group-form-entry-workflow/SessionMetaWorkspace.tsx +107 -0
- package/src/group-form-entry-workflow/attendance-table/AttendanceTable.tsx +144 -0
- package/src/group-form-entry-workflow/attendance-table/index.ts +1 -0
- package/src/group-form-entry-workflow/configurable-questions/ConfigurableQuestionsSection.tsx +47 -0
- package/src/group-form-entry-workflow/group-display-header/GroupDisplayHeader.tsx +1 -9
- package/src/group-form-entry-workflow/group-display-header/styles.scss +20 -20
- package/src/group-form-entry-workflow/group-search/CompactGroupSearch.tsx +1 -1
- package/src/group-form-entry-workflow/group-search/GroupSearch.tsx +1 -1
- package/src/group-form-entry-workflow/group-search/compact-group-result.scss +16 -17
- package/src/group-form-entry-workflow/group-search/compact-group-search.scss +7 -8
- package/src/group-form-entry-workflow/group-search/group-search.scss +20 -23
- package/src/group-form-entry-workflow/group-search-header/GroupSearchHeader.tsx +36 -6
- package/src/group-form-entry-workflow/group-search-header/styles.scss +8 -8
- package/src/group-form-entry-workflow/styles.scss +15 -17
- package/src/hooks/index.ts +8 -1
- package/src/hooks/useForm.ts +73 -0
- package/src/hooks/useGetAllForms.ts +3 -2
- package/src/hooks/useGetEncounter.ts +2 -2
- package/src/hooks/useGetPatient.ts +1 -1
- package/src/hooks/useGetPatients.ts +34 -0
- package/src/hooks/useGetSystemSetting.ts +38 -0
- package/src/hooks/usePostEndpoint.ts +10 -4
- package/src/hooks/useSearchEndpoint.ts +14 -8
- package/src/hooks/useStartVisit.ts +93 -0
- package/src/index.ts +13 -65
- package/src/patient-card/styles.scss +3 -4
- package/src/routes.json +24 -0
- package/src/types.ts +20 -0
- package/tools/i18next-parser.config.js +93 -0
- package/translations/am.json +75 -0
- package/translations/ar.json +75 -0
- package/translations/en.json +32 -11
- package/translations/es.json +75 -0
- package/translations/fr.json +75 -0
- package/translations/he.json +75 -0
- package/translations/km.json +75 -0
- package/turbo.json +18 -0
- package/dist/247.js +0 -1
- package/dist/255.js +0 -1
- package/dist/294.js +0 -2
- package/dist/32.js +0 -1
- package/dist/327.js +0 -1
- package/dist/403.js +0 -2
- package/dist/403.js.LICENSE.txt +0 -14
- package/dist/553.js +0 -2
- package/dist/553.js.LICENSE.txt +0 -14
- package/dist/569.js +0 -2
- package/dist/574.js +0 -1
- package/dist/595.js +0 -2
- package/dist/595.js.LICENSE.txt +0 -1
- package/dist/617.js +0 -1
- package/dist/68.js +0 -2
- package/dist/776.js +0 -1
- package/dist/804.js +0 -1
- package/dist/820.js +0 -1
- package/dist/906.js +0 -1
- package/dist/935.js +0 -2
- package/dist/openmrs-esm-fast-data-entry-app.old +0 -1
- package/src/declarations.d.tsx +0 -2
- /package/dist/{294.js.LICENSE.txt → 540.js.LICENSE.txt} +0 -0
- /package/dist/{935.js.LICENSE.txt → 961.js.LICENSE.txt} +0 -0
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
@use '@carbon/
|
|
3
|
-
@use '@carbon/
|
|
4
|
-
@import '~@openmrs/esm-styleguide/src/vars';
|
|
1
|
+
@use '@carbon/colors';
|
|
2
|
+
@use '@carbon/layout';
|
|
3
|
+
@use '@carbon/type';
|
|
5
4
|
|
|
6
5
|
.patientSearchBar {
|
|
7
6
|
width: 50vw;
|
|
@@ -11,11 +10,11 @@
|
|
|
11
10
|
.floatingSearchResultsContainer {
|
|
12
11
|
position: absolute;
|
|
13
12
|
overflow-y: auto;
|
|
14
|
-
box-shadow: 0
|
|
13
|
+
box-shadow: 0 layout.$spacing-03 layout.$spacing-05 colors.$gray-20;
|
|
15
14
|
z-index: 99;
|
|
16
|
-
border: 0 1px 1px 1px solid
|
|
15
|
+
border: 0 1px 1px 1px solid colors.$gray-20;
|
|
17
16
|
width: 100%;
|
|
18
|
-
background-color:
|
|
17
|
+
background-color: colors.$white-0;
|
|
19
18
|
}
|
|
20
19
|
|
|
21
20
|
.searchArea {
|
|
@@ -23,7 +22,7 @@
|
|
|
23
22
|
display: flex;
|
|
24
23
|
justify-content: center;
|
|
25
24
|
align-items: center;
|
|
26
|
-
border: 1px solid
|
|
25
|
+
border: 1px solid colors.$gray-50;
|
|
27
26
|
}
|
|
28
27
|
|
|
29
28
|
.patientSearchInput {
|
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
@use '@carbon/
|
|
2
|
-
@use '@carbon/
|
|
3
|
-
@
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
@use '@carbon/colors';
|
|
2
|
+
@use '@carbon/layout';
|
|
3
|
+
@use '@carbon/type';
|
|
6
4
|
|
|
7
5
|
.searchResultsContainer {
|
|
8
6
|
width: 100%;
|
|
9
|
-
background-color:
|
|
7
|
+
background-color: colors.$white-0;
|
|
10
8
|
|
|
11
9
|
a {
|
|
12
10
|
text-decoration: none;
|
|
13
11
|
@include type.type-style('heading-02');
|
|
14
|
-
color:
|
|
12
|
+
color: colors.$gray-70;
|
|
15
13
|
margin: 0rem;
|
|
16
14
|
}
|
|
17
15
|
}
|
|
@@ -22,7 +20,7 @@
|
|
|
22
20
|
|
|
23
21
|
:global(.omrs-breakpoint-gt-tablet) .searchResultsContainer {
|
|
24
22
|
padding: 0;
|
|
25
|
-
top:
|
|
23
|
+
top: layout.$spacing-09;
|
|
26
24
|
}
|
|
27
25
|
|
|
28
26
|
.searchResults {
|
|
@@ -30,7 +28,6 @@
|
|
|
30
28
|
}
|
|
31
29
|
|
|
32
30
|
|
|
33
|
-
|
|
34
31
|
.searchTerm {
|
|
35
32
|
@include type.type-style('heading-03');
|
|
36
33
|
margin-top: 0.375rem;
|
|
@@ -38,9 +35,9 @@
|
|
|
38
35
|
|
|
39
36
|
.resultsText {
|
|
40
37
|
@include type.type-style('label-01');
|
|
41
|
-
color:
|
|
42
|
-
line-height:
|
|
43
|
-
margin:
|
|
38
|
+
color: colors.$gray-70;
|
|
39
|
+
line-height: layout.$spacing-05;
|
|
40
|
+
margin: layout.$spacing-03 layout.$spacing-05;
|
|
44
41
|
}
|
|
45
42
|
|
|
46
43
|
.helperText {
|
|
@@ -50,46 +47,46 @@
|
|
|
50
47
|
|
|
51
48
|
.emptyResultText {
|
|
52
49
|
@include type.type-style('heading-compact-01');
|
|
53
|
-
color:
|
|
54
|
-
margin-top:
|
|
50
|
+
color: colors.$gray-70;
|
|
51
|
+
margin-top: layout.$spacing-05;
|
|
55
52
|
margin-bottom: 0.313rem;
|
|
56
53
|
}
|
|
57
54
|
|
|
58
55
|
.actionText {
|
|
59
56
|
@include type.type-style('body-01');
|
|
60
|
-
color:
|
|
57
|
+
color: colors.$gray-70;
|
|
61
58
|
}
|
|
62
59
|
|
|
63
60
|
.pagination {
|
|
64
61
|
display: flex;
|
|
65
62
|
justify-content: space-evenly;
|
|
66
|
-
padding: 4.688rem 0
|
|
63
|
+
padding: 4.688rem 0 layout.$spacing-06;
|
|
67
64
|
}
|
|
68
65
|
|
|
69
66
|
.emptySearchResultsTile {
|
|
70
67
|
text-align: center;
|
|
71
|
-
margin-top:
|
|
72
|
-
padding:
|
|
68
|
+
margin-top: layout.$spacing-05;
|
|
69
|
+
padding: layout.$spacing-09 0rem;
|
|
73
70
|
}
|
|
74
71
|
|
|
75
72
|
:global(.omrs-breakpoint-gt-tablet) .emptySearchResultsTile {
|
|
76
|
-
margin:
|
|
73
|
+
margin: layout.$spacing-05;
|
|
77
74
|
}
|
|
78
75
|
|
|
79
76
|
.errorMessage {
|
|
80
77
|
@include type.type-style('heading-compact-02');
|
|
81
78
|
margin-top: 2.25rem;
|
|
82
|
-
margin-bottom:
|
|
79
|
+
margin-bottom: layout.$spacing-03;
|
|
83
80
|
}
|
|
84
81
|
|
|
85
82
|
.errorCopy {
|
|
86
|
-
margin-bottom:
|
|
83
|
+
margin-bottom: layout.$spacing-03;
|
|
87
84
|
@include type.type-style('body-01');
|
|
88
|
-
color:
|
|
85
|
+
color: colors.$gray-70;
|
|
89
86
|
}
|
|
90
87
|
|
|
91
88
|
.lastItem {
|
|
92
|
-
padding:
|
|
89
|
+
padding: layout.$spacing-05;
|
|
93
90
|
display: flex;
|
|
94
91
|
justify-content: center;
|
|
95
92
|
align-items: center;
|
|
@@ -1,22 +1,40 @@
|
|
|
1
|
-
import { Close } from "@carbon/react/icons";
|
|
1
|
+
import { Close, Add } from "@carbon/react/icons";
|
|
2
2
|
import { Button } from "@carbon/react";
|
|
3
|
-
import React, { useContext } from "react";
|
|
3
|
+
import React, { useCallback, useContext, useState } from "react";
|
|
4
4
|
import GroupFormWorkflowContext from "../../context/GroupFormWorkflowContext";
|
|
5
5
|
import styles from "./styles.scss";
|
|
6
6
|
import { useTranslation } from "react-i18next";
|
|
7
7
|
import CompactGroupSearch from "../group-search/CompactGroupSearch";
|
|
8
8
|
import AddGroupModal from "../../add-group-modal/AddGroupModal";
|
|
9
|
-
import { navigate } from "@openmrs/esm-framework";
|
|
10
9
|
|
|
11
10
|
const GroupSearchHeader = () => {
|
|
12
11
|
const { t } = useTranslation();
|
|
13
12
|
const { activeGroupUuid, setGroup, destroySession } = useContext(
|
|
14
13
|
GroupFormWorkflowContext
|
|
15
14
|
);
|
|
15
|
+
const [isOpen, setOpen] = useState(false);
|
|
16
16
|
const handleSelectGroup = (group) => {
|
|
17
|
+
group.cohortMembers.sort((a, b) => {
|
|
18
|
+
let aName = a?.patient?.person?.names?.[0]?.display;
|
|
19
|
+
let bName = b?.patient?.person?.names?.[0]?.display;
|
|
20
|
+
return aName.localeCompare(bName, undefined, {sensitivity: "base"});
|
|
21
|
+
}
|
|
22
|
+
);
|
|
17
23
|
setGroup(group);
|
|
18
24
|
};
|
|
19
25
|
|
|
26
|
+
const handleCancel = useCallback(() => {
|
|
27
|
+
setOpen(false);
|
|
28
|
+
}, []);
|
|
29
|
+
|
|
30
|
+
const onPostSubmit = useCallback(() => {
|
|
31
|
+
setOpen(false);
|
|
32
|
+
}, []);
|
|
33
|
+
|
|
34
|
+
const handleOpenClick = useCallback(() => {
|
|
35
|
+
setOpen(true);
|
|
36
|
+
}, []);
|
|
37
|
+
|
|
20
38
|
if (activeGroupUuid) return null;
|
|
21
39
|
|
|
22
40
|
return (
|
|
@@ -27,7 +45,21 @@ const GroupSearchHeader = () => {
|
|
|
27
45
|
</span>
|
|
28
46
|
<span className={styles.padded}>{t("or", "or")}</span>
|
|
29
47
|
<span>
|
|
30
|
-
<
|
|
48
|
+
<Button
|
|
49
|
+
onClick={handleOpenClick}
|
|
50
|
+
renderIcon={Add}
|
|
51
|
+
iconDescription="Add"
|
|
52
|
+
>
|
|
53
|
+
{t("createNewGroup", "Create New Group")}
|
|
54
|
+
</Button>
|
|
55
|
+
<AddGroupModal
|
|
56
|
+
{...{
|
|
57
|
+
isCreate: true,
|
|
58
|
+
isOpen: isOpen,
|
|
59
|
+
onPostCancel: handleCancel,
|
|
60
|
+
onPostSubmit: onPostSubmit,
|
|
61
|
+
}}
|
|
62
|
+
/>
|
|
31
63
|
</span>
|
|
32
64
|
<span style={{ flexGrow: 1 }} />
|
|
33
65
|
<span>
|
|
@@ -35,8 +67,6 @@ const GroupSearchHeader = () => {
|
|
|
35
67
|
kind="ghost"
|
|
36
68
|
onClick={() => {
|
|
37
69
|
destroySession();
|
|
38
|
-
// eslint-disable-next-line
|
|
39
|
-
navigate({ to: "${openmrsSpaBase}/forms" });
|
|
40
70
|
}}
|
|
41
71
|
>
|
|
42
72
|
{t("cancel", "Cancel")} <Close size={20} />
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
@use '@carbon/
|
|
2
|
-
@
|
|
1
|
+
@use '@carbon/colors';
|
|
2
|
+
@use '@carbon/layout';
|
|
3
3
|
|
|
4
4
|
.searchHeaderContainer {
|
|
5
|
-
height:
|
|
5
|
+
height: layout.$spacing-11;
|
|
6
6
|
display: flex;
|
|
7
7
|
align-items: center;
|
|
8
|
-
background-color:
|
|
9
|
-
border-top: 0.0125rem solid
|
|
10
|
-
border-bottom: 0.0125rem solid
|
|
11
|
-
padding: 0
|
|
8
|
+
background-color: colors.$white-0;
|
|
9
|
+
border-top: 0.0125rem solid colors.$gray-20;
|
|
10
|
+
border-bottom: 0.0125rem solid colors.$gray-20;
|
|
11
|
+
padding: 0 layout.$spacing-05;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
.searchBarWrapper {
|
|
@@ -16,5 +16,5 @@
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
.padded {
|
|
19
|
-
padding:
|
|
19
|
+
padding: layout.$spacing-05;
|
|
20
20
|
}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
@use '@carbon/styles/scss/spacing';
|
|
2
1
|
@use '@carbon/colors';
|
|
3
|
-
@use '@carbon/
|
|
4
|
-
@
|
|
5
|
-
|
|
2
|
+
@use '@carbon/layout';
|
|
3
|
+
@use '@carbon/type';
|
|
6
4
|
|
|
7
5
|
.breadcrumbsContainer > div > div > nav {
|
|
8
|
-
background-color:
|
|
9
|
-
padding:
|
|
10
|
-
height:
|
|
6
|
+
background-color: colors.$white-0;
|
|
7
|
+
padding: layout.$spacing-04 layout.$spacing-05;
|
|
8
|
+
height: layout.$spacing-08;
|
|
11
9
|
}
|
|
12
10
|
|
|
13
11
|
.workspaceWrapper {
|
|
@@ -26,26 +24,27 @@
|
|
|
26
24
|
:global(.omrs-breakpoint-lt-small-desktop) .workspace {
|
|
27
25
|
// there's only so much we can do here. Currenlty the design does not support tablet
|
|
28
26
|
width: 100vw;
|
|
29
|
-
padding: 0
|
|
27
|
+
padding: 0 layout.$spacing-04;
|
|
30
28
|
}
|
|
31
29
|
|
|
32
30
|
.selectPatientMessage {
|
|
33
|
-
@include type.type-style('
|
|
34
|
-
margin:
|
|
31
|
+
@include type.type-style('heading-03');
|
|
32
|
+
margin: layout.$spacing-07;
|
|
35
33
|
text-align: center;
|
|
36
34
|
}
|
|
37
35
|
|
|
38
36
|
.formMainContent {
|
|
39
37
|
display: flex;
|
|
40
38
|
text-align: center;
|
|
41
|
-
margin-top:
|
|
42
|
-
column-gap:
|
|
39
|
+
margin-top: layout.$spacing-05;
|
|
40
|
+
column-gap: layout.$spacing-05;
|
|
43
41
|
}
|
|
44
42
|
|
|
45
43
|
.formContainer {
|
|
46
44
|
flex-grow: 1;
|
|
47
45
|
max-height: calc(100vh - 14rem);
|
|
48
46
|
overflow-y: scroll;
|
|
47
|
+
text-align: left;
|
|
49
48
|
}
|
|
50
49
|
|
|
51
50
|
.formContainer :global(.cds--form-item) :global(.question-area) {
|
|
@@ -53,23 +52,23 @@
|
|
|
53
52
|
}
|
|
54
53
|
|
|
55
54
|
.rightPanel {
|
|
56
|
-
width: 13rem;
|
|
55
|
+
min-width: 13rem;
|
|
57
56
|
text-align: left;
|
|
58
57
|
overflow-y: scroll;
|
|
59
58
|
display: flex;
|
|
60
59
|
flex-direction: column;
|
|
61
|
-
row-gap:
|
|
60
|
+
row-gap: layout.$spacing-05;
|
|
62
61
|
}
|
|
63
62
|
|
|
64
63
|
.patientCardsSection {
|
|
65
|
-
margin:
|
|
64
|
+
margin: layout.$spacing-05 0;
|
|
66
65
|
border-bottom: 1px solid colors.$gray-10;
|
|
67
66
|
}
|
|
68
67
|
|
|
69
68
|
.rightPanelActionButtons {
|
|
70
69
|
display: flex;
|
|
71
70
|
flex-direction: column;
|
|
72
|
-
row-gap:
|
|
71
|
+
row-gap: layout.$spacing-03;
|
|
73
72
|
& button {
|
|
74
73
|
width: 100%;
|
|
75
74
|
text-decoration: "none";
|
|
@@ -89,7 +88,6 @@
|
|
|
89
88
|
width: 500px;
|
|
90
89
|
}
|
|
91
90
|
|
|
92
|
-
|
|
93
91
|
.formError {
|
|
94
92
|
@include type.type-style("helper-text-02");
|
|
95
93
|
color: colors.$red-60;
|
package/src/hooks/index.ts
CHANGED
|
@@ -2,6 +2,13 @@ import useGetAllForms from "./useGetAllForms";
|
|
|
2
2
|
import useGetPatient from "./useGetPatient";
|
|
3
3
|
import useFormState from "./useFormState";
|
|
4
4
|
import useGetEncounter from "./useGetEncounter";
|
|
5
|
+
import useForm from "./useForm";
|
|
5
6
|
|
|
6
|
-
export {
|
|
7
|
+
export {
|
|
8
|
+
useGetAllForms,
|
|
9
|
+
useGetPatient,
|
|
10
|
+
useFormState,
|
|
11
|
+
useGetEncounter,
|
|
12
|
+
useForm,
|
|
13
|
+
};
|
|
7
14
|
export * from "./usePostEndpoint";
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type FetchResponse,
|
|
3
|
+
openmrsFetch,
|
|
4
|
+
restBaseUrl,
|
|
5
|
+
} from "@openmrs/esm-framework";
|
|
6
|
+
import useSWR from "swr";
|
|
7
|
+
import { type SpecificQuestion, type SpecificQuestionConfig } from "../types";
|
|
8
|
+
import { useMemo } from "react";
|
|
9
|
+
|
|
10
|
+
const formUrl = `${restBaseUrl}/o3/forms`;
|
|
11
|
+
|
|
12
|
+
export const useSpecificQuestions = (
|
|
13
|
+
formUuid: string,
|
|
14
|
+
specificQuestionConfig: Array<SpecificQuestionConfig>
|
|
15
|
+
) => {
|
|
16
|
+
const specificQuestionsToLoad = useMemo(
|
|
17
|
+
() => getQuestionIdsByFormId(formUuid, specificQuestionConfig),
|
|
18
|
+
[formUuid, specificQuestionConfig]
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
const { data, error } = useSWR<FetchResponse, Error>(
|
|
22
|
+
specificQuestionsToLoad ? `${formUrl}/${formUuid}` : null,
|
|
23
|
+
openmrsFetch
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
const specificQuestions = getQuestionsByIds(
|
|
27
|
+
specificQuestionsToLoad,
|
|
28
|
+
data?.data
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
return {
|
|
32
|
+
questions: specificQuestions || null,
|
|
33
|
+
isError: error,
|
|
34
|
+
isLoading: !data && !error,
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
function getQuestionIdsByFormId(
|
|
39
|
+
formUuid: string,
|
|
40
|
+
specificQuestionConfig: Array<SpecificQuestionConfig>
|
|
41
|
+
) {
|
|
42
|
+
const matchingQuestions = specificQuestionConfig.filter((question) =>
|
|
43
|
+
question.forms.includes(formUuid)
|
|
44
|
+
);
|
|
45
|
+
return matchingQuestions.map((question) => question.questionId);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function getQuestionsByIds(questionIds, formSchema): Array<SpecificQuestion> {
|
|
49
|
+
if (!formSchema || questionIds.lenght <= 0) {
|
|
50
|
+
return [];
|
|
51
|
+
}
|
|
52
|
+
const conceptLabels = formSchema.conceptReferences;
|
|
53
|
+
return formSchema.pages.flatMap((page) =>
|
|
54
|
+
page.sections.flatMap((section) =>
|
|
55
|
+
section.questions
|
|
56
|
+
.filter((question) => questionIds.includes(question.id))
|
|
57
|
+
.map((question) => ({
|
|
58
|
+
question: {
|
|
59
|
+
display:
|
|
60
|
+
question.label ??
|
|
61
|
+
conceptLabels[question.questionOptions.concept]?.display,
|
|
62
|
+
id: question.id,
|
|
63
|
+
},
|
|
64
|
+
answers: (question.questionOptions.answers ?? []).map((answer) => ({
|
|
65
|
+
value: answer.concept,
|
|
66
|
+
display: answer.label ?? conceptLabels[answer.concept]?.display,
|
|
67
|
+
})),
|
|
68
|
+
}))
|
|
69
|
+
)
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export default useSpecificQuestions;
|
|
@@ -2,14 +2,15 @@ import {
|
|
|
2
2
|
openmrsFetch,
|
|
3
3
|
userHasAccess,
|
|
4
4
|
useSession,
|
|
5
|
+
restBaseUrl,
|
|
5
6
|
} from "@openmrs/esm-framework";
|
|
6
7
|
import useSWR from "swr";
|
|
7
8
|
|
|
8
9
|
const customFormRepresentation =
|
|
9
10
|
"(uuid,name,display,encounterType:(uuid,name,viewPrivilege,editPrivilege),version,published,retired,resources:(uuid,name,dataType,valueReference))";
|
|
10
11
|
|
|
11
|
-
const formEncounterUrl =
|
|
12
|
-
const formEncounterUrlPoc =
|
|
12
|
+
const formEncounterUrl = `${restBaseUrl}/form?v=custom:${customFormRepresentation}`;
|
|
13
|
+
const formEncounterUrlPoc = `${restBaseUrl}/form?v=custom:${customFormRepresentation}&q=poc`;
|
|
13
14
|
|
|
14
15
|
export function useGetAllForms(cachedOfflineFormsOnly = false) {
|
|
15
16
|
const session = useSession();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { openmrsFetch } from "@openmrs/esm-framework";
|
|
1
|
+
import { openmrsFetch, restBaseUrl } from "@openmrs/esm-framework";
|
|
2
2
|
import useSWR from "swr";
|
|
3
3
|
|
|
4
|
-
const encounterUrl =
|
|
4
|
+
const encounterUrl = `${restBaseUrl}/encounter/`;
|
|
5
5
|
|
|
6
6
|
const useGetEncounter = (encounterUuid) => {
|
|
7
7
|
const url = `${encounterUrl}${encounterUuid}`;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { fetchCurrentPatient } from "@openmrs/esm-framework";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
|
|
4
|
+
const useGetPatients = (patientUuids) => {
|
|
5
|
+
const [patients, setPatients] = useState([]);
|
|
6
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
7
|
+
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
if (!patientUuids || patientUuids.length === 0) {
|
|
10
|
+
setPatients([]);
|
|
11
|
+
setIsLoading(false);
|
|
12
|
+
} else {
|
|
13
|
+
getPatients(patientUuids);
|
|
14
|
+
}
|
|
15
|
+
}, [patientUuids]);
|
|
16
|
+
|
|
17
|
+
const getPatients = async (uuids) => {
|
|
18
|
+
try {
|
|
19
|
+
setIsLoading(true);
|
|
20
|
+
const results = await Promise.all(
|
|
21
|
+
uuids.map(async (uuid) => await fetchCurrentPatient(uuid))
|
|
22
|
+
);
|
|
23
|
+
setPatients(results);
|
|
24
|
+
setIsLoading(false);
|
|
25
|
+
} catch (error) {
|
|
26
|
+
console.error("Error fetching patients:", error);
|
|
27
|
+
setIsLoading(false);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
return { patients, isLoading };
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export default useGetPatients;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { useCallback, useEffect, useState } from "react";
|
|
2
|
+
import { openmrsFetch, restBaseUrl } from "@openmrs/esm-framework";
|
|
3
|
+
|
|
4
|
+
const useGetSystemSetting = (settingId) => {
|
|
5
|
+
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
6
|
+
const [result, setResult] = useState(null);
|
|
7
|
+
const [error, setError] = useState(null);
|
|
8
|
+
|
|
9
|
+
const onResult = useCallback((result) => {
|
|
10
|
+
setIsSubmitting(false);
|
|
11
|
+
setError(false);
|
|
12
|
+
setResult(result);
|
|
13
|
+
}, []);
|
|
14
|
+
|
|
15
|
+
const onError = useCallback((error) => {
|
|
16
|
+
setIsSubmitting(false);
|
|
17
|
+
setResult(null);
|
|
18
|
+
setError(error);
|
|
19
|
+
}, []);
|
|
20
|
+
|
|
21
|
+
const getSetting = useCallback(() => {
|
|
22
|
+
openmrsFetch(`${restBaseUrl}/systemsetting?q=${settingId}&v=default`)
|
|
23
|
+
.then(onResult)
|
|
24
|
+
.catch(onError);
|
|
25
|
+
}, [onError, onResult, settingId]);
|
|
26
|
+
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
getSetting();
|
|
29
|
+
}, [getSetting]);
|
|
30
|
+
|
|
31
|
+
return {
|
|
32
|
+
result,
|
|
33
|
+
error,
|
|
34
|
+
isSubmitting,
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export default useGetSystemSetting;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { openmrsFetch } from "@openmrs/esm-framework";
|
|
1
|
+
import { openmrsFetch, restBaseUrl } from "@openmrs/esm-framework";
|
|
2
2
|
import { useCallback, useState } from "react";
|
|
3
3
|
|
|
4
4
|
const usePostEndpoint = ({ endpointUrl }) => {
|
|
@@ -31,7 +31,13 @@ const usePostEndpoint = ({ endpointUrl }) => {
|
|
|
31
31
|
const post = useCallback(
|
|
32
32
|
async (data) => {
|
|
33
33
|
setSubmissionInProgress(true);
|
|
34
|
-
|
|
34
|
+
|
|
35
|
+
let path = endpointUrl;
|
|
36
|
+
if (data.uuid) {
|
|
37
|
+
path += "/" + data.uuid;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return openmrsFetch(path, {
|
|
35
41
|
method: "POST",
|
|
36
42
|
headers: {
|
|
37
43
|
"Content-Type": "application/json",
|
|
@@ -60,11 +66,11 @@ const usePostEndpoint = ({ endpointUrl }) => {
|
|
|
60
66
|
};
|
|
61
67
|
|
|
62
68
|
const usePostVisit = () => {
|
|
63
|
-
return usePostEndpoint({ endpointUrl:
|
|
69
|
+
return usePostEndpoint({ endpointUrl: `${restBaseUrl}/visit` });
|
|
64
70
|
};
|
|
65
71
|
|
|
66
72
|
const usePostCohort = () => {
|
|
67
|
-
return usePostEndpoint({ endpointUrl:
|
|
73
|
+
return usePostEndpoint({ endpointUrl: `${restBaseUrl}/cohortm/cohort` });
|
|
68
74
|
};
|
|
69
75
|
|
|
70
76
|
export { usePostEndpoint, usePostVisit, usePostCohort };
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
openmrsFetch,
|
|
3
|
+
type FetchResponse,
|
|
4
|
+
restBaseUrl,
|
|
5
|
+
} from "@openmrs/esm-framework";
|
|
2
6
|
import { useCallback, useMemo } from "react";
|
|
3
7
|
import useSWRInfinite from "swr/infinite";
|
|
4
8
|
|
|
@@ -11,12 +15,14 @@ export interface SearchResponse {
|
|
|
11
15
|
currentPage: number;
|
|
12
16
|
totalResults: number;
|
|
13
17
|
setPage: (size: number | ((_size: number) => number)) => Promise<
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
Array<
|
|
19
|
+
FetchResponse<{
|
|
20
|
+
results: Array<Record<string, unknown>>;
|
|
21
|
+
links: Array<{
|
|
22
|
+
rel: "prev" | "next";
|
|
23
|
+
}>;
|
|
24
|
+
}>
|
|
25
|
+
>
|
|
20
26
|
>;
|
|
21
27
|
}
|
|
22
28
|
|
|
@@ -111,7 +117,7 @@ const useSearchCohortInfinite = ({
|
|
|
111
117
|
...props
|
|
112
118
|
}: SearchInfiniteProps): SearchResponse => {
|
|
113
119
|
return useSearchEndpointInfinite({
|
|
114
|
-
baseUrl:
|
|
120
|
+
baseUrl: `${restBaseUrl}/cohortm/cohort`,
|
|
115
121
|
resultsToFetch: 10,
|
|
116
122
|
...props,
|
|
117
123
|
});
|