Skip to content

Commit

Permalink
feat(EP): formEpidemiologia.type.id
Browse files Browse the repository at this point in the history
  • Loading branch information
plammel authored and sychus committed Apr 14, 2021
1 parent 908135a commit 1e31d26
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import { AuditPlugin } from '@andes/mongoose-plugin-audit';
import * as mongoose from 'mongoose';

export const FormsEpidemiologiaSchema = new mongoose.Schema({
type: String,
type: {
id: mongoose.Schema.Types.ObjectId,
name: String
},
paciente: {
id: { type: mongoose.Schema.Types.ObjectId, ref: 'paciente' },
documento: String,
Expand Down
15 changes: 14 additions & 1 deletion modules/forms/forms-epidemiologia/forms-epidemiologia.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ class FormsEpidemiologiaResource extends ResourceBase {
resourceName = 'formEpidemiologia';
middlewares = [Auth.authenticate()];
searchFileds = {
type: MongoQuery.partialString,
type: {
field: 'type.name',
fn: MongoQuery.partialString
},
fechaCondicion: MongoQuery.matchDate.withField('createdAt'),
paciente: {
field: 'paciente.id',
Expand All @@ -18,3 +21,13 @@ class FormsEpidemiologiaResource extends ResourceBase {

export const FormEpidemiologiaCtr = new FormsEpidemiologiaResource();
export const FormEpidemiologiaRouter = FormEpidemiologiaCtr.makeRoutes();

FormEpidemiologiaRouter.get('/types', Auth.authenticate(), async (req, res, next) => {
try {
const types: any = await FormsEpidemiologia.find({}, { type: 1 });
return res.json(types);
} catch (err) {
return next(err);
}
});

0 comments on commit 1e31d26

Please sign in to comment.