const prisma = require('../../prisma/PrismaClient.js');

const StatusHistoryRepository = {
    findAll: async ({ skip, take, where, orderBy }) => {
        return prisma.statusHistory.findMany({
            where,
            skip,
            take,
            orderBy,
            select: {
                id: true,
                hospital: {
                    select: {
                        id: true,
                        name: true,
                        // hospital_code: true,
                        // type: true,
                        // ownership: true,
                        // province: {
                        //     select: {
                        //         id: true,
                        //         name: true
                        //     }
                        // },
                        // city: {
                        //     select: {
                        //         id: true,
                        //         name: true
                        //     }
                        // },
                        // address: true,
                        // simrs_type: true,
                        // contact: true,
                        // image: true,
                        progress_status: true,
                        // note: true,
                        // user: {
                        //     select: {
                        //         id: true,
                        //         username: true
                        //     }
                        // }
                    }
                },
                user: {
                    select: {
                        id: true,
                        username: true,
                    }
                },
                old_status: true,
                new_status: true,
                note: true,
                createdAt: true,
                updatedAt: true,
            },
        });
    },

    countAll: async (where) => {
        return prisma.statusHistory.count({ where });
    },

    create: async (data) => {
        return prisma.statusHistory.create({ data });
    },
};

module.exports = StatusHistoryRepository;