{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://developers.youareaccountable.com/schemas/breathalyzer.result.posted.json",
  "title": "BreathalyzerResultPosted",
  "description": "A breathalyzer result is posted or changed. A changed result is sent again with the same test_id.",
  "type": "object",
  "required": [
    "event_type",
    "data"
  ],
  "properties": {
    "event_type": {
      "const": "breathalyzer.result.posted"
    },
    "data": {
      "type": "object",
      "required": [
        "medical_record_number",
        "test_date",
        "test_result",
        "test_type",
        "self_reported",
        "test_id"
      ],
      "properties": {
        "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."
        },
        "test_date": {
          "type": "string",
          "format": "date-time",
          "description": "When the test was taken."
        },
        "test_result": {
          "type": "string",
          "description": "The overall result. Usually Positive, Negative or Missed. Lab tests can also be Inconclusive.",
          "examples": [
            "Positive",
            "Negative",
            "Missed",
            "Inconclusive"
          ]
        },
        "test_type": {
          "const": "Breathalyzer"
        },
        "self_reported": {
          "type": "boolean",
          "description": "true when the member reported the result themselves. false for results read from the device."
        },
        "test_notes": {
          "type": [
            "string",
            "null"
          ],
          "description": "Notes on the result. Can be null or left out."
        },
        "test_id": {
          "type": "string",
          "description": "The result's ID. The same ID is sent again if the result changes or is deleted."
        }
      }
    }
  },
  "examples": [
    {
      "event_type": "breathalyzer.result.posted",
      "data": {
        "medical_record_number": "3f2b8c1e-7a4d-4e9b-9c55-0d6a1f2e8b47",
        "plan_name": "Standard Plan",
        "test_date": "2026-01-01T18:45:00.000Z",
        "test_result": "Negative",
        "test_type": "Breathalyzer",
        "self_reported": false,
        "test_notes": "Evening test.",
        "test_id": "665f1c2ab7e4d90012a3f4c3"
      }
    }
  ]
}
