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

module.exports = (sequelize) => {
    const Dosage = sequelize.define('dosage', {
        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 },

        // main
        dosage: { type: DataTypes.TEXT, allowNull: true },
        frequency: { type: DataTypes.TEXT, allowNull: true },
        duration: { type: DataTypes.TEXT, allowNull: true },
        notes: { type: DataTypes.TEXT, allowNull: true },
        description: { type: DataTypes.TEXT, allowNull: true },
        used_by: { type: DataTypes.TEXT, allowNull: true },
                                
        // fk
        routeadministration_id: {
            type: DataTypes.INTEGER,
            allowNull: true,
        },
        dosagetype_id: {
            type: DataTypes.INTEGER,
            allowNull: true,
        },
        drug_id: {
            type: DataTypes.INTEGER,
            allowNull: true,
        },
    }, {
        tableName: 'dosages',
        freezeTableName: true
    });

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

    return Dosage;
};
