{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "CareStellar local working record, not a clinical exchange standard",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema_version",
    "summary_id",
    "summary_date",
    "generated_at",
    "language",
    "author",
    "review",
    "patient",
    "sources",
    "allergies",
    "medications",
    "problems"
  ],
  "properties": {
    "schema_version": {
      "enum": [
        "1.0.0",
        "1.1.0"
      ]
    },
    "summary_id": {
      "type": "string",
      "format": "uuid"
    },
    "summary_date": {
      "type": "string",
      "format": "date",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
    },
    "generated_at": {
      "type": "string",
      "format": "date-time"
    },
    "language": {
      "type": "string",
      "pattern": "^[A-Za-z]{2,8}(-[A-Za-z0-9]{1,8})*$",
      "maxLength": 40
    },
    "author": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "name",
        "role"
      ],
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1,
          "maxLength": 500
        },
        "role": {
          "enum": [
            "patient",
            "caregiver",
            "clinician",
            "organization"
          ]
        }
      }
    },
    "review": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "status"
      ],
      "properties": {
        "status": {
          "enum": [
            "not_reviewed",
            "patient_reviewed",
            "clinician_reviewed"
          ]
        },
        "reviewer": {
          "type": "string",
          "minLength": 1,
          "maxLength": 500
        },
        "reviewed_at": {
          "type": "string",
          "maxLength": 60
        },
        "source_id": {
          "type": "string",
          "pattern": "^[A-Za-z][A-Za-z0-9._-]{0,63}$"
        },
        "content_sha256": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$",
          "description": "SHA-256 of canonical JSON of every record field except review. Content binding only; not reviewer authentication or a digital signature."
        }
      }
    },
    "patient": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "name"
      ],
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1,
          "maxLength": 500
        },
        "birth_date": {
          "type": "string",
          "format": "date",
          "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
        },
        "sex": {
          "enum": [
            "female",
            "male",
            "other",
            "unknown"
          ],
          "description": "Legacy input field preserved as labeled source text; it is not automatically mapped to FHIR administrative gender."
        },
        "preferred_language": {
          "type": "string",
          "minLength": 1,
          "maxLength": 500
        },
        "identifiers": {
          "type": "array",
          "maxItems": 20,
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "system",
              "value"
            ],
            "properties": {
              "system": {
                "type": "string",
                "format": "uri",
                "maxLength": 500
              },
              "value": {
                "type": "string",
                "minLength": 1,
                "maxLength": 500
              },
              "label": {
                "type": "string",
                "minLength": 1,
                "maxLength": 500
              }
            }
          }
        },
        "administrative_gender": {
          "enum": [
            "female",
            "male",
            "other",
            "unknown"
          ],
          "description": "Explicitly supplied FHIR administrative gender for administration and record keeping; never inferred from another sex or gender field."
        },
        "administrative_gender_source_ids": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^[A-Za-z][A-Za-z0-9._-]{0,63}$"
          },
          "uniqueItems": true,
          "minItems": 1,
          "maxItems": 200,
          "description": "Sources explicitly establishing the supplied administrative gender."
        }
      }
    },
    "sources": {
      "type": "array",
      "maxItems": 200,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "title",
          "kind",
          "original_reviewed"
        ],
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[A-Za-z][A-Za-z0-9._-]{0,63}$"
          },
          "title": {
            "type": "string",
            "minLength": 1,
            "maxLength": 500
          },
          "kind": {
            "enum": [
              "clinical_document",
              "patient_report",
              "caregiver_report",
              "clinician_report",
              "prior_summary"
            ]
          },
          "date": {
            "type": "string",
            "format": "date",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
          },
          "locator": {
            "type": "string",
            "minLength": 1,
            "maxLength": 500
          },
          "original_reviewed": {
            "type": "boolean"
          }
        }
      }
    },
    "current_concern": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "title",
        "source_ids"
      ],
      "properties": {
        "title": {
          "type": "string",
          "minLength": 1,
          "maxLength": 500
        },
        "description": {
          "type": "string",
          "minLength": 1,
          "maxLength": 12000
        },
        "symptoms": {
          "type": "string",
          "minLength": 1,
          "maxLength": 12000
        },
        "onset": {
          "type": "string",
          "minLength": 1,
          "maxLength": 500
        },
        "current_status": {
          "type": "string",
          "minLength": 1,
          "maxLength": 12000
        },
        "source_ids": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^[A-Za-z][A-Za-z0-9._-]{0,63}$"
          },
          "uniqueItems": true,
          "maxItems": 200,
          "minItems": 1
        }
      }
    },
    "allergies": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "status",
        "source_ids",
        "items"
      ],
      "properties": {
        "status": {
          "enum": [
            "documented",
            "none_known",
            "unknown",
            "not_asked"
          ]
        },
        "source_ids": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^[A-Za-z][A-Za-z0-9._-]{0,63}$"
          },
          "uniqueItems": true,
          "maxItems": 200
        },
        "items": {
          "type": "array",
          "maxItems": 200,
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id",
              "label",
              "source_ids"
            ],
            "properties": {
              "id": {
                "type": "string",
                "pattern": "^[A-Za-z][A-Za-z0-9._-]{0,63}$"
              },
              "label": {
                "type": "string",
                "minLength": 1,
                "maxLength": 500
              },
              "source_ids": {
                "type": "array",
                "items": {
                  "type": "string",
                  "pattern": "^[A-Za-z][A-Za-z0-9._-]{0,63}$"
                },
                "uniqueItems": true,
                "maxItems": 200,
                "minItems": 1
              },
              "notes": {
                "type": "string",
                "minLength": 1,
                "maxLength": 12000
              },
              "date": {
                "type": "string",
                "format": "date",
                "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
              },
              "date_text": {
                "type": "string",
                "minLength": 1,
                "maxLength": 500
              },
              "verification": {
                "enum": [
                  "documented_in_source",
                  "patient_reported",
                  "caregiver_reported",
                  "uncertain"
                ]
              },
              "code": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "system",
                  "code",
                  "display"
                ],
                "properties": {
                  "system": {
                    "type": "string",
                    "format": "uri",
                    "maxLength": 500
                  },
                  "code": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 500
                  },
                  "display": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 500
                  }
                }
              },
              "reaction": {
                "type": "string",
                "minLength": 1,
                "maxLength": 12000
              },
              "severity": {
                "type": "string",
                "minLength": 1,
                "maxLength": 500
              },
              "clinical_status": {
                "enum": [
                  "active",
                  "inactive",
                  "resolved",
                  "unknown"
                ]
              }
            }
          }
        }
      }
    },
    "medications": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "status",
        "source_ids",
        "items"
      ],
      "properties": {
        "status": {
          "enum": [
            "documented",
            "none_known",
            "unknown",
            "not_asked"
          ]
        },
        "source_ids": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^[A-Za-z][A-Za-z0-9._-]{0,63}$"
          },
          "uniqueItems": true,
          "maxItems": 200
        },
        "items": {
          "type": "array",
          "maxItems": 200,
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id",
              "label",
              "source_ids"
            ],
            "properties": {
              "id": {
                "type": "string",
                "pattern": "^[A-Za-z][A-Za-z0-9._-]{0,63}$"
              },
              "label": {
                "type": "string",
                "minLength": 1,
                "maxLength": 500
              },
              "source_ids": {
                "type": "array",
                "items": {
                  "type": "string",
                  "pattern": "^[A-Za-z][A-Za-z0-9._-]{0,63}$"
                },
                "uniqueItems": true,
                "maxItems": 200,
                "minItems": 1
              },
              "notes": {
                "type": "string",
                "minLength": 1,
                "maxLength": 12000
              },
              "date": {
                "type": "string",
                "format": "date",
                "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
              },
              "date_text": {
                "type": "string",
                "minLength": 1,
                "maxLength": 500
              },
              "verification": {
                "enum": [
                  "documented_in_source",
                  "patient_reported",
                  "caregiver_reported",
                  "uncertain"
                ]
              },
              "code": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "system",
                  "code",
                  "display"
                ],
                "properties": {
                  "system": {
                    "type": "string",
                    "format": "uri",
                    "maxLength": 500
                  },
                  "code": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 500
                  },
                  "display": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 500
                  }
                }
              },
              "dose": {
                "type": "string",
                "minLength": 1,
                "maxLength": 500
              },
              "route": {
                "type": "string",
                "minLength": 1,
                "maxLength": 500
              },
              "frequency": {
                "type": "string",
                "minLength": 1,
                "maxLength": 500
              },
              "clinical_status": {
                "enum": [
                  "active",
                  "stopped",
                  "on_hold",
                  "historical",
                  "unknown"
                ]
              },
              "as_of_date": {
                "type": "string",
                "format": "date",
                "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
              }
            }
          }
        }
      }
    },
    "problems": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "status",
        "source_ids",
        "items"
      ],
      "properties": {
        "status": {
          "enum": [
            "documented",
            "none_known",
            "unknown",
            "not_asked"
          ]
        },
        "source_ids": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^[A-Za-z][A-Za-z0-9._-]{0,63}$"
          },
          "uniqueItems": true,
          "maxItems": 200
        },
        "items": {
          "type": "array",
          "maxItems": 200,
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id",
              "label",
              "source_ids"
            ],
            "properties": {
              "id": {
                "type": "string",
                "pattern": "^[A-Za-z][A-Za-z0-9._-]{0,63}$"
              },
              "label": {
                "type": "string",
                "minLength": 1,
                "maxLength": 500
              },
              "source_ids": {
                "type": "array",
                "items": {
                  "type": "string",
                  "pattern": "^[A-Za-z][A-Za-z0-9._-]{0,63}$"
                },
                "uniqueItems": true,
                "maxItems": 200,
                "minItems": 1
              },
              "notes": {
                "type": "string",
                "minLength": 1,
                "maxLength": 12000
              },
              "date": {
                "type": "string",
                "format": "date",
                "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
              },
              "date_text": {
                "type": "string",
                "minLength": 1,
                "maxLength": 500
              },
              "verification": {
                "enum": [
                  "documented_in_source",
                  "patient_reported",
                  "caregiver_reported",
                  "uncertain"
                ]
              },
              "code": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "system",
                  "code",
                  "display"
                ],
                "properties": {
                  "system": {
                    "type": "string",
                    "format": "uri",
                    "maxLength": 500
                  },
                  "code": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 500
                  },
                  "display": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 500
                  }
                }
              },
              "clinical_status": {
                "enum": [
                  "active",
                  "inactive",
                  "resolved",
                  "unknown"
                ]
              }
            }
          }
        }
      }
    },
    "procedures": {
      "type": "array",
      "maxItems": 200,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "label",
          "source_ids"
        ],
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[A-Za-z][A-Za-z0-9._-]{0,63}$"
          },
          "label": {
            "type": "string",
            "minLength": 1,
            "maxLength": 500
          },
          "source_ids": {
            "type": "array",
            "items": {
              "type": "string",
              "pattern": "^[A-Za-z][A-Za-z0-9._-]{0,63}$"
            },
            "uniqueItems": true,
            "maxItems": 200,
            "minItems": 1
          },
          "notes": {
            "type": "string",
            "minLength": 1,
            "maxLength": 12000
          },
          "date": {
            "type": "string",
            "format": "date",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
          },
          "date_text": {
            "type": "string",
            "minLength": 1,
            "maxLength": 500
          },
          "verification": {
            "enum": [
              "documented_in_source",
              "patient_reported",
              "caregiver_reported",
              "uncertain"
            ]
          },
          "code": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "system",
              "code",
              "display"
            ],
            "properties": {
              "system": {
                "type": "string",
                "format": "uri",
                "maxLength": 500
              },
              "code": {
                "type": "string",
                "minLength": 1,
                "maxLength": 500
              },
              "display": {
                "type": "string",
                "minLength": 1,
                "maxLength": 500
              }
            }
          }
        }
      }
    },
    "results": {
      "type": "array",
      "maxItems": 200,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "label",
          "source_ids"
        ],
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[A-Za-z][A-Za-z0-9._-]{0,63}$"
          },
          "label": {
            "type": "string",
            "minLength": 1,
            "maxLength": 500
          },
          "source_ids": {
            "type": "array",
            "items": {
              "type": "string",
              "pattern": "^[A-Za-z][A-Za-z0-9._-]{0,63}$"
            },
            "uniqueItems": true,
            "maxItems": 200,
            "minItems": 1
          },
          "notes": {
            "type": "string",
            "minLength": 1,
            "maxLength": 12000
          },
          "date": {
            "type": "string",
            "format": "date",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
          },
          "date_text": {
            "type": "string",
            "minLength": 1,
            "maxLength": 500
          },
          "verification": {
            "enum": [
              "documented_in_source",
              "patient_reported",
              "caregiver_reported",
              "uncertain"
            ]
          },
          "code": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "system",
              "code",
              "display"
            ],
            "properties": {
              "system": {
                "type": "string",
                "format": "uri",
                "maxLength": 500
              },
              "code": {
                "type": "string",
                "minLength": 1,
                "maxLength": 500
              },
              "display": {
                "type": "string",
                "minLength": 1,
                "maxLength": 500
              }
            }
          },
          "value": {
            "type": "string",
            "minLength": 1,
            "maxLength": 500
          },
          "unit": {
            "type": "string",
            "minLength": 1,
            "maxLength": 500
          },
          "interpretation": {
            "type": "string",
            "minLength": 1,
            "maxLength": 12000
          }
        }
      }
    },
    "events": {
      "type": "array",
      "maxItems": 200,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "label",
          "source_ids"
        ],
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[A-Za-z][A-Za-z0-9._-]{0,63}$"
          },
          "label": {
            "type": "string",
            "minLength": 1,
            "maxLength": 500
          },
          "source_ids": {
            "type": "array",
            "items": {
              "type": "string",
              "pattern": "^[A-Za-z][A-Za-z0-9._-]{0,63}$"
            },
            "uniqueItems": true,
            "maxItems": 200,
            "minItems": 1
          },
          "notes": {
            "type": "string",
            "minLength": 1,
            "maxLength": 12000
          },
          "date": {
            "type": "string",
            "format": "date",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
          },
          "date_text": {
            "type": "string",
            "minLength": 1,
            "maxLength": 500
          },
          "verification": {
            "enum": [
              "documented_in_source",
              "patient_reported",
              "caregiver_reported",
              "uncertain"
            ]
          },
          "code": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "system",
              "code",
              "display"
            ],
            "properties": {
              "system": {
                "type": "string",
                "format": "uri",
                "maxLength": 500
              },
              "code": {
                "type": "string",
                "minLength": 1,
                "maxLength": 500
              },
              "display": {
                "type": "string",
                "minLength": 1,
                "maxLength": 500
              }
            }
          },
          "description": {
            "type": "string",
            "minLength": 1,
            "maxLength": 12000
          }
        }
      }
    },
    "patient_story": {
      "type": "array",
      "maxItems": 30,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "label",
          "source_ids"
        ],
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[A-Za-z][A-Za-z0-9._-]{0,63}$"
          },
          "label": {
            "type": "string",
            "minLength": 1,
            "maxLength": 500
          },
          "source_ids": {
            "type": "array",
            "items": {
              "type": "string",
              "pattern": "^[A-Za-z][A-Za-z0-9._-]{0,63}$"
            },
            "uniqueItems": true,
            "maxItems": 200,
            "minItems": 1
          },
          "notes": {
            "type": "string",
            "minLength": 1,
            "maxLength": 12000
          },
          "date": {
            "type": "string",
            "format": "date",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
          },
          "date_text": {
            "type": "string",
            "minLength": 1,
            "maxLength": 500
          },
          "verification": {
            "enum": [
              "documented_in_source",
              "patient_reported",
              "caregiver_reported",
              "uncertain"
            ]
          },
          "code": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "system",
              "code",
              "display"
            ],
            "properties": {
              "system": {
                "type": "string",
                "format": "uri",
                "maxLength": 500
              },
              "code": {
                "type": "string",
                "minLength": 1,
                "maxLength": 500
              },
              "display": {
                "type": "string",
                "minLength": 1,
                "maxLength": 500
              }
            }
          },
          "description": {
            "type": "string",
            "minLength": 1,
            "maxLength": 12000
          }
        }
      }
    },
    "contacts": {
      "type": "array",
      "maxItems": 20,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "name",
          "relationship"
        ],
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 500
          },
          "relationship": {
            "type": "string",
            "minLength": 1,
            "maxLength": 500
          },
          "phone": {
            "type": "string",
            "minLength": 1,
            "maxLength": 500
          },
          "source_ids": {
            "type": "array",
            "items": {
              "type": "string",
              "pattern": "^[A-Za-z][A-Za-z0-9._-]{0,63}$"
            },
            "uniqueItems": true,
            "maxItems": 200,
            "minItems": 1
          }
        }
      }
    },
    "questions": {
      "type": "array",
      "maxItems": 30,
      "items": {
        "type": "string",
        "minLength": 1,
        "maxLength": 12000
      }
    },
    "discrepancies": {
      "type": "array",
      "maxItems": 100,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "description",
          "source_ids",
          "status"
        ],
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[A-Za-z][A-Za-z0-9._-]{0,63}$"
          },
          "description": {
            "type": "string",
            "minLength": 1,
            "maxLength": 12000
          },
          "source_ids": {
            "type": "array",
            "items": {
              "type": "string",
              "pattern": "^[A-Za-z][A-Za-z0-9._-]{0,63}$"
            },
            "uniqueItems": true,
            "maxItems": 200,
            "minItems": 1
          },
          "status": {
            "enum": [
              "open",
              "resolved"
            ]
          },
          "resolution": {
            "type": "string",
            "minLength": 1,
            "maxLength": 12000
          }
        }
      }
    },
    "card": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "medication_ids",
        "problem_ids",
        "include_contact"
      ],
      "properties": {
        "medication_ids": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^[A-Za-z][A-Za-z0-9._-]{0,63}$"
          },
          "uniqueItems": true,
          "maxItems": 200
        },
        "problem_ids": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^[A-Za-z][A-Za-z0-9._-]{0,63}$"
          },
          "uniqueItems": true,
          "maxItems": 200
        },
        "include_contact": {
          "type": "boolean"
        }
      }
    },
    "summary_selection": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "medication_ids",
        "problem_ids",
        "result_ids"
      ],
      "properties": {
        "medication_ids": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^[A-Za-z][A-Za-z0-9._-]{0,63}$"
          },
          "uniqueItems": true,
          "maxItems": 200
        },
        "problem_ids": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^[A-Za-z][A-Za-z0-9._-]{0,63}$"
          },
          "uniqueItems": true,
          "maxItems": 200
        },
        "result_ids": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^[A-Za-z][A-Za-z0-9._-]{0,63}$"
          },
          "uniqueItems": true,
          "maxItems": 200
        }
      }
    },
    "synthetic": {
      "type": "boolean"
    },
    "version": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "number",
        "history"
      ],
      "properties": {
        "number": {
          "type": "integer",
          "minimum": 1,
          "maximum": 10000
        },
        "previous": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "number",
            "summary_id",
            "summary_date",
            "content_sha256"
          ],
          "properties": {
            "number": {
              "type": "integer",
              "minimum": 1,
              "maximum": 10000
            },
            "summary_id": {
              "type": "string",
              "format": "uuid"
            },
            "summary_date": {
              "type": "string",
              "format": "date"
            },
            "content_sha256": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            }
          }
        },
        "history": {
          "type": "array",
          "maxItems": 1000,
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "number",
              "summary_id",
              "summary_date",
              "content_sha256"
            ],
            "properties": {
              "number": {
                "type": "integer",
                "minimum": 1,
                "maximum": 10000
              },
              "summary_id": {
                "type": "string",
                "format": "uuid"
              },
              "summary_date": {
                "type": "string",
                "format": "date"
              },
              "content_sha256": {
                "type": "string",
                "pattern": "^[0-9a-f]{64}$"
              }
            }
          }
        },
        "update": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "baseline_content_sha256",
            "candidate_content_sha256",
            "new_source_ids",
            "changes"
          ],
          "properties": {
            "baseline_content_sha256": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            },
            "candidate_content_sha256": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            },
            "new_source_ids": {
              "type": "array",
              "items": {
                "type": "string",
                "pattern": "^[A-Za-z][A-Za-z0-9._-]{0,63}$"
              },
              "uniqueItems": true,
              "maxItems": 200
            },
            "changes": {
              "type": "array",
              "maxItems": 500,
              "items": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "id",
                  "kind",
                  "target",
                  "decision",
                  "summary",
                  "source_ids"
                ],
                "properties": {
                  "id": {
                    "type": "string",
                    "pattern": "^c-[0-9a-f]{12}$"
                  },
                  "kind": {
                    "enum": [
                      "added",
                      "changed",
                      "removed",
                      "status_changed",
                      "conflict_noted",
                      "question_added",
                      "question_removed"
                    ]
                  },
                  "target": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "decision": {
                    "enum": [
                      "accepted",
                      "kept_open",
                      "rejected"
                    ]
                  },
                  "summary": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 4000
                  },
                  "source_ids": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "pattern": "^[A-Za-z][A-Za-z0-9._-]{0,63}$"
                    },
                    "uniqueItems": true,
                    "maxItems": 200
                  },
                  "flags": {
                    "type": "array",
                    "maxItems": 20,
                    "items": {
                      "enum": [
                        "older_source",
                        "undated_source",
                        "current_use_not_established",
                        "stopped_or_paused",
                        "conflicting_dates",
                        "missing_unit",
                        "unit_removed",
                        "no_new_source",
                        "possible_duplicate",
                        "removed_item",
                        "identity_change"
                      ]
                    },
                    "uniqueItems": true
                  },
                  "check_id": {
                    "type": "string",
                    "pattern": "^[A-Za-z][A-Za-z0-9._-]{0,63}$"
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
