@openmrs/esm-fast-data-entry-app 1.0.1-pre.15 → 1.0.1-pre.154

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 (135) hide show
  1. package/README.md +21 -2
  2. package/dist/101.js +1 -0
  3. package/dist/101.js.map +1 -0
  4. package/dist/132.js +1 -0
  5. package/dist/143.js +1 -0
  6. package/dist/143.js.map +1 -0
  7. package/dist/188.js +1 -0
  8. package/dist/188.js.map +1 -0
  9. package/dist/197.js +1 -0
  10. package/dist/219.js +1 -0
  11. package/dist/219.js.map +1 -0
  12. package/dist/221.js +1 -0
  13. package/dist/221.js.map +1 -0
  14. package/dist/259.js +1 -0
  15. package/dist/259.js.map +1 -0
  16. package/dist/29.js +2 -0
  17. package/dist/29.js.LICENSE.txt +3 -0
  18. package/dist/29.js.map +1 -0
  19. package/dist/300.js +1 -0
  20. package/dist/31.js +2 -0
  21. package/dist/31.js.LICENSE.txt +30 -0
  22. package/dist/31.js.map +1 -0
  23. package/dist/326.js +1 -0
  24. package/dist/326.js.map +1 -0
  25. package/dist/335.js +1 -0
  26. package/dist/367.js +1 -0
  27. package/dist/367.js.map +1 -0
  28. package/dist/480.js +1 -0
  29. package/dist/491.js +1 -0
  30. package/dist/491.js.map +1 -0
  31. package/dist/540.js +2 -0
  32. package/dist/540.js.LICENSE.txt +9 -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/773.js.LICENSE.txt +32 -0
  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.LICENSE.txt +19 -0
  52. package/dist/961.js.map +1 -0
  53. package/dist/99.js +1 -0
  54. package/dist/99.js.map +1 -0
  55. package/dist/main.js +1 -0
  56. package/dist/main.js.map +1 -0
  57. package/dist/openmrs-esm-fast-data-entry-app.js +1 -1
  58. package/dist/openmrs-esm-fast-data-entry-app.js.buildmanifest.json +811 -0
  59. package/dist/openmrs-esm-fast-data-entry-app.js.map +1 -0
  60. package/dist/routes.json +1 -0
  61. package/jest.config.json +2 -1
  62. package/package.json +42 -37
  63. package/src/CancelModal.tsx +48 -0
  64. package/src/CompleteModal.tsx +46 -0
  65. package/src/FormBootstrap.tsx +30 -3
  66. package/src/add-group-modal/AddGroupModal.tsx +77 -52
  67. package/src/add-group-modal/styles.scss +7 -3
  68. package/src/config-schema.ts +57 -0
  69. package/src/context/FormWorkflowContext.tsx +13 -1
  70. package/src/context/FormWorkflowReducer.ts +13 -3
  71. package/src/context/GroupFormWorkflowContext.tsx +43 -6
  72. package/src/context/GroupFormWorkflowReducer.ts +154 -10
  73. package/src/declarations.d.ts +4 -0
  74. package/src/empty-state/styles.scss +14 -14
  75. package/src/form-entry-workflow/FormEntryWorkflow.tsx +74 -102
  76. package/src/form-entry-workflow/form-review-card/styles.scss +9 -11
  77. package/src/form-entry-workflow/patient-banner/styles.scss +11 -12
  78. package/src/form-entry-workflow/patient-search-header/PatientSearchHeader.tsx +2 -2
  79. package/src/form-entry-workflow/patient-search-header/styles.scss +13 -10
  80. package/src/form-entry-workflow/styles.scss +13 -14
  81. package/src/form-entry-workflow/workflow-review/WorkflowReview.tsx +5 -3
  82. package/src/form-entry-workflow/workflow-review/styles.scss +0 -4
  83. package/src/forms-page/FormsPage.tsx +10 -5
  84. package/src/forms-page/forms-table/FormsTable.tsx +11 -5
  85. package/src/forms-page/forms-table/styles.scss +4 -5
  86. package/src/forms-page/styles.scss +3 -5
  87. package/src/group-form-entry-workflow/GroupFormEntryWorkflow.tsx +12 -399
  88. package/src/group-form-entry-workflow/GroupSessionWorkspace.tsx +238 -0
  89. package/src/group-form-entry-workflow/SessionDetailsForm.tsx +177 -0
  90. package/src/group-form-entry-workflow/SessionMetaWorkspace.tsx +107 -0
  91. package/src/group-form-entry-workflow/attendance-table/AttendanceTable.tsx +144 -0
  92. package/src/group-form-entry-workflow/attendance-table/index.ts +1 -0
  93. package/src/group-form-entry-workflow/configurable-questions/ConfigurableQuestionsSection.tsx +47 -0
  94. package/src/group-form-entry-workflow/group-display-header/GroupDisplayHeader.tsx +1 -9
  95. package/src/group-form-entry-workflow/group-display-header/styles.scss +20 -20
  96. package/src/group-form-entry-workflow/group-search/CompactGroupSearch.tsx +1 -1
  97. package/src/group-form-entry-workflow/group-search/GroupSearch.tsx +1 -1
  98. package/src/group-form-entry-workflow/group-search/compact-group-result.scss +16 -17
  99. package/src/group-form-entry-workflow/group-search/compact-group-search.scss +7 -8
  100. package/src/group-form-entry-workflow/group-search/group-search.scss +20 -23
  101. package/src/group-form-entry-workflow/group-search-header/GroupSearchHeader.tsx +30 -6
  102. package/src/group-form-entry-workflow/group-search-header/styles.scss +8 -8
  103. package/src/group-form-entry-workflow/styles.scss +15 -17
  104. package/src/hooks/index.ts +8 -1
  105. package/src/hooks/useForm.ts +73 -0
  106. package/src/hooks/useGetAllForms.ts +3 -2
  107. package/src/hooks/useGetEncounter.ts +2 -2
  108. package/src/hooks/useGetPatient.ts +1 -1
  109. package/src/hooks/useGetPatients.ts +34 -0
  110. package/src/hooks/useGetSystemSetting.ts +38 -0
  111. package/src/hooks/usePostEndpoint.ts +10 -4
  112. package/src/hooks/useSearchEndpoint.ts +14 -8
  113. package/src/hooks/useStartVisit.ts +93 -0
  114. package/src/index.ts +13 -65
  115. package/src/patient-card/styles.scss +3 -4
  116. package/src/routes.json +24 -0
  117. package/src/types.ts +20 -0
  118. package/tools/i18next-parser.config.js +93 -0
  119. package/translations/am.json +75 -0
  120. package/translations/ar.json +75 -0
  121. package/translations/en.json +32 -11
  122. package/translations/es.json +75 -0
  123. package/translations/fr.json +75 -0
  124. package/translations/he.json +75 -0
  125. package/translations/km.json +75 -0
  126. package/turbo.json +18 -0
  127. package/.editorconfig +0 -12
  128. package/.eslintignore +0 -2
  129. package/.eslintrc.js +0 -10
  130. package/.husky/pre-push +0 -1
  131. package/.prettierignore +0 -14
  132. package/.tx/config +0 -9
  133. package/.yarn/plugins/@yarnpkg/plugin-version.cjs +0 -550
  134. package/.yarn/versions/c1451405.yml +0 -0
  135. package/src/declarations.d.tsx +0 -2
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openmrs-esm-fast-data-entry-app.js","mappings":"4DAAIA,EACAC,ECDAC,EAIAC,EAIAC,EAIAC,EAgBAC,EAMAC,EAOAC,EA8BAC,EAMAC,EA6CAC,EAYAC,EACAC,EAWAC,E,kBClJJ,IAAIC,EAAY,CACf,UAAW,IACHC,EAAoBC,EAAE,IAAIC,MAAK,IAAM,IAASF,EAAoB,SAGvEN,EAAM,CAACS,EAAQC,KAClBJ,EAAoBK,EAAID,EACxBA,EACCJ,EAAoBM,EAAEP,EAAWI,GAC9BJ,EAAUI,KACVI,QAAQC,UAAUN,MAAK,KACxB,MAAM,IAAIO,MAAM,WAAaN,EAAS,iCAAiC,IAG1EH,EAAoBK,OAAIK,EACjBN,GAEJO,EAAO,CAACC,EAAYC,KACvB,GAAKb,EAAoBc,EAAzB,CACA,IAAIC,EAAO,UACPC,EAAWhB,EAAoBc,EAAEC,GACrC,GAAGC,GAAYA,IAAaJ,EAAY,MAAM,IAAIH,MAAM,mGAExD,OADAT,EAAoBc,EAAEC,GAAQH,EACvBZ,EAAoBiB,EAAEF,EAAMF,EALD,CAKW,EAI9Cb,EAAoBkB,EAAEC,EAAS,CAC9BzB,IAAK,IAAM,EACXiB,KAAM,IAAM,G,GC5BTS,EAA2B,CAAC,EAGhC,SAASpB,EAAoBqB,GAE5B,IAAIC,EAAeF,EAAyBC,GAC5C,QAAqBX,IAAjBY,E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gC,IAAxBkH,EAAgBlH,KAAa,CACtD,IAAIF,KAAYgI,EACZrJ,EAAoBM,EAAE+I,EAAahI,KACrCrB,EAAoB2B,EAAEN,GAAYgI,EAAYhI,IAG7CiI,GAAsBA,EAAQtJ,EAClC,CAEA,IADGkJ,GAA4BA,EAA2BC,GACrDpF,EAAIqF,EAASpF,OAAQD,IACzBxB,EAAU6G,EAASrF,GAChB/D,EAAoBM,EAAEmI,EAAiBlG,IAAYkG,EAAgBlG,IACrEkG,EAAgBlG,GAAS,KAE1BkG,EAAgBlG,GAAW,CAC5B,EAIGiH,EAAqB1G,WAAyD,6CAAIA,WAAyD,8CAAK,GACpJ0G,EAAmBtE,QAAQ+D,EAAqB5D,KAAK,KAAM,IAC3DmE,EAAmB/F,KAAOwF,EAAqB5D,KAAK,KAAMmE,EAAmB/F,KAAK4B,KAAKmE,G,KCrFvFxJ,EAAoBsE,QAAK5D,ECGzB,IAAI+I,EAAsBzJ,EAAoB,M","sources":["webpack://@openmrs/esm-fast-data-entry-app/webpack/runtime/load script","webpack://@openmrs/esm-fast-data-entry-app/webpack/runtime/consumes","webpack://@openmrs/esm-fast-data-entry-app/webpack/container-entry","webpack://@openmrs/esm-fast-data-entry-app/webpack/bootstrap","webpack://@openmrs/esm-fast-data-entry-app/webpack/runtime/compat get default export","webpack://@openmrs/esm-fast-data-entry-app/webpack/runtime/define property getters","webpack://@openmrs/esm-fast-data-entry-app/webpack/runtime/ensure chunk","webpack://@openmrs/esm-fast-data-entry-app/webpack/runtime/get javascript chunk filename","webpack://@openmrs/esm-fast-data-entry-app/webpack/runtime/global","webpack://@openmrs/esm-fast-data-entry-app/webpack/runtime/hasOwnProperty shorthand","webpack://@openmrs/esm-fast-data-entry-app/webpack/runtime/make namespace object","webpack://@openmrs/esm-fast-data-entry-app/webpack/runtime/node module decorator","webpack://@openmrs/esm-fast-data-entry-app/webpack/runtime/sharing","webpack://@openmrs/esm-fast-data-entry-app/webpack/runtime/publicPath","webpack://@openmrs/esm-fast-data-entry-app/webpack/runtime/jsonp chunk loading","webpack://@openmrs/esm-fast-data-entry-app/webpack/runtime/nonce","webpack://@openmrs/esm-fast-data-entry-app/webpack/startup"],"names":["inProgress","dataWebpackPrefix","parseVersion","versionLt","rangeToString","satisfy","findSingletonVersionKey","getInvalidSingletonVersionMessage","getSingletonVersion","warn","get","loadSingletonVersionCheckFallback","installedModules","moduleToHandlerMapping","chunkMapping","moduleMap","__webpack_require__","e","then","module","getScope","R","o","Promise","resolve","Error","undefined","init","shareScope","initScope","S","name","oldScope","I","d","exports","__webpack_module_cache__","moduleId","cachedModule","id","loaded","__webpack_modules__","call","m","c","n","getter","__esModule","a","definition","key","Object","defineProperty","enumerable","f","chunkId","all","keys","reduce","promises","u","g","globalThis","this","Function","window","obj","prop","prototype","hasOwnProperty","l","url","done","push","script","needAttach","scripts","document","getElementsByTagName","i","length","s","getAttribute","createElement","charset","timeout","nc","setAttribute","src","onScriptComplete","prev","event","onerror","onload","clearTimeout","doneFns","parentNode","removeChild","forEach","fn","setTimeout","bind","type","target","head","appendChild","r","Symbol","toStringTag","value","nmd","paths","children","initPromises","initTokens","initToken","indexOf","scope","uniqueName","register","version","factory","eager","versions","activeVersion","from","scriptUrl","importScripts","location","currentScript","test","replace","p","str","split","map","exec","apply","b","t","range","pop","requiredVersion","scopeName","msg","console","entry","promise","fallback","consumes","onFactory","onError","error","installedChunks","j","installedChunkData","reject","errorType","realSrc","message","request","webpackJsonpCallback","parentChunkLoadingFunction","data","chunkIds","moreModules","runtime","some","chunkLoadingGlobal","__webpack_exports__"],"sourceRoot":""}
@@ -0,0 +1 @@
1
+ {"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"fhir2":">=1.2","webservices.rest":"^2.2.0"},"pages":[{"component":"root","routeRegex":"forms","online":true,"offline":true}],"extensions":[{"name":"forms-app-link","slot":"app-menu-slot","component":"formsAppMenuLink","online":true,"offline":true}],"version":"1.0.1-pre.154"}
package/jest.config.json CHANGED
@@ -8,7 +8,8 @@
8
8
  "\\.(s?css)$": "identity-obj-proxy",
9
9
  "@openmrs/esm-framework": "@openmrs/esm-framework/mock",
10
10
  "^lodash-es/(.*)$": "lodash/$1",
11
- "^uuid$": "<rootDir>/node_modules/uuid/dist/index.js"
11
+ "^uuid$": "<rootDir>/node_modules/uuid/dist/index.js",
12
+ "^dexie$": "<rootDir>/node_modules/dexie"
12
13
  },
13
14
  "setupFilesAfterEnv": [
14
15
  "<rootDir>/src/setup-tests.ts"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openmrs/esm-fast-data-entry-app",
3
- "version": "1.0.1-pre.15",
3
+ "version": "1.0.1-pre.154",
4
4
  "license": "MPL-2.0",
5
5
  "description": "An OpenMRS 3.x microfrontend",
6
6
  "browser": "dist/openmrs-esm-fast-data-entry-app.js",
@@ -9,20 +9,16 @@
9
9
  "scripts": {
10
10
  "start": "openmrs develop",
11
11
  "serve": "webpack serve --mode=development",
12
- "build": "webpack --mode production",
12
+ "build": "webpack --mode production --color",
13
13
  "analyze": "webpack --mode=production --env.analyze=true",
14
- "lint": "eslint \"src/**/*.ts\" \"src/**/*.tsx\" --fix --max-warnings=0 -c .eslintrc.js",
15
- "prettier": "prettier --write \"src/**/*.{ts,tsx}\"",
14
+ "lint": "eslint \"src/**/*.ts\" \"src/**/*.tsx\" --fix --max-warnings=0",
15
+ "prettier": "prettier --write \"src/**/*.{ts,tsx}\" --list-different",
16
16
  "typescript": "tsc",
17
17
  "test": "jest --config jest.config.json --passWithNoTests",
18
- "verify": "concurrently 'yarn:lint' 'yarn:test' 'yarn:typescript'",
18
+ "verify": "turbo lint typescript test",
19
19
  "coverage": "yarn test -- --coverage ",
20
- "prepare": "husky install"
21
- },
22
- "husky": {
23
- "hooks": {
24
- "pre-commit": "pretty-quick --staged && yarn verify"
25
- }
20
+ "postinstall": "husky install",
21
+ "extract-translations": "i18next 'src/**/*.tsx' --config ./tools/i18next-parser.config.js"
26
22
  },
27
23
  "browserslist": [
28
24
  "extends browserslist-config-openmrs"
@@ -49,51 +45,60 @@
49
45
  "react": "18.x",
50
46
  "react-dom": "18.x",
51
47
  "react-i18next": "11.x",
52
- "react-router-dom": "6.x"
48
+ "react-router-dom": "6.x",
49
+ "swr": "2.x"
53
50
  },
54
51
  "devDependencies": {
55
- "@carbon/react": "^1.9.0",
52
+ "@carbon/react": "^1.37.0",
56
53
  "@openmrs/esm-framework": "next",
57
- "@swc/core": "^1.2.245",
58
- "@swc/jest": "^0.2.22",
59
- "@testing-library/dom": "^7.20.0",
60
- "@testing-library/jest-dom": "^5.16.5",
61
- "@testing-library/react": "^13.3.0",
54
+ "@swc-node/loader": "^1.3.7",
55
+ "@swc/core": "^1.3.84",
56
+ "@swc/jest": "^0.2.29",
57
+ "@testing-library/dom": "^7.31.2",
58
+ "@testing-library/jest-dom": "^5.17.0",
59
+ "@testing-library/react": "^13.4.0",
62
60
  "@testing-library/user-event": "^14.4.3",
63
- "@types/jest": "^28.1.7",
64
- "@types/react-dom": "^18.0.6",
61
+ "@types/jest": "^28.1.8",
62
+ "@types/react-dom": "^18.2.7",
65
63
  "@types/react-router-dom": "^5.3.3",
66
- "@types/testing-library__jest-dom": "^5.14.5",
67
- "@types/webpack-env": "^1.16.0",
68
- "@typescript-eslint/parser": "^5.14.0",
69
- "concurrently": "^6.2.0",
70
- "eslint": "^8.20.0",
71
- "eslint-config-prettier": "^8.3.0",
64
+ "@types/testing-library__jest-dom": "^5.14.9",
65
+ "@types/webpack-env": "^1.18.1",
66
+ "@typescript-eslint/eslint-plugin": "^6.7.0",
67
+ "@typescript-eslint/parser": "^6.7.0",
68
+ "concurrently": "^6.5.1",
69
+ "css-loader": "^6.8.1",
70
+ "eslint": "^8.49.0",
71
+ "eslint-config-prettier": "^8.10.0",
72
72
  "eslint-config-react-app": "^7.0.1",
73
- "eslint-config-ts-react-important-stuff": "^3.0.0",
74
73
  "eslint-plugin-prettier": "^4.2.1",
75
- "husky": "^8.0.1",
74
+ "husky": "^8.0.3",
76
75
  "identity-obj-proxy": "^3.0.0",
77
76
  "jest": "^28.1.3",
78
77
  "jest-cli": "^28.1.3",
79
78
  "jest-environment-jsdom": "^28.1.3",
80
79
  "lodash-es": "^4.17.21",
81
80
  "openmrs": "next",
82
- "prettier": "^2.3.0",
83
- "pretty-quick": "^3.1.0",
81
+ "prettier": "^2.8.8",
82
+ "pretty-quick": "^3.1.3",
84
83
  "react": "^18.2.0",
85
84
  "react-dom": "^18.2.0",
86
- "react-i18next": "^11.18.4",
87
- "react-router-dom": "^6.3.0",
88
- "semver": "^7.3.7",
85
+ "react-i18next": "^11.18.6",
86
+ "react-router-dom": "^6.15.0",
87
+ "semver": "^7.5.4",
89
88
  "swc-loader": "^0.2.3",
90
- "typescript": "^4.7.3",
91
- "webpack": "^5.73.0"
89
+ "swr": "^2.2.4",
90
+ "turbo": "^1.10.13",
91
+ "typescript": "^4.9.5",
92
+ "webpack": "^5.88.2",
93
+ "webpack-cli": "^5.1.4"
92
94
  },
93
- "packageManager": "yarn@3.2.2",
94
95
  "dependencies": {
96
+ "i18next": "^21.10.0",
97
+ "i18next-parser": "^6.6.0",
95
98
  "react-hook-form": "^7.34.2",
96
- "swr": "1.1.2"
99
+ "turbo": "^1.12.4",
100
+ "uuid": "^9.0.1"
97
101
  },
102
+ "packageManager": "yarn@4.1.1",
98
103
  "stableVersion": "1.0.0"
99
104
  }
@@ -0,0 +1,48 @@
1
+ import {
2
+ Button,
3
+ ComposedModal,
4
+ ModalBody,
5
+ ModalFooter,
6
+ ModalHeader,
7
+ } from "@carbon/react";
8
+ import React from "react";
9
+ import { useTranslation } from "react-i18next";
10
+
11
+ const CancelModal = ({ open, setOpen, context }) => {
12
+ const { t } = useTranslation();
13
+
14
+ const onCancel = () => setOpen(false);
15
+
16
+ const onDiscard = async () => {
17
+ await context.destroySession();
18
+ };
19
+
20
+ const onSaveAndClose = async () => {
21
+ await context.closeSession();
22
+ };
23
+
24
+ return (
25
+ <ComposedModal open={open}>
26
+ <ModalHeader>{t("areYouSure", "Are you sure?")}</ModalHeader>
27
+ <ModalBody>
28
+ {t(
29
+ "cancelExplanation",
30
+ "You will lose any unsaved changes on the current form. Do you want to discard the current session?"
31
+ )}
32
+ </ModalBody>
33
+ <ModalFooter>
34
+ <Button kind="secondary" onClick={onCancel}>
35
+ {t("cancel", "Cancel")}
36
+ </Button>
37
+ <Button kind="danger" onClick={onDiscard}>
38
+ {t("discard", "Discard")}
39
+ </Button>
40
+ <Button kind="primary" onClick={onSaveAndClose}>
41
+ {t("saveSession", "Save Session")}
42
+ </Button>
43
+ </ModalFooter>
44
+ </ComposedModal>
45
+ );
46
+ };
47
+
48
+ export default CancelModal;
@@ -0,0 +1,46 @@
1
+ import {
2
+ Button,
3
+ ComposedModal,
4
+ ModalBody,
5
+ ModalFooter,
6
+ ModalHeader,
7
+ } from "@carbon/react";
8
+ import React from "react";
9
+ import { useTranslation } from "react-i18next";
10
+
11
+ const CompleteModal = ({ open, setOpen, context, validateFirst = false }) => {
12
+ const { t } = useTranslation();
13
+
14
+ const onCancel = () => setOpen(false);
15
+
16
+ const onComplete = () => {
17
+ if (validateFirst) {
18
+ context.validateForComplete();
19
+ } else {
20
+ context.submitForComplete();
21
+ }
22
+ setOpen(false);
23
+ };
24
+
25
+ return (
26
+ <ComposedModal open={open}>
27
+ <ModalHeader>{t("areYouSure", "Are you sure?")}</ModalHeader>
28
+ <ModalBody>
29
+ {t(
30
+ "saveExplanation",
31
+ "Do you want to save the current form and exit the workflow?"
32
+ )}
33
+ </ModalBody>
34
+ <ModalFooter>
35
+ <Button kind="secondary" onClick={onCancel}>
36
+ {t("cancel", "Cancel")}
37
+ </Button>
38
+ <Button kind="primary" onClick={onComplete}>
39
+ {t("complete", "Complete")}
40
+ </Button>
41
+ </ModalFooter>
42
+ </ComposedModal>
43
+ );
44
+ };
45
+
46
+ export default CompleteModal;
@@ -1,6 +1,7 @@
1
- import React, { useEffect } from "react";
1
+ import React, { useContext, useEffect, useState } from "react";
2
2
  import { detach, ExtensionSlot } from "@openmrs/esm-framework";
3
3
  import useGetPatient from "./hooks/useGetPatient";
4
+ import GroupFormWorkflowContext from "./context/GroupFormWorkflowContext";
4
5
 
5
6
  export interface Order {
6
7
  uuid: string;
@@ -98,15 +99,22 @@ export interface Encounter {
98
99
  obs: Array<Observation>;
99
100
  orders: Array<Order>;
100
101
  }
102
+
103
+ type PreFilledQuestions = {
104
+ [key: string]: string;
105
+ };
106
+
101
107
  interface FormParams {
102
108
  formUuid: string;
103
109
  patientUuid: string;
104
110
  visitUuid?: string;
105
111
  visitTypeUuid?: string;
106
112
  encounterUuid?: string;
113
+ preFilledQuestions?: PreFilledQuestions;
107
114
  showDiscardSubmitButtons?: boolean;
108
115
  handlePostResponse?: (Encounter) => void;
109
116
  handleEncounterCreate?: (Object) => void;
117
+ handleOnValidate?: (boolean) => void;
110
118
  }
111
119
 
112
120
  const FormBootstrap = ({
@@ -117,18 +125,32 @@ const FormBootstrap = ({
117
125
  encounterUuid,
118
126
  handlePostResponse,
119
127
  handleEncounterCreate,
128
+ handleOnValidate,
120
129
  }: FormParams) => {
121
130
  const patient = useGetPatient(patientUuid);
131
+ const { activeSessionMeta } = useContext(GroupFormWorkflowContext);
122
132
 
123
133
  useEffect(() => {
124
134
  return () => detach("form-widget-slot", "form-widget-slot");
125
135
  });
126
136
 
137
+ // FIXME This should not be necessary
138
+ const [showForm, setShowForm] = useState(true);
139
+
140
+ useEffect(() => {
141
+ if (patientUuid && formUuid && patient) {
142
+ setShowForm(false);
143
+ setTimeout(() => {
144
+ setShowForm(true);
145
+ });
146
+ }
147
+ }, [patientUuid, formUuid, patient]);
148
+
127
149
  return (
128
150
  <div>
129
- {formUuid && patientUuid && patient && (
151
+ {showForm && formUuid && patientUuid && patient && (
130
152
  <ExtensionSlot
131
- extensionSlotName="form-widget-slot"
153
+ name="form-widget-slot"
132
154
  state={{
133
155
  view: "form",
134
156
  formUuid,
@@ -140,7 +162,12 @@ const FormBootstrap = ({
140
162
  closeWorkspace: () => undefined,
141
163
  handlePostResponse,
142
164
  handleEncounterCreate,
165
+ handleOnValidate,
143
166
  showDiscardSubmitButtons: false,
167
+ preFilledQuestions: {
168
+ ...activeSessionMeta,
169
+ encDate: activeSessionMeta.sessionDate,
170
+ },
144
171
  }}
145
172
  />
146
173
  )}
@@ -1,4 +1,10 @@
1
- import React, { useCallback, useContext, useEffect, useState } from "react";
1
+ import React, {
2
+ useCallback,
3
+ useContext,
4
+ useEffect,
5
+ useMemo,
6
+ useState,
7
+ } from "react";
2
8
  import {
3
9
  ComposedModal,
4
10
  Button,
@@ -7,11 +13,10 @@ import {
7
13
  ModalBody,
8
14
  TextInput,
9
15
  FormLabel,
10
- Loading,
11
16
  } from "@carbon/react";
12
- import { Add, TrashCan } from "@carbon/react/icons";
17
+ import { TrashCan } from "@carbon/react/icons";
13
18
  import { useTranslation } from "react-i18next";
14
- import { ExtensionSlot, showToast } from "@openmrs/esm-framework";
19
+ import { ExtensionSlot, showToast, usePatient } from "@openmrs/esm-framework";
15
20
  import styles from "./styles.scss";
16
21
  import GroupFormWorkflowContext from "../context/GroupFormWorkflowContext";
17
22
  import { usePostCohort } from "../hooks";
@@ -20,21 +25,41 @@ const MemExtension = React.memo(ExtensionSlot);
20
25
 
21
26
  const PatientRow = ({ patient, removePatient }) => {
22
27
  const { t } = useTranslation();
28
+ const { patient: patientInfo, error, isLoading } = usePatient(patient?.uuid);
29
+ const onClickHandler = useCallback(
30
+ () => removePatient(patient?.uuid),
31
+ [patient, removePatient]
32
+ );
33
+
34
+ const patientDisplay = useMemo(() => {
35
+ if (isLoading || error || !patientInfo) return "";
36
+
37
+ const { identifier, name } = patientInfo;
38
+ const displayIdentifier = identifier?.[0]?.value || "";
39
+ const givenNames = `${(name?.[0]?.given || []).join(" ")} ${
40
+ name?.[0]?.family || ""
41
+ }`;
42
+
43
+ return `${displayIdentifier ? `${displayIdentifier} -` : ""}${
44
+ givenNames ? ` ${givenNames}` : ""
45
+ }`.trim();
46
+ }, [isLoading, error, patientInfo]);
47
+
23
48
  return (
24
- <li key={patient.uuid} className={styles.patientRow}>
49
+ <li className={styles.patientRow}>
25
50
  <span>
26
51
  <Button
27
52
  kind="tertiary"
28
53
  size="sm"
29
54
  hasIconOnly
30
- onClick={() => removePatient(patient.uuid)}
55
+ onClick={onClickHandler}
31
56
  renderIcon={TrashCan}
32
57
  tooltipAlignment="start"
33
58
  tooltipPosition="top"
34
59
  iconDescription={t("remove", "Remove")}
35
60
  />
36
61
  </span>
37
- <span className={styles.patientName}>{patient?.display}</span>
62
+ <span className={styles.patientName}>{patientDisplay}</span>
38
63
  </li>
39
64
  );
40
65
  };
@@ -92,7 +117,12 @@ const NewGroupForm = (props) => {
92
117
  </ul>
93
118
  )}
94
119
 
95
- <FormLabel>Search for patients to add to group</FormLabel>
120
+ <FormLabel>
121
+ {t(
122
+ "searchForPatientsToAddToGroup",
123
+ "Search for patients to add to group"
124
+ )}
125
+ </FormLabel>
96
126
  <div className={styles.searchBar}>
97
127
  <MemExtension
98
128
  extensionSlotName="patient-search-bar-slot"
@@ -108,18 +138,21 @@ const NewGroupForm = (props) => {
108
138
  );
109
139
  };
110
140
 
111
- const AddGroupModal = () => {
141
+ const AddGroupModal = ({
142
+ patients = undefined,
143
+ isCreate = undefined,
144
+ groupName = "",
145
+ cohortUuid = undefined,
146
+ isOpen,
147
+ handleCancel,
148
+ onPostSubmit,
149
+ }) => {
112
150
  const { setGroup } = useContext(GroupFormWorkflowContext);
113
151
  const { t } = useTranslation();
114
- const [open, setOpen] = useState(false);
115
152
  const [errors, setErrors] = useState({});
116
- const [name, setName] = useState("");
117
- const [patientList, setPatientList] = useState([]);
118
- const { post, result, isPosting, error } = usePostCohort();
119
-
120
- const handleCancel = () => {
121
- setOpen(false);
122
- };
153
+ const [name, setName] = useState(groupName);
154
+ const [patientList, setPatientList] = useState(patients || []);
155
+ const { post, result, error } = usePostCohort();
123
156
 
124
157
  const removePatient = useCallback(
125
158
  (patientUuid: string) =>
@@ -160,8 +193,8 @@ const AddGroupModal = () => {
160
193
  const updatePatientList = useCallback(
161
194
  (patient) => {
162
195
  setPatientList((patientList) => {
163
- if (!patientList.find((p) => p.uuid === patient.uuid)) {
164
- return [...patientList, patient];
196
+ if (!patientList.find((p) => p.uuid === patient)) {
197
+ return [...patientList, { uuid: patient }];
165
198
  } else {
166
199
  return patientList;
167
200
  }
@@ -174,9 +207,13 @@ const AddGroupModal = () => {
174
207
  const handleSubmit = () => {
175
208
  if (validate()) {
176
209
  post({
210
+ uuid: cohortUuid,
177
211
  name: name,
178
212
  cohortMembers: patientList.map((p) => ({ patient: p.uuid })),
179
213
  });
214
+ if (onPostSubmit) {
215
+ onPostSubmit();
216
+ }
180
217
  }
181
218
  };
182
219
 
@@ -198,7 +235,7 @@ const AddGroupModal = () => {
198
235
  title: t("postError", "POST Error"),
199
236
  description:
200
237
  error.message ??
201
- t("unknownPostError", "An unknown error occured while saving data"),
238
+ t("unknownPostError", "An unknown error occurred while saving data"),
202
239
  });
203
240
  if (error.fieldErrors) {
204
241
  setErrors(
@@ -215,43 +252,31 @@ const AddGroupModal = () => {
215
252
 
216
253
  return (
217
254
  <div className={styles.modal}>
218
- <Button
219
- onClick={() => setOpen(true)}
220
- renderIcon={Add}
221
- iconDescription="Add"
222
- >
223
- {t("createNewGroup", "Create New Group")}
224
- </Button>
225
- <ComposedModal open={open} onClose={() => setOpen(false)}>
226
- <ModalHeader>{t("createNewGroup", "Create New Group")}</ModalHeader>
255
+ <ComposedModal open={isOpen} onClose={handleCancel}>
256
+ <ModalHeader>
257
+ {isCreate
258
+ ? t("createNewGroup", "Create New Group")
259
+ : t("editGroup", "Edit Group")}
260
+ </ModalHeader>
227
261
  <ModalBody>
228
- {result ? (
229
- <p>Group saved succesfully</p>
230
- ) : isPosting ? (
231
- <div className={styles.loading}>
232
- <Loading withOverlay={false} />
233
- <span>Saving new group...</span>
234
- </div>
235
- ) : (
236
- <NewGroupForm
237
- {...{
238
- name,
239
- setName,
240
- patientList,
241
- updatePatientList,
242
- errors,
243
- validate,
244
- removePatient,
245
- }}
246
- />
247
- )}
262
+ <NewGroupForm
263
+ {...{
264
+ name,
265
+ setName,
266
+ patientList,
267
+ updatePatientList,
268
+ errors,
269
+ validate,
270
+ removePatient,
271
+ }}
272
+ />
248
273
  </ModalBody>
249
274
  <ModalFooter>
250
- <Button kind="secondary" onClick={handleCancel} disabled={isPosting}>
275
+ <Button kind="secondary" onClick={handleCancel}>
251
276
  {t("cancel", "Cancel")}
252
277
  </Button>
253
- <Button kind="primary" onClick={handleSubmit} disabled={isPosting}>
254
- {t("createGroup", "Create Group")}
278
+ <Button kind="primary" onClick={handleSubmit}>
279
+ {isCreate ? t("createGroup", "Create Group") : t("save", "Save")}
255
280
  </Button>
256
281
  </ModalFooter>
257
282
  </ComposedModal>
@@ -1,5 +1,5 @@
1
- @use '@carbon/styles/scss/spacing';
2
1
  @use '@carbon/colors';
2
+ @use '@carbon/layout';
3
3
 
4
4
  .modal {
5
5
  :global(.cds--modal) {
@@ -17,6 +17,10 @@
17
17
  width: 100%
18
18
  }
19
19
 
20
+ .searchBar > div button {
21
+ height: auto;
22
+ }
23
+
20
24
  .formError {
21
25
  color: red;
22
26
  }
@@ -32,7 +36,7 @@
32
36
 
33
37
  .patientName {
34
38
  flex-grow: 1;
35
- padding-left: spacing.$spacing-05;
39
+ padding-left: layout.$spacing-05;
36
40
  }
37
41
 
38
42
  .loading {
@@ -41,5 +45,5 @@
41
45
  flex-direction: column;
42
46
  justify-content: center;
43
47
  align-items: center;
44
- row-gap: spacing.$spacing-05;
48
+ row-gap: layout.$spacing-05;
45
49
  }
@@ -60,6 +60,63 @@ export const configSchema = {
60
60
  },
61
61
  _default: ["ICRC Forms", "Distress Scales"],
62
62
  },
63
+ groupSessionConcepts: {
64
+ sessionName: {
65
+ _type: Type.UUID,
66
+ _description: "UUID of concept for Session Name",
67
+ _default: "e2559620-900b-4f66-ae41-0b9c4adfb654",
68
+ },
69
+ sessionDate: {
70
+ _type: Type.UUID,
71
+ _description: "UUID of concept for Session Date",
72
+ _default: "ceaca505-6dff-4940-8a43-8c060a0924d7",
73
+ },
74
+ practitionerName: {
75
+ _type: Type.UUID,
76
+ _description: "UUID of concept for Practitioner Name",
77
+ _default: "f1a2d58c-1a0e-4148-931a-aac224649fdc",
78
+ },
79
+ sessionNotes: {
80
+ _type: Type.UUID,
81
+ _description: "UUID of concept for Session Notes",
82
+ _default: "fa8fedc0-c066-4da3-8dc1-2ad8621fc480",
83
+ },
84
+ cohortId: {
85
+ _type: Type.UUID,
86
+ _description: "UUID of concept for cohort identifier",
87
+ _default: "5461f231-7e59-4be8-93a4-6d49fd13c00a",
88
+ },
89
+ cohortName: {
90
+ _type: Type.UUID,
91
+ _description: "UUID of concept for cohort name",
92
+ _default: "6029f289-92a6-4a68-80f1-3078d0152449",
93
+ },
94
+ sessionUuid: {
95
+ _type: Type.UUID,
96
+ _description: "UUID of concept for session identifier",
97
+ _default: "6a803908-8a5b-4598-adea-19358c83529a",
98
+ },
99
+ },
100
+ specificQuestions: {
101
+ _type: Type.Array,
102
+ _description: "List of specific questions to populate forms.",
103
+ _elements: {
104
+ forms: {
105
+ _type: Type.Array,
106
+ _description: "List of form UUIDs for which the question applies.",
107
+ _elements: {
108
+ _type: Type.UUID,
109
+ },
110
+ _default: [],
111
+ },
112
+ questionId: {
113
+ _type: Type.String,
114
+ _description: "ID of the question.",
115
+ _default: "",
116
+ },
117
+ },
118
+ _default: [],
119
+ },
63
120
  };
64
121
 
65
122
  export type Form = {