const uniqueValidator = require('mongoose-unique-validator'); module.exports = mongoose => { var schema = mongoose.Schema( { // Basic Info username: { type: String, unique: true }, name: String, firstname: String, middle_name: String, lastname: String, name_cn: String, name_on_id: String, type: String, program_type: String, pay_source: String, pay_source_other: String, birth_date: String, legal_sex: String, gender: String, // keeping for backward compatibility marital_status: String, marriage_date: String, immigration_status: String, immigration_status_other: String, language_spoken: [{ type: String }], language_spoken_other: String, language: String, // keeping for backward compatibility // Contact Info email: { type: String, unique: true }, phone: String, mobile_phone: String, home_phone: String, // Address 1 address_line_1: String, address_line_2: String, city: String, state: String, zip_code: String, address_note: String, // Address 2 address2_line_1: String, address2_line_2: String, city2: String, state2: String, zip_code2: String, address2_note: String, // Address 3 address3_line_1: String, address3_line_2: String, city3: String, state3: String, zip_code3: String, address3_note: String, // Address 4 address4_line_1: String, address4_line_2: String, city4: String, state4: String, zip_code4: String, address4_note: String, // Address 5 address5_line_1: String, address5_line_2: String, city5: String, state5: String, zip_code5: String, address5_note: String, // Legacy address fields (keeping for backward compatibility) address1: String, address2: String, address3: String, address4: String, address5: String, street_address_1: String, city1: String, state1: String, zip_code1: String, street_address_2: String, street_address_3: String, street_address_4: String, street_address_5: String, apartment: String, // Emergency Contact emergency_contact: String, // legacy field emergency_contact2: String, // legacy field emergency_contact_name: String, emergency_contact_phone: String, emergency_contact_relationship: String, emergency_contact_relationship_other: String, emergency_contact_role: [{ type: String }], emergency_contact2_name: String, emergency_contact2_phone: String, emergency_contact2_relationship: String, emergency_contact2_relationship_other: String, emergency_contact2_role: [{ type: String }], emergency_contact3_name: String, emergency_contact3_phone: String, emergency_contact3_relationship: String, emergency_contact3_relationship_other: String, emergency_contact3_role: [{ type: String }], emergency_contact4_name: String, emergency_contact4_phone: String, emergency_contact4_relationship: String, emergency_contact4_relationship_other: String, emergency_contact4_role: [{ type: String }], emergency_contact5_name: String, emergency_contact5_phone: String, emergency_contact5_relationship: String, emergency_contact5_relationship_other: String, emergency_contact5_role: [{ type: String }], // Schedule days_of_week: [{ type: String }], // Admission & Discharge Record admission_date: String, enrolled_date: String, create_by: String, create_date: Date, referral_source: String, referral_source_other: String, discharge_date: String, discharge_by: String, discharge_reason: String, discharge_reason_other: String, join_reason: String, // Care & Services dietary_restrictions: [{ type: String }], dietary_restrictions_other: String, diet_texture: String, table_id: String, seat_number: String, seating: String, // legacy field transportation_type: String, consent_to_text_messages: String, text_msg_enabled: Boolean, // legacy field preferred_text_language: String, consent_to_media_use: String, pickup_status: String, // Medical & Insurance - Providers care_provider: String, primary_care_physician: String, pharmacy: String, pharmacy_id: String, // General Conditions diabetes_mellitus: String, eyes_on: String, disability: Boolean, // legacy field for eyes_on wheelchair: String, special_needs: String, health_condition: String, allergy_info: String, meal_requirement: String, service_requirement: String, // Legal molst: String, provisions_for_advance_medical: String, hospice: String, burial_arrangements: String, power_of_attorney: String, // Rounding requires_rounding: String, rounding_notes: String, // Confidential Details medicare_number: String, medicaid_number: String, social_security_number: String, adcaps_id: String, // Compliance & Deadlines adcaps_completed_date: String, center_qualification_renew_date: String, medicaid_renew_date: String, id_expiration_date: String, // Form Submission - Admission Forms hipaa_authorization_form: String, medication_management_consent_form: String, freedom_of_choice_form: String, meal_benefit_application_form: String, photo_video_release_form: String, security_deposit_agreement_form: String, recreational_program_contract_form: String, // Medical Forms tb_form: String, pre_screening_form: String, // Additional Information note: String, private_note: String, // Other legacy fields password: String, salt: String, api_token: String, avatar: String, parent_id: String, nickname: String, pin: String, vehicle_no: String, caller: String, placement: String, height: String, weight: String, status: String, roles: [{ type: String }], groups: [{ type: String }], tags: [{ type: String }], data: String, title: String, site: Number, edit_by: String, edit_date: Date, payment_due_date: String, payment_status: String }, { collection: 'customer', timestamps: true } ); schema.method("toJSON", function() { const { __v, _id, ...object } = this.toObject(); object.id = _id; return object; }); const Customer = mongoose.model("customer", schema); return Customer; };