@aehrc/smart-forms-renderer 0.31.4 → 0.31.6
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.
- package/lib/components/Renderer/BaseRenderer.d.ts +1 -1
- package/lib/components/Renderer/BaseRenderer.js +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +0 -1
- package/lib/index.js.map +1 -1
- package/lib/stores/questionnaireResponseStore.d.ts +7 -7
- package/lib/stores/questionnaireStore.d.ts +13 -13
- package/lib/stores/smartConfigStore.d.ts +4 -4
- package/lib/stores/terminologyServerStore.d.ts +2 -2
- package/lib/stories/StorybookWrappers/InitialiseFormWrapperForStorybook.d.ts +1 -1
- package/lib/stories/StorybookWrappers/index.d.ts +1 -0
- package/lib/stories/StorybookWrappers/index.js.map +1 -1
- package/lib/utils/manageForm.js +7 -1
- package/lib/utils/manageForm.js.map +1 -1
- package/package.json +2 -2
- package/src/components/Renderer/BaseRenderer.tsx +1 -1
- package/src/index.ts +1 -0
- package/src/stores/questionnaireResponseStore.ts +7 -7
- package/src/stores/questionnaireStore.ts +13 -13
- package/src/stores/smartConfigStore.ts +4 -4
- package/src/stores/terminologyServerStore.ts +2 -2
- package/src/stories/storybookWrappers/InitialiseFormWrapperForStorybook.tsx +1 -1
- package/src/stories/storybookWrappers/index.ts +1 -0
- package/src/stories/testing/BuildFormButtonTesterWrapper.stories.tsx +8 -0
- package/src/utils/manageForm.ts +12 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
/**
|
|
3
3
|
* Main component of the form-rendering engine.
|
|
4
|
-
* Renders the Questionnaire and QuestionnaireResponse defined in the state management
|
|
4
|
+
* Renders the Questionnaire and QuestionnaireResponse defined in the state management stores QuestionnaireStore and QuestionnaireResponseStore respectively.
|
|
5
5
|
* Use buildForm() in your wrapping component or in an event handler to initialise the form.
|
|
6
6
|
*
|
|
7
7
|
* @author Sean Fong
|
|
@@ -24,7 +24,7 @@ import { getQrItemsIndex, mapQItemsIndex } from '../../utils/mapItem';
|
|
|
24
24
|
import { updateQrItemsInGroup } from '../../utils/qrItem';
|
|
25
25
|
/**
|
|
26
26
|
* Main component of the form-rendering engine.
|
|
27
|
-
* Renders the Questionnaire and QuestionnaireResponse defined in the state management
|
|
27
|
+
* Renders the Questionnaire and QuestionnaireResponse defined in the state management stores QuestionnaireStore and QuestionnaireResponseStore respectively.
|
|
28
28
|
* Use buildForm() in your wrapping component or in an event handler to initialise the form.
|
|
29
29
|
*
|
|
30
30
|
* @author Sean Fong
|
package/lib/index.d.ts
CHANGED
|
@@ -7,4 +7,5 @@ export { useHidden, useBuildForm, useRendererQueryClient } from './hooks';
|
|
|
7
7
|
export type { ItemToRepopulate } from './utils';
|
|
8
8
|
export { buildForm, destroyForm, getResponse, removeEmptyAnswersFromResponse, isSpecificItemControl, isRepeatItemAndNotCheckbox, initialiseQuestionnaireResponse, generateItemsToRepopulate, repopulateResponse } from './utils';
|
|
9
9
|
export { RendererThemeProvider } from './theme';
|
|
10
|
+
export type { InitialiseFormWrapperProps } from './stories/storybookWrappers';
|
|
10
11
|
export { InitialiseFormWrapperForStorybook } from './stories/storybookWrappers';
|
package/lib/index.js
CHANGED
|
@@ -5,6 +5,5 @@ export { useHidden, useBuildForm, useRendererQueryClient } from './hooks';
|
|
|
5
5
|
export { buildForm, destroyForm, getResponse, removeEmptyAnswersFromResponse, isSpecificItemControl, isRepeatItemAndNotCheckbox, initialiseQuestionnaireResponse, generateItemsToRepopulate, repopulateResponse } from './utils';
|
|
6
6
|
// theme provider exports
|
|
7
7
|
export { RendererThemeProvider } from './theme';
|
|
8
|
-
// wrapper exports - only for smartforms.csiro.au/standalone use
|
|
9
8
|
export { InitialiseFormWrapperForStorybook } from './stories/storybookWrappers';
|
|
10
9
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,kBAAkB,EAClB,YAAY,EACZ,UAAU,EACV,UAAU,EACV,WAAW,EACX,UAAU,EACV,SAAS,EACT,0BAA0B,EAC3B,MAAM,cAAc,CAAC;AAStB,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EACrB,0BAA0B,EAC1B,6BAA6B,EAC7B,gBAAgB,EAChB,mBAAmB,EACnB,sBAAsB,EACtB,yBAAyB,EAC1B,MAAM,UAAU,CAAC;AAElB,gBAAgB;AAChB,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAI1E,OAAO,EACL,SAAS,EACT,WAAW,EACX,WAAW,EACX,8BAA8B,EAC9B,qBAAqB,EACrB,0BAA0B,EAC1B,+BAA+B,EAC/B,yBAAyB,EACzB,kBAAkB,EACnB,MAAM,SAAS,CAAC;AAEjB,yBAAyB;AACzB,OAAO,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,kBAAkB,EAClB,YAAY,EACZ,UAAU,EACV,UAAU,EACV,WAAW,EACX,UAAU,EACV,SAAS,EACT,0BAA0B,EAC3B,MAAM,cAAc,CAAC;AAStB,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EACrB,0BAA0B,EAC1B,6BAA6B,EAC7B,gBAAgB,EAChB,mBAAmB,EACnB,sBAAsB,EACtB,yBAAyB,EAC1B,MAAM,UAAU,CAAC;AAElB,gBAAgB;AAChB,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAI1E,OAAO,EACL,SAAS,EACT,WAAW,EACX,WAAW,EACX,8BAA8B,EAC9B,qBAAqB,EACrB,0BAA0B,EAC1B,+BAA+B,EAC/B,yBAAyB,EACzB,kBAAkB,EACnB,MAAM,SAAS,CAAC;AAEjB,yBAAyB;AACzB,OAAO,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAIhD,OAAO,EAAE,iCAAiC,EAAE,MAAM,6BAA6B,CAAC"}
|
|
@@ -11,13 +11,13 @@ import type { Diff } from 'deep-diff';
|
|
|
11
11
|
* @property formChangesHistory - Array of form changes history in the form of deep-diff objects
|
|
12
12
|
* @property invalidItems - Key-value pair of invalid items based on defined value constraints in the questionnaire `Record<linkId, OperationOutcome>`
|
|
13
13
|
* @property responseIsValid - Whether there are any invalid items in the response
|
|
14
|
-
* @
|
|
15
|
-
* @
|
|
16
|
-
* @
|
|
17
|
-
* @
|
|
18
|
-
* @
|
|
19
|
-
* @
|
|
20
|
-
* @
|
|
14
|
+
* @property validateQuestionnaire - Used to validate the questionnaire response based on the questionnaire
|
|
15
|
+
* @property buildSourceResponse - Used to build the source response when the form is first initialised
|
|
16
|
+
* @property setUpdatableResponseAsPopulated - Used to set a pre-populated response as the current response
|
|
17
|
+
* @property updateResponse - Used to update the current response
|
|
18
|
+
* @property setUpdatableResponseAsSaved - Used to set a saved response as the current response
|
|
19
|
+
* @property setUpdatableResponseAsEmpty - Used to set an empty response as the current response
|
|
20
|
+
* @property destroySourceResponse - Used to destroy the source response and reset all properties
|
|
21
21
|
*
|
|
22
22
|
* @author Sean Fong
|
|
23
23
|
*/
|
|
@@ -29,19 +29,19 @@ import type { Tabs } from '../interfaces/tab.interface';
|
|
|
29
29
|
* @property populatedContext - Key-value pair of one-off pre-populated FHIRPath values `Record<variable/launchContext/sourceQueries batch name, evaluated value(s)>`
|
|
30
30
|
* @property focusedLinkId - LinkId of the currently focused item
|
|
31
31
|
* @property readOnly - Flag to set the form to read-only mode
|
|
32
|
-
* @
|
|
33
|
-
* @
|
|
34
|
-
* @
|
|
35
|
-
* @
|
|
36
|
-
* @
|
|
37
|
-
* @
|
|
38
|
-
* @
|
|
39
|
-
* @
|
|
40
|
-
* @
|
|
41
|
-
* @
|
|
42
|
-
* @
|
|
43
|
-
* @
|
|
44
|
-
* @
|
|
32
|
+
* @property buildSourceQuestionnaire - Used to build the source questionnaire with the provided questionnaire and optionally questionnaire response, additional variables, terminology server url and readyOnly flag
|
|
33
|
+
* @property destroySourceQuestionnaire - Used to destroy the source questionnaire and reset all properties
|
|
34
|
+
* @property switchTab - Used to switch the current tab index
|
|
35
|
+
* @property markTabAsComplete - Used to mark a tab index as complete
|
|
36
|
+
* @property updateEnableWhenItem - Used to update linked enableWhen items by updating a question with a new answer
|
|
37
|
+
* @property mutateRepeatEnableWhenItems - Used to add or remove instances of repeating enableWhen items
|
|
38
|
+
* @property toggleEnableWhenActivation - Used to toggle enableWhen checks on/off
|
|
39
|
+
* @property updateExpressions - Used to update all SDC expressions based on the updated questionnaire response
|
|
40
|
+
* @property addCodingToCache - Used to add a coding to the cached value set codings
|
|
41
|
+
* @property updatePopulatedProperties - Used to update all SDC expressions based on a pre-populated questionnaire response
|
|
42
|
+
* @property onFocusLinkId - Used to set the focused linkId
|
|
43
|
+
* @property setPopulatedContext - Used to set the populated contexts (launchContext, sourceQueries, x-fhir-query vars) for debugging purposes
|
|
44
|
+
* @property setFormAsReadOnly - Used to set the form as read-only
|
|
45
45
|
*
|
|
46
46
|
* @author Sean Fong
|
|
47
47
|
*/
|
|
@@ -9,10 +9,10 @@ import type Client from 'fhirclient/lib/Client';
|
|
|
9
9
|
* @property patient - The patient resource in context
|
|
10
10
|
* @property user - The user resource in context
|
|
11
11
|
* @property encounter - The encounter resource in context
|
|
12
|
-
* @
|
|
13
|
-
* @
|
|
14
|
-
* @
|
|
15
|
-
* @
|
|
12
|
+
* @property setClient - Set the FHIRClient object when launching via SMART App Launch
|
|
13
|
+
* @property setPatient - Set the patient resource in context
|
|
14
|
+
* @property setUser - Set the user resource in context
|
|
15
|
+
* @property setEncounter - Set the encounter resource in context
|
|
16
16
|
*
|
|
17
17
|
* @author Sean Fong
|
|
18
18
|
*/
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* Methods are usually used internally, using them from an external source is not recommended.
|
|
5
5
|
*
|
|
6
6
|
* @property url - The current terminology server URL
|
|
7
|
-
* @
|
|
8
|
-
* @
|
|
7
|
+
* @property setUrl - Set the terminology server URL
|
|
8
|
+
* @property resetUrl - Reset the terminology server URL to the default
|
|
9
9
|
*
|
|
10
10
|
* @author Sean Fong
|
|
11
11
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { Questionnaire, QuestionnaireResponse } from 'fhir/r4';
|
|
3
3
|
import type Client from 'fhirclient/lib/Client';
|
|
4
|
-
interface InitialiseFormWrapperProps {
|
|
4
|
+
export interface InitialiseFormWrapperProps {
|
|
5
5
|
questionnaire: Questionnaire;
|
|
6
6
|
questionnaireResponse?: QuestionnaireResponse;
|
|
7
7
|
readOnly?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/stories/storybookWrappers/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/stories/storybookWrappers/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAAE,OAAO,IAAI,iCAAiC,EAAE,MAAM,qCAAqC,CAAC"}
|
package/lib/utils/manageForm.js
CHANGED
|
@@ -7,7 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import { questionnaireResponseStore, questionnaireStore, smartConfigStore } from '../stores';
|
|
10
|
+
import { questionnaireResponseStore, questionnaireStore, smartConfigStore, terminologyServerStore } from '../stores';
|
|
11
11
|
import { initialiseQuestionnaireResponse } from './initialise';
|
|
12
12
|
import { removeEmptyAnswers } from './removeEmptyAnswers';
|
|
13
13
|
import { readEncounter, readPatient, readUser } from '../api/smartClient';
|
|
@@ -26,6 +26,12 @@ import { readEncounter, readPatient, readUser } from '../api/smartClient';
|
|
|
26
26
|
*/
|
|
27
27
|
export function buildForm(questionnaire, questionnaireResponse, readOnly, terminologyServerUrl, additionalVariables) {
|
|
28
28
|
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
if (terminologyServerUrl) {
|
|
30
|
+
terminologyServerStore.getState().setUrl(terminologyServerUrl);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
terminologyServerStore.getState().resetUrl();
|
|
34
|
+
}
|
|
29
35
|
// QR is set to undefined here to prevent it from being initialised twice. This is defined like that for backward compatibility purposes.
|
|
30
36
|
yield questionnaireStore
|
|
31
37
|
.getState()
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manageForm.js","sourceRoot":"","sources":["../../src/utils/manageForm.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"manageForm.js","sourceRoot":"","sources":["../../src/utils/manageForm.ts"],"names":[],"mappings":"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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aehrc/smart-forms-renderer",
|
|
3
|
-
"version": "0.31.
|
|
3
|
+
"version": "0.31.6",
|
|
4
4
|
"description": "FHIR Structured Data Captured (SDC) rendering engine for Smart Forms",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
},
|
|
28
28
|
"homepage": "https://github.com/aehrc/smart-forms#readme",
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@aehrc/sdc-populate": "^2.0.
|
|
30
|
+
"@aehrc/sdc-populate": "^2.0.3",
|
|
31
31
|
"@iconify/react": "^4.1.1",
|
|
32
32
|
"dayjs": "^1.11.10",
|
|
33
33
|
"deep-diff": "^1.0.2",
|
|
@@ -28,7 +28,7 @@ import type { QrRepeatGroup } from '../../interfaces/repeatGroup.interface';
|
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
30
|
* Main component of the form-rendering engine.
|
|
31
|
-
* Renders the Questionnaire and QuestionnaireResponse defined in the state management
|
|
31
|
+
* Renders the Questionnaire and QuestionnaireResponse defined in the state management stores QuestionnaireStore and QuestionnaireResponseStore respectively.
|
|
32
32
|
* Use buildForm() in your wrapping component or in an event handler to initialise the form.
|
|
33
33
|
*
|
|
34
34
|
* @author Sean Fong
|
package/src/index.ts
CHANGED
|
@@ -53,4 +53,5 @@ export {
|
|
|
53
53
|
export { RendererThemeProvider } from './theme';
|
|
54
54
|
|
|
55
55
|
// wrapper exports - only for smartforms.csiro.au/standalone use
|
|
56
|
+
export type { InitialiseFormWrapperProps } from './stories/storybookWrappers';
|
|
56
57
|
export { InitialiseFormWrapperForStorybook } from './stories/storybookWrappers';
|
|
@@ -42,13 +42,13 @@ import { createQuestionnaireResponseItemMap } from '../utils/questionnaireRespon
|
|
|
42
42
|
* @property formChangesHistory - Array of form changes history in the form of deep-diff objects
|
|
43
43
|
* @property invalidItems - Key-value pair of invalid items based on defined value constraints in the questionnaire `Record<linkId, OperationOutcome>`
|
|
44
44
|
* @property responseIsValid - Whether there are any invalid items in the response
|
|
45
|
-
* @
|
|
46
|
-
* @
|
|
47
|
-
* @
|
|
48
|
-
* @
|
|
49
|
-
* @
|
|
50
|
-
* @
|
|
51
|
-
* @
|
|
45
|
+
* @property validateQuestionnaire - Used to validate the questionnaire response based on the questionnaire
|
|
46
|
+
* @property buildSourceResponse - Used to build the source response when the form is first initialised
|
|
47
|
+
* @property setUpdatableResponseAsPopulated - Used to set a pre-populated response as the current response
|
|
48
|
+
* @property updateResponse - Used to update the current response
|
|
49
|
+
* @property setUpdatableResponseAsSaved - Used to set a saved response as the current response
|
|
50
|
+
* @property setUpdatableResponseAsEmpty - Used to set an empty response as the current response
|
|
51
|
+
* @property destroySourceResponse - Used to destroy the source response and reset all properties
|
|
52
52
|
*
|
|
53
53
|
* @author Sean Fong
|
|
54
54
|
*/
|
|
@@ -71,19 +71,19 @@ import { createQuestionnaireResponseItemMap } from '../utils/questionnaireRespon
|
|
|
71
71
|
* @property populatedContext - Key-value pair of one-off pre-populated FHIRPath values `Record<variable/launchContext/sourceQueries batch name, evaluated value(s)>`
|
|
72
72
|
* @property focusedLinkId - LinkId of the currently focused item
|
|
73
73
|
* @property readOnly - Flag to set the form to read-only mode
|
|
74
|
-
* @
|
|
75
|
-
* @
|
|
76
|
-
* @
|
|
77
|
-
* @
|
|
78
|
-
* @
|
|
79
|
-
* @
|
|
80
|
-
* @
|
|
81
|
-
* @
|
|
82
|
-
* @
|
|
83
|
-
* @
|
|
84
|
-
* @
|
|
85
|
-
* @
|
|
86
|
-
* @
|
|
74
|
+
* @property buildSourceQuestionnaire - Used to build the source questionnaire with the provided questionnaire and optionally questionnaire response, additional variables, terminology server url and readyOnly flag
|
|
75
|
+
* @property destroySourceQuestionnaire - Used to destroy the source questionnaire and reset all properties
|
|
76
|
+
* @property switchTab - Used to switch the current tab index
|
|
77
|
+
* @property markTabAsComplete - Used to mark a tab index as complete
|
|
78
|
+
* @property updateEnableWhenItem - Used to update linked enableWhen items by updating a question with a new answer
|
|
79
|
+
* @property mutateRepeatEnableWhenItems - Used to add or remove instances of repeating enableWhen items
|
|
80
|
+
* @property toggleEnableWhenActivation - Used to toggle enableWhen checks on/off
|
|
81
|
+
* @property updateExpressions - Used to update all SDC expressions based on the updated questionnaire response
|
|
82
|
+
* @property addCodingToCache - Used to add a coding to the cached value set codings
|
|
83
|
+
* @property updatePopulatedProperties - Used to update all SDC expressions based on a pre-populated questionnaire response
|
|
84
|
+
* @property onFocusLinkId - Used to set the focused linkId
|
|
85
|
+
* @property setPopulatedContext - Used to set the populated contexts (launchContext, sourceQueries, x-fhir-query vars) for debugging purposes
|
|
86
|
+
* @property setFormAsReadOnly - Used to set the form as read-only
|
|
87
87
|
*
|
|
88
88
|
* @author Sean Fong
|
|
89
89
|
*/
|
|
@@ -29,10 +29,10 @@ import { createSelectors } from './selector';
|
|
|
29
29
|
* @property patient - The patient resource in context
|
|
30
30
|
* @property user - The user resource in context
|
|
31
31
|
* @property encounter - The encounter resource in context
|
|
32
|
-
* @
|
|
33
|
-
* @
|
|
34
|
-
* @
|
|
35
|
-
* @
|
|
32
|
+
* @property setClient - Set the FHIRClient object when launching via SMART App Launch
|
|
33
|
+
* @property setPatient - Set the patient resource in context
|
|
34
|
+
* @property setUser - Set the user resource in context
|
|
35
|
+
* @property setEncounter - Set the encounter resource in context
|
|
36
36
|
*
|
|
37
37
|
* @author Sean Fong
|
|
38
38
|
*/
|
|
@@ -26,8 +26,8 @@ const ONTOSERVER_R4 = 'https://r4.ontoserver.csiro.au/fhir';
|
|
|
26
26
|
* Methods are usually used internally, using them from an external source is not recommended.
|
|
27
27
|
*
|
|
28
28
|
* @property url - The current terminology server URL
|
|
29
|
-
* @
|
|
30
|
-
* @
|
|
29
|
+
* @property setUrl - Set the terminology server URL
|
|
30
|
+
* @property resetUrl - Reset the terminology server URL to the default
|
|
31
31
|
*
|
|
32
32
|
* @author Sean Fong
|
|
33
33
|
*/
|
|
@@ -28,7 +28,7 @@ import Box from '@mui/material/Box';
|
|
|
28
28
|
import CircularProgress from '@mui/material/CircularProgress';
|
|
29
29
|
import Typography from '@mui/material/Typography';
|
|
30
30
|
|
|
31
|
-
interface InitialiseFormWrapperProps {
|
|
31
|
+
export interface InitialiseFormWrapperProps {
|
|
32
32
|
questionnaire: Questionnaire;
|
|
33
33
|
questionnaireResponse?: QuestionnaireResponse;
|
|
34
34
|
readOnly?: boolean;
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
import type { Meta, StoryObj } from '@storybook/react';
|
|
19
19
|
import BuildFormButtonTesterWrapperForStorybook from '../storybookWrappers/BuildFormButtonTesterWrapperForStorybook';
|
|
20
20
|
import { qButtonTester, qrButtonTesterResponse } from '../assets/questionnaires/QButtonTester';
|
|
21
|
+
import { qBooleanBasic, qrBooleanBasicResponse } from '../assets/questionnaires';
|
|
21
22
|
|
|
22
23
|
// More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
|
|
23
24
|
const meta = {
|
|
@@ -38,3 +39,10 @@ export const BuildFormButtonTester: Story = {
|
|
|
38
39
|
questionnaireResponse: qrButtonTesterResponse
|
|
39
40
|
}
|
|
40
41
|
};
|
|
42
|
+
|
|
43
|
+
export const BuildFormButtonTesterBoolean: Story = {
|
|
44
|
+
args: {
|
|
45
|
+
questionnaire: qBooleanBasic,
|
|
46
|
+
questionnaireResponse: qrBooleanBasicResponse
|
|
47
|
+
}
|
|
48
|
+
};
|
package/src/utils/manageForm.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import type { Questionnaire, QuestionnaireResponse } from 'fhir/r4';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
questionnaireResponseStore,
|
|
4
|
+
questionnaireStore,
|
|
5
|
+
smartConfigStore,
|
|
6
|
+
terminologyServerStore
|
|
7
|
+
} from '../stores';
|
|
3
8
|
import { initialiseQuestionnaireResponse } from './initialise';
|
|
4
9
|
import { removeEmptyAnswers } from './removeEmptyAnswers';
|
|
5
10
|
import { readEncounter, readPatient, readUser } from '../api/smartClient';
|
|
@@ -25,6 +30,12 @@ export async function buildForm(
|
|
|
25
30
|
terminologyServerUrl?: string,
|
|
26
31
|
additionalVariables?: Record<string, object>
|
|
27
32
|
): Promise<void> {
|
|
33
|
+
if (terminologyServerUrl) {
|
|
34
|
+
terminologyServerStore.getState().setUrl(terminologyServerUrl);
|
|
35
|
+
} else {
|
|
36
|
+
terminologyServerStore.getState().resetUrl();
|
|
37
|
+
}
|
|
38
|
+
|
|
28
39
|
// QR is set to undefined here to prevent it from being initialised twice. This is defined like that for backward compatibility purposes.
|
|
29
40
|
await questionnaireStore
|
|
30
41
|
.getState()
|