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

module.exports = (sequelize) => {
    const PatientExamination = sequelize.define('patientexamination', {
        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
        exam_result: { type: DataTypes.TEXT, allowNull: true },

        // fk
        examination_id: {
            type: DataTypes.INTEGER,
            allowNull: true,
            references: {
                model: 'examinations',
                key: 'id'
            }
        },
        examinationgroup_id: {
            type: DataTypes.INTEGER,
            allowNull: true,
            references: {
                model: 'examinationgroups',
                key: 'id'
            }
        },
        patient_id: {
            type: DataTypes.INTEGER,
            allowNull: true,
            references: {
                model: 'patients',
                key: 'id'
            }
        },
        hospital_id: {
            type: DataTypes.INTEGER,
            allowNull: true,
            references: {
                model: 'hospitals',
                key: 'id'
            }
        },
        visite_id: {
            type: DataTypes.INTEGER,
            allowNull: true,
            references: {
                model: 'visites',
                key: 'id'
            }
        }
    }, {
        tableName: 'patientexaminations',
        freezeTableName: true
    });

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

    };

    return PatientExamination;
};
