@openmrs/esm-fast-data-entry-app 1.0.1-pre.17 → 1.0.1-pre.176

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 (176) hide show
  1. package/README.md +21 -2
  2. package/__mocks__/react-i18next.js +9 -14
  3. package/dist/101.js +1 -0
  4. package/dist/101.js.map +1 -0
  5. package/dist/132.js +1 -1
  6. package/dist/143.js +1 -0
  7. package/dist/143.js.map +1 -0
  8. package/dist/188.js +1 -0
  9. package/dist/188.js.map +1 -0
  10. package/dist/197.js +1 -0
  11. package/dist/219.js +1 -0
  12. package/dist/219.js.map +1 -0
  13. package/dist/221.js +1 -0
  14. package/dist/221.js.map +1 -0
  15. package/dist/259.js +1 -0
  16. package/dist/259.js.map +1 -0
  17. package/dist/29.js +2 -0
  18. package/dist/29.js.LICENSE.txt +3 -0
  19. package/dist/29.js.map +1 -0
  20. package/dist/300.js +1 -0
  21. package/dist/31.js +2 -0
  22. package/dist/{569.js.LICENSE.txt → 31.js.LICENSE.txt} +9 -6
  23. package/dist/31.js.map +1 -0
  24. package/dist/326.js +1 -0
  25. package/dist/326.js.map +1 -0
  26. package/dist/335.js +1 -0
  27. package/dist/367.js +1 -0
  28. package/dist/367.js.map +1 -0
  29. package/dist/480.js +1 -0
  30. package/dist/491.js +1 -0
  31. package/dist/491.js.map +1 -0
  32. package/dist/540.js +2 -0
  33. package/dist/540.js.map +1 -0
  34. package/dist/55.js +1 -0
  35. package/dist/564.js +1 -0
  36. package/dist/564.js.map +1 -0
  37. package/dist/602.js +1 -0
  38. package/dist/602.js.map +1 -0
  39. package/dist/626.js +2 -0
  40. package/dist/626.js.LICENSE.txt +9 -0
  41. package/dist/626.js.map +1 -0
  42. package/dist/652.js +1 -0
  43. package/dist/685.js +1 -0
  44. package/dist/685.js.map +1 -0
  45. package/dist/773.js +2 -0
  46. package/dist/{68.js.LICENSE.txt → 773.js.LICENSE.txt} +13 -2
  47. package/dist/773.js.map +1 -0
  48. package/dist/91.js +1 -0
  49. package/dist/91.js.map +1 -0
  50. package/dist/961.js +2 -0
  51. package/dist/961.js.map +1 -0
  52. package/dist/99.js +1 -0
  53. package/dist/99.js.map +1 -0
  54. package/dist/main.js +1 -1
  55. package/dist/main.js.map +1 -0
  56. package/dist/openmrs-esm-fast-data-entry-app.js +1 -1
  57. package/dist/openmrs-esm-fast-data-entry-app.js.buildmanifest.json +403 -136
  58. package/dist/openmrs-esm-fast-data-entry-app.js.map +1 -0
  59. package/dist/routes.json +1 -0
  60. package/jest.config.json +2 -1
  61. package/package.json +41 -38
  62. package/prettier.config.js +8 -0
  63. package/src/CancelModal.tsx +42 -0
  64. package/src/CompleteModal.tsx +35 -0
  65. package/src/FormBootstrap.tsx +39 -11
  66. package/src/Root.tsx +7 -12
  67. package/src/add-group-modal/AddGroupModal.tsx +107 -120
  68. package/src/add-group-modal/styles.scss +7 -3
  69. package/src/config-schema.ts +77 -16
  70. package/src/constant.ts +1 -1
  71. package/src/context/FormWorkflowContext.tsx +31 -32
  72. package/src/context/FormWorkflowReducer.ts +53 -67
  73. package/src/context/GroupFormWorkflowContext.tsx +56 -44
  74. package/src/context/GroupFormWorkflowReducer.ts +177 -68
  75. package/src/declarations.d.ts +4 -0
  76. package/src/empty-state/EmptyDataIllustration.tsx +4 -16
  77. package/src/empty-state/EmptyState.tsx +8 -13
  78. package/src/empty-state/styles.scss +14 -14
  79. package/src/form-entry-workflow/FormEntryWorkflow.tsx +78 -124
  80. package/src/form-entry-workflow/form-review-card/FormReviewCard.tsx +7 -7
  81. package/src/form-entry-workflow/form-review-card/index.ts +1 -1
  82. package/src/form-entry-workflow/form-review-card/styles.scss +9 -11
  83. package/src/form-entry-workflow/index.ts +1 -1
  84. package/src/form-entry-workflow/patient-banner/PatientBanner.test.tsx +5 -5
  85. package/src/form-entry-workflow/patient-banner/PatientBanner.tsx +14 -27
  86. package/src/form-entry-workflow/patient-banner/index.ts +1 -1
  87. package/src/form-entry-workflow/patient-banner/styles.scss +11 -12
  88. package/src/form-entry-workflow/patient-search-header/PatientSearchHeader.tsx +19 -28
  89. package/src/form-entry-workflow/patient-search-header/index.ts +1 -1
  90. package/src/form-entry-workflow/patient-search-header/styles.scss +13 -10
  91. package/src/form-entry-workflow/styles.scss +13 -14
  92. package/src/form-entry-workflow/workflow-review/WorkflowReview.tsx +13 -11
  93. package/src/form-entry-workflow/workflow-review/index.ts +1 -1
  94. package/src/form-entry-workflow/workflow-review/styles.scss +0 -4
  95. package/src/forms-app-menu-link.tsx +4 -6
  96. package/src/forms-page/FormsPage.tsx +24 -47
  97. package/src/forms-page/forms-table/FormsTable.tsx +33 -47
  98. package/src/forms-page/forms-table/index.ts +1 -1
  99. package/src/forms-page/forms-table/styles.scss +4 -5
  100. package/src/forms-page/index.ts +1 -1
  101. package/src/forms-page/styles.scss +3 -5
  102. package/src/group-form-entry-workflow/GroupFormEntryWorkflow.tsx +15 -402
  103. package/src/group-form-entry-workflow/GroupSessionWorkspace.tsx +207 -0
  104. package/src/group-form-entry-workflow/SessionDetailsForm.tsx +154 -0
  105. package/src/group-form-entry-workflow/SessionMetaWorkspace.tsx +99 -0
  106. package/src/group-form-entry-workflow/attendance-table/AttendanceTable.tsx +130 -0
  107. package/src/group-form-entry-workflow/attendance-table/index.ts +1 -0
  108. package/src/group-form-entry-workflow/configurable-questions/ConfigurableQuestionsSection.tsx +41 -0
  109. package/src/group-form-entry-workflow/group-display-header/GroupDisplayHeader.test.tsx +5 -5
  110. package/src/group-form-entry-workflow/group-display-header/GroupDisplayHeader.tsx +14 -30
  111. package/src/group-form-entry-workflow/group-display-header/index.ts +1 -1
  112. package/src/group-form-entry-workflow/group-display-header/styles.scss +20 -20
  113. package/src/group-form-entry-workflow/group-search/CompactGroupResults.tsx +24 -35
  114. package/src/group-form-entry-workflow/group-search/CompactGroupSearch.tsx +13 -15
  115. package/src/group-form-entry-workflow/group-search/GroupSearch.tsx +22 -38
  116. package/src/group-form-entry-workflow/group-search/compact-group-result.scss +16 -17
  117. package/src/group-form-entry-workflow/group-search/compact-group-search.scss +7 -8
  118. package/src/group-form-entry-workflow/group-search/group-search.scss +20 -23
  119. package/src/group-form-entry-workflow/group-search-header/GroupSearchHeader.tsx +41 -18
  120. package/src/group-form-entry-workflow/group-search-header/index.ts +1 -1
  121. package/src/group-form-entry-workflow/group-search-header/styles.scss +8 -8
  122. package/src/group-form-entry-workflow/index.ts +1 -1
  123. package/src/group-form-entry-workflow/styles.scss +15 -17
  124. package/src/hooks/index.ts +7 -6
  125. package/src/hooks/useForm.ts +56 -0
  126. package/src/hooks/useFormState.ts +3 -3
  127. package/src/hooks/useGetAllForms.ts +7 -15
  128. package/src/hooks/useGetEncounter.ts +3 -3
  129. package/src/hooks/useGetPatient.ts +3 -3
  130. package/src/hooks/useGetPatients.ts +32 -0
  131. package/src/hooks/useGetSystemSetting.ts +36 -0
  132. package/src/hooks/useKeyPress.ts +5 -5
  133. package/src/hooks/usePostEndpoint.ts +16 -10
  134. package/src/hooks/useSearchEndpoint.ts +23 -40
  135. package/src/hooks/useStartVisit.ts +82 -0
  136. package/src/index.ts +12 -76
  137. package/src/patient-card/PatientCard.tsx +8 -20
  138. package/src/patient-card/index.ts +1 -1
  139. package/src/patient-card/styles.scss +3 -4
  140. package/src/routes.json +24 -0
  141. package/src/setup-tests.ts +1 -1
  142. package/src/types.ts +20 -0
  143. package/tools/i18next-parser.config.js +93 -0
  144. package/translations/am.json +75 -0
  145. package/translations/ar.json +75 -0
  146. package/translations/en.json +32 -11
  147. package/translations/es.json +75 -0
  148. package/translations/fr.json +75 -0
  149. package/translations/he.json +75 -0
  150. package/translations/km.json +75 -0
  151. package/turbo.json +18 -0
  152. package/webpack.config.js +1 -1
  153. package/dist/247.js +0 -1
  154. package/dist/255.js +0 -1
  155. package/dist/294.js +0 -2
  156. package/dist/32.js +0 -1
  157. package/dist/327.js +0 -1
  158. package/dist/403.js +0 -2
  159. package/dist/403.js.LICENSE.txt +0 -14
  160. package/dist/553.js +0 -2
  161. package/dist/553.js.LICENSE.txt +0 -14
  162. package/dist/569.js +0 -2
  163. package/dist/574.js +0 -1
  164. package/dist/595.js +0 -2
  165. package/dist/595.js.LICENSE.txt +0 -1
  166. package/dist/617.js +0 -1
  167. package/dist/68.js +0 -2
  168. package/dist/776.js +0 -1
  169. package/dist/804.js +0 -1
  170. package/dist/820.js +0 -1
  171. package/dist/906.js +0 -1
  172. package/dist/935.js +0 -2
  173. package/dist/openmrs-esm-fast-data-entry-app.old +0 -1
  174. package/src/declarations.d.tsx +0 -2
  175. /package/dist/{294.js.LICENSE.txt → 540.js.LICENSE.txt} +0 -0
  176. /package/dist/{935.js.LICENSE.txt → 961.js.LICENSE.txt} +0 -0
@@ -1,107 +1,22 @@
1
- import {
2
- ExtensionSlot,
3
- getGlobalStore,
4
- useStore,
5
- } from "@openmrs/esm-framework";
6
- import {
7
- Button,
8
- ComposedModal,
9
- ModalBody,
10
- ModalFooter,
11
- ModalHeader,
12
- } from "@carbon/react";
13
- import React, { useContext, useState } from "react";
14
- import { useNavigate } from "react-router-dom";
15
- import FormBootstrap from "../FormBootstrap";
16
- import PatientCard from "../patient-card/PatientCard";
17
- import styles from "./styles.scss";
18
- import PatientSearchHeader from "./patient-search-header";
19
- import { useTranslation } from "react-i18next";
20
- import FormWorkflowContext, {
21
- FormWorkflowProvider,
22
- } from "../context/FormWorkflowContext";
23
- import WorkflowReview from "./workflow-review";
24
- import PatientBanner from "./patient-banner";
25
-
26
- const formStore = getGlobalStore("ampath-form-state");
27
-
28
- const CancelModal = ({ open, setOpen }) => {
29
- const { destroySession, closeSession } = useContext(FormWorkflowContext);
30
- const { t } = useTranslation();
31
- const navigate = useNavigate();
32
-
33
- const discard = async () => {
34
- await destroySession();
35
- setOpen(false);
36
- navigate("../");
37
- };
38
-
39
- const saveAndClose = async () => {
40
- await closeSession();
41
- setOpen(false);
42
- navigate("../");
43
- };
44
-
45
- return (
46
- <ComposedModal open={open}>
47
- <ModalHeader>{t("areYouSure", "Are you sure?")}</ModalHeader>
48
- <ModalBody>
49
- {t(
50
- "cancelExplanation",
51
- "You will lose any unsaved changes on the current form. Do you want to discard the current session?"
52
- )}
53
- </ModalBody>
54
- <ModalFooter>
55
- <Button kind="secondary" onClick={() => setOpen(false)}>
56
- {t("cancel", "Cancel")}
57
- </Button>
58
- <Button kind="danger" onClick={discard}>
59
- {t("discard", "Discard")}
60
- </Button>
61
- <Button kind="primary" onClick={saveAndClose}>
62
- {t("saveSession", "Save Session")}
63
- </Button>
64
- </ModalFooter>
65
- </ComposedModal>
66
- );
67
- };
68
-
69
- const CompleteModal = ({ open, setOpen }) => {
70
- const { submitForComplete } = useContext(FormWorkflowContext);
71
- const { t } = useTranslation();
72
-
73
- const completeSession = () => {
74
- submitForComplete();
75
- setOpen(false);
76
- };
77
-
78
- return (
79
- <ComposedModal open={open}>
80
- <ModalHeader>{t("areYouSure", "Are you sure?")}</ModalHeader>
81
- <ModalBody>
82
- {t(
83
- "saveExplanation",
84
- "Do you want to save the current form and exit the workflow?"
85
- )}
86
- </ModalBody>
87
- <ModalFooter>
88
- <Button kind="secondary" onClick={() => setOpen(false)}>
89
- {t("cancel", "Cancel")}
90
- </Button>
91
- <Button kind="primary" onClick={completeSession}>
92
- {t("complete", "Complete")}
93
- </Button>
94
- </ModalFooter>
95
- </ComposedModal>
96
- );
97
- };
1
+ import { ExtensionSlot, useSession } from '@openmrs/esm-framework';
2
+ import { Button } from '@carbon/react';
3
+ import React, { useCallback, useContext, useEffect, useState } from 'react';
4
+ import FormBootstrap from '../FormBootstrap';
5
+ import PatientCard from '../patient-card/PatientCard';
6
+ import styles from './styles.scss';
7
+ import PatientSearchHeader from './patient-search-header';
8
+ import { useTranslation } from 'react-i18next';
9
+ import { v4 as uuid } from 'uuid';
10
+ import FormWorkflowContext, { FormWorkflowProvider } from '../context/FormWorkflowContext';
11
+ import WorkflowReview from './workflow-review';
12
+ import PatientBanner from './patient-banner';
13
+ import CompleteModal from '../CompleteModal';
14
+ import CancelModal from '../CancelModal';
15
+ import useStartVisit from '../hooks/useStartVisit';
98
16
 
99
17
  const WorkflowNavigationButtons = () => {
100
- const { activeFormUuid, submitForNext, workflowState, destroySession } =
101
- useContext(FormWorkflowContext);
102
- const store = useStore(formStore);
103
- const formState = store[activeFormUuid];
104
- const navigationDisabled = formState !== "ready";
18
+ const context = useContext(FormWorkflowContext);
19
+ const { workflowState, destroySession } = context;
105
20
  const [cancelModalOpen, setCancelModalOpen] = useState(false);
106
21
  const [completeModalOpen, setCompleteModalOpen] = useState(false);
107
22
  const { t } = useTranslation();
@@ -111,29 +26,18 @@ const WorkflowNavigationButtons = () => {
111
26
  return (
112
27
  <>
113
28
  <div className={styles.rightPanelActionButtons}>
114
- <Button
115
- kind="primary"
116
- onClick={() => submitForNext()}
117
- disabled={navigationDisabled || workflowState === "NEW_PATIENT"}
118
- >
119
- {t("nextPatient", "Next Patient")}
120
- </Button>
121
29
  <Button
122
30
  kind="secondary"
123
- onClick={
124
- workflowState === "NEW_PATIENT"
125
- ? () => destroySession()
126
- : () => setCompleteModalOpen(true)
127
- }
31
+ onClick={workflowState === 'NEW_PATIENT' ? () => destroySession() : () => setCompleteModalOpen(true)}
128
32
  >
129
- {t("saveAndComplete", "Save & Complete")}
33
+ {t('saveAndComplete', 'Save & Complete')}
130
34
  </Button>
131
35
  <Button kind="tertiary" onClick={() => setCancelModalOpen(true)}>
132
- {t("cancel", "Cancel")}
36
+ {t('cancel', 'Cancel')}
133
37
  </Button>
134
38
  </div>
135
- <CancelModal open={cancelModalOpen} setOpen={setCancelModalOpen} />
136
- <CompleteModal open={completeModalOpen} setOpen={setCompleteModalOpen} />
39
+ <CancelModal open={cancelModalOpen} setOpen={setCancelModalOpen} context={context} />
40
+ <CompleteModal open={completeModalOpen} setOpen={setCompleteModalOpen} context={context} />
137
41
  </>
138
42
  );
139
43
  };
@@ -147,21 +51,70 @@ const FormWorkspace = () => {
147
51
  activeFormUuid,
148
52
  editEncounter,
149
53
  encounters,
54
+ singleSessionVisitTypeUuid,
150
55
  } = useContext(FormWorkflowContext);
151
56
  const { t } = useTranslation();
152
57
 
58
+ const [encounter, setEncounter] = useState(null);
59
+ const [visit, setVisit] = useState(null);
60
+ const { sessionLocation } = useSession();
61
+
62
+ const { updateEncounter, success: visitSaveSuccess } = useStartVisit({
63
+ showSuccessNotification: false,
64
+ showErrorNotification: true,
65
+ });
66
+
153
67
  const handlePostResponse = (encounter) => {
154
68
  if (encounter && encounter.uuid) {
155
69
  saveEncounter(encounter.uuid);
70
+ setEncounter(encounter);
156
71
  }
157
72
  };
158
73
 
74
+ useEffect(() => {
75
+ if (encounter && visit) {
76
+ // Update encounter so that it belongs to the created visit
77
+ updateEncounter({ uuid: encounter.uuid, visit: visit.uuid });
78
+ }
79
+ }, [encounter, visit, updateEncounter]);
80
+
81
+ useEffect(() => {
82
+ if (visitSaveSuccess) {
83
+ setVisit(visitSaveSuccess.data);
84
+ }
85
+ }, [visitSaveSuccess]);
86
+
87
+ const handleEncounterCreate = useCallback(
88
+ (payload) => {
89
+ payload.location = sessionLocation?.uuid;
90
+ payload.encounterDatetime = payload.encounterDatetime ? payload.encounterDatetime : new Date().toISOString();
91
+ // Create a visit with the same date as the encounter being saved
92
+ const visitStartDatetime = new Date(payload.encounterDatetime);
93
+ const visitStopDatetime = new Date(payload.encounterDatetime);
94
+ const visitInfo = {
95
+ startDatetime: visitStartDatetime,
96
+ stopDatetime: visitStopDatetime,
97
+ uuid: uuid(),
98
+ patient: {
99
+ uuid: activePatientUuid,
100
+ },
101
+ location: {
102
+ uuid: sessionLocation?.uuid,
103
+ },
104
+ visitType: {
105
+ uuid: singleSessionVisitTypeUuid,
106
+ },
107
+ };
108
+
109
+ payload.visit = visitInfo;
110
+ },
111
+ [activePatientUuid, singleSessionVisitTypeUuid, sessionLocation],
112
+ );
113
+
159
114
  return (
160
115
  <div className={styles.workspace}>
161
116
  {!patientUuids.length && (
162
- <div className={styles.selectPatientMessage}>
163
- {t("selectPatientFirst", "Please select a patient first")}
164
- </div>
117
+ <div className={styles.selectPatientMessage}>{t('selectPatientFirst', 'Please select a patient first')}</div>
165
118
  )}
166
119
  {!!patientUuids.length && (
167
120
  <div className={styles.formMainContent}>
@@ -172,11 +125,12 @@ const FormWorkspace = () => {
172
125
  {...{
173
126
  formUuid: activeFormUuid,
174
127
  handlePostResponse,
128
+ handleEncounterCreate,
175
129
  }}
176
130
  />
177
131
  </div>
178
132
  <div className={styles.rightPanel}>
179
- <h4>Forms filled</h4>
133
+ <h4>{t('formsFilled', 'Forms filled')}</h4>
180
134
  <div className={styles.patientCardsSection}>
181
135
  {patientUuids.map((patientUuid) => (
182
136
  <PatientCard
@@ -205,8 +159,8 @@ const FormEntryWorkflow = () => {
205
159
  <div className={styles.breadcrumbsContainer}>
206
160
  <ExtensionSlot extensionSlotName="breadcrumbs-slot" />
207
161
  </div>
208
- {workflowState === "REVIEW" && <WorkflowReview />}
209
- {workflowState !== "REVIEW" && (
162
+ {workflowState === 'REVIEW' && <WorkflowReview />}
163
+ {workflowState !== 'REVIEW' && (
210
164
  <>
211
165
  <PatientSearchHeader />
212
166
  <PatientBanner />
@@ -1,9 +1,9 @@
1
- import { Accordion, AccordionItem, Button } from "@carbon/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";
1
+ import { Accordion, AccordionItem, Button } from '@carbon/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
7
 
8
8
  const FormReviewCard = ({ patientUuid }) => {
9
9
  const { encounters, editEncounter } = useContext(FormWorkflowContext);
@@ -39,7 +39,7 @@ const FormReviewCard = ({ patientUuid }) => {
39
39
  </div>
40
40
  )}
41
41
  <Button kind="primary" onClick={() => editEncounter(patientUuid)}>
42
- {t("goToForm", "Go To Form")}
42
+ {t('goToForm', 'Go To Form')}
43
43
  </Button>
44
44
  </AccordionItem>
45
45
  </Accordion>
@@ -1,3 +1,3 @@
1
- import FormReviewCard from "./FormReviewCard";
1
+ import FormReviewCard from './FormReviewCard';
2
2
 
3
3
  export default FormReviewCard;
@@ -1,12 +1,10 @@
1
- @use '@carbon/styles/scss/spacing';
2
- // @use '@carbon/colors';
3
- @use '@carbon/styles/scss/type';
4
- @import '~@openmrs/esm-styleguide/src/vars';
5
-
1
+ @use '@carbon/colors';
2
+ @use '@carbon/layout';
3
+ @use '@carbon/type';
6
4
 
7
5
  .formReviewCard {
8
- background-color: $ui-02;
9
- padding: spacing.$spacing-02;
6
+ background-color: colors.$white-0;
7
+ padding: layout.$spacing-02;
10
8
  }
11
9
 
12
10
  .formReviewCard :global(.cds--accordion) :global(.cds--accordion__item) {
@@ -16,17 +14,17 @@
16
14
  .formReviewCard :global(.cds--accordion__title) {
17
15
  display: flex;
18
16
  align-items: baseline;
19
- column-gap: spacing.$spacing-05;
17
+ column-gap: layout.$spacing-05;
20
18
  }
21
19
 
22
20
  .formReviewCard :global(.cds--accordion__content) {
23
- padding: spacing.$spacing-03;
21
+ padding: layout.$spacing-03;
24
22
  }
25
23
 
26
24
  .dataField {
27
25
  @include type.type-style('code-02');
28
- background-color: $ui-01;
29
- padding: spacing.$spacing-03;
26
+ background-color: colors.$gray-10;
27
+ padding: layout.$spacing-03;
30
28
  }
31
29
 
32
30
  .displayName {
@@ -1,3 +1,3 @@
1
- import FormEntryWorkflow from "./FormEntryWorkflow";
1
+ import FormEntryWorkflow from './FormEntryWorkflow';
2
2
 
3
3
  export default FormEntryWorkflow;
@@ -1,9 +1,9 @@
1
- import React from "react";
2
- import { render } from "@testing-library/react";
3
- import PatientBanner from "./PatientBanner";
1
+ import React from 'react';
2
+ import { render } from '@testing-library/react';
3
+ import PatientBanner from './PatientBanner';
4
4
 
5
- describe("PatientBanner", () => {
6
- it("renders placeholder information when no data is present", () => {
5
+ describe('PatientBanner', () => {
6
+ it('renders placeholder information when no data is present', () => {
7
7
  render(<PatientBanner />);
8
8
  });
9
9
  });
@@ -1,10 +1,10 @@
1
- import { age, ExtensionSlot } from "@openmrs/esm-framework";
2
- import { SkeletonPlaceholder, SkeletonText } from "@carbon/react";
3
- import React, { useContext } from "react";
4
- import styles from "./styles.scss";
5
- import { useTranslation } from "react-i18next";
6
- import useGetPatient from "../../hooks/useGetPatient";
7
- import FormWorkflowContext from "../../context/FormWorkflowContext";
1
+ import { age, ExtensionSlot } from '@openmrs/esm-framework';
2
+ import { SkeletonPlaceholder, SkeletonText } from '@carbon/react';
3
+ import React, { useContext } from 'react';
4
+ import styles from './styles.scss';
5
+ import { useTranslation } from 'react-i18next';
6
+ import useGetPatient from '../../hooks/useGetPatient';
7
+ import FormWorkflowContext from '../../context/FormWorkflowContext';
8
8
 
9
9
  const SkeletonPatientInfo = () => {
10
10
  return (
@@ -36,16 +36,14 @@ const PatientBanner = () => {
36
36
  const { activePatientUuid, workflowState } = useContext(FormWorkflowContext);
37
37
  const patient = useGetPatient(activePatientUuid);
38
38
  const { t } = useTranslation();
39
- const patientName = `${patient?.name?.[0].given?.join(" ")} ${
40
- patient?.name?.[0]?.family
41
- }`;
39
+ const patientName = `${patient?.name?.[0].given?.join(' ')} ${patient?.name?.[0]?.family}`;
42
40
 
43
41
  const patientPhotoSlotState = React.useMemo(
44
- () => ({ patientUuid: patient?.id, patientName, size: "small" }),
45
- [patient?.id, patientName]
42
+ () => ({ patientUuid: patient?.id, patientName, size: 'small' }),
43
+ [patient?.id, patientName],
46
44
  );
47
45
 
48
- if (workflowState === "NEW_PATIENT") return null;
46
+ if (workflowState === 'NEW_PATIENT') return null;
49
47
 
50
48
  if (!patient) {
51
49
  return <SkeletonPatientInfo />;
@@ -53,29 +51,18 @@ const PatientBanner = () => {
53
51
 
54
52
  return (
55
53
  <div className={styles.container}>
56
- <ExtensionSlot
57
- extensionSlotName="patient-photo-slot"
58
- state={patientPhotoSlotState}
59
- />
54
+ <ExtensionSlot extensionSlotName="patient-photo-slot" state={patientPhotoSlotState} />
60
55
  <div className={styles.patientInfoContent}>
61
56
  <div className={styles.patientInfoRow}>
62
57
  <span className={styles.patientName}>{patientName}</span>
63
58
  </div>
64
59
  <div className={styles.patientInfoRow}>
65
- <span>
66
- {(patient.gender ?? t("unknown", "Unknown")).replace(/^\w/, (c) =>
67
- c.toUpperCase()
68
- )}
69
- </span>
60
+ <span>{(patient.gender ?? t('unknown', 'Unknown')).replace(/^\w/, (c) => c.toUpperCase())}</span>
70
61
  <span>&middot;</span>
71
62
  <span>{age(patient.birthDate)}</span>
72
63
  <span>&middot;</span>
73
64
  <span>
74
- {patient.identifier.length
75
- ? patient.identifier
76
- .map((identifier) => identifier.value)
77
- .join(", ")
78
- : "--"}
65
+ {patient.identifier.length ? patient.identifier.map((identifier) => identifier.value).join(', ') : '--'}
79
66
  </span>
80
67
  </div>
81
68
  </div>
@@ -1,3 +1,3 @@
1
- import PatientBanner from "./PatientBanner";
1
+ import PatientBanner from './PatientBanner';
2
2
 
3
3
  export default PatientBanner;
@@ -1,16 +1,15 @@
1
- @use '@carbon/styles/scss/spacing';
2
- // @use '@carbon/colors';
3
- @use '@carbon/styles/scss/type';
4
- @import '~@openmrs/esm-styleguide/src/vars';
1
+ @use '@carbon/colors';
2
+ @use '@carbon/layout';
3
+ @use '@carbon/type';
5
4
 
6
5
  .container {
7
- height: spacing.$spacing-11;
6
+ height: layout.$spacing-11;
8
7
  display: flex;
9
8
  align-items: center;
10
- background-color: $ui-02;
11
- border-top: 0.0125rem solid $ui-03;
12
- border-bottom: 0.0125rem solid $ui-03;
13
- padding: 0 spacing.$spacing-05;
9
+ background-color: colors.$white-0;
10
+ border-top: 0.0125rem solid colors.$gray-20;
11
+ border-bottom: 0.0125rem solid colors.$gray-20;
12
+ padding: 0 layout.$spacing-05;
14
13
  }
15
14
 
16
15
  .photoPlaceholder {
@@ -35,11 +34,11 @@
35
34
  min-height: 2rem;
36
35
  }
37
36
  @include type.type-style('body-compact-02');
38
- color: $text-02;
37
+ color: colors.$gray-70;
39
38
  column-gap: 0.8rem;
40
39
  }
41
40
 
42
41
  .patientEditBtn {
43
- color: $ui-05;
44
- margin: spacing.$spacing-03;
42
+ color: colors.$gray-100;
43
+ margin: layout.$spacing-03;
45
44
  }
@@ -1,58 +1,49 @@
1
- import { Add, Close } from "@carbon/react/icons";
2
- import {
3
- ExtensionSlot,
4
- interpolateUrl,
5
- navigate,
6
- } from "@openmrs/esm-framework";
7
- import { Button } from "@carbon/react";
8
- import React, { useContext } from "react";
9
- import { Link } from "react-router-dom";
10
- import FormWorkflowContext from "../../context/FormWorkflowContext";
11
- import styles from "./styles.scss";
12
- import { useTranslation } from "react-i18next";
1
+ import { Add, Close } from '@carbon/react/icons';
2
+ import { ExtensionSlot, interpolateUrl, navigate } from '@openmrs/esm-framework';
3
+ import { Button } from '@carbon/react';
4
+ import React, { useContext } from 'react';
5
+ import { Link } from 'react-router-dom';
6
+ import FormWorkflowContext from '../../context/FormWorkflowContext';
7
+ import styles from './styles.scss';
8
+ import { useTranslation } from 'react-i18next';
13
9
 
14
10
  const PatientSearchHeader = () => {
15
- const { addPatient, workflowState, activeFormUuid } =
16
- useContext(FormWorkflowContext);
11
+ const { addPatient, workflowState, activeFormUuid } = useContext(FormWorkflowContext);
17
12
  const handleSelectPatient = (patient) => {
18
- addPatient(patient.uuid);
13
+ addPatient(patient);
19
14
  };
20
15
  const { t } = useTranslation();
21
16
 
22
- if (workflowState !== "NEW_PATIENT") return null;
17
+ if (workflowState !== 'NEW_PATIENT') return null;
23
18
 
24
- const afterUrl = encodeURIComponent(
25
- `\${openmrsSpaBase}/forms/form/${activeFormUuid}?patientUuid=\${patientUuid}`
26
- );
27
- const patientRegistrationUrl = interpolateUrl(
28
- `\${openmrsSpaBase}/patient-registration?afterUrl=${afterUrl}`
29
- );
19
+ const afterUrl = encodeURIComponent(`\${openmrsSpaBase}/forms/form/${activeFormUuid}?patientUuid=\${patientUuid}`);
20
+ const patientRegistrationUrl = interpolateUrl(`\${openmrsSpaBase}/patient-registration?afterUrl=${afterUrl}`);
30
21
 
31
22
  return (
32
23
  <div className={styles.searchHeaderContainer}>
33
- <span className={styles.padded}>{t("nextPatient", "Next patient")}:</span>
24
+ <span className={styles.padded}>{t('nextPatient', 'Next patient')}:</span>
34
25
  <span className={styles.searchBarWrapper}>
35
26
  <ExtensionSlot
36
- extensionSlotName="patient-search-bar-slot"
27
+ name="patient-search-bar-slot"
37
28
  state={{
38
29
  selectPatientAction: handleSelectPatient,
39
30
  buttonProps: {
40
- kind: "primary",
31
+ kind: 'primary',
41
32
  },
42
33
  }}
43
34
  />
44
35
  </span>
45
- <span className={styles.padded}>{t("or", "or")}</span>
36
+ <span className={styles.padded}>{t('or', 'or')}</span>
46
37
  <span>
47
38
  <Button onClick={() => navigate({ to: patientRegistrationUrl })}>
48
- {t("createNewPatient", "Create new patient")} <Add size={20} />
39
+ {t('createNewPatient', 'Create new patient')} <Add size={20} />
49
40
  </Button>
50
41
  </span>
51
42
  <span style={{ flexGrow: 1 }} />
52
43
  <span>
53
44
  <Link to="../">
54
45
  <Button kind="ghost">
55
- {t("cancel", "Cancel")} <Close size={20} />
46
+ {t('cancel', 'Cancel')} <Close size={20} />
56
47
  </Button>
57
48
  </Link>
58
49
  </span>
@@ -1,3 +1,3 @@
1
- import PatientSearchHeader from "./PatientSearchHeader";
1
+ import PatientSearchHeader from './PatientSearchHeader';
2
2
 
3
3
  export default PatientSearchHeader;
@@ -1,22 +1,25 @@
1
- @use '@carbon/styles/scss/spacing';
2
- // @use '@carbon/colors';
3
- // @use '@carbon/styles/scss/type';
4
- @import '~@openmrs/esm-styleguide/src/vars';
1
+ @use '@carbon/colors';
2
+ @use '@carbon/layout';
3
+ @use '@carbon/type';
5
4
 
6
5
  .searchHeaderContainer {
7
- height: spacing.$spacing-11;
6
+ height: layout.$spacing-11;
8
7
  display: flex;
9
8
  align-items: center;
10
- background-color: $ui-02;
11
- border-top: 0.0125rem solid $ui-03;
12
- border-bottom: 0.0125rem solid $ui-03;
13
- padding: 0 spacing.$spacing-05;
9
+ background-color: colors.$white-0;
10
+ border-top: 0.0125rem solid colors.$gray-20;
11
+ border-bottom: 0.0125rem solid colors.$gray-20;
12
+ padding: 0 layout.$spacing-05;
14
13
  }
15
14
 
16
15
  .searchBarWrapper {
17
16
  min-width: 35rem;
18
17
  }
19
18
 
19
+ .searchBarWrapper > div button {
20
+ height: auto;
21
+ }
22
+
20
23
  .padded {
21
- padding: spacing.$spacing-05;
24
+ padding: layout.$spacing-05;
22
25
  }
@@ -1,13 +1,11 @@
1
- @use '@carbon/styles/scss/spacing';
2
1
  @use '@carbon/colors';
3
- @use '@carbon/styles/scss/type';
4
- @import '~@openmrs/esm-styleguide/src/vars';
5
-
2
+ @use '@carbon/layout';
3
+ @use '@carbon/type';
6
4
 
7
5
  .breadcrumbsContainer > div > div > nav {
8
- background-color: $ui-02;
9
- padding: spacing.$spacing-04 spacing.$spacing-05;
10
- height: spacing.$spacing-08;
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 {
@@ -20,22 +18,23 @@
20
18
  }
21
19
 
22
20
  .selectPatientMessage {
23
- @include type.type-style('productive-heading-03');
24
- margin: spacing.$spacing-07;
21
+ @include type.type-style('heading-03');
22
+ margin: layout.$spacing-07;
25
23
  text-align: center;
26
24
  }
27
25
 
28
26
  .formMainContent {
29
27
  display: flex;
30
28
  text-align: center;
31
- margin-top: spacing.$spacing-05;
32
- column-gap: spacing.$spacing-05;
29
+ margin-top: layout.$spacing-05;
30
+ column-gap: layout.$spacing-05;
33
31
  }
34
32
 
35
33
  .formContainer {
36
34
  flex-grow: 1;
37
35
  max-height: calc(100vh - 14rem);
38
36
  overflow-y: scroll;
37
+ text-align: left;
39
38
  }
40
39
 
41
40
  .formContainer :global(.cds--form-item) :global(.question-area) {
@@ -43,20 +42,20 @@
43
42
  }
44
43
 
45
44
  .rightPanel {
46
- width: 13rem;
45
+ min-width: 13rem;
47
46
  text-align: left;
48
47
  overflow-y: scroll;
49
48
  }
50
49
 
51
50
  .patientCardsSection {
52
- margin: spacing.$spacing-05 0;
51
+ margin: layout.$spacing-05 0;
53
52
  border-bottom: 1px solid colors.$gray-10;
54
53
  }
55
54
 
56
55
  .rightPanelActionButtons {
57
56
  display: flex;
58
57
  flex-direction: column;
59
- row-gap: spacing.$spacing-03;
58
+ row-gap: layout.$spacing-03;
60
59
  & button {
61
60
  width: 100%;
62
61
  text-decoration: "none";