worldshine-redesign/app/models/resource.model.js
2026-01-29 21:01:01 -05:00

69 lines
2.0 KiB
JavaScript

module.exports = mongoose => {
var editHistorySchema = mongoose.Schema({
employee: String,
date: Date
});
var schema = mongoose.Schema(
{
// Basic Information
name: String, // Provider name (renamed from doctor name)
office_name: String, // Merged from name_original and name_branch
specialty: String,
type: String, // value may be ['doctor', 'pharmacy' or 'other']
// Legacy fields for backward compatibility
name_original: String,
name_branch: String,
// Contact Information
phone: String, // Office Phone Number
contact: String, // Secondary Phone Number
fax: String, // Fax Number
email: String,
// Address (split fields)
address_line_1: String,
address_line_2: String,
city: String,
state: String,
zipcode: String,
// Legacy address field
address: String,
// Additional Information
note: String, // Merged from description and note
// Legacy fields
description: String,
color: String,
status: String, // value might be ['active', 'inactive']
// System fields
create_by: String,
create_date: Date,
parent_id: String,
ext_id: String,
category: String,
data: Object,
edit_by: String,
edit_date: Date,
site: Number,
images: [{
type: String
}],
edit_history: [{
type: editHistorySchema
}],
},
{ collection: 'resource', timestamps: true }
);
schema.method("toJSON", function() {
const { __v, _id, ...object } = this.toObject();
object.id = _id;
return object;
});
const Resource = mongoose.model("resource", schema);
return Resource;
};