import { DataTypes } from 'sequelize';
import { SYNC_DIRECTIONS, VISIBILITY_STATUSES } from '@tamanu/constants';
import { Model } from '../Model';
export class InvoiceInsurancePlan extends Model {
    static initModel({ primaryKey, ...options }) {
        super.init({
            id: primaryKey,
            code: {
                type: DataTypes.STRING,
                allowNull: false
            },
            name: {
                type: DataTypes.STRING,
                allowNull: true
            },
            defaultCoverage: {
                type: DataTypes.DECIMAL,
                allowNull: true
            },
            visibilityStatus: {
                type: DataTypes.TEXT,
                defaultValue: VISIBILITY_STATUSES.CURRENT,
                allowNull: false
            }
        }, {
            ...options,
            syncDirection: SYNC_DIRECTIONS.PULL_FROM_CENTRAL,
            indexes: [
                {
                    unique: true,
                    fields: [
                        'code'
                    ]
                }
            ]
        });
    }
    static initRelations(models) {
        this.hasMany(models.InvoiceInsurancePlanItem, {
            foreignKey: 'invoiceInsurancePlanId',
            as: 'invoiceInsurancePlanItems'
        });
        this.hasMany(models.InvoicesInvoiceInsurancePlan, {
            foreignKey: 'invoiceInsurancePlanId',
            as: 'invoices'
        });
        this.hasMany(models.PatientInvoiceInsurancePlan, {
            foreignKey: 'invoiceInsurancePlanId',
            as: 'patientInvoiceInsurancePlans'
        });
        this.belongsToMany(models.Invoice, {
            through: models.InvoicesInvoiceInsurancePlan,
            foreignKey: 'invoiceInsurancePlanId',
            otherKey: 'invoiceId',
            as: 'relatedInvoices'
        });
    }
    static buildSyncFilter() {
        return null; // syncs everywhere
    }
    static async buildSyncLookupQueryDetails() {
        return null; // syncs everywhere
    }
}

//# sourceMappingURL=InvoiceInsurancePlan.js.map