Skip to content
Open
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 @@ -13,6 +13,18 @@
<ads-icon icon="ball-triangle"></ads-icon>
</div>

<div class="ion-padding" *ngIf="estado === 'validado' && !inProgress">
<ion-text color="light">
<h5 class="ion-text-center"><b>El paciente ya se encuentra registrado en ANDES</b></h5>
</ion-text>
</div>

<div class="ion-padding" *ngIf="estado !== 'validado' && !inProgress">
<ion-text color="light">
<h5 class="ion-text-center"><b>Usted va a registrar un nuevo paciente con los siguientes datos:</b></h5>
</ion-text>
</div>

<ion-card *ngIf="paciente && !inProgress">
<ion-card-header>
<ion-avatar>
Expand All @@ -26,9 +38,7 @@
<ion-card-content>
<ion-list>
<ion-label>
<h3 class="badge success" *ngIf="estado === 'nuevo'"> NUEVO</h3>
<h3 class="badge success" *ngIf="estado === 'temporal'"> ACTUALIZAR </h3>
<h3 class="badge danger" *ngIf="estado === 'validado'">VALIDADO </h3>
<h3 class="badge success" *ngIf="estado === 'validado'">VALIDADO</h3>
</ion-label>
<ion-item>
<ion-label color="dark">
Expand All @@ -51,8 +61,14 @@ <h3 class="badge danger" *ngIf="estado === 'validado'">VALIDADO </h3>
</ion-list>
</ion-card-content>
</ion-card>

<ion-button expand="block" color="success" class="ion-margin" size="medium" (click)="irAlInicio()"
*ngIf="estado === 'validado'">
Ir al inicio
</ion-button>

<ion-button expand="block" color="success" class="ion-margin" size="medium" (click)="save()"
*ngIf="estado !== 'validado'" [disabled]="saving">
Confirmar Datos
Registrar paciente
</ion-button>
</ion-content>
Original file line number Diff line number Diff line change
Expand Up @@ -69,29 +69,59 @@ export class RegistroPacientePage {

this.mpiService.get(search).then((resultado: any[]) => {
if (resultado.length) {
this.paciente = resultado[0];
this.estado = this.paciente.estado;
this.paciente.scan = scan;
this.paciente.nombre = datos.nombre.toUpperCase();
this.paciente.apellido = datos.apellido.toUpperCase();
this.paciente.fechaNacimiento = moment(datos.fechaNacimiento, 'DD/MM/YYYY');
this.paciente.sexo = datos.sexo.toLowerCase();
this.paciente.documento = datos.documento;
this.inProgress = false;
// CASO 1: 100% - Ya registrado
this.actualizarDatosPaciente(resultado[0], datos, scan);
this.estado = 'validado';
} else {
// No existe el paciente
this.estado = 'nuevo';
this.paciente.nombre = datos.nombre.toUpperCase();
this.paciente.apellido = datos.apellido.toUpperCase();
this.paciente.fechaNacimiento = moment(datos.fechaNacimiento, 'DD/MM/YYYY');
this.paciente.sexo = datos.sexo.toLowerCase();
this.paciente.documento = datos.documento;
this.paciente.scan = datos.scan;
this.paciente.estado = 'validado';
this.paciente.genero = datos.sexo.toLowerCase();
this.inProgress = false;
// Buscamos sugeridos para ver si hay posibles duplicados (> 94%)
this.mpiService.match(datos).then((sugeridos: any[]) => {
const candidatos = sugeridos.filter(s => s._score >= 0.94);
this.prepararPacienteNuevo(datos, scan); // Primero creamos el objeto base
this.paciente.estado = 'validado';

if (candidatos.length > 0) {
// Ahora que el objeto existe, le añadimos los duplicados
this.paciente.posibleDuplicado = candidatos.map(c => ({
id: c.id,
score: c._score,
fecha: new Date()
}));
}
this.inProgress = false;
}).catch(() => {
this.prepararPacienteNuevo(datos, scan);
this.inProgress = false;
});
}
});
}

private actualizarDatosPaciente(pacienteEncontrado, datosScan, scanText) {
this.paciente = pacienteEncontrado;
this.paciente.scan = scanText;
this.paciente.nombre = datosScan.nombre.toUpperCase();
this.paciente.apellido = datosScan.apellido.toUpperCase();
this.paciente.fechaNacimiento = moment(datosScan.fechaNacimiento, 'DD/MM/YYYY');
this.paciente.sexo = datosScan.sexo.toLowerCase();
this.paciente.documento = datosScan.documento;
this.inProgress = false;
}

private prepararPacienteNuevo(datos, scan) {
this.paciente = {
nombre: datos.nombre.toUpperCase(),
apellido: datos.apellido.toUpperCase(),
fechaNacimiento: moment(datos.fechaNacimiento, 'DD/MM/YYYY'),
sexo: datos.sexo.toLowerCase(),
documento: datos.documento,
scan: scan,
genero: datos.sexo.toLowerCase()
};
this.estado = 'nuevo';
}

public irAlInicio() {
this.router.navigate(['/home/paciente']);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ export class ScanDocumentoPage {
}

scanner() {
this.barcodeScannerService.scannerProfesional();
this.barcodeScannerService.scannerParaMPI();
}
}
17 changes: 17 additions & 0 deletions src/providers/library-services/barcode-scanner.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,23 @@ export class BarcodeScannerService {
}
);
}
scannerParaMPI() {

const options = configScan.setOptions();
this.barcodeScanner.scan(options).then((barcodeData) => {
const datos = this.scanParser.scan(barcodeData.text);
if (datos) {
this.router.navigate(['profesional/registro-paciente'],
{ queryParams: { datos: JSON.stringify(datos), scan: barcodeData.text } });
} else {
this.toastCtrl.danger('Documento inválido.');
}

}, (err) => {
this.scanFail(err);
});
}


async scanFail(error) {
const alert = await this.alertCtrl.create({
Expand Down
4 changes: 4 additions & 0 deletions src/providers/paciente-mpi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,8 @@ export class PacienteMPIService {
}
}

match(params) {
return this.network.post(this.pacienteUrl + '/match', params);
}

}
Loading