Skip to main content

Overview

The Client model represents a tattoo studio client with comprehensive personal information, health records, emergency contacts, consent tracking, and preferences.

Model Definition

from sqlalchemy import Column, Integer, String, Text, Date, DateTime, Boolean, ForeignKey
from sqlalchemy.orm import relationship

class Client(Base):
    __tablename__ = "clients"

Fields

Primary Key

id
Integer
required
Unique identifier for the client

Basic Information

name
String(120)
required
Client’s full name
phone
String(40)
Contact phone number
email
String(120)
Email address
notes
Text
General notes about the client
is_active
Boolean
default:"true"
Whether the client is active in the system
created_at
DateTime
default:"CURRENT_TIMESTAMP"
Timestamp when the client record was created

Personal Details

instagram
Text
Client’s Instagram handle
city
Text
City of residence
state
Text
State or province
gender
Text
Client’s gender
birthdate
Date
Date of birth
Consent to receive information
Consent for image usage
Consent for data processing

Emergency Contact

emergency_name
Text
Emergency contact’s full name
emergency_relation
Text
Relationship to the emergency contact
emergency_phone
Text
Emergency contact’s phone number

Preferences

preferred_artist_id
Integer
Foreign key reference to the client’s preferred artist (artists.id)

Health Information

health_allergies
Boolean
Client has allergies
health_diabetes
Boolean
Client has diabetes
health_coagulation
Boolean
Client has coagulation issues
health_epilepsy
Boolean
Client has epilepsy
health_cardiac
Boolean
Client has cardiac conditions
health_anticoagulants
Boolean
Client takes anticoagulants
health_preg_lact
Boolean
Client is pregnant or lactating
health_substances
Boolean
Client uses substances that may affect tattooing
health_derm
Boolean
Client has dermatological conditions
health_obs
Text
Additional health observations or notes

Relationships

preferred_artist
Artist
The Artist object for the client’s preferred artistForeign Key: preferred_artist_idartists.idBackref: preferred_clients on Artist model
sessions
List[TattooSession]
List of all tattoo sessions for this clientRelationship: One-to-Many with TattooSessionCascade: all, delete-orphan - sessions are deleted when client is deletedBack Populates: client on TattooSession model

Database Schema

CREATE TABLE clients (
    id INTEGER PRIMARY KEY,
    name VARCHAR(120) NOT NULL,
    phone VARCHAR(40),
    email VARCHAR(120),
    notes TEXT,
    is_active BOOLEAN NOT NULL DEFAULT 1,
    created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    
    -- Personal details
    instagram TEXT,
    city TEXT,
    state TEXT,
    gender TEXT,
    birthdate DATE,
    
    -- Consent
    consent_info BOOLEAN,
    consent_image BOOLEAN,
    consent_data BOOLEAN,
    
    -- Emergency contact
    emergency_name TEXT,
    emergency_relation TEXT,
    emergency_phone TEXT,
    
    -- Preferences
    preferred_artist_id INTEGER,
    FOREIGN KEY (preferred_artist_id) REFERENCES artists(id),
    
    -- Health information
    health_allergies BOOLEAN,
    health_diabetes BOOLEAN,
    health_coagulation BOOLEAN,
    health_epilepsy BOOLEAN,
    health_cardiac BOOLEAN,
    health_anticoagulants BOOLEAN,
    health_preg_lact BOOLEAN,
    health_substances BOOLEAN,
    health_derm BOOLEAN,
    health_obs TEXT
);

Usage Example

from data.models.client import Client
from sqlalchemy.orm import Session

# Create a new client
new_client = Client(
    name="John Doe",
    phone="555-0123",
    email="[email protected]",
    city="New York",
    state="NY",
    birthdate="1990-05-15",
    consent_info=True,
    consent_image=True,
    consent_data=True,
    health_allergies=False,
    health_diabetes=False,
    preferred_artist_id=1
)

db.add(new_client)
db.commit()

# Query client with sessions
client = db.query(Client).filter(Client.id == 1).first()
print(f"Client: {client.name}")
print(f"Total sessions: {len(client.sessions)}")
print(f"Preferred artist: {client.preferred_artist.name}")

Notes

  • The is_active field allows soft-deletion of client records
  • All health fields are optional booleans for quick screening
  • The health_obs field provides space for detailed health notes
  • Emergency contact information is stored separately for quick access
  • The relationship with sessions includes cascade delete to maintain referential integrity
  • Location in codebase: data/models/client.py:11

Build docs developers (and LLMs) love