Templates/Health

Telehealth database schema

Video consultations between patients and clinicians, messages and payments.

6 tables, 5 relationships

Opens as a new diagram you can change. Free.

Tables

patients

  • iduuid not null
  • full_nametext not null
  • emailtext not null
  • created_attimestamptz not null

clinicians

  • iduuid not null
  • full_nametext not null
  • specialtytext not null
  • licence_numbertext not null
  • created_attimestamptz not null

consultations

  • iduuid not null
  • patient_id> patientsuuid not null
  • clinician_id> cliniciansuuid not null
  • scheduled_attimestamptz not null
  • video_room_urltext
  • statustext not null
  • created_attimestamptz not null

consultation_messages

  • iduuid not null
  • consultation_id> consultationsuuid not null
  • from_patientboolean not null
  • bodytext not null
  • created_attimestamptz not null

consultation_notes

  • iduuid not null
  • consultation_id> consultationsuuid not null
  • summarytext not null
  • created_attimestamptz not null

consultation_payments

  • iduuid not null
  • consultation_id> consultationsuuid not null
  • amountnumeric(8,2) not null
  • paid_attimestamptz
  • created_attimestamptz not null

As PostgreSQL

The same diagram exports to MySQL, MariaDB, SQLite, SQL Server and Oracle, and to Prisma, Drizzle, SQLAlchemy and Convex models.

CREATE TABLE "clinicians" (
  "id" UUID DEFAULT gen_random_uuid() NOT NULL,
  "full_name" TEXT NOT NULL,
  "specialty" TEXT NOT NULL,
  "licence_number" TEXT NOT NULL,
  "created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
  PRIMARY KEY ("id")
);

CREATE TABLE "consultation_messages" (
  "id" UUID DEFAULT gen_random_uuid() NOT NULL,
  "consultation_id" UUID NOT NULL,
  "from_patient" BOOLEAN NOT NULL,
  "body" TEXT NOT NULL,
  "created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
  PRIMARY KEY ("id")
);

CREATE TABLE "consultation_notes" (
  "id" UUID DEFAULT gen_random_uuid() NOT NULL,
  "consultation_id" UUID NOT NULL UNIQUE,
  "summary" TEXT NOT NULL,
  "created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
  PRIMARY KEY ("id")
);

CREATE TABLE "consultation_payments" (
  "id" UUID DEFAULT gen_random_uuid() NOT NULL,
  "consultation_id" UUID NOT NULL,
  "amount" NUMERIC(8,2) NOT NULL,
  "paid_at" TIMESTAMPTZ,
  "created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
  PRIMARY KEY ("id")
);

CREATE TABLE "consultations" (
  "id" UUID DEFAULT gen_random_uuid() NOT NULL,
  "patient_id" UUID NOT NULL,
  "clinician_id" UUID NOT NULL,
  "scheduled_at" TIMESTAMPTZ NOT NULL,
  "video_room_url" TEXT,
  "status" TEXT DEFAULT 'scheduled' NOT NULL,
  "created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
  PRIMARY KEY ("id")
);

CREATE TABLE "patients" (
  "id" UUID DEFAULT gen_random_uuid() NOT NULL,
  "full_name" TEXT NOT NULL,
  "email" TEXT NOT NULL UNIQUE,
  "created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
  PRIMARY KEY ("id")
);

ALTER TABLE "consultations" ADD CONSTRAINT "fk_consultations_patient_id" FOREIGN KEY ("patient_id") REFERENCES "patients" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;

ALTER TABLE "consultations" ADD CONSTRAINT "fk_consultations_clinician_id" FOREIGN KEY ("clinician_id") REFERENCES "clinicians" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;

ALTER TABLE "consultation_messages" ADD CONSTRAINT "fk_consultation_messages_consultation_id" FOREIGN KEY ("consultation_id") REFERENCES "consultations" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;

ALTER TABLE "consultation_notes" ADD CONSTRAINT "fk_consultation_notes_consultation_id" FOREIGN KEY ("consultation_id") REFERENCES "consultations" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;

ALTER TABLE "consultation_payments" ADD CONSTRAINT "fk_consultation_payments_consultation_id" FOREIGN KEY ("consultation_id") REFERENCES "consultations" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;

More Health templates

Start with one diagram, free

One diagram with two branches, no card needed. Upgrade when your team needs more.