Skip to content

Commit 2e49470

Browse files
committed
feat(model): add email to victim & next of kin
1 parent 514ea42 commit 2e49470

File tree

2 files changed

+77
-21
lines changed

2 files changed

+77
-21
lines changed

src/schema/common.schema.js

+49-21
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export const properties = {
5252
*
5353
* @property {object} type - schema(data) type
5454
* @property {boolean} trim - force trimming
55+
* @property {boolean} startcase - ensure start case(or title case)
5556
* @property {boolean} index - ensure database index
5657
* @property {boolean} searchable - allow for searching
5758
* @property {boolean} taggable - allow field use for tagging
@@ -68,6 +69,7 @@ export const properties = {
6869
export const name = {
6970
type: String,
7071
trim: true,
72+
startcase: true,
7173
index: true,
7274
searchable: true,
7375
taggable: true,
@@ -152,7 +154,7 @@ export const score = {
152154
};
153155

154156
/**
155-
* @name phone
157+
* @name mobile
156158
* @description A mobile phone number of the party(i.e individual).
157159
*
158160
* @property {object} type - schema(data) type
@@ -177,7 +179,39 @@ export const mobile = {
177179
searchable: true,
178180
taggable: true,
179181
exportable: true,
180-
fake: (faker) => faker.helpers.replaceSymbolWithNumber('255714######'),
182+
fake: (f) => f.helpers.replaceSymbolWithNumber('255714######'),
183+
};
184+
185+
/**
186+
* @name email
187+
* @description Email address of the party(i.e individual).
188+
*
189+
* @type {object}
190+
* @property {object} type - schema(data) type
191+
* @property {boolean} trim - force trimming
192+
* @property {boolean} lowercase - force lower-casing
193+
* @property {boolean} email - force to be a valid email address
194+
* @property {boolean} index - ensure database index
195+
* @property {boolean} searchable - allow for searching
196+
* @property {boolean} taggable - allow field use for tagging
197+
* @property {object} fake - fake data generator options
198+
*
199+
* @since 0.1.0
200+
* @version 0.1.0
201+
* @instance
202+
* @example
203+
* jane.doe@example.com
204+
*/
205+
export const email = {
206+
type: String,
207+
trim: true,
208+
lowercase: true,
209+
email: true,
210+
index: true,
211+
searchable: true,
212+
taggable: true,
213+
exportable: true,
214+
fake: (f) => f.internet.email(),
181215
};
182216

183217
/**
@@ -503,12 +537,9 @@ export const nationality = {
503537
* @description A party who closest to a victim.
504538
*
505539
* @type {object}
506-
* @property {string} name - Full name of the nextOfKin
507-
* @property {string} mobile - Mobile phone number of the nextOfKin
508-
* @property {object} facility - Facility of the nextOfKin
509-
* @property {object} area - Administrative area of the nextOfKin
510-
* @property {object} location - Geo-point of the nextOfKin
511-
* @property {string} address - Address of the nextOfKin
540+
* @property {string} name - Full name of the next of kin
541+
* @property {string} mobile - Mobile phone number of the next of kin
542+
* @property {string} email - Email address of the victim
512543
*
513544
* @author lally elias <lallyelias87@gmail.com>
514545
* @since 0.1.0
@@ -518,11 +549,13 @@ export const nationality = {
518549
* {
519550
* name: "Jane Doe",
520551
* mobile: "+255715463739"
552+
* email: "jane.doe@example.com"
521553
* }
522554
*/
523555
export const nextOfKin = createSubSchema({
524556
name,
525557
mobile,
558+
email,
526559
});
527560

528561
/**
@@ -534,6 +567,7 @@ export const nextOfKin = createSubSchema({
534567
* @property {string} pcr - Valid patient care number
535568
* @property {string} name - Full name of the victim
536569
* @property {string} mobile - Mobile phone number of the victim
570+
* @property {string} email - Email address of the victim
537571
* @property {object} gender - Gender of the victim
538572
* @property {number} age - Age of the victim
539573
* @property {number} weight - Weight of the victim
@@ -551,6 +585,7 @@ export const nextOfKin = createSubSchema({
551585
* pcr: "PTN-8687",
552586
* name: "Jane Doe",
553587
* mobile: "+255715463739",
588+
* email: "jane.doe@example.com",
554589
* gender: { name: { en: "Female"} },
555590
* age: 23,
556591
* weight: 53,
@@ -566,6 +601,7 @@ export const victim = createSubSchema({
566601
pcr,
567602
name,
568603
mobile,
604+
email,
569605
gender,
570606
age,
571607
// dob
@@ -578,20 +614,12 @@ export const victim = createSubSchema({
578614
});
579615

580616
/**
581-
* @name victim
582-
* @description A party(i.e patient or victim) whom a case is for.
617+
* @name followup
618+
* @description A party(i.e doctor or nurse) who followed case victim.
583619
*
584620
* @type {object}
585-
* @property {string} referral - Valid referral number
586-
* @property {string} pcr - Valid patient care number
587-
* @property {string} name - Full name of the victim
588-
* @property {string} mobile - Mobile phone number of the victim
589-
* @property {object} gender - Gender of the victim
590-
* @property {number} age - Age of the victim
591-
* @property {number} weight - Weight of the victim
592-
* @property {object} occupation - Occupation of the victim
593-
* @property {object} nationality - Nationality of the victim
594-
* @property {string} address - Address of the victim
621+
* @property {object} follower - Following party
622+
* @property {Date} followedAt - Latest date followed
595623
*
596624
* @author lally elias <lallyelias87@gmail.com>
597625
* @since 0.1.0
@@ -610,7 +638,7 @@ export const followup = createSubSchema({
610638
follower,
611639
followedAt,
612640
symptoms: properties,
613-
score,
641+
score, // TODO: systemScore vs followerScore
614642
outcome,
615643
remarks,
616644
});

test/unit/case.schema.spec.js

+28
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,13 @@ describe('Case Schema', () => {
6969
const pcr = Case.path('victim.pcr');
7070
const name = Case.path('victim.name');
7171
const mobile = Case.path('victim.mobile');
72+
const email = Case.path('victim.email');
7273
const gender = Case.path('victim.gender');
7374
const occupation = Case.path('victim.occupation');
7475
const nationality = Case.path('victim.nationality');
7576
const nextOfKinName = Case.path('victim.nextOfKin.name');
7677
const nextOfKinMobile = Case.path('victim.nextOfKin.mobile');
78+
const nextOfKinEmail = Case.path('victim.nextOfKin.email');
7779

7880
expect(victim).to.exist;
7981
expect(victim).to.be.an.instanceof(SchemaTypes.Embedded);
@@ -126,6 +128,19 @@ describe('Case Schema', () => {
126128
expect(mobile.options.exportable).to.be.true;
127129
expect(mobile.options.fake).to.exist;
128130

131+
expect(email).to.exist;
132+
expect(email).to.be.instanceof(SchemaTypes.String);
133+
expect(email.options).to.exist;
134+
expect(email.options).to.be.an('object');
135+
expect(email.options.type).to.exist;
136+
expect(email.options.trim).to.be.true;
137+
expect(email.options.email).to.be.true;
138+
expect(email.options.index).to.be.true;
139+
expect(email.options.searchable).to.be.true;
140+
expect(email.options.taggable).to.be.true;
141+
expect(email.options.exportable).to.be.true;
142+
expect(email.options.fake).to.exist;
143+
129144
expect(gender).to.exist;
130145
expect(gender).to.be.instanceof(SchemaTypes.ObjectId);
131146
expect(gender.options).to.exist;
@@ -197,6 +212,19 @@ describe('Case Schema', () => {
197212
expect(nextOfKinMobile.options.taggable).to.be.true;
198213
expect(nextOfKinMobile.options.exportable).to.be.true;
199214
expect(nextOfKinMobile.options.fake).to.exist;
215+
216+
expect(nextOfKinEmail).to.exist;
217+
expect(nextOfKinEmail).to.be.instanceof(SchemaTypes.String);
218+
expect(nextOfKinEmail.options).to.exist;
219+
expect(nextOfKinEmail.options).to.be.an('object');
220+
expect(nextOfKinEmail.options.type).to.exist;
221+
expect(nextOfKinEmail.options.trim).to.be.true;
222+
expect(nextOfKinEmail.options.email).to.be.true;
223+
expect(nextOfKinEmail.options.index).to.be.true;
224+
expect(nextOfKinEmail.options.searchable).to.be.true;
225+
expect(nextOfKinEmail.options.taggable).to.be.true;
226+
expect(nextOfKinEmail.options.exportable).to.be.true;
227+
expect(nextOfKinEmail.options.fake).to.exist;
200228
});
201229

202230
it('should have description field', () => {

0 commit comments

Comments
 (0)