The GenericQuestionnaire.tsx
will be the entry point of the component, but you need to specify some configs beforehand.
- In
GenericQuestionnaire/services/questionnaireServices.ts
, you will need to add the URL of the form that you are going to use.
export const fetchQuestionnaire = async (medplum: MedplumClient) => {
// HINT: Add your own questionnaire URL
const questionnaire = await medplum.searchResources("Questionnaire", {
url: "add-questionnaire-url",
});
return questionnaire[0];
};
- In
GenericQuestionnaire/components/QuestionnaireForm.ts
, it is necessary to create extensions for eachplaceholder
,icon
, andmask
key.
-
In
GenericQuestionnaire/components/QuestionnaireForm.ts
, if you need more required components, you will need to add them to thezodValidationOptions
function. -
In
GenericQuestionnaire/constants
, underVALUE_TYPE_PARSERS
, you will need to add morevalueX
as needed. -
In
GenericQuestionnaire/utils
, in thehandleFormControlAnswer
function, add a newformControlType
for each newchoice
you add based on thehttp://hl7.org/fhir/StructureDefinition/questionnaire-itemControl
extension.- You will also need to add the new choice component in
GenericQuestionnaire/components/QuestionnaireChoiceField.ts
.
- You will also need to add the new choice component in
-
In
GenericQuestionnaire/utils
, in thehandleBaseTypeAnswer
function, if you add more types of answers, specify how they need to be saved in theQuestionnaireResponse
. -
If you need to add more
QuestionnaireItem
types, go toGenericQuestionnaire/constants
and updateFORMS_FIELDS
by adding more object keys[string]: ReactNode
.
-
The
Wizard Form
uses the maingroup
type of theQuestionnaireItem
to render the page and theWizardCounter
. Every nested group will be considered a section of the form. -
The function
getQuestionnaireResponseFromFormValues
insideGenericQuestionnaire/utils
creates aQuestionnaireResponse
based on pre-determined values (Record<string, unknown>
). If you need to create aQuestionnaireResponse
earlier, you can use this function along withmedplum.createResource
.