erp-clinicas-backend-v2/src/modules/consultations/entities/consultation.entity.ts
rckrdmrd f8aacbd316 Migración desde erp-clinicas/backend - Estándar multi-repo v2
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 08:11:57 -06:00

81 lines
2.0 KiB
TypeScript

import {
Entity,
PrimaryGeneratedColumn,
Column,
CreateDateColumn,
UpdateDateColumn,
Index,
OneToMany,
} from 'typeorm';
export type ConsultationStatus = 'in_progress' | 'completed' | 'cancelled';
export interface VitalSigns {
weight_kg?: number;
height_cm?: number;
temperature?: number;
blood_pressure?: string; // "120/80"
heart_rate?: number;
respiratory_rate?: number;
oxygen_saturation?: number;
}
@Entity({ name: 'consultations', schema: 'clinica' })
export class Consultation {
@PrimaryGeneratedColumn('uuid')
id: string;
@Index()
@Column({ name: 'tenant_id', type: 'uuid' })
tenantId: string;
// Relaciones
@Index()
@Column({ name: 'patient_id', type: 'uuid' })
patientId: string;
@Index()
@Column({ name: 'doctor_id', type: 'uuid' })
doctorId: string;
@Column({ name: 'appointment_id', type: 'uuid', nullable: true })
appointmentId?: string;
// Tiempo
@Column({ name: 'started_at', type: 'timestamptz', default: () => 'NOW()' })
startedAt: Date;
@Column({ name: 'ended_at', type: 'timestamptz', nullable: true })
endedAt?: Date;
// Contenido clinico
@Column({ name: 'chief_complaint', type: 'text', nullable: true })
chiefComplaint?: string;
@Column({ name: 'present_illness', type: 'text', nullable: true })
presentIllness?: string;
@Column({ name: 'physical_examination', type: 'text', nullable: true })
physicalExamination?: string;
@Column({ type: 'text', nullable: true })
assessment?: string;
@Column({ type: 'text', nullable: true })
plan?: string;
// Signos vitales (snapshot)
@Column({ name: 'vital_signs', type: 'jsonb', nullable: true })
vitalSigns?: VitalSigns;
// Estado
@Column({ type: 'enum', enum: ['in_progress', 'completed', 'cancelled'], default: 'in_progress' })
status: ConsultationStatus;
@CreateDateColumn({ name: 'created_at', type: 'timestamptz' })
createdAt: Date;
@UpdateDateColumn({ name: 'updated_at', type: 'timestamptz' })
updatedAt: Date;
}