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

record_number: {
        type: DataTypes.TEXT,
      
      

      },

condition_type: {
        type: DataTypes.ENUM,
      
      

        values: [

"diabetes",


"hypertension",


"other"

        ],

      },

route: {
        type: DataTypes.ENUM,
      
      

        values: [

"iv",


"oral"

        ],

      },

notes: {
        type: DataTypes.TEXT,
      
      

      },

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

      },

price: {
        type: DataTypes.DECIMAL,
      
      

      },

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

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




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

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



  return daily_followup_clinic;
};


