176 lines
5.4 KiB
Dart
176 lines
5.4 KiB
Dart
class PatientModel {
|
|||
|
|
final int? id;
|
||
|
|
final String nombre;
|
||
|
|
final String apellido;
|
||
|
|
final String telefono;
|
||
|
|
final String direccion;
|
||
|
|
final String cedula;
|
||
|
|
final String ocupacion;
|
||
|
|
final String edad;
|
||
|
|
final String fecUltcon;
|
||
|
|
final String fecReg;
|
||
|
|
final String sexo;
|
||
|
|
final String seguro;
|
||
|
|
final String estCivil;
|
||
|
|
final String motCons;
|
||
|
|
final String hisEnfAct;
|
||
|
|
final String datPadre;
|
||
|
|
final String datEsp;
|
||
|
|
final String datHijos;
|
||
|
|
final String datOtrosnp;
|
||
|
|
final String datAlerg;
|
||
|
|
final String datTran;
|
||
|
|
final String datOtrosp;
|
||
|
|
final String metDiagnRad;
|
||
|
|
final String datLab;
|
||
|
|
final String diagnDesc;
|
||
|
|
final String diagnDef;
|
||
|
|
final String fecProxcita;
|
||
|
|
final String tratamiento;
|
||
|
|
final String datHer;
|
||
|
|
final String datMad;
|
||
|
|
final String datNi;
|
||
|
|
final String datAdo;
|
||
|
|
final String datAdu;
|
||
|
|
final String datAc;
|
||
|
|
final String datCir;
|
||
|
|
final String datJuv;
|
||
|
|
final String estadoEspera;
|
||
|
|
|
||
|
|
const PatientModel({
|
||
|
|
this.id,
|
||
|
|
this.nombre = '',
|
||
|
|
this.apellido = '',
|
||
|
|
this.telefono = '',
|
||
|
|
this.direccion = '',
|
||
|
|
this.cedula = '',
|
||
|
|
this.ocupacion = '',
|
||
|
|
this.edad = '',
|
||
|
|
this.fecUltcon = '',
|
||
|
|
this.fecReg = '',
|
||
|
|
this.sexo = 'Masculino',
|
||
|
|
this.seguro = 'Sí',
|
||
|
|
this.estCivil = 'Soltero',
|
||
|
|
this.motCons = '',
|
||
|
|
this.hisEnfAct = '',
|
||
|
|
this.datPadre = '',
|
||
|
|
this.datEsp = '',
|
||
|
|
this.datHijos = '',
|
||
|
|
this.datOtrosnp = '',
|
||
|
|
this.datAlerg = '',
|
||
|
|
this.datTran = '',
|
||
|
|
this.datOtrosp = '',
|
||
|
|
this.metDiagnRad = '',
|
||
|
|
this.datLab = '',
|
||
|
|
this.diagnDesc = '',
|
||
|
|
this.diagnDef = '',
|
||
|
|
this.fecProxcita = '',
|
||
|
|
this.tratamiento = '',
|
||
|
|
this.datHer = '',
|
||
|
|
this.datMad = '',
|
||
|
|
this.datNi = '',
|
||
|
|
this.datAdo = '',
|
||
|
|
this.datAdu = '',
|
||
|
|
this.datAc = '',
|
||
|
|
this.datCir = '',
|
||
|
|
this.datJuv = '',
|
||
|
|
this.estadoEspera = 'no_presente',
|
||
|
|
});
|
||
|
|
|
||
|
|
String get fullName => '$nombre $apellido'.trim();
|
||
|
|
|
||
|
|
factory PatientModel.fromJson(Map<String, dynamic> json) {
|
||
|
|
int? parsedId;
|
||
|
|
if (json['id'] is int) {
|
||
|
|
parsedId = json['id'] as int;
|
||
|
|
} else if (json['id'] != null) {
|
||
|
|
parsedId = int.tryParse(json['id'].toString());
|
||
|
|
}
|
||
|
|
|
||
|
|
return PatientModel(
|
||
|
|
id: parsedId,
|
||
|
|
nombre: json['nombre']?.toString().trim() ?? '',
|
||
|
|
apellido: json['apellido']?.toString().trim() ?? '',
|
||
|
|
telefono: json['telefono']?.toString().trim() ?? '',
|
||
|
|
direccion: json['direccion']?.toString().trim() ?? '',
|
||
|
|
cedula: json['cedula']?.toString().trim() ?? '',
|
||
|
|
ocupacion: json['ocupacion']?.toString().trim() ?? '',
|
||
|
|
edad: json['edad']?.toString().trim() ?? '',
|
||
|
|
fecUltcon: json['fec_ultcon']?.toString().trim() ?? '',
|
||
|
|
fecReg: json['fec_reg']?.toString().trim() ?? '',
|
||
|
|
sexo: json['sexo']?.toString().trim() ?? 'Masculino',
|
||
|
|
seguro: json['seguro']?.toString().trim() ?? 'Sí',
|
||
|
|
estCivil: json['est_civil']?.toString().trim() ?? 'Soltero',
|
||
|
|
motCons: json['mot_cons']?.toString().trim() ?? '',
|
||
|
|
hisEnfAct: json['his_enf_act']?.toString().trim() ?? '',
|
||
|
|
datPadre: json['dat_padre']?.toString().trim() ?? '',
|
||
|
|
datEsp: json['dat_esp']?.toString().trim() ?? '',
|
||
|
|
datHijos: json['dat_hijos']?.toString().trim() ?? '',
|
||
|
|
datOtrosnp: json['dat_otrosnp']?.toString().trim() ?? '',
|
||
|
|
datAlerg: json['dat_alerg']?.toString().trim() ?? '',
|
||
|
|
datTran: json['dat_tran']?.toString().trim() ?? '',
|
||
|
|
datOtrosp: json['dat_otrosp']?.toString().trim() ?? '',
|
||
|
|
metDiagnRad: json['met_diagn_rad']?.toString().trim() ?? '',
|
||
|
|
datLab: json['dat_lab']?.toString().trim() ?? '',
|
||
|
|
diagnDesc: json['diagn_desc']?.toString().trim() ?? '',
|
||
|
|
diagnDef: json['diagn_def']?.toString().trim() ?? '',
|
||
|
|
fecProxcita: json['fec_proxcita']?.toString().trim() ?? '',
|
||
|
|
tratamiento: json['tratamiento']?.toString().trim() ?? '',
|
||
|
|
datHer: json['dat_her']?.toString().trim() ?? '',
|
||
|
|
datMad: json['dat_mad']?.toString().trim() ?? '',
|
||
|
|
datNi: json['dat_ni']?.toString().trim() ?? '',
|
||
|
|
datAdo: json['dat_ado']?.toString().trim() ?? '',
|
||
|
|
datAdu: json['dat_adu']?.toString().trim() ?? '',
|
||
|
|
datAc: json['dat_ac']?.toString().trim() ?? '',
|
||
|
|
datCir: json['dat_cir']?.toString().trim() ?? '',
|
||
|
|
datJuv: json['dat_juv']?.toString().trim() ?? '',
|
||
|
|
estadoEspera: json['estado_espera']?.toString().trim() ?? 'no_presente',
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
Map<String, dynamic> toJson({bool includeId = false}) {
|
||
|
|
final data = <String, dynamic>{
|
||
|
|
'nombre': nombre,
|
||
|
|
'apellido': apellido,
|
||
|
|
'telefono': telefono,
|
||
|
|
'direccion': direccion,
|
||
|
|
'cedula': cedula,
|
||
|
|
'ocupacion': ocupacion,
|
||
|
|
'edad': edad,
|
||
|
|
'fec_ultcon': fecUltcon,
|
||
|
|
'fec_reg': fecReg,
|
||
|
|
'sexo': sexo,
|
||
|
|
'seguro': seguro,
|
||
|
|
'est_civil': estCivil,
|
||
|
|
'mot_cons': motCons,
|
||
|
|
'his_enf_act': hisEnfAct,
|
||
|
|
'dat_padre': datPadre,
|
||
|
|
'dat_esp': datEsp,
|
||
|
|
'dat_hijos': datHijos,
|
||
|
|
'dat_otrosnp': datOtrosnp,
|
||
|
|
'dat_alerg': datAlerg,
|
||
|
|
'dat_tran': datTran,
|
||
|
|
'dat_otrosp': datOtrosp,
|
||
|
|
'met_diagn_rad': metDiagnRad,
|
||
|
|
'dat_lab': datLab,
|
||
|
|
'diagn_desc': diagnDesc,
|
||
|
|
'diagn_def': diagnDef,
|
||
|
|
'fec_proxcita': fecProxcita,
|
||
|
|
'tratamiento': tratamiento,
|
||
|
|
'dat_her': datHer,
|
||
|
|
'dat_mad': datMad,
|
||
|
|
'dat_ni': datNi,
|
||
|
|
'dat_ado': datAdo,
|
||
|
|
'dat_adu': datAdu,
|
||
|
|
'dat_ac': datAc,
|
||
|
|
'dat_cir': datCir,
|
||
|
|
'dat_juv': datJuv,
|
||
|
|
'estado_espera': estadoEspera,
|
||
|
|
};
|
||
|
|
if (includeId && id != null) {
|
||
|
|
data['id'] = id;
|
||
|
|
}
|
||
|
|
return data;
|
||
|
|
}
|
||
|
|
}
|