Skip to main content

AI Patient Readiness & Eligibility API

Clinical Workflow Scoring Document Completeness Contraindication Rules Routing Flags Provider-Specific Requirements Explainable Decisions Audit-Ready
Operated by Spyface Tech Company, LLC • 30 N Gould St Ste N, Sheridan, WY 82801 USA • Support: hello@spyface.com

Purpose

The AI Patient Readiness & Eligibility API is a clinical workflow scoring layer for medical travel and cross-provider intake. It converts messy intake + documents into structured readiness outputs: completeness, eligibility routing, required next steps, and provider-specific checklists.

It’s designed to reduce wasted quote cycles, prevent incomplete cases from reaching surgeons, and standardize pre-consult clearance across a global network.

What you get (always measurable)

  • Readiness Score (0–1): how complete the case is for review/quote/teleconsult
  • Eligibility Status: ELIGIBLE / REQUIRES_REVIEW / NOT_READY
  • Missing Items: specific documents/data points with priority and rationale
  • Routing Flags: “teleconsult required”, “lab re-take recommended”, “identity step-up”, etc.
  • Contraindication Alerts: rules-based alerts (non-diagnostic) for provider escalation
  • Explainability: confidence, reasons[], trace_id

Clinical Safety Notice

Outputs are operational workflow signals and require professional review. The API does not diagnose, does not prescribe, and does not replace a licensed clinician. Contraindication alerts are based on explicit rules and data quality checks to support routing, not medical decision-making.

1) Overview

“Eligibility” in medical tourism usually fails because intake is incomplete, documents are unstructured, and each provider has different pre-consult requirements. This API standardizes the process into a three-layer gating system:

Layer A — Data Integrity

  • Required fields present (procedure, timeline, travel constraints)
  • Identity linkage and de-dup checks (optional)
  • Document types + freshness windows validated
  • Document quality heuristics (pages, readability, language, corruption)

Layer B — Clinical Workflow Readiness

  • Case is complete enough for a surgeon/clinic to review
  • Pre-op items are flagged as required vs recommended
  • Teleconsult gating is applied where appropriate
  • Contraindication “alerts” trigger escalation workflows

Layer C — Provider-Specific Requirements

The same patient can be “ready” for Provider A but “not ready” for Provider B due to differing policies. The API supports provider templates that define required documents, validity windows, and escalation rules.

2) Inputs: Intake + Documents

You can submit structured intake directly, or let the API derive fields from documents using document intelligence. Inputs are designed to be minimal, but extensible.

InputDescriptionExamples
procedure_code Normalized procedure identifier used for templates and rules. PROC_RHINOPLASTY, PROC_DENTAL_IMPLANT
timeline Preferred and latest possible start dates. preferred_start, latest_start
constraints Budget band, destination prefs, language, travel limitations. budget_max_usd, destination[]
documents[] Medical docs referenced by ID + hash (or upload workflow). LAB_REPORT, IMAGING_SUMMARY, MED_HISTORY
provider_context Optional: evaluate against provider templates/rules. provider_id, offer_id

3) Outputs: Scores, Status, Flags

Eligibility status

  • ELIGIBLE — case is ready for review/quote/booking step
  • REQUIRES_REVIEW — case can proceed, but triggers escalation flags
  • NOT_READY — blocking missing items prevent safe progression

Flag categories

  • DATA_QUALITY: missing/invalid documents, conflicting fields
  • WORKFLOW: teleconsult required, pre-op checklist required
  • SAFETY: contraindication alerts that require clinician review
  • POLICY: consent scope missing, retention restrictions

4) Scoring Model (Clinical Workflow Grade)

The readiness score is computed as a weighted composition of workflow-critical dimensions. You can customize weights per procedure family and per tenant.

DimensionWhat it measuresTypical weight
Completeness Required intake + required doc types present. 35%
Freshness Documents within validity windows (e.g., labs within X days). 20%
Coherence No conflicting or inconsistent inputs (procedure vs docs vs constraints). 15%
Provider Fit Meets provider-specific pre-consult rules (optional context). 15%
Operational Risk Signals that increase coordination failure (identity, unreachable, policy gaps). 15%

Explainability contract

Every score must be explainable. The API returns: reasons[] with code, detail, and impact. This allows deterministic UI and internal SOP automation.

5) Provider Rules & Contraindication Logic

Provider rules are explicit configuration—this is how you turn “clinic requirements” into machine-checkable gates. Rules are grouped by procedure and can include:

Examples of rule types

  • Required docs: “Lab report required”
  • Freshness window: “CBC within 30 days”
  • Conditional docs: “If prior surgery → operative note requested”
  • Routing: “Teleconsult required for revision cases”
  • Escalation: “If red-flag keyword appears → clinician review”

Contraindication alerts (non-diagnostic)

Contraindication outputs are alerts that a provider’s workflow requires a licensed review. The API surfaces what triggered it and which rule fired.

  • Rule fired: RULE_BP_OUT_OF_RANGE
  • Evidence: doc snippet reference / extracted value reference
  • Action: CLINICIAN_REVIEW_REQUIRED

6) Checklists & Next-Best-Actions

Instead of telling users “missing docs,” the API returns a sequenced checklist that can drive your product UI and internal coordinator SOPs.

Checklist itemFieldsHow you use it
Document request type, priority, why, due_by Create a task, send message to patient
Teleconsult gating required, recommended_slots[] Force scheduling before quote acceptance
Pre-op step step, dependency, owner_role Generate timeline tasks for coordinator/clinic

7) Endpoints

MethodEndpointPurpose
POST /v1/medical/ai/readiness Compute readiness score + missing items + next actions
POST /v1/medical/ai/eligibility Eligibility status + routing flags + contraindication alerts
POST /v1/medical/ai/provider-check Evaluate readiness against a specific provider/offer template
POST /v1/medical/ai/document-intel Extract/normalize fields from documents (optional)
GET /v1/medical/cases/{case_id}/eligibility Fetch latest eligibility snapshot

8) Webhooks

Use webhooks to drive automation (task creation, email/SMS triggers, clinic escalation). All webhooks should be verified by signature.

EventWhen firedPayload
ai.readiness.completed Readiness scoring finished case_id, readiness_score, trace_id
ai.eligibility.completed Eligibility finished status, flags[], alerts[]
ai.provider_check.completed Provider-specific evaluation finished provider_id, blockers[], checklist[]

9) Security, Consent & Audit

Consent gating

  • Every call includes a policy object (scope + consent state)
  • Cross-provider sharing requires explicit consent state where applicable
  • Field-level redaction for restricted roles

Example: policy: { scope: “MEDICAL”, consent: “GRANTED” }

Audit guarantees

  • All decisions return trace_id
  • Decision snapshots can be attached to cases
  • Every rules engine hit can be recorded with versioned rule IDs

10) Errors & Idempotency

Idempotency

Send Idempotency-Key for all scoring requests to safely retry.

Error format

{
  "error":{
    "code":"VALIDATION_ERROR",
    "message":"Missing required field: intake.procedure_code",
    "details":[{"path":"intake.procedure_code","reason":"REQUIRED"}],
    "request_id":"req_31b2"
  }
}

11) Code Examples

cURL — Readiness scoring


curl -sS https://api.spyface.com/v1/medical/ai/readiness \
  -H "Authorization: Bearer $SPYFACE_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: readiness-case_10021" \
  -d '{
    "tenant_id":"t_global_med",
    "case_id":"case_10021",
    "policy":{"scope":"MEDICAL","consent":"GRANTED"},
    "intake":{
      "procedure_code":"PROC_RHINOPLASTY",
      "timeline":{"preferred_start":"2026-03-10","latest_start":"2026-04-15"},
      "constraints":{"budget_max_usd":5200,"language":"EN","destination":["TR","MX","TH"]}
    },
    "documents":[
      {"doc_id":"doc_aa1","type":"LAB_REPORT","hash":"sha256:...","language":"TR"},
      {"doc_id":"doc_aa2","type":"MEDICAL_HISTORY","hash":"sha256:...","language":"EN"}
    ]
  }'

Sample response — Clinical workflow-grade output

{
  "case_id":"case_10021",
  "readiness":{
    "readiness_score":0.74,
    "status":"NOT_READY",
    "confidence":0.90,
    "reasons":[
      {"code":"MISSING_DOC","detail":"Imaging summary not provided", "impact":"BLOCKING"},
      {"code":"DOC_FRESHNESS_OK","detail":"Lab report within expected range", "impact":"POSITIVE"}
    ],
    "missing_items":[
      {
        "type":"IMAGING_SUMMARY",
        "priority":"MEDIUM",
        "why":"Improves surgeon review quality and reduces back-and-forth",
        "blocking":true
      }
    ],
    "routing_flags":[
      {"flag":"TELECONSULT_RECOMMENDED","severity":"LOW","why":"Revision risk unknown from intake"}
    ],
    "checklist":[
      {"step":"REQUEST_DOCUMENT","target":"IMAGING_SUMMARY","owner_role":"COORDINATOR"},
      {"step":"SCHEDULE_TELECONSULT","owner_role":"COORDINATOR"}
    ],
    "trace_id":"trace_ready_22c9a"
  }
}

Python — Auto-create tasks from checklist


import os, requests, json

BASE = "https://api.spyface.com"
KEY  = os.environ["SPYFACE_API_KEY"]

def post(path, body, idem):
  return requests.post(
    f"{BASE}{path}",
    headers={
      "Authorization": f"Bearer {KEY}",
      "Content-Type": "application/json",
      "Idempotency-Key": idem
    },
    data=json.dumps(body),
    timeout=30
  ).json()

tenant_id = "t_global_med"
case_id   = "case_10021"

readiness = post("/v1/medical/ai/readiness", {
  "tenant_id": tenant_id,
  "case_id": case_id,
  "policy":{"scope":"MEDICAL","consent":"GRANTED"},
  "intake":{
    "procedure_code":"PROC_RHINOPLASTY",
    "timeline":{"preferred_start":"2026-03-10","latest_start":"2026-04-15"},
    "constraints":{"budget_max_usd":5200,"language":"EN","destination":["TR","MX","TH"]}
  },
  "documents":[
    {"doc_id":"doc_aa1","type":"LAB_REPORT","hash":"sha256:...","language":"TR"},
    {"doc_id":"doc_aa2","type":"MEDICAL_HISTORY","hash":"sha256:...","language":"EN"}
  ]
}, f"readiness-{case_id}")

chk = readiness.get("readiness", {}).get("checklist", [])
trace = readiness.get("readiness", {}).get("trace_id", "n/a")

for i, item in enumerate(chk):
  title = f"{item['step']}: {item.get('target','')}".strip()
  post(f"/v1/medical/cases/{case_id}/tasks", {
    "tenant_id": tenant_id,
    "title": title,
    "priority": "MEDIUM",
    "owner_role": item.get("owner_role","COORDINATOR"),
    "state": "OPEN",
    "metadata": {"trace_id": trace, "source": "ai_readiness"}
  }, f"task-{case_id}-{i}")

print("Created tasks from checklist. Trace:", trace)

Implementation Support

Need procedure templates, provider rule sets, and readiness thresholds tuned for your network? Contact: hello@spyface.com