"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.IccTmpApi = 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 Classification_1 = require("../model/Classification");
const Contact_1 = require("../model/Contact");
const DocIdentifier_1 = require("../model/DocIdentifier");
const Document_1 = require("../model/Document");
const EntityTemplate_1 = require("../model/EntityTemplate");
const Form_1 = require("../model/Form");
const HealthElement_1 = require("../model/HealthElement");
const Invoice_1 = require("../model/Invoice");
const Message_1 = require("../model/Message");
const PaginatedListClassification_1 = require("../model/PaginatedListClassification");
const PaginatedListDocument_1 = require("../model/PaginatedListDocument");
const PaginatedListEntityTemplate_1 = require("../model/PaginatedListEntityTemplate");
const PaginatedListForm_1 = require("../model/PaginatedListForm");
const PaginatedListHealthElement_1 = require("../model/PaginatedListHealthElement");
const PaginatedListInvoice_1 = require("../model/PaginatedListInvoice");
const PaginatedListPatient_1 = require("../model/PaginatedListPatient");
const Patient_1 = require("../model/Patient");
const ReplicatorDocument_1 = require("../model/ReplicatorDocument");
const Unit_1 = require("../model/Unit");
const AuthenticationProvider_1 = require("../../icc-x-api/auth/AuthenticationProvider");
const IccRestApiPath_1 = require("./IccRestApiPath");
class IccTmpApi {
    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;
    }
    /**
     * Returns an instance of created classification.
     * @summary Create a classification with the current user
     * @param body
     */
    createTmpClassification(body) {
        let _body = null;
        _body = body;
        const _url = this.host + `/tmp/classification` + '?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 Classification_1.Classification(doc.body))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns an instance of created classification.
     * @summary Create a classification with the current user
     * @param body
     */
    createTmpClassifications(body) {
        let _body = null;
        _body = body;
        const _url = this.host + `/tmp/classification/batch` + '?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 Classification_1.Classification(it)))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns an instance of created contact.
     * @summary Create a contact with the current user
     * @param body
     */
    createTmpContact(body) {
        let _body = null;
        _body = body;
        const _url = this.host + `/tmp/contact` + '?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 Contact_1.Contact(doc.body))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns an instance of created contact.
     * @summary Create a contact with the current user
     * @param body
     */
    createTmpContacts(body) {
        let _body = null;
        _body = body;
        const _url = this.host + `/tmp/contact/batch` + '?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 Contact_1.Contact(it)))
            .catch((err) => this.handleError(err));
    }
    /**
     * Nothing happens if the database already exists
     * @summary Create tmp database for current user
     */
    createTmpDatabase() {
        let _body = null;
        const _url = this.host + `/tmp` + '?ts=' + new Date().getTime();
        let headers = this.headers;
        return XHR_1.XHR.sendCommand('POST', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => new Unit_1.Unit(doc.body))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns an instance of created document.
     * @summary Create a document with the current user
     * @param body
     */
    createTmpDocument(body) {
        let _body = null;
        _body = body;
        const _url = this.host + `/tmp/document` + '?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 Document_1.Document(doc.body))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns an instance of created document.
     * @summary Create a document with the current user
     * @param body
     */
    createTmpDocuments(body) {
        let _body = null;
        _body = body;
        const _url = this.host + `/tmp/document/batch` + '?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 Document_1.Document(it)))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns an instance of created entityTemplate.
     * @summary Create a entityTemplate with the current user
     * @param body
     */
    createTmpEntityTemplate(body) {
        let _body = null;
        _body = body;
        const _url = this.host + `/tmp/entityTemplate` + '?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 EntityTemplate_1.EntityTemplate(doc.body))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns an instance of created entityTemplate.
     * @summary Create a entityTemplate with the current user
     * @param body
     */
    createTmpEntityTemplates(body) {
        let _body = null;
        _body = body;
        const _url = this.host + `/tmp/entityTemplate/batch` + '?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 EntityTemplate_1.EntityTemplate(it)))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns an instance of created form.
     * @summary Create a form with the current user
     * @param body
     */
    createTmpForm(body) {
        let _body = null;
        _body = body;
        const _url = this.host + `/tmp/form` + '?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 Form_1.Form(doc.body))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns an instance of created form.
     * @summary Create a form with the current user
     * @param body
     */
    createTmpForms(body) {
        let _body = null;
        _body = body;
        const _url = this.host + `/tmp/form/batch` + '?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 Form_1.Form(it)))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns an instance of created healthElement.
     * @summary Create a healthElement with the current user
     * @param body
     */
    createTmpHealthElement(body) {
        let _body = null;
        _body = body;
        const _url = this.host + `/tmp/healthElement` + '?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 HealthElement_1.HealthElement(doc.body))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns an instance of created healthElement.
     * @summary Create a healthElement with the current user
     * @param body
     */
    createTmpHealthElements(body) {
        let _body = null;
        _body = body;
        const _url = this.host + `/tmp/healthElement/batch` + '?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 HealthElement_1.HealthElement(it)))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns an instance of created invoice.
     * @summary Create a invoice with the current user
     * @param body
     */
    createTmpInvoice(body) {
        let _body = null;
        _body = body;
        const _url = this.host + `/tmp/invoice` + '?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 Invoice_1.Invoice(doc.body))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns an instance of created invoice.
     * @summary Create a invoice with the current user
     * @param body
     */
    createTmpInvoices(body) {
        let _body = null;
        _body = body;
        const _url = this.host + `/tmp/invoice/batch` + '?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 Invoice_1.Invoice(it)))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns an instance of created message.
     * @summary Create a message with the current user
     * @param body
     */
    createTmpMessage(body) {
        let _body = null;
        _body = body;
        const _url = this.host + `/tmp/message` + '?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 Message_1.Message(doc.body))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns an instance of created message.
     * @summary Create a message with the current user
     * @param body
     */
    createTmpMessages(body) {
        let _body = null;
        _body = body;
        const _url = this.host + `/tmp/message/batch` + '?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 Message_1.Message(it)))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns an instance of created patient.
     * @summary Create a patient with the current user
     * @param body
     */
    createTmpPatient(body) {
        let _body = null;
        _body = body;
        const _url = this.host + `/tmp/patient` + '?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 Patient_1.Patient(doc.body))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns an instance of created patient.
     * @summary Create a patient with the current user
     * @param body
     */
    createTmpPatients(body) {
        let _body = null;
        _body = body;
        const _url = this.host + `/tmp/patient/batch` + '?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 Patient_1.Patient(it)))
            .catch((err) => this.handleError(err));
    }
    /**
     * Deletes a document's attachment and returns the modified document instance afterward
     * @summary Delete a document's attachment
     * @param documentId
     */
    deleteTmpDocumentAttachment(documentId) {
        let _body = null;
        const _url = this.host + `/tmp/document/${encodeURIComponent(String(documentId))}/attachment` + '?ts=' + new Date().getTime();
        let headers = this.headers;
        return XHR_1.XHR.sendCommand('DELETE', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => new Document_1.Document(doc.body))
            .catch((err) => this.handleError(err));
    }
    /**
     * Response is a set containing the ID's of deleted items.
     * @summary Soft delete items.
     * @param body
     */
    deleteTmpItems(body) {
        let _body = null;
        _body = body;
        const _url = this.host + `/tmp/batch/delete` + '?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 DocIdentifier_1.DocIdentifier(it)))
            .catch((err) => this.handleError(err));
    }
    /**
     * Nothing happens if the database does not exists
     * @summary Destroy tmp database for current user
     */
    destroyTmpDatabase() {
        let _body = null;
        const _url = this.host + `/tmp` + '?ts=' + new Date().getTime();
        let headers = this.headers;
        return XHR_1.XHR.sendCommand('DELETE', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => new Unit_1.Unit(doc.body))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns an instance of classification.
     * @summary Get a classification by id
     * @param id
     */
    getTmpClassification(id) {
        let _body = null;
        const _url = this.host + `/tmp/classification/byId/${encodeURIComponent(String(id))}` + '?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 Classification_1.Classification(doc.body))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns an instance of created classification.
     * @summary Get classifications by ids with the current user
     * @param body
     */
    getTmpClassifications(body) {
        let _body = null;
        _body = body;
        const _url = this.host + `/tmp/classification/get` + '?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 Classification_1.Classification(it)))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns an instance of contact.
     * @summary Get a contact by id
     * @param id
     */
    getTmpContact(id) {
        let _body = null;
        const _url = this.host + `/tmp/contact/byId/${encodeURIComponent(String(id))}` + '?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 Contact_1.Contact(doc.body))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns an instance of created contact.
     * @summary Get contacts by ids with the current user
     * @param body
     */
    getTmpContacts(body) {
        let _body = null;
        _body = body;
        const _url = this.host + `/tmp/contact/get` + '?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 Contact_1.Contact(it)))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns an instance of document.
     * @summary Get a document by id
     * @param id
     */
    getTmpDocument(id) {
        let _body = null;
        const _url = this.host + `/tmp/document/byId/${encodeURIComponent(String(id))}` + '?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 Document_1.Document(doc.body))
            .catch((err) => this.handleError(err));
    }
    /**
     *
     * @param documentId
     * @param attachmentId
     * @param enckeys
     * @param fileName
     */
    getTmpDocumentAttachment(documentId, attachmentId, enckeys, fileName) {
        let _body = null;
        const _url = this.host +
            `/tmp/document/${encodeURIComponent(String(documentId))}/attachment/${encodeURIComponent(String(attachmentId))}` +
            '?ts=' +
            new Date().getTime() +
            (enckeys ? '&enckeys=' + encodeURIComponent(String(enckeys)) : '') +
            (fileName ? '&fileName=' + encodeURIComponent(String(fileName)) : '');
        let headers = this.headers;
        return XHR_1.XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => true)
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns an instance of created document.
     * @summary Get documents by ids with the current user
     * @param body
     */
    getTmpDocuments(body) {
        let _body = null;
        _body = body;
        const _url = this.host + `/tmp/document/get` + '?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 Document_1.Document(it)))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns an instance of entityTemplate.
     * @summary Get a entityTemplate by id
     * @param id
     */
    getTmpEntityTemplate(id) {
        let _body = null;
        const _url = this.host + `/tmp/entityTemplate/byId/${encodeURIComponent(String(id))}` + '?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 EntityTemplate_1.EntityTemplate(doc.body))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns an instance of created entityTemplate.
     * @summary Get entityTemplates by ids with the current user
     * @param body
     */
    getTmpEntityTemplates(body) {
        let _body = null;
        _body = body;
        const _url = this.host + `/tmp/entityTemplate/get` + '?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 EntityTemplate_1.EntityTemplate(it)))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns an instance of form.
     * @summary Get a form by id
     * @param id
     */
    getTmpForm(id) {
        let _body = null;
        const _url = this.host + `/tmp/form/byId/${encodeURIComponent(String(id))}` + '?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 Form_1.Form(doc.body))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns an instance of created form.
     * @summary Get forms by ids with the current user
     * @param body
     */
    getTmpForms(body) {
        let _body = null;
        _body = body;
        const _url = this.host + `/tmp/form/get` + '?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 Form_1.Form(it)))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns an instance of healthElement.
     * @summary Get a healthElement by id
     * @param id
     */
    getTmpHealthElement(id) {
        let _body = null;
        const _url = this.host + `/tmp/healthElement/byId/${encodeURIComponent(String(id))}` + '?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 HealthElement_1.HealthElement(doc.body))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns an instance of created healthElement.
     * @summary Get healthElements by ids with the current user
     * @param body
     */
    getTmpHealthElements(body) {
        let _body = null;
        _body = body;
        const _url = this.host + `/tmp/healthElement/get` + '?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 HealthElement_1.HealthElement(it)))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns an instance of invoice.
     * @summary Get a invoice by id
     * @param id
     */
    getTmpInvoice(id) {
        let _body = null;
        const _url = this.host + `/tmp/invoice/byId/${encodeURIComponent(String(id))}` + '?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 Invoice_1.Invoice(doc.body))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns an instance of created invoice.
     * @summary Get invoices by ids with the current user
     * @param body
     */
    getTmpInvoices(body) {
        let _body = null;
        _body = body;
        const _url = this.host + `/tmp/invoice/get` + '?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 Invoice_1.Invoice(it)))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns an instance of message.
     * @summary Get a message by id
     * @param id
     */
    getTmpMessage(id) {
        let _body = null;
        const _url = this.host + `/tmp/message/byId/${encodeURIComponent(String(id))}` + '?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 Message_1.Message(doc.body))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns an instance of created message.
     * @summary Get messages by ids with the current user
     * @param body
     */
    getTmpMessages(body) {
        let _body = null;
        _body = body;
        const _url = this.host + `/tmp/message/get` + '?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 Message_1.Message(it)))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns an instance of patient.
     * @summary Get a patient by id
     * @param id
     */
    getTmpPatient(id) {
        let _body = null;
        const _url = this.host + `/tmp/patient/byId/${encodeURIComponent(String(id))}` + '?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 Patient_1.Patient(doc.body))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns an instance of created patient.
     * @summary Get patients by ids with the current user
     * @param body
     */
    getTmpPatients(body) {
        let _body = null;
        _body = body;
        const _url = this.host + `/tmp/patient/get` + '?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 Patient_1.Patient(it)))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns paginated classifications.
     * @summary List classifications with the current user
     * @param firstClassificationId
     * @param pageSize
     */
    listTmpClassifications(firstClassificationId, pageSize) {
        let _body = null;
        const _url = this.host +
            `/tmp/classification/list` +
            '?ts=' +
            new Date().getTime() +
            (firstClassificationId ? '&firstClassificationId=' + encodeURIComponent(String(firstClassificationId)) : '') +
            (pageSize ? '&pageSize=' + encodeURIComponent(String(pageSize)) : '');
        let headers = this.headers;
        return XHR_1.XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => new PaginatedListClassification_1.PaginatedListClassification(doc.body))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns paginated contacts.
     * @summary List contacts with the current user
     * @param firstContactId
     * @param pageSize
     */
    listTmpContacts(firstContactId, pageSize) {
        let _body = null;
        const _url = this.host +
            `/tmp/contact/list` +
            '?ts=' +
            new Date().getTime() +
            (firstContactId ? '&firstContactId=' + encodeURIComponent(String(firstContactId)) : '') +
            (pageSize ? '&pageSize=' + encodeURIComponent(String(pageSize)) : '');
        let headers = 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));
    }
    /**
     * Returns paginated documents.
     * @summary List documents with the current user
     * @param firstDocumentId
     * @param pageSize
     */
    listTmpDocuments(firstDocumentId, pageSize) {
        let _body = null;
        const _url = this.host +
            `/tmp/document/list` +
            '?ts=' +
            new Date().getTime() +
            (firstDocumentId ? '&firstDocumentId=' + encodeURIComponent(String(firstDocumentId)) : '') +
            (pageSize ? '&pageSize=' + encodeURIComponent(String(pageSize)) : '');
        let headers = this.headers;
        return XHR_1.XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => new PaginatedListDocument_1.PaginatedListDocument(doc.body))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns paginated entityTemplates.
     * @summary List entityTemplates with the current user
     * @param firstEntityTemplateId
     * @param pageSize
     */
    listTmpEntityTemplates(firstEntityTemplateId, pageSize) {
        let _body = null;
        const _url = this.host +
            `/tmp/entityTemplate/list` +
            '?ts=' +
            new Date().getTime() +
            (firstEntityTemplateId ? '&firstEntityTemplateId=' + encodeURIComponent(String(firstEntityTemplateId)) : '') +
            (pageSize ? '&pageSize=' + encodeURIComponent(String(pageSize)) : '');
        let headers = this.headers;
        return XHR_1.XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => new PaginatedListEntityTemplate_1.PaginatedListEntityTemplate(doc.body))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns paginated forms.
     * @summary List forms with the current user
     * @param firstFormId
     * @param pageSize
     */
    listTmpForms(firstFormId, pageSize) {
        let _body = null;
        const _url = this.host +
            `/tmp/form/list` +
            '?ts=' +
            new Date().getTime() +
            (firstFormId ? '&firstFormId=' + encodeURIComponent(String(firstFormId)) : '') +
            (pageSize ? '&pageSize=' + encodeURIComponent(String(pageSize)) : '');
        let headers = this.headers;
        return XHR_1.XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => new PaginatedListForm_1.PaginatedListForm(doc.body))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns paginated healthElements.
     * @summary List healthElements with the current user
     * @param firstHealthElementId
     * @param pageSize
     */
    listTmpHealthElements(firstHealthElementId, pageSize) {
        let _body = null;
        const _url = this.host +
            `/tmp/healthElement/list` +
            '?ts=' +
            new Date().getTime() +
            (firstHealthElementId ? '&firstHealthElementId=' + encodeURIComponent(String(firstHealthElementId)) : '') +
            (pageSize ? '&pageSize=' + encodeURIComponent(String(pageSize)) : '');
        let headers = this.headers;
        return XHR_1.XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => new PaginatedListHealthElement_1.PaginatedListHealthElement(doc.body))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns paginated invoices.
     * @summary List invoices with the current user
     * @param firstInvoiceId
     * @param pageSize
     */
    listTmpInvoices(firstInvoiceId, pageSize) {
        let _body = null;
        const _url = this.host +
            `/tmp/invoice/list` +
            '?ts=' +
            new Date().getTime() +
            (firstInvoiceId ? '&firstInvoiceId=' + encodeURIComponent(String(firstInvoiceId)) : '') +
            (pageSize ? '&pageSize=' + encodeURIComponent(String(pageSize)) : '');
        let headers = 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));
    }
    /**
     * Returns paginated messages.
     * @summary List messages with the current user
     * @param firstMessageId
     * @param pageSize
     */
    listTmpMessages(firstMessageId, pageSize) {
        let _body = null;
        const _url = this.host +
            `/tmp/message/list` +
            '?ts=' +
            new Date().getTime() +
            (firstMessageId ? '&firstMessageId=' + encodeURIComponent(String(firstMessageId)) : '') +
            (pageSize ? '&pageSize=' + encodeURIComponent(String(pageSize)) : '');
        let headers = 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));
    }
    /**
     * Returns paginated patients.
     * @summary List patients with the current user
     * @param firstPatientId
     * @param pageSize
     */
    listTmpPatients(firstPatientId, pageSize) {
        let _body = null;
        const _url = this.host +
            `/tmp/patient/list` +
            '?ts=' +
            new Date().getTime() +
            (firstPatientId ? '&firstPatientId=' + encodeURIComponent(String(firstPatientId)) : '') +
            (pageSize ? '&pageSize=' + encodeURIComponent(String(pageSize)) : '');
        let headers = this.headers;
        return XHR_1.XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => new PaginatedListPatient_1.PaginatedListPatient(doc.body))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns the modified classification.
     * @summary Modify a classification
     * @param body
     */
    modifyTmpClassification(body) {
        let _body = null;
        _body = body;
        const _url = this.host + `/tmp/classification` + '?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('PUT', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => new Classification_1.Classification(doc.body))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns the modified healthcare elements.
     * @summary Modify a batch of healthcare elements
     * @param body
     */
    modifyTmpClassifications(body) {
        let _body = null;
        _body = body;
        const _url = this.host + `/tmp/classification/batch` + '?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('PUT', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => doc.body.map((it) => new Classification_1.Classification(it)))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns the modified contact.
     * @summary Modify a contact
     * @param body
     */
    modifyTmpContact(body) {
        let _body = null;
        _body = body;
        const _url = this.host + `/tmp/contact` + '?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('PUT', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => new Contact_1.Contact(doc.body))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns the modified healthcare elements.
     * @summary Modify a batch of healthcare elements
     * @param body
     */
    modifyTmpContacts(body) {
        let _body = null;
        _body = body;
        const _url = this.host + `/tmp/contact/batch` + '?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('PUT', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => doc.body.map((it) => new Contact_1.Contact(it)))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns the modified document.
     * @summary Modify a document
     * @param body
     */
    modifyTmpDocument(body) {
        let _body = null;
        _body = body;
        const _url = this.host + `/tmp/document` + '?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('PUT', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => new Document_1.Document(doc.body))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns the modified healthcare elements.
     * @summary Modify a batch of healthcare elements
     * @param body
     */
    modifyTmpDocuments(body) {
        let _body = null;
        _body = body;
        const _url = this.host + `/tmp/document/batch` + '?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('PUT', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => doc.body.map((it) => new Document_1.Document(it)))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns the modified entityTemplate.
     * @summary Modify a entityTemplate
     * @param body
     */
    modifyTmpEntityTemplate(body) {
        let _body = null;
        _body = body;
        const _url = this.host + `/tmp/entityTemplate` + '?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('PUT', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => new EntityTemplate_1.EntityTemplate(doc.body))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns the modified healthcare elements.
     * @summary Modify a batch of healthcare elements
     * @param body
     */
    modifyTmpEntityTemplates(body) {
        let _body = null;
        _body = body;
        const _url = this.host + `/tmp/entityTemplate/batch` + '?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('PUT', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => doc.body.map((it) => new EntityTemplate_1.EntityTemplate(it)))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns the modified form.
     * @summary Modify a form
     * @param body
     */
    modifyTmpForm(body) {
        let _body = null;
        _body = body;
        const _url = this.host + `/tmp/form` + '?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('PUT', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => new Form_1.Form(doc.body))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns the modified healthcare elements.
     * @summary Modify a batch of healthcare elements
     * @param body
     */
    modifyTmpForms(body) {
        let _body = null;
        _body = body;
        const _url = this.host + `/tmp/form/batch` + '?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('PUT', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => doc.body.map((it) => new Form_1.Form(it)))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns the modified healthElement.
     * @summary Modify a healthElement
     * @param body
     */
    modifyTmpHealthElement(body) {
        let _body = null;
        _body = body;
        const _url = this.host + `/tmp/healthElement` + '?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('PUT', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => new HealthElement_1.HealthElement(doc.body))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns the modified healthcare elements.
     * @summary Modify a batch of healthcare elements
     * @param body
     */
    modifyTmpHealthElements(body) {
        let _body = null;
        _body = body;
        const _url = this.host + `/tmp/healthElement/batch` + '?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('PUT', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => doc.body.map((it) => new HealthElement_1.HealthElement(it)))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns the modified invoice.
     * @summary Modify a invoice
     * @param body
     */
    modifyTmpInvoice(body) {
        let _body = null;
        _body = body;
        const _url = this.host + `/tmp/invoice` + '?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('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 healthcare elements.
     * @summary Modify a batch of healthcare elements
     * @param body
     */
    modifyTmpInvoices(body) {
        let _body = null;
        _body = body;
        const _url = this.host + `/tmp/invoice/batch` + '?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('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));
    }
    /**
     * Returns the modified message.
     * @summary Modify a message
     * @param body
     */
    modifyTmpMessage(body) {
        let _body = null;
        _body = body;
        const _url = this.host + `/tmp/message` + '?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('PUT', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => new Message_1.Message(doc.body))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns the modified healthcare elements.
     * @summary Modify a batch of healthcare elements
     * @param body
     */
    modifyTmpMessages(body) {
        let _body = null;
        _body = body;
        const _url = this.host + `/tmp/message/batch` + '?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('PUT', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => doc.body.map((it) => new Message_1.Message(it)))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns the modified patient.
     * @summary Modify a patient
     * @param body
     */
    modifyTmpPatient(body) {
        let _body = null;
        _body = body;
        const _url = this.host + `/tmp/patient` + '?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('PUT', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => new Patient_1.Patient(doc.body))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns the modified healthcare elements.
     * @summary Modify a batch of healthcare elements
     * @param body
     */
    modifyTmpPatients(body) {
        let _body = null;
        _body = body;
        const _url = this.host + `/tmp/patient/batch` + '?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('PUT', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => doc.body.map((it) => new Patient_1.Patient(it)))
            .catch((err) => this.handleError(err));
    }
    /**
     * Response is a set containing the ID's of deleted items.
     * @summary Hard delete items.
     * @param body
     */
    purgeTmpItems(body) {
        let _body = null;
        _body = body;
        const _url = this.host + `/tmp/batch/purge` + '?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 DocIdentifier_1.DocIdentifier(it)))
            .catch((err) => this.handleError(err));
    }
    /**
     *
     * @param body
     * @param from
     */
    replicateToTmpDatabase(from, body) {
        let _body = null;
        _body = body;
        const _url = this.host + `/tmp/replicate/from/${encodeURIComponent(String(from))}` + '?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 ReplicatorDocument_1.ReplicatorDocument(doc.body))
            .catch((err) => this.handleError(err));
    }
    /**
     * Creates a document's attachment and returns the modified document instance afterward
     * @summary Create a document's attachment
     * @param body
     * @param documentId
     * @param enckeys
     */
    setTmpDocumentAttachment(documentId, enckeys, body) {
        let _body = null;
        _body = body;
        const _url = this.host +
            `/tmp/document/${encodeURIComponent(String(documentId))}/attachment` +
            '?ts=' +
            new Date().getTime() +
            (enckeys ? '&enckeys=' + encodeURIComponent(String(enckeys)) : '');
        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('PUT', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => new Document_1.Document(doc.body))
            .catch((err) => this.handleError(err));
    }
}
exports.IccTmpApi = IccTmpApi;
//# sourceMappingURL=IccTmpApi.js.map