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

full_name: {
        type: DataTypes.TEXT,
      
      

      },

date_of_birth: {
        type: DataTypes.DATE,
      
      

      },

blood_type: {
        type: DataTypes.TEXT,
      
      

      },

critical_allergies: {
        type: DataTypes.TEXT,
      
      

      },

critical_conditions: {
        type: DataTypes.TEXT,
      
      

      },

critical_medications: {
        type: DataTypes.TEXT,
      
      

      },

emergency_contacts: {
        type: DataTypes.TEXT,
      
      

      },

treating_doctor_contact: {
        type: DataTypes.TEXT,
      
      

      },

organ_donor_status: {
        type: DataTypes.ENUM,
      
      

        values: [

"yes",


"no",


"specific_organs",


"unknown"

        ],

      },

advance_directives_summary: {
        type: DataTypes.TEXT,
      
      

      },

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

  emergency_medical_cards.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.emergency_medical_cards.belongsTo(db.users, {
      as: 'user',
      foreignKey: {
        name: 'userId',
      },
      constraints: false,
    });




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

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



  return emergency_medical_cards;
};


