0.30.2 • Published 2 days ago

@aehrc/smart-forms-renderer v0.30.2

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
2 days ago

Smart Forms Renderer

This React-based package acts as the rendering engine for the Smart Forms app.

Try out a minimal demo here: https://smartforms.csiro.au/standalone.

Installation

npm install @aehrc/smart-forms-renderer

Basic Usage

import React from 'react';
import { SmartFormsRenderer, getResponse } from '@aehrc/smart-forms-renderer';

export default function App () {
  const questionnaire = {...}   // FHIR R4.Questionnaire
  
  return (
    <div>
      <SmartFormsRenderer questionnaire={questionnaire}/>
      <button onClick={() => {
        const response = getResponse()
        // Do something with the questionnaire response
      }}/>
    </div>  
  )
}

Note: The SmartFormsRenderer component trades customisability for simplicity. If you need more control over the rendering engine, refer to the Advanced Usage section.

SmartFormsRenderer Props

NameTypeDescriptionRequired?
questionnaireFHIR R4.QuestionnaireQuestionnaire to be renderedRequired
questionnaireResponseFHIR R4.QuestionnaireResponsePre-populated QuestionnaireResponse to be renderedOptional
additionalVariablesRecord<string, Extension>Key-value pair of SDC variables <name, variable extension>Optional
terminologyServerUrlstringTerminology server url to fetch terminologyOptional

The below props are not supported at the moment, but will be in the future.

NameTypeDescription
fhirClientClientFhirClient to perform further FHIR calls

Functions

/**
 * Get the filled QuestionnaireResponse at its current state.
 * If no changes have been made to the form, the initial or an empty QuestionnaireResponse is returned.
 *
 * @returns {FHIR R4.QuestionnaireResponse} The filled QuestionnaireResponse
 */
function getResponse() {}

Advanced Usage (If basic usage does not suffice)

/* Components */
// A self-initialising wrapper around the rendering engine. This is sufficient for most use cases.

function SmartFormsRenderer(props: {
  questionnaire: Questionnaire,
  questionnaireResponse?: QuestionnaireResponse,
  additionalVariables?: Record<string, Extension>,
  terminologyServerUrl?: string,
}): JSX.Element {}

// BaseRenderer underneath the SmartFormsRenderer wrapper. Requires buildForm() to initialise form.
function BaseRenderer(): JSX.Element {}

/* Functions */
// Get the filled QuestionnaireResponse at its current state.
// If no changes have been made to the form, the initial QuestionnaireResponse is returned.
function getResponse(): QuestionnaireResponse {}

// Build 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.
async function buildForm(
  questionnaire: Questionnaire,
  questionnaireResponse?: QuestionnaireResponse
): Promise<void> {}

// Destroy the form to clean up the questionnaire and questionnaireResponse stores.
function destroyForm(): void {}

// Remove all hidden answers from the filled QuestionnaireResponse.
// This takes into account the questionnaire-hidden extension, enableWhens and enableWhenExpressions.
function removeHiddenAnswersFromResponse(
  questionnaire: Questionnaire,
  questionnaireResponse: QuestionnaireResponse
): QuestionnaireResponse {}

The Smart Forms app uses a even finer-grained control which directly interacts with the state management stores.

At the moment there are no plans to document state management methods, but happy to do so if there is demand for it. Raise a request in https://github.com/aehrc/smart-forms/issues if you want to see it happen!


Copyright © 2022, Commonwealth Scientific and Industrial Research Organisation (CSIRO) ABN 41 687 119 230. All rights reserved.

0.30.2

2 days ago

0.30.1

2 days ago

0.30.0

2 days ago

0.29.0

3 days ago

0.28.0

6 days ago

0.27.4

8 days ago

0.27.3

9 days ago

0.27.2

12 days ago

0.27.1

12 days ago

0.27.0

14 days ago

0.26.3

15 days ago

0.26.2

16 days ago

0.26.1

18 days ago

0.25.2

18 days ago

0.26.0

18 days ago

0.25.1

19 days ago

0.25.0

20 days ago

0.23.2

22 days ago

0.24.1

22 days ago

0.23.1

28 days ago

0.23.0

28 days ago

0.22.1

29 days ago

0.22.0

1 month ago

0.21.2

1 month ago

0.21.1

1 month ago

0.20.0

1 month ago

0.21.0

1 month ago

0.19.0

1 month ago

0.16.3

2 months ago

0.17.0

2 months ago

0.16.1

2 months ago

0.16.2

2 months ago

0.16.0

2 months ago

0.15.3

2 months ago

0.15.2

2 months ago

0.15.0

3 months ago

0.15.1

3 months ago

0.14.0

3 months ago

0.13.2

3 months ago

0.13.0

3 months ago

0.13.1

3 months ago

0.12.1

3 months ago

0.11.0

3 months ago

0.12.0

3 months ago

0.10.6

5 months ago

0.10.4

5 months ago

0.10.5

5 months ago

0.9.3

6 months ago

0.10.1

6 months ago

0.10.2

6 months ago

0.10.3

6 months ago

0.10.0

6 months ago

0.9.2

6 months ago

0.9.1

6 months ago

0.9.0

7 months ago

0.8.1

8 months ago

0.8.0

8 months ago

0.7.2

8 months ago

0.7.1

9 months ago

0.7.0

9 months ago

0.6.7

9 months ago

0.6.6

9 months ago

0.6.5

9 months ago

0.6.4

9 months ago

0.6.3

9 months ago

0.6.1

9 months ago

0.6.0

9 months ago

0.5.0

9 months ago

0.4.0

9 months ago

0.3.0

9 months ago

0.2.0

9 months ago

0.1.0

9 months ago