{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://developers.youareaccountable.com/schemas/toxicology.result.posted.json",
  "title": "ToxicologyResultPosted",
  "description": "A drug test 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": "toxicology.result.posted"
    },
    "data": {
      "type": "object",
      "required": [
        "medical_record_number",
        "test_date",
        "test_type",
        "test_result",
        "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": "The calendar day of the test in UTC. The time is always 00:00:00.000Z. Read the date part only."
        },
        "test_type": {
          "type": "string",
          "description": "The kind of test. New test types can be added, so do not reject a value you don't recognize.",
          "examples": [
            "10 Panel Instant",
            "10 Panel Instant w/ THC",
            "14 Panel Instant",
            "Cotinine",
            "Saliva Lab Confirmation",
            "Urine Analysis",
            "Urine Instant"
          ]
        },
        "test_result": {
          "type": "string",
          "description": "The overall result. Usually Positive, Negative or Missed. Lab tests can also be Inconclusive.",
          "examples": [
            "Positive",
            "Negative",
            "Missed",
            "Inconclusive"
          ]
        },
        "self_reported": {
          "type": "boolean",
          "description": "true when the member reported the result themselves."
        },
        "test_notes": {
          "type": [
            "string",
            "null"
          ],
          "description": "Notes on the result. Can be null or left out."
        },
        "kit_id": {
          "type": [
            "string",
            "null"
          ],
          "description": "The test kit ID. 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."
        },
        "lab_results": {
          "type": "array",
          "description": "The lab's per-analyte panel. Sent only for lab tests that have a panel. Left out on every other result.",
          "items": {
            "type": "object",
            "required": [
              "code",
              "name",
              "result",
              "units",
              "cutoff"
            ],
            "properties": {
              "code": {
                "type": "string",
                "description": "The lab's analyte code, such as LCMSAMPH."
              },
              "name": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "The analyte name as the lab reports it."
              },
              "result": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "The lab's result text. Values vary by lab. Treat it as display text."
              },
              "units": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "Units as reported by the lab, such as ng/mL."
              },
              "cutoff": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "The cutoff as reported by the lab."
              }
            }
          }
        }
      }
    }
  },
  "examples": [
    {
      "event_type": "toxicology.result.posted",
      "data": {
        "medical_record_number": "3f2b8c1e-7a4d-4e9b-9c55-0d6a1f2e8b47",
        "plan_name": "Standard Plan",
        "test_date": "2026-01-01T00:00:00.000Z",
        "test_type": "10 Panel Instant",
        "test_result": "Negative",
        "self_reported": false,
        "test_id": "665f1c2ab7e4d90012a3f4c2"
      }
    },
    {
      "event_type": "toxicology.result.posted",
      "data": {
        "medical_record_number": "3f2b8c1e-7a4d-4e9b-9c55-0d6a1f2e8b47",
        "plan_name": "Standard Plan",
        "test_date": "2026-01-01T00:00:00.000Z",
        "test_type": "Saliva Lab Confirmation",
        "test_result": "Positive",
        "self_reported": false,
        "test_notes": "Confirmed by lab.",
        "kit_id": "KIT-000123",
        "test_id": "665f1c2ab7e4d90012a3f4c2",
        "lab_results": [
          {
            "code": "LCMSAMPH",
            "name": "Amphetamine",
            "result": "Not Detected",
            "units": "ng/mL",
            "cutoff": "2"
          },
          {
            "code": "LCMSCOTN",
            "name": "Cotinine",
            "result": "444.29",
            "units": "ng/mL",
            "cutoff": "2"
          },
          {
            "code": "LCMSFENT",
            "name": "Fentanyl",
            "result": "Not Detected",
            "units": "ng/mL",
            "cutoff": "0.25"
          }
        ]
      }
    }
  ]
}
