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

module.exports = (sequelize) => {
    const Examination = sequelize.define('examination', {
        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
        name: { type: DataTypes.STRING(150), allowNull: false },
        display_name: { type: DataTypes.STRING(150), allowNull: false },
        description: { type: DataTypes.TEXT, allowNull: true },
        example: { type: DataTypes.TEXT, allowNull: true },
        objective: { type: DataTypes.TEXT, allowNull: true },
        normal_range_male: { type: DataTypes.STRING(50), allowNull: true },
        normal_range_female: { type: DataTypes.STRING(50), allowNull: true },
        
        // fk
        examinationgroup_id: {
            type: DataTypes.INTEGER,
            allowNull: true,
            references: {
                model: 'examinationgroups',
                key: 'id'
            }
        },
    }, {
        tableName: 'examinations',
        freezeTableName: true
    });

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

    return Examination;
};
