@aehrc/smart-forms-renderer 0.34.1 → 0.34.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 (88) hide show
  1. package/package.json +1 -1
  2. package/lib/components/FormComponents/ChoiceItems/CheckboxFields.d.ts +0 -11
  3. package/lib/components/FormComponents/ChoiceItems/CheckboxFields.js +0 -41
  4. package/lib/components/FormComponents/ChoiceItems/CheckboxFields.js.map +0 -1
  5. package/lib/components/FormComponents/ChoiceItems/CheckboxOptionFields.d.ts +0 -11
  6. package/lib/components/FormComponents/ChoiceItems/CheckboxOptionFields.js +0 -41
  7. package/lib/components/FormComponents/ChoiceItems/CheckboxOptionFields.js.map +0 -1
  8. package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerValueSetView.d.ts +0 -13
  9. package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerValueSetView.js +0 -46
  10. package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerValueSetView.js.map +0 -1
  11. package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxFields.d.ts +0 -11
  12. package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxFields.js +0 -41
  13. package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxFields.js.map +0 -1
  14. package/lib/components/FormComponents/DateTimeItem/DateTimeField.d.ts +0 -12
  15. package/lib/components/FormComponents/DateTimeItem/DateTimeField.js +0 -34
  16. package/lib/components/FormComponents/DateTimeItem/DateTimeField.js.map +0 -1
  17. package/lib/components/FormComponents/DateTimeItem/DateTimeItem.d.ts +0 -9
  18. package/lib/components/FormComponents/DateTimeItem/DateTimeItem.js +0 -60
  19. package/lib/components/FormComponents/DateTimeItem/DateTimeItem.js.map +0 -1
  20. package/lib/components/FormComponents/GroupItem/NextTabButtonWrapper.d.ts +0 -8
  21. package/lib/components/FormComponents/GroupItem/NextTabButtonWrapper.js +0 -57
  22. package/lib/components/FormComponents/GroupItem/NextTabButtonWrapper.js.map +0 -1
  23. package/lib/components/FormComponents/ItemParts/RadioAnswerOptionButtons.d.ts +0 -8
  24. package/lib/components/FormComponents/ItemParts/RadioAnswerOptionButtons.js +0 -37
  25. package/lib/components/FormComponents/ItemParts/RadioAnswerOptionButtons.js.map +0 -1
  26. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxFields.d.ts +0 -18
  27. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxFields.js +0 -48
  28. package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxFields.js.map +0 -1
  29. package/lib/components/StoryWrappers/BuildFormWrapper.d.ts +0 -7
  30. package/lib/components/StoryWrappers/BuildFormWrapper.js +0 -57
  31. package/lib/components/StoryWrappers/BuildFormWrapper.js.map +0 -1
  32. package/lib/hooks/useDisplayCalculatedExpression.d.ts +0 -3
  33. package/lib/hooks/useDisplayCalculatedExpression.js +0 -40
  34. package/lib/hooks/useDisplayCalculatedExpression.js.map +0 -1
  35. package/lib/hooks/useInitaliseFhirClient.d.ts +0 -1
  36. package/lib/hooks/useInitaliseFhirClient.js +0 -55
  37. package/lib/hooks/useInitaliseFhirClient.js.map +0 -1
  38. package/lib/hooks/useInitialiseRenderer.d.ts +0 -4
  39. package/lib/hooks/useInitialiseRenderer.js +0 -62
  40. package/lib/hooks/useInitialiseRenderer.js.map +0 -1
  41. package/lib/hooks/useNextPreviousVisibleTabs.d.ts +0 -6
  42. package/lib/hooks/useNextPreviousVisibleTabs.js +0 -63
  43. package/lib/hooks/useNextPreviousVisibleTabs.js.map +0 -1
  44. package/lib/hooks/useQueryClient.d.ts +0 -3
  45. package/lib/hooks/useQueryClient.js +0 -29
  46. package/lib/hooks/useQueryClient.js.map +0 -1
  47. package/lib/hooks/useRepeatitemState.d.ts +0 -0
  48. package/lib/hooks/useRepeatitemState.js +0 -2
  49. package/lib/hooks/useRepeatitemState.js.map +0 -1
  50. package/lib/interfaces/repopulateItems.interface.d.ts +0 -0
  51. package/lib/interfaces/repopulateItems.interface.js +0 -2
  52. package/lib/interfaces/repopulateItems.interface.js.map +0 -1
  53. package/lib/setup-jest.js +0 -1
  54. package/lib/stories/InitialiseFormWrapperForStorybook.d.ts +0 -29
  55. package/lib/stories/InitialiseFormWrapperForStorybook.js +0 -65
  56. package/lib/stories/InitialiseFormWrapperForStorybook.js.map +0 -1
  57. package/lib/stories/MedicalHistoryTable.stories.js +0 -45
  58. package/lib/stories/SmartFormsRenderer.stories.js +0 -117
  59. package/lib/stories/StorybookWrappers/BuildFormButtonForStorybook.d.ts +0 -8
  60. package/lib/stories/StorybookWrappers/BuildFormButtonForStorybook.js +0 -44
  61. package/lib/stories/StorybookWrappers/BuildFormButtonForStorybook.js.map +0 -1
  62. package/lib/stories/StorybookWrappers/BuildFormButtonTesterWrapperForStorybook.d.ts +0 -18
  63. package/lib/stories/StorybookWrappers/BuildFormButtonTesterWrapperForStorybook.js +0 -48
  64. package/lib/stories/StorybookWrappers/BuildFormButtonTesterWrapperForStorybook.js.map +0 -1
  65. package/lib/stories/StorybookWrappers/PrePopButtonForStorybook.d.ts +0 -7
  66. package/lib/stories/StorybookWrappers/PrePopButtonForStorybook.js +0 -32
  67. package/lib/stories/StorybookWrappers/PrePopButtonForStorybook.js.map +0 -1
  68. package/lib/stories/StorybookWrappers/PrePopWrapperForStorybook.d.ts +0 -21
  69. package/lib/stories/StorybookWrappers/PrePopWrapperForStorybook.js +0 -83
  70. package/lib/stories/StorybookWrappers/PrePopWrapperForStorybook.js.map +0 -1
  71. package/lib/stories/StorybookWrappers/populateCallbackForStorybook.d.ts +0 -8
  72. package/lib/stories/StorybookWrappers/populateCallbackForStorybook.js +0 -46
  73. package/lib/stories/StorybookWrappers/populateCallbackForStorybook.js.map +0 -1
  74. package/lib/stories/index.d.ts +0 -1
  75. package/lib/stories/index.js +0 -18
  76. package/lib/stories/index.js.map +0 -1
  77. package/lib/utils/buildForm.d.ts +0 -8
  78. package/lib/utils/buildForm.js +0 -26
  79. package/lib/utils/buildForm.js.map +0 -1
  80. package/lib/utils/buildForms.d.ts +0 -0
  81. package/lib/utils/buildForms.js +0 -2
  82. package/lib/utils/buildForms.js.map +0 -1
  83. /package/lib/stories/{StorybookWrappers → storybookWrappers}/InitialiseFormWrapperForStorybook.d.ts +0 -0
  84. /package/lib/stories/{StorybookWrappers → storybookWrappers}/InitialiseFormWrapperForStorybook.js +0 -0
  85. /package/lib/stories/{StorybookWrappers → storybookWrappers}/InitialiseFormWrapperForStorybook.js.map +0 -0
  86. /package/lib/stories/{StorybookWrappers → storybookWrappers}/index.d.ts +0 -0
  87. /package/lib/stories/{StorybookWrappers → storybookWrappers}/index.js +0 -0
  88. /package/lib/stories/{StorybookWrappers → storybookWrappers}/index.js.map +0 -0
@@ -1,117 +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
- */ import { SmartFormsRenderer } from '../components';
17
- import Q715Json from './assets/Qs-and-QRs/Q715.json';
18
- import R715Json from './assets/Qs-and-QRs/R715.json';
19
- import QTestGridJson from './assets/Qs-and-QRs/QTestGrid.json';
20
- import RTestGridJson from './assets/Qs-and-QRs/RTestGrid.json';
21
- import QDev715Json from './assets/Qs-and-QRs/QDev715.json';
22
- // More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
23
- const meta = {
24
- title: 'Component/SmartFormsRenderer',
25
- component: SmartFormsRenderer,
26
- // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/react/writing-docs/autodocs
27
- tags: []
28
- };
29
- const Q715 = Q715Json;
30
- const R715 = R715Json;
31
- const QTestGrid = QTestGridJson;
32
- const RTestGrid = RTestGridJson;
33
- const QDev715 = QDev715Json;
34
- export default meta;
35
- // More on writing stories with args: https://storybook.js.org/docs/react/writing-stories/args
36
- export const Form715 = {
37
- args: {
38
- questionnaire: Q715
39
- }
40
- };
41
- export const Form715WithResponse = {
42
- args: {
43
- questionnaire: Q715,
44
- questionnaireResponse: R715
45
- }
46
- };
47
- export const FormDev715 = {
48
- args: {
49
- questionnaire: QDev715
50
- }
51
- };
52
- export const FormTestGrid = {
53
- args: {
54
- questionnaire: QTestGrid
55
- }
56
- };
57
- export const FormTestGridWithResponse = {
58
- args: {
59
- questionnaire: QTestGrid,
60
- questionnaireResponse: RTestGrid,
61
- additionalVariables: {}
62
- }
63
- };
64
- export const QTestGridWithResponseAddFhirPath = {
65
- args: {
66
- questionnaire: QTestGrid,
67
- questionnaireResponse: RTestGrid,
68
- additionalVariables: {
69
- addVar1: {
70
- url: 'http://hl7.org/fhir/StructureDefinition/variable',
71
- valueExpression: {
72
- name: 'addVar1',
73
- language: 'text/fhirpath',
74
- expression: "%resource.item.where(linkId='grid').item.where(linkId='1').item.where(linkId='1.1').item.where(linkId='1.1.1').answer.value"
75
- }
76
- }
77
- }
78
- }
79
- };
80
- export const QTestGridWithResponseAddXFhirQuery = {
81
- args: {
82
- questionnaire: QTestGrid,
83
- questionnaireResponse: RTestGrid,
84
- additionalVariables: {
85
- addVar1: {
86
- url: 'http://hl7.org/fhir/StructureDefinition/variable',
87
- valueExpression: {
88
- name: 'addVar1',
89
- language: 'text/fhirpath',
90
- expression: "%resource.item.where(linkId='grid').item.where(linkId='1').item.where(linkId='1.1').item.where(linkId='1.1.1').answer.value"
91
- }
92
- },
93
- addVar2: {
94
- url: 'http://hl7.org/fhir/StructureDefinition/variable',
95
- valueExpression: {
96
- name: 'addVar2',
97
- language: 'application/x-fhir-query',
98
- expression: 'Condition?patient={{%patient.id}}'
99
- }
100
- }
101
- }
102
- }
103
- };
104
- export const QTestGridWithResponseReadOnly = {
105
- args: {
106
- questionnaire: QTestGrid,
107
- questionnaireResponse: RTestGrid,
108
- readOnly: true
109
- }
110
- };
111
- export const Form715WithResponseReadOnly = {
112
- args: {
113
- questionnaire: Q715,
114
- questionnaireResponse: R715,
115
- readOnly: true
116
- }
117
- };
@@ -1,8 +0,0 @@
1
- import React from 'react';
2
- import type { Questionnaire, QuestionnaireResponse } from 'fhir/r4';
3
- interface BuildFormButtonProps {
4
- questionnaire: Questionnaire;
5
- questionnaireResponse?: QuestionnaireResponse;
6
- }
7
- declare function BuildFormButtonForStorybook(props: BuildFormButtonProps): React.JSX.Element;
8
- export default BuildFormButtonForStorybook;
@@ -1,44 +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
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
- return new (P || (P = Promise))(function (resolve, reject) {
20
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
21
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
23
- step((generator = generator.apply(thisArg, _arguments || [])).next());
24
- });
25
- };
26
- // @ts-ignore
27
- import React from 'react';
28
- import { Box, IconButton, Tooltip } from '@mui/material';
29
- import Iconify from '../../components/Iconify/Iconify';
30
- import { buildForm } from '../../utils';
31
- function BuildFormButtonForStorybook(props) {
32
- const { questionnaire, questionnaireResponse } = props;
33
- function handleBuildForm() {
34
- return __awaiter(this, void 0, void 0, function* () {
35
- yield buildForm(questionnaire, questionnaireResponse);
36
- });
37
- }
38
- return (React.createElement(Box, { display: "flex", mb: 0.5, alignItems: "center", columnGap: 3 },
39
- React.createElement(Tooltip, { title: "Build form with questionnaire response", placement: "right" },
40
- React.createElement(IconButton, { onClick: handleBuildForm, size: "small", color: "primary" },
41
- React.createElement(Iconify, { icon: "ph:hammer", sx: { mb: 0.5 } })))));
42
- }
43
- export default BuildFormButtonForStorybook;
44
- //# sourceMappingURL=BuildFormButtonForStorybook.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BuildFormButtonForStorybook.js","sourceRoot":"","sources":["../../../src/stories/StorybookWrappers/BuildFormButtonForStorybook.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;;;;;;;;;;AAEH,aAAa;AACb,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,OAAO,MAAM,kCAAkC,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAOxC,SAAS,2BAA2B,CAAC,KAA2B;IAC9D,MAAM,EAAE,aAAa,EAAE,qBAAqB,EAAE,GAAG,KAAK,CAAC;IAEvD,SAAe,eAAe;;YAC5B,MAAM,SAAS,CAAC,aAAa,EAAE,qBAAqB,CAAC,CAAC;QACxD,CAAC;KAAA;IAED,OAAO,CACL,oBAAC,GAAG,IAAC,OAAO,EAAC,MAAM,EAAC,EAAE,EAAE,GAAG,EAAE,UAAU,EAAC,QAAQ,EAAC,SAAS,EAAE,CAAC;QAC3D,oBAAC,OAAO,IAAC,KAAK,EAAC,wCAAwC,EAAC,SAAS,EAAC,OAAO;YACvE,oBAAC,UAAU,IAAC,OAAO,EAAE,eAAe,EAAE,IAAI,EAAC,OAAO,EAAC,KAAK,EAAC,SAAS;gBAChE,oBAAC,OAAO,IAAC,IAAI,EAAC,WAAW,EAAC,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,GAAI,CAClC,CACL,CACN,CACP,CAAC;AACJ,CAAC;AAED,eAAe,2BAA2B,CAAC"}
@@ -1,18 +0,0 @@
1
- import React from 'react';
2
- import type { Questionnaire, QuestionnaireResponse } from 'fhir/r4';
3
- interface BuildFormButtonTesterWrapperForStorybookProps {
4
- questionnaire: Questionnaire;
5
- questionnaireResponse?: QuestionnaireResponse;
6
- }
7
- /**
8
- * This is a demo wrapper which initialises the BaseRenderer with the passed in questionnaire using useBuildForm.
9
- * It also provides a button to build the form with the passed in questionnaire + questionnaireResponse.
10
- * It was done as a two-step process for demo purposes.
11
- *
12
- * Use this pattern if you already have a pre-populated/pre-filled/draft response.
13
- * If you want to pre-pop on the fly, see https://github.com/aehrc/smart-forms/blob/main/packages/smart-forms-renderer/src/stories/StorybookWrappers/PrePopWrapperForStorybook.tsx instead
14
- *
15
- * @author Sean Fong
16
- */
17
- declare function BuildFormButtonTesterWrapperForStorybook(props: BuildFormButtonTesterWrapperForStorybookProps): React.JSX.Element;
18
- export default BuildFormButtonTesterWrapperForStorybook;
@@ -1,48 +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
- // @ts-ignore
18
- import React from 'react';
19
- import { BaseRenderer } from '../../components';
20
- import { QueryClientProvider } from '@tanstack/react-query';
21
- import { RendererThemeProvider } from '../../theme';
22
- import { useBuildForm, useRendererQueryClient } from '../../hooks';
23
- import BuildFormButtonForStorybook from './BuildFormButtonForStorybook';
24
- /**
25
- * This is a demo wrapper which initialises the BaseRenderer with the passed in questionnaire using useBuildForm.
26
- * It also provides a button to build the form with the passed in questionnaire + questionnaireResponse.
27
- * It was done as a two-step process for demo purposes.
28
- *
29
- * Use this pattern if you already have a pre-populated/pre-filled/draft response.
30
- * If you want to pre-pop on the fly, see https://github.com/aehrc/smart-forms/blob/main/packages/smart-forms-renderer/src/stories/StorybookWrappers/PrePopWrapperForStorybook.tsx instead
31
- *
32
- * @author Sean Fong
33
- */
34
- function BuildFormButtonTesterWrapperForStorybook(props) {
35
- const { questionnaire, questionnaireResponse } = props;
36
- const queryClient = useRendererQueryClient();
37
- const isBuilding = useBuildForm(questionnaire);
38
- if (isBuilding) {
39
- return React.createElement("div", null, "Loading...");
40
- }
41
- return (React.createElement(RendererThemeProvider, null,
42
- React.createElement(QueryClientProvider, { client: queryClient },
43
- React.createElement("div", null,
44
- React.createElement(BuildFormButtonForStorybook, { questionnaire: questionnaire, questionnaireResponse: questionnaireResponse }),
45
- React.createElement(BaseRenderer, null)))));
46
- }
47
- export default BuildFormButtonTesterWrapperForStorybook;
48
- //# sourceMappingURL=BuildFormButtonTesterWrapperForStorybook.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BuildFormButtonTesterWrapperForStorybook.js","sourceRoot":"","sources":["../../../src/stories/StorybookWrappers/BuildFormButtonTesterWrapperForStorybook.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,aAAa;AACb,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,2BAA2B,MAAM,+BAA+B,CAAC;AAOxE;;;;;;;;;GASG;AACH,SAAS,wCAAwC,CAC/C,KAAoD;IAEpD,MAAM,EAAE,aAAa,EAAE,qBAAqB,EAAE,GAAG,KAAK,CAAC;IAEvD,MAAM,WAAW,GAAG,sBAAsB,EAAE,CAAC;IAE7C,MAAM,UAAU,GAAG,YAAY,CAAC,aAAa,CAAC,CAAC;IAE/C,IAAI,UAAU,EAAE;QACd,OAAO,8CAAqB,CAAC;KAC9B;IAED,OAAO,CACL,oBAAC,qBAAqB;QACpB,oBAAC,mBAAmB,IAAC,MAAM,EAAE,WAAW;YACtC;gBACE,oBAAC,2BAA2B,IAC1B,aAAa,EAAE,aAAa,EAC5B,qBAAqB,EAAE,qBAAqB,GAC5C;gBACF,oBAAC,YAAY,OAAG,CACZ,CACc,CACA,CACzB,CAAC;AACJ,CAAC;AAED,eAAe,wCAAwC,CAAC"}
@@ -1,7 +0,0 @@
1
- import React from 'react';
2
- interface PrePopButtonForStorybookProps {
3
- isPopulating: boolean;
4
- onPopulate: () => void;
5
- }
6
- declare function PrePopButtonForStorybook(props: PrePopButtonForStorybookProps): React.JSX.Element;
7
- export default PrePopButtonForStorybook;
@@ -1,32 +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
- // @ts-ignore
18
- import React from 'react';
19
- import { Box, CircularProgress, Fade, IconButton, Tooltip } from '@mui/material';
20
- import CloudDownloadIcon from '@mui/icons-material/CloudDownload';
21
- import Typography from '@mui/material/Typography';
22
- function PrePopButtonForStorybook(props) {
23
- const { isPopulating, onPopulate } = props;
24
- return (React.createElement(Box, { display: "flex", mb: 0.5, alignItems: "center", columnGap: 3 },
25
- React.createElement(Tooltip, { title: "Pre-populate form", placement: "right" },
26
- React.createElement("span", null,
27
- React.createElement(IconButton, { disabled: isPopulating, onClick: onPopulate, size: "small", color: "primary" }, isPopulating ? (React.createElement(CircularProgress, { size: 20, color: "inherit", sx: { mb: 0.5 } })) : (React.createElement(CloudDownloadIcon, null))))),
28
- isPopulating ? (React.createElement(Fade, { in: true, timeout: 100 },
29
- React.createElement(Typography, { variant: "body2", color: "text.secondary" }, "Pre-populating form..."))) : null));
30
- }
31
- export default PrePopButtonForStorybook;
32
- //# sourceMappingURL=PrePopButtonForStorybook.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PrePopButtonForStorybook.js","sourceRoot":"","sources":["../../../src/stories/StorybookWrappers/PrePopButtonForStorybook.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,aAAa;AACb,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,GAAG,EAAE,gBAAgB,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACjF,OAAO,iBAAiB,MAAM,mCAAmC,CAAC;AAClE,OAAO,UAAU,MAAM,0BAA0B,CAAC;AAOlD,SAAS,wBAAwB,CAAC,KAAoC;IACpE,MAAM,EAAE,YAAY,EAAE,UAAU,EAAE,GAAG,KAAK,CAAC;IAE3C,OAAO,CACL,oBAAC,GAAG,IAAC,OAAO,EAAC,MAAM,EAAC,EAAE,EAAE,GAAG,EAAE,UAAU,EAAC,QAAQ,EAAC,SAAS,EAAE,CAAC;QAC3D,oBAAC,OAAO,IAAC,KAAK,EAAC,mBAAmB,EAAC,SAAS,EAAC,OAAO;YAClD;gBACE,oBAAC,UAAU,IAAC,QAAQ,EAAE,YAAY,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAC,OAAO,EAAC,KAAK,EAAC,SAAS,IAClF,YAAY,CAAC,CAAC,CAAC,CACd,oBAAC,gBAAgB,IAAC,IAAI,EAAE,EAAE,EAAE,KAAK,EAAC,SAAS,EAAC,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,GAAI,CAChE,CAAC,CAAC,CAAC,CACF,oBAAC,iBAAiB,OAAG,CACtB,CACU,CACR,CACC;QACT,YAAY,CAAC,CAAC,CAAC,CACd,oBAAC,IAAI,IAAC,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG;YAC1B,oBAAC,UAAU,IAAC,OAAO,EAAC,OAAO,EAAC,KAAK,EAAC,gBAAgB,6BAErC,CACR,CACR,CAAC,CAAC,CAAC,IAAI,CACJ,CACP,CAAC;AACJ,CAAC;AAED,eAAe,wBAAwB,CAAC"}
@@ -1,21 +0,0 @@
1
- import React from 'react';
2
- import type { Patient, Practitioner, Questionnaire } from 'fhir/r4';
3
- import type Client from 'fhirclient/lib/Client';
4
- interface PrePopWrapperForStorybookProps {
5
- questionnaire: Questionnaire;
6
- fhirClient: Client;
7
- patient: Patient;
8
- user: Practitioner;
9
- }
10
- /**
11
- * This is a demo wrapper which initialises the BaseRenderer with the passed in questionnaire using useBuildForm.
12
- * It also provides a button to pre-populate the questionnaire on the fly using populateQuestionnaire() from '@aehrc/sdc-populate'.
13
- * This does in-app population and you have to define your own callback function to retrieve resources from your source server.
14
- *
15
- * Use this pattern if you do not have a pre-populated/pre-filled/draft response and want to pre-populate on the fly.
16
- * If you already have a questionnaireResponse, see https://github.com/aehrc/smart-forms/blob/main/packages/smart-forms-renderer/src/stories/StorybookWrappers/BuildFormButtonTesterWrapperForStorybook.tsx instead
17
- *
18
- * @author Sean Fong
19
- */
20
- declare function PrePopWrapperForStorybook(props: PrePopWrapperForStorybookProps): React.JSX.Element;
21
- export default PrePopWrapperForStorybook;
@@ -1,83 +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
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
- return new (P || (P = Promise))(function (resolve, reject) {
20
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
21
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
23
- step((generator = generator.apply(thisArg, _arguments || [])).next());
24
- });
25
- };
26
- // @ts-ignore
27
- import React, { useState } from 'react';
28
- import { BaseRenderer } from '../../components';
29
- import { QueryClientProvider } from '@tanstack/react-query';
30
- import { RendererThemeProvider } from '../../theme';
31
- import { useBuildForm, useRendererQueryClient } from '../../hooks';
32
- import PrePopButtonForStorybook from './PrePopButtonForStorybook';
33
- import { populateQuestionnaire } from '@aehrc/sdc-populate';
34
- import { fetchResourceCallback } from './populateCallbackForStorybook';
35
- import { buildForm } from '../../utils';
36
- /**
37
- * This is a demo wrapper which initialises the BaseRenderer with the passed in questionnaire using useBuildForm.
38
- * It also provides a button to pre-populate the questionnaire on the fly using populateQuestionnaire() from '@aehrc/sdc-populate'.
39
- * This does in-app population and you have to define your own callback function to retrieve resources from your source server.
40
- *
41
- * Use this pattern if you do not have a pre-populated/pre-filled/draft response and want to pre-populate on the fly.
42
- * If you already have a questionnaireResponse, see https://github.com/aehrc/smart-forms/blob/main/packages/smart-forms-renderer/src/stories/StorybookWrappers/BuildFormButtonTesterWrapperForStorybook.tsx instead
43
- *
44
- * @author Sean Fong
45
- */
46
- function PrePopWrapperForStorybook(props) {
47
- const { questionnaire, fhirClient, patient, user } = props;
48
- const [isPopulating, setIsPopulating] = useState(false);
49
- const isBuilding = useBuildForm(questionnaire);
50
- const queryClient = useRendererQueryClient();
51
- function handlePrepopulate() {
52
- setIsPopulating(true);
53
- populateQuestionnaire({
54
- questionnaire: questionnaire,
55
- fetchResourceCallback: fetchResourceCallback,
56
- requestConfig: {
57
- clientEndpoint: fhirClient.state.serverUrl,
58
- authToken: null
59
- },
60
- patient: patient,
61
- user: user
62
- }).then(({ populateSuccess, populateResult }) => __awaiter(this, void 0, void 0, function* () {
63
- if (!populateSuccess || !populateResult) {
64
- setIsPopulating(false);
65
- return;
66
- }
67
- const { populatedResponse } = populateResult;
68
- // Call to buildForm to pre-populate the QR which repaints the entire BaseRenderer view
69
- yield buildForm(questionnaire, populatedResponse);
70
- setIsPopulating(false);
71
- }));
72
- }
73
- if (isBuilding) {
74
- return React.createElement("div", null, "Loading...");
75
- }
76
- return (React.createElement(RendererThemeProvider, null,
77
- React.createElement(QueryClientProvider, { client: queryClient },
78
- React.createElement("div", null,
79
- React.createElement(PrePopButtonForStorybook, { isPopulating: isPopulating, onPopulate: handlePrepopulate }),
80
- isPopulating ? null : React.createElement(BaseRenderer, null)))));
81
- }
82
- export default PrePopWrapperForStorybook;
83
- //# sourceMappingURL=PrePopWrapperForStorybook.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PrePopWrapperForStorybook.js","sourceRoot":"","sources":["../../../src/stories/StorybookWrappers/PrePopWrapperForStorybook.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;;;;;;;;;;AAEH,aAAa;AACb,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAExC,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAEnE,OAAO,wBAAwB,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AASxC;;;;;;;;;GASG;AACH,SAAS,yBAAyB,CAAC,KAAqC;IACtE,MAAM,EAAE,aAAa,EAAE,UAAU,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC;IAE3D,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAExD,MAAM,UAAU,GAAG,YAAY,CAAC,aAAa,CAAC,CAAC;IAE/C,MAAM,WAAW,GAAG,sBAAsB,EAAE,CAAC;IAE7C,SAAS,iBAAiB;QACxB,eAAe,CAAC,IAAI,CAAC,CAAC;QAEtB,qBAAqB,CAAC;YACpB,aAAa,EAAE,aAAa;YAC5B,qBAAqB,EAAE,qBAAqB;YAC5C,aAAa,EAAE;gBACb,cAAc,EAAE,UAAU,CAAC,KAAK,CAAC,SAAS;gBAC1C,SAAS,EAAE,IAAI;aAChB;YACD,OAAO,EAAE,OAAO;YAChB,IAAI,EAAE,IAAI;SACX,CAAC,CAAC,IAAI,CAAC,CAAO,EAAE,eAAe,EAAE,cAAc,EAAE,EAAE,EAAE;YACpD,IAAI,CAAC,eAAe,IAAI,CAAC,cAAc,EAAE;gBACvC,eAAe,CAAC,KAAK,CAAC,CAAC;gBACvB,OAAO;aACR;YAED,MAAM,EAAE,iBAAiB,EAAE,GAAG,cAAc,CAAC;YAE7C,uFAAuF;YACvF,MAAM,SAAS,CAAC,aAAa,EAAE,iBAAiB,CAAC,CAAC;YAElD,eAAe,CAAC,KAAK,CAAC,CAAC;QACzB,CAAC,CAAA,CAAC,CAAC;IACL,CAAC;IAED,IAAI,UAAU,EAAE;QACd,OAAO,8CAAqB,CAAC;KAC9B;IAED,OAAO,CACL,oBAAC,qBAAqB;QACpB,oBAAC,mBAAmB,IAAC,MAAM,EAAE,WAAW;YACtC;gBACE,oBAAC,wBAAwB,IAAC,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,iBAAiB,GAAI;gBACtF,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,oBAAC,YAAY,OAAG,CACnC,CACc,CACA,CACzB,CAAC;AACJ,CAAC;AAED,eAAe,yBAAyB,CAAC"}
@@ -1,8 +0,0 @@
1
- import type { FetchResourceCallback } from '@aehrc/sdc-populate';
2
- /**
3
- * Sample callback function to fetch resources from your source server when using populate() or populateQuestionnaire() from @aehrc/sdc-populate.
4
- * See https://github.com/aehrc/smart-forms/blob/main/packages/smart-forms-renderer/src/stories/StorybookWrappers/PrePopWrapperForStorybook.tsx#L50-L59 for usage.
5
- *
6
- * @author Sean Fong
7
- */
8
- export declare const fetchResourceCallback: FetchResourceCallback;
@@ -1,46 +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 axios from 'axios';
18
- const ABSOLUTE_URL_REGEX = /^(https?|ftp):\/\/[^\s/$.?#].[^\s]*$/;
19
- /**
20
- * Sample callback function to fetch resources from your source server when using populate() or populateQuestionnaire() from @aehrc/sdc-populate.
21
- * See https://github.com/aehrc/smart-forms/blob/main/packages/smart-forms-renderer/src/stories/StorybookWrappers/PrePopWrapperForStorybook.tsx#L50-L59 for usage.
22
- *
23
- * @author Sean Fong
24
- */
25
- export const fetchResourceCallback = (query, requestConfig) => {
26
- let { clientEndpoint } = requestConfig;
27
- const { authToken } = requestConfig;
28
- const headers = {
29
- Accept: 'application/json;charset=utf-8'
30
- };
31
- if (authToken) {
32
- headers['Authorization'] = `Bearer ${authToken}`;
33
- }
34
- if (!clientEndpoint.endsWith('/')) {
35
- clientEndpoint += '/';
36
- }
37
- if (ABSOLUTE_URL_REGEX.test(query)) {
38
- return axios.get(query, {
39
- headers: headers
40
- });
41
- }
42
- return axios.get(clientEndpoint + query, {
43
- headers: headers
44
- });
45
- };
46
- //# sourceMappingURL=populateCallbackForStorybook.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"populateCallbackForStorybook.js","sourceRoot":"","sources":["../../../src/stories/StorybookWrappers/populateCallbackForStorybook.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,kBAAkB,GAAG,sCAAsC,CAAC;AAOlE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAA0B,CAC1D,KAAa,EACb,aAA4B,EAC5B,EAAE;IACF,IAAI,EAAE,cAAc,EAAE,GAAG,aAAa,CAAC;IACvC,MAAM,EAAE,SAAS,EAAE,GAAG,aAAa,CAAC;IAEpC,MAAM,OAAO,GAAQ;QACnB,MAAM,EAAE,gCAAgC;KACzC,CAAC;IAEF,IAAI,SAAS,EAAE;QACb,OAAO,CAAC,eAAe,CAAC,GAAG,UAAU,SAAS,EAAE,CAAC;KAClD;IAED,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;QACjC,cAAc,IAAI,GAAG,CAAC;KACvB;IAED,IAAI,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;QAClC,OAAO,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE;YACtB,OAAO,EAAE,OAAO;SACjB,CAAC,CAAC;KACJ;IAED,OAAO,KAAK,CAAC,GAAG,CAAC,cAAc,GAAG,KAAK,EAAE;QACvC,OAAO,EAAE,OAAO;KACjB,CAAC,CAAC;AACL,CAAC,CAAC"}
@@ -1 +0,0 @@
1
- export { default as InitialiseFormWrapperForStorybook } from './InitialiseFormWrapperForStorybook';
@@ -1,18 +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
- export { default as InitialiseFormWrapperForStorybook } from './InitialiseFormWrapperForStorybook';
18
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/stories/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,OAAO,IAAI,iCAAiC,EAAE,MAAM,qCAAqC,CAAC"}
@@ -1,8 +0,0 @@
1
- import type { Questionnaire, QuestionnaireResponse } from 'fhir/r4';
2
- /**
3
- * Build the form with an initial Questionnaire and an optional filled QuestionnaireResponse.
4
- * If a QuestionnaireResponse is not provided, an empty QuestionnaireResponse is set as the initial QuestionnaireResponse.
5
- *
6
- * @author Sean Fong
7
- */
8
- export declare function buildForm(questionnaire: Questionnaire, questionnaireResponse?: QuestionnaireResponse): Promise<void>;
@@ -1,26 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { questionnaireResponseStore, questionnaireStore } from '../stores';
11
- import { initialiseQuestionnaireResponse } from './initialise';
12
- /**
13
- * Build the form with an initial Questionnaire and an optional filled QuestionnaireResponse.
14
- * If a QuestionnaireResponse is not provided, an empty QuestionnaireResponse is set as the initial QuestionnaireResponse.
15
- *
16
- * @author Sean Fong
17
- */
18
- export function buildForm(questionnaire, questionnaireResponse) {
19
- return __awaiter(this, void 0, void 0, function* () {
20
- yield questionnaireStore.getState().buildSourceQuestionnaire(questionnaire);
21
- const initialisedQuestionnaireResponse = initialiseQuestionnaireResponse(questionnaire, questionnaireResponse);
22
- questionnaireResponseStore.getState().buildSourceResponse(initialisedQuestionnaireResponse);
23
- questionnaireStore.getState().updatePopulatedProperties(initialisedQuestionnaireResponse);
24
- });
25
- }
26
- //# sourceMappingURL=buildForm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"buildForm.js","sourceRoot":"","sources":["../../src/utils/buildForm.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,0BAA0B,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAC3E,OAAO,EAAE,+BAA+B,EAAE,MAAM,cAAc,CAAC;AAE/D;;;;;GAKG;AACH,MAAM,UAAgB,SAAS,CAC7B,aAA4B,EAC5B,qBAA6C;;QAE7C,MAAM,kBAAkB,CAAC,QAAQ,EAAE,CAAC,wBAAwB,CAAC,aAAa,CAAC,CAAC;QAE5E,MAAM,gCAAgC,GAAG,+BAA+B,CACtE,aAAa,EACb,qBAAqB,CACtB,CAAC;QACF,0BAA0B,CAAC,QAAQ,EAAE,CAAC,mBAAmB,CAAC,gCAAgC,CAAC,CAAC;QAC5F,kBAAkB,CAAC,QAAQ,EAAE,CAAC,yBAAyB,CAAC,gCAAgC,CAAC,CAAC;IAC5F,CAAC;CAAA"}
File without changes
@@ -1,2 +0,0 @@
1
- "use strict";
2
- //# sourceMappingURL=buildForms.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"buildForms.js","sourceRoot":"","sources":["../../src/utils/buildForms.ts"],"names":[],"mappings":""}