@aehrc/smart-forms-renderer 0.27.4 → 0.29.0

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 (83) hide show
  1. package/.swcrc +2 -2
  2. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionFields.d.ts +1 -0
  3. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionFields.js +12 -2
  4. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionFields.js.map +1 -1
  5. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionItem.js +5 -2
  6. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionItem.js.map +1 -1
  7. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionView.d.ts +1 -0
  8. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionView.js +3 -3
  9. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionView.js.map +1 -1
  10. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetFields.d.ts +1 -0
  11. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetFields.js +12 -2
  12. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetFields.js.map +1 -1
  13. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetItem.js +5 -2
  14. package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetItem.js.map +1 -1
  15. package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionItem.js +4 -1
  16. package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionItem.js.map +1 -1
  17. package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionView.d.ts +1 -0
  18. package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionView.js +1 -1
  19. package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionView.js.map +1 -1
  20. package/lib/components/FormComponents/DateTimeItems/CustomDateTimeItem/DateTimeField.d.ts +2 -1
  21. package/lib/components/FormComponents/DateTimeItems/CustomDateTimeItem/DateTimeField.js.map +1 -1
  22. package/lib/components/FormComponents/DecimalItem/DecimalItem.js +3 -1
  23. package/lib/components/FormComponents/DecimalItem/DecimalItem.js.map +1 -1
  24. package/lib/hooks/useValidationFeedback.js +1 -1
  25. package/lib/utils/calculatedExpression.js +3 -3
  26. package/lib/utils/calculatedExpression.js.map +1 -1
  27. package/lib/utils/validateQuestionnaire.js.map +1 -1
  28. package/package.json +7 -3
  29. package/src/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionFields.tsx +28 -1
  30. package/src/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionItem.tsx +6 -0
  31. package/src/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionView.tsx +5 -1
  32. package/src/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetFields.tsx +20 -1
  33. package/src/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetItem.tsx +6 -0
  34. package/src/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionItem.tsx +5 -0
  35. package/src/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionView.tsx +3 -1
  36. package/src/components/FormComponents/DateTimeItems/CustomDateTimeItem/DateTimeField.tsx +2 -1
  37. package/src/components/FormComponents/DecimalItem/DecimalItem.tsx +15 -12
  38. package/src/hooks/useValidationFeedback.ts +1 -1
  39. package/src/stories/BuildFormWrapper.tsx +6 -11
  40. package/src/stories/PrePopButtonForStorybook.tsx +54 -0
  41. package/src/stories/PrePopWrapper.tsx +92 -0
  42. package/src/stories/assets/fhirClient/mockFhirClient.ts +52 -0
  43. package/src/stories/assets/patients/PatSmartForm.ts +281 -0
  44. package/src/stories/assets/practitioners/PracPrimaryPeter.ts +38 -0
  45. package/src/stories/assets/questionnaires/QAdvancedAdditionalDisplayContent.ts +30 -0
  46. package/src/stories/assets/questionnaires/QAdvancedOther.ts +1 -2
  47. package/src/stories/assets/questionnaires/QAdvancedTextApperance.ts +28 -0
  48. package/src/stories/assets/questionnaires/QBehaviorCalculations.ts +17 -19
  49. package/src/stories/assets/questionnaires/QBehaviorValueConstraints.ts +1 -1
  50. package/src/stories/assets/questionnaires/QBoolean.ts +1 -1
  51. package/src/stories/assets/questionnaires/QChoice.ts +357 -1
  52. package/src/stories/assets/questionnaires/QDate.ts +1 -1
  53. package/src/stories/assets/questionnaires/QDateTime.ts +1 -1
  54. package/src/stories/assets/questionnaires/QDecimal.ts +1 -1
  55. package/src/stories/assets/questionnaires/QFormPopulation.ts +1349 -0
  56. package/src/stories/assets/questionnaires/QInteger.ts +1 -1
  57. package/src/stories/assets/questionnaires/QItemControlDisplay.ts +460 -17
  58. package/src/stories/assets/questionnaires/QItemControlGroup.ts +220 -6
  59. package/src/stories/assets/questionnaires/QOpenChoice.ts +1 -1
  60. package/src/stories/assets/questionnaires/QQuantity.ts +6 -0
  61. package/src/stories/assets/questionnaires/QString.ts +1 -1
  62. package/src/stories/assets/questionnaires/QText.ts +2 -2
  63. package/src/stories/itemTypes/Boolean.stories.tsx +0 -17
  64. package/src/stories/itemTypes/Choice.stories.tsx +15 -0
  65. package/src/stories/itemTypes/Url.stories.tsx +2 -2
  66. package/src/stories/populateCallbackForStorybook.ts +56 -0
  67. package/src/stories/populateUtilsForStorybook.ts +545 -0
  68. package/src/stories/sdc/AdvancedAdditionalDisplayContent.stories.tsx +7 -1
  69. package/src/stories/sdc/AdvancedTextAppearance.stories.tsx +7 -0
  70. package/src/stories/sdc/BehaviorChoiceRestriction.stories.tsx +1 -1
  71. package/src/stories/sdc/FormPopulation.stories.tsx +97 -0
  72. package/src/stories/sdc/ItemControlDisplay.stories.tsx +31 -1
  73. package/src/stories/sdc/ItemControlGroup.stories.tsx +10 -3
  74. package/src/stories/useBuildFormForStorybook.ts +37 -0
  75. package/src/tests/enableWhen.test.ts +112 -0
  76. package/src/tests/test-data/enable-when-items-sample.json +3848 -0
  77. package/src/tests/test-data/initial-answers-sample.json +16 -0
  78. package/src/tests/test-data/linked-questions-map.json +217 -0
  79. package/src/tests/test-data/questionnaire-response-sample.json +650 -0
  80. package/src/utils/calculatedExpression.ts +3 -2
  81. package/src/utils/validateQuestionnaire.ts +18 -6
  82. package/storybook.log +6 -0
  83. package/vite.config.ts +9 -1
@@ -35,6 +35,7 @@ interface ChoiceRadioAnswerOptionViewProps
35
35
  calcExpUpdated: boolean;
36
36
  onCheckedChange: (linkId: string) => void;
37
37
  onFocusLinkId: () => void;
38
+ onClear: () => void;
38
39
  }
39
40
 
40
41
  function ChoiceRadioAnswerOptionView(props: ChoiceRadioAnswerOptionViewProps) {
@@ -47,7 +48,8 @@ function ChoiceRadioAnswerOptionView(props: ChoiceRadioAnswerOptionViewProps) {
47
48
  readOnly,
48
49
  calcExpUpdated,
49
50
  onFocusLinkId,
50
- onCheckedChange
51
+ onCheckedChange,
52
+ onClear
51
53
  } = props;
52
54
 
53
55
  if (isRepeated) {
@@ -60,6 +62,7 @@ function ChoiceRadioAnswerOptionView(props: ChoiceRadioAnswerOptionViewProps) {
60
62
  readOnly={readOnly}
61
63
  calcExpUpdated={calcExpUpdated}
62
64
  onCheckedChange={onCheckedChange}
65
+ onClear={onClear}
63
66
  />
64
67
  );
65
68
  }
@@ -78,6 +81,7 @@ function ChoiceRadioAnswerOptionView(props: ChoiceRadioAnswerOptionViewProps) {
78
81
  isTabled={isTabled}
79
82
  calcExpUpdated={calcExpUpdated}
80
83
  onCheckedChange={onCheckedChange}
84
+ onClear={onClear}
81
85
  />
82
86
  </ItemFieldGrid>
83
87
  </FullWidthFormComponentBox>
@@ -28,6 +28,10 @@ import FadingCheckIcon from '../ItemParts/FadingCheckIcon';
28
28
  import type { PropsWithIsTabledAttribute } from '../../../interfaces/renderProps.interface';
29
29
  import Box from '@mui/material/Box';
30
30
  import RadioOptionList from '../ItemParts/RadioOptionList';
31
+ import Tooltip from '@mui/material/Tooltip';
32
+ import Button from '@mui/material/Button';
33
+ import { grey } from '@mui/material/colors';
34
+ import Fade from '@mui/material/Fade';
31
35
 
32
36
  interface ChoiceRadioAnswerValueSetFieldsProps extends PropsWithIsTabledAttribute {
33
37
  qItem: QuestionnaireItem;
@@ -37,6 +41,7 @@ interface ChoiceRadioAnswerValueSetFieldsProps extends PropsWithIsTabledAttribut
37
41
  calcExpUpdated: boolean;
38
42
  terminologyError: TerminologyError;
39
43
  onCheckedChange: (newValue: string) => void;
44
+ onClear: () => void;
40
45
  }
41
46
 
42
47
  function ChoiceRadioAnswerValueSetFields(props: ChoiceRadioAnswerValueSetFieldsProps) {
@@ -48,7 +53,8 @@ function ChoiceRadioAnswerValueSetFields(props: ChoiceRadioAnswerValueSetFieldsP
48
53
  calcExpUpdated,
49
54
  terminologyError,
50
55
  isTabled,
51
- onCheckedChange
56
+ onCheckedChange,
57
+ onClear
52
58
  } = props;
53
59
 
54
60
  const orientation = getChoiceOrientation(qItem) ?? ChoiceItemOrientation.Vertical;
@@ -69,6 +75,19 @@ function ChoiceRadioAnswerValueSetFields(props: ChoiceRadioAnswerValueSetFieldsP
69
75
  <Box flexGrow={1} />
70
76
 
71
77
  <FadingCheckIcon fadeIn={calcExpUpdated} disabled={readOnly} />
78
+ <Fade in={!!valueRadio} timeout={100}>
79
+ <Tooltip title="Set question as unanswered">
80
+ <Button
81
+ sx={{
82
+ color: grey['500'],
83
+ '&:hover': { backgroundColor: grey['200'] }
84
+ }}
85
+ disabled={readOnly}
86
+ onClick={onClear}>
87
+ Clear
88
+ </Button>
89
+ </Tooltip>
90
+ </Fade>
72
91
  </Box>
73
92
  );
74
93
  }
@@ -82,6 +82,10 @@ function ChoiceRadioAnswerValueSetItem(props: ChoiceRadioAnswerValueSetItemProps
82
82
  }
83
83
  }
84
84
 
85
+ function handleClear() {
86
+ onQrItemChange(createEmptyQrItem(qItem));
87
+ }
88
+
85
89
  if (isRepeated) {
86
90
  return (
87
91
  <ChoiceRadioAnswerValueSetFields
@@ -93,6 +97,7 @@ function ChoiceRadioAnswerValueSetItem(props: ChoiceRadioAnswerValueSetItemProps
93
97
  terminologyError={terminologyError}
94
98
  isTabled={isTabled}
95
99
  onCheckedChange={handleChange}
100
+ onClear={handleClear}
96
101
  />
97
102
  );
98
103
  }
@@ -112,6 +117,7 @@ function ChoiceRadioAnswerValueSetItem(props: ChoiceRadioAnswerValueSetItemProps
112
117
  terminologyError={terminologyError}
113
118
  isTabled={isTabled}
114
119
  onCheckedChange={handleChange}
120
+ onClear={handleClear}
115
121
  />
116
122
  </ItemFieldGrid>
117
123
  </FullWidthFormComponentBox>
@@ -79,6 +79,10 @@ function ChoiceSelectAnswerOptionItem(props: ChoiceSelectAnswerOptionItemProps)
79
79
  );
80
80
  }
81
81
 
82
+ function handleClear() {
83
+ onQrItemChange(createEmptyQrItem(qItem));
84
+ }
85
+
82
86
  return (
83
87
  <ChoiceSelectAnswerOptionView
84
88
  qItem={qItem}
@@ -90,6 +94,7 @@ function ChoiceSelectAnswerOptionItem(props: ChoiceSelectAnswerOptionItemProps)
90
94
  isTabled={isTabled}
91
95
  onFocusLinkId={() => onFocusLinkId(qItem.linkId)}
92
96
  onSelectChange={handleChange}
97
+ onClear={handleClear}
93
98
  />
94
99
  );
95
100
  }
@@ -35,6 +35,7 @@ interface ChoiceSelectAnswerOptionViewProps
35
35
  calcExpUpdated: boolean;
36
36
  onSelectChange: (linkId: string) => void;
37
37
  onFocusLinkId: () => void;
38
+ onClear: () => void;
38
39
  }
39
40
 
40
41
  function ChoiceSelectAnswerOptionView(props: ChoiceSelectAnswerOptionViewProps) {
@@ -47,7 +48,8 @@ function ChoiceSelectAnswerOptionView(props: ChoiceSelectAnswerOptionViewProps)
47
48
  readOnly,
48
49
  calcExpUpdated,
49
50
  onFocusLinkId,
50
- onSelectChange
51
+ onSelectChange,
52
+ onClear
51
53
  } = props;
52
54
 
53
55
  if (isRepeated) {
@@ -15,7 +15,8 @@
15
15
  * limitations under the License.
16
16
  */
17
17
 
18
- import React, { Dispatch, SetStateAction } from 'react';
18
+ import type { Dispatch, SetStateAction } from 'react';
19
+ import React from 'react';
19
20
  import type { PropsWithIsTabledAttribute } from '../../../../interfaces/renderProps.interface';
20
21
  import CustomDateField from '../CustomDateItem/CustomDateField';
21
22
  import CustomTimeField from './CustomTimeField';
@@ -40,6 +40,7 @@ import useDecimalCalculatedExpression from '../../../hooks/useDecimalCalculatedE
40
40
  import useStringInput from '../../../hooks/useStringInput';
41
41
  import useReadOnly from '../../../hooks/useReadOnly';
42
42
  import { useQuestionnaireStore } from '../../../stores';
43
+ import Box from '@mui/material/Box';
43
44
 
44
45
  interface DecimalItemProps
45
46
  extends PropsWithQrItemChangeHandler,
@@ -127,18 +128,20 @@ function DecimalItem(props: DecimalItemProps) {
127
128
 
128
129
  if (isRepeated) {
129
130
  return (
130
- <DecimalField
131
- linkId={qItem.linkId}
132
- input={input}
133
- feedback={feedback}
134
- displayPrompt={displayPrompt}
135
- displayUnit={displayUnit}
136
- entryFormat={entryFormat}
137
- readOnly={readOnly}
138
- calcExpUpdated={calcExpUpdated}
139
- isTabled={isTabled}
140
- onInputChange={handleInputChange}
141
- />
131
+ <Box data-test="q-item-decimal-box">
132
+ <DecimalField
133
+ linkId={qItem.linkId}
134
+ input={input}
135
+ feedback={feedback}
136
+ displayPrompt={displayPrompt}
137
+ displayUnit={displayUnit}
138
+ entryFormat={entryFormat}
139
+ readOnly={readOnly}
140
+ calcExpUpdated={calcExpUpdated}
141
+ isTabled={isTabled}
142
+ onInputChange={handleInputChange}
143
+ />
144
+ </Box>
142
145
  );
143
146
  }
144
147
 
@@ -70,7 +70,7 @@ function useValidationFeedback(qItem: QuestionnaireItem, input: string): string
70
70
  return `Input is lower than the expected minimum value of ${minValue}.`;
71
71
  }
72
72
 
73
- // Test min value
73
+ // Test max value
74
74
  if (
75
75
  invalidType === ValidationResult.maxValue &&
76
76
  (typeof maxValue === 'string' || typeof maxValue === 'number')
@@ -15,13 +15,14 @@
15
15
  * limitations under the License.
16
16
  */
17
17
 
18
- import React, { useLayoutEffect, useState } from 'react';
18
+ // @ts-ignore
19
+ import React from 'react';
19
20
  import type { Questionnaire, QuestionnaireResponse } from 'fhir/r4';
20
21
  import { BaseRenderer } from '../components';
21
22
  import { QueryClientProvider } from '@tanstack/react-query';
22
23
  import ThemeProvider from '../theme/Theme';
23
24
  import useQueryClient from '../hooks/useQueryClient';
24
- import { buildForm } from '../utils';
25
+ import useBuildFormForStorybook from './useBuildFormForStorybook';
25
26
 
26
27
  interface BuildFormWrapperProps {
27
28
  questionnaire: Questionnaire;
@@ -31,17 +32,11 @@ interface BuildFormWrapperProps {
31
32
  function BuildFormWrapper(props: BuildFormWrapperProps) {
32
33
  const { questionnaire, questionnaireResponse } = props;
33
34
 
34
- const [isLoading, setIsLoading] = useState(true);
35
-
36
- useLayoutEffect(() => {
37
- buildForm(questionnaire, questionnaireResponse).then(() => {
38
- setIsLoading(false);
39
- });
40
- }, [questionnaire, questionnaireResponse]);
41
-
42
35
  const queryClient = useQueryClient();
43
36
 
44
- if (isLoading) {
37
+ const isBuilding = useBuildFormForStorybook(questionnaire, questionnaireResponse);
38
+
39
+ if (isBuilding) {
45
40
  return <div>Loading...</div>;
46
41
  }
47
42
 
@@ -0,0 +1,54 @@
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
+
18
+ // @ts-ignore
19
+ import React from 'react';
20
+ import { Box, CircularProgress, Fade, IconButton, Tooltip } from '@mui/material';
21
+ import PlayCircleIcon from '@mui/icons-material/PlayCircle';
22
+ import Typography from '@mui/material/Typography';
23
+
24
+ interface PrePopButtonProps {
25
+ isPopulating: boolean;
26
+ onPopulate: () => void;
27
+ }
28
+
29
+ function PrePopButtonForStorybook(props: PrePopButtonProps) {
30
+ const { isPopulating, onPopulate } = props;
31
+
32
+ return (
33
+ <Box display="flex" mb={0.5} alignItems="center" columnGap={3}>
34
+ <Tooltip title="Pre-populate form" placement="right">
35
+ <IconButton disabled={isPopulating} onClick={onPopulate} size="small" color="primary">
36
+ {isPopulating ? (
37
+ <CircularProgress size={20} color="inherit" sx={{ mb: 0.5 }} />
38
+ ) : (
39
+ <PlayCircleIcon />
40
+ )}
41
+ </IconButton>
42
+ </Tooltip>
43
+ {isPopulating ? (
44
+ <Fade in={true} timeout={100}>
45
+ <Typography variant="body2" color="text.secondary">
46
+ Pre-populating form...
47
+ </Typography>
48
+ </Fade>
49
+ ) : null}
50
+ </Box>
51
+ );
52
+ }
53
+
54
+ export default PrePopButtonForStorybook;
@@ -0,0 +1,92 @@
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
+
18
+ // @ts-ignore
19
+ import React, { useState } from 'react';
20
+ import type { Patient, Practitioner, Questionnaire } from 'fhir/r4';
21
+ import { BaseRenderer } from '../components';
22
+ import { QueryClientProvider } from '@tanstack/react-query';
23
+ import ThemeProvider from '../theme/Theme';
24
+ import useQueryClient from '../hooks/useQueryClient';
25
+ import type Client from 'fhirclient/lib/Client';
26
+ import useBuildFormForStorybook from './useBuildFormForStorybook';
27
+ import { buildForm } from '../utils';
28
+ import PrePopButtonForStorybook from './PrePopButtonForStorybook';
29
+ import { populateQuestionnaire } from '@aehrc/sdc-populate';
30
+ import { fetchResourceCallback } from './populateCallbackForStorybook';
31
+
32
+ interface PrePopWrapperProps {
33
+ questionnaire: Questionnaire;
34
+ fhirClient: Client;
35
+ patient: Patient;
36
+ user: Practitioner;
37
+ }
38
+
39
+ function PrePopWrapper(props: PrePopWrapperProps) {
40
+ const { questionnaire, fhirClient, patient, user } = props;
41
+
42
+ const [isPopulating, setIsPopulating] = useState(false);
43
+
44
+ const isBuilding = useBuildFormForStorybook(questionnaire);
45
+
46
+ const queryClient = useQueryClient();
47
+
48
+ function handlePrepopulate() {
49
+ setIsPopulating(true);
50
+
51
+ populateQuestionnaire({
52
+ questionnaire: questionnaire,
53
+ fetchResourceCallback: fetchResourceCallback,
54
+ requestConfig: {
55
+ clientEndpoint: fhirClient.state.serverUrl,
56
+ authToken: null
57
+ },
58
+ patient: patient,
59
+ user: user
60
+ }).then(async ({ populateSuccess, populateResult }) => {
61
+ if (!populateSuccess || !populateResult) {
62
+ setIsPopulating(false);
63
+ return;
64
+ }
65
+
66
+ const { populatedResponse } = populateResult;
67
+
68
+ // buildForm is used here because there is a really bizarre bug - using the store hooks directly doesn't update the baseRenderer
69
+ // could be the fact that it doesn't play well with storybook
70
+ await buildForm(questionnaire, populatedResponse);
71
+
72
+ setIsPopulating(false);
73
+ });
74
+ }
75
+
76
+ if (isBuilding) {
77
+ return <div>Loading...</div>;
78
+ }
79
+
80
+ return (
81
+ <ThemeProvider>
82
+ <QueryClientProvider client={queryClient}>
83
+ <div>
84
+ <PrePopButtonForStorybook isPopulating={isPopulating} onPopulate={handlePrepopulate} />
85
+ {isPopulating ? null : <BaseRenderer />}
86
+ </div>
87
+ </QueryClientProvider>
88
+ </ThemeProvider>
89
+ );
90
+ }
91
+
92
+ export default PrePopWrapper;
@@ -0,0 +1,52 @@
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
+
18
+ import type Client from 'fhirclient/lib/Client';
19
+
20
+ const iss = 'https://proxy.smartforms.io/v/r4/fhir';
21
+
22
+ const clientId = 'smart-forms-storybook';
23
+
24
+ const scope =
25
+ 'fhirUser online_access openid profile patient/Condition.rs patient/Observation.rs launch patient/Encounter.rs patient/Patient.rs';
26
+
27
+ // This must be a patient ID that exists in the EHR
28
+ const patientId = 'pat-sf';
29
+
30
+ // This must be a practitioner ID that exists in the EHR
31
+ const userId = 'primary-peter';
32
+
33
+ export const mockFhirClient = {
34
+ state: {
35
+ clientId: clientId,
36
+ scope: scope,
37
+ serverUrl: iss,
38
+ tokenResponse: {
39
+ access_token: 'mock_access_token'
40
+ }
41
+ },
42
+ patient: {
43
+ id: patientId
44
+ },
45
+ encounter: { id: null },
46
+
47
+ user: {
48
+ id: userId,
49
+ fhirUser: `Practitioner/${userId}`,
50
+ resourceType: 'Practitioner'
51
+ }
52
+ } as unknown as Client;