95 lines
2.9 KiB
JavaScript
95 lines
2.9 KiB
JavaScript
module.exports = mongoose => {
|
|
var editHistorySchema = mongoose.Schema({
|
|
employee: String,
|
|
date: Date
|
|
});
|
|
var eventDataSchema = mongoose.Schema({
|
|
customer: {type: mongoose.Schema.Types.ObjectId, ref: 'Customer'},
|
|
resource: {type: mongoose.Schema.Types.ObjectId, ref: 'Resource'},
|
|
// These fields are legacy fields, we will keep it but won't use it again
|
|
client_name: String,
|
|
client_pharmacy: String,
|
|
client_pcp: String,
|
|
client_birth_date: String,
|
|
client_seating: String,
|
|
resource_type: String,
|
|
resource_name: String,
|
|
resource_phone: String,
|
|
resource_contact: String,
|
|
resource_address: String,
|
|
resource_city: String,
|
|
resource_state: String,
|
|
// legacy fields end
|
|
// We still wanna keep the legacy fields below
|
|
new_patient: String,
|
|
confirmed: String,
|
|
fasting: String,
|
|
interpreter: String,
|
|
doc_order: String,
|
|
need_id: String,
|
|
need_med_list: String,
|
|
notes: String,
|
|
reason: String,
|
|
other: String,
|
|
disability: String,
|
|
disability_support: String,
|
|
video_type: String,
|
|
video_id: String,
|
|
presenter: String,
|
|
trans_method: String,
|
|
});
|
|
var schema = mongoose.Schema(
|
|
{
|
|
title: String,
|
|
type: String,
|
|
// value could be ['shopping', 'banking', 'singing', 'dancing', 'medical', 'haircut', 'meal', 'transportation', 'others']
|
|
description: String,
|
|
department: String,
|
|
notes: String,
|
|
start_time: Date,
|
|
stop_time: Date,
|
|
color: String,
|
|
source_type: String,
|
|
source_uuid: String,
|
|
source_name: String,
|
|
target_type: String,
|
|
target_uuid: String,
|
|
target_name: String,
|
|
link_event_uuid: String,
|
|
link_event_name: String,
|
|
data: eventDataSchema,
|
|
files: [{
|
|
type: String
|
|
}],
|
|
status: String,
|
|
confirmed: Boolean,
|
|
// value could be ['active', 'inactive']
|
|
signup_start_date: Date,
|
|
member_col: Object,
|
|
tags: [{
|
|
type: String
|
|
}],
|
|
create_by: String,
|
|
create_date: Date,
|
|
edit_by: String,
|
|
edit_date: Date,
|
|
youtube_video_id: String,
|
|
edit_history: [{
|
|
type: editHistorySchema
|
|
}],
|
|
site: Number,
|
|
event_location: String,
|
|
event_prediction_date: String,
|
|
event_reminder_type: String,
|
|
rrule: String
|
|
},
|
|
{ collection: 'calendar_event', timestamps: true }
|
|
);
|
|
schema.method("toJSON", function() {
|
|
const { __v, _id, ...object } = this.toObject();
|
|
object.id = _id;
|
|
return object;
|
|
});
|
|
const CalendarEvent = mongoose.model("calendar_event", schema);
|
|
return CalendarEvent;
|
|
}; |