@aehrc/smart-forms-renderer 0.40.0 → 0.40.2

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 (108) hide show
  1. package/lib/components/FormComponents/ItemParts/ItemFieldGrid.js +6 -2
  2. package/lib/components/FormComponents/ItemParts/ItemFieldGrid.js.map +1 -1
  3. package/lib/components/FormComponents/RepeatGroup/RepeatGroup.js +3 -3
  4. package/lib/components/FormComponents/RepeatGroup/RepeatGroup.js.map +1 -1
  5. package/lib/components/FormComponents/RepeatGroup/RepeatGroupView.js +6 -6
  6. package/lib/components/FormComponents/RepeatGroup/RepeatGroupView.js.map +1 -1
  7. package/lib/components/FormComponents/RepeatItem/RepeatItem.js +5 -5
  8. package/lib/components/FormComponents/RepeatItem/RepeatItem.js.map +1 -1
  9. package/lib/components/FormComponents/Tables/GroupTable.js +10 -10
  10. package/lib/components/FormComponents/Tables/GroupTable.js.map +1 -1
  11. package/lib/components/FormComponents/Tables/GroupTableBody.d.ts +1 -1
  12. package/lib/components/FormComponents/Tables/GroupTableBody.js +3 -3
  13. package/lib/components/FormComponents/Tables/GroupTableBody.js.map +1 -1
  14. package/lib/components/FormComponents/Tables/GroupTableRow.d.ts +1 -1
  15. package/lib/components/FormComponents/Tables/GroupTableRow.js +4 -4
  16. package/lib/components/FormComponents/Tables/GroupTableRow.js.map +1 -1
  17. package/lib/components/FormComponents/Tables/GroupTableView.d.ts +1 -1
  18. package/lib/components/Renderer/FormTopLevelItem.js +13 -1
  19. package/lib/components/Renderer/FormTopLevelItem.js.map +1 -1
  20. package/lib/hooks/useDateValidation.js +2 -2
  21. package/lib/hooks/useDateValidation.js.map +1 -1
  22. package/lib/hooks/useGroupTableRows.d.ts +1 -1
  23. package/lib/hooks/useGroupTableRows.js +3 -3
  24. package/lib/hooks/useGroupTableRows.js.map +1 -1
  25. package/lib/hooks/useInitialiseGroupTable.d.ts +1 -1
  26. package/lib/hooks/useInitialiseGroupTable.js +10 -16
  27. package/lib/hooks/useInitialiseGroupTable.js.map +1 -1
  28. package/lib/hooks/useInitialiseRepeatAnswers.d.ts +1 -1
  29. package/lib/hooks/useInitialiseRepeatAnswers.js +9 -12
  30. package/lib/hooks/useInitialiseRepeatAnswers.js.map +1 -1
  31. package/lib/hooks/useInitialiseRepeatGroups.d.ts +2 -2
  32. package/lib/hooks/useInitialiseRepeatGroups.js +11 -20
  33. package/lib/hooks/useInitialiseRepeatGroups.js.map +1 -1
  34. package/lib/hooks/useRepeatGroups.js +6 -2
  35. package/lib/hooks/useRepeatGroups.js.map +1 -1
  36. package/lib/index.d.ts +1 -1
  37. package/lib/index.js +1 -1
  38. package/lib/index.js.map +1 -1
  39. package/lib/interfaces/groupTable.interface.d.ts +1 -1
  40. package/lib/interfaces/repeatGroup.interface.d.ts +1 -1
  41. package/lib/theme/palette.js +0 -4
  42. package/lib/theme/palette.js.map +1 -1
  43. package/lib/utils/groupTable.js +1 -1
  44. package/lib/utils/groupTable.js.map +1 -1
  45. package/lib/utils/index.d.ts +1 -1
  46. package/lib/utils/index.js +1 -1
  47. package/lib/utils/index.js.map +1 -1
  48. package/lib/utils/manageForm.d.ts +7 -0
  49. package/lib/utils/manageForm.js +15 -1
  50. package/lib/utils/manageForm.js.map +1 -1
  51. package/lib/utils/repeatId.d.ts +4 -0
  52. package/lib/utils/repeatId.js +93 -0
  53. package/lib/utils/repeatId.js.map +1 -0
  54. package/package.json +1 -1
  55. package/src/components/FormComponents/ItemParts/ItemFieldGrid.tsx +8 -2
  56. package/src/components/FormComponents/RepeatGroup/RepeatGroup.tsx +3 -3
  57. package/src/components/FormComponents/RepeatGroup/RepeatGroupView.tsx +6 -6
  58. package/src/components/FormComponents/RepeatItem/RepeatItem.tsx +7 -5
  59. package/src/components/FormComponents/Tables/GroupTable.tsx +13 -10
  60. package/src/components/FormComponents/Tables/GroupTableBody.tsx +5 -5
  61. package/src/components/FormComponents/Tables/GroupTableRow.tsx +5 -5
  62. package/src/components/FormComponents/Tables/GroupTableView.tsx +1 -1
  63. package/src/components/Renderer/FormTopLevelItem.tsx +33 -1
  64. package/src/hooks/useDateValidation.tsx +2 -2
  65. package/src/hooks/useGroupTableRows.ts +3 -3
  66. package/src/hooks/useInitialiseGroupTable.ts +13 -17
  67. package/src/hooks/useInitialiseRepeatAnswers.ts +9 -12
  68. package/src/hooks/useInitialiseRepeatGroups.ts +14 -25
  69. package/src/hooks/useRepeatGroups.ts +8 -4
  70. package/src/index.ts +1 -0
  71. package/src/interfaces/groupTable.interface.ts +1 -1
  72. package/src/interfaces/repeatGroup.interface.ts +1 -1
  73. package/src/stories/assets/questionnaires/QIdRemoverDebugger.ts +161 -0
  74. package/src/stories/storybookWrappers/BuildFormButtonForStorybook.tsx +1 -1
  75. package/src/stories/storybookWrappers/IdRemoverButtonForStorybook.tsx +51 -0
  76. package/src/stories/storybookWrappers/IdRemoverDebuggerWrapperForStorybook.tsx +84 -0
  77. package/src/stories/testing/IdRemoverDebuggerWrapper.stories.tsx +39 -0
  78. package/src/tests/extractObservation.test.ts +2 -5
  79. package/src/theme/palette.ts +0 -4
  80. package/src/utils/groupTable.ts +1 -1
  81. package/src/utils/index.ts +7 -1
  82. package/src/utils/manageForm.ts +28 -1
  83. package/src/utils/repeatId.ts +123 -0
  84. package/CHANGELOG.md +0 -43
  85. package/lib/hooks/useRepeatAnswers.d.ts +0 -4
  86. package/lib/hooks/useRepeatAnswers.js +0 -34
  87. package/lib/hooks/useRepeatAnswers.js.map +0 -1
  88. package/lib/interfaces/repeatItem.interface.d.ts +0 -5
  89. package/lib/interfaces/repeatItem.interface.js +0 -2
  90. package/lib/interfaces/repeatItem.interface.js.map +0 -1
  91. package/lib/utils/answerExpression.d.ts +0 -18
  92. package/lib/utils/answerExpression.js +0 -133
  93. package/lib/utils/answerExpression.js.map +0 -1
  94. package/lib/utils/dynamicValueSet.d.ts +0 -5
  95. package/lib/utils/dynamicValueSet.js +0 -96
  96. package/lib/utils/dynamicValueSet.js.map +0 -1
  97. package/lib/utils/fhirpathAsyncUtils/fhirpath-async.d.ts +0 -14
  98. package/lib/utils/fhirpathAsyncUtils/fhirpath-async.js +0 -639
  99. package/lib/utils/fhirpathAsyncUtils/fhirpath-async.js.map +0 -1
  100. package/lib/utils/fhirpathAsyncUtils/outcome-utils.d.ts +0 -3
  101. package/lib/utils/fhirpathAsyncUtils/outcome-utils.js +0 -41
  102. package/lib/utils/fhirpathAsyncUtils/outcome-utils.js.map +0 -1
  103. package/lib/utils/questionnaireStoreUtils/extractPreferredTerminologyServerUrls.d.ts +0 -3
  104. package/lib/utils/questionnaireStoreUtils/extractPreferredTerminologyServerUrls.js +0 -34
  105. package/lib/utils/questionnaireStoreUtils/extractPreferredTerminologyServerUrls.js.map +0 -1
  106. package/lib/utils/updateQr.d.ts +0 -9
  107. package/lib/utils/updateQr.js +0 -55
  108. package/lib/utils/updateQr.js.map +0 -1
@@ -1,3 +0,0 @@
1
- import type { Coding, OperationOutcome } from 'fhir/r4b';
2
- export declare function CreateOperationOutcome(severity: 'error' | 'fatal' | 'warning' | 'information', code: 'invalid' | 'structure' | 'required' | 'value' | 'invariant' | 'security' | 'login' | 'unknown' | 'expired' | 'forbidden' | 'suppressed' | 'processing' | 'not-supported' | 'duplicate' | 'multiple-matches' | 'not-found' | 'deleted' | 'too-long' | 'code-invalid' | 'extension' | 'too-costly' | 'business-rule' | 'conflict' | 'transient' | 'lock-error' | 'no-store' | 'exception' | 'timeout' | 'incomplete' | 'throttled' | 'informational', message: string, coding?: Coding, diagnostics?: string): fhir4b.OperationOutcome;
3
- export declare function logMessage(enabled: boolean, outcome: OperationOutcome, message: string, data?: any): void;
@@ -1,41 +0,0 @@
1
- // --------------------------------------------------------------------------
2
- // From: https://github.com/brianpos/fhirpathjs-async-poc/commit/950475900d09bf399574c24f142f3eeae1552fe6
3
- // Forked from: https://github.com/brianpos/fhirpathjs-async-poc
4
- // --------------------------------------------------------------------------
5
- export function CreateOperationOutcome(severity, code, message, coding, diagnostics) {
6
- const result = {
7
- resourceType: 'OperationOutcome',
8
- issue: []
9
- };
10
- const issue = {
11
- severity: severity,
12
- code: code,
13
- details: { text: message }
14
- };
15
- if (coding && issue.details)
16
- issue.details.coding = [coding];
17
- if (diagnostics)
18
- issue.diagnostics = diagnostics;
19
- result.issue.push(issue);
20
- return result;
21
- }
22
- export function logMessage(enabled, outcome, message, data) {
23
- if (enabled) {
24
- // and append it into the outcome issues
25
- const issue = {
26
- severity: 'information',
27
- code: 'informational',
28
- details: { text: message }
29
- };
30
- outcome.issue.push(issue);
31
- if (typeof data === 'string' || typeof data === 'number' || typeof data === 'boolean')
32
- issue.details.text += '' + data;
33
- if (data) {
34
- if (typeof data === 'string')
35
- issue.diagnostics = data;
36
- else
37
- issue.diagnostics = JSON.stringify(data);
38
- }
39
- }
40
- }
41
- //# sourceMappingURL=outcome-utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"outcome-utils.js","sourceRoot":"","sources":["../../../src/utils/fhirpathAsyncUtils/outcome-utils.ts"],"names":[],"mappings":"AAEA,6EAA6E;AAC7E,yGAAyG;AACzG,gEAAgE;AAChE,6EAA6E;AAE7E,MAAM,UAAU,sBAAsB,CACpC,QAAuD,EACvD,IA+BmB,EACnB,OAAe,EACf,MAAe,EACf,WAAoB;IAEpB,MAAM,MAAM,GAA4B;QACtC,YAAY,EAAE,kBAAkB;QAChC,KAAK,EAAE,EAAE;KACV,CAAC;IAEF,MAAM,KAAK,GAA0B;QACnC,QAAQ,EAAE,QAAQ;QAClB,IAAI,EAAE,IAAI;QACV,OAAO,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE;KAC3B,CAAC;IACF,IAAI,MAAM,IAAI,KAAK,CAAC,OAAO;QAAE,KAAK,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,MAAM,CAAC,CAAC;IAC7D,IAAI,WAAW;QAAE,KAAK,CAAC,WAAW,GAAG,WAAW,CAAC;IACjD,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACzB,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,UAAU,CACxB,OAAgB,EAChB,OAAyB,EACzB,OAAe,EACf,IAAU;IAEV,IAAI,OAAO,EAAE;QACX,wCAAwC;QACxC,MAAM,KAAK,GAA0B;YACnC,QAAQ,EAAE,aAAa;YACvB,IAAI,EAAE,eAAe;YACrB,OAAO,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE;SAC3B,CAAC;QACF,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC1B,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,OAAO,IAAI,KAAK,SAAS;YACnF,KAAK,CAAC,OAAQ,CAAC,IAAI,IAAI,EAAE,GAAG,IAAI,CAAC;QACnC,IAAI,IAAI,EAAE;YACR,IAAI,OAAO,IAAI,KAAK,QAAQ;gBAAE,KAAK,CAAC,WAAW,GAAG,IAAI,CAAC;;gBAClD,KAAK,CAAC,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;SAC/C;KACF;AACH,CAAC"}
@@ -1,3 +0,0 @@
1
- import type { Questionnaire } from 'fhir/r4';
2
- import type { Pages } from '../../interfaces/page.interface';
3
- export declare function extractPreferredTerminologyServerUrls(questionnaire: Questionnaire): Pages;
@@ -1,34 +0,0 @@
1
- /*
2
- * Copyright 2024 Commonwealth Scientific and Industrial Research
3
- * Organisation (CSIRO) ABN 41 687 119 230.
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
- import { constructPagesWithProperties, isPage, isPageContainer } from '../page';
18
- export function extractPreferredTerminologyServerUrls(questionnaire) {
19
- if (!questionnaire.item || questionnaire.item.length === 0) {
20
- return {};
21
- }
22
- if (!isPageContainer(questionnaire.item)) {
23
- return constructPagesWithProperties(questionnaire.item, false);
24
- }
25
- let totalPages = {};
26
- for (const topLevelItem of questionnaire.item) {
27
- const items = topLevelItem.item;
28
- const topLevelItemIsPageContainer = isPage(topLevelItem);
29
- const pages = constructPagesWithProperties(items, topLevelItemIsPageContainer);
30
- totalPages = Object.assign(Object.assign({}, totalPages), pages);
31
- }
32
- return totalPages;
33
- }
34
- //# sourceMappingURL=extractPreferredTerminologyServerUrls.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"extractPreferredTerminologyServerUrls.js","sourceRoot":"","sources":["../../../src/utils/questionnaireStoreUtils/extractPreferredTerminologyServerUrls.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,OAAO,EAAE,4BAA4B,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAEhF,MAAM,UAAU,qCAAqC,CAAC,aAA4B;IAChF,IAAI,CAAC,aAAa,CAAC,IAAI,IAAI,aAAa,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;QAC1D,OAAO,EAAE,CAAC;KACX;IAED,IAAI,CAAC,eAAe,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE;QACxC,OAAO,4BAA4B,CAAC,aAAa,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;KAChE;IAED,IAAI,UAAU,GAAG,EAAE,CAAC;IACpB,KAAK,MAAM,YAAY,IAAI,aAAa,CAAC,IAAI,EAAE;QAC7C,MAAM,KAAK,GAAG,YAAY,CAAC,IAAI,CAAC;QAChC,MAAM,2BAA2B,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC;QAEzD,MAAM,KAAK,GAAG,4BAA4B,CAAC,KAAK,EAAE,2BAA2B,CAAC,CAAC;QAC/E,UAAU,mCAAQ,UAAU,GAAK,KAAK,CAAE,CAAC;KAC1C;IAED,OAAO,UAAU,CAAC;AACpB,CAAC"}
@@ -1,9 +0,0 @@
1
- import type { Questionnaire, QuestionnaireItem, QuestionnaireResponse, QuestionnaireResponseItem } from 'fhir/r4';
2
- export type RepopulateFunction<T> = (qItem: QuestionnaireItem, qrItemOrItems: QuestionnaireResponseItem | QuestionnaireResponseItem[] | null, extraData: T) => QuestionnaireResponseItem | QuestionnaireResponseItem[] | null;
3
- /**
4
- * A generic (and safe) way to update a QuestionnaireResponse given a recursive function and a set of data i.e. Record<linkId, calculated expression values>, Record<linkId, re-populated values>
5
- * This function relies heavily on mapQItemsIndex() and getQrItemsIndex() to accurately pinpoint the locations of QR items based on their positions in the Q, taking into account repeating group answers, non-filled questions, etc
6
- *
7
- * @author Sean Fong
8
- */
9
- export declare function updateQuestionnaireResponse<T>(questionnaire: Questionnaire, questionnaireResponse: QuestionnaireResponse, recursiveUpdateFunction: RepopulateFunction<T>, extraData: T): QuestionnaireResponse;
@@ -1,55 +0,0 @@
1
- /*
2
- * Copyright 2024 Commonwealth Scientific and Industrial Research
3
- * Organisation (CSIRO) ABN 41 687 119 230.
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
- import { getQrItemsIndex, mapQItemsIndex } from './mapItem';
18
- import { qrItemHasItemsOrAnswer } from './manageForm';
19
- /**
20
- * A generic (and safe) way to update a QuestionnaireResponse given a recursive function and a set of data i.e. Record<linkId, calculated expression values>, Record<linkId, re-populated values>
21
- * This function relies heavily on mapQItemsIndex() and getQrItemsIndex() to accurately pinpoint the locations of QR items based on their positions in the Q, taking into account repeating group answers, non-filled questions, etc
22
- *
23
- * @author Sean Fong
24
- */
25
- export function updateQuestionnaireResponse(questionnaire, questionnaireResponse, recursiveUpdateFunction, extraData) {
26
- var _a;
27
- if (!questionnaire.item ||
28
- questionnaire.item.length === 0 ||
29
- !questionnaireResponse.item ||
30
- questionnaireResponse.item.length === 0) {
31
- return questionnaireResponse;
32
- }
33
- const qItemsIndexMap = mapQItemsIndex(questionnaire);
34
- const topLevelQRItemsByIndex = getQrItemsIndex(questionnaire.item, questionnaireResponse.item, qItemsIndexMap);
35
- const topLevelQrItems = [];
36
- for (const [index, topLevelQItem] of questionnaire.item.entries()) {
37
- const topLevelQRItemOrItems = (_a = topLevelQRItemsByIndex[index]) !== null && _a !== void 0 ? _a : {
38
- linkId: topLevelQItem.linkId,
39
- text: topLevelQItem.text,
40
- item: []
41
- };
42
- const updatedTopLevelQRItem = recursiveUpdateFunction(topLevelQItem, topLevelQRItemOrItems, extraData);
43
- if (Array.isArray(updatedTopLevelQRItem)) {
44
- if (updatedTopLevelQRItem.length > 0) {
45
- topLevelQrItems.push(...updatedTopLevelQRItem);
46
- }
47
- continue;
48
- }
49
- if (updatedTopLevelQRItem && qrItemHasItemsOrAnswer(updatedTopLevelQRItem)) {
50
- topLevelQrItems.push(updatedTopLevelQRItem);
51
- }
52
- }
53
- return Object.assign(Object.assign({}, questionnaireResponse), { item: topLevelQrItems });
54
- }
55
- //# sourceMappingURL=updateQr.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"updateQr.js","sourceRoot":"","sources":["../../src/utils/updateQr.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAQH,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAQtD;;;;;GAKG;AACH,MAAM,UAAU,2BAA2B,CACzC,aAA4B,EAC5B,qBAA4C,EAC5C,uBAA8C,EAC9C,SAAY;;IAEZ,IACE,CAAC,aAAa,CAAC,IAAI;QACnB,aAAa,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC;QAC/B,CAAC,qBAAqB,CAAC,IAAI;QAC3B,qBAAqB,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,EACvC;QACA,OAAO,qBAAqB,CAAC;KAC9B;IAED,MAAM,cAAc,GAAG,cAAc,CAAC,aAAa,CAAC,CAAC;IACrD,MAAM,sBAAsB,GAAG,eAAe,CAC5C,aAAa,CAAC,IAAI,EAClB,qBAAqB,CAAC,IAAI,EAC1B,cAAc,CACf,CAAC;IAEF,MAAM,eAAe,GAAG,EAAE,CAAC;IAC3B,KAAK,MAAM,CAAC,KAAK,EAAE,aAAa,CAAC,IAAI,aAAa,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE;QACjE,MAAM,qBAAqB,GAAG,MAAA,sBAAsB,CAAC,KAAK,CAAC,mCAAI;YAC7D,MAAM,EAAE,aAAa,CAAC,MAAM;YAC5B,IAAI,EAAE,aAAa,CAAC,IAAI;YACxB,IAAI,EAAE,EAAE;SACT,CAAC;QAEF,MAAM,qBAAqB,GAAG,uBAAuB,CACnD,aAAa,EACb,qBAAqB,EACrB,SAAS,CACV,CAAC;QAEF,IAAI,KAAK,CAAC,OAAO,CAAC,qBAAqB,CAAC,EAAE;YACxC,IAAI,qBAAqB,CAAC,MAAM,GAAG,CAAC,EAAE;gBACpC,eAAe,CAAC,IAAI,CAAC,GAAG,qBAAqB,CAAC,CAAC;aAChD;YACD,SAAS;SACV;QAED,IAAI,qBAAqB,IAAI,sBAAsB,CAAC,qBAAqB,CAAC,EAAE;YAC1E,eAAe,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;SAC7C;KACF;IAED,uCAAY,qBAAqB,KAAE,IAAI,EAAE,eAAe,IAAG;AAC7D,CAAC"}