"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.IccInvoiceApi = void 0;
/**
 * iCure Data Stack API Documentation
 * The iCure Data Stack Application API is the native interface to iCure. This version is obsolete, please use v2.
 *
 * OpenAPI spec version: v1
 *
 *
 * NOTE: This class is auto generated by the swagger code generator program.
 * https://github.com/swagger-api/swagger-codegen.git
 * Do not edit the class manually.
 */
const XHR_1 = require("./XHR");
const DocIdentifier_1 = require("../model/DocIdentifier");
const IcureStub_1 = require("../model/IcureStub");
const Invoice_1 = require("../model/Invoice");
const LabelledOccurence_1 = require("../model/LabelledOccurence");
const ListOfIds_1 = require("../model/ListOfIds");
const PaginatedListInvoice_1 = require("../model/PaginatedListInvoice");
const AuthenticationProvider_1 = require("../../icc-x-api/auth/AuthenticationProvider");
const IccRestApiPath_1 = require("./IccRestApiPath");
const EntityBulkShareResult_1 = require("../model/requests/EntityBulkShareResult");
const MinimalEntityBulkShareResult_1 = require("../model/requests/MinimalEntityBulkShareResult");
class IccInvoiceApi {
    get headers() {
        return Promise.resolve(this._headers);
    }
    constructor(host, headers, authenticationProvider, fetchImpl) {
        this.host = (0, IccRestApiPath_1.iccRestApiPath)(host);
        this._headers = Object.keys(headers).map((k) => new XHR_1.XHR.Header(k, headers[k]));
        this.authenticationProvider = !!authenticationProvider ? authenticationProvider : new AuthenticationProvider_1.NoAuthenticationProvider();
        this.fetchImpl = fetchImpl;
    }
    setHeaders(h) {
        this._headers = h;
    }
    handleError(e) {
        throw e;
    }
    /**
     *
     * @summary Append codes to new or existing invoice
     * @param body
     * @param userId
     * @param type
     * @param sentMediumType
     * @param secretFKeys
     * @param insuranceId
     * @param invoiceId
     * @param gracePeriod
     */
    appendCodes(userId, type, sentMediumType, secretFKeys, insuranceId, invoiceId, gracePeriod, body) {
        return __awaiter(this, void 0, void 0, function* () {
            let _body = null;
            _body = body;
            const _url = this.host +
                `/invoice/byauthor/${encodeURIComponent(String(userId))}/append/${encodeURIComponent(String(type))}/${encodeURIComponent(String(sentMediumType))}` +
                '?ts=' +
                new Date().getTime() +
                (secretFKeys ? '&secretFKeys=' + encodeURIComponent(String(secretFKeys)) : '') +
                (insuranceId ? '&insuranceId=' + encodeURIComponent(String(insuranceId)) : '') +
                (invoiceId ? '&invoiceId=' + encodeURIComponent(String(invoiceId)) : '') +
                (gracePeriod ? '&gracePeriod=' + encodeURIComponent(String(gracePeriod)) : '');
            let headers = yield this.headers;
            headers = headers.filter((h) => h.header !== 'Content-Type').concat(new XHR_1.XHR.Header('Content-Type', 'application/json'));
            return XHR_1.XHR.sendCommand('POST', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
                .then((doc) => doc.body.map((it) => new Invoice_1.Invoice(it)))
                .catch((err) => this.handleError(err));
        });
    }
    /**
     *
     * @summary Creates an invoice
     * @param body
     */
    createInvoice(body) {
        return __awaiter(this, void 0, void 0, function* () {
            const _url = this.host + `/invoice` + '?ts=' + new Date().getTime();
            let headers = yield this.headers;
            headers = headers.filter((h) => h.header !== 'Content-Type').concat(new XHR_1.XHR.Header('Content-Type', 'application/json'));
            return XHR_1.XHR.sendCommand('POST', _url, headers, body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
                .then((doc) => new Invoice_1.Invoice(doc.body))
                .catch((err) => this.handleError(err));
        });
    }
    /**
     * Returns the created invoices.
     * @summary Create a batch of invoices
     * @param body
     */
    createInvoices(body) {
        return __awaiter(this, void 0, void 0, function* () {
            const _url = this.host + `/invoice/batch` + '?ts=' + new Date().getTime();
            let headers = yield this.headers;
            headers = headers.filter((h) => h.header !== 'Content-Type').concat(new XHR_1.XHR.Header('Content-Type', 'application/json'));
            return XHR_1.XHR.sendCommand('POST', _url, headers, body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
                .then((doc) => doc.body.map((it) => new Invoice_1.Invoice(it)))
                .catch((err) => this.handleError(err));
        });
    }
    /**
     *
     * @summary Deletes an invoice
     * @param invoiceId
     */
    deleteInvoice(invoiceId) {
        return __awaiter(this, void 0, void 0, function* () {
            let _body = null;
            const _url = this.host + `/invoice/${encodeURIComponent(String(invoiceId))}` + '?ts=' + new Date().getTime();
            let headers = yield this.headers;
            return XHR_1.XHR.sendCommand('DELETE', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
                .then((doc) => new DocIdentifier_1.DocIdentifier(doc.body))
                .catch((err) => this.handleError(err));
        });
    }
    filterInvoicesBy(body_1) {
        return __awaiter(this, arguments, void 0, function* (body, collectTiming = false) {
            const _url = this.host + `/invoice/filter` + '?ts=' + new Date().getTime();
            let headers = yield this.headers;
            headers = headers.filter((h) => h.header !== 'Content-Type').concat(new XHR_1.XHR.Header('Content-Type', 'application/json'));
            return XHR_1.XHR.sendCommand('POST', _url, headers, body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService(), undefined, false, collectTiming ? ['x-filter-timing-*'] : [])
                .then((doc) => Object.assign(doc.body.map((it) => new Invoice_1.Invoice(it)), collectTiming ? { responseHeaders: doc.responseHeaders } : {}))
                .catch((err) => this.handleError(err));
        });
    }
    /**
     *
     * @summary Gets all invoices for author at date
     * @param hcPartyId
     * @param fromDate
     * @param toDate
     * @param startKey The start key for pagination: a JSON representation of an array containing all the necessary components to form the Complex Key&#x27;s startKey
     * @param startDocumentId A patient document ID
     * @param limit Number of rows
     */
    findByAuthor(hcPartyId, fromDate, toDate, startKey, startDocumentId, limit) {
        return __awaiter(this, void 0, void 0, function* () {
            let _body = null;
            const _url = this.host +
                `/invoice/byauthor/${encodeURIComponent(String(hcPartyId))}` +
                '?ts=' +
                new Date().getTime() +
                (fromDate ? '&fromDate=' + encodeURIComponent(String(fromDate)) : '') +
                (toDate ? '&toDate=' + encodeURIComponent(String(toDate)) : '') +
                (startKey ? '&startKey=' + encodeURIComponent(String(startKey)) : '') +
                (startDocumentId ? '&startDocumentId=' + encodeURIComponent(String(startDocumentId)) : '') +
                (limit ? '&limit=' + encodeURIComponent(String(limit)) : '');
            let headers = yield this.headers;
            return XHR_1.XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
                .then((doc) => new PaginatedListInvoice_1.PaginatedListInvoice(doc.body))
                .catch((err) => this.handleError(err));
        });
    }
    /**
     * @deprecated use {@link findInvoiceIdsByDataOwnerPatientInvoiceDate} instead.
     * @summary List invoices found By Healthcare Party and secret foreign patient keys.
     * @param body
     * @param hcPartyId
     */
    findInvoicesByHCPartyPatientForeignKeysUsingPost(hcPartyId, body) {
        return __awaiter(this, void 0, void 0, function* () {
            let _body = null;
            _body = body;
            const _url = this.host +
                `/invoice/byHcPartySecretForeignKeys` +
                '?ts=' +
                new Date().getTime() +
                (hcPartyId ? '&hcPartyId=' + encodeURIComponent(String(hcPartyId)) : '');
            let headers = yield this.headers;
            headers = headers.filter((h) => h.header !== 'Content-Type').concat(new XHR_1.XHR.Header('Content-Type', 'application/json'));
            return XHR_1.XHR.sendCommand('POST', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
                .then((doc) => doc.body.map((it) => new Invoice_1.Invoice(it)))
                .catch((err) => this.handleError(err));
        });
    }
    /**
     * Keys have to delimited by commas.
     * @deprecated use {@link findInvoiceIdsByDataOwnerPatientInvoiceDate} instead.
     * @summary List invoices found By Healthcare Party and secret foreign patient keys.
     * @param hcPartyId
     * @param secretFKeys
     */
    findInvoicesByHCPartyPatientForeignKeys(hcPartyId, secretFKeys) {
        return __awaiter(this, void 0, void 0, function* () {
            let _body = null;
            const _url = this.host +
                `/invoice/byHcPartySecretForeignKeys` +
                '?ts=' +
                new Date().getTime() +
                (hcPartyId ? '&hcPartyId=' + encodeURIComponent(String(hcPartyId)) : '') +
                (secretFKeys ? '&secretFKeys=' + encodeURIComponent(String(secretFKeys)) : '');
            let headers = yield this.headers;
            return XHR_1.XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
                .then((doc) => doc.body.map((it) => new Invoice_1.Invoice(it)))
                .catch((err) => this.handleError(err));
        });
    }
    /**
     * @summary List Invoice ids by data owner and a set of secret foreign key. The ids will be sorted by Invoice invoiceDate, in ascending or descending
     * order according to the specified parameter value.
     *
     * @param dataOwnerId the data owner id.
     * @param secretFKeys an array of secret foreign keys.
     * @param startDate a timestamp in epoch milliseconds. If undefined, all the invoice ids since the beginning of time will be returned.
     * @param endDate a timestamp in epoch milliseconds. If undefined, all the invoice ids until the end of time will be returned.
     * @param descending whether to return the ids ordered in ascending or descending order by Invoice invoiceDate.
     * @return a promise that will resolve in an Array of Invoice ids.
     */
    findInvoiceIdsByDataOwnerPatientInvoiceDate(dataOwnerId, secretFKeys, startDate, endDate, descending) {
        return __awaiter(this, void 0, void 0, function* () {
            const _url = this.host +
                `/invoice/byDataOwnerPatientInvoiceDate?ts=${new Date().getTime()}` +
                '&dataOwnerId=' +
                encodeURIComponent(dataOwnerId) +
                (!!startDate ? `&startDate=${encodeURIComponent(startDate)}` : '') +
                (!!endDate ? `&endDate=${encodeURIComponent(endDate)}` : '') +
                (!!descending ? `&descending=${descending}` : '');
            const headers = (yield this.headers).filter((h) => h.header !== 'Content-Type').concat(new XHR_1.XHR.Header('Content-Type', 'application/json'));
            const body = new ListOfIds_1.ListOfIds({ ids: secretFKeys });
            return XHR_1.XHR.sendCommand('POST', _url, headers, body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
                .then((doc) => doc.body.map((it) => JSON.parse(JSON.stringify(it))))
                .catch((err) => this.handleError(err));
        });
    }
    /**
     * @summary List Invoice ids by data owner and a decision reference
     *
     * @param dataOwnerId the data owner id.
     * @param decisionReference the decision reference to search.
     * @return a promise that will resolve in an Array of Invoice ids.
     */
    findInvoiceIdsByDataOwnerDecisionReference(dataOwnerId, decisionReference) {
        return __awaiter(this, void 0, void 0, function* () {
            const _url = this.host +
                `/invoice/byDecisionReference?ts=${new Date().getTime()}` +
                `&dataOwnerId=${encodeURIComponent(dataOwnerId)}` +
                `&decisionReference=${encodeURIComponent(decisionReference)}`;
            const headers = yield this.headers;
            return XHR_1.XHR.sendCommand('GET', _url, headers, null, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
                .then((doc) => doc.body.map((it) => JSON.parse(JSON.stringify(it))))
                .catch((err) => this.handleError(err));
        });
    }
    /**
     * @deprecated use {@link findInvoicesDelegationsStubsByIds} instead.
     * @summary List helement stubs found By Healthcare Party and secret foreign keys.
     * @param body
     * @param hcPartyId
     */
    findInvoicesDelegationsStubsByHCPartyPatientForeignKeysUsingPost(hcPartyId, body) {
        return __awaiter(this, void 0, void 0, function* () {
            let _body = null;
            _body = body;
            const _url = this.host +
                `/invoice/byHcPartySecretForeignKeys/delegations` +
                '?ts=' +
                new Date().getTime() +
                (hcPartyId ? '&hcPartyId=' + encodeURIComponent(String(hcPartyId)) : '');
            let headers = yield this.headers;
            headers = headers.filter((h) => h.header !== 'Content-Type').concat(new XHR_1.XHR.Header('Content-Type', 'application/json'));
            return XHR_1.XHR.sendCommand('POST', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
                .then((doc) => doc.body.map((it) => new IcureStub_1.IcureStub(it)))
                .catch((err) => this.handleError(err));
        });
    }
    /**
     * Keys must be delimited by commas.
     * @deprecated use {@link findInvoicesDelegationsStubsByIds} instead.
     * @summary List helement stubs found By Healthcare Party and secret foreign keys.
     * @param hcPartyId
     * @param secretFKeys
     */
    findInvoicesDelegationsStubsByHCPartyPatientForeignKeys(hcPartyId, secretFKeys) {
        return __awaiter(this, void 0, void 0, function* () {
            let _body = null;
            const _url = this.host +
                `/invoice/byHcPartySecretForeignKeys/delegations` +
                '?ts=' +
                new Date().getTime() +
                (hcPartyId ? '&hcPartyId=' + encodeURIComponent(String(hcPartyId)) : '') +
                (secretFKeys ? '&secretFKeys=' + encodeURIComponent(String(secretFKeys)) : '');
            let headers = yield this.headers;
            return XHR_1.XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
                .then((doc) => doc.body.map((it) => new IcureStub_1.IcureStub(it)))
                .catch((err) => this.handleError(err));
        });
    }
    findInvoicesDelegationsStubsByIds(invoiceIds) {
        return __awaiter(this, void 0, void 0, function* () {
            const _url = this.host + `/invoice/delegations`;
            let headers = yield this.headers;
            headers = headers.filter((h) => h.header !== 'Content-Type').concat(new XHR_1.XHR.Header('Content-Type', 'application/json'));
            return XHR_1.XHR.sendCommand('POST', _url, headers, { ids: invoiceIds }, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
                .then((doc) => doc.body.map((it) => new IcureStub_1.IcureStub(it)))
                .catch((err) => this.handleError(err));
        });
    }
    /**
     *
     * @summary Gets an invoice
     * @param invoiceId
     */
    getInvoice(invoiceId) {
        return __awaiter(this, void 0, void 0, function* () {
            let _body = null;
            const _url = this.host + `/invoice/${encodeURIComponent(String(invoiceId))}` + '?ts=' + new Date().getTime();
            let headers = yield this.headers;
            return XHR_1.XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
                .then((doc) => new Invoice_1.Invoice(doc.body))
                .catch((err) => this.handleError(err));
        });
    }
    /**
     *
     * @summary Gets an invoice
     * @param body
     */
    getInvoices(body) {
        return __awaiter(this, void 0, void 0, function* () {
            let _body = null;
            _body = body;
            const _url = this.host + `/invoice/byIds` + '?ts=' + new Date().getTime();
            let headers = yield this.headers;
            headers = headers.filter((h) => h.header !== 'Content-Type').concat(new XHR_1.XHR.Header('Content-Type', 'application/json'));
            return XHR_1.XHR.sendCommand('POST', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
                .then((doc) => doc.body.map((it) => new Invoice_1.Invoice(it)))
                .catch((err) => this.handleError(err));
        });
    }
    /**
     *
     * @summary Get the list of all used tarifications frequencies in invoices
     * @param minOccurrences
     */
    getTarificationsCodesOccurences(minOccurrences) {
        return __awaiter(this, void 0, void 0, function* () {
            let _body = null;
            const _url = this.host + `/invoice/codes/${encodeURIComponent(String(minOccurrences))}` + '?ts=' + new Date().getTime();
            let headers = yield this.headers;
            return XHR_1.XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
                .then((doc) => doc.body.map((it) => new LabelledOccurence_1.LabelledOccurence(it)))
                .catch((err) => this.handleError(err));
        });
    }
    /**
     *
     * @summary Gets all invoices per status
     * @param body
     * @param status
     * @param from
     * @param to
     */
    listAllHcpsByStatus(status, from, to, body) {
        return __awaiter(this, void 0, void 0, function* () {
            let _body = null;
            _body = body;
            const _url = this.host +
                `/invoice/allHcpsByStatus/${encodeURIComponent(String(status))}` +
                '?ts=' +
                new Date().getTime() +
                (from ? '&from=' + encodeURIComponent(String(from)) : '') +
                (to ? '&to=' + encodeURIComponent(String(to)) : '');
            let headers = yield this.headers;
            headers = headers.filter((h) => h.header !== 'Content-Type').concat(new XHR_1.XHR.Header('Content-Type', 'application/json'));
            return XHR_1.XHR.sendCommand('POST', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
                .then((doc) => doc.body.map((it) => new Invoice_1.Invoice(it)))
                .catch((err) => this.handleError(err));
        });
    }
    /**
     *
     * @summary Gets all invoices for author at date
     * @param body
     */
    listByContactIds(body) {
        return __awaiter(this, void 0, void 0, function* () {
            let _body = null;
            _body = body;
            const _url = this.host + `/invoice/byContacts` + '?ts=' + new Date().getTime();
            let headers = yield this.headers;
            headers = headers.filter((h) => h.header !== 'Content-Type').concat(new XHR_1.XHR.Header('Content-Type', 'application/json'));
            return XHR_1.XHR.sendCommand('POST', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
                .then((doc) => doc.body.map((it) => new Invoice_1.Invoice(it)))
                .catch((err) => this.handleError(err));
        });
    }
    /**
     * Keys have to delimited by coma
     * @summary List invoices by groupId
     * @param hcPartyId
     * @param groupId
     */
    listByHcPartyGroupId(hcPartyId, groupId) {
        return __awaiter(this, void 0, void 0, function* () {
            let _body = null;
            const _url = this.host +
                `/invoice/byHcPartyGroupId/${encodeURIComponent(String(hcPartyId))}/${encodeURIComponent(String(groupId))}` +
                '?ts=' +
                new Date().getTime();
            let headers = yield this.headers;
            return XHR_1.XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
                .then((doc) => doc.body.map((it) => new Invoice_1.Invoice(it)))
                .catch((err) => this.handleError(err));
        });
    }
    /**
     * Keys have to delimited by coma
     * @summary List invoices by type, sent or unsent
     * @param hcPartyId
     * @param sentMediumType
     * @param invoiceType
     * @param sent
     * @param from
     * @param to
     */
    listByHcPartySentMediumTypeInvoiceTypeSentDate(hcPartyId, sentMediumType, invoiceType, sent, from, to) {
        return __awaiter(this, void 0, void 0, function* () {
            let _body = null;
            const _url = this.host +
                `/invoice/byHcParty/${encodeURIComponent(String(hcPartyId))}/mediumType/${encodeURIComponent(String(sentMediumType))}/invoiceType/${encodeURIComponent(String(invoiceType))}/sent/${encodeURIComponent(String(sent))}` +
                '?ts=' +
                new Date().getTime() +
                (from ? '&from=' + encodeURIComponent(String(from)) : '') +
                (to ? '&to=' + encodeURIComponent(String(to)) : '');
            let headers = yield this.headers;
            return XHR_1.XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
                .then((doc) => doc.body.map((it) => new Invoice_1.Invoice(it)))
                .catch((err) => this.handleError(err));
        });
    }
    /**
     *
     * @summary Get all invoices by author, by sending mode, by status and by date
     * @param hcPartyId
     * @param sendingMode
     * @param status
     * @param from
     * @param to
     */
    listByHcpartySendingModeStatusDate(hcPartyId, sendingMode, status, from, to) {
        return __awaiter(this, void 0, void 0, function* () {
            let _body = null;
            const _url = this.host +
                `/invoice/byHcpartySendingModeStatusDate/${encodeURIComponent(String(hcPartyId))}` +
                '?ts=' +
                new Date().getTime() +
                (sendingMode ? '&sendingMode=' + encodeURIComponent(String(sendingMode)) : '') +
                (status ? '&status=' + encodeURIComponent(String(status)) : '') +
                (from ? '&from=' + encodeURIComponent(String(from)) : '') +
                (to ? '&to=' + encodeURIComponent(String(to)) : '');
            let headers = yield this.headers;
            return XHR_1.XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
                .then((doc) => doc.body.map((it) => new Invoice_1.Invoice(it)))
                .catch((err) => this.handleError(err));
        });
    }
    /**
     *
     * @summary Gets all invoices for author at date
     * @param invoiceIds
     */
    listByIds(invoiceIds) {
        return __awaiter(this, void 0, void 0, function* () {
            let _body = null;
            const _url = this.host + `/invoice/byIds/${encodeURIComponent(String(invoiceIds))}` + '?ts=' + new Date().getTime();
            let headers = yield this.headers;
            return XHR_1.XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
                .then((doc) => doc.body.map((it) => new Invoice_1.Invoice(it)))
                .catch((err) => this.handleError(err));
        });
    }
    /**
     *
     * @summary Gets all invoices for author at date
     * @param recipientIds
     */
    listByRecipientsIds(recipientIds) {
        return __awaiter(this, void 0, void 0, function* () {
            let _body = null;
            const _url = this.host + `/invoice/to/${encodeURIComponent(String(recipientIds))}` + '?ts=' + new Date().getTime();
            let headers = yield this.headers;
            return XHR_1.XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
                .then((doc) => doc.body.map((it) => new Invoice_1.Invoice(it)))
                .catch((err) => this.handleError(err));
        });
    }
    /**
     *
     * @summary Gets all invoices for author at date
     * @param serviceIds
     */
    listByServiceIds(serviceIds) {
        return __awaiter(this, void 0, void 0, function* () {
            let _body = null;
            const _url = this.host + `/invoice/byServiceIds/${encodeURIComponent(String(serviceIds))}` + '?ts=' + new Date().getTime();
            let headers = yield this.headers;
            return XHR_1.XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
                .then((doc) => doc.body.map((it) => new Invoice_1.Invoice(it)))
                .catch((err) => this.handleError(err));
        });
    }
    /**
     *
     * @summary Gets all invoices for author at date
     * @param userIds
     */
    listToInsurances(userIds) {
        return __awaiter(this, void 0, void 0, function* () {
            let _body = null;
            const _url = this.host + `/invoice/toInsurances` + '?ts=' + new Date().getTime() + (userIds ? '&userIds=' + encodeURIComponent(String(userIds)) : '');
            let headers = yield this.headers;
            return XHR_1.XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
                .then((doc) => doc.body.map((it) => new Invoice_1.Invoice(it)))
                .catch((err) => this.handleError(err));
        });
    }
    /**
     *
     * @summary Gets all invoices for author at date
     * @param userIds
     */
    listToInsurancesUnsent(userIds) {
        return __awaiter(this, void 0, void 0, function* () {
            let _body = null;
            const _url = this.host + `/invoice/toInsurances/unsent` + '?ts=' + new Date().getTime() + (userIds ? '&userIds=' + encodeURIComponent(String(userIds)) : '');
            let headers = yield this.headers;
            return XHR_1.XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
                .then((doc) => doc.body.map((it) => new Invoice_1.Invoice(it)))
                .catch((err) => this.handleError(err));
        });
    }
    /**
     *
     * @summary Gets all invoices for author at date
     * @param hcPartyId
     */
    listToPatients(hcPartyId) {
        return __awaiter(this, void 0, void 0, function* () {
            let _body = null;
            const _url = this.host + `/invoice/toPatients` + '?ts=' + new Date().getTime() + (hcPartyId ? '&hcPartyId=' + encodeURIComponent(String(hcPartyId)) : '');
            let headers = yield this.headers;
            return XHR_1.XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
                .then((doc) => doc.body.map((it) => new Invoice_1.Invoice(it)))
                .catch((err) => this.handleError(err));
        });
    }
    /**
     *
     * @summary Gets all invoices for author at date
     * @param hcPartyId
     */
    listToPatientsUnsent(hcPartyId) {
        return __awaiter(this, void 0, void 0, function* () {
            let _body = null;
            const _url = this.host +
                `/invoice/toPatients/unsent` +
                '?ts=' +
                new Date().getTime() +
                (hcPartyId ? '&hcPartyId=' + encodeURIComponent(String(hcPartyId)) : '');
            let headers = yield this.headers;
            return XHR_1.XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
                .then((doc) => doc.body.map((it) => new Invoice_1.Invoice(it)))
                .catch((err) => this.handleError(err));
        });
    }
    /**
     *
     * @summary Gets all invoices for author at date
     * @param body
     * @param invoiceId
     */
    mergeTo(invoiceId, body) {
        return __awaiter(this, void 0, void 0, function* () {
            let _body = null;
            _body = body;
            const _url = this.host + `/invoice/mergeTo/${encodeURIComponent(String(invoiceId))}` + '?ts=' + new Date().getTime();
            let headers = yield this.headers;
            headers = headers.filter((h) => h.header !== 'Content-Type').concat(new XHR_1.XHR.Header('Content-Type', 'application/json'));
            return XHR_1.XHR.sendCommand('POST', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
                .then((doc) => new Invoice_1.Invoice(doc.body))
                .catch((err) => this.handleError(err));
        });
    }
    /**
     *
     * @summary Modifies an invoice
     * @param body
     */
    modifyInvoice(body) {
        return __awaiter(this, void 0, void 0, function* () {
            let _body = null;
            _body = body;
            const _url = this.host + `/invoice` + '?ts=' + new Date().getTime();
            let headers = yield this.headers;
            headers = headers.filter((h) => h.header !== 'Content-Type').concat(new XHR_1.XHR.Header('Content-Type', 'application/json'));
            return XHR_1.XHR.sendCommand('PUT', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
                .then((doc) => new Invoice_1.Invoice(doc.body))
                .catch((err) => this.handleError(err));
        });
    }
    /**
     * Returns the modified invoices.
     * @summary Modify a batch of invoices
     * @param body
     */
    modifyInvoices(body) {
        return __awaiter(this, void 0, void 0, function* () {
            let _body = null;
            _body = body;
            const _url = this.host + `/invoice/batch` + '?ts=' + new Date().getTime();
            let headers = yield this.headers;
            headers = headers.filter((h) => h.header !== 'Content-Type').concat(new XHR_1.XHR.Header('Content-Type', 'application/json'));
            return XHR_1.XHR.sendCommand('PUT', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
                .then((doc) => doc.body.map((it) => new Invoice_1.Invoice(it)))
                .catch((err) => this.handleError(err));
        });
    }
    /**
     *
     * @summary Modifies an invoice
     * @param body
     */
    reassignInvoice(body) {
        return __awaiter(this, void 0, void 0, function* () {
            let _body = null;
            _body = body;
            const _url = this.host + `/invoice/reassign` + '?ts=' + new Date().getTime();
            let headers = yield this.headers;
            headers = headers.filter((h) => h.header !== 'Content-Type').concat(new XHR_1.XHR.Header('Content-Type', 'application/json'));
            return XHR_1.XHR.sendCommand('POST', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
                .then((doc) => new Invoice_1.Invoice(doc.body))
                .catch((err) => this.handleError(err));
        });
    }
    /**
     *
     * @summary removeCodes for linked serviceId
     * @param body
     * @param userId
     * @param serviceId
     * @param secretFKeys
     */
    removeCodes(userId, serviceId, secretFKeys, body) {
        return __awaiter(this, void 0, void 0, function* () {
            let _body = null;
            _body = body;
            const _url = this.host +
                `/invoice/byauthor/${encodeURIComponent(String(userId))}/service/${encodeURIComponent(String(serviceId))}` +
                '?ts=' +
                new Date().getTime() +
                (secretFKeys ? '&secretFKeys=' + encodeURIComponent(String(secretFKeys)) : '');
            let headers = yield this.headers;
            headers = headers.filter((h) => h.header !== 'Content-Type').concat(new XHR_1.XHR.Header('Content-Type', 'application/json'));
            return XHR_1.XHR.sendCommand('POST', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
                .then((doc) => doc.body.map((it) => new Invoice_1.Invoice(it)))
                .catch((err) => this.handleError(err));
        });
    }
    /**
     *
     * @summary Gets all invoices for author at date
     * @param invoiceId
     * @param scheme
     * @param forcedValue
     */
    validate(invoiceId, scheme, forcedValue) {
        return __awaiter(this, void 0, void 0, function* () {
            let _body = null;
            const _url = this.host +
                `/invoice/validate/${encodeURIComponent(String(invoiceId))}` +
                '?ts=' +
                new Date().getTime() +
                (scheme ? '&scheme=' + encodeURIComponent(String(scheme)) : '') +
                (forcedValue ? '&forcedValue=' + encodeURIComponent(String(forcedValue)) : '');
            let headers = yield this.headers;
            return XHR_1.XHR.sendCommand('POST', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
                .then((doc) => new Invoice_1.Invoice(doc.body))
                .catch((err) => this.handleError(err));
        });
    }
    /**
     * @internal this method is for internal use only and may be changed without notice
     */
    bulkShareInvoices(request) {
        return __awaiter(this, void 0, void 0, function* () {
            const _url = this.host + '/invoice/bulkSharedMetadataUpdate' + '?ts=' + new Date().getTime();
            let headers = yield this.headers;
            headers = headers.filter((h) => h.header !== 'Content-Type').concat(new XHR_1.XHR.Header('Content-Type', 'application/json'));
            return XHR_1.XHR.sendCommand('PUT', _url, headers, request, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
                .then((doc) => doc.body.map((x) => new EntityBulkShareResult_1.EntityBulkShareResult(x, Invoice_1.Invoice)))
                .catch((err) => this.handleError(err));
        });
    }
    /**
     * @internal this method is for internal use only and may be changed without notice
     */
    bulkShareInvoicesMinimal(request) {
        return __awaiter(this, void 0, void 0, function* () {
            const _url = this.host + '/invoice/bulkSharedMetadataUpdateMinimal' + '?ts=' + new Date().getTime();
            let headers = yield this.headers;
            headers = headers.filter((h) => h.header !== 'Content-Type').concat(new XHR_1.XHR.Header('Content-Type', 'application/json'));
            return XHR_1.XHR.sendCommand('PUT', _url, headers, request, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
                .then((doc) => doc.body.map((x) => new MinimalEntityBulkShareResult_1.MinimalEntityBulkShareResult(x)))
                .catch((err) => this.handleError(err));
        });
    }
}
exports.IccInvoiceApi = IccInvoiceApi;
//# sourceMappingURL=IccInvoiceApi.js.map