From 8992fd36964e1f97e9fcc1c1e6f4bff6f3384669 Mon Sep 17 00:00:00 2001 From: Sean Fong Date: Fri, 5 Jul 2024 09:28:41 +0930 Subject: [PATCH 1/4] Change Developer Usage docs shorthand 'devUsage' to 'dev' --- .../docs/{devUsage => dev}/index.mdx | 5 +++ .../{devUsage => dev}/renderer-overview.mdx | 0 .../{devUsage => dev}/renderer-utilities.mdx | 32 +++++++++---------- .../{devUsage => dev}/storehooks/index.mdx | 2 +- .../form-changes-history.mdx | 0 .../questionnaire-response-store/index.mdx | 0 .../invalid-items.mdx | 0 .../response-is-valid.mdx | 0 .../source-response.mdx | 2 +- .../updatable-response-items.mdx | 0 .../updatable-response.mdx | 0 .../calculated-expressions.mdx | 0 .../questionnaire-store/fhirpath-context.mdx | 0 .../questionnaire-store/focused-linkid.mdx | 0 .../storehooks/questionnaire-store/index.mdx | 0 .../questionnaire-store/item-types.mdx | 0 .../source-questionnaire.mdx | 0 .../questionnaire-store/variables.mdx | 0 .../storehooks/smart-config-store.mdx | 2 +- .../terminology-server-store/index.mdx | 0 .../terminology-server-store/url.mdx | 0 documentation/docusaurus.config.ts | 2 +- documentation/sidebars.ts | 4 +-- packages/smart-forms-renderer/README.md | 2 +- 24 files changed, 28 insertions(+), 23 deletions(-) rename documentation/docs/{devUsage => dev}/index.mdx (67%) rename documentation/docs/{devUsage => dev}/renderer-overview.mdx (100%) rename documentation/docs/{devUsage => dev}/renderer-utilities.mdx (85%) rename documentation/docs/{devUsage => dev}/storehooks/index.mdx (94%) rename documentation/docs/{devUsage => dev}/storehooks/questionnaire-response-store/form-changes-history.mdx (100%) rename documentation/docs/{devUsage => dev}/storehooks/questionnaire-response-store/index.mdx (100%) rename documentation/docs/{devUsage => dev}/storehooks/questionnaire-response-store/invalid-items.mdx (100%) rename documentation/docs/{devUsage => dev}/storehooks/questionnaire-response-store/response-is-valid.mdx (100%) rename documentation/docs/{devUsage => dev}/storehooks/questionnaire-response-store/source-response.mdx (82%) rename documentation/docs/{devUsage => dev}/storehooks/questionnaire-response-store/updatable-response-items.mdx (100%) rename documentation/docs/{devUsage => dev}/storehooks/questionnaire-response-store/updatable-response.mdx (100%) rename documentation/docs/{devUsage => dev}/storehooks/questionnaire-store/calculated-expressions.mdx (100%) rename documentation/docs/{devUsage => dev}/storehooks/questionnaire-store/fhirpath-context.mdx (100%) rename documentation/docs/{devUsage => dev}/storehooks/questionnaire-store/focused-linkid.mdx (100%) rename documentation/docs/{devUsage => dev}/storehooks/questionnaire-store/index.mdx (100%) rename documentation/docs/{devUsage => dev}/storehooks/questionnaire-store/item-types.mdx (100%) rename documentation/docs/{devUsage => dev}/storehooks/questionnaire-store/source-questionnaire.mdx (100%) rename documentation/docs/{devUsage => dev}/storehooks/questionnaire-store/variables.mdx (100%) rename documentation/docs/{devUsage => dev}/storehooks/smart-config-store.mdx (95%) rename documentation/docs/{devUsage => dev}/storehooks/terminology-server-store/index.mdx (100%) rename documentation/docs/{devUsage => dev}/storehooks/terminology-server-store/url.mdx (100%) diff --git a/documentation/docs/devUsage/index.mdx b/documentation/docs/dev/index.mdx similarity index 67% rename from documentation/docs/devUsage/index.mdx rename to documentation/docs/dev/index.mdx index 06c2455a4..f18362aef 100644 --- a/documentation/docs/devUsage/index.mdx +++ b/documentation/docs/dev/index.mdx @@ -15,3 +15,8 @@ Smart Forms provides the following open-source TypeScript libraries: A reference implementation of the [SDC Populate Questionnaire](https://hl7.org/fhir/uv/sdc/OperationDefinition-Questionnaire-populate.html) operation, also known as $populate. Currently, there are no written documentation available for this library. Please refer to the [API](/docs/api/sdc-populate) for more information. + +3. **SDC Assemble** ([@aehrc/sdc-assemble](https://www.npmjs.com/package/@aehrc/sdc-assemble)) + + A reference implementation of the [SDC Assemble Questionnaire](https://hl7.org/fhir/uv/sdc/OperationDefinition-Questionnaire-assemble.html) operation, also known as $assemble. + Currently, there are no written documentation available for this library. Please refer to the [API](/docs/api/sdc-assemble) for more information. diff --git a/documentation/docs/devUsage/renderer-overview.mdx b/documentation/docs/dev/renderer-overview.mdx similarity index 100% rename from documentation/docs/devUsage/renderer-overview.mdx rename to documentation/docs/dev/renderer-overview.mdx diff --git a/documentation/docs/devUsage/renderer-utilities.mdx b/documentation/docs/dev/renderer-utilities.mdx similarity index 85% rename from documentation/docs/devUsage/renderer-utilities.mdx rename to documentation/docs/dev/renderer-utilities.mdx index e42f52f18..97570a4ec 100644 --- a/documentation/docs/devUsage/renderer-utilities.mdx +++ b/documentation/docs/dev/renderer-utilities.mdx @@ -8,25 +8,25 @@ The renderer provides a set of utilities to build and interact with the form. #### Functions -- [buildForm](/docs/devUsage/renderer-utilities#buildform) -- [destroyForm](/docs/devUsage/renderer-utilities#destroyform) -- [getResponse](/docs/devUsage/renderer-utilities#getresponse) -- [removeEmptyAnswersFromResponse](/docs/devUsage/renderer-utilities#removeemptyanswersfromresponse) +- [buildForm](/docs/dev/renderer-utilities#buildform) +- [destroyForm](/docs/dev/renderer-utilities#destroyform) +- [getResponse](/docs/dev/renderer-utilities#getresponse) +- [removeEmptyAnswersFromResponse](/docs/dev/renderer-utilities#removeemptyanswersfromresponse) #### Components -- [BaseRenderer](/docs/devUsage/renderer-utilities#baserenderer) -- [SmartFormsRenderer](/docs/devUsage/renderer-utilities#smartformsrenderer) (to be deprecated) -- [RendererThemeProvider](/docs/devUsage/renderer-utilities#rendererthemeprovider) +- [BaseRenderer](/docs/dev/renderer-utilities#baserenderer) +- [SmartFormsRenderer](/docs/dev/renderer-utilities#smartformsrenderer) (to be deprecated) +- [RendererThemeProvider](/docs/dev/renderer-utilities#rendererthemeprovider) #### Hooks -- [useBuildForm](/docs/devUsage/renderer-utilities#usebuildform) -- [useRendererQueryClient](/docs/devUsage/renderer-utilities#userendererqueryclient) -- [**QuestionnaireStore** state management hooks](/docs/devUsage/storehooks/questionnaire-store) -- [**QuestionnaireResponseStore** state management properties](/docs/devUsage/storehooks/questionnaire-response-store) -- [**SmartConfigStore state** management properties](/docs/devUsage/storehooks/smart-config-store) -- [**TerminologyServerStore** state management properties](/docs/devUsage/storehooks/terminology-server-store) +- [useBuildForm](/docs/dev/renderer-utilities#usebuildform) +- [useRendererQueryClient](/docs/dev/renderer-utilities#userendererqueryclient) +- [**QuestionnaireStore** state management hooks](/docs/dev/storehooks/questionnaire-store) +- [**QuestionnaireResponseStore** state management properties](/docs/dev/storehooks/questionnaire-response-store) +- [**SmartConfigStore state** management properties](/docs/dev/storehooks/smart-config-store) +- [**TerminologyServerStore** state management properties](/docs/dev/storehooks/terminology-server-store) :::note @@ -61,7 +61,7 @@ If no changes have been made to the form, the initial QuestionnaireResponse is r Use this if you are planning to use a button click to get the QuestionnaireResponse. -If you want to get the latest QuestionnaireResponse every time the form is changed, use the [QuestionnaireResponseStore `updatableResponse`](/docs/devUsage/storehooks/questionnaire-response-store/updatable-response) hook. +If you want to get the latest QuestionnaireResponse every time the form is changed, use the [QuestionnaireResponseStore `updatableResponse`](/docs/dev/storehooks/questionnaire-response-store/updatable-response) hook. ### RemoveEmptyAnswersFromResponse @@ -83,7 +83,7 @@ The `BaseRenderer` component is the main component that renders the form. It renders the Questionnaire and QuestionnaireResponse defined in the QuestionnaireStore and QuestionnaireResponseStore state management stores respectively. -[`buildForm()`](/docs/devUsage/renderer-utilities#buildform) used be used in your wrapping component or in an event handler to initialise the form before React renders the `BaseRenderer`. +[`buildForm()`](/docs/dev/renderer-utilities#buildform) used be used in your wrapping component or in an event handler to initialise the form before React renders the `BaseRenderer`. ### SmartFormsRenderer @@ -137,4 +137,4 @@ If you want to customise the renderer to use your own query client, refer to the ### State Management Hooks -Refer to the [Renderer Store Hooks](/docs/devUsage/storehooks) section for more information on the state management hooks provided by the renderer. +Refer to the [Renderer Store Hooks](/docs/dev/storehooks) section for more information on the state management hooks provided by the renderer. diff --git a/documentation/docs/devUsage/storehooks/index.mdx b/documentation/docs/dev/storehooks/index.mdx similarity index 94% rename from documentation/docs/devUsage/storehooks/index.mdx rename to documentation/docs/dev/storehooks/index.mdx index 8ce1650b9..6158ad0d0 100644 --- a/documentation/docs/devUsage/storehooks/index.mdx +++ b/documentation/docs/dev/storehooks/index.mdx @@ -14,7 +14,7 @@ The renderer uses four state management stores, each for a different purpose: - **SmartConfigStore**: Manages a FHIRClient instance for further FHIR calls if needed i.e. `answerExpression` extensions. - **TerminologyServerStore**: Manages the terminology server url to fetch terminology resources. -The usage examples provided in this section uses the BMI Calculator as its input questionnaire, with the exception of [TerminologyServerStore](/docs/devUsage/storehooks/terminology-server-store). +The usage examples provided in this section uses the BMI Calculator as its input questionnaire, with the exception of [TerminologyServerStore](/docs/dev/storehooks/terminology-server-store). As the BMI Calculator does not use all of the available properties, only properties relevant to the questionnaire are shown as examples. You can use [Playground](https://smartforms.csiro.au/playground) to try them out in real-time. diff --git a/documentation/docs/devUsage/storehooks/questionnaire-response-store/form-changes-history.mdx b/documentation/docs/dev/storehooks/questionnaire-response-store/form-changes-history.mdx similarity index 100% rename from documentation/docs/devUsage/storehooks/questionnaire-response-store/form-changes-history.mdx rename to documentation/docs/dev/storehooks/questionnaire-response-store/form-changes-history.mdx diff --git a/documentation/docs/devUsage/storehooks/questionnaire-response-store/index.mdx b/documentation/docs/dev/storehooks/questionnaire-response-store/index.mdx similarity index 100% rename from documentation/docs/devUsage/storehooks/questionnaire-response-store/index.mdx rename to documentation/docs/dev/storehooks/questionnaire-response-store/index.mdx diff --git a/documentation/docs/devUsage/storehooks/questionnaire-response-store/invalid-items.mdx b/documentation/docs/dev/storehooks/questionnaire-response-store/invalid-items.mdx similarity index 100% rename from documentation/docs/devUsage/storehooks/questionnaire-response-store/invalid-items.mdx rename to documentation/docs/dev/storehooks/questionnaire-response-store/invalid-items.mdx diff --git a/documentation/docs/devUsage/storehooks/questionnaire-response-store/response-is-valid.mdx b/documentation/docs/dev/storehooks/questionnaire-response-store/response-is-valid.mdx similarity index 100% rename from documentation/docs/devUsage/storehooks/questionnaire-response-store/response-is-valid.mdx rename to documentation/docs/dev/storehooks/questionnaire-response-store/response-is-valid.mdx diff --git a/documentation/docs/devUsage/storehooks/questionnaire-response-store/source-response.mdx b/documentation/docs/dev/storehooks/questionnaire-response-store/source-response.mdx similarity index 82% rename from documentation/docs/devUsage/storehooks/questionnaire-response-store/source-response.mdx rename to documentation/docs/dev/storehooks/questionnaire-response-store/source-response.mdx index 876c2ee62..7e5fce401 100644 --- a/documentation/docs/devUsage/storehooks/questionnaire-response-store/source-response.mdx +++ b/documentation/docs/dev/storehooks/questionnaire-response-store/source-response.mdx @@ -6,7 +6,7 @@ sidebar_position: 2 The sourceResponse is the first QuestionnaireResponse being passed into the renderer. If no response is passed in, an empty sourceResponse will be initialized by the renderer. -The sourceResponse does not change when the form gets edited - that is where the [`updatableResponse`](/docs/devUsage/storehooks/questionnaire-response-store/updatable-response) comes in. +The sourceResponse does not change when the form gets edited - that is where the [`updatableResponse`](/docs/dev/storehooks/questionnaire-response-store/updatable-response) comes in. ```tsx live function App() { diff --git a/documentation/docs/devUsage/storehooks/questionnaire-response-store/updatable-response-items.mdx b/documentation/docs/dev/storehooks/questionnaire-response-store/updatable-response-items.mdx similarity index 100% rename from documentation/docs/devUsage/storehooks/questionnaire-response-store/updatable-response-items.mdx rename to documentation/docs/dev/storehooks/questionnaire-response-store/updatable-response-items.mdx diff --git a/documentation/docs/devUsage/storehooks/questionnaire-response-store/updatable-response.mdx b/documentation/docs/dev/storehooks/questionnaire-response-store/updatable-response.mdx similarity index 100% rename from documentation/docs/devUsage/storehooks/questionnaire-response-store/updatable-response.mdx rename to documentation/docs/dev/storehooks/questionnaire-response-store/updatable-response.mdx diff --git a/documentation/docs/devUsage/storehooks/questionnaire-store/calculated-expressions.mdx b/documentation/docs/dev/storehooks/questionnaire-store/calculated-expressions.mdx similarity index 100% rename from documentation/docs/devUsage/storehooks/questionnaire-store/calculated-expressions.mdx rename to documentation/docs/dev/storehooks/questionnaire-store/calculated-expressions.mdx diff --git a/documentation/docs/devUsage/storehooks/questionnaire-store/fhirpath-context.mdx b/documentation/docs/dev/storehooks/questionnaire-store/fhirpath-context.mdx similarity index 100% rename from documentation/docs/devUsage/storehooks/questionnaire-store/fhirpath-context.mdx rename to documentation/docs/dev/storehooks/questionnaire-store/fhirpath-context.mdx diff --git a/documentation/docs/devUsage/storehooks/questionnaire-store/focused-linkid.mdx b/documentation/docs/dev/storehooks/questionnaire-store/focused-linkid.mdx similarity index 100% rename from documentation/docs/devUsage/storehooks/questionnaire-store/focused-linkid.mdx rename to documentation/docs/dev/storehooks/questionnaire-store/focused-linkid.mdx diff --git a/documentation/docs/devUsage/storehooks/questionnaire-store/index.mdx b/documentation/docs/dev/storehooks/questionnaire-store/index.mdx similarity index 100% rename from documentation/docs/devUsage/storehooks/questionnaire-store/index.mdx rename to documentation/docs/dev/storehooks/questionnaire-store/index.mdx diff --git a/documentation/docs/devUsage/storehooks/questionnaire-store/item-types.mdx b/documentation/docs/dev/storehooks/questionnaire-store/item-types.mdx similarity index 100% rename from documentation/docs/devUsage/storehooks/questionnaire-store/item-types.mdx rename to documentation/docs/dev/storehooks/questionnaire-store/item-types.mdx diff --git a/documentation/docs/devUsage/storehooks/questionnaire-store/source-questionnaire.mdx b/documentation/docs/dev/storehooks/questionnaire-store/source-questionnaire.mdx similarity index 100% rename from documentation/docs/devUsage/storehooks/questionnaire-store/source-questionnaire.mdx rename to documentation/docs/dev/storehooks/questionnaire-store/source-questionnaire.mdx diff --git a/documentation/docs/devUsage/storehooks/questionnaire-store/variables.mdx b/documentation/docs/dev/storehooks/questionnaire-store/variables.mdx similarity index 100% rename from documentation/docs/devUsage/storehooks/questionnaire-store/variables.mdx rename to documentation/docs/dev/storehooks/questionnaire-store/variables.mdx diff --git a/documentation/docs/devUsage/storehooks/smart-config-store.mdx b/documentation/docs/dev/storehooks/smart-config-store.mdx similarity index 95% rename from documentation/docs/devUsage/storehooks/smart-config-store.mdx rename to documentation/docs/dev/storehooks/smart-config-store.mdx index 6994194c0..5fa094d65 100644 --- a/documentation/docs/devUsage/storehooks/smart-config-store.mdx +++ b/documentation/docs/dev/storehooks/smart-config-store.mdx @@ -31,7 +31,7 @@ Refer to the [API Reference](/docs/api/smart-forms-renderer/interfaces/SmartConf The SmartConfigStore doesn't actually do much within the renderer at the moment. It is not tested thoroughly and is retained for backward compatibility purposes. -Terminology endpoints are managed in [TerminologyServerStore](/docs/devUsage/storehooks/terminology-server-store). +Terminology endpoints are managed in [TerminologyServerStore](/docs/dev/storehooks/terminology-server-store). If there is a need to expand on functionality of making FHIR calls within the renderer, feel free to [let us know](https://github.com/aehrc/smart-forms/issues/new). From a best practice perspective, it is recommended to perform FHIR calls outside of the renderer and pass the pre-populated QuestionnaireResponse into the renderer. diff --git a/documentation/docs/devUsage/storehooks/terminology-server-store/index.mdx b/documentation/docs/dev/storehooks/terminology-server-store/index.mdx similarity index 100% rename from documentation/docs/devUsage/storehooks/terminology-server-store/index.mdx rename to documentation/docs/dev/storehooks/terminology-server-store/index.mdx diff --git a/documentation/docs/devUsage/storehooks/terminology-server-store/url.mdx b/documentation/docs/dev/storehooks/terminology-server-store/url.mdx similarity index 100% rename from documentation/docs/devUsage/storehooks/terminology-server-store/url.mdx rename to documentation/docs/dev/storehooks/terminology-server-store/url.mdx diff --git a/documentation/docusaurus.config.ts b/documentation/docusaurus.config.ts index 35807377b..fbe558337 100644 --- a/documentation/docusaurus.config.ts +++ b/documentation/docusaurus.config.ts @@ -80,7 +80,7 @@ const config: Config = { }, { type: 'docSidebar', - sidebarId: 'devUsageSidebar', + sidebarId: 'devSidebar', position: 'left', label: 'Developer Usage' }, diff --git a/documentation/sidebars.ts b/documentation/sidebars.ts index b5aff2524..33ad8e57e 100644 --- a/documentation/sidebars.ts +++ b/documentation/sidebars.ts @@ -14,8 +14,8 @@ const sidebars: SidebarsConfig = { // By default, Docusaurus generates a sidebar from the docs folder structure componentsSidebar: [{ type: 'autogenerated', dirName: 'components' }], sdcSidebar: [{ type: 'autogenerated', dirName: 'sdc' }], - devUsageSidebar: [ - { type: 'autogenerated', dirName: 'devUsage' }, + devSidebar: [ + { type: 'autogenerated', dirName: 'dev' }, { type: 'link', label: 'Playground', href: 'https://smartforms.csiro.au/playground' } ], apiSidebar: [{ type: 'autogenerated', dirName: 'api' }] diff --git a/packages/smart-forms-renderer/README.md b/packages/smart-forms-renderer/README.md index ad28ce43e..363eaa577 100644 --- a/packages/smart-forms-renderer/README.md +++ b/packages/smart-forms-renderer/README.md @@ -3,7 +3,7 @@ A React-based library that contains the Questionnaire renderer used in the Smart Forms app. It acts as a reference implementation for the [SDC Form Filler](https://hl7.org/fhir/uv/sdc/CapabilityStatement-sdc-form-filler.html). -

Check out the documentation 📚

+

Check out the documentation 📚

--- From 0767f5e256a91e432ebe52509314e91cbf33e248 Mon Sep 17 00:00:00 2001 From: Sean Fong Date: Fri, 5 Jul 2024 15:02:32 +0930 Subject: [PATCH 2/4] Add sdc-assemble typedoc API to docs --- .../api/sdc-assemble/functions/assemble.md | 19 + .../functions/isInputParameters.md | 21 + documentation/docs/api/sdc-assemble/index.md | 17 + .../interfaces/FetchQuestionnaireCallback.md | 49 + .../interfaces/InputParameters.md | 111 +++ .../interfaces/OutcomeParameter.md | 849 ++++++++++++++++++ .../interfaces/OutputParameters.md | 111 +++ .../docs/api/sdc-assemble/typedoc-sidebar.cjs | 47 + documentation/docs/index.md | 2 +- documentation/docusaurus.config.ts | 21 + .../src/interfaces/callback.interface.ts | 27 +- .../src/interfaces/parameters.interface.ts | 6 + 12 files changed, 1274 insertions(+), 6 deletions(-) create mode 100644 documentation/docs/api/sdc-assemble/functions/assemble.md create mode 100644 documentation/docs/api/sdc-assemble/functions/isInputParameters.md create mode 100644 documentation/docs/api/sdc-assemble/index.md create mode 100644 documentation/docs/api/sdc-assemble/interfaces/FetchQuestionnaireCallback.md create mode 100644 documentation/docs/api/sdc-assemble/interfaces/InputParameters.md create mode 100644 documentation/docs/api/sdc-assemble/interfaces/OutcomeParameter.md create mode 100644 documentation/docs/api/sdc-assemble/interfaces/OutputParameters.md create mode 100644 documentation/docs/api/sdc-assemble/typedoc-sidebar.cjs diff --git a/documentation/docs/api/sdc-assemble/functions/assemble.md b/documentation/docs/api/sdc-assemble/functions/assemble.md new file mode 100644 index 000000000..7cd85cc55 --- /dev/null +++ b/documentation/docs/api/sdc-assemble/functions/assemble.md @@ -0,0 +1,19 @@ +# Function: assemble() + +> **assemble**(`parameters`, `fetchQuestionnaireCallback`, `fetchQuestionnaireRequestConfig`): `Promise`\<`Questionnaire` \| `OperationOutcome` \| [`OutputParameters`](../interfaces/OutputParameters.md)\> + +The $assemble operation - https://build.fhir.org/ig/HL7/sdc/OperationDefinition-Questionnaire-assemble.html + +## Parameters + +| Parameter | Type | Description | +| :------ | :------ | :------ | +| `parameters` | [`InputParameters`](../interfaces/InputParameters.md) | The input parameters for $assemble | +| `fetchQuestionnaireCallback` | [`FetchQuestionnaireCallback`](../interfaces/FetchQuestionnaireCallback.md) | A callback function defined by the implementer to fetch Questionnaire resources by a canonical url | +| `fetchQuestionnaireRequestConfig` | `any` | A request configuration object to be passed to the callback function | + +## Returns + +`Promise`\<`Questionnaire` \| `OperationOutcome` \| [`OutputParameters`](../interfaces/OutputParameters.md)\> + +A fully assembled questionnaire, an operationOutcome error(if present) or both (if there are warnings) diff --git a/documentation/docs/api/sdc-assemble/functions/isInputParameters.md b/documentation/docs/api/sdc-assemble/functions/isInputParameters.md new file mode 100644 index 000000000..77aaaef87 --- /dev/null +++ b/documentation/docs/api/sdc-assemble/functions/isInputParameters.md @@ -0,0 +1,21 @@ +# Function: isInputParameters() + +> **isInputParameters**(`parameters`): `parameters is InputParameters` + +Check if the given parameters is a valid InputParameters for $assemble + +## Parameters + +| Parameter | Type | Description | +| :------ | :------ | :------ | +| `parameters` | `Parameters` | a given Parameters resource | + +## Returns + +`parameters is InputParameters` + +boolean value of whether the given parameters is InputParameters + +## See + +[http://hl7.org/fhir/uv/sdc/OperationDefinition/Questionnaire-assemble](http://hl7.org/fhir/uv/sdc/OperationDefinition/Questionnaire-assemble) diff --git a/documentation/docs/api/sdc-assemble/index.md b/documentation/docs/api/sdc-assemble/index.md new file mode 100644 index 000000000..4a80bb1a6 --- /dev/null +++ b/documentation/docs/api/sdc-assemble/index.md @@ -0,0 +1,17 @@ +# @aehrc/sdc-assemble + +## Interfaces + +| Interface | Description | +| :------ | :------ | +| [FetchQuestionnaireCallback](interfaces/FetchQuestionnaireCallback.md) | - | +| [InputParameters](interfaces/InputParameters.md) | Input parameters for the $assemble operation | +| [OutcomeParameter](interfaces/OutcomeParameter.md) | Output parameter from $assemble's 'outcome' parameter | +| [OutputParameters](interfaces/OutputParameters.md) | Output parameters for the $assemble operation | + +## Functions + +| Function | Description | +| :------ | :------ | +| [assemble](functions/assemble.md) | The $assemble operation - https://build.fhir.org/ig/HL7/sdc/OperationDefinition-Questionnaire-assemble.html | +| [isInputParameters](functions/isInputParameters.md) | Check if the given parameters is a valid InputParameters for $assemble | diff --git a/documentation/docs/api/sdc-assemble/interfaces/FetchQuestionnaireCallback.md b/documentation/docs/api/sdc-assemble/interfaces/FetchQuestionnaireCallback.md new file mode 100644 index 000000000..9694dd20d --- /dev/null +++ b/documentation/docs/api/sdc-assemble/interfaces/FetchQuestionnaireCallback.md @@ -0,0 +1,49 @@ +# Interface: FetchQuestionnaireCallback() + +To define a method to fetch Questionnaire resources from the FHIR server with the given canonical URL + +## See + +[https://www.hl7.org/fhir/questionnaire.html](https://www.hl7.org/fhir/questionnaire.html) + +## Example + +```ts +const fetchQuestionnaireCallback: FetchQuestionnaireCallback = async ( + canonicalUrl: string, + requestConfig: {url: string, authToken?: string} +) => { + const { url, authToken } = requestConfig; + + let requestUrl = url; + if (!requestUrl.endsWith('/')) { + requestUrl += '/'; + } + requestUrl += `Questionnaire?url=${canonicalUrl}`; + + const headers = authToken ? { ...HEADERS, Authorization: `Bearer ${authToken}` } : HEADERS; + + const response = await fetch(requestUrl, { + headers: headers + }); + + if (!response.ok) { + throw new Error(`HTTP error when performing ${requestUrl}. Status: ${response.status}`); + } + + return response.json(); +}; +``` + +> **FetchQuestionnaireCallback**(`canonicalUrl`, `requestConfig`?): `Promise`\<`any`\> + +## Parameters + +| Parameter | Type | +| :------ | :------ | +| `canonicalUrl` | `string` | +| `requestConfig`? | `any` | + +## Returns + +`Promise`\<`any`\> diff --git a/documentation/docs/api/sdc-assemble/interfaces/InputParameters.md b/documentation/docs/api/sdc-assemble/interfaces/InputParameters.md new file mode 100644 index 000000000..2205c2641 --- /dev/null +++ b/documentation/docs/api/sdc-assemble/interfaces/InputParameters.md @@ -0,0 +1,111 @@ +# Interface: InputParameters + +Input parameters for the $assemble operation + +## See + +[http://hl7.org/fhir/uv/sdc/OperationDefinition/Questionnaire-assemble](http://hl7.org/fhir/uv/sdc/OperationDefinition/Questionnaire-assemble) + +## Extends + +- `Parameters` + +## Properties + +### \_id? + +> `optional` **\_id**: `Element` + +#### Inherited from + +`Parameters._id` + +*** + +### \_implicitRules? + +> `optional` **\_implicitRules**: `Element` + +#### Inherited from + +`Parameters._implicitRules` + +*** + +### \_language? + +> `optional` **\_language**: `Element` + +#### Inherited from + +`Parameters._language` + +*** + +### id? + +> `optional` **id**: `string` + +The only time that a resource does not have an id is when it is being submitted to the server using a create operation. + +#### Inherited from + +`Parameters.id` + +*** + +### implicitRules? + +> `optional` **implicitRules**: `string` + +Asserting this rule set restricts the content to be only understood by a limited set of trading partners. This inherently limits the usefulness of the data in the long term. However, the existing health eco-system is highly fractured, and not yet ready to define, collect, and exchange data in a generally computable sense. Wherever possible, implementers and/or specification writers should avoid using this element. Often, when used, the URL is a reference to an implementation guide that defines these special rules as part of it's narrative along with other profiles, value sets, etc. + +#### Inherited from + +`Parameters.implicitRules` + +*** + +### language? + +> `optional` **language**: `string` + +Language is provided to support indexing and accessibility (typically, services such as text to speech use the language tag). The html language tag in the narrative applies to the narrative. The language tag on the resource may be used to specify the language of other presentations generated from the data in the resource. Not all the content has to be in the base language. The Resource.language should not be assumed to apply to the narrative automatically. If a language is specified, it should it also be specified on the div element in the html (see rules in HTML5 for information about the relationship between xml:lang and the html lang attribute). + +#### Inherited from + +`Parameters.language` + +*** + +### meta? + +> `optional` **meta**: `Meta` + +The metadata about the resource. This is content that is maintained by the infrastructure. Changes to the content might not always be associated with version changes to the resource. + +#### Inherited from + +`Parameters.meta` + +*** + +### parameter + +> **parameter**: [`object`] + +#### Overrides + +`Parameters.parameter` + +*** + +### resourceType + +> `readonly` **resourceType**: `"Parameters"` + +Resource Type Name (for serialization) + +#### Inherited from + +`Parameters.resourceType` diff --git a/documentation/docs/api/sdc-assemble/interfaces/OutcomeParameter.md b/documentation/docs/api/sdc-assemble/interfaces/OutcomeParameter.md new file mode 100644 index 000000000..af972b7d5 --- /dev/null +++ b/documentation/docs/api/sdc-assemble/interfaces/OutcomeParameter.md @@ -0,0 +1,849 @@ +# Interface: OutcomeParameter + +Output parameter from $assemble's 'outcome' parameter + +## See + +[http://hl7.org/fhir/uv/sdc/OperationDefinition/Questionnaire-assemble](http://hl7.org/fhir/uv/sdc/OperationDefinition/Questionnaire-assemble) + +## Extends + +- `ParametersParameter` + +## Properties + +### \_id? + +> `optional` **\_id**: `Element` + +#### Inherited from + +`ParametersParameter._id` + +*** + +### \_name? + +> `optional` **\_name**: `Element` + +#### Inherited from + +`ParametersParameter._name` + +*** + +### \_valueBase64Binary? + +> `optional` **\_valueBase64Binary**: `Element` + +#### Inherited from + +`ParametersParameter._valueBase64Binary` + +*** + +### \_valueBoolean? + +> `optional` **\_valueBoolean**: `Element` + +#### Inherited from + +`ParametersParameter._valueBoolean` + +*** + +### \_valueCanonical? + +> `optional` **\_valueCanonical**: `Element` + +#### Inherited from + +`ParametersParameter._valueCanonical` + +*** + +### \_valueCode? + +> `optional` **\_valueCode**: `Element` + +#### Inherited from + +`ParametersParameter._valueCode` + +*** + +### \_valueDate? + +> `optional` **\_valueDate**: `Element` + +#### Inherited from + +`ParametersParameter._valueDate` + +*** + +### \_valueDateTime? + +> `optional` **\_valueDateTime**: `Element` + +#### Inherited from + +`ParametersParameter._valueDateTime` + +*** + +### \_valueId? + +> `optional` **\_valueId**: `Element` + +#### Inherited from + +`ParametersParameter._valueId` + +*** + +### \_valueInstant? + +> `optional` **\_valueInstant**: `Element` + +#### Inherited from + +`ParametersParameter._valueInstant` + +*** + +### \_valueMarkdown? + +> `optional` **\_valueMarkdown**: `Element` + +#### Inherited from + +`ParametersParameter._valueMarkdown` + +*** + +### \_valueOid? + +> `optional` **\_valueOid**: `Element` + +#### Inherited from + +`ParametersParameter._valueOid` + +*** + +### \_valueString? + +> `optional` **\_valueString**: `Element` + +#### Inherited from + +`ParametersParameter._valueString` + +*** + +### \_valueTime? + +> `optional` **\_valueTime**: `Element` + +#### Inherited from + +`ParametersParameter._valueTime` + +*** + +### \_valueUri? + +> `optional` **\_valueUri**: `Element` + +#### Inherited from + +`ParametersParameter._valueUri` + +*** + +### \_valueUrl? + +> `optional` **\_valueUrl**: `Element` + +#### Inherited from + +`ParametersParameter._valueUrl` + +*** + +### \_valueUuid? + +> `optional` **\_valueUuid**: `Element` + +#### Inherited from + +`ParametersParameter._valueUuid` + +*** + +### extension? + +> `optional` **extension**: `Extension`[] + +There can be no stigma associated with the use of extensions by any application, project, or standard - regardless of the institution or jurisdiction that uses or defines the extensions. The use of extensions is what allows the FHIR specification to retain a core level of simplicity for everyone. + +#### Inherited from + +`ParametersParameter.extension` + +*** + +### id? + +> `optional` **id**: `string` + +Unique id for the element within a resource (for internal references). This may be any string value that does not contain spaces. + +#### Inherited from + +`ParametersParameter.id` + +*** + +### modifierExtension? + +> `optional` **modifierExtension**: `Extension`[] + +There can be no stigma associated with the use of extensions by any application, project, or standard - regardless of the institution or jurisdiction that uses or defines the extensions. The use of extensions is what allows the FHIR specification to retain a core level of simplicity for everyone. + +#### Inherited from + +`ParametersParameter.modifierExtension` + +*** + +### name + +> **name**: `"outcome"` + +#### Overrides + +`ParametersParameter.name` + +*** + +### part? + +> `optional` **part**: `ParametersParameter`[] + +Only one level of nested parameters is allowed. + +#### Inherited from + +`ParametersParameter.part` + +*** + +### resource + +> **resource**: `OperationOutcome` + +#### Overrides + +`ParametersParameter.resource` + +*** + +### valueAddress? + +> `optional` **valueAddress**: `Address` + +If the parameter is a data type. + +#### Inherited from + +`ParametersParameter.valueAddress` + +*** + +### valueAge? + +> `optional` **valueAge**: `Age` + +If the parameter is a data type. + +#### Inherited from + +`ParametersParameter.valueAge` + +*** + +### valueAnnotation? + +> `optional` **valueAnnotation**: `Annotation` + +If the parameter is a data type. + +#### Inherited from + +`ParametersParameter.valueAnnotation` + +*** + +### valueAttachment? + +> `optional` **valueAttachment**: `Attachment` + +If the parameter is a data type. + +#### Inherited from + +`ParametersParameter.valueAttachment` + +*** + +### valueBase64Binary? + +> `optional` **valueBase64Binary**: `string` + +If the parameter is a data type. + +#### Inherited from + +`ParametersParameter.valueBase64Binary` + +*** + +### valueBoolean? + +> `optional` **valueBoolean**: `boolean` + +If the parameter is a data type. + +#### Inherited from + +`ParametersParameter.valueBoolean` + +*** + +### valueCanonical? + +> `optional` **valueCanonical**: `string` + +If the parameter is a data type. + +#### Inherited from + +`ParametersParameter.valueCanonical` + +*** + +### valueCode? + +> `optional` **valueCode**: `string` + +If the parameter is a data type. + +#### Inherited from + +`ParametersParameter.valueCode` + +*** + +### valueCodeableConcept? + +> `optional` **valueCodeableConcept**: `CodeableConcept` + +If the parameter is a data type. + +#### Inherited from + +`ParametersParameter.valueCodeableConcept` + +*** + +### valueCoding? + +> `optional` **valueCoding**: `Coding` + +If the parameter is a data type. + +#### Inherited from + +`ParametersParameter.valueCoding` + +*** + +### valueContactDetail? + +> `optional` **valueContactDetail**: `ContactDetail` + +If the parameter is a data type. + +#### Inherited from + +`ParametersParameter.valueContactDetail` + +*** + +### valueContactPoint? + +> `optional` **valueContactPoint**: `ContactPoint` + +If the parameter is a data type. + +#### Inherited from + +`ParametersParameter.valueContactPoint` + +*** + +### valueContributor? + +> `optional` **valueContributor**: `Contributor` + +If the parameter is a data type. + +#### Inherited from + +`ParametersParameter.valueContributor` + +*** + +### valueCount? + +> `optional` **valueCount**: `Count` + +If the parameter is a data type. + +#### Inherited from + +`ParametersParameter.valueCount` + +*** + +### valueDataRequirement? + +> `optional` **valueDataRequirement**: `DataRequirement` + +If the parameter is a data type. + +#### Inherited from + +`ParametersParameter.valueDataRequirement` + +*** + +### valueDate? + +> `optional` **valueDate**: `string` + +If the parameter is a data type. + +#### Inherited from + +`ParametersParameter.valueDate` + +*** + +### valueDateTime? + +> `optional` **valueDateTime**: `string` + +If the parameter is a data type. + +#### Inherited from + +`ParametersParameter.valueDateTime` + +*** + +### valueDecimal? + +> `optional` **valueDecimal**: `number` + +If the parameter is a data type. + +#### Inherited from + +`ParametersParameter.valueDecimal` + +*** + +### valueDistance? + +> `optional` **valueDistance**: `Distance` + +If the parameter is a data type. + +#### Inherited from + +`ParametersParameter.valueDistance` + +*** + +### valueDosage? + +> `optional` **valueDosage**: `Dosage` + +If the parameter is a data type. + +#### Inherited from + +`ParametersParameter.valueDosage` + +*** + +### valueDuration? + +> `optional` **valueDuration**: `Duration` + +If the parameter is a data type. + +#### Inherited from + +`ParametersParameter.valueDuration` + +*** + +### valueExpression? + +> `optional` **valueExpression**: `Expression` + +If the parameter is a data type. + +#### Inherited from + +`ParametersParameter.valueExpression` + +*** + +### valueHumanName? + +> `optional` **valueHumanName**: `HumanName` + +If the parameter is a data type. + +#### Inherited from + +`ParametersParameter.valueHumanName` + +*** + +### valueId? + +> `optional` **valueId**: `string` + +If the parameter is a data type. + +#### Inherited from + +`ParametersParameter.valueId` + +*** + +### valueIdentifier? + +> `optional` **valueIdentifier**: `Identifier` + +If the parameter is a data type. + +#### Inherited from + +`ParametersParameter.valueIdentifier` + +*** + +### valueInstant? + +> `optional` **valueInstant**: `string` + +If the parameter is a data type. + +#### Inherited from + +`ParametersParameter.valueInstant` + +*** + +### valueInteger? + +> `optional` **valueInteger**: `number` + +If the parameter is a data type. + +#### Inherited from + +`ParametersParameter.valueInteger` + +*** + +### valueMarkdown? + +> `optional` **valueMarkdown**: `string` + +If the parameter is a data type. + +#### Inherited from + +`ParametersParameter.valueMarkdown` + +*** + +### valueMeta? + +> `optional` **valueMeta**: `Meta` + +If the parameter is a data type. + +#### Inherited from + +`ParametersParameter.valueMeta` + +*** + +### valueMoney? + +> `optional` **valueMoney**: `Money` + +If the parameter is a data type. + +#### Inherited from + +`ParametersParameter.valueMoney` + +*** + +### valueOid? + +> `optional` **valueOid**: `string` + +If the parameter is a data type. + +#### Inherited from + +`ParametersParameter.valueOid` + +*** + +### valueParameterDefinition? + +> `optional` **valueParameterDefinition**: `ParameterDefinition` + +If the parameter is a data type. + +#### Inherited from + +`ParametersParameter.valueParameterDefinition` + +*** + +### valuePeriod? + +> `optional` **valuePeriod**: `Period` + +If the parameter is a data type. + +#### Inherited from + +`ParametersParameter.valuePeriod` + +*** + +### valuePositiveInt? + +> `optional` **valuePositiveInt**: `number` + +If the parameter is a data type. + +#### Inherited from + +`ParametersParameter.valuePositiveInt` + +*** + +### valueQuantity? + +> `optional` **valueQuantity**: `Quantity` + +If the parameter is a data type. + +#### Inherited from + +`ParametersParameter.valueQuantity` + +*** + +### valueRange? + +> `optional` **valueRange**: `Range` + +If the parameter is a data type. + +#### Inherited from + +`ParametersParameter.valueRange` + +*** + +### valueRatio? + +> `optional` **valueRatio**: `Ratio` + +If the parameter is a data type. + +#### Inherited from + +`ParametersParameter.valueRatio` + +*** + +### valueReference? + +> `optional` **valueReference**: `Reference` + +If the parameter is a data type. + +#### Inherited from + +`ParametersParameter.valueReference` + +*** + +### valueRelatedArtifact? + +> `optional` **valueRelatedArtifact**: `RelatedArtifact` + +If the parameter is a data type. + +#### Inherited from + +`ParametersParameter.valueRelatedArtifact` + +*** + +### valueSampledData? + +> `optional` **valueSampledData**: `SampledData` + +If the parameter is a data type. + +#### Inherited from + +`ParametersParameter.valueSampledData` + +*** + +### valueSignature? + +> `optional` **valueSignature**: `Signature` + +If the parameter is a data type. + +#### Inherited from + +`ParametersParameter.valueSignature` + +*** + +### valueString? + +> `optional` **valueString**: `string` + +If the parameter is a data type. + +#### Inherited from + +`ParametersParameter.valueString` + +*** + +### valueTime? + +> `optional` **valueTime**: `string` + +If the parameter is a data type. + +#### Inherited from + +`ParametersParameter.valueTime` + +*** + +### valueTiming? + +> `optional` **valueTiming**: `Timing` + +If the parameter is a data type. + +#### Inherited from + +`ParametersParameter.valueTiming` + +*** + +### valueTriggerDefinition? + +> `optional` **valueTriggerDefinition**: `TriggerDefinition` + +If the parameter is a data type. + +#### Inherited from + +`ParametersParameter.valueTriggerDefinition` + +*** + +### valueUnsignedInt? + +> `optional` **valueUnsignedInt**: `number` + +If the parameter is a data type. + +#### Inherited from + +`ParametersParameter.valueUnsignedInt` + +*** + +### valueUri? + +> `optional` **valueUri**: `string` + +If the parameter is a data type. + +#### Inherited from + +`ParametersParameter.valueUri` + +*** + +### valueUrl? + +> `optional` **valueUrl**: `string` + +If the parameter is a data type. + +#### Inherited from + +`ParametersParameter.valueUrl` + +*** + +### valueUsageContext? + +> `optional` **valueUsageContext**: `UsageContext` + +If the parameter is a data type. + +#### Inherited from + +`ParametersParameter.valueUsageContext` + +*** + +### valueUuid? + +> `optional` **valueUuid**: `string` + +If the parameter is a data type. + +#### Inherited from + +`ParametersParameter.valueUuid` diff --git a/documentation/docs/api/sdc-assemble/interfaces/OutputParameters.md b/documentation/docs/api/sdc-assemble/interfaces/OutputParameters.md new file mode 100644 index 000000000..6189cce7c --- /dev/null +++ b/documentation/docs/api/sdc-assemble/interfaces/OutputParameters.md @@ -0,0 +1,111 @@ +# Interface: OutputParameters + +Output parameters for the $assemble operation + +## See + +[http://hl7.org/fhir/uv/sdc/OperationDefinition/Questionnaire-assemble](http://hl7.org/fhir/uv/sdc/OperationDefinition/Questionnaire-assemble) + +## Extends + +- `Parameters` + +## Properties + +### \_id? + +> `optional` **\_id**: `Element` + +#### Inherited from + +`Parameters._id` + +*** + +### \_implicitRules? + +> `optional` **\_implicitRules**: `Element` + +#### Inherited from + +`Parameters._implicitRules` + +*** + +### \_language? + +> `optional` **\_language**: `Element` + +#### Inherited from + +`Parameters._language` + +*** + +### id? + +> `optional` **id**: `string` + +The only time that a resource does not have an id is when it is being submitted to the server using a create operation. + +#### Inherited from + +`Parameters.id` + +*** + +### implicitRules? + +> `optional` **implicitRules**: `string` + +Asserting this rule set restricts the content to be only understood by a limited set of trading partners. This inherently limits the usefulness of the data in the long term. However, the existing health eco-system is highly fractured, and not yet ready to define, collect, and exchange data in a generally computable sense. Wherever possible, implementers and/or specification writers should avoid using this element. Often, when used, the URL is a reference to an implementation guide that defines these special rules as part of it's narrative along with other profiles, value sets, etc. + +#### Inherited from + +`Parameters.implicitRules` + +*** + +### language? + +> `optional` **language**: `string` + +Language is provided to support indexing and accessibility (typically, services such as text to speech use the language tag). The html language tag in the narrative applies to the narrative. The language tag on the resource may be used to specify the language of other presentations generated from the data in the resource. Not all the content has to be in the base language. The Resource.language should not be assumed to apply to the narrative automatically. If a language is specified, it should it also be specified on the div element in the html (see rules in HTML5 for information about the relationship between xml:lang and the html lang attribute). + +#### Inherited from + +`Parameters.language` + +*** + +### meta? + +> `optional` **meta**: `Meta` + +The metadata about the resource. This is content that is maintained by the infrastructure. Changes to the content might not always be associated with version changes to the resource. + +#### Inherited from + +`Parameters.meta` + +*** + +### parameter + +> **parameter**: [`ReturnParameter`, [`OutcomeParameter`](OutcomeParameter.md)] + +#### Overrides + +`Parameters.parameter` + +*** + +### resourceType + +> `readonly` **resourceType**: `"Parameters"` + +Resource Type Name (for serialization) + +#### Inherited from + +`Parameters.resourceType` diff --git a/documentation/docs/api/sdc-assemble/typedoc-sidebar.cjs b/documentation/docs/api/sdc-assemble/typedoc-sidebar.cjs new file mode 100644 index 000000000..956829b44 --- /dev/null +++ b/documentation/docs/api/sdc-assemble/typedoc-sidebar.cjs @@ -0,0 +1,47 @@ +// @ts-check +/** @type {import('@docusaurus/plugin-content-docs').SidebarsConfig} */ +const typedocSidebar = { items: [ + { + "type": "category", + "label": "Interfaces", + "items": [ + { + "type": "doc", + "id": "api/sdc-assemble/interfaces/FetchQuestionnaireCallback", + "label": "FetchQuestionnaireCallback" + }, + { + "type": "doc", + "id": "api/sdc-assemble/interfaces/InputParameters", + "label": "InputParameters" + }, + { + "type": "doc", + "id": "api/sdc-assemble/interfaces/OutcomeParameter", + "label": "OutcomeParameter" + }, + { + "type": "doc", + "id": "api/sdc-assemble/interfaces/OutputParameters", + "label": "OutputParameters" + } + ] + }, + { + "type": "category", + "label": "Functions", + "items": [ + { + "type": "doc", + "id": "api/sdc-assemble/functions/assemble", + "label": "assemble" + }, + { + "type": "doc", + "id": "api/sdc-assemble/functions/isInputParameters", + "label": "isInputParameters" + } + ] + } +]}; +module.exports = typedocSidebar.items; \ No newline at end of file diff --git a/documentation/docs/index.md b/documentation/docs/index.md index c59e2171b..9dd5222ba 100644 --- a/documentation/docs/index.md +++ b/documentation/docs/index.md @@ -13,7 +13,7 @@ It is intended to demonstrate the use of [HL7 FHIR](https://hl7.org/fhir/) speci This documentation is intended to provide a guide on how to use Smart Forms. It is divided into the following sections: - [Components](/docs/components): A showcase of supported Questionnaire form components. - [SDC](/docs/sdc): A section around the conformance and usage of functionalities defined in the SDC specification. -- [Developer Usage](/docs/devUsage): A guide on how to use the form renderer in your own application. +- [Developer Usage](/docs/dev): A guide on how to use the form renderer in your own application. ### Referenced FHIR Specifications diff --git a/documentation/docusaurus.config.ts b/documentation/docusaurus.config.ts index fbe558337..6c75a530b 100644 --- a/documentation/docusaurus.config.ts +++ b/documentation/docusaurus.config.ts @@ -209,6 +209,27 @@ const config: Config = { enumMembersFormat: 'table', readme: 'none' } + ], + [ + 'docusaurus-plugin-typedoc', + // Options + { + id: 'sdc-assemble', + entryPoints: '../packages/sdc-assemble/src/index.ts', + tsconfig: '../packages/sdc-assemble/tsconfig.json', + out: 'docs/api/sdc-assemble', + excludeTags: ['@author'], + sidebar: { + autoConfiguration: true, + pretty: true + }, + plugin: ['typedoc-plugin-frontmatter'], + indexFormat: 'table', + disableSources: true, + parametersFormat: 'table', + enumMembersFormat: 'table', + readme: 'none' + } ] ] }; diff --git a/packages/sdc-assemble/src/interfaces/callback.interface.ts b/packages/sdc-assemble/src/interfaces/callback.interface.ts index eb850dda0..7d96e9789 100644 --- a/packages/sdc-assemble/src/interfaces/callback.interface.ts +++ b/packages/sdc-assemble/src/interfaces/callback.interface.ts @@ -24,12 +24,29 @@ * @returns A promise of the Questionnaire Bundle resource (or an error)! * * @example - * const fetchQuestionnaireCallback: FetchQuestionnaireCallback = (canonicalUrl: string, requestConfig: any) => { - * const { endpoint, token } = requestConfig; - * return axios.get(`${endpoint}/Questionnaire?url=${canonicalUrl}`, { - * method: 'GET', - * headers: { Accept: 'application/json;charset=utf-8', Authorization: `Bearer ${token}`, } + * const fetchQuestionnaireCallback: FetchQuestionnaireCallback = async ( + * canonicalUrl: string, + * requestConfig: {url: string, authToken?: string} + * ) => { + * const { url, authToken } = requestConfig; + * + * let requestUrl = url; + * if (!requestUrl.endsWith('/')) { + * requestUrl += '/'; + * } + * requestUrl += `Questionnaire?url=${canonicalUrl}`; + * + * const headers = authToken ? { ...HEADERS, Authorization: `Bearer ${authToken}` } : HEADERS; + * + * const response = await fetch(requestUrl, { + * headers: headers * }); + * + * if (!response.ok) { + * throw new Error(`HTTP error when performing ${requestUrl}. Status: ${response.status}`); + * } + * + * return response.json(); * }; * * @author Sean Fong diff --git a/packages/sdc-assemble/src/interfaces/parameters.interface.ts b/packages/sdc-assemble/src/interfaces/parameters.interface.ts index 50a8c512f..1903bbca2 100644 --- a/packages/sdc-assemble/src/interfaces/parameters.interface.ts +++ b/packages/sdc-assemble/src/interfaces/parameters.interface.ts @@ -47,6 +47,12 @@ interface ReturnParameter extends ParametersParameter { resource: Questionnaire; } +/** + * Output parameter from $assemble's 'outcome' parameter + * @see {@link http://hl7.org/fhir/uv/sdc/OperationDefinition/Questionnaire-assemble} + * + * @author Sean Fong + */ export interface OutcomeParameter extends ParametersParameter { name: 'outcome'; resource: OperationOutcome; From 8d0cd2bf8fe65ee540ef0772e9bd71ac231b3545 Mon Sep 17 00:00:00 2001 From: Sean Fong Date: Mon, 8 Jul 2024 15:29:41 +0930 Subject: [PATCH 3/4] Fix calculated expressions map Q to QR index --- .../utils/removeEmptyAnswers.ts | 26 ++++++++- .../src/utils/calculatedExpression.ts | 56 ++++++++++--------- .../src/utils/manageForm.ts | 11 +++- .../src/utils/removeEmptyAnswers.ts | 28 ++++++++-- .../src/utils/repopulateIntoResponse.ts | 5 +- 5 files changed, 88 insertions(+), 38 deletions(-) diff --git a/packages/sdc-populate/src/SDCPopulateQuestionnaireOperation/utils/removeEmptyAnswers.ts b/packages/sdc-populate/src/SDCPopulateQuestionnaireOperation/utils/removeEmptyAnswers.ts index ac7900a1b..5f67900ca 100644 --- a/packages/sdc-populate/src/SDCPopulateQuestionnaireOperation/utils/removeEmptyAnswers.ts +++ b/packages/sdc-populate/src/SDCPopulateQuestionnaireOperation/utils/removeEmptyAnswers.ts @@ -37,25 +37,36 @@ export function removeEmptyAnswersFromResponse( return questionnaireResponse; } + const newQuestionnaireResponse: QuestionnaireResponse = { ...questionnaireResponse, item: [] }; for (const [i, topLevelQRItem] of topLevelQRItems.entries()) { const qItem = topLevelQItems[i]; if (!qItem) { continue; } + // If QR item don't have either item.item and item.answer, continue + if (!qrItemHasItemsOrAnswer(topLevelQRItem)) { + continue; + } + const newTopLevelQRItem = removeEmptyAnswersFromItemRecursive(qItem, topLevelQRItem); - if (newTopLevelQRItem && questionnaireResponse.item) { - questionnaireResponse.item[i] = { ...newTopLevelQRItem }; + if (newTopLevelQRItem && newQuestionnaireResponse.item) { + newQuestionnaireResponse.item.push(newTopLevelQRItem); } } - return questionnaireResponse; + return newQuestionnaireResponse; } function removeEmptyAnswersFromItemRecursive( qItem: QuestionnaireItem, qrItem: QuestionnaireResponseItem ): QuestionnaireResponseItem | null { + // If QR item don't have either item.item and item.answer, return null + if (!qrItemHasItemsOrAnswer(qrItem)) { + return null; + } + const qItems = qItem.item; const qrItems = qrItem.item; @@ -120,3 +131,12 @@ function answerIsEmpty(qrItem: QuestionnaireResponseItem) { return false; } + +/** + * Check if a QuestionnaireResponseItem has either an item or an answer property. + * + * @author Sean Fong + */ +function qrItemHasItemsOrAnswer(qrItem: QuestionnaireResponseItem): boolean { + return (!!qrItem.item && qrItem.item.length > 0) || (!!qrItem.answer && qrItem.answer.length > 0); +} diff --git a/packages/smart-forms-renderer/src/utils/calculatedExpression.ts b/packages/smart-forms-renderer/src/utils/calculatedExpression.ts index ed7722f8e..bc2a5ceba 100644 --- a/packages/smart-forms-renderer/src/utils/calculatedExpression.ts +++ b/packages/smart-forms-renderer/src/utils/calculatedExpression.ts @@ -34,6 +34,7 @@ import { getQrItemsIndex, mapQItemsIndex } from './mapItem'; import { updateQrItemsInGroup } from './qrItem'; import cloneDeep from 'lodash.clonedeep'; import dayjs from 'dayjs'; +import { qrItemHasItemsOrAnswer } from './manageForm'; interface EvaluateInitialCalculatedExpressionsParams { initialResponse: QuestionnaireResponse; @@ -186,9 +187,16 @@ export function initialiseCalculatedExpressionValues( } // Populate calculated expression values into QR + const qItemsIndexMap = mapQItemsIndex(questionnaire); + const topLevelQRItemsByIndex = getQrItemsIndex( + questionnaire.item, + populatedResponse.item, + qItemsIndexMap + ); + const topLevelQrItems: QuestionnaireResponseItem[] = []; for (const [index, topLevelQItem] of questionnaire.item.entries()) { - const populatedTopLevelQrItem = populatedResponse.item[index] ?? { + const topLevelQRItemOrItems = topLevelQRItemsByIndex[index] ?? { linkId: topLevelQItem.linkId, text: topLevelQItem.text, item: [] @@ -196,7 +204,7 @@ export function initialiseCalculatedExpressionValues( const updatedTopLevelQRItem = initialiseItemCalculatedExpressionValueRecursive( topLevelQItem, - populatedTopLevelQrItem, + topLevelQRItemOrItems, calculatedExpressionsWithValues ); @@ -207,7 +215,7 @@ export function initialiseCalculatedExpressionValues( continue; } - if (updatedTopLevelQRItem) { + if (updatedTopLevelQRItem && qrItemHasItemsOrAnswer(updatedTopLevelQRItem)) { topLevelQrItems.push(updatedTopLevelQRItem); } } @@ -217,48 +225,44 @@ export function initialiseCalculatedExpressionValues( function initialiseItemCalculatedExpressionValueRecursive( qItem: QuestionnaireItem, - qrItem: QuestionnaireResponseItem | undefined, + qrItemOrItems: QuestionnaireResponseItem | QuestionnaireResponseItem[] | null, calculatedExpressions: Record -): QuestionnaireResponseItem[] | QuestionnaireResponseItem | null { +): QuestionnaireResponseItem | QuestionnaireResponseItem[] | null { + // For repeat groups + const hasMultipleAnswers = Array.isArray(qrItemOrItems); + if (hasMultipleAnswers) { + return qrItemOrItems; + } + + const qrItem = qrItemOrItems; const childQItems = qItem.item; if (childQItems && childQItems.length > 0) { - // iterate through items of item recursively const childQrItems = qrItem?.item ?? []; - // const updatedChildQrItems: QuestionnaireResponseItem[] = []; - - // FIXME Not implemented for repeat groups - if (qItem.type === 'group' && qItem.repeats) { - return qrItem ?? null; - } const indexMap = mapQItemsIndex(qItem); const qrItemsByIndex = getQrItemsIndex(childQItems, childQrItems, indexMap); // Otherwise loop through qItem as usual for (const [index, childQItem] of childQItems.entries()) { - const childQrItem = qrItemsByIndex[index]; - - // FIXME Not implemented for repeat groups - if (Array.isArray(childQrItem)) { - continue; - } + const childQRItemOrItems = qrItemsByIndex[index]; - const newQrItem = initialiseItemCalculatedExpressionValueRecursive( + const updatedChildQRItemOrItems = initialiseItemCalculatedExpressionValueRecursive( childQItem, - childQrItem, + childQRItemOrItems ?? null, calculatedExpressions ); // FIXME Not implemented for repeat groups - if (Array.isArray(newQrItem)) { + if (Array.isArray(updatedChildQRItemOrItems)) { continue; } - if (newQrItem) { + const updatedChildQRItem = updatedChildQRItemOrItems; + if (updatedChildQRItem) { updateQrItemsInGroup( - newQrItem, + updatedChildQRItem, null, - qrItem ?? { linkId: qItem.linkId, text: qItem.text, item: [] }, + updatedChildQRItem ?? { linkId: qItem.linkId, text: qItem.text, item: [] }, indexMap ); } @@ -287,7 +291,7 @@ function getCalculatedExpressionAnswer( function constructGroupItem( qItem: QuestionnaireItem, - qrItem: QuestionnaireResponseItem | undefined, + qrItem: QuestionnaireResponseItem | null, calculatedExpressions: Record ): QuestionnaireResponseItem | null { const calculatedExpressionAnswer = getCalculatedExpressionAnswer(qItem, calculatedExpressions); @@ -317,7 +321,7 @@ function constructGroupItem( function constructSingleItem( qItem: QuestionnaireItem, - qrItem: QuestionnaireResponseItem | undefined, + qrItem: QuestionnaireResponseItem | null, calculatedExpressions: Record ): QuestionnaireResponseItem | null { const calculatedExpressionAnswer = getCalculatedExpressionAnswer(qItem, calculatedExpressions); diff --git a/packages/smart-forms-renderer/src/utils/manageForm.ts b/packages/smart-forms-renderer/src/utils/manageForm.ts index 9fd0b9277..f799e0e41 100644 --- a/packages/smart-forms-renderer/src/utils/manageForm.ts +++ b/packages/smart-forms-renderer/src/utils/manageForm.ts @@ -1,4 +1,4 @@ -import type { Questionnaire, QuestionnaireResponse } from 'fhir/r4'; +import type { Questionnaire, QuestionnaireResponse, QuestionnaireResponseItem } from 'fhir/r4'; import { questionnaireResponseStore, questionnaireStore, @@ -120,3 +120,12 @@ export function removeEmptyAnswersFromResponse( enableWhenExpressions }); } + +/** + * Check if a QuestionnaireResponseItem has either an item or an answer property. + * + * @author Sean Fong + */ +export function qrItemHasItemsOrAnswer(qrItem: QuestionnaireResponseItem): boolean { + return (!!qrItem.item && qrItem.item.length > 0) || (!!qrItem.answer && qrItem.answer.length > 0); +} diff --git a/packages/smart-forms-renderer/src/utils/removeEmptyAnswers.ts b/packages/smart-forms-renderer/src/utils/removeEmptyAnswers.ts index a8a29d2ad..1422f2125 100644 --- a/packages/smart-forms-renderer/src/utils/removeEmptyAnswers.ts +++ b/packages/smart-forms-renderer/src/utils/removeEmptyAnswers.ts @@ -24,6 +24,7 @@ import type { import type { EnableWhenExpressions, EnableWhenItems } from '../interfaces/enableWhen.interface'; import { isHiddenByEnableWhen } from './qItem'; import cloneDeep from 'lodash.clonedeep'; +import { qrItemHasItemsOrAnswer } from './manageForm'; interface removeEmptyAnswersParams { questionnaire: Questionnaire; @@ -60,21 +61,31 @@ export function removeEmptyAnswers(params: removeEmptyAnswersParams): Questionna return updatedQuestionnaireResponse; } - topLevelQRItems.forEach((qrItem, i) => { + const newQuestionnaireResponse: QuestionnaireResponse = { ...questionnaireResponse, item: [] }; + for (const [i, topLevelQRItem] of topLevelQRItems.entries()) { const qItem = topLevelQItems[i]; + if (!qItem) { + continue; + } + + // If QR item don't have either item.item and item.answer, continue + if (!qrItemHasItemsOrAnswer(topLevelQRItem)) { + continue; + } + const newTopLevelQRItem = removeEmptyAnswersFromItemRecursive({ qItem, - qrItem, + qrItem: topLevelQRItem, enableWhenIsActivated, enableWhenItems, enableWhenExpressions }); - if (newTopLevelQRItem && questionnaireResponse.item) { - questionnaireResponse.item[i] = { ...newTopLevelQRItem }; + if (newTopLevelQRItem && newQuestionnaireResponse.item) { + newQuestionnaireResponse.item.push(newTopLevelQRItem); } - }); + } - return questionnaireResponse; + return newQuestionnaireResponse; } interface removeEmptyAnswersFromItemRecursiveParams { @@ -90,6 +101,11 @@ function removeEmptyAnswersFromItemRecursive( ): QuestionnaireResponseItem | null { const { qItem, qrItem, enableWhenIsActivated, enableWhenItems, enableWhenExpressions } = params; + // If QR item don't have either item.item and item.answer, return null + if (!qrItemHasItemsOrAnswer(qrItem)) { + return null; + } + const qItems = qItem.item; const qrItems = qrItem.item; diff --git a/packages/smart-forms-renderer/src/utils/repopulateIntoResponse.ts b/packages/smart-forms-renderer/src/utils/repopulateIntoResponse.ts index 32b80bda5..936d7105b 100644 --- a/packages/smart-forms-renderer/src/utils/repopulateIntoResponse.ts +++ b/packages/smart-forms-renderer/src/utils/repopulateIntoResponse.ts @@ -8,6 +8,7 @@ import type { ItemToRepopulate } from './repopulateItems'; import { getQrItemsIndex, mapQItemsIndex } from './mapItem'; import { isSpecificItemControl } from './itemControl'; import { questionnaireResponseStore, questionnaireStore } from '../stores'; +import { qrItemHasItemsOrAnswer } from './manageForm'; /** * Re-populate checked items in the re-population dialog into the current QuestionnaireResponse @@ -67,7 +68,7 @@ export function repopulateItemsIntoResponse( continue; } - if (updatedTopLevelQRItem) { + if (updatedTopLevelQRItem && qrItemHasItemsOrAnswer(updatedTopLevelQRItem)) { topLevelQrItems.push(updatedTopLevelQRItem); } } @@ -79,7 +80,7 @@ function repopulateItemRecursive( qItem: QuestionnaireItem, qrItemOrItems: QuestionnaireResponseItem | QuestionnaireResponseItem[] | null, checkedItemsToRepopulate: Record -): QuestionnaireResponseItem[] | QuestionnaireResponseItem | null { +): QuestionnaireResponseItem | QuestionnaireResponseItem[] | null { // For repeat groups const hasMultipleAnswers = Array.isArray(qrItemOrItems); if (hasMultipleAnswers) { From 0acbc015942f11c10b7eabf8a4d15dfd28e672e6 Mon Sep 17 00:00:00 2001 From: Sean Fong Date: Mon, 8 Jul 2024 15:34:19 +0930 Subject: [PATCH 4/4] Add operations doc sidebar --- documentation/docs/api/index.mdx | 2 +- documentation/docs/operations/index.mdx | 25 +++++++++++++++++++++++++ documentation/docusaurus.config.ts | 6 ++++++ documentation/sidebars.ts | 1 + 4 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 documentation/docs/operations/index.mdx diff --git a/documentation/docs/api/index.mdx b/documentation/docs/api/index.mdx index b1ea2afff..d306a69e4 100644 --- a/documentation/docs/api/index.mdx +++ b/documentation/docs/api/index.mdx @@ -7,4 +7,4 @@ sidebar_label: Introduction This section is automatically generated from the source code using [TypeDoc and its plugin for Docusaurus](https://github.com/typedoc2md/typedoc-plugin-markdown/tree/main/packages/docusaurus-plugin-typedoc#readme). -It provides a full coverage of the exposed API of [@aehrc/smart-forms-renderer](https://www.npmjs.com/package/@aehrc/smart-forms-renderer) and [@aehrc/sdc-populate](https://www.npmjs.com/package/@aehrc/sdc-populate). +It provides a full coverage of the exposed API of [@aehrc/smart-forms-renderer](https://www.npmjs.com/package/@aehrc/smart-forms-renderer), [@aehrc/sdc-populate](https://www.npmjs.com/package/@aehrc/sdc-populate) and [@aehrc/sdc-assemble](https://www.npmjs.com/package/@aehrc/sdc-assemble). diff --git a/documentation/docs/operations/index.mdx b/documentation/docs/operations/index.mdx new file mode 100644 index 000000000..7c36fa145 --- /dev/null +++ b/documentation/docs/operations/index.mdx @@ -0,0 +1,25 @@ +--- +sidebar_position: 1 +sidebar_label: Introduction +--- + +# FHIR Operations + +Smart Forms provides reference implementations for `$populate` and `$assemble` operations as [ExpressJS](https://expressjs.com/) services to complement the FHIR Questionnaire renderer. +These operations are available as Docker images and can be deployed as microservices. + +[//]: # '1. **`$populate`**' +[//]: # ' Operation definition: [SDCPopulateQuestionnaire](http://hl7.org/fhir/uv/sdc/OperationDefinition/Questionnaire-populate)' +[//]: # ' Github repository:' +[//]: # +[//]: # ' A React-based library that contains the rendering engine. It acts as a reference implementation for the [SDC Form Filler](https://hl7.org/fhir/uv/sdc/CapabilityStatement-sdc-form-filler.html).' +[//]: # +[//]: # '2. **`$assemble`** ([@aehrc/sdc-populate](https://www.npmjs.com/package/@aehrc/sdc-populate))' +[//]: # +[//]: # ' A reference implementation of the [SDC Populate Questionnaire](https://hl7.org/fhir/uv/sdc/OperationDefinition-Questionnaire-populate.html) operation, also known as $populate.' +[//]: # ' Currently, there are no written documentation available for this library. Please refer to the [API](/docs/api/sdc-populate) for more information.' +[//]: # +[//]: # '3. **SDC Assemble** ([@aehrc/sdc-assemble](https://www.npmjs.com/package/@aehrc/sdc-assemble))' +[//]: # +[//]: # ' A reference implementation of the [SDC Assemble Questionnaire](https://hl7.org/fhir/uv/sdc/OperationDefinition-Questionnaire-assemble.html) operation, also known as $assemble.' +[//]: # ' Currently, there are no written documentation available for this library. Please refer to the [API](/docs/api/sdc-assemble) for more information.' diff --git a/documentation/docusaurus.config.ts b/documentation/docusaurus.config.ts index 6c75a530b..a7f1b34f4 100644 --- a/documentation/docusaurus.config.ts +++ b/documentation/docusaurus.config.ts @@ -84,6 +84,12 @@ const config: Config = { position: 'left', label: 'Developer Usage' }, + { + type: 'docSidebar', + sidebarId: 'operationsSidebar', + position: 'left', + label: 'FHIR Operations' + }, { type: 'docSidebar', sidebarId: 'apiSidebar', diff --git a/documentation/sidebars.ts b/documentation/sidebars.ts index 33ad8e57e..d599b9b56 100644 --- a/documentation/sidebars.ts +++ b/documentation/sidebars.ts @@ -18,6 +18,7 @@ const sidebars: SidebarsConfig = { { type: 'autogenerated', dirName: 'dev' }, { type: 'link', label: 'Playground', href: 'https://smartforms.csiro.au/playground' } ], + operationsSidebar: [{ type: 'autogenerated', dirName: 'operations' }], apiSidebar: [{ type: 'autogenerated', dirName: 'api' }] };