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 rule_requirements = sequelize.define(
    'rule_requirements',
    {
      id: {
        type: DataTypes.UUID,
        defaultValue: DataTypes.UUIDV4,
        primaryKey: true,
      },

requirement_type: {
        type: DataTypes.ENUM,
      
      

        values: [

"document",


"clinical_evidence",


"questionnaire",


"form_field",


"timing",


"other"

        ],

      },

requirement_label: {
        type: DataTypes.TEXT,
      
      

      },

evidence_needed: {
        type: DataTypes.TEXT,
      
      

      },

severity: {
        type: DataTypes.ENUM,
      
      

        values: [

"info",


"warning",


"blocking"

        ],

      },

active: {
        type: DataTypes.BOOLEAN,
      
        allowNull: false,
        defaultValue: false,
      
      

      },

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

  rule_requirements.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.rule_requirements.belongsTo(db.payer_rules, {
      as: 'payer_rule',
      foreignKey: {
        name: 'payer_ruleId',
      },
      constraints: false,
    });

    db.rule_requirements.belongsTo(db.organizations, {
      as: 'organizations',
      foreignKey: {
        name: 'organizationsId',
      },
      constraints: false,
    });




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

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



  return rule_requirements;
};


