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

medications: {
        type: DataTypes.TEXT,
      
      

      },

start_time: {
        type: DataTypes.DATE,
      
      

      },

end_time: {
        type: DataTypes.DATE,
      
      

      },

recovery_notes: {
        type: DataTypes.TEXT,
      
      

      },

price: {
        type: DataTypes.DECIMAL,
      
      

      },

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

  anesthesia_records.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.anesthesia_records.belongsTo(db.surgery_cases, {
      as: 'surgery_case',
      foreignKey: {
        name: 'surgery_caseId',
      },
      constraints: false,
    });




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

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



  return anesthesia_records;
};


