import { DataTypes } from "sequelize";
import { sequelize } from "@/configs/sequelize";
import { User } from "./user";
import { Disease } from "./disease";

export const Diagnose = sequelize.define(
    "Diagnose",
    {
        id: {
            type: DataTypes.UUID,
            primaryKey: true,
            defaultValue: DataTypes.UUIDV4,
        },
        patient_id: {
            type: DataTypes.UUID,
            allowNull: false,
        },
        disease_id: {
            type: DataTypes.UUID,
            defaultValue: "",
        },
        symptoms_id: {
            type: DataTypes.JSON,
            defaultValue: [],
        },
        follow_up_questions: {
            type: DataTypes.JSON,
            defaultValue: [],
        },
        created_by_id: {
            type: DataTypes.UUID,
            allowNull: false,
        },
    },
    {
        tableName: "diagnoses",
        timestamps: true,
        createdAt: "created_at",
        updatedAt: "updated_at",
    },
);

Diagnose.belongsTo(User, {
    foreignKey: "created_by_id",
    as: "created_by",
});

Diagnose.belongsTo(Disease, {
    foreignKey: "disease_id",
    as: "disease",
});
