Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@
</span>
</td>
<td *plTableCol="'unidadOrganizativa'">
{{ (internacion.idPrestacion?.unidadOrganizativa?.term) ||
(internacion.estadosCama[0]?.estados[0]?.unidadOrganizativa?.term) }}
{{ getUltimaUnidadOrganizativa(internacion) }}
</td>
</plex-table>
</ng-container>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ export class ListadoInternacionCapasComponent implements OnInit, OnDestroy {
sorteable: true,
opcional: true,
sort: (a: any, b: any) => {
const nameA = a.idPrestacion?.unidadOrganizativa?.term || a.estadosCama?.[0]?.estados?.[0]?.unidadOrganizativa?.term || '';
const nameB = b.idPrestacion?.unidadOrganizativa?.term || b.estadosCama?.[0]?.estados?.[0]?.unidadOrganizativa?.term || '';
const nameA = this.getUltimaUnidadOrganizativa(a) || '';
const nameB = this.getUltimaUnidadOrganizativa(b) || '';
return nameA.localeCompare(nameB);
}
}
Expand Down Expand Up @@ -144,6 +144,26 @@ export class ListadoInternacionCapasComponent implements OnInit, OnDestroy {
this.location.back();
}

getUltimaUnidadOrganizativa(internacion: any): string {
const estadosCama = internacion.estadosCama;
if (!estadosCama?.length) {
return internacion.idPrestacion?.unidadOrganizativa?.term;
}
let ultimoEstadoConPaciente: any = null;
for (const cama of estadosCama) {
if (cama.estados && cama.estados.length > 0) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Esta condición la podemos simplificar asi: if (cama.estados?.length)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

se corrigió

for (const estado of cama.estados) {
if (estado.paciente) {
if (!ultimoEstadoConPaciente || new Date(estado.fecha) > new Date(ultimoEstadoConPaciente.fecha)) {
ultimoEstadoConPaciente = estado;
}
}
}
}
}
return ultimoEstadoConPaciente?.unidadOrganizativa?.term || internacion.idPrestacion?.unidadOrganizativa?.term;
}

cancelar() {
this.mapaCamasService.selectResumen(null);
this.mapaCamasService.selectPrestacion(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,37 @@ export class ListadoInternacionCapasService {
}

if (unidad) {
const unidadId = unidad?.conceptId || unidad;
listaInternacionFiltrada = listaInternacionFiltrada.filter(
(internacion: IResumenInternacion) =>
(internacion as any).idPrestacion?.unidadOrganizativa?.conceptId === (unidad?.conceptId || unidad)
(internacion: any) => {
const uoEfectiva = this.getUltimaUnidadOrganizativaConceptId(internacion);
return uoEfectiva === unidadId;
}
);
}
return listaInternacionFiltrada;
}

getUltimaUnidadOrganizativaConceptId(internacion: any): string {
const estadosCama = internacion.estadosCama;
if (!estadosCama?.length) {
return internacion.idPrestacion?.unidadOrganizativa?.conceptId;
}
let ultimoEstadoConPaciente: any = null;
for (const cama of estadosCama) {
if (cama.estados?.length) {
for (const estado of cama.estados) {
if (estado.paciente) {
if (!ultimoEstadoConPaciente || new Date(estado.fecha) > new Date(ultimoEstadoConPaciente.fecha)) {
ultimoEstadoConPaciente = estado;
}
}
}
}
}
return ultimoEstadoConPaciente?.unidadOrganizativa?.conceptId || internacion.idPrestacion?.unidadOrganizativa?.conceptId;
}

setFechaHasta(fecha: Date) {
this.fechaIngresoHasta.next(fecha);
}
Expand Down
Loading