1
- import { COLLECTION_NAME_CASE , POPULATION_MAX_DEPTH , MODEL_NAME_CASE } from '@codetanzania/ewea-internals' ;
1
+ import { COLLECTION_NAME_CASE , POPULATION_MAX_DEPTH , PREDEFINE_NAMESPACE_ADMINISTRATIVEAREA , PREDEFINE_NAMESPACE_PARTYGENDER , PREDEFINE_NAMESPACE_PARTYOCCUPATION , PREDEFINE_NAMESPACE_PARTYNATIONALITY , MODEL_NAME_CASE } from '@codetanzania/ewea-internals' ;
2
2
import { compact , mergeObjects , idOf , pkg } from '@lykmapipo/common' ;
3
3
import { getString , apiVersion as apiVersion$1 } from '@lykmapipo/env' ;
4
4
import { ObjectId , createSubSchema , model , createSchema , copyInstance , connect } from '@lykmapipo/mongoose-common' ;
@@ -12,6 +12,7 @@ import exportable from '@lykmapipo/mongoose-exportable';
12
12
import moment from 'moment' ;
13
13
import { Predefine } from '@lykmapipo/predefine' ;
14
14
import { Event } from '@codetanzania/ewea-event' ;
15
+ import { DEFAULT_SEEDS } from '@codetanzania/ewea-common' ;
15
16
import 'mongoose-geojson-schemas' ;
16
17
import { Party } from '@codetanzania/emis-stakeholder' ;
17
18
@@ -565,6 +566,7 @@ const area = {
565
566
order : 3 ,
566
567
default : 'NA' ,
567
568
} ,
569
+ default : DEFAULT_SEEDS [ PREDEFINE_NAMESPACE_ADMINISTRATIVEAREA ] ,
568
570
} ;
569
571
570
572
/**
@@ -618,7 +620,7 @@ const facility = {
618
620
* @property {boolean } taggable - allow field use for tagging
619
621
* @property {boolean } default - default value set when none provided
620
622
*
621
- * @since 2.6 .0
623
+ * @since 0.1 .0
622
624
* @version 0.1.0
623
625
* @instance
624
626
* @example
@@ -642,7 +644,7 @@ const gender = {
642
644
order : 2 ,
643
645
default : 'NA' ,
644
646
} ,
645
- default : undefined ,
647
+ default : DEFAULT_SEEDS [ PREDEFINE_NAMESPACE_PARTYGENDER ] ,
646
648
} ;
647
649
648
650
/**
@@ -658,7 +660,7 @@ const gender = {
658
660
* @property {boolean } taggable - allow field use for tagging
659
661
* @property {boolean } default - default value set when none provided
660
662
*
661
- * @since 2.6 .0
663
+ * @since 0.1 .0
662
664
* @version 0.1.0
663
665
* @instance
664
666
* @example
@@ -682,7 +684,47 @@ const occupation = {
682
684
order : 2 ,
683
685
default : 'NA' ,
684
686
} ,
685
- default : undefined ,
687
+ default : DEFAULT_SEEDS [ PREDEFINE_NAMESPACE_PARTYOCCUPATION ] ,
688
+ } ;
689
+
690
+ /**
691
+ * @name nationality
692
+ * @description Assignable or given nationality to a party.
693
+ *
694
+ * @type {object }
695
+ * @property {object } type - schema(data) type
696
+ * @property {string } ref - referenced collection
697
+ * @property {boolean } index - ensure database index
698
+ * @property {boolean } exists - ensure ref exists before save
699
+ * @property {object } autopopulate - population options
700
+ * @property {boolean } taggable - allow field use for tagging
701
+ * @property {boolean } default - default value set when none provided
702
+ *
703
+ * @since 0.2.0
704
+ * @version 0.1.0
705
+ * @instance
706
+ * @example
707
+ * {
708
+ * "name": { "en" : "Tanzanian" }
709
+ * }
710
+ */
711
+ const nationality = {
712
+ type : ObjectId ,
713
+ ref : Predefine . MODEL_NAME ,
714
+ index : true ,
715
+ exists : true ,
716
+ aggregatable : { unwind : true } ,
717
+ autopopulate : AUTOPOPULATE_OPTION_PREDEFINE ,
718
+ taggable : true ,
719
+ exportable : {
720
+ header : 'Nationality' ,
721
+ format : ( v ) => {
722
+ return v && v . strings && compact ( [ v . strings . name . en ] ) . join ( ' - ' ) ;
723
+ } ,
724
+ order : 2 ,
725
+ default : 'NA' ,
726
+ } ,
727
+ default : DEFAULT_SEEDS [ PREDEFINE_NAMESPACE_PARTYNATIONALITY ] ,
686
728
} ;
687
729
688
730
/**
@@ -724,11 +766,13 @@ const nextOfKin = createSubSchema({
724
766
* @property {object } gender - Gender of the victim
725
767
* @property {number } age - Age of the victim
726
768
* @property {number } weight - Weight of the victim
769
+ * @property {object } occupation - Occupation of the victim
770
+ * @property {object } nationality - Nationality of the victim
727
771
* @property {string } address - Address of the victim
728
772
*
729
773
* @author lally elias <lallyelias87@gmail.com>
730
774
* @since 0.1.0
731
- * @version 0.1 .0
775
+ * @version 0.2 .0
732
776
* @instance
733
777
* @example
734
778
* {
@@ -739,6 +783,8 @@ const nextOfKin = createSubSchema({
739
783
* gender: { name: { en: "Female"} },
740
784
* age: 23,
741
785
* weight: 53,
786
+ * occupation: { name: { en: "Businessman"} },
787
+ * nationality: { name: { en: "Tanzanian"} },
742
788
* address: "Tandale",
743
789
* area: { name: { en: "Dar es Salaam"} },
744
790
* nextOfKin: { name: "Halima Mdoe", mobile: "+255715463740" }
@@ -750,10 +796,11 @@ const victim = createSubSchema({
750
796
name,
751
797
mobile,
752
798
gender,
753
- occupation,
754
799
age,
755
800
// dob
756
801
weight,
802
+ occupation,
803
+ nationality,
757
804
address,
758
805
area,
759
806
nextOfKin,
0 commit comments