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

module.exports = (sequelize) => {
    const DiseaseDrugUsage = sequelize.define('diseasedrugusage', {
        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 
        composition: { type: DataTypes.TEXT, allowNull: true },
        dosage: { type: DataTypes.TEXT, allowNull: true },
        usage_instructions: { type: DataTypes.TEXT, allowNull: true },
        result: { type: DataTypes.TEXT, allowNull: true },
        therapy_target: { type: DataTypes.TEXT, allowNull: true },

        // fk
        druggroup_id: {
            type: DataTypes.INTEGER,
            allowNull: true,
            references: {
                model: 'druggroups',
                key: 'id'
            }
        },
        disease_id: {
            type: DataTypes.INTEGER,
            allowNull: true,
            references: {
                model: 'diseases',
                key: 'id'
            }
        },
    }, {
        tableName: 'diseasedrugusages',
        freezeTableName: true
    });

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

    };

    return DiseaseDrugUsage;
};
