import { REPORT_DB_CONNECTIONS, REPORT_STATUSES } from '@tamanu/constants';
import { randomRecordId } from '@tamanu/database/demoData/utilities';
import { fake } from '../../fake/index.js';
export const createDbReport = async ({ models: { ReportDefinition, ReportDefinitionVersion }, userId })=>{
    const reportDefinition = await ReportDefinition.create(fake(ReportDefinition, {
        dbSchema: REPORT_DB_CONNECTIONS.REPORTING
    }));
    await ReportDefinitionVersion.create(fake(ReportDefinitionVersion, {
        status: REPORT_STATUSES.DRAFT,
        queryOptions: `{"parameters": [], "defaultDateRange": "allTime"}`,
        reportDefinitionId: reportDefinition.id,
        userId
    }));
};
export const updateDbReport = async ({ models, userId, reportDefinitionId })=>{
    const { ReportDefinitionVersion } = models;
    await ReportDefinitionVersion.create(fake(ReportDefinitionVersion, {
        status: REPORT_STATUSES.DRAFT,
        queryOptions: `{"parameters": [], "defaultDateRange": "allTime"}`,
        reportDefinitionId: reportDefinitionId || await randomRecordId(models, 'ReportDefinition'),
        userId
    }));
};

//# sourceMappingURL=dbReport.js.map