Dynamic Choice Options in Questionnaire from a Bot...
# support
s
I'm trying to implement a dynamic field in a Questionnaire and need guidance on the best-practice architecture, similar to how the Lab Ordering form is handled in the Medplum Provider App. 🎯 My Goal: I want to create a
Questionnaire.item
(a question/input field) of type
choice
or
open-choice
where the options presented to the user are generated dynamically by a Medplum Bot. For example, I want a "Select Lab Panel" field where the list of available lab panels is retrieved from an external system or generated based on complex logic (e.g., patient age, current date, etc.) by a Bot. 🚧 Current Challenge & Context: 1. I am primarily using the Medplum Provider App UI to render and fill out the Questionnaire. (This means the "custom frontend component" approach won't work easily). 2. I understand that for a standard Medplum form to display dynamic options, the options must come from a referenced
ValueSet
. 3. My current plan is to use a Bot to periodically update a specific
ValueSet
resource with the latest options. Thanks in advance for your help!
f
Hi @Sidheeq Thrissure will the dynamic nature of your options be informed by previous questions in this Questionnaire? Or will you already have this information by the time you render the QuestionnaireForm to begin?
I see that part of your logic is (e.g., patient age, current date, etc). If this is data that you already have, as part of
Questionnaire.item
, you could dynamically populate the
answerOption []
instead of using
answerValueSet
Although that would require some FE changes to alter the Questionnaire before passing it into [QuestionnaireForm](https://storybook.medplum.com/?path=/story/medplum-questionnaireform--kitchen-sink-with-questionnaire-response)
s
I actually need both kinds of fields.
No, I don't already have the data. But data is retrieved from a source. I'm going to use a bot here for that reason.
f
Yea, in that case, updating a ValueSet with a Bot might be your best bet
53 Views