FHIR questionnaire: Managing grouping and Extensions

When I first looked at how the groups were organized in a Questionnaire I did find them a bit confusing. But actually, its not too bad – though does support an arbitrary level of complexity!

Here’s how it works.

  • The main body of the Questionnaire has a single group (Think of it as the ‘content’ of the Questionnaire).
  • The content group can then contain any number of ‘section’ groups, each of can contain either questions, or a ‘sub-section’ group. This nesting can continue to any level, and allows you to define the ‘structure’ of a Questionnaire.
  • Questions themselves can also contain a group structure (which can have questions/groups in the same way as a group can). This is a nice way of supporting a ‘dynamic’ form – where parts of the form are hidden or shown depending on the answer to a question – although would have other purposes as well. For example smoking status – the details of smoking (how much, for how long etc)  are only shown if the person is a smoker. Note that the Questionnaire resource itself does not have these ‘rules’ within it – this would need to be managed externally probably using an extension.

The following ‘tree’ shows a hypothetical Questionnaire with some of these features.

Questionnaire
  Content group
    Section group
      Sub-section group
        Question
        Question
      Subsection group
        Question
          Question specific group
            Question
            Question
    Section group
      ...

Because of the flexibility of the Questionnaire – and the very widespread use of forms in clinical practice, extensions (and profiles) will be very important in helping to ‘constrain’ specific Questionnaires. Indeed, there are already a number of core extensions that have been proposed in the spec. (As a side note, the intention is that there will be a number of ‘core’ extensions maintained by HL7 for general use with FHIR. These will cover the data requirements that weren’t believed to be in the ‘80%’ for core resource properties. A persons religion could be an example of this).

The proposed extensions are in the spec, so can be viewed directly there. (Incidentally, one of them covers of my suggestion from the last post for a question to contain the expected format – either I’m ahead of my time, or I should have looked more closely in the first place).

And, of course you can create your own extensions.

For example, you may wish to consider an extension that can be used to embed simple hide/show logic for groups that are associated with a question – this is likely to be a common use of this structure. One way to approach this would be for each group within the question to have an extension that determines when the group is displayed on the form.

The example below shows our smoking question, with a nested group of further questions to add. The group contains an extension that has the value that will cause it to be displayed. So – if the answer to ‘Is the person a smoker’ is true, then the extra questions are displayed.


<question>
     <name>
         <coding>
             <system value="http://snomed.info/sct"/>
             <code value="118212000"/>
         </coding>
     </name>
     <text value="Is the person a smoker"/>
     <group>
         <text value="Additional questions for smokers"/>
         <question>
             <extension url="http://orionhealth.com/fhir/profile/questionnaire#hideshow">
                 <valueBoolean value="true"/>
             </extension>
             <name>
                 <coding>
                     <system value="http://snomed.info/sct"/>
                     <code value="228488005"/>
                 </coding>
             </name>
             <text value="How old when they started smoking"/>
         </question>
     </group>
 </question>

The profile entry (an extension definition) that defines this could be:


<extensionDefn>
     <code value="hideshow"/>
     <contextType value="resource"/>
     <context value="Questionnaire"/>
     <definition>
         <short value="The value for dependant groups to be shown in a question"/>
         <formal value="Applied to a group child element of a question in a questionnaire. If the parent
             question has this value, then show the contents of the group"/>
         <min value="0"/>
         <max value="1"/>
         <type>
             <code value="boolean"/>
         </type>
         <isModifier value="false"/>
     </definition>
 </extensionDefn>

You might also want to use the ‘answerFormat’ core extension  against the question to ensure that the format of the question matches the format expected by the hide/show extension.

About David Hay
I'm an independent contractor working with a number of Organizations in the health IT space. I'm an HL7 Fellow, Chair Emeritus of HL7 New Zealand and a co-chair of the FHIR Management Group. I have a keen interest in health IT, especially health interoperability with HL7 and the FHIR standard. I'm the author of a FHIR training and design tool - clinFHIR - which is sponsored by InterSystems Ltd.

Leave a Reply

Discover more from Hay on FHIR

Subscribe now to keep reading and get access to the full archive.

Continue reading