From b0cfd87162282cf5696515015f8d024822658686 Mon Sep 17 00:00:00 2001 From: Sean Fong Date: Wed, 22 May 2024 12:21:33 +0930 Subject: [PATCH] Add links to exposed demo wrappers --- .../BuildFormButtonTesterWrapperForStorybook.tsx | 10 ++++++++++ .../InitialiseFormWrapperForStorybook.tsx | 6 ++++-- .../StorybookWrappers/PrePopWrapperForStorybook.tsx | 10 ++++++++++ .../StorybookWrappers/populateCallbackForStorybook.ts | 6 ++++++ 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/packages/smart-forms-renderer/src/stories/StorybookWrappers/BuildFormButtonTesterWrapperForStorybook.tsx b/packages/smart-forms-renderer/src/stories/StorybookWrappers/BuildFormButtonTesterWrapperForStorybook.tsx index 7a68b7d1c..d5e54a40f 100644 --- a/packages/smart-forms-renderer/src/stories/StorybookWrappers/BuildFormButtonTesterWrapperForStorybook.tsx +++ b/packages/smart-forms-renderer/src/stories/StorybookWrappers/BuildFormButtonTesterWrapperForStorybook.tsx @@ -29,6 +29,16 @@ interface BuildFormButtonTesterWrapperForStorybookProps { questionnaireResponse?: QuestionnaireResponse; } +/** + * This is a demo wrapper which initialises the BaseRenderer with the passed in questionnaire using useBuildForm. + * It also provides a button to build the form with the passed in questionnaire + questionnaireResponse. + * It was done as a two-step process for demo purposes. + * + * Use this pattern if you already have a pre-populated/pre-filled/draft response. + * If you want to pre-pop on the fly, see https://github.com/aehrc/smart-forms/blob/main/packages/smart-forms-renderer/src/stories/StorybookWrappers/PrePopWrapperForStorybook.tsx instead + * + * @author Sean Fong + */ function BuildFormButtonTesterWrapperForStorybook( props: BuildFormButtonTesterWrapperForStorybookProps ) { diff --git a/packages/smart-forms-renderer/src/stories/StorybookWrappers/InitialiseFormWrapperForStorybook.tsx b/packages/smart-forms-renderer/src/stories/StorybookWrappers/InitialiseFormWrapperForStorybook.tsx index 196bd9557..bead80add 100644 --- a/packages/smart-forms-renderer/src/stories/StorybookWrappers/InitialiseFormWrapperForStorybook.tsx +++ b/packages/smart-forms-renderer/src/stories/StorybookWrappers/InitialiseFormWrapperForStorybook.tsx @@ -48,8 +48,10 @@ interface InitialiseFormWrapperProps { * - The initialised FHIRClient is only used for further FHIR calls. It does not provide pre-population capabilities. * * For button click usage examples of buildForm(), see: - * - https://github.com/aehrc/smart-forms/blob/main/packages/smart-forms-renderer/src/stories/BuildFormButtonTesterWrapper.tsx#L47 - * - https://github.com/aehrc/smart-forms/blob/main/packages/smart-forms-renderer/src/stories/BuildFormButtonForStorybook.tsx + * - https://github.com/aehrc/smart-forms/blob/main/packages/smart-forms-renderer/src/stories/StorybookWrappers/BuildFormButtonTesterWrapperForStorybook.tsx + * - https://github.com/aehrc/smart-forms/blob/main/packages/smart-forms-renderer/src/stories/StorybookWrappers/BuildFormButtonForStorybook.tsx + * - https://github.com/aehrc/smart-forms/blob/main/packages/smart-forms-renderer/src/stories/StorybookWrappers/PrePopWrapperForStorybook.tsx + * - https://github.com/aehrc/smart-forms/blob/main/packages/smart-forms-renderer/src/stories/StorybookWrappers/PrePopButtonForStorybook.tsx * * @author Sean Fong */ diff --git a/packages/smart-forms-renderer/src/stories/StorybookWrappers/PrePopWrapperForStorybook.tsx b/packages/smart-forms-renderer/src/stories/StorybookWrappers/PrePopWrapperForStorybook.tsx index c4018d82d..4c6fa9b32 100644 --- a/packages/smart-forms-renderer/src/stories/StorybookWrappers/PrePopWrapperForStorybook.tsx +++ b/packages/smart-forms-renderer/src/stories/StorybookWrappers/PrePopWrapperForStorybook.tsx @@ -35,6 +35,16 @@ interface PrePopWrapperForStorybookProps { user: Practitioner; } +/** + * This is a demo wrapper which initialises the BaseRenderer with the passed in questionnaire using useBuildForm. + * It also provides a button to pre-populate the questionnaire on the fly using populateQuestionnaire() from '@aehrc/sdc-populate'. + * This does in-app population and you have to define your own callback function to retrieve resources from your source server. + * + * Use this pattern if you do not have a pre-populated/pre-filled/draft response and want to pre-populate on the fly. + * If you already have a questionnaireResponse, see https://github.com/aehrc/smart-forms/blob/main/packages/smart-forms-renderer/src/stories/StorybookWrappers/BuildFormButtonTesterWrapperForStorybook.tsx instead + * + * @author Sean Fong + */ function PrePopWrapperForStorybook(props: PrePopWrapperForStorybookProps) { const { questionnaire, fhirClient, patient, user } = props; diff --git a/packages/smart-forms-renderer/src/stories/StorybookWrappers/populateCallbackForStorybook.ts b/packages/smart-forms-renderer/src/stories/StorybookWrappers/populateCallbackForStorybook.ts index 5eeb26520..055e4b611 100644 --- a/packages/smart-forms-renderer/src/stories/StorybookWrappers/populateCallbackForStorybook.ts +++ b/packages/smart-forms-renderer/src/stories/StorybookWrappers/populateCallbackForStorybook.ts @@ -25,6 +25,12 @@ interface RequestConfig { authToken: string | null; } +/** + * Sample callback function to fetch resources from your source server when using populate() or populateQuestionnaire() from @aehrc/sdc-populate. + * See https://github.com/aehrc/smart-forms/blob/main/packages/smart-forms-renderer/src/stories/StorybookWrappers/PrePopWrapperForStorybook.tsx#L50-L59 for usage. + * + * @author Sean Fong + */ export const fetchResourceCallback: FetchResourceCallback = ( query: string, requestConfig: RequestConfig