@openmrs/esm-fast-data-entry-app 1.0.1-pre.171 → 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 (77) hide show
  1. package/__mocks__/react-i18next.js +9 -14
  2. package/dist/101.js.map +1 -1
  3. package/dist/188.js.map +1 -1
  4. package/dist/219.js.map +1 -1
  5. package/dist/326.js.map +1 -1
  6. package/dist/564.js.map +1 -1
  7. package/dist/91.js.map +1 -1
  8. package/dist/99.js.map +1 -1
  9. package/dist/main.js.map +1 -1
  10. package/dist/openmrs-esm-fast-data-entry-app.js.buildmanifest.json +8 -8
  11. package/dist/routes.json +1 -1
  12. package/package.json +1 -3
  13. package/prettier.config.js +8 -0
  14. package/src/CancelModal.tsx +9 -15
  15. package/src/CompleteModal.tsx +7 -18
  16. package/src/FormBootstrap.tsx +9 -9
  17. package/src/Root.tsx +7 -12
  18. package/src/add-group-modal/AddGroupModal.tsx +46 -109
  19. package/src/config-schema.ts +35 -36
  20. package/src/constant.ts +1 -1
  21. package/src/context/FormWorkflowContext.tsx +26 -39
  22. package/src/context/FormWorkflowReducer.ts +50 -74
  23. package/src/context/GroupFormWorkflowContext.tsx +36 -61
  24. package/src/context/GroupFormWorkflowReducer.ts +69 -105
  25. package/src/declarations.d.ts +3 -3
  26. package/src/empty-state/EmptyDataIllustration.tsx +4 -16
  27. package/src/empty-state/EmptyState.tsx +8 -13
  28. package/src/form-entry-workflow/FormEntryWorkflow.tsx +26 -44
  29. package/src/form-entry-workflow/form-review-card/FormReviewCard.tsx +7 -7
  30. package/src/form-entry-workflow/form-review-card/index.ts +1 -1
  31. package/src/form-entry-workflow/index.ts +1 -1
  32. package/src/form-entry-workflow/patient-banner/PatientBanner.test.tsx +5 -5
  33. package/src/form-entry-workflow/patient-banner/PatientBanner.tsx +14 -27
  34. package/src/form-entry-workflow/patient-banner/index.ts +1 -1
  35. package/src/form-entry-workflow/patient-search-header/PatientSearchHeader.tsx +17 -26
  36. package/src/form-entry-workflow/patient-search-header/index.ts +1 -1
  37. package/src/form-entry-workflow/workflow-review/WorkflowReview.tsx +12 -12
  38. package/src/form-entry-workflow/workflow-review/index.ts +1 -1
  39. package/src/forms-app-menu-link.tsx +4 -6
  40. package/src/forms-page/FormsPage.tsx +22 -50
  41. package/src/forms-page/forms-table/FormsTable.tsx +22 -42
  42. package/src/forms-page/forms-table/index.ts +1 -1
  43. package/src/forms-page/index.ts +1 -1
  44. package/src/group-form-entry-workflow/GroupFormEntryWorkflow.tsx +8 -8
  45. package/src/group-form-entry-workflow/GroupSessionWorkspace.tsx +27 -58
  46. package/src/group-form-entry-workflow/SessionDetailsForm.tsx +43 -66
  47. package/src/group-form-entry-workflow/SessionMetaWorkspace.tsx +20 -28
  48. package/src/group-form-entry-workflow/attendance-table/AttendanceTable.tsx +13 -27
  49. package/src/group-form-entry-workflow/attendance-table/index.ts +1 -1
  50. package/src/group-form-entry-workflow/configurable-questions/ConfigurableQuestionsSection.tsx +6 -12
  51. package/src/group-form-entry-workflow/group-display-header/GroupDisplayHeader.test.tsx +5 -5
  52. package/src/group-form-entry-workflow/group-display-header/GroupDisplayHeader.tsx +13 -21
  53. package/src/group-form-entry-workflow/group-display-header/index.ts +1 -1
  54. package/src/group-form-entry-workflow/group-search/CompactGroupResults.tsx +24 -35
  55. package/src/group-form-entry-workflow/group-search/CompactGroupSearch.tsx +13 -15
  56. package/src/group-form-entry-workflow/group-search/GroupSearch.tsx +22 -38
  57. package/src/group-form-entry-workflow/group-search-header/GroupSearchHeader.tsx +18 -25
  58. package/src/group-form-entry-workflow/group-search-header/index.ts +1 -1
  59. package/src/group-form-entry-workflow/index.ts +1 -1
  60. package/src/hooks/index.ts +7 -13
  61. package/src/hooks/useForm.ts +13 -30
  62. package/src/hooks/useFormState.ts +3 -3
  63. package/src/hooks/useGetAllForms.ts +5 -14
  64. package/src/hooks/useGetEncounter.ts +2 -2
  65. package/src/hooks/useGetPatient.ts +2 -2
  66. package/src/hooks/useGetPatients.ts +4 -6
  67. package/src/hooks/useGetSystemSetting.ts +3 -5
  68. package/src/hooks/useKeyPress.ts +5 -5
  69. package/src/hooks/usePostEndpoint.ts +8 -8
  70. package/src/hooks/useSearchEndpoint.ts +15 -38
  71. package/src/hooks/useStartVisit.ts +16 -27
  72. package/src/index.ts +8 -20
  73. package/src/patient-card/PatientCard.tsx +8 -20
  74. package/src/patient-card/index.ts +1 -1
  75. package/src/setup-tests.ts +1 -1
  76. package/tools/i18next-parser.config.js +19 -19
  77. package/webpack.config.js +1 -1
@@ -1,10 +1,6 @@
1
- import {
2
- openmrsFetch,
3
- type FetchResponse,
4
- restBaseUrl,
5
- } from "@openmrs/esm-framework";
6
- import { useCallback, useMemo } from "react";
7
- import useSWRInfinite from "swr/infinite";
1
+ import { openmrsFetch, type FetchResponse, restBaseUrl } from '@openmrs/esm-framework';
2
+ import { useCallback, useMemo } from 'react';
3
+ import useSWRInfinite from 'swr/infinite';
8
4
 
9
5
  export interface SearchResponse {
10
6
  data: Array<Record<string, unknown>> | null;
@@ -19,7 +15,7 @@ export interface SearchResponse {
19
15
  FetchResponse<{
20
16
  results: Array<Record<string, unknown>>;
21
17
  links: Array<{
22
- rel: "prev" | "next";
18
+ rel: 'prev' | 'next';
23
19
  }>;
24
20
  }>
25
21
  >
@@ -34,29 +30,18 @@ interface SearchInfiniteProps {
34
30
  resultsToFetch?: number;
35
31
  }
36
32
 
37
- const useSearchEndpointInfinite = (
38
- arg0: SearchInfiniteProps
39
- ): SearchResponse => {
40
- const {
41
- baseUrl,
42
- searchTerm,
43
- parameters,
44
- searching = true,
45
- resultsToFetch = 10,
46
- } = arg0;
33
+ const useSearchEndpointInfinite = (arg0: SearchInfiniteProps): SearchResponse => {
34
+ const { baseUrl, searchTerm, parameters, searching = true, resultsToFetch = 10 } = arg0;
47
35
 
48
36
  const getUrl = useCallback(
49
37
  (
50
38
  page: number,
51
39
  prevPageData: FetchResponse<{
52
40
  results: Array<Record<string, unknown>>;
53
- links: Array<{ rel: "prev" | "next" }>;
54
- }>
41
+ links: Array<{ rel: 'prev' | 'next' }>;
42
+ }>,
55
43
  ) => {
56
- if (
57
- prevPageData &&
58
- !prevPageData?.data?.links.some((link) => link.rel === "next")
59
- ) {
44
+ if (prevPageData && !prevPageData?.data?.links.some((link) => link.rel === 'next')) {
60
45
  return null;
61
46
  }
62
47
  let url = `${baseUrl}?q=${searchTerm}`;
@@ -78,13 +63,13 @@ const useSearchEndpointInfinite = (
78
63
  }
79
64
  return url;
80
65
  },
81
- [baseUrl, searchTerm, parameters, resultsToFetch]
66
+ [baseUrl, searchTerm, parameters, resultsToFetch],
82
67
  );
83
68
 
84
69
  const { data, isValidating, setSize, error, size } = useSWRInfinite<
85
70
  FetchResponse<{
86
71
  results: Array<Record<string, unknown>>;
87
- links: Array<{ rel: "prev" | "next" }>;
72
+ links: Array<{ rel: 'prev' | 'next' }>;
88
73
  totalCount: number;
89
74
  }>,
90
75
  Error
@@ -92,30 +77,22 @@ const useSearchEndpointInfinite = (
92
77
 
93
78
  const results = useMemo(
94
79
  () => ({
95
- data: data
96
- ? [].concat(...(data?.map((resp) => resp?.data?.results) ?? []))
97
- : null,
80
+ data: data ? [].concat(...(data?.map((resp) => resp?.data?.results) ?? [])) : null,
98
81
  isLoading: !data && !error,
99
82
  error,
100
- hasMore: data?.length
101
- ? !!data[data.length - 1].data?.links?.some(
102
- (link) => link.rel === "next"
103
- )
104
- : false,
83
+ hasMore: data?.length ? !!data[data.length - 1].data?.links?.some((link) => link.rel === 'next') : false,
105
84
  loadingNewData: isValidating,
106
85
  setPage: setSize,
107
86
  currentPage: size,
108
87
  totalResults: data?.[0]?.data?.totalCount,
109
88
  }),
110
- [data, isValidating, error, setSize, size]
89
+ [data, isValidating, error, setSize, size],
111
90
  );
112
91
 
113
92
  return results;
114
93
  };
115
94
 
116
- const useSearchCohortInfinite = ({
117
- ...props
118
- }: SearchInfiniteProps): SearchResponse => {
95
+ const useSearchCohortInfinite = ({ ...props }: SearchInfiniteProps): SearchResponse => {
119
96
  return useSearchEndpointInfinite({
120
97
  baseUrl: `${restBaseUrl}/cohortm/cohort`,
121
98
  resultsToFetch: 10,
@@ -1,16 +1,8 @@
1
- import { useCallback, useState } from "react";
2
- import { useTranslation } from "react-i18next";
3
- import {
4
- showNotification,
5
- showToast,
6
- openmrsFetch,
7
- restBaseUrl,
8
- } from "@openmrs/esm-framework";
1
+ import { useCallback, useState } from 'react';
2
+ import { useTranslation } from 'react-i18next';
3
+ import { showNotification, showToast, openmrsFetch, restBaseUrl } from '@openmrs/esm-framework';
9
4
 
10
- const useStartVisit = ({
11
- showSuccessNotification = true,
12
- showErrorNotification = true,
13
- }) => {
5
+ const useStartVisit = ({ showSuccessNotification = true, showErrorNotification = true }) => {
14
6
  const { t } = useTranslation();
15
7
  const [isSubmitting, setIsSubmitting] = useState(false);
16
8
  const [success, setSuccess] = useState(null);
@@ -24,16 +16,13 @@ const useStartVisit = ({
24
16
  if (showSuccessNotification) {
25
17
  showToast({
26
18
  critical: true,
27
- kind: "success",
28
- description: t(
29
- "visitStartedSuccessfully",
30
- `${result?.data?.visitType?.display} started successfully`
31
- ),
32
- title: t("visitStarted", "Visit started"),
19
+ kind: 'success',
20
+ description: t('visitStartedSuccessfully', `${result?.data?.visitType?.display} started successfully`),
21
+ title: t('visitStarted', 'Visit started'),
33
22
  });
34
23
  }
35
24
  },
36
- [t, showSuccessNotification]
25
+ [t, showSuccessNotification],
37
26
  );
38
27
 
39
28
  const onError = useCallback(
@@ -43,14 +32,14 @@ const useStartVisit = ({
43
32
  setError(error);
44
33
  if (showErrorNotification) {
45
34
  showNotification({
46
- title: t("startVisitError", "Error starting visit"),
47
- kind: "error",
35
+ title: t('startVisitError', 'Error starting visit'),
36
+ kind: 'error',
48
37
  critical: true,
49
38
  description: error?.message,
50
39
  });
51
40
  }
52
41
  },
53
- [t, showErrorNotification]
42
+ [t, showErrorNotification],
54
43
  );
55
44
 
56
45
  const saveVisit = useCallback(
@@ -63,21 +52,21 @@ const useStartVisit = ({
63
52
  location: data.location,
64
53
  };
65
54
  openmrsFetch(`${restBaseUrl}/visit`, {
66
- method: "POST",
55
+ method: 'POST',
67
56
  body: payload,
68
- headers: { "Content-Type": "application/json" },
57
+ headers: { 'Content-Type': 'application/json' },
69
58
  })
70
59
  .then(onSave)
71
60
  .catch(onError);
72
61
  },
73
- [onError, onSave]
62
+ [onError, onSave],
74
63
  );
75
64
 
76
65
  const updateEncounter = useCallback((data) => {
77
66
  openmrsFetch(`${restBaseUrl}/encounter/` + data.uuid, {
78
- method: "POST",
67
+ method: 'POST',
79
68
  body: { visit: data.visit },
80
- headers: { "Content-Type": "application/json" },
69
+ headers: { 'Content-Type': 'application/json' },
81
70
  });
82
71
  }, []);
83
72
 
package/src/index.ts CHANGED
@@ -1,30 +1,18 @@
1
- import {
2
- getAsyncLifecycle,
3
- defineConfigSchema,
4
- registerBreadcrumbs,
5
- } from "@openmrs/esm-framework";
6
- import { configSchema } from "./config-schema";
1
+ import { getAsyncLifecycle, defineConfigSchema, registerBreadcrumbs } from '@openmrs/esm-framework';
2
+ import { configSchema } from './config-schema';
7
3
 
8
- const moduleName = "@openmrs/esm-fast-data-entry-app";
4
+ const moduleName = '@openmrs/esm-fast-data-entry-app';
9
5
 
10
6
  const options = {
11
- featureName: "fast-data-entry-app",
7
+ featureName: 'fast-data-entry-app',
12
8
  moduleName,
13
9
  };
14
10
 
15
- export const importTranslation = require.context(
16
- "../translations",
17
- false,
18
- /.json$/,
19
- "lazy"
20
- );
11
+ export const importTranslation = require.context('../translations', false, /.json$/, 'lazy');
21
12
 
22
- export const root = getAsyncLifecycle(() => import("./Root"), options);
13
+ export const root = getAsyncLifecycle(() => import('./Root'), options);
23
14
 
24
- export const formsAppMenuLink = getAsyncLifecycle(
25
- () => import("./forms-app-menu-link"),
26
- options
27
- );
15
+ export const formsAppMenuLink = getAsyncLifecycle(() => import('./forms-app-menu-link'), options);
28
16
 
29
17
  export function startupApp() {
30
18
  defineConfigSchema(moduleName, configSchema);
@@ -32,7 +20,7 @@ export function startupApp() {
32
20
  registerBreadcrumbs([
33
21
  {
34
22
  path: `${window.spaBase}/forms`,
35
- title: "Forms",
23
+ title: 'Forms',
36
24
  parent: `${window.spaBase}/home`,
37
25
  },
38
26
  ]);
@@ -1,8 +1,8 @@
1
- import { CheckmarkOutline, WarningAlt } from "@carbon/react/icons";
2
- import { SkeletonText } from "@carbon/react";
3
- import React from "react";
4
- import useGetPatient from "../hooks/useGetPatient";
5
- import styles from "./styles.scss";
1
+ import { CheckmarkOutline, WarningAlt } from '@carbon/react/icons';
2
+ import { SkeletonText } from '@carbon/react';
3
+ import React from 'react';
4
+ import useGetPatient from '../hooks/useGetPatient';
5
+ import styles from './styles.scss';
6
6
 
7
7
  const CardContainer = ({ onClick = () => undefined, active, children }) => {
8
8
  return (
@@ -17,12 +17,7 @@ const CardContainer = ({ onClick = () => undefined, active, children }) => {
17
17
  );
18
18
  };
19
19
 
20
- const PatientCard = ({
21
- patientUuid,
22
- activePatientUuid,
23
- editEncounter,
24
- encounters,
25
- }) => {
20
+ const PatientCard = ({ patientUuid, activePatientUuid, editEncounter, encounters }) => {
26
21
  const patient = useGetPatient(patientUuid);
27
22
  const givenName = patient?.name?.[0]?.given?.[0];
28
23
  const familyName = patient?.name?.[0]?.family;
@@ -39,17 +34,10 @@ const PatientCard = ({
39
34
  const active = activePatientUuid === patientUuid;
40
35
 
41
36
  return (
42
- <CardContainer
43
- onClick={active ? () => undefined : () => editEncounter(patientUuid)}
44
- active={active}
45
- >
37
+ <CardContainer onClick={active ? () => undefined : () => editEncounter(patientUuid)} active={active}>
46
38
  <div className={styles.patientInfo}>
47
39
  <div className={styles.identifier}>{identifier}</div>
48
- <div
49
- className={`${styles.displayName} ${
50
- active && styles.activeDisplayName
51
- }`}
52
- >
40
+ <div className={`${styles.displayName} ${active && styles.activeDisplayName}`}>
53
41
  {givenName} {familyName}
54
42
  </div>
55
43
  </div>
@@ -1,3 +1,3 @@
1
- import PatientCard from "./PatientCard";
1
+ import PatientCard from './PatientCard';
2
2
 
3
3
  export default PatientCard;
@@ -1 +1 @@
1
- import "@testing-library/jest-dom/extend-expect";
1
+ import '@testing-library/jest-dom/extend-expect';
@@ -1,14 +1,14 @@
1
1
  module.exports = {
2
- contextSeparator: "_",
2
+ contextSeparator: '_',
3
3
  // Key separator used in your translation keys
4
4
 
5
5
  createOldCatalogs: false,
6
6
  // Save the \_old files
7
7
 
8
- defaultNamespace: "translations",
8
+ defaultNamespace: 'translations',
9
9
  // Default namespace used in your i18next config
10
10
 
11
- defaultValue: "",
11
+ defaultValue: '',
12
12
  // Default value to give to empty keys
13
13
  // You may also specify a function accepting the locale, namespace, and key as arguments
14
14
 
@@ -18,43 +18,43 @@ module.exports = {
18
18
  keepRemoved: false,
19
19
  // Keep keys from the catalog that are no longer in code
20
20
 
21
- keySeparator: ".",
21
+ keySeparator: '.',
22
22
  // Key separator used in your translation keys
23
23
  // If you want to use plain english keys, separators such as `.` and `:` will conflict. You might want to set `keySeparator: false` and `namespaceSeparator: false`. That way, `t('Status: Loading...')` will not think that there are a namespace and three separator dots for instance.
24
24
 
25
25
  // see below for more details
26
26
  lexers: {
27
- hbs: ["HandlebarsLexer"],
28
- handlebars: ["HandlebarsLexer"],
27
+ hbs: ['HandlebarsLexer'],
28
+ handlebars: ['HandlebarsLexer'],
29
29
 
30
- htm: ["HTMLLexer"],
31
- html: ["HTMLLexer"],
30
+ htm: ['HTMLLexer'],
31
+ html: ['HTMLLexer'],
32
32
 
33
- mjs: ["JavascriptLexer"],
34
- js: ["JavascriptLexer"], // if you're writing jsx inside .js files, change this to JsxLexer
35
- ts: ["JavascriptLexer"],
36
- jsx: ["JsxLexer"],
37
- tsx: ["JsxLexer"],
33
+ mjs: ['JavascriptLexer'],
34
+ js: ['JavascriptLexer'], // if you're writing jsx inside .js files, change this to JsxLexer
35
+ ts: ['JavascriptLexer'],
36
+ jsx: ['JsxLexer'],
37
+ tsx: ['JsxLexer'],
38
38
 
39
- default: ["JavascriptLexer"],
39
+ default: ['JavascriptLexer'],
40
40
  },
41
41
 
42
- lineEnding: "lf",
42
+ lineEnding: 'lf',
43
43
  // Control the line ending. See options at https://github.com/ryanve/eol
44
44
 
45
- locales: ["en", "am", "es", "fr", "km", "he", "ar"],
45
+ locales: ['en', 'am', 'es', 'fr', 'km', 'he', 'ar'],
46
46
  // An array of the locales in your applications
47
47
 
48
- namespaceSeparator: ":",
48
+ namespaceSeparator: ':',
49
49
  // Namespace separator used in your translation keys
50
50
  // If you want to use plain english keys, separators such as `.` and `:` will conflict. You might want to set `keySeparator: false` and `namespaceSeparator: false`. That way, `t('Status: Loading...')` will not think that there are a namespace and three separator dots for instance.
51
51
 
52
- output: "$NAMESPACE/$LOCALE.json",
52
+ output: '$NAMESPACE/$LOCALE.json',
53
53
  // Supports $LOCALE and $NAMESPACE injection
54
54
  // Supports JSON (.json) and YAML (.yml) file formats
55
55
  // Where to write the locale files relative to process.cwd()
56
56
 
57
- pluralSeparator: "_",
57
+ pluralSeparator: '_',
58
58
  // Plural separator used in your translation keys
59
59
  // If you want to use plain english keys, separators such as `_` might conflict. You might want to set `pluralSeparator` to a different string that does not occur in your keys.
60
60
 
package/webpack.config.js CHANGED
@@ -1 +1 @@
1
- module.exports = require("openmrs/default-webpack-config");
1
+ module.exports = require('openmrs/default-webpack-config');