From de2ebe8193697dc53703c316906ab2506a7d873b Mon Sep 17 00:00:00 2001 From: Naod Yeheyes Date: Sun, 12 Apr 2020 15:33:37 -0400 Subject: [PATCH] #19: Updated Address Schema and #18: Updated field inconsistencies. --- models/Address.js | 16 ++++++++++ models/Community.js | 19 +++++------- models/MedicalFacility.js | 33 +++++++++------------ models/Passenger.js | 33 +++++++++++---------- models/Surveillance.js | 32 +++++++++----------- models/Symptom.js | 15 ++++++++++ models/TollFree.js | 62 +++++++-------------------------------- 7 files changed, 95 insertions(+), 115 deletions(-) create mode 100644 models/Address.js create mode 100644 models/Symptom.js diff --git a/models/Address.js b/models/Address.js new file mode 100644 index 0000000..3a22ca4 --- /dev/null +++ b/models/Address.js @@ -0,0 +1,16 @@ +const mongoose = require('mongoose'); +const Schema = mongoose.Schema; + +const AddressSchema = new Schema({ + country: { type: String, required: true, max: 100 }, + region: { type: String, max: 100 }, + city: { type: String, max: 100 }, + postalCode: { type: String, max: 100 }, + street: { type: String, max: 100 }, + building: { type: String, max: 100 }, + customField1: { type: String, max: 100 }, + customField2: { type: String, max: 100 }, +}); + +// Export the model +module.exports = mongoose.model('Address', AddressSchema); diff --git a/models/Community.js b/models/Community.js index 1b3232d..3ad6fd9 100644 --- a/models/Community.js +++ b/models/Community.js @@ -1,6 +1,9 @@ const mongoose = require('mongoose'); const Schema = mongoose.Schema; +const AddressModel = require('./Address'); +const SymptomModel = require('./Symptom'); + const CommunitySchema = new Schema( { firstName: { type: String, required: true, max: 100 }, @@ -9,26 +12,18 @@ const CommunitySchema = new Schema( age: { type: Number, required: true }, sex: { type: String, required: true }, language: { type: String }, - region: { type: String }, - subcityOrZone: { type: String }, - sefer: { type: String }, - woreda: { type: String }, - kebele: { type: String }, - houseNumber: { type: String }, + address: { type: AddressModel.schema }, + symptom: { type: SymptomModel.schema }, phoneNumber: { type: String }, latitude: { type: Number }, longitude: { type: Number }, - fever: { type: Boolean }, - cough: { type: Boolean }, - shortnessOfBreath: { type: Boolean }, formStatus: { type: String }, travelHx: { type: Boolean }, - haveSex: { type: Boolean }, - animalMarket: { type: Boolean }, + contactWithSuspected: { type: Boolean }, + contactWithConfirmed: { type: Boolean }, healthFacility: { type: Boolean }, occupation: { type: String }, dataSource: { type: String }, - fatigue: { type: Boolean }, underlyingConditions: { chronicLungDisease: { type: Boolean }, heartDisease: { type: Boolean }, diff --git a/models/MedicalFacility.js b/models/MedicalFacility.js index 4a40a24..3430b4f 100644 --- a/models/MedicalFacility.js +++ b/models/MedicalFacility.js @@ -1,40 +1,35 @@ const mongoose = require('mongoose'); const Schema = mongoose.Schema; +const AddressModel = require('./Address'); +const SymptomModel = require('./Symptom'); + const MedicalFacilitySchema = new Schema( { firstName: { type: String, required: true, max: 100 }, middleName: { type: String, max: 100 }, lastName: { type: String, required: true, max: 100 }, nationality: { type: String }, - email: { type: String }, - sex: { type: String }, - age: { type: Number }, - region: { type: String }, - subcity: { type: String }, - zone: { type: String }, - woreda: { type: String }, - kebele: { type: String }, - houseNumber: { type: String }, + email: { + type: String, + lowercase: true, + match: [/\S+@\S+\.\S+/, 'is invalid'], + }, + age: { type: Number, required: true }, + sex: { type: String, required: true }, + address: { type: AddressModel.schema }, + symptom: { type: SymptomModel.schema }, phoneNumber: { type: String }, occupation: { type: String }, callDate: { type: Date }, callerType: { type: String }, - fever: { type: Boolean }, - cough: { type: Boolean }, - headache: { type: Boolean }, - runnyNose: { type: Boolean }, - feelingUnwell: { type: Boolean }, - shortnessOfBreath: { type: Boolean }, - bodyPain: { type: Boolean }, travelHx: { type: Boolean }, - haveSex: { type: Boolean }, - animalMarket: { type: Boolean }, + contactWithSuspected: { type: Boolean }, + contactWithConfirmed: { type: Boolean }, healthFacility: { type: Boolean }, receiverName: { type: String }, source: { type: String }, formStatus: { type: String }, - fatigue: { type: Boolean }, underlyingConditions: { chronicLungDisease: { type: Boolean }, heartDisease: { type: Boolean }, diff --git a/models/Passenger.js b/models/Passenger.js index a6c7c2a..ce6ffa4 100644 --- a/models/Passenger.js +++ b/models/Passenger.js @@ -1,12 +1,16 @@ const mongoose = require('mongoose'); const Schema = mongoose.Schema; +const AddressModel = require('./Address'); +const SymptomModel = require('./Symptom'); + const PassengerSchema = new Schema( { firstName: { type: String, required: true, max: 100 }, middleName: { type: String, max: 100 }, lastName: { type: String, required: true, max: 100 }, - gender: { type: String }, + age: { type: Number, required: true }, + sex: { type: String, required: true }, dateOfBirth: { type: Date }, nationality: { type: String }, passportNo: { type: String }, @@ -16,27 +20,30 @@ const PassengerSchema = new Schema( flightNumber: { type: String }, seatNumber: { type: String }, transitFrom: { type: String }, - fever: { type: Boolean }, - shortnessOfBreath: { type: Boolean }, - cough: { type: Boolean }, + address: { type: AddressModel.schema }, + symptom: { type: SymptomModel.schema }, + contactWithSuspected: { type: Boolean }, + contactWithConfirmed: { type: Boolean }, dependents: [ { - firstName: { type: String, max: 100 }, + firstName: { type: String, required: true, max: 100 }, middleName: { type: String, max: 100 }, - lastName: { type: String, max: 100 }, - gender: { type: String }, + lastName: { type: String, required: true, max: 100 }, + age: { type: Number, required: true }, + sex: { type: String, required: true }, dateOfBirth: { type: Date }, nationality: { type: String }, passportNo: { type: String }, seatNumber: { type: String }, - fever: { type: Boolean }, - shortnessOfBreath: { type: Boolean }, - cough: { type: Boolean }, + address: { type: AddressModel.schema }, + symptom: { type: SymptomModel.schema }, travelFrom: { type: String }, transitFrom: { type: String }, phoneNumber: { type: String }, flightNumber: { type: String }, - selectedLanguage: { type: String }, + language: { type: String }, + contactWithSuspected: { type: Boolean }, + contactWithConfirmed: { type: Boolean }, }, ], otherHotelName: { type: String }, @@ -46,7 +53,6 @@ const PassengerSchema = new Schema( match: [/\S+@\S+\.\S+/, 'is invalid'], }, language: { type: String }, - fatigue: { type: Boolean }, underlyingConditions: { chronicLungDisease: { type: Boolean }, heartDisease: { type: Boolean }, @@ -58,9 +64,6 @@ const PassengerSchema = new Schema( hiv: { type: Boolean }, pregnancy: { type: Boolean }, }, - haveSex: { type: Boolean }, - animalMarket: { type: Boolean }, - healthFacility: { type: Boolean }, }, { timestamps: true, diff --git a/models/Surveillance.js b/models/Surveillance.js index f6e2d1a..0839184 100644 --- a/models/Surveillance.js +++ b/models/Surveillance.js @@ -1,35 +1,31 @@ const mongoose = require('mongoose'); const Schema = mongoose.Schema; +const AddressModel = require('./Address'); +const SymptomModel = require('./Symptom'); + const SurveillanceSchema = new Schema( { firstName: { type: String, required: true, max: 100 }, middleName: { type: String, max: 100 }, lastName: { type: String, required: true, max: 100 }, nationality: { type: String }, - email: { type: String }, - sex: { type: String }, - age: { type: Number }, - region: { type: String }, - subcity: { type: String }, - zone: { type: String }, - woreda: { type: String }, - kebele: { type: String }, - houseNumber: { type: String }, + email: { + type: String, + lowercase: true, + match: [/\S+@\S+\.\S+/, 'is invalid'], + }, + age: { type: Number, required: true }, + sex: { type: String, required: true }, + address: { type: AddressModel.schema }, + symptom: { type: SymptomModel.schema }, phoneNumber: { type: String }, occupation: { type: String }, callDate: { type: Date }, callerType: { type: String }, - fever: { type: Boolean }, - cough: { type: Boolean }, - headache: { type: Boolean }, - runnyNose: { type: Boolean }, - feelingUnwell: { type: Boolean }, - shortnessOfBreath: { type: Boolean }, - bodyPain: { type: Boolean }, travelHx: { type: Boolean }, - haveSex: { type: Boolean }, - animalMarket: { type: Boolean }, + contactWithSuspected: { type: Boolean }, + contactWithConfirmed: { type: Boolean }, healthFacility: { type: Boolean }, receiverName: { type: String }, source: { type: String }, diff --git a/models/Symptom.js b/models/Symptom.js new file mode 100644 index 0000000..8972266 --- /dev/null +++ b/models/Symptom.js @@ -0,0 +1,15 @@ +const mongoose = require('mongoose'); +const Schema = mongoose.Schema; + +const SymptomSchema = new Schema({ + fever: { type: Boolean }, + cough: { type: Boolean }, + shortnessOfBreath: { type: Boolean }, + fatigue: { type: Boolean }, + headache: { type: Boolean }, + runnyNose: { type: Boolean }, + feelingUnwell: { type: Boolean }, +}); + +// Export the model +module.exports = mongoose.model('Symptom', SymptomSchema); diff --git a/models/TollFree.js b/models/TollFree.js index 5d90deb..1cec6e7 100644 --- a/models/TollFree.js +++ b/models/TollFree.js @@ -1,70 +1,30 @@ const mongoose = require('mongoose'); const Schema = mongoose.Schema; +const AddressModel = require('./Address'); +const SymptomModel = require('./Symptom'); + const TollFreeSchema = new Schema( { firstName: { type: String, required: true, max: 100 }, middleName: { type: String, max: 100 }, lastName: { type: String, required: true, max: 100 }, - age: { type: Number }, - sex: { type: String }, - reportRegion: { - id: { type: Number }, - name: { type: String }, - }, - region: { - id: { type: Number }, - name: { type: String }, - latitude: { type: Number }, - longitude: { type: Number }, - description: { type: String }, - createdAt: { type: Date }, - updatedAt: { type: Date }, - deletedAt: { type: Date }, - }, - zone: { - id: { type: Number }, - name: { type: String }, - }, - woreda: { - id: { type: Number }, - name: { type: String }, - }, - city: { - id: { type: Number }, - name: { type: String }, - }, - subcity: { - id: { type: Number }, - name: { type: String }, - }, - kebele: { - id: { type: Number }, - name: { type: String }, - }, + age: { type: Number, required: true }, + sex: { type: String, required: true }, + reportingFrom: { type: AddressModel.schema }, + address: { type: AddressModel.schema }, + symptom: { type: SymptomModel.schema }, createdBy: { - id: { type: Number }, - firstName: { type: String, max: 100 }, + firstName: { type: String, required: true, max: 100 }, middleName: { type: String, max: 100 }, - lastName: { type: String, max: 100 }, + lastName: { type: String, required: true, max: 100 }, email: { type: String, lowercase: true, match: [/\S+@\S+\.\S+/, 'is invalid'], }, phoneNumber: { type: String }, - region: { - id: { type: Number }, - firstName: { type: String, max: 100 }, - middleName: { type: String, max: 100 }, - lastName: { type: String, max: 100 }, - email: { - type: String, - lowercase: true, - match: [/\S+@\S+\.\S+/, 'is invalid'], - }, - phoneNumber: { type: String }, - }, + address: { type: AddressModel.schema }, role: { id: { type: Number }, name: { type: String },