<StructureDefinition xmlns="http://hl7.org/fhir">
  <id value="2b02f97f-e0db-48c9-af27-0fc391677dc4" />
  <url value="https://fhir.nhs.uk/StructureDefinition/NHSDigital-QuestionnaireResponse" />
  <name value="NHSDigitalQuestionnaireResponse" />
  <status value="draft" />
  <fhirVersion value="4.0.1" />
  <kind value="resource" />
  <abstract value="false" />
  <type value="QuestionnaireResponse" />
  <baseDefinition value="https://fhir.hl7.org.uk/StructureDefinition/UKCore-QuestionnaireResponse" />
  <derivation value="constraint" />
  <differential>
    <element id="QuestionnaireResponse.identifier">
      <path value="QuestionnaireResponse.identifier" />
      <mustSupport value="true" />
    </element>
    <element id="QuestionnaireResponse.questionnaire">
      <path value="QuestionnaireResponse.questionnaire" />
      <definition value="The Questionnaire that defines and organizes the questions for which answers are being provided.&#xD;&#xA;&#xD;&#xA;```json&#xD;&#xA;&quot;questionnaire&quot;: &quot;https://fhir.nhs.uk/Questionnaire/COVIDVaccinationMedicalExemption&quot;,&#xD;&#xA;```" />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="QuestionnaireResponse.status">
      <path value="QuestionnaireResponse.status" />
      <mustSupport value="true" />
    </element>
    <element id="QuestionnaireResponse.subject">
      <path value="QuestionnaireResponse.subject" />
      <definition value="The subject of the questionnaire response.  This could be a patient, organization, practitioner, device, etc.  This is who/what the answers apply to, but is not necessarily the source of information.&#xD;&#xA;&#xD;&#xA;```json&#xD;&#xA;&quot;subject&quot;: {&#xD;&#xA;        &quot;identifier&quot;: [&#xD;&#xA;            {&#xD;&#xA;                &quot;system&quot;: &quot;https://fhir.nhs.uk/Id/nhs-number&quot;,&#xD;&#xA;                &quot;value&quot;: &quot;9912003888&quot;&#xD;&#xA;            }&#xD;&#xA;        ],&#xD;&#xA;        &quot;display&quot;: &quot;Ivor Fritagelse&quot;&#xD;&#xA;    },&#xD;&#xA;```" />
      <min value="1" />
      <type>
        <code value="Reference" />
        <targetProfile value="https://fhir.nhs.uk/StructureDefinition/NHSDigital-Patient" />
      </type>
      <constraint>
        <key value="patient-reference" />
        <severity value="error" />
        <human value="An identifier reference or resource reference must be provided" />
        <expression value="(reference.exists() or (identifier.exists()))" />
        <source value="https://fhir.nhs.uk/StructureDefinition/NHSDigital-QuestionnaireResponse" />
      </constraint>
      <constraint>
        <key value="patient-nhs" />
        <severity value="error" />
        <human value="Supplied NHS Number is outside the English and Welsh NHS Number range or length of the number is wrong." />
        <expression value="identifier.where(system='https://fhir.nhs.uk/Id/nhs-number').exists().not() or (identifier.where(system='https://fhir.nhs.uk/Id/nhs-number').exists()  and identifier.where(system='https://fhir.nhs.uk/Id/nhs-number').value.matches('^([456789]{1}[0-9]{9})$'))" />
        <source value="https://fhir.nhs.uk/StructureDefinition/NHSDigital-Claim" />
      </constraint>
      <mustSupport value="true" />
    </element>
    <element id="QuestionnaireResponse.subject.identifier.system">
      <path value="QuestionnaireResponse.subject.identifier.system" />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="QuestionnaireResponse.subject.identifier.value">
      <path value="QuestionnaireResponse.subject.identifier.value" />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="QuestionnaireResponse.subject.display">
      <path value="QuestionnaireResponse.subject.display" />
      <mustSupport value="true" />
    </element>
    <element id="QuestionnaireResponse.authored">
      <path value="QuestionnaireResponse.authored" />
      <definition value="The date and/or time that this set of answers were last changed.&#xD;&#xA;&#xD;&#xA;```json&#xD;&#xA;&quot;authored&quot;: &quot;2021-09-09T08:32:00+00:00&quot;,&#xD;&#xA;```" />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="QuestionnaireResponse.author">
      <path value="QuestionnaireResponse.author" />
      <definition value="Person who received the answers to the questions in the QuestionnaireResponse and recorded them in the system.&#xD;&#xA;&#xD;&#xA;```json&#xD;&#xA;&quot;author&quot;: {&#xD;&#xA;        &quot;identifier&quot;: {&#xD;&#xA;            &quot;system&quot;: &quot;https://fhir.nhs.uk/Id/ods-organization-code&quot;,&#xD;&#xA;            &quot;value&quot;: &quot;B81001&quot;&#xD;&#xA;        },&#xD;&#xA;        &quot;display&quot;: &quot;Austhorpe Springs Practice&quot;&#xD;&#xA;    },&#xD;&#xA;```" />
      <type>
        <code value="Reference" />
        <targetProfile value="https://fhir.nhs.uk/StructureDefinition/NHSDigital-Organization" />
        <targetProfile value="https://fhir.nhs.uk/StructureDefinition/NHSDigital-PractitionerRole-Minimal" />
        <aggregation value="contained" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="QuestionnaireResponse.author.identifier.system">
      <path value="QuestionnaireResponse.author.identifier.system" />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="QuestionnaireResponse.author.identifier.value">
      <path value="QuestionnaireResponse.author.identifier.value" />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="QuestionnaireResponse.author.display">
      <path value="QuestionnaireResponse.author.display" />
      <mustSupport value="true" />
    </element>
    <element id="QuestionnaireResponse.source">
      <path value="QuestionnaireResponse.source" />
      <type>
        <code value="Reference" />
        <targetProfile value="https://fhir.nhs.uk/StructureDefinition/NHSDigital-PractitionerRole" />
        <aggregation value="contained" />
      </type>
      <constraint>
        <key value="usercode-reference" />
        <severity value="warning" />
        <human value="An identifier reference or resource reference must be provided" />
        <expression value="(reference.exists() or (identifier.exists()))" />
        <source value="https://fhir.nhs.uk/StructureDefinition/NHSDigital-QuestionnaireResponse" />
      </constraint>
      <constraint>
        <key value="usercode-nmc" />
        <severity value="error" />
        <human value="NMC must be of the format NNANNNNA" />
        <expression value="identifier.exists().not() or identifier.where(system='https://fhir.hl7.org.uk/Id/nmc-number').exists().not() or (identifier.where(system='https://fhir.hl7.org.uk/Id/nmc-number').exists()  and identifier.where(system='https://fhir.hl7.org.uk/Id/nmc-number').value.matches('^[0-9]{2}[A-Z]{1}[0-9]{4}[A-Z]{1}$'))" />
        <source value="https://fhir.nhs.uk/StructureDefinition/NHSDigital-QuestionnaireResponse" />
      </constraint>
      <constraint>
        <key value="usercodee-gmp" />
        <severity value="error" />
        <human value="GMP must be of the format GNNNNNNN and not be a spurious code (starts with G6 or G7)" />
        <expression value="identifier.exists().not() or identifier.where(system='https://fhir.hl7.org.uk/Id/gmp-number').exists().not() or (identifier.where(system='https://fhir.hl7.org.uk/Id/gmp-number').exists()  and identifier.where(system='https://fhir.hl7.org.uk/Id/gmp-number').value.matches('^[G]{1}[01234589]{1}[0-9]{6}$'))" />
        <source value="https://fhir.nhs.uk/StructureDefinition/NHSDigital-QuestionnaireResponse" />
      </constraint>
      <constraint>
        <key value="usercode-gmc" />
        <severity value="error" />
        <human value="GMC must be of the format CNNNNNNN" />
        <expression value="identifier.exists().not() or identifier.where(system='https://fhir.hl7.org.uk/Id/gmc-number').exists().not() or (identifier.where(system='https://fhir.hl7.org.uk/Id/gmc-number').exists()  and identifier.where(system='https://fhir.hl7.org.uk/Id/gmc-number').value.matches('^[C]{1}[0-9]{7}$'))" />
        <source value="https://fhir.nhs.uk/StructureDefinition/NHSDigital-QuestionnaireResponse" />
      </constraint>
      <constraint>
        <key value="usercode-gphc" />
        <severity value="error" />
        <human value="GPHC must be of the format NNNNNNN" />
        <expression value="identifier.exists().not() or identifier.where(system='https://fhir.hl7.org.uk/Id/gphc-number').exists().not() or (identifier.where(system='https://fhir.hl7.org.uk/Id/gphc-number').exists()  and identifier.where(system='https://fhir.hl7.org.uk/Id/gphc-number').value.matches('^[0-9]{7}$'))" />
        <source value="https://fhir.nhs.uk/StructureDefinition/NHSDigital-QuestionnaireResponse" />
      </constraint>
      <constraint>
        <key value="usercode-hcpc" />
        <severity value="error" />
        <human value="HCPC must be of the format AANNNNNN" />
        <expression value="identifier.exists().not() or identifier.where(system='https://fhir.hl7.org.uk/Id/hcpc-number').exists().not() or (identifier.where(system='https://fhir.hl7.org.uk/Id/hcpc-number').exists()  and identifier.where(system='https://fhir.hl7.org.uk/Id/hcpc-number').value.matches('^[A-Z]{2}[0-9]{6}$'))" />
        <source value="https://fhir.nhs.uk/StructureDefinition/NHSDigital-QuestionnaireResponse" />
      </constraint>
      <constraint>
        <key value="usercode-din" />
        <severity value="error" />
        <human value="DIN format must be NNNNNN" />
        <expression value="identifier.exists().not() or identifier.where(system='https://fhir.hl7.org.uk/Id/din-number').exists().not() or (identifier.where(system='https://fhir.hl7.org.uk/Id/din-number').exists()  and identifier.where(system='https://fhir.hl7.org.uk/Id/din-number').value.matches('^[0-9]{6}$'))" />
        <source value="https://fhir.nhs.uk/StructureDefinition/NHSDigital-QuestionnaireResponse" />
      </constraint>
      <mustSupport value="true" />
    </element>
    <element id="QuestionnaireResponse.source.identifier">
      <path value="QuestionnaireResponse.source.identifier" />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="QuestionnaireResponse.source.identifier.value">
      <path value="QuestionnaireResponse.source.identifier.value" />
      <min value="1" />
    </element>
    <element id="QuestionnaireResponse.source.display">
      <path value="QuestionnaireResponse.source.display" />
      <mustSupport value="true" />
    </element>
    <element id="QuestionnaireResponse.item">
      <path value="QuestionnaireResponse.item" />
      <definition value="A group or question item from the original questionnaire for which answers are provided.&#xD;&#xA;&#xD;&#xA;```json&#xD;&#xA; &quot;item&quot;: [&#xD;&#xA;        {&#xD;&#xA;            &quot;linkId&quot;: &quot;exemptionStatus&quot;,&#xD;&#xA;            &quot;answer&quot;: [&#xD;&#xA;                {&#xD;&#xA;                    &quot;valueCoding&quot;: {&#xD;&#xA;                        &quot;system&quot;: &quot;https://fhir.nhs.uk/CodeSystem/covid-vaccination-medical-exemption&quot;,&#xD;&#xA;                        &quot;code&quot;: &quot;4&quot;,&#xD;&#xA;                        &quot;display&quot;: &quot;Rejected: Exemption from COVID vaccination and testing&quot;&#xD;&#xA;                    }&#xD;&#xA;                }&#xD;&#xA;            ]&#xD;&#xA;        }&#xD;&#xA;   ]&#xD;&#xA;```" />
      <min value="1" />
      <mustSupport value="true" />
    </element>
  </differential>
</StructureDefinition>