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

incubator_number: {
        type: DataTypes.TEXT,
      
      

      },

baby_name: {
        type: DataTypes.TEXT,
      
      

      },

baby_age: {
        type: DataTypes.TEXT,
      
      

      },

medications: {
        type: DataTypes.TEXT,
      
      

      },

devices: {
        type: DataTypes.TEXT,
      
      

      },

daily_price: {
        type: DataTypes.DECIMAL,
      
      

      },

admission_date: {
        type: DataTypes.DATE,
      
      

      },

discharge_date: {
        type: DataTypes.DATE,
      
      

      },

cancellation_reason: {
        type: DataTypes.TEXT,
      
      

      },

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

  nicu_incubators.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.nicu_incubators.belongsTo(db.doctors, {
      as: 'admitting_doctor',
      foreignKey: {
        name: 'admitting_doctorId',
      },
      constraints: false,
    });




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

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



  return nicu_incubators;
};


