Skip to main content

@aehrc/smart-forms-renderer

Interfaces

InterfaceDescription
InitialiseFormWrapperProps-
ItemToRepopulateItemToRepopulate interface
LaunchContextLaunchContext interface
QuestionnaireResponseStoreTypeQuestionnaireResponseStore properties and methods Properties can be accessed for fine-grain details. Methods are usually used internally, using them from an external source is not recommended.
QuestionnaireStoreTypeQuestionnaireStore properties and methods Properties can be accessed for fine-grain details. Methods are usually used internally, using them from an external source is not recommended.
SmartConfigStoreTypeSmartConfigStore properties and methods Properties can be accessed for fine-grain details. Methods are usually used internally, using them from an external source is not recommended.
SmartFormsRendererPropsSmartFormsRenderer properties
TerminologyServerStoreTypeTerminologyServerStore properties and methods Properties can be accessed for fine-grain details. Methods are usually used internally, using them from an external source is not recommended.
VariablesVariables interface
VariableXFhirQueryVariableXFhirQuery interface

Type Aliases

Type aliasDescription
TabTab interface
TabsKey-value pair of tabs Record<linkId, Tab>

Variables

VariableDescription
questionnaireResponseStoreQuestionnaireResponse state management store which contains all properties and methods to manage the state of the questionnaireResponse. This is the vanilla version of the store which can be used in non-React environments.
questionnaireStoreQuestionnaire state management store which contains all properties and methods to manage the state of the questionnaire. This is the vanilla version of the store which can be used in non-React environments.
smartConfigStoreSmart Config state management store. This is only used for answerExpressions. It is recommended to manage the state of the FHIRClient, patient, user, and encounter in the parent application, since the renderer doesn't provide pre-population capabilities. Will be deprecated in version 1.0.0.
terminologyServerStoreTerminology server state management store. This is used for resolving valueSets externally. Defaults to use https://tx.ontoserver.csiro.au/fhir. This is the vanilla version of the store which can be used in non-React environments.
useQuestionnaireResponseStoreQuestionnaireResponse state management store which contains all properties and methods to manage the state of the questionnaire. This is the React version of the store which can be used as React hooks in React functional components.
useQuestionnaireStoreQuestionnaire state management store which contains all properties and methods to manage the state of the questionnaire. This is the React version of the store which can be used as React hooks in React functional components.
useSmartConfigStoreSmart Config state management store. This is only used for answerExpressions. It is recommended to manage the state of the FHIRClient, patient, user, and encounter in the parent application, since the renderer doesn't provide pre-population capabilities. Will be deprecated in version 1.0.0.
useTerminologyServerStoreTerminology server state management store. This is used for resolving valueSets externally. Defaults to use https://tx.ontoserver.csiro.au/fhir. This is the React version of the store which can be used as React hooks in React functional components.

Functions

FunctionDescription
BaseRendererMain component of the form-rendering engine. Renders the Questionnaire and QuestionnaireResponse defined in the state management stores QuestionnaireStore and QuestionnaireResponseStore respectively. Use buildForm() in your wrapping component or in an event handler to initialise the form.
buildFormBuild the form with an initial Questionnaire and an optional filled QuestionnaireResponse. If a QuestionnaireResponse is not provided, an empty QuestionnaireResponse is set as the initial QuestionnaireResponse. There are other optional properties such as applying readOnly, providing a terminology server url and additional variables.
destroyFormDestroy the form to clean up the questionnaire and questionnaireResponse stores.
extractObservationBasedExtract an array of Observations from a QuestionnaireResponse and its source Questionnaire.
generateItemsToRepopulateCompare latest data from the server with the current QuestionnaireResponse and decide items to re-populate
getResponseGet the filled QuestionnaireResponse at its current state. If no changes have been made to the form, the initial QuestionnaireResponse is returned.
GridGroupMain component to render a Group Grid (grid) Questionnaire item.
GroupTableMain component to render a Group Table (gtable) Questionnaire item.
InitialiseFormWrapperForStorybookThis is a one-to-one replacement for the SmartFormsRenderer for demo purposes. Instead of using this React component, define your own wrapper component that uses the BaseRenderer directly. Things to note: - It is required to wrap the BaseRenderer with the QueryClientProvider to make requests. - You can wrap the BaseRenderer with the RendererThemeProvider to apply the default renderer theme used in Smart Forms. Optionally, you can define your own ThemeProvider https://mui.com/material-ui/customization/theming/. - Make your buildForm() call in a button click or other event handler. Alternatively, you can use the useInitialiseForm hook to initialise the form. - Make your own initialiseFhirClient() call in a button click or other event handler. Alternatively, you can use the useInitialiseForm hook to initialise the form. - The initialised FHIRClient is only used for further FHIR calls. It does not provide pre-population capabilities.
initialiseQuestionnaireResponseInitialise a questionnaireResponse from a given questionnaire optionally takes in an existing questionnaireResponse to be initialised
isRepeatItemAndNotCheckboxCheck if qItem is a repeat item AND if it isn't a checkbox item Note: repeat checkbox items are rendered as multi-select checkbox instead of being rendered as a traditional repeat item
isSpecificItemControlCheck if the extension has an itemControl code equal to the given itemControlCode
parseFhirDateToDisplayDateParse a FHIR date string to a date to be consumed and displayed by the DateItem component.
removeEmptyAnswersFromResponseRemove all empty/hidden answers from the filled QuestionnaireResponse. This takes into account enableWhens, enableWhenExpressions, items without item.answer, empty item.answer arrays and empty strings. This does not remove items that are hidden by the http://hl7.org/fhir/StructureDefinition/questionnaire-hidden extension.
removeInternalIdsFromResponseRemove all instances of item.answer.id from the filled QuestionnaireResponse. These IDs are used internally for rendering repeating items, and can be safely left out of the final response.
RendererThemeProviderDefault theme used by the renderer using Material UI. You can customise your own theme by defining a new ThemeProvider.
RepeatGroupMain component to render a repeating, group Questionnaire item. Store and manages the state of multiple instances of GroupItem in a repeating group.
RepeatItemMain component to render a repeating, non-group Questionnaire item.
repopulateResponseRe-populate checked items in the re-population dialog into the current QuestionnaireResponse
SingleItemMain component to render a repeating, non-group Questionnaire item. Store and manages the state of multiple instances of SingleItem in a repeating item.
SmartFormsRendererA self-initialising wrapper around the BaseRenderer rendering engine. Will be deprecated in version 1.0.0. For alternative usage, see: - https://github.com/aehrc/smart-forms/blob/main/packages/smart-forms-renderer/src/stories/storybookWrappers/InitialiseFormWrapperForStorybook.tsx#L40-L57
useBuildFormReact hook wrapping around the buildForm() function to build a form from a questionnaire and an optional QuestionnaireResponse.
useHiddenReact hook to determine if a QuestionnaireItem is hidden via item.hidden, enableWhens, enableWhenExpressions. When checking for repeating group enableWhen items, the parentRepeatGroupIndex should be provided.
useRendererQueryClientDefault QueryClient used by the renderer. You can customise your own QueryClient with your own options, use v4 of @tanstack/react-query.