@@ -47,34 +47,45 @@ export class DetalleSolicitudComponent implements OnChanges, OnDestroy {
4747 fotos : any [ ] = [ ] ;
4848
4949 ngOnChanges ( changes : SimpleChanges ) {
50- if ( changes . prestacionSeleccionada ) {
51- this . adjuntosService . token$ . subscribe ( ( payload ) => {
52- const { token } = payload ;
53- const solicitudRegistros = this . prestacionSeleccionada . solicitud . registros ;
54- const documentos = solicitudRegistros [ 0 ] . valor . documentos || [ ] ;
55- this . fotos = documentos . map ( ( doc ) => {
56- return {
57- ...doc ,
58- url : this . adjuntosService . createUrl ( 'rup' , doc , token )
59- } ;
60- } ) ;
61- } ) ;
50+ if ( ! changes . prestacionSeleccionada || ! this . prestacionSeleccionada ) {
51+ return ;
6252 }
63- this . pacienteService . getEstadoInternacion ( this . prestacionSeleccionada . paciente . id ) . subscribe ( resp => {
6453
65- if ( resp ) {
66- this . internacion = resp . estado ;
67- this . organizacionInternacion = resp . organizacion ? resp . organizacion : 'Sin organización' ;
68- }
69- this . internacionPaciente . emit ( this . internacion ) ;
70- } ) ;
71- const conceptId = this . prestacionSeleccionada . solicitud . tipoPrestacion . conceptId ;
72- this . conceptosTurneablesService . search ( { conceptId } ) . subscribe ( conceptos => {
73- this . tiempoVigencia = conceptos ?. [ 0 ] ?. tiempoVigencia || 365 ;
74- const fechaSolicitud = new Date ( this . prestacionSeleccionada . solicitud . fecha ) ;
75- this . fechaVencimiento = new Date ( fechaSolicitud ) ;
76- this . fechaVencimiento . setDate ( this . fechaVencimiento . getDate ( ) + this . tiempoVigencia ) ;
54+ this . adjuntosService . token$ . subscribe ( ( payload ) => {
55+ const { token } = payload ;
56+ const solicitudRegistros = this . prestacionSeleccionada . solicitud . registros ;
57+ const documentos = solicitudRegistros ?. [ 0 ] ?. valor ?. documentos || [ ] ;
58+ this . fotos = documentos . map ( ( doc ) => {
59+ return {
60+ ...doc ,
61+ url : this . adjuntosService . createUrl ( 'rup' , doc , token )
62+ } ;
63+ } ) ;
7764 } ) ;
65+
66+ if ( this . prestacionSeleccionada ?. paciente ?. id ) {
67+ this . pacienteService
68+ . getEstadoInternacion ( this . prestacionSeleccionada . paciente . id )
69+ . subscribe ( resp => {
70+ if ( resp ) {
71+ this . internacion = resp . estado ;
72+ this . organizacionInternacion = resp . organizacion ?? 'Sin organización' ;
73+ }
74+ this . internacionPaciente . emit ( this . internacion ) ;
75+ } ) ;
76+ }
77+
78+ const conceptId = this . prestacionSeleccionada ?. solicitud ?. tipoPrestacion ?. conceptId ;
79+ if ( conceptId ) {
80+ this . conceptosTurneablesService . search ( { conceptId } ) . subscribe ( conceptos => {
81+ this . tiempoVigencia = conceptos ?. [ 0 ] ?. tiempoVigencia || 365 ;
82+ const fechaSolicitud = new Date ( this . prestacionSeleccionada . solicitud . fecha ) ;
83+ this . fechaVencimiento = new Date ( fechaSolicitud ) ;
84+ this . fechaVencimiento . setDate (
85+ this . fechaVencimiento . getDate ( ) + this . tiempoVigencia
86+ ) ;
87+ } ) ;
88+ }
7889 }
7990
8091 cambiarOpcion ( opcion ) {
0 commit comments