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
3 changes: 2 additions & 1 deletion core/tm/conceptos-turneables.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ class ConceptoTurneableResource extends ResourceBase {
return { $in: value };
}
},
ids: MongoQuery.inArray.withField('_id')
ids: MongoQuery.inArray.withField('_id'),
teleConsulta: MongoQuery.equalMatch
};
middlewares = [Auth.authenticate()];
routesAuthorization = {
Expand Down
9 changes: 7 additions & 2 deletions core/tm/schemas/tipoPrestacion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ export interface ITipoPrestacion extends Document {
ambito: String[];
queries: [Types.ObjectId];
agendaDinamica?: Boolean;
teleConsulta?: Boolean;
}


export const tipoPrestacionSchema = new Schema({
conceptId: String,
term: String,
Expand Down Expand Up @@ -48,7 +48,12 @@ export const tipoPrestacionSchema = new Schema({
type: Boolean,
required: false
},
queries: [Types.ObjectId]
queries: [Types.ObjectId],
teleConsulta: {
type: Boolean,
required: false,
default: false
}
});

/* Se definen los campos virtuals */
Expand Down
9 changes: 7 additions & 2 deletions modules/mobileApp/routes/agendas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { getDistanceBetweenPoints } from '../../../utils/utilCoordenadas';
import { verificarCondicionPaciente } from '../../../modules/turnos/condicionPaciente/condicionPaciente.controller';
import { CondicionPaciente } from '../../../modules/turnos/condicionPaciente/condicionPaciente.schema';
import { Constantes, Constante } from '../../../modules/constantes/constantes.schema';
import { tipoPrestacion } from '../../../core/tm/schemas/tipoPrestacion';

const router = express.Router();

Expand All @@ -27,9 +28,14 @@ router.get('/agendasDisponibles', async (req: any, res, next) => {
}
}
}

if (req.query.conceptId) {
matchAgendas['tipoPrestaciones.conceptId'] = req.query.conceptId;
} else {
if (!req.query.teleConsulta) {
const conceptosTurneables: any = await tipoPrestacion.find({ teleConsulta: true });
const conceptIdArray = conceptosTurneables?.map(ct => ct.conceptId);
matchAgendas['tipoPrestaciones.conceptId'] = { $nin: conceptIdArray };
}
}
matchAgendas['horaInicio'] = { $gt: new Date(moment().format('YYYY-MM-DD HH:mm')) };
matchAgendas['bloques.restantesProgramados'] = { $gt: 0 };
Expand Down Expand Up @@ -67,7 +73,6 @@ router.get('/agendasDisponibles', async (req: any, res, next) => {
pipelineAgendas.push({
$sort: { 'agendas.horaInicio': 1 }
});

try {
let agendasResultado = await Agenda.aggregate(pipelineAgendas);
if (req.query.userLocation) {
Expand Down
29 changes: 20 additions & 9 deletions modules/turnos/routes/agenda.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import * as AgendasEstadisticas from '../controller/estadisticas';
import { getPlanillaC1, getResumenDiarioMensual } from '../controller/reportesDiariosController';
import { Agenda } from '../schemas/agenda';
import { Auth } from './../../../auth/auth.class';
import { tipoPrestacion } from '../../../core/tm/schemas/tipoPrestacion';

const router = express.Router();

Expand Down Expand Up @@ -155,11 +156,10 @@ router.get('/agenda/diagnosticos', async (req, res, next) => {
} catch (err) { return next(err); }
});

router.get('/agenda/:id?', (req, res, next) => {
router.get('/agenda/:id?', async (req, res, next) => {

if (mongoose.Types.ObjectId.isValid(req.params.id)) {

Agenda.findById(req.params.id, (err, data) => {
await Agenda.findById(req.params.id, (err, data) => {
if (err) {
return next(err);
}
Expand Down Expand Up @@ -250,6 +250,17 @@ router.get('/agenda/:id?', (req, res, next) => {
query.where('bloques.turnos._id').equals(req.query.turno);
}

if (!req.query.teleConsulta) {
const conceptosTurneables: any = await tipoPrestacion.find({ teleConsulta: true });
const conceptId = [];
if (conceptosTurneables.length > 0) {
for (const ct of conceptosTurneables) {
conceptId.push(ct.conceptId);
}
query.where('tipoPrestaciones.conceptId').nin(conceptId);
}
}

// Si rango es true se buscan las agendas que se solapen con la actual en algún punto
if (req.query.rango) {
const variable: any[] = [];
Expand Down Expand Up @@ -678,9 +689,9 @@ router.patch('/agenda/:id*?', (req, res, next) => {

router.post('/dashboard', async (req, res, next) => {
const permisos: any = {};
const tipoPrestacion = Auth.getPermissions(req, 'visualizacionInformacion:dashboard:citas:tipoPrestacion:?');
if (tipoPrestacion.length > 0 && tipoPrestacion[0] !== '*') {
permisos.tipoPrestacion = tipoPrestacion;
const permisosTP = Auth.getPermissions(req, 'visualizacionInformacion:dashboard:citas:tipoPrestacion:?');
if (permisosTP.length > 0 && permisosTP[0] !== '*') {
permisos.tipoPrestacion = permisosTP;
}

try {
Expand Down Expand Up @@ -734,9 +745,9 @@ router.post('/dashboard/descargarCsv', async (req, res, next) => {

router.post('/dashboard/localidades', async (req, res, next) => {
const permisos: any = {};
const tipoPrestacion = Auth.getPermissions(req, 'visualizacionInformacion:dashboard:citas:tipoPrestacion:?');
if (tipoPrestacion.length > 0 && tipoPrestacion[0] !== '*') {
permisos.tipoPrestacion = tipoPrestacion;
const permisosTP = Auth.getPermissions(req, 'visualizacionInformacion:dashboard:citas:tipoPrestacion:?');
if (permisosTP.length > 0 && permisosTP[0] !== '*') {
permisos.tipoPrestacion = permisosTP;
}

try {
Expand Down