96 lines
3.6 KiB
TypeScript
96 lines
3.6 KiB
TypeScript
/**
|
|
* IncidenteService - Servicio para gestión de incidentes HSE
|
|
*
|
|
* Gestión de incidentes de seguridad con workflow y relaciones.
|
|
* Workflow: abierto -> en_investigacion -> cerrado
|
|
*
|
|
* @module HSE
|
|
*/
|
|
import { Repository } from 'typeorm';
|
|
import { Incidente, TipoIncidente, GravedadIncidente, EstadoIncidente } from '../entities/incidente.entity';
|
|
import { IncidenteInvolucrado, RolInvolucrado } from '../entities/incidente-involucrado.entity';
|
|
import { IncidenteAccion, EstadoAccion } from '../entities/incidente-accion.entity';
|
|
import { ServiceContext, PaginatedResult } from '../../../shared/services/base.service';
|
|
export interface CreateIncidenteDto {
|
|
fechaHora: Date;
|
|
fraccionamientoId: string;
|
|
ubicacionDescripcion?: string;
|
|
tipo: TipoIncidente;
|
|
gravedad: GravedadIncidente;
|
|
descripcion: string;
|
|
causaInmediata?: string;
|
|
causaBasica?: string;
|
|
}
|
|
export interface UpdateIncidenteDto {
|
|
ubicacionDescripcion?: string;
|
|
tipo?: TipoIncidente;
|
|
gravedad?: GravedadIncidente;
|
|
descripcion?: string;
|
|
causaInmediata?: string;
|
|
causaBasica?: string;
|
|
}
|
|
export interface AddInvolucradoDto {
|
|
employeeId: string;
|
|
rol: RolInvolucrado;
|
|
descripcionLesion?: string;
|
|
parteCuerpo?: string;
|
|
diasIncapacidad?: number;
|
|
}
|
|
export interface AddAccionDto {
|
|
descripcion: string;
|
|
tipo: string;
|
|
responsableId?: string;
|
|
fechaCompromiso: Date;
|
|
}
|
|
export interface UpdateAccionDto {
|
|
descripcion?: string;
|
|
responsableId?: string;
|
|
fechaCompromiso?: Date;
|
|
estado?: EstadoAccion;
|
|
evidenciaUrl?: string;
|
|
observaciones?: string;
|
|
}
|
|
export interface IncidenteFilters {
|
|
fraccionamientoId?: string;
|
|
tipo?: TipoIncidente;
|
|
gravedad?: GravedadIncidente;
|
|
estado?: EstadoIncidente;
|
|
dateFrom?: Date;
|
|
dateTo?: Date;
|
|
}
|
|
export interface IncidenteStats {
|
|
total: number;
|
|
porTipo: {
|
|
tipo: string;
|
|
count: number;
|
|
}[];
|
|
porGravedad: {
|
|
gravedad: string;
|
|
count: number;
|
|
}[];
|
|
porEstado: {
|
|
estado: string;
|
|
count: number;
|
|
}[];
|
|
diasSinAccidente: number;
|
|
}
|
|
export declare class IncidenteService {
|
|
private readonly incidenteRepository;
|
|
private readonly involucradoRepository;
|
|
private readonly accionRepository;
|
|
constructor(incidenteRepository: Repository<Incidente>, involucradoRepository: Repository<IncidenteInvolucrado>, accionRepository: Repository<IncidenteAccion>);
|
|
private generateFolio;
|
|
findWithFilters(ctx: ServiceContext, filters?: IncidenteFilters, page?: number, limit?: number): Promise<PaginatedResult<Incidente>>;
|
|
findById(ctx: ServiceContext, id: string): Promise<Incidente | null>;
|
|
findWithDetails(ctx: ServiceContext, id: string): Promise<Incidente | null>;
|
|
create(ctx: ServiceContext, dto: CreateIncidenteDto): Promise<Incidente>;
|
|
update(ctx: ServiceContext, id: string, dto: UpdateIncidenteDto): Promise<Incidente | null>;
|
|
startInvestigation(ctx: ServiceContext, id: string): Promise<Incidente | null>;
|
|
closeIncident(ctx: ServiceContext, id: string): Promise<Incidente | null>;
|
|
addInvolucrado(ctx: ServiceContext, incidenteId: string, dto: AddInvolucradoDto): Promise<IncidenteInvolucrado>;
|
|
removeInvolucrado(ctx: ServiceContext, incidenteId: string, involucradoId: string): Promise<boolean>;
|
|
addAccion(ctx: ServiceContext, incidenteId: string, dto: AddAccionDto): Promise<IncidenteAccion>;
|
|
updateAccion(ctx: ServiceContext, incidenteId: string, accionId: string, dto: UpdateAccionDto): Promise<IncidenteAccion | null>;
|
|
getStats(ctx: ServiceContext, fraccionamientoId?: string): Promise<IncidenteStats>;
|
|
}
|
|
//# sourceMappingURL=incidente.service.d.ts.map
|