UKCore Hackathon Supporting Guide

This guidance is under active development by NHS England and content may be added or updated on a regular basis.

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 Creating Forms

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

  1. Click on Search LOINC Panels
  2. Enter Kansas City Cardiomyopathy Questionnaire - 12 item
  3. Select the entry and click on show panel
  4. Enter some data into the form
  5. Click on Show Form Data As and select SDC QuestionnaireResponse
  6. Copy the JSON response.

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

{
  "resourceType": "QuestionnaireResponse",
  "meta": {
    "profile": [
      "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaireresponse|2.7"
    ],
    "tag": [
      {
        "code": "lformsVersion: 33.1.2"
      }
    ]
  },
  "status": "completed",
  "authored": "2023-02-24T07:29:15.300Z",
  "item": [
    {
      "linkId": "/86483-5",
      "text": "Please indicate how much you are limited by heart failure (shortness of breath or fatigue) in your ability to do the following activities over the past 2 weeks. Showering or bathing",
      "answer": [
        {
          "valueCoding": {
            "system": "http://loinc.org",
            "code": "LA27708-9",
            "display": "Limited for other reasons or did not do the activity"
          }
        }
      ]
    },
    {
      "linkId": "/86474-4",
      "text": "Please indicate how much you are limited by heart failure (shortness of breath or fatigue) in your ability to do the following activities over the past 2 weeks. Walking 1 block on level ground",
      "answer": [
        {
          "valueCoding": {
            "system": "http://loinc.org",
            "code": "LA6460-5",
            "display": "Moderately limited"
          }
        }
      ]
    },
    {
      "linkId": "/86477-7",
      "text": "Please indicate how much you are limited by heart failure (shortness of breath or fatigue) in your ability to do the following activities over the past 2 weeks. Hurrying or jogging (as if to catch a bus)",
      "answer": [
        {
          "valueCoding": {
            "system": "http://loinc.org",
            "code": "LA9605-2",
            "display": "Slightly limited"
          }
        }
      ]
    },
    {
      "linkId": "/86481-9",
      "text": "Over the past 2 weeks, on average, how many times has fatigue limited your ability to do what you want?",
      "answer": [
        {
          "valueCoding": {
            "system": "http://loinc.org",
            "code": "LA27730-3",
            "display": "At least once a day"
          }
        }
      ]
    },
    {
      "linkId": "/86472-8",
      "text": "Over the past 2 weeks, on average, how many times has shortness of breath limited your ability to do what you wanted?",
      "answer": [
        {
          "valueCoding": {
            "system": "http://loinc.org",
            "code": "LA27770-9",
            "display": "3 or more times per week but not every day"
          }
        }
      ]
    },
    {
      "linkId": "/86485-0",
      "text": "Over the past 2 weeks, on average, how many times have you been forced to sleep sitting up in a chair or with at least 3 pillows to prop you up because of shortness of breath?",
      "answer": [
        {
          "valueCoding": {
            "system": "http://loinc.org",
            "code": "LA27720-4",
            "display": "3 or more times a week, but not every day"
          }
        }
      ]
    },
    {
      "linkId": "/86924-8",
      "text": "Overall summary score",
      "answer": [
        {
          "valueDecimal": 22
        }
      ]
    }
  ]
}

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 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/86923-0 If we amend the JSON (see below) and try validating this passes validation.

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

The UKCore Hackathon 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/86923-0",
  "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": [

An example of the finished resource can be found on Github

Add the resource to the server via POST /QuestionnaireResponse


back to top