Skip to content

Commit

Permalink
MONIT - Actualización de ABM (#61)
Browse files Browse the repository at this point in the history
* feat(MONIT): agregar warning para concepto repetido

* feat(MONIT): quitar eliminacion de concepto turneable
  • Loading branch information
ma7payne committed Mar 6, 2024
1 parent 361ca2a commit 276a27c
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 51 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { Component, Input, OnInit, OnDestroy } from '@angular/core';
import { Auth } from '@andes/auth';
import { Plex } from '@andes/plex';
import { Component, OnDestroy, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { IConceptoTurneable } from '../Interfaces/IConceptoTurneable';
import { ConceptoTruneableService } from '../services/concepto-turneable.service';
import { Auth } from '@andes/auth';
import { Router } from '@angular/router';


@Component({
selector: 'app-conceptos-turneables',
Expand Down Expand Up @@ -54,7 +53,7 @@ export class ConceptosTurneablesComponent implements OnInit, OnDestroy {
this.timeoutHandle = null;
this.conceptoTurneableService.get({
conceptId: this.conceptID,
term: '^' + this.term,
term: conceptID && !term ? this.term : '^' + this.term,
}).subscribe(
resultado => {
this.loading = false;
Expand Down Expand Up @@ -119,29 +118,4 @@ export class ConceptosTurneablesComponent implements OnInit, OnDestroy {
this.buscar();
});
}

onEliminarConceptoTurneable(conceptoTurneable) {
if (this.conceptoSeleccionado && this.conceptoSeleccionado.id) {
this.plex.confirm('Eliminar concepto turneable "' + conceptoTurneable.term + '"', '¿Desea eliminar?').then(confirmacion => {
if (confirmacion) {
this.conceptoTurneableService.delete(conceptoTurneable).subscribe(resultado => {
this.plex.info('info', 'El Concepto Turneable fue eliminado');
this.conceptoSeleccionado = null;
let i = 0;
let index;
this.conceptosTurneables.forEach(concepto => {
if (concepto.id === conceptoTurneable.id) {
index = i;
}
i++;
});

this.conceptosTurneables.splice(index, 1);
});
}
});
} else {
this.plex.info('danger', 'No es posible dar de baja este Concepto Turneable');
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
<tbody>
<tr class="hover" *ngFor="let concepto of conceptosSnomed" label="elemento conceptos snomed"
[ngClass]="{'bg-inverse text-white': conceptoSnomedSeleccionado && concepto.id === conceptoSnomedSeleccionado.id}"
(click)="onRowClick(concepto)">
(click)="seleccionarConcepto(concepto)">
<td class="">
<span *ngIf="concepto?.term !== ''" class="d-block">{{concepto.term}}</span>
</td>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import { Component, Input, OnInit, Output, EventEmitter } from '@angular/core';
import { Plex } from '@andes/plex';
import { SnomedService } from 'src/app/shared/snomed.service';
import { PlexModalComponent } from '@andes/plex/src/lib/modal/modal.component';
import { Component, EventEmitter, Output, ViewChild } from '@angular/core';
import { Subject } from 'rxjs';
import { ISnomedConcept } from 'src/app/shared/ISnomedConcept';
import { SnomedService } from 'src/app/shared/snomed.service';
import { IConceptoTurneable } from '../Interfaces/IConceptoTurneable';
import { ConceptoTruneableService } from '../services/concepto-turneable.service';

@Component({
selector: 'app-concepto-turneable-nuevo',
templateUrl: './nuevo-concepto-turneable.component.html',
})
export class NuevoConceptoTurneableComponent implements OnInit {
export class NuevoConceptoTurneableComponent {
@ViewChild('modal', { static: true }) modal: PlexModalComponent;
@Output() agregarConceptoTurneable = new EventEmitter<IConceptoTurneable>();
@Output() cancelarAgregarConceptoTurneable = new EventEmitter<any>();

Expand All @@ -33,11 +37,25 @@ export class NuevoConceptoTurneableComponent implements OnInit {
constructor(
public plex: Plex,
private snomedService: SnomedService,
private conceptoTurneableService: ConceptoTruneableService,
) {
}

ngOnInit() {
mostrarMensaje() {
this.plex.info('warning', 'Ya existe un concepto turneable para el conceptId seleccionado. Para mayor información comunicarse con <b>soporteandes@neuquen.gov.ar</b>.', 'Información');
}

buscarConcepto(concepto: IConceptoTurneable) {
const existe = new Subject<boolean>();

this.conceptoTurneableService.get({
conceptId: concepto.conceptId
}).subscribe(
resultado => existe.next(resultado.length > 0),
() => existe.next(true)
);

return existe.asObservable();
}

buscar() {
Expand All @@ -58,6 +76,7 @@ export class NuevoConceptoTurneableComponent implements OnInit {
search: this.term,
semanticTag: ['procedimiento']
};

this.snomedService.get(query).subscribe((resultado: ISnomedConcept[]) => {
this.loading = false;
this.conceptosSnomed = resultado;
Expand All @@ -68,16 +87,20 @@ export class NuevoConceptoTurneableComponent implements OnInit {
}
}

onRowClick(concepto: IConceptoTurneable) {
if (!this.conceptoSnomedSeleccionado || this.conceptoSnomedSeleccionado.id !== concepto.id) {
this.conceptoSnomedSeleccionado = concepto;
this.nuevoConceptoTurneable.conceptId = this.conceptoSnomedSeleccionado.conceptId;
this.nuevoConceptoTurneable.term = this.conceptoSnomedSeleccionado.term;
this.nuevoConceptoTurneable.fsn = this.conceptoSnomedSeleccionado.fsn;
this.nuevoConceptoTurneable.semanticTag = this.conceptoSnomedSeleccionado.semanticTag;
} else {
this.conceptoSnomedSeleccionado = null;
}
seleccionarConcepto(concepto: IConceptoTurneable) {
this.buscarConcepto(concepto).subscribe(existe => {
if (existe) { this.mostrarMensaje(); } else {
if (!this.conceptoSnomedSeleccionado || this.conceptoSnomedSeleccionado.id !== concepto.id) {
this.conceptoSnomedSeleccionado = concepto;
this.nuevoConceptoTurneable.conceptId = this.conceptoSnomedSeleccionado.conceptId;
this.nuevoConceptoTurneable.term = this.conceptoSnomedSeleccionado.term;
this.nuevoConceptoTurneable.fsn = this.conceptoSnomedSeleccionado.fsn;
this.nuevoConceptoTurneable.semanticTag = this.conceptoSnomedSeleccionado.semanticTag;
} else {
this.conceptoSnomedSeleccionado = null;
}
}
});
}

agregar() {
Expand All @@ -89,6 +112,4 @@ export class NuevoConceptoTurneableComponent implements OnInit {
cancelarAgregar() {
this.cancelarAgregarConceptoTurneable.emit();
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,4 @@ export class ConceptoTruneableService {
patch(id: string, cambios: any, options: any = {}): Observable<IConceptoTurneable> {
return this.server.patch(`${this.conceptoTurneableUrl}/${id}`, cambios);
}

delete(conceptoTurneable: IConceptoTurneable): Observable<any> {
return this.server.delete(`${this.conceptoTurneableUrl}/${conceptoTurneable.id}`);
}
}

0 comments on commit 276a27c

Please sign in to comment.