"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.IccBeresultexportApi = 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 AuthenticationProvider_1 = require("../../icc-x-api/auth/AuthenticationProvider");
const IccRestApiPath_1 = require("./IccRestApiPath");
class IccBeresultexportApi {
    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 Export data
     * @param body
     * @param fromHcpId
     * @param toHcpId
     * @param patId
     * @param date
     * @param ref
     */
    exportHealthOne(fromHcpId, toHcpId, patId, date, ref, body) {
        let _body = null;
        _body = body;
        const _url = this.host +
            `/be_result_export/hl1/${encodeURIComponent(String(fromHcpId))}/${encodeURIComponent(String(toHcpId))}/${encodeURIComponent(String(patId))}/${encodeURIComponent(String(date))}/${encodeURIComponent(String(ref))}` +
            '?ts=' +
            new Date().getTime();
        let headers = this.headers;
        headers = headers.filter((h) => h.header !== 'Content-Type').concat(new XHR_1.XHR.Header('Content-Type', 'application/octet-stream'));
        return XHR_1.XHR.sendCommand('POST', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => doc.body)
            .catch((err) => this.handleError(err));
    }
    /**
     *
     * @summary Export data
     * @param body
     * @param fromHcpId
     * @param toHcpId
     * @param patId
     * @param date
     * @param ref
     * @param mimeType
     */
    exportKmehrReport(fromHcpId, toHcpId, patId, date, ref, mimeType, body) {
        let _body = null;
        _body = body;
        const _url = this.host +
            `/be_result_export/kmehrreport/${encodeURIComponent(String(fromHcpId))}/${encodeURIComponent(String(toHcpId))}/${encodeURIComponent(String(patId))}/${encodeURIComponent(String(date))}/${encodeURIComponent(String(ref))}` +
            '?ts=' +
            new Date().getTime() +
            (mimeType ? '&mimeType=' + encodeURIComponent(String(mimeType)) : '');
        let headers = this.headers;
        headers = headers.filter((h) => h.header !== 'Content-Type').concat(new XHR_1.XHR.Header('Content-Type', 'application/octet-stream'));
        return XHR_1.XHR.sendCommand('POST', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => doc.body)
            .catch((err) => this.handleError(err));
    }
    /**
     *
     * @summary Export data
     * @param body
     * @param fromHcpId
     * @param toHcpId
     * @param patId
     * @param date
     * @param ref
     */
    exportMedidoc(fromHcpId, toHcpId, patId, date, ref, body) {
        let _body = null;
        _body = body;
        const _url = this.host +
            `/be_result_export/medidoc/${encodeURIComponent(String(fromHcpId))}/${encodeURIComponent(String(toHcpId))}/${encodeURIComponent(String(patId))}/${encodeURIComponent(String(date))}/${encodeURIComponent(String(ref))}` +
            '?ts=' +
            new Date().getTime();
        let headers = this.headers;
        headers = headers.filter((h) => h.header !== 'Content-Type').concat(new XHR_1.XHR.Header('Content-Type', 'application/octet-stream'));
        return XHR_1.XHR.sendCommand('POST', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => doc.body)
            .catch((err) => this.handleError(err));
    }
}
exports.IccBeresultexportApi = IccBeresultexportApi;
//# sourceMappingURL=IccBeresultexportApi.js.map