Dynamic Questionnaires
# support
s
I'm wondering the best way to use the Questionnaire resource for our workflow. We generate a pretty dynamic set of questions from our system to collect answers for medical conditions, history, etc. We want to store this is Medplum as a
QuestionnaireResponse
resource. This intake is mainly for review by a physician and doesn't necessarily need to be rigidly structured as long as the physician can read through it. I see two ways of doing this: 1. Create a new
Questionnaire
with the exact questions/fields we asked for each new response 2. Create a single
Questionnaire
with just a free form field where we put all the answers in as markdown/html (or some other formatted/rich text) Any recommendations? Option 1 seems like a bit of a hacky use of the
Questionnaire
resource and would lead to a huge number of these resources.
r
The questionnaire supports a lot of stuff - including pagination, enableWhen etc. Here are some examples: https://storybook.medplum.com/?path=/story/medplum-questionnaireform--basic Do any of these look close to what you want to capture? This is kind of a "kitchen sink" example too: https://github.com/medplum/medplum/tree/main/examples/medplum-patient-intake-demo
s
If it makes any difference we aren't concerned with the actual form UI since we will be creating the response via the API
I'm mainly wondering the best way to structure this data. Is there a rich text field in Questionnaires?
In theory we could probably use the conditional questions to map it all out into a single structured Questionnaire, but in practice this would just be too difficult to maintain with how dynamic our questionnaires can be.
r
Yeah, there is a "code" section in the storybook, so you can see what fields are available as types and how to manipulate using the SDK. Look at Kitchen Sink for example https://storybook.medplum.com/?path=/story/medplum-questionnaireform--kitchen-sink-with-initial-values (No rich text at present)
s
I see, thanks
In your opinion then, would creating a separate
Questionnaire
resource for each dynamic intake be problematic? Anything I'm not thinking about?
r
That is unconventional! No reason to think it wouldn't work - but typically a single or a few questionnaires for intake (can be very complex) are the common path.
d
I think that the FHIR Structured Data Capture IG might have exactly what you're looking for. Part of the IG defines a system for dynamic/adaptive forms. This is typically used for computer adaptive tests where the computer selects the next question based on it's current expectation of your "skill" level from a pool of questions so as to greatly reduce the number of questions that needs to be asked. https://build.fhir.org/ig/HL7/sdc/en/adaptive.html The core insight here is that you store the Questionnaire in the
contained
field on the response. That way you don't have to create a new Questionnaire for each response but can still track and know what questions were asked
I built out a system using this IG 5 years ago so my memory is a little rusty but I think the intended path was that your Questionnaire stored ALL of the potential questions and then the
contained
questionnaire stored only the asked & answered questions
s
Ah great this is super helpful thanks! I'll look into this
48 Views