{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/optum/json-schema/optum-next-question-response-schema.json",
  "title": "NextQuestionResponse",
  "description": "FHIR QuestionnaireResponse response containing next adaptive question",
  "x-generated": "2026-11-09",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/optum-nextquestion-api-openapi.yml#/components/schemas/NextQuestionResponse",
  "type": "object",
  "properties": {
    "resourceType": {
      "type": "string"
    },
    "meta": {
      "$ref": "#/$defs/Meta"
    },
    "contained": {
      "type": "array",
      "description": "Contained Questionnaire with next question items",
      "items": {
        "$ref": "#/$defs/Questionnaire"
      }
    },
    "extension": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/Extension"
      }
    },
    "questionnaire": {
      "type": "string"
    },
    "status": {
      "type": "string"
    },
    "subject": {
      "$ref": "#/$defs/Reference"
    },
    "authored": {
      "type": "string"
    }
  },
  "$defs": {
    "AnswerOption": {
      "type": "object",
      "description": "Answer choice option",
      "properties": {
        "valueCoding": {
          "$ref": "#/$defs/Coding"
        }
      }
    },
    "Coding": {
      "type": "object",
      "description": "Coding structure for answers",
      "properties": {
        "code": {
          "type": "string"
        },
        "display": {
          "type": "string"
        }
      }
    },
    "Extension": {
      "type": "object",
      "description": "FHIR extension with Reference",
      "properties": {
        "url": {
          "type": "string"
        },
        "valueReference": {
          "$ref": "#/$defs/Reference"
        }
      }
    },
    "ExtensionGeneric": {
      "type": "object",
      "description": "Generic extension supporting multiple value types",
      "properties": {
        "url": {
          "type": "string"
        },
        "valueBoolean": {
          "type": "boolean"
        },
        "valueUri": {
          "type": "string"
        }
      }
    },
    "Item": {
      "type": "object",
      "description": "Questionnaire item (question)",
      "properties": {
        "id": {
          "type": "string"
        },
        "linkId": {
          "type": "string"
        },
        "text": {
          "type": "string"
        },
        "type": {
          "type": "string"
        },
        "required": {
          "type": "boolean"
        },
        "repeats": {
          "type": "boolean"
        },
        "extension": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/ExtensionGeneric"
          }
        },
        "answerOption": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/AnswerOption"
          }
        },
        "item": {
          "type": "array",
          "description": "Nested child questions",
          "items": {
            "$ref": "#/$defs/Item"
          }
        }
      }
    },
    "Meta": {
      "type": "object",
      "description": "FHIR metadata",
      "properties": {
        "profile": {
          "type": "array",
          "description": "FHIR profile URLs",
          "items": {
            "type": "string"
          }
        }
      }
    },
    "Questionnaire": {
      "type": "object",
      "description": "FHIR Questionnaire resource",
      "properties": {
        "resourceType": {
          "type": "string"
        },
        "id": {
          "type": "string"
        },
        "meta": {
          "$ref": "#/$defs/Meta"
        },
        "extension": {
          "type": "array",
          "description": "Questionnaire extensions",
          "items": {
            "$ref": "#/$defs/ExtensionGeneric"
          }
        },
        "name": {
          "type": "string",
          "description": "Questionnaire name"
        },
        "title": {
          "type": "string",
          "description": "Questionnaire title"
        },
        "status": {
          "type": "string",
          "description": "Questionnaire status"
        },
        "date": {
          "type": "string",
          "description": "Date of creation"
        },
        "description": {
          "type": "string",
          "description": "Questionnaire description"
        },
        "item": {
          "type": "array",
          "description": "List of questions",
          "items": {
            "$ref": "#/$defs/Item"
          }
        }
      }
    },
    "Reference": {
      "type": "object",
      "description": "FHIR Reference",
      "properties": {
        "reference": {
          "type": "string"
        }
      }
    }
  }
}