const { DataTypes } = require('sequelize');

module.exports = (sequelize) => {
    const Doctor = sequelize.define('doctor', {
        id: {
            type: DataTypes.INTEGER,
            autoIncrement: true,
            primaryKey: true
        },
        creation: { type: DataTypes.DATE, allowNull: false },
        modified: { type: DataTypes.DATE, allowNull: false },
        modified_by: { type: DataTypes.INTEGER, allowNull: false },
        owner: { type: DataTypes.INTEGER, allowNull: false },
        enabled: { type: DataTypes.BOOLEAN, allowNull: false },

        // main
        full_name: { type: DataTypes.STRING(150), allowNull: false },
        email: { type: DataTypes.STRING(50), allowNull: true },
        birth_date: { type: DataTypes.DATEONLY, allowNull: true },
        age: { type: DataTypes.INTEGER, allowNull: true },
        gender: { type: DataTypes.STRING(10), allowNull: true },
        address: { type: DataTypes.STRING(150), allowNull: true },
        mobile_no: { type: DataTypes.STRING(50), allowNull: true },
        marital_status: { type: DataTypes.STRING(50), allowNull: true },
        blood_type: { type: DataTypes.STRING(50), allowNull: true },
        religion: { type: DataTypes.STRING(50), allowNull: true },
        nationality: { type: DataTypes.STRING(50), allowNull: true },
        image: { type: DataTypes.STRING, allowNull: true },
        practice_license_number: { type: DataTypes.STRING(50), allowNull: true },
        
        // fk
        specalist_id: {
            type: DataTypes.INTEGER,
            allowNull: true,
            references: {
                model: 'specialists',
                key: 'id'
            }
        },
        subspecialist_id: {
            type: DataTypes.INTEGER,
            allowNull: true,
            references: {
                model: 'subspecialists',
                key: 'id'
            }
        }
    }, {
        tableName: 'doctors',
        freezeTableName: true
    });

    /**
     * Associates the Doctor model with other models.
     * @param {object} models - The models to associate with.
     * @description
     */
    Doctor.associate = (models) => {
        
    };

    return Doctor;
};
