@@ -13,8 +13,8 @@ const actions = require('mongoose-rest-actions');
13
13
const exportable = require ( '@lykmapipo/mongoose-exportable' ) ;
14
14
const moment = require ( 'moment' ) ;
15
15
const predefine = require ( '@lykmapipo/predefine' ) ;
16
- const eweaEvent = require ( '@codetanzania/ewea-event' ) ;
17
16
const eweaCommon = require ( '@codetanzania/ewea-common' ) ;
17
+ const eweaEvent = require ( '@codetanzania/ewea-event' ) ;
18
18
require ( 'mongoose-geojson-schemas' ) ;
19
19
const emisStakeholder = require ( '@codetanzania/emis-stakeholder' ) ;
20
20
@@ -197,6 +197,94 @@ const event = {
197
197
default : undefined ,
198
198
} ;
199
199
200
+ /**
201
+ * @name stage
202
+ * @description Currently assigned stage of a case.
203
+ *
204
+ * @memberof Case
205
+ *
206
+ * @type {object }
207
+ * @property {object } type - schema(data) type
208
+ * @property {boolean } required - mark required
209
+ * @property {boolean } index - ensure database index
210
+ * @property {boolean } exists - ensure ref exists before save
211
+ * @property {object } autopopulate - auto populate(eager loading) options
212
+ * @property {boolean } taggable - allow field use for tagging
213
+ * @property {boolean } exportable - allow field use for exporting
214
+ * @property {boolean } aggregatable - allow field use for aggregation
215
+ * @property {boolean } default - default value set when none provided
216
+ * @property {object } fake - fake data generator options
217
+ *
218
+ * @author lally elias <lallyelias87@gmail.com>
219
+ * @since 0.4.0
220
+ * @version 0.1.0
221
+ * @instance
222
+ * @example
223
+ * {
224
+ * _id: '5dde6ca23631a92c2d616250',
225
+ * strings: { name: { en: 'Confirmed' } },
226
+ * }
227
+ */
228
+ const stage = {
229
+ type : mongooseCommon . ObjectId ,
230
+ ref : predefine . Predefine . MODEL_NAME ,
231
+ // required: true,
232
+ index : true ,
233
+ exists : true ,
234
+ aggregatable : { unwind : true } ,
235
+ autopopulate : AUTOPOPULATE_OPTION_PREDEFINE ,
236
+ taggable : true ,
237
+ exportable : {
238
+ format : ( v ) => lodash . get ( v , 'strings.name.en' ) ,
239
+ default : 'NA' ,
240
+ } ,
241
+ default : eweaCommon . DEFAULT_SEEDS . CaseStage ,
242
+ } ;
243
+
244
+ /**
245
+ * @name severity
246
+ * @description Currently assigned severity of a case.
247
+ *
248
+ * @memberof Case
249
+ *
250
+ * @type {object }
251
+ * @property {object } type - schema(data) type
252
+ * @property {boolean } required - mark required
253
+ * @property {boolean } index - ensure database index
254
+ * @property {boolean } exists - ensure ref exists before save
255
+ * @property {object } autopopulate - auto populate(eager loading) options
256
+ * @property {boolean } taggable - allow field use for tagging
257
+ * @property {boolean } exportable - allow field use for exporting
258
+ * @property {boolean } aggregatable - allow field use for aggregation
259
+ * @property {boolean } default - default value set when none provided
260
+ * @property {object } fake - fake data generator options
261
+ *
262
+ * @author lally elias <lallyelias87@gmail.com>
263
+ * @since 0.4.0
264
+ * @version 0.1.0
265
+ * @instance
266
+ * @example
267
+ * {
268
+ * _id: '5dde6ca23631a92c2d616250',
269
+ * strings: { name: { en: 'Extreme' } },
270
+ * }
271
+ */
272
+ const severity = {
273
+ type : mongooseCommon . ObjectId ,
274
+ ref : predefine . Predefine . MODEL_NAME ,
275
+ // required: true,
276
+ index : true ,
277
+ exists : true ,
278
+ aggregatable : { unwind : true } ,
279
+ autopopulate : AUTOPOPULATE_OPTION_PREDEFINE ,
280
+ taggable : true ,
281
+ exportable : {
282
+ format : ( v ) => lodash . get ( v , 'strings.name.en' ) ,
283
+ default : 'NA' ,
284
+ } ,
285
+ default : eweaCommon . DEFAULT_SEEDS . CaseSeverity ,
286
+ } ;
287
+
200
288
/**
201
289
* @name number
202
290
* @description Human readable, unique identifier of a case.
@@ -1133,6 +1221,7 @@ const followup = mongooseCommon.createSubSchema({
1133
1221
1134
1222
const SCHEMA = common . mergeObjects (
1135
1223
{ number } ,
1224
+ { stage, severity } ,
1136
1225
{ victim } ,
1137
1226
{ description } ,
1138
1227
{ reportedAt, reporter } ,
0 commit comments