2. Completing the Form

FHIR does not define or dictate how an application should store it's completed forms. It does suggest methods of sharing the completed forms with others providers and applications. The idea here is standardising the API so that the persisted forms can be shared (at scale) within the NHS and Social Services.

The common format of the completed forms in FHIR is a FHIR QuestionnaireResponse.

UKCore-QuestionnaireResponse

The XML and JSON schema for this is the same as international FHIR QuestionnaireResponse. Note: UKCore is not a schema, it is data rules which build on top of HL7 FHIR schema.

These QuestionnaireResponses SHOULD follow the definition of the forms in a FHIR Questionnaire. In Structured Data Capture, the management of these definitions is called Form Manager and this has been partly discussed in 1. Creating the Form

To see what the QuestionnaireResponse looks like we will use another application from NLM LHC FHIR Tools.

  1. Under Featured Forms
  2. Select Vital Signs Panel
  3. Enter some data into the form
  4. Click on Show Form Data As and select SDC QuestionnaireResponse
  5. Copy the JSON response.

Note: This step is simulating a practitioner or patient completing the form and then the application converting the response to FHIR.

We need to make some changes to this so that it can be stored on the UKCore Hackathon server.

  1. Open up the FHIR Validator
  2. Click 'Try it out`
  3. Remove the profile entry, we are going to use the default profile configured in the validator.
  4. Paste in the JSON from the earlier steps and click execute.

The result should look something like this

{
  "resourceType": "OperationOutcome",
  "issue": [
    {
      "severity": "error",
      "code": "processing",
      "details": {
        "coding": [
          {
            "system": "http://hl7.org/fhir/java-core-messageId",
            "code": "Validation_VAL_Profile_Minimum"
          }
        ]
      },
      "diagnostics": "QuestionnaireResponse.questionnaire: minimum required = 1, but only found 0 (from https://fhir.nhs.uk/StructureDefinition/NHSDigital-QuestionnaireResponse)",
      "location": [
        "QuestionnaireResponse",
        "Line 1, Col 2"
      ]
    },
    {
      "severity": "information",
      "code": "processing",
      "details": {
        "coding": [
          {
            "system": "http://hl7.org/fhir/java-core-messageId",
            "code": "Questionnaire_QR_Q_None"
          }
        ]
      },
      "diagnostics": "No questionnaire is identified, so no validation can be performed against the base questionnaire",
      "location": [
        "QuestionnaireResponse",
        "Line 1, Col 2"
      ]
    }
  ]
}

This says we need to supply a QuestionnaireResponse.questionnaire entry. From earlier steps when we added the Questionnaire to the server, this is entry is https://example.fhir.nhs.uk/Questionnaire/74728-7 If we amend the JSON (see below) and try validating again this time it passes.

{
    "resourceType": "QuestionnaireResponse",
    "status": "completed",
    "authored": "2023-02-24T07:29:15.300Z",
    "questionnaire": "https://example.fhir.nhs.uk/Questionnaire/74728-7",
    "item": [

The Demonstration Server will now accept this form and store it. If you wish to try this out use POST /QuestionnaireResponse

We have one big omission, it has not been linked to a Patient. To do this we need to add in a reference to the Patient or an identifier for the patient. For this example we are going to use the patients NHS Number which is an identifier. In addition to the patient identifier we add in an identifier for the form itself, the hackathon server uses this identifier to prevent duplicate entries.

{
  "resourceType": "QuestionnaireResponse",
  "status": "completed",
  "authored": "2023-02-24T07:29:15.300Z",
  "questionnaire": "https://example.fhir.nhs.uk/Questionnaire/74728-7",
  "identifier": {
    "system": "https://tools.ietf.org/html/rfc4122",
    "value": "56694b60-f3ba-4214-9868-d63d649f4bf0"
  },
  "subject": {
    "identifier": {
      "system": "https://fhir.nhs.uk/Id/nhs-number",
      "value": "9876543210"
    },
    "display": "R Kanfeld"
  },
  "item": [

This server is configured to accept NHS Number identifiers, an alternative (and common approach in FHIR) is the use references. This gives the following:

{
  "resourceType": "QuestionnaireResponse",
  "status": "completed",
  "authored": "2023-02-24T07:29:15.300Z",
  "questionnaire": "https://example.fhir.nhs.uk/Questionnaire/74728-7",
  "identifier": {
    "system": "https://tools.ietf.org/html/rfc4122",
    "value": "56694b60-f3ba-4214-9868-d63d649f4bf0"
  },
  "subject": {
    "reference" : "Patient/073eef49-81ee-4c2e-893b-bc2e4efd2630",
    "display": "R Kanfeld"
  },
  "item": [

Add the resource to the Demonstration Server via POST /QuestionnaireResponse