"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.IccBekmehrApi = 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 CheckSMFPatientResult_1 = require("../model/CheckSMFPatientResult");
const Content_1 = require("../model/Content");
const ImportResult_1 = require("../model/ImportResult");
const SumehrContent_1 = require("../model/SumehrContent");
const SumehrValidity_1 = require("../model/SumehrValidity");
const AuthenticationProvider_1 = require("../../icc-x-api/auth/AuthenticationProvider");
const IccRestApiPath_1 = require("./IccRestApiPath");
const proxy_utils_1 = require("../../icc-x-api/utils/proxy-utils");
class IccBekmehrApi {
    constructor(host, headers, authenticationProvider, fetchImpl) {
        this.host = (0, proxy_utils_1.mapKmehrHost)((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 Check whether patients in SMF already exists in DB
     * @param body
     * @param documentId
     * @param documentKey
     * @param patientId
     * @param language
     */
    checkIfSMFPatientsExists(documentId, documentKey, patientId, language, body) {
        let _body = null;
        _body = body;
        const _url = this.host +
            `/be_kmehr/smf/${encodeURIComponent(String(documentId))}/checkIfSMFPatientsExists` +
            '?ts=' +
            new Date().getTime() +
            (documentKey ? '&documentKey=' + encodeURIComponent(String(documentKey)) : '') +
            (patientId ? '&patientId=' + encodeURIComponent(String(patientId)) : '') +
            (language ? '&language=' + encodeURIComponent(String(language)) : '');
        let headers = 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 CheckSMFPatientResult_1.CheckSMFPatientResult(it)))
            .catch((err) => this.handleError(err));
    }
    /**
     *
     * @summary Get Kmehr contactreport
     * @param body
     * @param patientId
     * @param id
     * @param date
     * @param language
     * @param recipientNihii
     * @param recipientSsin
     * @param recipientFirstName
     * @param recipientLastName
     * @param mimeType
     */
    generateContactreportExport(patientId, id, date, language, recipientNihii, recipientSsin, recipientFirstName, recipientLastName, mimeType, body) {
        let _body = null;
        _body = body;
        const _url = this.host +
            `/be_kmehr/contactreport/${encodeURIComponent(String(patientId))}/export/${encodeURIComponent(String(id))}` +
            '?ts=' +
            new Date().getTime() +
            (date ? '&date=' + encodeURIComponent(String(date)) : '') +
            (language ? '&language=' + encodeURIComponent(String(language)) : '') +
            (recipientNihii ? '&recipientNihii=' + encodeURIComponent(String(recipientNihii)) : '') +
            (recipientSsin ? '&recipientSsin=' + encodeURIComponent(String(recipientSsin)) : '') +
            (recipientFirstName ? '&recipientFirstName=' + encodeURIComponent(String(recipientFirstName)) : '') +
            (recipientLastName ? '&recipientLastName=' + encodeURIComponent(String(recipientLastName)) : '') +
            (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 Generate diarynote
     * @param body
     * @param patientId
     * @param language
     */
    generateDiaryNote(patientId, language, body) {
        let _body = null;
        _body = body;
        const _url = this.host +
            `/be_kmehr/diarynote/${encodeURIComponent(String(patientId))}/export` +
            '?ts=' +
            new Date().getTime() +
            (language ? '&language=' + encodeURIComponent(String(language)) : '');
        let headers = 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)
            .catch((err) => this.handleError(err));
    }
    /**
     *
     * @summary Get Incapacity export
     * @param patientId
     * @param language
     * @param body
     * @param xTimezoneOffset
     */
    generateIncapacityExport(patientId, language, body, xTimezoneOffset) {
        let _body = null;
        _body = body;
        const _url = this.host +
            `/be_kmehr/incapacity/${encodeURIComponent(String(patientId))}/export` +
            '?ts=' +
            new Date().getTime() +
            (language ? '&language=' + encodeURIComponent(String(language)) : '');
        let headers = this.headers;
        headers = headers.filter((h) => h.header !== 'Content-Type').concat(new XHR_1.XHR.Header('Content-Type', 'application/json'));
        xTimezoneOffset && (headers = headers.concat(new XHR_1.XHR.Header('X-Timezone-Offset', xTimezoneOffset)));
        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 Get Kmehr labresult
     * @param body
     * @param patientId
     * @param id
     * @param date
     * @param language
     * @param recipientNihii
     * @param recipientSsin
     * @param recipientFirstName
     * @param recipientLastName
     * @param mimeType
     */
    generateLabresultExport(patientId, id, date, language, recipientNihii, recipientSsin, recipientFirstName, recipientLastName, mimeType, body) {
        let _body = null;
        _body = body;
        const _url = this.host +
            `/be_kmehr/labresult/${encodeURIComponent(String(patientId))}/export/${encodeURIComponent(String(id))}` +
            '?ts=' +
            new Date().getTime() +
            (date ? '&date=' + encodeURIComponent(String(date)) : '') +
            (language ? '&language=' + encodeURIComponent(String(language)) : '') +
            (recipientNihii ? '&recipientNihii=' + encodeURIComponent(String(recipientNihii)) : '') +
            (recipientSsin ? '&recipientSsin=' + encodeURIComponent(String(recipientSsin)) : '') +
            (recipientFirstName ? '&recipientFirstName=' + encodeURIComponent(String(recipientFirstName)) : '') +
            (recipientLastName ? '&recipientLastName=' + encodeURIComponent(String(recipientLastName)) : '') +
            (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 Get Medicationscheme export
     * @param body
     * @param xTimezoneOffset
     * @param patientId
     * @param language
     * @param recipientSafe
     * @param xTimezoneOffset
     * @param version
     */
    generateMedicationSchemeExport(patientId, language, recipientSafe, xTimezoneOffset, version = 0, body) {
        let _body = null;
        _body = body;
        const _url = this.host +
            `/be_kmehr/medicationscheme/${encodeURIComponent(String(patientId))}/export` +
            '?ts=' +
            new Date().getTime() +
            (language ? '&language=' + encodeURIComponent(String(language)) : '') +
            (recipientSafe ? '&recipientSafe=' + encodeURIComponent(String(recipientSafe)) : '') +
            ('&version=' + encodeURIComponent(String(version !== null && version !== void 0 ? version : 0)));
        let headers = this.headers;
        headers = headers.filter((h) => h.header !== 'Content-Type').concat(new XHR_1.XHR.Header('Content-Type', 'application/json'));
        xTimezoneOffset && (headers = headers.concat(new XHR_1.XHR.Header('X-Timezone-Offset', xTimezoneOffset)));
        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 Get Kmehr note
     * @param body
     * @param patientId
     * @param id
     * @param date
     * @param language
     * @param recipientNihii
     * @param recipientSsin
     * @param recipientFirstName
     * @param recipientLastName
     * @param mimeType
     */
    generateNoteExport(patientId, id, date, language, recipientNihii, recipientSsin, recipientFirstName, recipientLastName, mimeType, body) {
        let _body = null;
        _body = body;
        const _url = this.host +
            `/be_kmehr/note/${encodeURIComponent(String(patientId))}/export/${encodeURIComponent(String(id))}` +
            '?ts=' +
            new Date().getTime() +
            (date ? '&date=' + encodeURIComponent(String(date)) : '') +
            (language ? '&language=' + encodeURIComponent(String(language)) : '') +
            (recipientNihii ? '&recipientNihii=' + encodeURIComponent(String(recipientNihii)) : '') +
            (recipientSsin ? '&recipientSsin=' + encodeURIComponent(String(recipientSsin)) : '') +
            (recipientFirstName ? '&recipientFirstName=' + encodeURIComponent(String(recipientFirstName)) : '') +
            (recipientLastName ? '&recipientLastName=' + encodeURIComponent(String(recipientLastName)) : '') +
            (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 Get KMEHR Patient Info export
     * @param patientId
     * @param language
     */
    generatePatientInfoExport(patientId, language) {
        let _body = null;
        const _url = this.host +
            `/be_kmehr/patientinfo/${encodeURIComponent(String(patientId))}/export` +
            '?ts=' +
            new Date().getTime() +
            (language ? '&language=' + encodeURIComponent(String(language)) : '');
        let headers = this.headers;
        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 Get Kmehr prescription
     * @param body
     * @param patientId
     * @param id
     * @param date
     * @param language
     * @param recipientNihii
     * @param recipientSsin
     * @param recipientFirstName
     * @param recipientLastName
     * @param mimeType
     */
    generatePrescriptionExport(patientId, id, date, language, recipientNihii, recipientSsin, recipientFirstName, recipientLastName, mimeType, body) {
        let _body = null;
        _body = body;
        const _url = this.host +
            `/be_kmehr/prescription/${encodeURIComponent(String(patientId))}/export/${encodeURIComponent(String(id))}` +
            '?ts=' +
            new Date().getTime() +
            (date ? '&date=' + encodeURIComponent(String(date)) : '') +
            (language ? '&language=' + encodeURIComponent(String(language)) : '') +
            (recipientNihii ? '&recipientNihii=' + encodeURIComponent(String(recipientNihii)) : '') +
            (recipientSsin ? '&recipientSsin=' + encodeURIComponent(String(recipientSsin)) : '') +
            (recipientFirstName ? '&recipientFirstName=' + encodeURIComponent(String(recipientFirstName)) : '') +
            (recipientLastName ? '&recipientLastName=' + encodeURIComponent(String(recipientLastName)) : '') +
            (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 Get Kmehr report
     * @param body
     * @param patientId
     * @param id
     * @param date
     * @param language
     * @param recipientNihii
     * @param recipientSsin
     * @param recipientFirstName
     * @param recipientLastName
     * @param mimeType
     */
    generateReportExport(patientId, id, date, language, recipientNihii, recipientSsin, recipientFirstName, recipientLastName, mimeType, body) {
        let _body = null;
        _body = body;
        const _url = this.host +
            `/be_kmehr/report/${encodeURIComponent(String(patientId))}/export/${encodeURIComponent(String(id))}` +
            '?ts=' +
            new Date().getTime() +
            (date ? '&date=' + encodeURIComponent(String(date)) : '') +
            (language ? '&language=' + encodeURIComponent(String(language)) : '') +
            (recipientNihii ? '&recipientNihii=' + encodeURIComponent(String(recipientNihii)) : '') +
            (recipientSsin ? '&recipientSsin=' + encodeURIComponent(String(recipientSsin)) : '') +
            (recipientFirstName ? '&recipientFirstName=' + encodeURIComponent(String(recipientFirstName)) : '') +
            (recipientLastName ? '&recipientLastName=' + encodeURIComponent(String(recipientLastName)) : '') +
            (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 Get Kmehr request
     * @param body
     * @param patientId
     * @param id
     * @param date
     * @param language
     * @param recipientNihii
     * @param recipientSsin
     * @param recipientFirstName
     * @param recipientLastName
     * @param mimeType
     */
    generateRequestExport(patientId, id, date, language, recipientNihii, recipientSsin, recipientFirstName, recipientLastName, mimeType, body) {
        let _body = null;
        _body = body;
        const _url = this.host +
            `/be_kmehr/request/${encodeURIComponent(String(patientId))}/export/${encodeURIComponent(String(id))}` +
            '?ts=' +
            new Date().getTime() +
            (date ? '&date=' + encodeURIComponent(String(date)) : '') +
            (language ? '&language=' + encodeURIComponent(String(language)) : '') +
            (recipientNihii ? '&recipientNihii=' + encodeURIComponent(String(recipientNihii)) : '') +
            (recipientSsin ? '&recipientSsin=' + encodeURIComponent(String(recipientSsin)) : '') +
            (recipientFirstName ? '&recipientFirstName=' + encodeURIComponent(String(recipientFirstName)) : '') +
            (recipientLastName ? '&recipientLastName=' + encodeURIComponent(String(recipientLastName)) : '') +
            (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 Get Kmehr result
     * @param body
     * @param patientId
     * @param id
     * @param date
     * @param language
     * @param recipientNihii
     * @param recipientSsin
     * @param recipientFirstName
     * @param recipientLastName
     * @param mimeType
     */
    generateResultExport(patientId, id, date, language, recipientNihii, recipientSsin, recipientFirstName, recipientLastName, mimeType, body) {
        let _body = null;
        _body = body;
        const _url = this.host +
            `/be_kmehr/result/${encodeURIComponent(String(patientId))}/export/${encodeURIComponent(String(id))}` +
            '?ts=' +
            new Date().getTime() +
            (date ? '&date=' + encodeURIComponent(String(date)) : '') +
            (language ? '&language=' + encodeURIComponent(String(language)) : '') +
            (recipientNihii ? '&recipientNihii=' + encodeURIComponent(String(recipientNihii)) : '') +
            (recipientSsin ? '&recipientSsin=' + encodeURIComponent(String(recipientSsin)) : '') +
            (recipientFirstName ? '&recipientFirstName=' + encodeURIComponent(String(recipientFirstName)) : '') +
            (recipientLastName ? '&recipientLastName=' + encodeURIComponent(String(recipientLastName)) : '') +
            (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 Get SMF (Software Medical File) export
     * @param body
     * @param patientId
     * @param language
     */
    generateSmfExport(patientId, language, body) {
        let _body = null;
        _body = body;
        const _url = this.host +
            `/be_kmehr/smf/${encodeURIComponent(String(patientId))}/export` +
            '?ts=' +
            new Date().getTime() +
            (language ? '&language=' + encodeURIComponent(String(language)) : '');
        let headers = 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)
            .catch((err) => this.handleError(err));
    }
    /**
     *
     * @summary Generate sumehr
     * @param body
     * @param patientId
     * @param language
     */
    generateSumehr(patientId, language, body) {
        let _body = null;
        _body = body;
        const _url = this.host +
            `/be_kmehr/sumehr/${encodeURIComponent(String(patientId))}/export` +
            '?ts=' +
            new Date().getTime() +
            (language ? '&language=' + encodeURIComponent(String(language)) : '');
        let headers = 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)
            .catch((err) => this.handleError(err));
    }
    /**
     *
     * @summary Generate sumehr
     * @param body
     * @param patientId
     * @param language
     */
    generateSumehrV2(patientId, language, body) {
        let _body = null;
        _body = body;
        const _url = this.host +
            `/be_kmehr/sumehrv2/${encodeURIComponent(String(patientId))}/export` +
            '?ts=' +
            new Date().getTime() +
            (language ? '&language=' + encodeURIComponent(String(language)) : '');
        let headers = 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)
            .catch((err) => this.handleError(err));
    }
    /**
     *
     * @summary Get sumehr elements
     * @param body
     * @param patientId
     */
    getSumehrContent(patientId, body) {
        let _body = null;
        _body = body;
        const _url = this.host + `/be_kmehr/sumehr/${encodeURIComponent(String(patientId))}/content` + '?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/json'));
        return XHR_1.XHR.sendCommand('POST', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => new SumehrContent_1.SumehrContent(doc.body))
            .catch((err) => this.handleError(err));
    }
    /**
     *
     * @summary Check sumehr signature
     * @param body
     * @param patientId
     */
    getSumehrMd5(patientId, body) {
        let _body = null;
        _body = body;
        const _url = this.host + `/be_kmehr/sumehr/${encodeURIComponent(String(patientId))}/md5` + '?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/json'));
        return XHR_1.XHR.sendCommand('POST', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => new Content_1.Content(doc.body))
            .catch((err) => this.handleError(err));
    }
    /**
     *
     * @summary Get sumehr elements
     * @param body
     * @param patientId
     */
    getSumehrV2Content(patientId, body) {
        let _body = null;
        _body = body;
        const _url = this.host + `/be_kmehr/sumehrv2/${encodeURIComponent(String(patientId))}/content` + '?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/json'));
        return XHR_1.XHR.sendCommand('POST', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => new SumehrContent_1.SumehrContent(doc.body))
            .catch((err) => this.handleError(err));
    }
    /**
     *
     * @summary Check sumehr signature
     * @param body
     * @param patientId
     */
    getSumehrV2Md5(patientId, body) {
        let _body = null;
        _body = body;
        const _url = this.host + `/be_kmehr/sumehrv2/${encodeURIComponent(String(patientId))}/md5` + '?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/json'));
        return XHR_1.XHR.sendCommand('POST', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => new Content_1.Content(doc.body))
            .catch((err) => this.handleError(err));
    }
    /**
     *
     * @summary Import MedicationScheme into patient(s) using existing document
     * @param body
     * @param documentId
     * @param documentKey
     * @param dryRun Dry run: do not save in database
     * @param patientId
     * @param language
     */
    importMedicationScheme(documentId, documentKey, dryRun, patientId, language, body) {
        let _body = null;
        _body = body;
        const _url = this.host +
            `/be_kmehr/medicationscheme/${encodeURIComponent(String(documentId))}/import` +
            '?ts=' +
            new Date().getTime() +
            (documentKey ? '&documentKey=' + encodeURIComponent(String(documentKey)) : '') +
            (dryRun ? '&dryRun=' + encodeURIComponent(String(dryRun)) : '') +
            (patientId ? '&patientId=' + encodeURIComponent(String(patientId)) : '') +
            (language ? '&language=' + encodeURIComponent(String(language)) : '');
        let headers = 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 ImportResult_1.ImportResult(it)))
            .catch((err) => this.handleError(err));
    }
    /**
     *
     * @summary Import SMF into patient(s) using existing document
     * @param body
     * @param documentId
     * @param documentKey
     * @param patientId
     * @param language
     * @param dryRun
     */
    importSmf(documentId, documentKey, patientId, language, dryRun, body) {
        let _body = null;
        _body = body;
        const _url = this.host +
            `/be_kmehr/smf/${encodeURIComponent(String(documentId))}/import` +
            '?ts=' +
            new Date().getTime() +
            (documentKey ? '&documentKey=' + encodeURIComponent(String(documentKey)) : '') +
            (patientId ? '&patientId=' + encodeURIComponent(String(patientId)) : '') +
            (language ? '&language=' + encodeURIComponent(String(language)) : '') +
            (dryRun ? '&dryRun=' + encodeURIComponent(String(dryRun)) : '');
        let headers = 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 ImportResult_1.ImportResult(it)))
            .catch((err) => this.handleError(err));
    }
    /**
     *
     * @summary Import sumehr into patient(s) using existing document
     * @param body
     * @param documentId
     * @param documentKey
     * @param dryRun Dry run: do not save in database
     * @param patientId
     * @param language
     */
    importSumehr(documentId, documentKey, dryRun, patientId, language, body) {
        let _body = null;
        _body = body;
        const _url = this.host +
            `/be_kmehr/sumehr/${encodeURIComponent(String(documentId))}/import` +
            '?ts=' +
            new Date().getTime() +
            (documentKey ? '&documentKey=' + encodeURIComponent(String(documentKey)) : '') +
            (dryRun ? '&dryRun=' + encodeURIComponent(String(dryRun)) : '') +
            (patientId ? '&patientId=' + encodeURIComponent(String(patientId)) : '') +
            (language ? '&language=' + encodeURIComponent(String(language)) : '');
        let headers = 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 ImportResult_1.ImportResult(it)))
            .catch((err) => this.handleError(err));
    }
    /**
     *
     * @summary Import sumehr into patient(s) using existing document
     * @param body
     * @param documentId
     * @param itemId
     * @param documentKey
     * @param dryRun Dry run: do not save in database
     * @param patientId
     * @param language
     */
    importSumehrByItemId(documentId, itemId, documentKey, dryRun, patientId, language, body) {
        let _body = null;
        _body = body;
        const _url = this.host +
            `/be_kmehr/sumehr/${encodeURIComponent(String(documentId))}/importbyitemid` +
            '?ts=' +
            new Date().getTime() +
            (itemId ? '&itemId=' + encodeURIComponent(String(itemId)) : '') +
            (documentKey ? '&documentKey=' + encodeURIComponent(String(documentKey)) : '') +
            (dryRun ? '&dryRun=' + encodeURIComponent(String(dryRun)) : '') +
            (patientId ? '&patientId=' + encodeURIComponent(String(patientId)) : '') +
            (language ? '&language=' + encodeURIComponent(String(language)) : '');
        let headers = 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 ImportResult_1.ImportResult(it)))
            .catch((err) => this.handleError(err));
    }
    /**
     *
     * @summary Get sumehr validity
     * @param body
     * @param patientId
     */
    isSumehrV2Valid(patientId, body) {
        let _body = null;
        _body = body;
        const _url = this.host + `/be_kmehr/sumehrv2/${encodeURIComponent(String(patientId))}/valid` + '?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/json'));
        return XHR_1.XHR.sendCommand('POST', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => new SumehrValidity_1.SumehrValidity(doc.body))
            .catch((err) => this.handleError(err));
    }
    /**
     *
     * @summary Get sumehr validity
     * @param body
     * @param patientId
     */
    isSumehrValid(patientId, body) {
        let _body = null;
        _body = body;
        const _url = this.host + `/be_kmehr/sumehr/${encodeURIComponent(String(patientId))}/valid` + '?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/json'));
        return XHR_1.XHR.sendCommand('POST', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => new SumehrValidity_1.SumehrValidity(doc.body))
            .catch((err) => this.handleError(err));
    }
    /**
     *
     * @summary Validate sumehr
     * @param body
     * @param patientId
     * @param language
     */
    validateSumehr(patientId, language, body) {
        let _body = null;
        _body = body;
        const _url = this.host +
            `/be_kmehr/sumehr/${encodeURIComponent(String(patientId))}/validate` +
            '?ts=' +
            new Date().getTime() +
            (language ? '&language=' + encodeURIComponent(String(language)) : '');
        let headers = 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)
            .catch((err) => this.handleError(err));
    }
    /**
     *
     * @summary Validate sumehr
     * @param body
     * @param patientId
     * @param language
     */
    validateSumehrV2(patientId, language, body) {
        let _body = null;
        _body = body;
        const _url = this.host +
            `/be_kmehr/sumehrv2/${encodeURIComponent(String(patientId))}/validate` +
            '?ts=' +
            new Date().getTime() +
            (language ? '&language=' + encodeURIComponent(String(language)) : '');
        let headers = 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)
            .catch((err) => this.handleError(err));
    }
}
exports.IccBekmehrApi = IccBekmehrApi;
//# sourceMappingURL=IccBekmehrApi.js.map