-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcargarPacientes.ts
More file actions
49 lines (44 loc) · 1.69 KB
/
cargarPacientes.ts
File metadata and controls
49 lines (44 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import {postPaciente} from './postPaciente';
import { servicioMongo } from './servicioMongo';
var servicio = new postPaciente();
var servMongo = new servicioMongo();
servMongo.getPacientes().then((resultado) => {
var listaPacientes;
listaPacientes = resultado;
// listaPacientes.forEach(pac => {
// servicio.cargarUnPacienteAndes(pac)
// .then((rta) => {
// console.log(rta,"fiinnnnn");
// })
// .catch((err) => {
// console.error('Error**:' + err)
// });
// });
console.log(resultado[0]);
var paciente;
paciente = resultado[0];
servicio.cargarUnPacienteAndes(paciente)
.then((rta) => {
console.log('Paciente Guardado');
servMongo.guardarLogSips({ "idPacienteSips": paciente['idPaciente'], "migrado": true, "Fecha": Date.now() })
.then((respuesta => {
console.log('Guardar Log', 'Se guarda log del paciente');
}))
.catch((err => {
console.log('Error al guardar log', paciente['idPaciente'], err);
}))
})
.catch((err) => {
console.error('Error**:' + err);
servMongo.guardarLogSips({ "idPacienteSips": paciente['idPaciente'], "migrado": false,"Error": err.toString(), "Fecha": Date.now() })
.then((respuesta => {
console.log('Guardar Log', 'Se guarda el paciente');
}))
.catch((err => {
console.log('Error al guardar log de error', paciente['idPaciente'], err);
}))
});
})
.catch((err) => {
console.error('Error**:' + err)
});