@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.
@@ -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 stpres QuestionnaireStore and QuestionnaireResponseStore respectively.
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 stpres QuestionnaireStore and QuestionnaireResponseStore respectively.
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;AAEhD,gEAAgE;AAChE,OAAO,EAAE,iCAAiC,EAAE,MAAM,6BAA6B,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
- * @method validateQuestionnaire - Used to validate the questionnaire response based on the questionnaire
15
- * @method buildSourceResponse - Used to build the source response when the form is first initialised
16
- * @method setUpdatableResponseAsPopulated - Used to set a pre-populated response as the current response
17
- * @method updateResponse - Used to update the current response
18
- * @method setUpdatableResponseAsSaved - Used to set a saved response as the current response
19
- * @method setUpdatableResponseAsEmpty - Used to set an empty response as the current response
20
- * @method destroySourceResponse - Used to destroy the source response and reset all properties
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
- * @method buildSourceQuestionnaire - Used to build the source questionnaire with the provided questionnaire and optionally questionnaire response, additional variables, terminology server url and readyOnly flag
33
- * @method destroySourceQuestionnaire - Used to destroy the source questionnaire and reset all properties
34
- * @method switchTab - Used to switch the current tab index
35
- * @method markTabAsComplete - Used to mark a tab index as complete
36
- * @method updateEnableWhenItem - Used to update linked enableWhen items by updating a question with a new answer
37
- * @method mutateRepeatEnableWhenItems - Used to add or remove instances of repeating enableWhen items
38
- * @method toggleEnableWhenActivation - Used to toggle enableWhen checks on/off
39
- * @method updateExpressions - Used to update all SDC expressions based on the updated questionnaire response
40
- * @method addCodingToCache - Used to add a coding to the cached value set codings
41
- * @method updatePopulatedProperties - Used to update all SDC expressions based on a pre-populated questionnaire response
42
- * @method onFocusLinkId - Used to set the focused linkId
43
- * @method setPopulatedContext - Used to set the populated contexts (launchContext, sourceQueries, x-fhir-query vars) for debugging purposes
44
- * @method setFormAsReadOnly - Used to set the form as read-only
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
- * @method setClient - Set the FHIRClient object when launching via SMART App Launch
13
- * @method setPatient - Set the patient resource in context
14
- * @method setUser - Set the user resource in context
15
- * @method setEncounter - Set the encounter resource in context
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
- * @method setUrl - Set the terminology server URL
8
- * @method resetUrl - Reset the terminology server URL to the default
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,2 @@
1
+ export type { InitialiseFormWrapperProps } from './InitialiseFormWrapperForStorybook';
1
2
  export { default as InitialiseFormWrapperForStorybook } from './InitialiseFormWrapperForStorybook';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/stories/storybookWrappers/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,OAAO,IAAI,iCAAiC,EAAE,MAAM,qCAAqC,CAAC"}
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"}
@@ -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,EAAE,0BAA0B,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7F,OAAO,EAAE,+BAA+B,EAAE,MAAM,cAAc,CAAC;A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CAAC,CAAC;QAEnD,MAAM,CAAC,OAAO,EAAE,IAAI,EAAE,SAAS,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;YACnD,cAAc;YACd,WAAW;YACX,gBAAgB;SACjB,CAAC,CAAC;QACH,gBAAgB,CAAC,QAAQ,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QAChD,gBAAgB,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAC1C,gBAAgB,CAAC,QAAQ,EAAE,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;IACtD,CAAC;CAAA;AAED;;;;;GAKG;AACH,MAAM,UAAU,WAAW;IACzB,OAAO,0BAA0B,CAAC,QAAQ,EAAE,CAAC,iBAAiB,CAAC;AACjE,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,8BAA8B,CAC5C,aAA4B,EAC5B,qBAA4C;IAE5C,MAAM,qBAAqB,GAAG,kBAAkB,CAAC,QAAQ,EAAE,CAAC,qBAAqB,CAAC;IAClF,MAAM,eAAe,GAAG,kBAAkB,CAAC,QAAQ,EAAE,CAAC,eAAe,CAAC;IACtE,MAAM,qBAAqB,GAAG,kBAAkB,CAAC,QAAQ,EAAE,CAAC,qBAAqB,CAAC;IAElF,OAAO,kBAAkB,CAAC;QACxB,aAAa;QACb,qBAAqB;QACrB,qBAAqB;QACrB,eAAe;QACf,qBAAqB;KACtB,CAAC,CAAC;AACL,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aehrc/smart-forms-renderer",
3
- "version": "0.31.4",
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.2",
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 stpres QuestionnaireStore and QuestionnaireResponseStore respectively.
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
- * @method validateQuestionnaire - Used to validate the questionnaire response based on the questionnaire
46
- * @method buildSourceResponse - Used to build the source response when the form is first initialised
47
- * @method setUpdatableResponseAsPopulated - Used to set a pre-populated response as the current response
48
- * @method updateResponse - Used to update the current response
49
- * @method setUpdatableResponseAsSaved - Used to set a saved response as the current response
50
- * @method setUpdatableResponseAsEmpty - Used to set an empty response as the current response
51
- * @method destroySourceResponse - Used to destroy the source response and reset all properties
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
- * @method buildSourceQuestionnaire - Used to build the source questionnaire with the provided questionnaire and optionally questionnaire response, additional variables, terminology server url and readyOnly flag
75
- * @method destroySourceQuestionnaire - Used to destroy the source questionnaire and reset all properties
76
- * @method switchTab - Used to switch the current tab index
77
- * @method markTabAsComplete - Used to mark a tab index as complete
78
- * @method updateEnableWhenItem - Used to update linked enableWhen items by updating a question with a new answer
79
- * @method mutateRepeatEnableWhenItems - Used to add or remove instances of repeating enableWhen items
80
- * @method toggleEnableWhenActivation - Used to toggle enableWhen checks on/off
81
- * @method updateExpressions - Used to update all SDC expressions based on the updated questionnaire response
82
- * @method addCodingToCache - Used to add a coding to the cached value set codings
83
- * @method updatePopulatedProperties - Used to update all SDC expressions based on a pre-populated questionnaire response
84
- * @method onFocusLinkId - Used to set the focused linkId
85
- * @method setPopulatedContext - Used to set the populated contexts (launchContext, sourceQueries, x-fhir-query vars) for debugging purposes
86
- * @method setFormAsReadOnly - Used to set the form as read-only
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
- * @method setClient - Set the FHIRClient object when launching via SMART App Launch
33
- * @method setPatient - Set the patient resource in context
34
- * @method setUser - Set the user resource in context
35
- * @method setEncounter - Set the encounter resource in context
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
- * @method setUrl - Set the terminology server URL
30
- * @method resetUrl - Reset the terminology server URL to the default
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;
@@ -15,4 +15,5 @@
15
15
  * limitations under the License.
16
16
  */
17
17
 
18
+ export type { InitialiseFormWrapperProps } from './InitialiseFormWrapperForStorybook';
18
19
  export { default as InitialiseFormWrapperForStorybook } from './InitialiseFormWrapperForStorybook';
@@ -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
+ };
@@ -1,5 +1,10 @@
1
1
  import type { Questionnaire, QuestionnaireResponse } from 'fhir/r4';
2
- import { questionnaireResponseStore, questionnaireStore, smartConfigStore } from '../stores';
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()