{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/finchnode-com/json-schema/finchnode-com-tefca-session-schema.json",
  "title": "TefcaSession",
  "x-generated": "2026-10-30",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/_original/finchnode-com-api-openapi.yml#/components/schemas/TefcaSession",
  "type": "object",
  "required": [
    "id",
    "object",
    "mode",
    "synthetic",
    "environment",
    "categories",
    "status",
    "expiresAt",
    "documents",
    "results",
    "failures"
  ],
  "properties": {
    "mode": {
      "type": "string",
      "const": "simulation"
    },
    "synthetic": {
      "type": "boolean",
      "const": true
    },
    "environment": {
      "type": "string",
      "const": "sandbox"
    },
    "categories": {
      "type": "array",
      "minItems": 1,
      "uniqueItems": true,
      "items": {
        "type": "string",
        "enum": [
          "demographics",
          "medications",
          "conditions",
          "labs",
          "vitals",
          "allergies",
          "immunizations",
          "encounters"
        ]
      }
    },
    "id": {
      "type": "string"
    },
    "object": {
      "type": "string",
      "const": "tefca_session"
    },
    "status": {
      "type": "string",
      "enum": [
        "consented",
        "discovered",
        "complete",
        "partial",
        "failed",
        "no-match",
        "revoked"
      ]
    },
    "patientId": {
      "type": "string"
    },
    "scenario": {
      "type": "string",
      "enum": [
        "matched",
        "partial",
        "no-match",
        "unavailable"
      ]
    },
    "createdAt": {
      "type": "string",
      "format": "date-time"
    },
    "expiresAt": {
      "type": "string",
      "format": "date-time"
    },
    "matches": {
      "type": "array",
      "description": "The synthetic patient match from discovery; empty before discovery and for no-match.",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "patientId": {
            "type": "string"
          },
          "source": {
            "type": "string"
          },
          "synthetic": {
            "type": "boolean",
            "const": true
          }
        }
      }
    },
    "documents": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/TefcaDocument"
      }
    },
    "results": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "bundle": {
            "type": "object",
            "description": "FHIR R4 collection for this selected record group."
          }
        }
      }
    },
    "failures": {
      "type": "array",
      "items": {
        "type": "object"
      }
    },
    "consent": {
      "type": "object"
    }
  },
  "$defs": {
    "TefcaDocument": {
      "type": "object",
      "required": [
        "id",
        "title",
        "resourceType",
        "resourceCount",
        "contentType",
        "source"
      ],
      "properties": {
        "id": {
          "type": "string"
        },
        "title": {
          "type": "string"
        },
        "resourceType": {
          "type": "string"
        },
        "resourceCount": {
          "type": "integer"
        },
        "contentType": {
          "type": "string",
          "const": "application/fhir+json"
        },
        "source": {
          "type": "string"
        }
      }
    }
  }
}