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

started_at: {
        type: DataTypes.DATE,
      
      

      },

ended_at: {
        type: DataTypes.DATE,
      
      

      },

channel: {
        type: DataTypes.ENUM,
      
      

        values: [

"mobile",


"web",


"smart_speaker"

        ],

      },

transcript: {
        type: DataTypes.TEXT,
      
      

      },

assistant_summary: {
        type: DataTypes.TEXT,
      
      

      },

outcome: {
        type: DataTypes.ENUM,
      
      

        values: [

"info",


"reminder_created",


"alert_created",


"handoff_to_caregiver",


"other"

        ],

      },

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

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

    db.voice_assistant_sessions.belongsTo(db.users, {
      as: 'initiated_by_user',
      foreignKey: {
        name: 'initiated_by_userId',
      },
      constraints: false,
    });

    db.voice_assistant_sessions.belongsTo(db.accounts, {
      as: 'accounts',
      foreignKey: {
        name: 'accountsId',
      },
      constraints: false,
    });




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

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



  return voice_assistant_sessions;
};


