const config = require('../../config');
const providers = config.providers;
const crypto = require('crypto');
const bcrypt = require('bcrypt');
const moment = require('moment');

module.exports = function(sequelize, DataTypes) {
  const stage_assessments = sequelize.define(
    'stage_assessments',
    {
      id: {
        type: DataTypes.UUID,
        defaultValue: DataTypes.UUIDV4,
        primaryKey: true,
      },

assessed_at: {
        type: DataTypes.DATE,
      
      

      },

predicted_stage: {
        type: DataTypes.ENUM,
      
      

        values: [

"mild",


"moderate",


"severe",


"unknown"

        ],

      },

confidence_score: {
        type: DataTypes.DECIMAL,
      
      

      },

method: {
        type: DataTypes.ENUM,
      
      

        values: [

"questionnaire",


"cognitive_model",


"clinician",


"hybrid"

        ],

      },

model_version: {
        type: DataTypes.TEXT,
      
      

      },

explanation: {
        type: DataTypes.TEXT,
      
      

      },

      importHash: {
        type: DataTypes.STRING(255),
        allowNull: true,
        unique: true,
      },
    },
    {
      timestamps: true,
      paranoid: true,
      freezeTableName: true,
    },
  );

  stage_assessments.associate = (db) => {


/// loop through entities and it's fields, and if ref === current e[name] and create relation has many on parent entity





























//end loop



    db.stage_assessments.belongsTo(db.patients, {
      as: 'patient',
      foreignKey: {
        name: 'patientId',
      },
      constraints: false,
    });

    db.stage_assessments.belongsTo(db.users, {
      as: 'reviewed_by_user',
      foreignKey: {
        name: 'reviewed_by_userId',
      },
      constraints: false,
    });

    db.stage_assessments.belongsTo(db.accounts, {
      as: 'accounts',
      foreignKey: {
        name: 'accountsId',
      },
      constraints: false,
    });




    db.stage_assessments.belongsTo(db.users, {
      as: 'createdBy',
    });

    db.stage_assessments.belongsTo(db.users, {
      as: 'updatedBy',
    });
  };



  return stage_assessments;
};


