Providing a dynamic list of values for a questionnaire item

Say you have designed a Questionnaire with an item of the open-choice where you are to choose which medications you are taking for your illness. To satisfy business requirements, this list may be compromised of thousands of choices, validating some custom front-end component to handle rendering and user-input in these cases. I guess telling the frontend that this Questionnaire.item is of the really-long-variety to make it employ special rendering could be done through some kind of extension, but I am not sure about the data part:

I see two main paths for the answerValueSet

  1. Define the set as a static part of the questionnaire, either as a long list of values in answerValueSet or maybe through some kind of embedded resource that is referenced? Not sure how to do the latter, if supported, and if possible to validate in some easy manner.
  2. Somehow make it dynamic - fetching it from some endpoint in the client

Is the latter possible (i.e. adding some extension that tells the client “this data can be fetched from http://my.server/medications/for/illness”)? I guess this makes would make validation a bit tricky, if the backend was to compare any code received in the questionnaire response with that of a dynamic endpoint, whose output could change in time.

The first option seems quite straight forward, but would bloat the documents considerably, unless I could somehow reference some external FHIR resource, like /fhir/Basic/772123 that would have it. Is this possible (and works with validation)?

ValueSets can be both ‘extensional’ (i.e. an enumeration of codes) or ‘intensional’ (meaning they define an expression that can be evaluated against the underlying code system(s) to determine the list of codes). When working with really long sets of codes, or codes drawn from a frequently evolving code system, the latter approach is preferable. The ‘form filler’ for the Questionnaire can then hit a terminology server to determine the current ‘expansion’ of the list of codes when it’s prompting the user. (In practice, it may use a type-ahead list-box type structure where the user can start typing the desired concept and the ‘expansion’ process will run continuously using the typed text as a filter and will return the first 100 concepts that contain the filter text - resulting in a list that rapidly shrinks as the user types until they can scroll and select the desired concept.

If you look at the SDC implementation guide, there’s an extension where a Questionnaire can indicate the terminology server(s) that are known to be able to expand the ValueSets referenced in the form.