Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MPI: Implementa registro para extranjeros con DNI argentino #2822

Merged
merged 1 commit into from
Dec 15, 2023
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
2 changes: 2 additions & 0 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ import { HistorialBusquedaService } from './core/mpi/services/historialBusqueda.
import { PacienteBuscarService } from './core/mpi/services/paciente-buscar.service';
import { PacienteService } from './core/mpi/services/paciente.service';
import { PacienteCacheService } from './core/mpi/services/pacienteCache.service';
import { PacienteVinculadoCacheService } from './core/mpi/services/pacienteVinculadoCache.service';
import { DirectiveLibModule } from './directives/directives.module';
import { AuditoriaModule } from './modules/auditoria/auditoria.module';
import { ValidarCertificadoComponent } from './modules/epidemiologia/components/validar-certificado/validar-certificado.component';
Expand Down Expand Up @@ -395,6 +396,7 @@ registerLocaleData(localeEs, 'es');
ConfiguracionPrestacionService,
PrestacionLegacyService,
PacienteCacheService,
PacienteVinculadoCacheService,
GeoreferenciaService,
HistorialBusquedaService,
CodificacionService,
Expand Down
1 change: 0 additions & 1 deletion src/app/core/mpi/components/busqueda-mpi.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ export class BusquedaMpiComponent implements OnInit {
if (paciente) {
this.historialBusquedaService.add(paciente);
this.pacienteCache.setPaciente(paciente);

if ((paciente.numeroIdentificacion || paciente.tipoIdentificacion) && !paciente.documento) {
this.router.navigate(['apps/mpi/paciente/extranjero/mpi']); // abre formulario paciente extranjero
} else {
Expand Down
59 changes: 49 additions & 10 deletions src/app/core/mpi/components/datos-basicos.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Plex } from '@andes/plex';
import { Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges, ViewChild } from '@angular/core';
import { AfterViewInit, Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges, ViewChild } from '@angular/core';
import { NgForm } from '@angular/forms';
import { Subscription } from 'rxjs';
import { IPacienteMatch } from '../../../modules/mpi/interfaces/IPacienteMatch.inteface';
Expand All @@ -16,12 +16,13 @@ import { PacienteService } from '../services/paciente.service';
styleUrls: ['datos-basicos.scss']
})

export class DatosBasicosComponent implements OnInit, OnChanges {
export class DatosBasicosComponent implements OnInit, OnChanges, AfterViewInit {

@Input() paciente: IPaciente;
@Input() tipoPaciente = 'con-dni';
@Output() changes: EventEmitter<any> = new EventEmitter<any>();
@ViewChild('form', { static: false }) ngForm: NgForm;
@ViewChild('formBasico', { static: false }) formBasico: NgForm;
@ViewChild('formExtranjero', { static: false }) formExtranjero: NgForm;
formChangesSubscription: Subscription;

estados = [];
Expand All @@ -30,7 +31,11 @@ export class DatosBasicosComponent implements OnInit, OnChanges {
estadosCiviles: any[];
tipoIdentificacion: any[];
noPoseeDNI = false;
botonRegistroDNI = false;
pacienteExtranjero: IPaciente;

public nuevoPaciente = false;
public disableRegistro = false;
public nombrePattern: string;
public patronDocumento = /^[1-9]{1}[0-9]{4,7}$/;
hoy = moment().endOf('day').toDate();
Expand Down Expand Up @@ -63,7 +68,6 @@ export class DatosBasicosComponent implements OnInit, OnChanges {
fotoId: null
};


constructor(
private plex: Plex,
private pacienteService: PacienteService,
Expand All @@ -72,6 +76,31 @@ export class DatosBasicosComponent implements OnInit, OnChanges {
this.nombrePattern = pacienteService.nombreRegEx.source;
}

ngOnChanges(changes: SimpleChanges) {
if (changes.paciente) {
this.nuevoPaciente = changes.paciente.firstChange || !changes.paciente.currentValue.id;

if (!changes.paciente.previousValue?.id) {
this.pacienteExtranjero = Object.assign({}, this.paciente);
}
}

if (!changes.paciente.currentValue.notaError?.length) {
this.paciente.reportarError = false;
}
}

ngAfterViewInit() {
if (this.formExtranjero) {
this.formExtranjero.control.valueChanges.subscribe(
() => {
this.changes.emit({ pacienteExtranjero: this.pacienteExtranjero });
this.disableRegistro = this.formExtranjero.invalid;
}
);
}
}

ngOnInit() {
if (this.tipoPaciente === 'sin-dni') {
this.noPoseeDNI = true;
Expand All @@ -88,15 +117,14 @@ export class DatosBasicosComponent implements OnInit, OnChanges {
});
}

ngOnChanges({ paciente }: SimpleChanges) {
if (!paciente.currentValue.notaError?.length) {
this.paciente.reportarError = false;
}
public checkFormExtranjero() {
this.formExtranjero.control.markAllAsTouched();
return this.formExtranjero.control.valid;
}

public checkForm() {
this.ngForm.control.markAllAsTouched();
return this.ngForm.control.valid;
this.formBasico.control.markAllAsTouched();
return this.formBasico.control.valid;
}

checkDisableValidar() {
Expand All @@ -116,6 +144,17 @@ export class DatosBasicosComponent implements OnInit, OnChanges {

completarGenero() {
this.paciente.genero = ((typeof this.paciente.sexo === 'string')) ? this.paciente.sexo : (Object(this.paciente.sexo).id);
this.paciente.genero = ((typeof this.pacienteExtranjero.sexo === 'string')) ? this.pacienteExtranjero.sexo : (Object(this.pacienteExtranjero.sexo).id);
}

registrarArgentino() {
if (this.botonRegistroDNI) {
this.disableRegistro = false;
this.formExtranjero.control.markAsPristine();
this.formExtranjero.control.markAsUntouched();
}

this.changes.emit({ registroDNI: this.botonRegistroDNI });
}


Expand Down
101 changes: 70 additions & 31 deletions src/app/core/mpi/components/datos-basicos.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,44 @@
<section class="mt-2">
<form #form="ngForm">

<div *ngIf="tipoPaciente === 'extranjero'">
<plex-title size="sm" titulo="Registro de paciente extranjero">
<plex-bool *ngIf="!nuevoPaciente" [(ngModel)]="botonRegistroDNI" label="Registrar DNI argentino"
type="slide" (change)="registrarArgentino()" name="registroDNI"
[readonly]="disableRegistro || paciente.estado === 'validado'"></plex-bool>
</plex-title>

<form #formExtranjero="ngForm">
<plex-wrapper>
<plex-text label="Apellido" [(ngModel)]="pacienteExtranjero.apellido" name="apellido"
[disabled]="botonRegistroDNI" required="true">
</plex-text>
<plex-text label="Nombre" [(ngModel)]="pacienteExtranjero.nombre" name="nombre"
[disabled]="botonRegistroDNI" required="true">
</plex-text>

<plex-select [(ngModel)]="pacienteExtranjero.sexo" label="Seleccione sexo" [data]="sexos" name="sexo"
required="true" [disabled]="botonRegistroDNI" placeholder="Seleccione..."
(change)="completarGenero()">
</plex-select>
</plex-wrapper>
<plex-wrapper>
<plex-datetime label="Fecha de Nacimiento" [max]="hoy" type="date"
[(ngModel)]="pacienteExtranjero.fechaNacimiento" name="fechaNacimiento" required="true"
grow="3" [disabled]="botonRegistroDNI">
</plex-datetime>

<plex-select label="Tipo de identificación" [(ngModel)]="pacienteExtranjero.tipoIdentificacion"
[data]="tipoIdentificacion" name="tipoIdentificacion" placeholder="Seleccione..." grow="3"
[disabled]="botonRegistroDNI">
</plex-select>
<plex-text label="Número de identificación" [(ngModel)]="pacienteExtranjero.numeroIdentificacion"
name="numeroIdentificacion" grow="3" [disabled]="botonRegistroDNI">
</plex-text>
</plex-wrapper>
</form>
</div>

<form #formBasico="ngForm">
<ng-container [ngSwitch]="tipoPaciente">
<div *ngSwitchCase="'bebe'">
<plex-title size="sm" titulo="Registro de bebé"></plex-title>
Expand All @@ -14,7 +53,7 @@
</plex-text>

<plex-select [(ngModel)]="paciente.sexo" label="Seleccione sexo" [data]="sexos" name="sexoBebe"
[required]="true" placeholder="Seleccione.." grow="4">
[required]="true" placeholder="Seleccione..." grow="4">
</plex-select>

<plex-datetime label="Fecha y hora de Nacimiento" [max]="hoy" type="datetime"
Expand Down Expand Up @@ -88,52 +127,53 @@
</div>

<div *ngSwitchCase="'extranjero'">
<plex-title size="sm" titulo="Registro de paciente extranjero"></plex-title>
<div *ngIf="botonRegistroDNI">
<plex-title size="sm" titulo="Registro de paciente argentino"></plex-title>

<plex-wrapper>
<plex-text label="Apellido" [(ngModel)]="paciente.apellido" name="apellidoExt" required="true">
</plex-text>

<plex-text label="Nombre" [(ngModel)]="paciente.nombre" name="nombreExt" [pattern]="nombrePattern"
required="true">
</plex-text>

<plex-select [(ngModel)]="paciente.sexo" label="Seleccione sexo" [data]="sexos" name="sexoExt"
required="true" placeholder="Seleccione.." (change)="completarGenero();">
</plex-select>
</plex-wrapper>
<plex-wrapper>
<plex-int class="mr-3" label="Número de DNI ARGENTINO" [(ngModel)]="paciente.documento"
[readonly]="validado || noPoseeDNI" [pattern]="patronDocumento" name="documento"
[required]="true" (change)="checkDisableValidar()" grow="3">
</plex-int>
<plex-select [(ngModel)]="paciente.sexo" label="Seleccione sexo" [data]="sexos" name="sexo"
required="true" placeholder="Seleccione..." [readonly]="validado"
(change)="completarGenero(); checkDisableValidar()" grow="3">
</plex-select>

<plex-wrapper>
<plex-datetime label="Fecha de Nacimiento" [max]="hoy" type="date"
[(ngModel)]="paciente.fechaNacimiento" name="fechaNacimientoExt" required="true"
grow="3">
</plex-datetime>
<plex-datetime label="Fecha de Nacimiento" [max]="hoy" type="date" [readonly]="true"
[(ngModel)]="paciente.fechaNacimiento" name="fechaNacimiento"
[required]="!noPoseeDNI" grow="3">
</plex-datetime>
</plex-wrapper>
<plex-wrapper>
<plex-text label="Apellido" [(ngModel)]="paciente.apellido" name="apellido" required="true"
[readonly]="true">
</plex-text>

<plex-select label="Tipo de identificación" [(ngModel)]="paciente.tipoIdentificacion"
[data]="tipoIdentificacion" name="tipoIdentificacion" placeholder="Seleccione.."
grow="3">
</plex-select>
<plex-text label="Nombre" [(ngModel)]="paciente.nombre" name="nombre" required="true"
[readonly]="true">
</plex-text>

<plex-text label="Número de identificación" [(ngModel)]="paciente.numeroIdentificacion"
name="numeroIdentificacion" grow="3">
</plex-text>
</plex-wrapper>
<plex-select [(ngModel)]="paciente.estadoCivil" name="estadoCivil" [data]="estadosCiviles"
label="Seleccione estado Civil">
</plex-select>
</plex-wrapper>
</div>
</div>

<div *ngSwitchDefault>
<plex-title size="sm" titulo="Registro de paciente">
<plex-bool *ngIf="!validado" [(ngModel)]="noPoseeDNI" label="No posee DNI ARGENTINO" type="slide"
name="noPoseDNI" (change)="limpiarDocumento()"></plex-bool>
</plex-title>

<plex-wrapper>
<plex-int class="mr-3" label="Número de DNI ARGENTINO" [(ngModel)]="paciente.documento"
[readonly]=" validado || noPoseeDNI " [pattern]="patronDocumento" name="documento"
[required]="!noPoseeDNI" (change)="checkDisableValidar()" grow="3">
</plex-int>

<plex-select [(ngModel)]="paciente.sexo" label="Seleccione sexo" [data]="sexos" name="sexo"
required="true" placeholder="Seleccione.." [readonly]="validado"
required="true" placeholder="Seleccione..." [readonly]="validado"
(change)="completarGenero(); checkDisableValidar()" grow="3">
</plex-select>

Expand Down Expand Up @@ -182,7 +222,6 @@
[required]="paciente.reportarError ? 'true' : 'false'"> </plex-text>
</div>
</ng-container>

</form>

</section>
Loading
Loading