/**
 * @fileoverview added by tsickle
 * Generated from: lib/fhir/practitioner/add/practitioner-add.component.ts
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
import * as tslib_1 from "tslib";
import { EMAIL_REGEX } from './../../../shared/regular-expressions/regex';
import { TelecomAddComponent, } from '../../../widgets/entry-components/modal/components/telecom-add/telecom-add.component';
import { ModalService } from '../../../widgets/entry-components/modal/services/modal.service';
import { Component } from '@angular/core';
import { ActionSheetController } from '@ionic/angular';
import { FormGroup, FormControl, Validators, FormArray } from '@angular/forms';
import { NameComponent } from '../../../widgets/entry-components/modal/components/name/name.component';
import { AddressComponent } from '../../../widgets/entry-components/modal/components/address/address.component';
import { TranslatePipe } from '../../../shared/translate/pipes/translate.pipe';
import { AbstractAddWmodalComponent } from '../../../shared/abstracts/add/abstract-add-wmodal/abstract-add-wmodal.component';
import { GENDER_LIST } from '../../../widgets/entry-components/modal/components/gender/gender.component';
/**
 * @return {?}
 */
export function getPractitionerForm() {
    return new FormGroup({
        id: new FormControl(),
        extension: new FormArray([
            new FormGroup({
                url: new FormControl(),
                valueString: new FormControl('')
            })
        ]),
        identifier: new FormArray([new FormGroup({
                value: new FormControl('', [Validators.required, Validators.pattern(EMAIL_REGEX)])
                /*  Validators.compose([Validators.required, Validators.minLength(5), Validators.maxLength(5)]) */
            })]),
        active: new FormControl(true),
        name: new FormArray([], Validators.required),
        gender: new FormControl('OTHER'),
        telecom: new FormArray([]),
        address: new FormArray([])
    });
}
var PractitionerAddComponent = /** @class */ (function (_super) {
    tslib_1.__extends(PractitionerAddComponent, _super);
    function PractitionerAddComponent(modalService, actionSheetController, translatePipe) {
        var _this = _super.call(this, modalService, actionSheetController, translatePipe) || this;
        _this.genderList = GENDER_LIST;
        _this.modalComponents = {
            name: (/**
             * @return {?}
             */
            function () { return NameComponent; }),
            address: (/**
             * @return {?}
             */
            function () { return AddressComponent; }),
            telecom: (/**
             * @return {?}
             */
            function () { return TelecomAddComponent; })
        };
        return _this;
    }
    /**
     * @return {?}
     */
    PractitionerAddComponent.prototype.resetForm = /**
     * @return {?}
     */
    function () {
        return getPractitionerForm();
    };
    /**
     * @param {?} practitionerData
     * @return {?}
     */
    PractitionerAddComponent.prototype.save = /**
     * @param {?} practitionerData
     * @return {?}
     */
    function (practitionerData) {
        this.inData ? this.callUpdate.emit(practitionerData) : this.callSave.emit((/** @type {?} */ ({ data: practitionerData })));
    };
    /**
     * @return {?}
     */
    PractitionerAddComponent.prototype.addDetails = /**
     * @return {?}
     */
    function () {
        return tslib_1.__awaiter(this, void 0, void 0, function () {
            var actionSheet;
            var _this = this;
            return tslib_1.__generator(this, function (_a) {
                switch (_a.label) {
                    case 0: return [4 /*yield*/, this.actionSheetController.create({
                            header: this.translatePipe.transform('ADDOTHERDATAS'),
                            buttons: [
                                {
                                    text: this.translatePipe.transform('ADDRESS'),
                                    icon: 'business',
                                    handler: (/**
                                     * @return {?}
                                     */
                                    function () {
                                        _this.openModal('address');
                                    })
                                }, {
                                    text: this.translatePipe.transform('AVAILABILITY'),
                                    icon: 'call',
                                    handler: (/**
                                     * @return {?}
                                     */
                                    function () {
                                        _this.openModal('telecom');
                                    })
                                },
                                {
                                    text: this.translatePipe.transform('BACK'),
                                    icon: 'close',
                                    role: 'cancel'
                                }
                            ]
                        })];
                    case 1:
                        actionSheet = _a.sent();
                        return [4 /*yield*/, actionSheet.present()];
                    case 2:
                        _a.sent();
                        return [2 /*return*/];
                }
            });
        });
    };
    PractitionerAddComponent.decorators = [
        { type: Component, args: [{
                    selector: 'inc-practitioner-add',
                    template: "<form [formGroup]=\"form\" (ngSubmit)=\"save(form.value)\">\r\n  <ion-grid class=\"ion-padding\">\r\n    <ion-row class=\"ion-align-items-end\">\r\n      <ion-col size=\"12\" sizeMd=\"6\">\r\n        <ion-radio-group class=\"radio-hor\" formControlName=\"gender\">\r\n          <ion-item *ngFor=\"let gender of genderList\" lines=\"none\" id=\"practitioner-gender\">\r\n            <ion-label>\r\n              {{gender.label | translate}}</ion-label>\r\n            <ion-radio slot=\"start\" value=\"{{gender.value}}\" color=\"secondary\">\r\n            </ion-radio>\r\n          </ion-item>\r\n        </ion-radio-group>\r\n      </ion-col>\r\n      <ion-col size=\"12\" sizeMd=\"6\" formArrayName=\"identifier\">\r\n        <ion-item formGroupName=\"0\">\r\n          <ion-label position=\"floating\">\r\n            {{'EMAIL' | translate}}\r\n            <span class=\"required\">*</span>\r\n          </ion-label>\r\n          <ion-input type=\"text\" autofocus=\"true\" formControlName=\"value\" clearInput\r\n            id=\"practitioner-social-security-number\">\r\n          </ion-input>\r\n        </ion-item>\r\n      </ion-col>\r\n    </ion-row>\r\n\r\n    <ion-col>\r\n      <ion-button expand=\"block\" fill=\"outline\" color=\"secondary\" (click)=\"openModal('name')\"\r\n        id=\"practitioner-name-button\">\r\n        <ion-icon name=\"add\"></ion-icon>&nbsp;{{'NAME_L' | translate}}&nbsp;\r\n        <span class=\"required\">*</span>\r\n      </ion-button>\r\n    </ion-col>\r\n\r\n    <ion-row *ngIf=\"form.value.name.length > 0\">\r\n      <ion-col>\r\n        <b class=\"ion-text-uppercase\"> {{'NAME_L' | translate}} </b>\r\n        <ion-chip color=\"dark\" outline=\"true\" *ngFor=\"let name of form.value.name; let i = index\"\r\n          id=\"practitioner-full-name\">\r\n          <ion-label color=\"primary\" *ngIf=\"i === 0\"><b>{{name.text}}</b></ion-label>\r\n          <ion-label *ngIf=\"i !== 0\">{{name.text}}</ion-label>\r\n          <ion-icon name=\"close\" (click)=\"deleteFromFormArray('name', i)\"></ion-icon>\r\n        </ion-chip>\r\n      </ion-col>\r\n    </ion-row>\r\n\r\n    <ion-col>\r\n      <ion-button expand=\"block\" fill=\"outline\" (click)=\"addDetails()\" id=\"plus-data-button\">\r\n        <ion-icon slot=\"start\" name=\"add\"></ion-icon>{{'DATA' | translate}}\r\n      </ion-button>\r\n    </ion-col>\r\n\r\n    <ion-row *ngIf=\"form.value.address.length > 0\">\r\n      <ion-col>\r\n        <b class=\"ion-text-uppercase\">{{'ADDRESS' | translate}}</b>\r\n        <ion-chip *ngFor=\"let addressElement of form.value.address; let i = index\" outline=\"true\" color=\"dark\"\r\n          id=\"practitioner-full-address\">\r\n          <ion-label>{{addressElement | address}}</ion-label>\r\n          <ion-icon name=\"close\" (click)=\"deleteFromFormArray('address', i)\"></ion-icon>\r\n        </ion-chip>\r\n      </ion-col>\r\n    </ion-row>\r\n\r\n    <ion-row *ngIf=\"form.value.telecom.length > 0\">\r\n      <ion-col>\r\n        <b class=\"ion-text-uppercase\">{{'AVAILABILITY' | translate}} </b>\r\n        <ion-chip *ngFor=\"let tel of form.value.telecom; let i = index\" outline=\"true\" color=\"dark\"\r\n          id=\"practitioner-telecom\">\r\n          <ion-label color=\"primary\" *ngIf=\"i === 0\"><b>{{tel.value}}</b></ion-label>\r\n          <ion-label *ngIf=\"i !== 0\">{{tel.value}}</ion-label>\r\n          <ion-icon name=\"close\" (click)=\"deleteFromFormArray('telecom', i)\"></ion-icon>\r\n        </ion-chip>\r\n      </ion-col>\r\n    </ion-row>\r\n\r\n    <ion-row class=\"ion-float-right ion-margin-bottom ion-margin-top\">\r\n      <ion-button fill=\"outline\" color=\"primary\" id=\"basic-data-reject-button\" *ngIf=\"inData\" (click)=\"discard()\"\r\n        class=\"ion-margin-end\">\r\n        <ion-icon slot=\"start\" name=\"close\"></ion-icon>{{'REJECT_BUTTON' | translate}}\r\n      </ion-button>\r\n      <ion-button fill=\"outline\" *ngIf=\"!inData\" color=\"primary\" id=\"basic-data-reset-button\" (click)=\"reset()\"\r\n        class=\"ion-margin-end\">\r\n        <ion-icon slot=\"start\" name=\"refresh\"></ion-icon>{{'AGAIN_BUTTON' | translate}}\r\n      </ion-button>\r\n      <ion-button id=\"basic-data-save-button\" type=\"submit\" [disabled]=\"form.invalid || (inData && form.pristine)\">\r\n        <ion-icon slot=\"start\" name=\"save\"></ion-icon>{{'SAVE_BUTTON' | translate}}\r\n      </ion-button>\r\n    </ion-row>\r\n\r\n  </ion-grid>\r\n</form>",
                    styles: ["@media (min-width:768px){.radio-hor{display:flex;flex-direction:row}.radio-hor ion-item{width:100%}}"]
                }] }
    ];
    /** @nocollapse */
    PractitionerAddComponent.ctorParameters = function () { return [
        { type: ModalService },
        { type: ActionSheetController },
        { type: TranslatePipe }
    ]; };
    return PractitionerAddComponent;
}(AbstractAddWmodalComponent));
export { PractitionerAddComponent };
if (false) {
    /** @type {?} */
    PractitionerAddComponent.prototype.genderList;
    /** @type {?} */
    PractitionerAddComponent.prototype.modalComponents;
}
//# sourceMappingURL=data:application/json;base64, 