class PatientSummaryModel { final int id; final String nombre; final String apellido; final String cedula; final String telefono; final String fecReg; final String fecProxCita; final String seguro; final String motCons; final String estadoEspera; const PatientSummaryModel({ required this.id, required this.nombre, required this.apellido, required this.cedula, required this.telefono, required this.fecReg, required this.fecProxCita, required this.seguro, required this.motCons, this.estadoEspera = 'no_presente', }); String get fullName => '$nombre $apellido'.trim(); bool get isNoPresente => estadoEspera == 'no_presente' || estadoEspera.isEmpty; bool get isEnEspera => estadoEspera == 'en_espera'; bool get isEnConsulta => estadoEspera == 'en_consulta'; bool get isAtendido => estadoEspera == 'atendido'; String get estadoEsperaLabel { switch (estadoEspera) { case 'en_espera': return 'En Sala de Espera'; case 'en_consulta': return 'En Consulta'; case 'atendido': return 'Atendido'; case 'no_presente': default: return 'No Presente'; } } PatientSummaryModel copyWith({ int? id, String? nombre, String? apellido, String? cedula, String? telefono, String? fecReg, String? fecProxCita, String? seguro, String? motCons, String? estadoEspera, }) { return PatientSummaryModel( id: id ?? this.id, nombre: nombre ?? this.nombre, apellido: apellido ?? this.apellido, cedula: cedula ?? this.cedula, telefono: telefono ?? this.telefono, fecReg: fecReg ?? this.fecReg, fecProxCita: fecProxCita ?? this.fecProxCita, seguro: seguro ?? this.seguro, motCons: motCons ?? this.motCons, estadoEspera: estadoEspera ?? this.estadoEspera, ); } factory PatientSummaryModel.fromJson(Map json) { int parsedId = 0; if (json['id'] is int) { parsedId = json['id'] as int; } else if (json['id'] != null) { parsedId = int.tryParse(json['id'].toString()) ?? 0; } return PatientSummaryModel( id: parsedId, nombre: json['nombre']?.toString() ?? '', apellido: json['apellido']?.toString() ?? '', cedula: json['cedula']?.toString() ?? '', telefono: json['telefono']?.toString() ?? '', fecReg: json['fec_reg']?.toString() ?? '', fecProxCita: json['fec_proxcita']?.toString() ?? '', seguro: json['seguro']?.toString() ?? '', motCons: json['mot_cons']?.toString() ?? '', estadoEspera: json['estado_espera']?.toString() ?? 'no_presente', ); } Map toJson() { return { 'id': id, 'nombre': nombre, 'apellido': apellido, 'cedula': cedula, 'telefono': telefono, 'fec_reg': fecReg, 'fec_proxcita': fecProxCita, 'seguro': seguro, 'mot_cons': motCons, 'estado_espera': estadoEspera, }; } }