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

module.exports = (sequelize) => {
    const PatientMedicationLeftover = sequelize.define('patientmedicationleftover', {
        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
        remaining: { type: DataTypes.INTEGER, allowNull: false },

        // fk
        patient_id: {
            type: DataTypes.INTEGER,
            allowNull: true,
            references: {
                model: 'patients',
                key: 'id'
            }
        },
        drug_id: {
            type: DataTypes.INTEGER,
            allowNull: true,
            references: {
                model: 'drugs',
                key: 'id'
            }
        },
    }, {
        tableName: 'patientmedicationleftovers',
        freezeTableName: true
    });

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

    };

    return PatientMedicationLeftover;
};
