@openmrs/esm-fast-data-entry-app 1.0.0-pre.34 → 1.0.0-pre.41

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 (43) hide show
  1. package/.github/pull_request_template.md +18 -0
  2. package/dist/120.js +2 -0
  3. package/dist/{147.js.LICENSE.txt → 120.js.LICENSE.txt} +6 -0
  4. package/dist/574.js +1 -1
  5. package/dist/595.js +1 -1
  6. package/dist/595.js.LICENSE.txt +0 -2
  7. package/dist/61.js +1 -0
  8. package/dist/804.js +1 -1
  9. package/dist/84.js +1 -0
  10. package/dist/990.js +1 -0
  11. package/dist/openmrs-esm-fast-data-entry-app.js +1 -1
  12. package/dist/openmrs-esm-fast-data-entry-app.js.buildmanifest.json +77 -77
  13. package/dist/openmrs-esm-fast-data-entry-app.old +1 -1
  14. package/package.json +4 -4
  15. package/src/FormBootstrap.tsx +2 -0
  16. package/src/Root.tsx +6 -9
  17. package/src/context/FormWorkflowContext.tsx +43 -15
  18. package/src/context/FormWorkflowReducer.ts +41 -0
  19. package/src/form-entry-workflow/FormEntryWorkflow.tsx +116 -54
  20. package/src/form-entry-workflow/styles.scss +13 -6
  21. package/src/form-review-card/FormReviewCard.tsx +50 -0
  22. package/src/form-review-card/index.ts +3 -0
  23. package/src/form-review-card/styles.scss +38 -0
  24. package/src/forms-table/FormsTable.tsx +3 -5
  25. package/src/hooks/index.ts +3 -1
  26. package/src/hooks/useFormState.ts +23 -0
  27. package/src/hooks/useGetEncounter.ts +22 -0
  28. package/src/patient-banner/PatientBanner.test.tsx +1 -1
  29. package/src/patient-banner/PatientBanner.tsx +51 -105
  30. package/src/patient-banner/styles.scss +13 -28
  31. package/src/patient-card/PatientCard.tsx +2 -2
  32. package/src/patient-card/styles.scss +6 -5
  33. package/src/patient-search-header/PatientSearchHeader.tsx +3 -1
  34. package/src/patient-search-header/styles.scss +6 -2
  35. package/src/workflow-review/WorkflowReview.tsx +36 -0
  36. package/src/workflow-review/index.ts +3 -0
  37. package/src/workflow-review/styles.scss +34 -0
  38. package/translations/en.json +1 -0
  39. package/dist/147.js +0 -2
  40. package/dist/508.js +0 -1
  41. package/dist/634.js +0 -2
  42. package/dist/634.js.LICENSE.txt +0 -5
  43. package/dist/954.js +0 -1
@@ -1,76 +1,51 @@
1
- import {
2
- age,
3
- ExtensionSlot,
4
- formatDate,
5
- parseDate,
6
- } from "@openmrs/esm-framework";
7
- import {
8
- Button,
9
- SkeletonPlaceholder,
10
- SkeletonText,
11
- } from "carbon-components-react";
12
- import React, { useState } from "react";
1
+ import { age, ExtensionSlot } from "@openmrs/esm-framework";
2
+ import { SkeletonPlaceholder, SkeletonText } from "carbon-components-react";
3
+ import React, { useContext } from "react";
13
4
  import styles from "./styles.scss";
14
- import ChevronDown16 from "@carbon/icons-react/es/chevron--down/16";
15
- import ChevronUp16 from "@carbon/icons-react/es/chevron--up/16";
16
5
  import { useTranslation } from "react-i18next";
17
6
  import useGetPatient from "../hooks/useGetPatient";
18
- interface PatientInfoProps {
19
- patientUuid: string;
20
- }
7
+ import FormWorkflowContext from "../context/FormWorkflowContext";
21
8
 
22
9
  const SkeletonPatientInfo = () => {
23
10
  return (
24
11
  <div className={styles.container}>
25
- <div className={styles.patientInfoContainer}>
26
- <SkeletonPlaceholder />
27
- <div className={styles.patientInfoContent}>
28
- <div className={styles.patientInfoRow}>
29
- <span className={styles.patientName}>
30
- <SkeletonText />
31
- </span>
32
- </div>
33
- <div className={styles.patientInfoRow}>
34
- <div className={styles.demographics}>
35
- <span>
36
- <SkeletonText />
37
- </span>
38
- <span>
39
- <SkeletonText />
40
- </span>
41
- <span>
42
- <SkeletonText />
43
- </span>
44
- </div>
45
- </div>
46
- <div className={styles.patientInfoRow}>
47
- <span className={styles.identifier}>
48
- <SkeletonText />
49
- </span>
50
- </div>
12
+ <SkeletonPlaceholder className={styles.photoPlaceholder} />
13
+ <div className={styles.patientInfoContent}>
14
+ <div className={styles.patientInfoRow}>
15
+ <SkeletonText width="7rem" lineCount={1} />
16
+ </div>
17
+ <div className={styles.patientInfoRow}>
18
+ <span>
19
+ <SkeletonText width="1rem" lineCount={1} />
20
+ </span>
21
+ <span>&middot;</span>
22
+ <span>
23
+ <SkeletonText width="1rem" lineCount={1} />
24
+ </span>
25
+ <span>&middot;</span>
26
+ <span>
27
+ <SkeletonText width="1rem" lineCount={1} />
28
+ </span>
51
29
  </div>
52
30
  </div>
53
31
  </div>
54
32
  );
55
33
  };
56
34
 
57
- const PatientInfo: React.FC<PatientInfoProps> = ({ patientUuid }) => {
58
- const patient = useGetPatient(patientUuid);
35
+ const PatientBanner = () => {
36
+ const { activePatientUuid, workflowState } = useContext(FormWorkflowContext);
37
+ const patient = useGetPatient(activePatientUuid);
59
38
  const { t } = useTranslation();
60
- const [showContactDetails, setShowContactDetails] = useState<boolean>(false);
61
39
  const patientName = `${patient?.name?.[0].given?.join(" ")} ${
62
40
  patient?.name?.[0]?.family
63
41
  }`;
64
42
 
65
43
  const patientPhotoSlotState = React.useMemo(
66
- () => ({ patientUuid: patient?.id, patientName }),
44
+ () => ({ patientUuid: patient?.id, patientName, size: "small" }),
67
45
  [patient?.id, patientName]
68
46
  );
69
47
 
70
- const toggleShowMore = (e: React.MouseEvent) => {
71
- e.stopPropagation();
72
- setShowContactDetails((prevState) => !prevState);
73
- };
48
+ if (workflowState === "NEW_PATIENT") return null;
74
49
 
75
50
  if (!patient) {
76
51
  return <SkeletonPatientInfo />;
@@ -78,63 +53,34 @@ const PatientInfo: React.FC<PatientInfoProps> = ({ patientUuid }) => {
78
53
 
79
54
  return (
80
55
  <div className={styles.container}>
81
- <div
82
- className={`${
83
- showContactDetails
84
- ? styles.activePatientInfoContainer
85
- : styles.patientInfoContainer
86
- }`}
87
- >
88
- <ExtensionSlot
89
- extensionSlotName="patient-photo-slot"
90
- state={patientPhotoSlotState}
91
- />
92
- <div className={styles.patientInfoContent}>
93
- <div className={styles.patientInfoRow}>
94
- <span className={styles.patientName}>{patientName}</span>
95
- </div>
96
- <div className={styles.patientInfoRow}>
97
- <div className={styles.demographics}>
98
- <span>
99
- {(patient.gender ?? t("unknown", "Unknown")).replace(
100
- /^\w/,
101
- (c) => c.toUpperCase()
102
- )}{" "}
103
- &middot;{" "}
104
- </span>
105
- <span>{age(patient.birthDate)} &middot; </span>
106
- <span>
107
- {formatDate(parseDate(patient.birthDate), {
108
- mode: "wide",
109
- time: false,
110
- })}
111
- </span>
112
- </div>
113
- </div>
114
- <div className={styles.patientInfoRow}>
115
- <span className={styles.identifier}>
116
- {patient.identifier.length
117
- ? patient.identifier
118
- .map((identifier) => identifier.value)
119
- .join(", ")
120
- : "--"}
121
- </span>
122
- <Button
123
- kind="ghost"
124
- renderIcon={showContactDetails ? ChevronUp16 : ChevronDown16}
125
- iconDescription="Toggle contact details"
126
- onClick={(e) => toggleShowMore(e)}
127
- disabled
128
- >
129
- {showContactDetails
130
- ? t("showLess", "Show less")
131
- : t("showAllDetails", "Show all details")}
132
- </Button>
133
- </div>
56
+ <ExtensionSlot
57
+ extensionSlotName="patient-photo-slot"
58
+ state={patientPhotoSlotState}
59
+ />
60
+ <div className={styles.patientInfoContent}>
61
+ <div className={styles.patientInfoRow}>
62
+ <span className={styles.patientName}>{patientName}</span>
63
+ </div>
64
+ <div className={styles.patientInfoRow}>
65
+ <span>
66
+ {(patient.gender ?? t("unknown", "Unknown")).replace(/^\w/, (c) =>
67
+ c.toUpperCase()
68
+ )}
69
+ </span>
70
+ <span>&middot;</span>
71
+ <span>{age(patient.birthDate)}</span>
72
+ <span>&middot;</span>
73
+ <span>
74
+ {patient.identifier.length
75
+ ? patient.identifier
76
+ .map((identifier) => identifier.value)
77
+ .join(", ")
78
+ : "--"}
79
+ </span>
134
80
  </div>
135
81
  </div>
136
82
  </div>
137
83
  );
138
84
  };
139
85
 
140
- export default PatientInfo;
86
+ export default PatientBanner;
@@ -3,54 +3,39 @@
3
3
  @import '~carbon-components/src/globals/scss/mixins';
4
4
 
5
5
  .container {
6
- border-bottom: 0.0125rem solid $color-gray-30;
7
- background-color: $ui-02;
8
- padding: 0;
9
- }
10
-
11
- .patientInfoContainer {
12
- padding: 0 0 0 $spacing-05;
6
+ height: $spacing-11;
13
7
  display: flex;
14
8
  align-items: center;
15
- min-height: 7rem;
9
+ background-color: $ui-02;
10
+ border-top: 0.0125rem solid $ui-03;
11
+ border-bottom: 0.0125rem solid $ui-03;
12
+ padding: 0 $spacing-05;
16
13
  }
17
14
 
18
- .activePatientInfoContainer {
19
- background-color: $color-blue-10;
20
- padding: 0 0 0 $spacing-05;
21
- display: flex;
22
- align-items: center;
23
- min-height: 7rem;
15
+ .photoPlaceholder {
16
+ height: 48px;
17
+ width: 48px;
24
18
  }
25
19
 
26
20
  .patientName {
27
21
  @include carbon--type-style('productive-heading-03');
22
+ font-weight: 600;
28
23
  }
29
24
 
30
25
  .patientInfoContent {
31
- margin: $spacing-05 0 0 $spacing-05;
32
26
  width: 100%;
33
- }
34
-
35
- .demographics {
36
- @include carbon--type-style('body-short-02');
37
- color: $text-02;
38
- margin-top: $spacing-02;
39
- }
40
-
41
- .identifier {
42
- @include carbon--type-style('body-short-02');
43
- color: $ui-04;
27
+ margin-left: 1rem;
44
28
  }
45
29
 
46
30
  .patientInfoRow {
47
31
  display: flex;
48
- justify-content: space-between;
49
32
  align-items: center;
50
-
51
33
  & > button {
52
34
  min-height: 2rem;
53
35
  }
36
+ @include carbon--type-style('body-short-02');
37
+ color: $text-02;
38
+ column-gap: 0.8rem;
54
39
  }
55
40
 
56
41
  .patientEditBtn {
@@ -7,8 +7,8 @@ import styles from "./styles.scss";
7
7
  const CardContainer = ({ active, onClick, children }) => {
8
8
  return (
9
9
  <div
10
- className={`${styles.cardContainer} ${!active && styles.hoverable}`}
11
- onClick={onClick}
10
+ className={`${styles.cardContainer} ${!active && styles.inactiveCard}`}
11
+ onClick={active ? onClick : () => {}}
12
12
  role="button"
13
13
  tabIndex={0}
14
14
  >
@@ -4,13 +4,8 @@
4
4
 
5
5
  .cardContainer {
6
6
  padding: $spacing-05;
7
- &:hover {
8
- background-color: $carbon--gray-40;
9
- }
10
7
  }
11
8
 
12
-
13
-
14
9
  .skeletonText {
15
10
  max-width: 8rem;
16
11
  }
@@ -28,3 +23,9 @@
28
23
  .activeDisplayName {
29
24
  color: $carbon--blue-50;
30
25
  }
26
+
27
+ .inactiveCard {
28
+ &:hover {
29
+ background-color: $carbon--gray-40;
30
+ }
31
+ }
@@ -7,11 +7,13 @@ import FormWorkflowContext from "../context/FormWorkflowContext";
7
7
  import styles from "./styles.scss";
8
8
 
9
9
  const PatientSearchHeader = () => {
10
- const { addPatient } = useContext(FormWorkflowContext);
10
+ const { addPatient, workflowState } = useContext(FormWorkflowContext);
11
11
  const handleSelectPatient = (uuid) => {
12
12
  addPatient(uuid);
13
13
  };
14
14
 
15
+ if (workflowState !== "NEW_PATIENT") return null;
16
+
15
17
  return (
16
18
  <div className={styles.searchHeaderContainer}>
17
19
  <span className={styles.padded}>Next patient:</span>
@@ -3,9 +3,13 @@
3
3
  @import "~carbon-components/src/globals/scss/mixins";
4
4
 
5
5
  .searchHeaderContainer {
6
+ height: $spacing-11;
6
7
  display: flex;
7
- background-color: white;
8
- padding: $spacing-07 $spacing-05;
8
+ align-items: center;
9
+ background-color: $ui-02;
10
+ border-top: 0.0125rem solid $ui-03;
11
+ border-bottom: 0.0125rem solid $ui-03;
12
+ padding: 0 $spacing-05;
9
13
  }
10
14
 
11
15
  .searchBarWrapper {
@@ -0,0 +1,36 @@
1
+ import { Button } from "carbon-components-react";
2
+ import React, { useContext } from "react";
3
+ import { useHistory } from "react-router-dom";
4
+ import FormWorkflowContext from "../context/FormWorkflowContext";
5
+ import FormReviewCard from "../form-review-card";
6
+ import PatientCard from "../patient-card";
7
+ import styles from "./styles.scss";
8
+
9
+ const WorkflowReview = () => {
10
+ const { patientUuids } = useContext(FormWorkflowContext);
11
+ const history = useHistory();
12
+ return (
13
+ <div className={styles.workspaceWrapper}>
14
+ <div className={styles.workspace}>
15
+ <div className={styles.leftPanel}>
16
+ <h4>Review</h4>
17
+ <div className={styles.navButtons}>
18
+ <Button kind="primary" onClick={() => history.push("/")}>
19
+ Save & Close
20
+ </Button>
21
+ <Button kind="tertiary" onClick={() => history.push("/")}>
22
+ Cancel
23
+ </Button>
24
+ </div>
25
+ </div>
26
+ <div className={styles.formContainer}>
27
+ {patientUuids.map((patientUuid) => (
28
+ <FormReviewCard patientUuid={patientUuid} key={patientUuid} />
29
+ ))}
30
+ </div>
31
+ </div>
32
+ </div>
33
+ );
34
+ };
35
+
36
+ export default WorkflowReview;
@@ -0,0 +1,3 @@
1
+ import WorkflowReview from "./WorkflowReview";
2
+
3
+ export default WorkflowReview;
@@ -0,0 +1,34 @@
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
+ .workspaceWrapper {
6
+ display: flex;
7
+ justify-content: center;
8
+ }
9
+
10
+ .workspace {
11
+ display: flex;
12
+ width: 800px;
13
+ margin-top: 1rem;
14
+ column-gap: 1rem;
15
+ }
16
+
17
+ .leftPanel {
18
+ width: 13rem;
19
+ overflow-y: scroll;
20
+ }
21
+
22
+ .navButtons {
23
+ margin-top: 1rem;
24
+ display: flex;
25
+ flex-direction: column;
26
+ row-gap: 0.5rem;
27
+ }
28
+
29
+ .formContainer {
30
+ flex-grow: 1;
31
+ max-height: calc(100vh - 14rem);
32
+ overflow-y: scroll;
33
+ row-gap: 1rem;
34
+ }
@@ -6,6 +6,7 @@
6
6
  "fillForm": "Fill Form",
7
7
  "formalGreeting": "hello",
8
8
  "formName": "Form Name",
9
+ "goToForm": "Go To Form",
9
10
  "noFormsFound": "No Forms To Show",
10
11
  "noFormsFoundMessage": "No forms could be found for this category. Please double check the form concept uuids and access permissions.",
11
12
  "selectPatientFirst": "Please select a patient first",