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

vaccine_name: {
        type: DataTypes.TEXT,
      
      

      },

dose_number: {
        type: DataTypes.ENUM,
      
      

        values: [

"dose_1",


"dose_2",


"booster",


"annual",


"other"

        ],

      },

due_at: {
        type: DataTypes.DATE,
      
      

      },

sent_at: {
        type: DataTypes.DATE,
      
      

      },

status: {
        type: DataTypes.ENUM,
      
      

        values: [

"scheduled",


"sent",


"completed",


"missed",


"cancelled"

        ],

      },

notes: {
        type: DataTypes.TEXT,
      
      

      },

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

  vaccination_reminders.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.vaccination_reminders.belongsTo(db.patients, {
      as: 'patient',
      foreignKey: {
        name: 'patientId',
      },
      constraints: false,
    });




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

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



  return vaccination_reminders;
};


