Skip to content

Session 26 Migration Summary

Date: 2026-03-31 Migration ID: f8a9b1c2d3e4 Branch: feat/doctors-schema

New Tables

  • doctors — 8 seed rows, 8 doctors across 6 providers
  • doctor_procedures — 8 seed rows, 1 procedure per doctor

New Columns

  • providers.language_services — JSONB, interpreter/coordinator/document language data (6 providers updated)
  • provider_procedures.lead_surgeon_id — UUID reference to lead doctor (1 row linked: Dr. Patel → Apollo TKR)

New Files

  • app/models/doctor.py — Doctor SQLAlchemy model
  • app/models/doctor_procedure.py — DoctorProcedure SQLAlchemy model
  • app/schemas/doctor.py — Pydantic schemas for CRUD + search + match results
  • app/services/doctor_service.py — CRUD + search service
  • app/services/data_completeness.py — 7-category weighted completeness calculator
  • app/services/language_concordance.py — 6-tier language scoring
  • app/services/weight_redistribution.py — Proportional weight redistribution
  • app/routers/doctors.py — 8 API endpoints under /api/v1/doctors/
  • app/seed_doctors.py — Seed script for 8 doctors + language services + Neo4j
  • tests/test_doctors.py — 15 tests

New API Endpoints

  • GET /api/v1/doctors/ — List doctors (paginated)
  • GET /api/v1/doctors/search — Search by specialty, procedure, language, gender
  • GET /api/v1/doctors/{id} — Get doctor by ID
  • GET /api/v1/doctors/slug/{slug} — Get doctor by slug
  • POST /api/v1/doctors/ — Create doctor (admin)
  • PATCH /api/v1/doctors/{id} — Update doctor (admin)
  • GET /api/v1/doctors/{id}/procedures — List doctor's procedures
  • POST /api/v1/doctors/{id}/procedures — Add procedure to doctor (admin)
  • GET /api/v1/providers/{id}/doctors — List doctors at a provider

Neo4j Changes

  • New node type: Doctor (8 nodes)
  • New node type: Specialty, Language
  • New relationships: AFFILIATED_WITH, PERFORMS, SPECIALIZES_IN, SPEAKS

Matching Engine Changes

  • ScoredProvider now includes doctor and language_support fields
  • Doctor-level scoring behind DOCTORS_IN_MATCHING feature flag
  • Match confidence = provider_score × data_completeness_score

Feature Flags

  • DOCTORS_IN_MATCHING — When ON, match results include doctor data