@@ -20,7 +20,6 @@ export class PacienteDetalleComponent implements OnInit, OnChanges {
2020 @Input ( ) datos = [ ] ;
2121 @Input ( ) paciente : IPaciente ;
2222 @Input ( ) fields : string [ ] = [ 'sexo' , 'fechaNacimiento' , 'edad' , 'cuil' , 'financiador' , 'numeroAfiliado' , 'telefono' , 'direccion' , 'lugarNacimiento' ] ;
23- @Input ( ) verMas = true ;
2423 @Input ( ) reload : Boolean = false ;
2524 @Input ( ) showRelaciones = false ;
2625 @Input ( ) showDocumentos = false ;
@@ -37,55 +36,48 @@ export class PacienteDetalleComponent implements OnInit, OnChanges {
3736 return this . orientacion === 'vertical' ? 'center' : 'start' ;
3837 }
3938
40- get camposVisibles ( ) {
41- if ( this . verMas ) {
42- return this . fields ;
43- }
44- return this . fields . filter ( ( f ) => f === 'edad' || f === 'fechaNacimiento' ) ;
45- }
46-
4739 get showSexo ( ) {
48- return this . camposVisibles . findIndex ( i => i === 'sexo' ) >= 0 ;
40+ return this . fields . findIndex ( i => i === 'sexo' ) >= 0 ;
4941 }
5042
5143 get showFechaNacimiento ( ) {
52- return this . camposVisibles . findIndex ( i => i === 'fechaNacimiento' ) >= 0 ;
44+ return this . fields . findIndex ( i => i === 'fechaNacimiento' ) >= 0 ;
5345 }
5446
5547 get showEdad ( ) {
56- return this . camposVisibles . findIndex ( i => i === 'edad' ) >= 0 ;
48+ return this . fields . findIndex ( i => i === 'edad' ) >= 0 ;
5749 }
5850
5951 get showCuil ( ) {
60- return this . camposVisibles . findIndex ( i => i === 'cuil' ) >= 0 ;
52+ return this . fields . findIndex ( i => i === 'cuil' ) >= 0 ;
6153 }
6254
6355 get showFinanciador ( ) {
64- return this . camposVisibles . findIndex ( i => i === 'financiador' ) >= 0 ;
56+ return this . fields . findIndex ( i => i === 'financiador' ) >= 0 ;
6557 }
6658
6759 get showNumeroAfiliado ( ) {
68- return this . camposVisibles . findIndex ( i => i === 'numeroAfiliado' ) >= 0 ;
60+ return this . fields . findIndex ( i => i === 'numeroAfiliado' ) >= 0 ;
6961 }
7062
7163 get notasDestacadas ( ) {
7264 return this . paciente ?. notas ?. filter ( n => n . destacada ) || [ ] ;
7365 }
7466
7567 get showDireccion ( ) {
76- return this . camposVisibles . findIndex ( i => i === 'direccion' ) >= 0 ;
68+ return this . fields . findIndex ( i => i === 'direccion' ) >= 0 ;
7769 }
7870
7971 get showTelefono ( ) {
80- return this . camposVisibles . findIndex ( i => i === 'telefono' ) >= 0 ;
72+ return this . fields . findIndex ( i => i === 'telefono' ) >= 0 ;
8173 }
8274
8375 get estadoBadgeType ( ) {
8476 return this . paciente ?. estado === 'validado' ? 'success' : 'warning' ;
8577 }
8678
8779 get showLugarNacimiento ( ) {
88- return this . camposVisibles . findIndex ( i => i === 'lugarNacimiento' ) >= 0 ;
80+ return this . fields . findIndex ( i => i === 'lugarNacimiento' ) >= 0 ;
8981 }
9082
9183 get direccion ( ) {
@@ -165,7 +157,6 @@ export class PacienteDetalleComponent implements OnInit, OnChanges {
165157 }
166158
167159 public relaciones : any [ ] ;
168- private _cargado = false ;
169160
170161 private doRelaciones ( ) {
171162 if ( this . paciente ?. relaciones ?. length ) {
@@ -201,20 +192,15 @@ export class PacienteDetalleComponent implements OnInit, OnChanges {
201192 }
202193
203194
204- ngOnChanges ( changes ) {
205- const cambioPaciente = changes ?. paciente &&
206- changes . paciente . previousValue &&
207- changes . paciente . currentValue ?. id !== changes . paciente . previousValue ?. id ;
208-
209- if ( cambioPaciente ) {
210- this . _cargado = false ;
211- }
195+ ngOnChanges ( ) {
196+ const requiereReload = this . reload ||
197+ ! this . paciente ?. financiador ||
198+ ! this . paciente ?. direccion ||
199+ ! this . paciente ?. contacto ;
212200
213- // Se recarga solo cuando el paciente cambia (o es la primera carga), no al alternar verMas/fields
214- if ( this . paciente ?. id && ! this . _cargado ) {
201+ if ( requiereReload && this . paciente ?. id ) {
215202 this . pacienteService . getById ( this . paciente . id ) . subscribe ( result => {
216203 this . paciente = result ;
217- this . _cargado = true ;
218204 this . loadObraSocial ( ) ;
219205 this . doRelaciones ( ) ;
220206 } ) ;
0 commit comments