Skip to content

Commit

Permalink
feat(events): se propone una forma de resolver lo del evento que no toma
Browse files Browse the repository at this point in the history
  • Loading branch information
sychus authored and plammel committed Jul 14, 2021
1 parent b755f8c commit 12e15aa
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 23 deletions.
8 changes: 0 additions & 8 deletions jobs/LAMPResultsImport.ts

This file was deleted.

1 change: 1 addition & 0 deletions jobs/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
require('./manual');

8 changes: 4 additions & 4 deletions jobs/jobLAMP.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { importLAMPResults } from './LAMPResultsImport';
import { importLAMPResults } from './../modules/forms/forms-epidemiologia/controller/forms-epidemiologia.controller';

function run(done) {
importLAMPResults(done);
}

async function run() {
await importLAMPResults();
}
export = run;
5 changes: 2 additions & 3 deletions jobs/manual.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@


import { AndesDrive } from '@andes/drive/';

import { Connections } from './../connections';
import { Drive } from '../config.private';
import { Connections } from './../connections';

const path = require('path');

Connections.initialize();

AndesDrive.setup(Drive);

const { setupServices } = require('../services');
Expand All @@ -24,6 +22,7 @@ const done = () => {
};

const actionName = process.argv[2];
require('./../modules/webhook');
const action = require(path.join('..', actionName));

action(done);
5 changes: 3 additions & 2 deletions jobs/scheduler.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { jobs } from '../config.private';
import { ChildProcess, spawn } from 'child_process';
import * as debug from 'debug';
import { spawn, ChildProcess } from 'child_process';
import { jobs } from '../config.private';


const schedule = require('node-schedule');
const log = debug('jobs');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { EventCore } from '@andes/event-bus/';
import { FormsEpidemiologia } from '../forms-epidemiologia-schema';
import * as mongoose from 'mongoose';

Expand All @@ -19,5 +20,10 @@ export async function updateField(id, body) {
}

export async function getLAMPPendientes() {
return await FormsEpidemiologia.find({'secciones.fields.lamp.id': 'muestra'});
return await FormsEpidemiologia.find({ 'secciones.fields.lamp.id': 'muestra' });
}

export async function importLAMPResults() {
const lamps = await this.getLAMPPendientes();
EventCore.emitAsync('notificacion:epidemio:lamp', lamps);
}
6 changes: 4 additions & 2 deletions modules/forms/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
export { FormEpidemiologiaRouter } from './forms-epidemiologia/forms-epidemiologia.routes';
export { FormHistoryRouter } from './forms-epidemiologia/forms-history.routes';
export { FormResourcesRouter } from './forms-resources/forms-resources-routes';
export { FormRouter } from './forms.routes';
export { FormHistoryRouter } from './forms-epidemiologia/forms-history.routes';
require('./forms-epidemiologia/forms-epidemiologia.events');
import './forms-epidemiologia/controller/forms-epidemiologia.controller';
import './forms-epidemiologia/forms-epidemiologia.events';

8 changes: 5 additions & 3 deletions modules/webhook/webhook.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import * as mongoose from 'mongoose';
import { EventCore } from '@andes/event-bus';
import { WebHook } from './webhook.schema';
import { WebHookLog } from './webhooklog/webhooklog.schema';
import { Patient } from '@andes/fhir';
import { Engine } from 'json-rules-engine';
import * as mongoose from 'mongoose';
import { WebHook } from './webhook.schema';
import { WebHookLog } from './webhooklog/webhooklog.schema';

const request = require('request');

const trasform = {
fhir: Patient.encode
};


EventCore.on(/.*/, async function (body) {
const event = this.event;
const subscriptions = await WebHook.find({
Expand Down Expand Up @@ -84,3 +85,4 @@ async function verificarFiltros(subscription, body) {
return true;
}
}

0 comments on commit 12e15aa

Please sign in to comment.