1
1
import { COLLECTION_NAME_CASE , POPULATION_MAX_DEPTH , PREDEFINE_NAMESPACE_CASESTAGE , PREDEFINE_NAMESPACE_CASESEVERITY , PREDEFINE_NAMESPACE_ADMINISTRATIVEAREA , PREDEFINE_NAMESPACE_PARTYGENDER , PREDEFINE_NAMESPACE_PARTYOCCUPATION , PREDEFINE_NAMESPACE_PARTYNATIONALITY , MODEL_NAME_CASE , DEFAULT_SEEDS as DEFAULT_SEEDS$1 } from '@codetanzania/ewea-internals' ;
2
2
import { compact , mergeObjects , idOf , pkg } from '@lykmapipo/common' ;
3
- import { getString , apiVersion as apiVersion$1 } from '@lykmapipo/env' ;
3
+ import { getString , getStrings , apiVersion as apiVersion$1 } from '@lykmapipo/env' ;
4
4
import { ObjectId , createSubSchema , Mixed , model , createSchema , copyInstance , connect } from '@lykmapipo/mongoose-common' ;
5
5
import { mount } from '@lykmapipo/express-common' ;
6
6
import { Router , getFor , schemaFor , downloadFor , postFor , getByIdFor , patchFor , putFor , deleteFor , start as start$1 } from '@lykmapipo/express-rest-actions' ;
@@ -669,6 +669,9 @@ const followedAt = {
669
669
} ,
670
670
} ;
671
671
672
+ const DEFAULT_LOCALE = getString ( 'DEFAULT_LOCALE' , 'en' ) ;
673
+ const LOCALES = getStrings ( 'LOCALES' , DEFAULT_LOCALE ) ;
674
+
672
675
/**
673
676
* @name properties
674
677
* @description A map of key value pairs to allow to associate
@@ -695,13 +698,48 @@ const properties = {
695
698
fake : ( f ) => f . helpers . createTransaction ( ) ,
696
699
} ;
697
700
701
+ /**
702
+ * @name locale
703
+ * @description Defines the party's language, region and any
704
+ * special variant preferences.
705
+ *
706
+ * @see {@link https://en.wikipedia.org/wiki/Locale_(computer_software) }
707
+ *
708
+ * @type {object }
709
+ * @property {object } type - schema(data) type
710
+ * @property {boolean } trim - force trimming
711
+ * @property {boolean } enum - list of acceptable values
712
+ * @property {boolean } index - ensure database index
713
+ * @property {boolean } searchable - allow for searching
714
+ * @property {boolean } taggable - allow field use for tagging
715
+ * @property {boolean } default - default value set when none provided
716
+ * @property {object } fake - fake data generator options
717
+ *
718
+ * @since 0.1.0
719
+ * @version 0.1.0
720
+ * @instance
721
+ * @example
722
+ * en
723
+ */
724
+ const locale = {
725
+ type : String ,
726
+ trim : true ,
727
+ enum : LOCALES ,
728
+ index : true ,
729
+ searchable : true ,
730
+ taggable : true ,
731
+ default : DEFAULT_LOCALE ,
732
+ fake : true ,
733
+ } ;
734
+
698
735
/**
699
736
* @name name
700
737
* @description Full name name of the party(i.e individual).
701
738
*
702
739
*
703
740
* @property {object } type - schema(data) type
704
741
* @property {boolean } trim - force trimming
742
+ * @property {boolean } startcase - ensure start case(or title case)
705
743
* @property {boolean } index - ensure database index
706
744
* @property {boolean } searchable - allow for searching
707
745
* @property {boolean } taggable - allow field use for tagging
@@ -718,6 +756,7 @@ const properties = {
718
756
const name = {
719
757
type : String ,
720
758
trim : true ,
759
+ startcase : true ,
721
760
index : true ,
722
761
searchable : true ,
723
762
taggable : true ,
@@ -802,7 +841,7 @@ const score = {
802
841
} ;
803
842
804
843
/**
805
- * @name phone
844
+ * @name mobile
806
845
* @description A mobile phone number of the party(i.e individual).
807
846
*
808
847
* @property {object } type - schema(data) type
@@ -827,7 +866,39 @@ const mobile = {
827
866
searchable : true ,
828
867
taggable : true ,
829
868
exportable : true ,
830
- fake : ( faker ) => faker . helpers . replaceSymbolWithNumber ( '255714######' ) ,
869
+ fake : ( f ) => f . helpers . replaceSymbolWithNumber ( '255714######' ) ,
870
+ } ;
871
+
872
+ /**
873
+ * @name email
874
+ * @description Email address of the party(i.e individual).
875
+ *
876
+ * @type {object }
877
+ * @property {object } type - schema(data) type
878
+ * @property {boolean } trim - force trimming
879
+ * @property {boolean } lowercase - force lower-casing
880
+ * @property {boolean } email - force to be a valid email address
881
+ * @property {boolean } index - ensure database index
882
+ * @property {boolean } searchable - allow for searching
883
+ * @property {boolean } taggable - allow field use for tagging
884
+ * @property {object } fake - fake data generator options
885
+ *
886
+ * @since 0.1.0
887
+ * @version 0.1.0
888
+ * @instance
889
+ * @example
890
+ * jane.doe@example.com
891
+ */
892
+ const email = {
893
+ type : String ,
894
+ trim : true ,
895
+ lowercase : true ,
896
+ email : true ,
897
+ index : true ,
898
+ searchable : true ,
899
+ taggable : true ,
900
+ exportable : true ,
901
+ fake : ( f ) => f . internet . email ( ) ,
831
902
} ;
832
903
833
904
/**
@@ -1131,12 +1202,10 @@ const nationality = {
1131
1202
* @description A party who closest to a victim.
1132
1203
*
1133
1204
* @type {object }
1134
- * @property {string } name - Full name of the nextOfKin
1135
- * @property {string } mobile - Mobile phone number of the nextOfKin
1136
- * @property {object } facility - Facility of the nextOfKin
1137
- * @property {object } area - Administrative area of the nextOfKin
1138
- * @property {object } location - Geo-point of the nextOfKin
1139
- * @property {string } address - Address of the nextOfKin
1205
+ * @property {string } name - Full name of the next of kin
1206
+ * @property {string } mobile - Mobile phone number of the next of kin
1207
+ * @property {string } email - Email address of the next of kin
1208
+ * @property {string } locale - Locale of the next of kin
1140
1209
*
1141
1210
* @author lally elias <lallyelias87@gmail.com>
1142
1211
* @since 0.1.0
@@ -1146,11 +1215,16 @@ const nationality = {
1146
1215
* {
1147
1216
* name: "Jane Doe",
1148
1217
* mobile: "+255715463739"
1218
+ * email: "jane.doe@example .com"
1219
+ * locale: "en"
1149
1220
* }
1150
1221
*/
1151
1222
const nextOfKin = createSubSchema ( {
1152
1223
name,
1153
1224
mobile,
1225
+ email,
1226
+ locale,
1227
+ // csids,
1154
1228
} ) ;
1155
1229
1156
1230
/**
@@ -1162,12 +1236,14 @@ const nextOfKin = createSubSchema({
1162
1236
* @property {string } pcr - Valid patient care number
1163
1237
* @property {string } name - Full name of the victim
1164
1238
* @property {string } mobile - Mobile phone number of the victim
1239
+ * @property {string } email - Email address of the victim
1165
1240
* @property {object } gender - Gender of the victim
1166
1241
* @property {number } age - Age of the victim
1167
1242
* @property {number } weight - Weight of the victim
1168
1243
* @property {object } occupation - Occupation of the victim
1169
1244
* @property {object } nationality - Nationality of the victim
1170
1245
* @property {string } address - Address of the victim
1246
+ * @property {string } locale - Locale of the victim
1171
1247
*
1172
1248
* @author lally elias <lallyelias87@gmail.com>
1173
1249
* @since 0.1.0
@@ -1179,13 +1255,15 @@ const nextOfKin = createSubSchema({
1179
1255
* pcr: "PTN-8687",
1180
1256
* name: "Jane Doe",
1181
1257
* mobile: "+255715463739",
1258
+ * email: "jane.doe@example .com",
1182
1259
* gender: { name: { en: "Female"} },
1183
1260
* age: 23,
1184
1261
* weight: 53,
1185
1262
* occupation: { name: { en: "Businessman"} },
1186
1263
* nationality: { name: { en: "Tanzanian"} },
1187
1264
* address: "Tandale",
1188
1265
* area: { name: { en: "Dar es Salaam"} },
1266
+ * locale: "en",
1189
1267
* nextOfKin: { name: "Halima Mdoe", mobile: "+255715463740" }
1190
1268
* }
1191
1269
*/
@@ -1194,6 +1272,7 @@ const victim = createSubSchema({
1194
1272
pcr,
1195
1273
name,
1196
1274
mobile,
1275
+ email,
1197
1276
gender,
1198
1277
age,
1199
1278
// dob
@@ -1202,24 +1281,18 @@ const victim = createSubSchema({
1202
1281
nationality,
1203
1282
address,
1204
1283
area,
1284
+ locale,
1205
1285
nextOfKin,
1286
+ // csids.
1206
1287
} ) ;
1207
1288
1208
1289
/**
1209
- * @name victim
1210
- * @description A party(i.e patient or victim) whom a case is for .
1290
+ * @name followup
1291
+ * @description A party(i.e doctor or nurse) who followed case victim .
1211
1292
*
1212
1293
* @type {object }
1213
- * @property {string } referral - Valid referral number
1214
- * @property {string } pcr - Valid patient care number
1215
- * @property {string } name - Full name of the victim
1216
- * @property {string } mobile - Mobile phone number of the victim
1217
- * @property {object } gender - Gender of the victim
1218
- * @property {number } age - Age of the victim
1219
- * @property {number } weight - Weight of the victim
1220
- * @property {object } occupation - Occupation of the victim
1221
- * @property {object } nationality - Nationality of the victim
1222
- * @property {string } address - Address of the victim
1294
+ * @property {object } follower - Following party
1295
+ * @property {Date } followedAt - Latest date followed
1223
1296
*
1224
1297
* @author lally elias <lallyelias87@gmail.com>
1225
1298
* @since 0.1.0
@@ -1238,7 +1311,7 @@ const followup = createSubSchema({
1238
1311
follower,
1239
1312
followedAt,
1240
1313
symptoms : properties ,
1241
- score,
1314
+ score, // TODO: systemScore vs followerScore
1242
1315
outcome,
1243
1316
remarks,
1244
1317
} ) ;
0 commit comments