/**
 * @fileoverview added by tsickle
 * Generated from: lib/user/profile/components/practitioner-info/practitioner-info.component.ts
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
import { AlertService } from './../../../../widgets/entry-components/alert/services/alert.service';
import { ProfessionalDataComponent } from './../../../../widgets/entry-components/modal/components/professional-data/professional-data.component';
import { TelecomAddComponent } from './../../../../widgets/entry-components/modal/components/telecom-add/telecom-add.component';
import { GenderComponent } from './../../../../widgets/entry-components/modal/components/gender/gender.component';
import { NameComponent } from './../../../../widgets/entry-components/modal/components/name/name.component';
import { ModalService } from './../../../../widgets/entry-components/modal/services/modal.service';
import { Component, Input, EventEmitter, Output } from '@angular/core';
export class PractitionerInfoComponent {
    /**
     * @param {?} modalService
     * @param {?} alertService
     */
    constructor(modalService, alertService) {
        this.modalService = modalService;
        this.alertService = alertService;
        this.modals = {
            name: (/**
             * @return {?}
             */
            () => NameComponent),
            gender: (/**
             * @return {?}
             */
            () => GenderComponent),
            telecom: (/**
             * @return {?}
             */
            () => TelecomAddComponent),
            qualification: (/**
             * @return {?}
             */
            () => ProfessionalDataComponent)
        };
        this.callUpdatePractitioner = new EventEmitter();
    }
    /**
     * @return {?}
     */
    ngOnInit() {
    }
    /**
     * @param {?} componentName
     * @param {?=} param
     * @return {?}
     */
    presentModal(componentName, param) {
        this.modalService.presentModal(this.modals[componentName](), { parameter: param }).then((/**
         * @param {?} modal
         * @return {?}
         */
        modal => {
            modal.onDidDismiss().then((/**
             * @param {?} detail
             * @return {?}
             */
            detail => {
                if (detail.data) {
                    /** @type {?} */
                    let practitioner = Object.assign({}, this.practitioner);
                    practitioner = this.modalRespHandler(practitioner, componentName, detail);
                    this.callUpdatePractitioner.emit({ practitioner, componentName });
                }
            }));
        }));
    }
    /**
     * @param {?} prac
     * @param {?} componentName
     * @param {?} detail
     * @return {?}
     */
    modalRespHandler(prac, componentName, detail) {
        if (componentName === 'gender') {
            prac[componentName] = detail.data.value[componentName].value;
        }
        else {
            if (!prac[componentName] || componentName !== 'telecom') {
                prac[componentName] = [];
            }
            prac[componentName].push(detail.data.value[componentName].value);
            if (componentName === 'telecom') {
                prac[componentName][prac[componentName].length - 1].rank = prac[componentName].length;
            }
        }
        return prac;
    }
    /**
     * @param {?} text
     * @param {?} subject
     * @param {?} rank
     * @return {?}
     */
    presentRemAler(text, subject, rank) {
        this.alertService.presentDelete(text, subject, (/**
         * @return {?}
         */
        () => { this.removeTelecom(rank); }));
    }
    /**
     * @param {?} rank
     * @return {?}
     */
    removeTelecom(rank) {
        this.practitioner.telecom.splice(rank - 1, 1);
        this.practitioner.telecom.map((/**
         * @param {?} data
         * @param {?} index
         * @return {?}
         */
        (data, index) => data.rank = index + 1));
        this.callUpdatePractitioner.emit({ practitioner: this.practitioner, componentName: null });
    }
}
PractitionerInfoComponent.decorators = [
    { type: Component, args: [{
                selector: 'inc-practitioner-info',
                template: "<span *ngIf=\"practitioner\">\r\n  <ion-text color=\"primary\" class=\"ion-text-uppercase ion-padding\" style=\"padding-bottom: 0;\">\r\n    <b>{{'GENERAL' | translate}}</b>\r\n  </ion-text>\r\n  <ion-list lines=\"none\" class=\"ion-padding-start\">\r\n    <ion-item button id=\"nameTag\" (click)=\"presentModal('name', practitioner.name ? practitioner.name[0] : undefined)\">\r\n      <ion-label>{{'NAME_L' | translate}}</ion-label>\r\n      <ion-label *ngIf=\"practitioner.name && practitioner.name[0]\"><b>{{practitioner.name[0].text}}</b></ion-label>\r\n    </ion-item>\r\n    <ion-item button id=\"genderTag\"\r\n      (click)=\"presentModal('gender', { gender: practitioner.gender ? practitioner.gender: undefined })\">\r\n      <ion-label>{{'GENDER' | translate}}</ion-label>\r\n      <ion-label><b>{{practitioner.gender | translate}}</b></ion-label>\r\n    </ion-item>\r\n  </ion-list>\r\n  <ion-item-divider></ion-item-divider>\r\n  <ion-text class=\"title-btn\" color=\"primary\" class=\"ion-text-uppercase ion-padding\" style=\"padding-bottom: 0;\">\r\n    <b>{{'CONTACT_INFO' | translate}}</b>\r\n    <ion-button id=\"contact\" fill=\"clear\" (click)=\"presentModal('telecom')\">\r\n      <ion-icon slot=\"icon-only\" name=\"add-circle-outline\"></ion-icon>\r\n    </ion-button>\r\n  </ion-text>\r\n  <ion-list lines=\"none\" class=\"ion-padding-start\">\r\n    <ion-item button id=\"telecom-details\" *ngFor=\"let tel of practitioner.telecom\"\r\n      (click)=\"presentRemAler(tel.value, tel.system, tel.rank)\">\r\n      <ion-badge slot=\"start\">{{tel.rank}}</ion-badge>\r\n      <ion-label>{{tel.system | translate}}</ion-label>\r\n      <ion-label><b>{{tel.value}}</b></ion-label>\r\n      <ion-icon slot=\"end\" name=\"trash\"></ion-icon>\r\n    </ion-item>\r\n  </ion-list>\r\n  <ion-item-divider class=\"ion-margin-bottom\"></ion-item-divider>\r\n  <ion-text color=\"primary\" class=\"ion-text-uppercase ion-padding\" style=\"padding-bottom: 0;\">\r\n    <b>{{'PROFESSIONAL_DATA' | translate}}</b>\r\n  </ion-text>\r\n  <ion-list lines=\"none\" class=\"ion-padding-start\">\r\n    <ion-item>\r\n      <ion-label>{{'ROLE' | translate}}</ion-label>\r\n      <ion-label><b>{{role | translate}}</b></ion-label>\r\n    </ion-item>\r\n    <ion-item button id=\"szakmai-adatok\" class=\"ion-no-padding\"\r\n      (click)=\"presentModal('qualification', practitioner.qualification ? practitioner.qualification[0] : undefined)\">\r\n      <ion-item-group>\r\n        <ion-item>\r\n          <ion-ripple-effect></ion-ripple-effect>\r\n          <ion-label>{{'SEAL_NUMBER' | translate}}</ion-label>\r\n          <ion-label class=\"ion-padding-start\" *ngIf=\"\r\n          practitioner.qualification && practitioner.qualification[0]\r\n          && practitioner.qualification[0].identifier\r\n          && practitioner.qualification[0].identifier[0]\r\n          && practitioner.qualification[0].identifier[0].value\">\r\n            <b>{{practitioner.qualification[0].identifier[0].value}}</b></ion-label>\r\n        </ion-item>\r\n        <ion-item>\r\n          <ion-ripple-effect></ion-ripple-effect>\r\n          <ion-label>{{'LOCATION_ANTSZ_ID' | translate}}</ion-label>\r\n          <ion-label class=\"ion-padding-start\" *ngIf=\"\r\n          practitioner.qualification\r\n          && practitioner.qualification[0]\r\n          && practitioner.qualification[0].issuer\r\n          && practitioner.qualification[0].issuer.reference\">\r\n            <b>{{practitioner.qualification[0].issuer.reference}}</b></ion-label>\r\n        </ion-item>\r\n      </ion-item-group>\r\n    </ion-item>\r\n  </ion-list>\r\n</span>",
                styles: ["ion-item-group{width:100%}.title-btn{display:flex;align-items:center}"]
            }] }
];
/** @nocollapse */
PractitionerInfoComponent.ctorParameters = () => [
    { type: ModalService },
    { type: AlertService }
];
PractitionerInfoComponent.propDecorators = {
    practitioner: [{ type: Input }],
    role: [{ type: Input }],
    callUpdatePractitioner: [{ type: Output }]
};
if (false) {
    /** @type {?} */
    PractitionerInfoComponent.prototype.modals;
    /** @type {?} */
    PractitionerInfoComponent.prototype.practitioner;
    /** @type {?} */
    PractitionerInfoComponent.prototype.role;
    /** @type {?} */
    PractitionerInfoComponent.prototype.callUpdatePractitioner;
    /**
     * @type {?}
     * @private
     */
    PractitionerInfoComponent.prototype.modalService;
    /**
     * @type {?}
     * @private
     */
    PractitionerInfoComponent.prototype.alertService;
}
//# sourceMappingURL=data:application/json;base64, 