"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.IccBesamv2Api = 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 Amp_1 = require("../model/Amp");
const Nmp_1 = require("../model/Nmp");
const PaginatedListAmp_1 = require("../model/PaginatedListAmp");
const PaginatedListNmp_1 = require("../model/PaginatedListNmp");
const PaginatedListVmp_1 = require("../model/PaginatedListVmp");
const PaginatedListVmpGroup_1 = require("../model/PaginatedListVmpGroup");
const Paragraph_1 = require("../model/Paragraph");
const PharmaceuticalForm_1 = require("../model/PharmaceuticalForm");
const SamVersion_1 = require("../model/SamVersion");
const Substance_1 = require("../model/Substance");
const Verse_1 = require("../model/Verse");
const Vmp_1 = require("../model/Vmp");
const VmpGroup_1 = require("../model/VmpGroup");
const AuthenticationProvider_1 = require("../../icc-x-api/auth/AuthenticationProvider");
const IccRestApiPath_1 = require("./IccRestApiPath");
const SamV2UpdateTaskLogItem_1 = require("../model/SamV2UpdateTaskLogItem");
const SamV2Update_1 = require("../model/SamV2Update");
const proxy_utils_1 = require("../../icc-x-api/utils/proxy-utils");
const SamText_1 = require("../model/SamText");
class IccBesamv2Api {
    constructor(host, headers, authenticationProvider, fetchImpl) {
        this.host = (0, proxy_utils_1.mapSamHost)((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;
    }
    /**
     * Warning: this function will work only with a single node installation of CouchDB
     *
     * Starts a new task on the backend that will retrieve all the missing updates on the drugs and ChapIV databases, and
     * it will apply them.
     * This method will fail if an update task is currently running or if the backend was not configured to run the update task.
     * As the operation may last several minutes, this process will not return the task status.
     * Instead, it is possible to check the status of the task using the {@link getSamUpdateTaskStatus} method.
     * @param apiToken a token from a cloud installation of the kraken.
     * @param forceSnapshot whether to apply only the latest diff patch or reset the database to the latest snapshot and apply the following patches.
     * @param purgeOutdatedEntities whether to purge the outdated entities from the diff patches or just soft-delete them (purges by default).
     */
    triggerSamUpdateTask(apiToken, forceSnapshot, purgeOutdatedEntities) {
        const _url = this.host +
            `/be_samv2/patch?apiToken=${encodeURIComponent(apiToken)}` +
            (forceSnapshot != null ? `&forceSnapshot=${forceSnapshot}` : ``) +
            (purgeOutdatedEntities != null ? `&purgeOutdatedEntities=${purgeOutdatedEntities}` : ``);
        let headers = this.headers;
        return XHR_1.XHR.sendCommand('POST', _url, headers, null, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => JSON.stringify(doc.body))
            .catch((err) => this.handleError(err));
    }
    /**
     * Warning: this function will work only with a single node installation of CouchDB
     * Returns the log of a SAM update operation that is running on the backend or the last the completed.
     * Starting a new task will erase the log of the previous task.
     * The item in the array are sorted from most recent to last recent.
     * This method will fail if the backend was not configured to run the update task.
     */
    getSamUpdateTaskStatus() {
        const _url = this.host + `/be_samv2/patch`;
        let headers = this.headers;
        return XHR_1.XHR.sendCommand('GET', _url, headers, null, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => doc.body.map((it) => new SamV2UpdateTaskLogItem_1.SamV2UpdateTaskLogItem(it)))
            .catch((err) => this.handleError(err));
    }
    /**
     * Warning: this function will work only with a single node installation of CouchDB
     * Returns all the SamV2 updates successfully applied to the drugs and ChapIV databases.
     * This method will fail if the backend was not configured to run the update task.
     */
    getSamUpdateTaskHistory() {
        const _url = this.host + `/be_samv2/patch/history`;
        let headers = this.headers;
        return XHR_1.XHR.sendCommand('GET', _url, headers, null, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => doc.body.map((it) => new SamV2Update_1.SamV2Update(it)))
            .catch((err) => this.handleError(err));
    }
    /**
     * Warning: this function will work only with a single node installation of CouchDB
     * Stops the current sam update task on the backend.
     * This method will fail if there is no method currently running on the backend or if the backend was not configured to run the update task.
     */
    stopCurrentSamUpdateTask() {
        const _url = this.host + `/be_samv2/patch`;
        let headers = this.headers;
        return XHR_1.XHR.sendCommand('DELETE', _url, headers, null, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => JSON.stringify(doc.body))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns a list of amps matched with given input. If several types are provided, paginantion is not supported
     * @summary Finding AMPs by dmpp code
     * @param dmppCode dmppCode
     */
    findAmpsByDmppCode(dmppCode) {
        let _body = null;
        const _url = this.host + `/be_samv2/amp/byDmppCode/${encodeURIComponent(String(dmppCode))}` + '?ts=' + new Date().getTime();
        let headers = this.headers;
        return XHR_1.XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => doc.body.map((it) => new Amp_1.Amp(it)))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns a list of amps matched with given input. If several types are provided, pagination is not supported
     * @summary Finding AMPs by amp code
     * @param ampCode ampCode
     */
    findAmpsByAmpCode(ampCode) {
        let _body = null;
        const _url = this.host + `/be_samv2/amp/byAmpCode/${encodeURIComponent(String(ampCode))}` + '?ts=' + new Date().getTime();
        let headers = this.headers;
        return XHR_1.XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => doc.body.map((it) => new Amp_1.Amp(it)))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns a list of amp names with that match the provided CNK.
     * @summary Finding AMPs names by CNK.
     * @param dmppCode the dmppCode
     */
    findAmpNamesByDmppCode(dmppCode) {
        const _url = this.host + `/be_samv2/amp/name/byDmppCode/${encodeURIComponent(dmppCode)}` + '?ts=' + new Date().getTime();
        let headers = this.headers;
        return XHR_1.XHR.sendCommand('GET', _url, headers, null, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => doc.body.map((it) => new SamText_1.SamText(it)))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns a list of codes matched with given input. If several types are provided, paginantion is not supported
     * @summary Finding AMPs by atc code with pagination.
     * @param atcCode atcCode
     * @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 amp document ID
     * @param limit Number of rows
     */
    findPaginatedAmpsByAtc(atcCode, startKey, startDocumentId, limit) {
        let _body = null;
        const _url = this.host +
            `/be_samv2/amp/byAtc/${encodeURIComponent(String(atcCode))}` +
            '?ts=' +
            new Date().getTime() +
            (startKey ? '&startKey=' + encodeURIComponent(String(startKey)) : '') +
            (startDocumentId ? '&startDocumentId=' + encodeURIComponent(String(startDocumentId)) : '') +
            (limit ? '&limit=' + encodeURIComponent(String(limit)) : '');
        let headers = this.headers;
        return XHR_1.XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => new PaginatedListAmp_1.PaginatedListAmp(doc.body))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns a list of codes matched with given input. If several types are provided, paginantion is not supported
     * @summary Finding AMPs by atc code with pagination.
     * @param atcCode atcCode
     * @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 amp document ID
     * @param limit Number of rows
     */
    findPaginatedAmpsByAtc1(atcCode, startKey, startDocumentId, limit) {
        let _body = null;
        const _url = this.host +
            `/be_samv2/vmp/byAtc/${encodeURIComponent(String(atcCode))}` +
            '?ts=' +
            new Date().getTime() +
            (startKey ? '&startKey=' + encodeURIComponent(String(startKey)) : '') +
            (startDocumentId ? '&startDocumentId=' + encodeURIComponent(String(startDocumentId)) : '') +
            (limit ? '&limit=' + encodeURIComponent(String(limit)) : '');
        let headers = this.headers;
        return XHR_1.XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => new PaginatedListAmp_1.PaginatedListAmp(doc.body))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns a list of codes matched with given input. If several types are provided, paginantion is not supported
     * @summary Finding AMPs by group with pagination.
     * @param vmpgCode vmpgCode
     * @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 vmp document ID
     * @param limit Number of rows
     */
    findPaginatedAmpsByGroupCode(vmpgCode, startKey, startDocumentId, limit) {
        let _body = null;
        const _url = this.host +
            `/be_samv2/amp/byGroupCode/${encodeURIComponent(String(vmpgCode))}` +
            '?ts=' +
            new Date().getTime() +
            (startKey ? '&startKey=' + encodeURIComponent(String(startKey)) : '') +
            (startDocumentId ? '&startDocumentId=' + encodeURIComponent(String(startDocumentId)) : '') +
            (limit ? '&limit=' + encodeURIComponent(String(limit)) : '');
        let headers = this.headers;
        return XHR_1.XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => new PaginatedListAmp_1.PaginatedListAmp(doc.body))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns a list of codes matched with given input. If several types are provided, paginantion is not supported
     * @summary Finding AMPs by group with pagination.
     * @param vmpgId vmpgCode
     * @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 vmp document ID
     * @param limit Number of rows
     */
    findPaginatedAmpsByGroupId(vmpgId, startKey, startDocumentId, limit) {
        let _body = null;
        const _url = this.host +
            `/be_samv2/amp/byGroupId/${encodeURIComponent(String(vmpgId))}` +
            '?ts=' +
            new Date().getTime() +
            (startKey ? '&startKey=' + encodeURIComponent(String(startKey)) : '') +
            (startDocumentId ? '&startDocumentId=' + encodeURIComponent(String(startDocumentId)) : '') +
            (limit ? '&limit=' + encodeURIComponent(String(limit)) : '');
        let headers = this.headers;
        return XHR_1.XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => new PaginatedListAmp_1.PaginatedListAmp(doc.body))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns a list of codes matched with given input. If several types are provided, paginantion is not supported
     * @summary Finding AMPs by label with pagination.
     * @param language language
     * @param label label
     * @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 An amp document ID
     * @param limit Number of rows
     */
    findPaginatedAmpsByLabel(language, label, startKey, startDocumentId, limit) {
        let _body = null;
        const _url = this.host +
            `/be_samv2/amp` +
            '?ts=' +
            new Date().getTime() +
            (language ? '&language=' + encodeURIComponent(String(language)) : '') +
            (label ? '&label=' + encodeURIComponent(String(label)) : '') +
            (startKey ? '&startKey=' + encodeURIComponent(String(startKey)) : '') +
            (startDocumentId ? '&startDocumentId=' + encodeURIComponent(String(startDocumentId)) : '') +
            (limit ? '&limit=' + encodeURIComponent(String(limit)) : '');
        let headers = this.headers;
        return XHR_1.XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => new PaginatedListAmp_1.PaginatedListAmp(doc.body))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns a list of codes matched with given input. If several types are provided, paginantion is not supported
     * @summary Finding AMPs by vmp code with pagination.
     * @param vmpCode vmpCode
     * @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 amp document ID
     * @param limit Number of rows
     */
    findPaginatedAmpsByVmpCode(vmpCode, startKey, startDocumentId, limit) {
        let _body = null;
        const _url = this.host +
            `/be_samv2/amp/byVmpCode/${encodeURIComponent(String(vmpCode))}` +
            '?ts=' +
            new Date().getTime() +
            (startKey ? '&startKey=' + encodeURIComponent(String(startKey)) : '') +
            (startDocumentId ? '&startDocumentId=' + encodeURIComponent(String(startDocumentId)) : '') +
            (limit ? '&limit=' + encodeURIComponent(String(limit)) : '');
        let headers = this.headers;
        return XHR_1.XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => new PaginatedListAmp_1.PaginatedListAmp(doc.body))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns a list of codes matched with given input. If several types are provided, paginantion is not supported
     * @summary Finding AMPs by vmp id with pagination.
     * @param vmpId vmpgCode
     * @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 amp document ID
     * @param limit Number of rows
     */
    findPaginatedAmpsByVmpId(vmpId, startKey, startDocumentId, limit) {
        let _body = null;
        const _url = this.host +
            `/be_samv2/amp/byVmpId/${encodeURIComponent(String(vmpId))}` +
            '?ts=' +
            new Date().getTime() +
            (startKey ? '&startKey=' + encodeURIComponent(String(startKey)) : '') +
            (startDocumentId ? '&startDocumentId=' + encodeURIComponent(String(startDocumentId)) : '') +
            (limit ? '&limit=' + encodeURIComponent(String(limit)) : '');
        let headers = this.headers;
        return XHR_1.XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => new PaginatedListAmp_1.PaginatedListAmp(doc.body))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns a paginated list of NMPs by matching label. Matches occur per word
     * @summary Finding NMPs by label with pagination.
     * @param language language
     * @param label label
     * @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 vmp document ID
     * @param limit Number of rows
     */
    findPaginatedNmpsByLabel(language, label, startKey, startDocumentId, limit) {
        let _body = null;
        const _url = this.host +
            `/be_samv2/nmp` +
            '?ts=' +
            new Date().getTime() +
            (language ? '&language=' + encodeURIComponent(String(language)) : '') +
            (label ? '&label=' + encodeURIComponent(String(label)) : '') +
            (startKey ? '&startKey=' + encodeURIComponent(String(startKey)) : '') +
            (startDocumentId ? '&startDocumentId=' + encodeURIComponent(String(startDocumentId)) : '') +
            (limit ? '&limit=' + encodeURIComponent(String(limit)) : '');
        let headers = this.headers;
        return XHR_1.XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => new PaginatedListNmp_1.PaginatedListNmp(doc.body))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns a list of codes matched with given input. If several types are provided, paginantion is not supported
     * @summary Finding VMP groups by language label with pagination.
     * @param language language
     * @param label label
     * @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 vmpgroup document ID
     * @param limit Number of rows
     */
    findPaginatedVmpGroupsByLabel(language, label, startKey, startDocumentId, limit) {
        let _body = null;
        const _url = this.host +
            `/be_samv2/vmpgroup` +
            '?ts=' +
            new Date().getTime() +
            (language ? '&language=' + encodeURIComponent(String(language)) : '') +
            (label ? '&label=' + encodeURIComponent(String(label)) : '') +
            (startKey ? '&startKey=' + encodeURIComponent(String(startKey)) : '') +
            (startDocumentId ? '&startDocumentId=' + encodeURIComponent(String(startDocumentId)) : '') +
            (limit ? '&limit=' + encodeURIComponent(String(limit)) : '');
        let headers = this.headers;
        return XHR_1.XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => new PaginatedListVmpGroup_1.PaginatedListVmpGroup(doc.body))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns a list of codes matched with given input. If several types are provided, paginantion is not supported
     * @summary Finding VMP groups by cmpgCode with pagination.
     * @param vmpgCode vmpgCode
     * @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 vmpgroup document ID
     * @param limit Number of rows
     */
    findPaginatedVmpGroupsByVmpGroupCode(vmpgCode, startKey, startDocumentId, limit) {
        let _body = null;
        const _url = this.host +
            `/be_samv2/vmpgroup/byGroupCode/${encodeURIComponent(String(vmpgCode))}` +
            '?ts=' +
            new Date().getTime() +
            (startKey ? '&startKey=' + encodeURIComponent(String(startKey)) : '') +
            (startDocumentId ? '&startDocumentId=' + encodeURIComponent(String(startDocumentId)) : '') +
            (limit ? '&limit=' + encodeURIComponent(String(limit)) : '');
        let headers = this.headers;
        return XHR_1.XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => new PaginatedListVmpGroup_1.PaginatedListVmpGroup(doc.body))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns a list of codes matched with given input. If several types are provided, paginantion is not supported
     * @summary Finding VMPs by group with pagination.
     * @param vmpgCode vmpgCode
     * @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 vmp document ID
     * @param limit Number of rows
     */
    findPaginatedVmpsByGroupCode(vmpgCode, startKey, startDocumentId, limit) {
        let _body = null;
        const _url = this.host +
            `/be_samv2/vmp/byGroupCode/${encodeURIComponent(String(vmpgCode))}` +
            '?ts=' +
            new Date().getTime() +
            (startKey ? '&startKey=' + encodeURIComponent(String(startKey)) : '') +
            (startDocumentId ? '&startDocumentId=' + encodeURIComponent(String(startDocumentId)) : '') +
            (limit ? '&limit=' + encodeURIComponent(String(limit)) : '');
        let headers = this.headers;
        return XHR_1.XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => new PaginatedListVmp_1.PaginatedListVmp(doc.body))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns a list of codes matched with given input. If several types are provided, paginantion is not supported
     * @summary Finding VMPs by group with pagination.
     * @param vmpgId vmpgId
     * @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 vmp document ID
     * @param limit Number of rows
     */
    findPaginatedVmpsByGroupId(vmpgId, startKey, startDocumentId, limit) {
        let _body = null;
        const _url = this.host +
            `/be_samv2/vmp/byGroupId/${encodeURIComponent(String(vmpgId))}` +
            '?ts=' +
            new Date().getTime() +
            (startKey ? '&startKey=' + encodeURIComponent(String(startKey)) : '') +
            (startDocumentId ? '&startDocumentId=' + encodeURIComponent(String(startDocumentId)) : '') +
            (limit ? '&limit=' + encodeURIComponent(String(limit)) : '');
        let headers = this.headers;
        return XHR_1.XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => new PaginatedListVmp_1.PaginatedListVmp(doc.body))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns a paginated list of VMPs by matching label. Matches occur per word
     * @summary Finding VMPs by label with pagination.
     * @param language language
     * @param label label
     * @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 vmp document ID
     * @param limit Number of rows
     */
    findPaginatedVmpsByLabel(language, label, startKey, startDocumentId, limit) {
        let _body = null;
        const _url = this.host +
            `/be_samv2/vmp` +
            '?ts=' +
            new Date().getTime() +
            (language ? '&language=' + encodeURIComponent(String(language)) : '') +
            (label ? '&label=' + encodeURIComponent(String(label)) : '') +
            (startKey ? '&startKey=' + encodeURIComponent(String(startKey)) : '') +
            (startDocumentId ? '&startDocumentId=' + encodeURIComponent(String(startDocumentId)) : '') +
            (limit ? '&limit=' + encodeURIComponent(String(limit)) : '');
        let headers = this.headers;
        return XHR_1.XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => new PaginatedListVmp_1.PaginatedListVmp(doc.body))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns a list of codes matched with given input. If several types are provided, paginantion is not supported
     * @summary Finding VMPs by group with pagination.
     * @param vmpCode vmpCode
     * @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 vmp document ID
     * @param limit Number of rows
     */
    findPaginatedVmpsByVmpCode(vmpCode, startKey, startDocumentId, limit) {
        let _body = null;
        const _url = this.host +
            `/be_samv2/vmp/byVmpCode/${encodeURIComponent(String(vmpCode))}` +
            '?ts=' +
            new Date().getTime() +
            (startKey ? '&startKey=' + encodeURIComponent(String(startKey)) : '') +
            (startDocumentId ? '&startDocumentId=' + encodeURIComponent(String(startDocumentId)) : '') +
            (limit ? '&limit=' + encodeURIComponent(String(limit)) : '');
        let headers = this.headers;
        return XHR_1.XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => new PaginatedListVmp_1.PaginatedListVmp(doc.body))
            .catch((err) => this.handleError(err));
    }
    /**
     *
     * @param searchString
     * @param language
     */
    findParagraphs(searchString, language) {
        let _body = null;
        const _url = this.host +
            `/be_samv2/chap/search/${encodeURIComponent(String(searchString))}/${encodeURIComponent(String(language))}` +
            '?ts=' +
            new Date().getTime();
        let headers = this.headers;
        return XHR_1.XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => doc.body.map((it) => new Paragraph_1.Paragraph(it)))
            .catch((err) => this.handleError(err));
    }
    /**
     *
     * @param cnk
     * @param language
     */
    findParagraphsWithCnk(cnk, language) {
        let _body = null;
        const _url = this.host + `/be_samv2/chap/bycnk/${encodeURIComponent(String(cnk))}/${encodeURIComponent(String(language))}` + '?ts=' + new Date().getTime();
        let headers = this.headers;
        return XHR_1.XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => doc.body.map((it) => new Paragraph_1.Paragraph(it)))
            .catch((err) => this.handleError(err));
    }
    /**
     *
     * @param chapterName
     * @param paragraphName
     * @param verseSeq
     * @param docSeq
     * @param language
     * @param response
     */
    getAddedDocument(chapterName, paragraphName, verseSeq, docSeq, language) {
        let _body = null;
        const _url = this.host +
            `/be_samv2/chap/${encodeURIComponent(String(chapterName))}/${encodeURIComponent(String(paragraphName))}/${encodeURIComponent(String(verseSeq))}/addeddoc/${encodeURIComponent(String(docSeq))}/${encodeURIComponent(String(language))}` +
            '?ts=' +
            new Date().getTime();
        let headers = this.headers;
        return XHR_1.XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => doc.body)
            .catch((err) => this.handleError(err));
    }
    /**
     *
     * @param chapterName
     * @param paragraphName
     */
    getAmpsForParagraph(chapterName, paragraphName) {
        let _body = null;
        const _url = this.host +
            `/be_samv2/chap/amps/${encodeURIComponent(String(chapterName))}/${encodeURIComponent(String(paragraphName))}` +
            '?ts=' +
            new Date().getTime();
        let headers = this.headers;
        return XHR_1.XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => doc.body.map((it) => new Amp_1.Amp(it)))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns a list of codes matched with given input. If several types are provided, paginantion is not supported
     * @summary Get Samv2 version.
     */
    getSamVersion() {
        let _body = null;
        const _url = this.host + `/be_samv2/v` + '?ts=' + new Date().getTime();
        let headers = this.headers;
        return XHR_1.XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => new SamVersion_1.SamVersion(doc.body))
            .catch((err) => this.handleError(err));
    }
    /**
     *
     * @param chapterName
     * @param paragraphName
     */
    getVersesHierarchy(chapterName, paragraphName) {
        let _body = null;
        const _url = this.host +
            `/be_samv2/chap/verse/${encodeURIComponent(String(chapterName))}/${encodeURIComponent(String(paragraphName))}` +
            '?ts=' +
            new Date().getTime();
        let headers = this.headers;
        return XHR_1.XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => new Verse_1.Verse(doc.body))
            .catch((err) => this.handleError(err));
    }
    /**
     *
     * @param chapterName
     * @param paragraphName
     * @param language
     */
    getVtmNamesForParagraph(chapterName, paragraphName, language) {
        let _body = null;
        const _url = this.host +
            `/be_samv2/chap/vtms/${encodeURIComponent(String(chapterName))}/${encodeURIComponent(String(paragraphName))}/${encodeURIComponent(String(language))}` +
            '?ts=' +
            new Date().getTime();
        let headers = this.headers;
        return XHR_1.XHR.sendCommand('GET', _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));
    }
    /**
     * Returns a list of amps matched with given input. If several types are provided, paginantion is not supported
     * @summary Finding AMPs by dmpp code
     * @param body
     */
    listAmpsByDmppCodes(body) {
        let _body = null;
        _body = body;
        const _url = this.host + `/be_samv2/amp/byDmppCodes` + '?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) => doc.body.map((it) => new Amp_1.Amp(it)))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns a list of codes matched with given input. If several types are provided, paginantion is not supported
     * @summary Finding AMPs by group.
     * @param body
     */
    listAmpsByGroupCodes(body) {
        let _body = null;
        _body = body;
        const _url = this.host + `/be_samv2/amp/byGroupCodes` + '?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) => doc.body.map((it) => new Amp_1.Amp(it)))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns a list of codes matched with given input. If several types are provided, paginantion is not supported
     * @summary Finding AMPs by group.
     * @param body
     */
    listAmpsByGroupIds(body) {
        let _body = null;
        _body = body;
        const _url = this.host + `/be_samv2/amp/byGroupIds` + '?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) => doc.body.map((it) => new Amp_1.Amp(it)))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns a list of codes matched with given input. If several types are provided, paginantion is not supported
     * @summary Finding AMPs by vmp code.
     * @param body
     */
    listAmpsByVmpCodes(body) {
        let _body = null;
        _body = body;
        const _url = this.host + `/be_samv2/amp/byVmpCodes` + '?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) => doc.body.map((it) => new Amp_1.Amp(it)))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns a list of codes matched with given input. If several types are provided, paginantion is not supported
     * @summary Finding AMPs by vmp id.
     * @param body
     */
    listAmpsByVmpIds(body) {
        let _body = null;
        _body = body;
        const _url = this.host + `/be_samv2/amp/byVmpIds` + '?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) => doc.body.map((it) => new Amp_1.Amp(it)))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns a list of codes matched with given input. If several types are provided, paginantion is not supported
     * @summary Finding NMPs by cnk id.
     * @param body
     */
    listNmpsByCnks(body) {
        let _body = null;
        _body = body;
        const _url = this.host + `/be_samv2/nmp/byCnks` + '?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) => doc.body.map((it) => new Nmp_1.Nmp(it)))
            .catch((err) => this.handleError(err));
    }
    /**
     *
     * @summary List all pharmaceutical forms.
     */
    listPharmaceuticalForms() {
        let _body = null;
        const _url = this.host + `/be_samv2/pharmaform` + '?ts=' + new Date().getTime();
        let headers = this.headers;
        return XHR_1.XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => doc.body.map((it) => new PharmaceuticalForm_1.PharmaceuticalForm(it)))
            .catch((err) => this.handleError(err));
    }
    /**
     *
     * @summary List all substances.
     */
    listSubstances() {
        let _body = null;
        const _url = this.host + `/be_samv2/substance` + '?ts=' + new Date().getTime();
        let headers = this.headers;
        return XHR_1.XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => doc.body.map((it) => new Substance_1.Substance(it)))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns a list of group codes matched with given input. If several types are provided, paginantion is not supported
     * @summary Finding AMPs by group.
     * @param body
     */
    listVmpGroupsByVmpGroupCodes(body) {
        let _body = null;
        _body = body;
        const _url = this.host + `/be_samv2/vmpgroup/byGroupCodes` + '?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) => doc.body.map((it) => new VmpGroup_1.VmpGroup(it)))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns a list of codes matched with given input. If several types are provided, paginantion is not supported
     * @summary Finding VMPs by group.
     * @param body
     */
    listVmpsByGroupIds(body) {
        let _body = null;
        _body = body;
        const _url = this.host + `/be_samv2/vmp/byGroupIds` + '?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) => doc.body.map((it) => new Vmp_1.Vmp(it)))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns a list of codes matched with given input. If several types are provided, paginantion is not supported
     * @summary Finding VMPs by group.
     * @param body
     */
    listVmpsByVmpCodes(body) {
        let _body = null;
        _body = body;
        const _url = this.host + `/be_samv2/vmp/byVmpCodes` + '?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) => doc.body.map((it) => new Vmp_1.Vmp(it)))
            .catch((err) => this.handleError(err));
    }
}
exports.IccBesamv2Api = IccBesamv2Api;
//# sourceMappingURL=IccBesamv2Api.js.map