{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://developers.youareaccountable.com/schemas/notes.created.json",
  "title": "NotesCreated",
  "description": "A note is created. Sends the full note.",
  "type": "object",
  "required": [
    "event_type",
    "data"
  ],
  "properties": {
    "event_type": {
      "const": "notes.created"
    },
    "data": {
      "type": "object",
      "required": [
        "note_id",
        "medical_record_number",
        "note_content",
        "created_at",
        "created_by",
        "session_details",
        "coaching_session",
        "flags",
        "tox_id",
        "file"
      ],
      "properties": {
        "note_id": {
          "type": "string",
          "description": "The note's ID."
        },
        "medical_record_number": {
          "type": "string",
          "format": "uuid",
          "description": "The member's medical record number. Always a UUID. Use it to match the event to your own record."
        },
        "plan_name": {
          "type": [
            "string",
            "null"
          ],
          "description": "The member's Accountable plan. Can be null or left out."
        },
        "note_content": {
          "type": "string",
          "description": "The text of the note."
        },
        "created_at": {
          "type": "string",
          "format": "date-time",
          "description": "The date on the note."
        },
        "updated_at": {
          "type": "string",
          "format": "date-time",
          "description": "When the note was last changed."
        },
        "created_by": {
          "type": [
            "string",
            "null"
          ],
          "description": "First and last name of the person who wrote the note."
        },
        "session_details": {
          "type": [
            "object",
            "null"
          ],
          "description": "The actual times the coach logged. null when the note has none.",
          "properties": {
            "start_time": {
              "type": [
                "string",
                "null"
              ],
              "format": "date-time",
              "description": "When the session started. null on a no-show note."
            },
            "stop_time": {
              "type": [
                "string",
                "null"
              ],
              "format": "date-time",
              "description": "When the session ended. Ignore it when start_time is null."
            },
            "duration_minutes": {
              "type": [
                "number",
                "null"
              ],
              "description": "How long the session ran."
            }
          }
        },
        "coaching_session": {
          "type": [
            "object",
            "null"
          ],
          "description": "The scheduled session this note was matched to. Set only on check-in and no-show notes that match a scheduled session.",
          "required": [
            "session_id",
            "scheduled_date",
            "status",
            "recurrence_group_id"
          ],
          "properties": {
            "session_id": {
              "type": "string",
              "description": "The scheduled session's ID."
            },
            "scheduled_date": {
              "type": "string",
              "format": "date-time",
              "description": "The scheduled start time."
            },
            "end_time": {
              "type": [
                "string",
                "null"
              ],
              "format": "date-time",
              "description": "The scheduled end time."
            },
            "duration_minutes": {
              "type": [
                "number",
                "null"
              ],
              "description": "The scheduled length."
            },
            "status": {
              "enum": [
                "scheduled",
                "completed",
                "canceled",
                "no-show"
              ]
            },
            "recurrence_group_id": {
              "type": [
                "string",
                "null"
              ],
              "description": "Set when the session belongs to a recurring series."
            }
          }
        },
        "flags": {
          "type": "object",
          "description": "What kind of note this is.",
          "properties": {
            "essential_info": {
              "type": "boolean",
              "description": "The note holds important information about the member."
            },
            "recovery_capital_summary": {
              "type": "boolean",
              "description": "The note came from a recovery capital assessment."
            },
            "compliance": {
              "type": "boolean",
              "description": "The note is a compliance note."
            },
            "tox_review": {
              "type": "boolean",
              "description": "The note came from a review of a recorded test."
            },
            "onboarding_complete": {
              "type": "boolean",
              "description": "The note marks the end of onboarding."
            },
            "notify_care_team": {
              "type": "boolean",
              "description": "The care team was notified about the note."
            },
            "call": {
              "type": "boolean",
              "description": "A call was made."
            },
            "email": {
              "type": "boolean",
              "description": "An email was sent."
            },
            "checkin": {
              "type": "boolean",
              "description": "The note documents a session with the member."
            },
            "family_contact": {
              "type": "boolean",
              "description": "The note documents contact with family."
            },
            "clinical_contact": {
              "type": "boolean",
              "description": "The note documents contact with a clinician."
            },
            "justice_contact": {
              "type": "boolean",
              "description": "The note documents contact with probation, court or other justice staff."
            },
            "no_show": {
              "type": "boolean",
              "description": "The member missed a scheduled session."
            }
          }
        },
        "tox_id": {
          "type": [
            "string",
            "null"
          ],
          "description": "The related test result, if there is one. Matches test_id on toxicology and breathalyzer events."
        },
        "file": {
          "type": "null",
          "description": "Reserved. Always null."
        }
      }
    }
  },
  "examples": [
    {
      "event_type": "notes.created",
      "data": {
        "note_id": "665f1c2ab7e4d90012a3f4c4",
        "medical_record_number": "3f2b8c1e-7a4d-4e9b-9c55-0d6a1f2e8b47",
        "plan_name": "Standard Plan",
        "note_content": "Weekly session. Member reports steady progress.",
        "created_at": "2026-01-01T14:30:00.000Z",
        "updated_at": "2026-01-01T14:31:10.000Z",
        "created_by": "Jordan Rivera",
        "session_details": {
          "start_time": "2026-01-01T14:00:00.000Z",
          "stop_time": "2026-01-01T14:30:00.000Z",
          "duration_minutes": 30
        },
        "coaching_session": {
          "session_id": "665f1c2ab7e4d90012a3f4c5",
          "scheduled_date": "2026-01-01T14:00:00.000Z",
          "end_time": "2026-01-01T14:30:00.000Z",
          "duration_minutes": 30,
          "status": "completed",
          "recurrence_group_id": null
        },
        "flags": {
          "essential_info": false,
          "recovery_capital_summary": false,
          "compliance": false,
          "tox_review": false,
          "onboarding_complete": false,
          "notify_care_team": true,
          "call": false,
          "email": false,
          "checkin": true,
          "family_contact": false,
          "clinical_contact": false,
          "justice_contact": false,
          "no_show": false
        },
        "tox_id": null,
        "file": null
      }
    }
  ]
}
