/**
 * @fileoverview added by tsickle
 * Generated from: lib/fhir/medication/dosage/add/dosage-add.component.ts
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
import { Component, Input } from '@angular/core';
import { AbstractAddComponent } from '../../../../shared/abstracts/add/abstract-add/abstract-add.component';
import { FormGroup, FormControl, FormArray } from '@angular/forms';
export class DosageAddComponent extends AbstractAddComponent {
    constructor() {
        super();
        this.allDaysAreSelected = false;
    }
    /**
     * @return {?}
     */
    ngOnInit() {
        if (this.inData) {
            this.form.patchValue(this.inData);
            if (this.inData.timing && this.inData.timing.repeat && this.inData.timing.repeat.dayOfWeek) {
                this.form.get('timing.repeat.dayOfWeek').setValue(this.inData.timing.repeat.dayOfWeek);
            }
        }
    }
    /**
     * @param {?} inData
     * @return {?}
     */
    save(inData) {
        this.inData ? this.callUpdate.emit(inData) : this.callSave.emit(inData);
        this.form.reset(this.form.value);
    }
    /**
     * @return {?}
     */
    resetForm() {
        return new FormGroup({
            timing: new FormGroup({
                repeat: new FormGroup({
                    dayOfWeek: new FormControl(),
                    periodUnit: new FormControl('daily')
                })
            }),
            doseAndRate: new FormArray([
                new FormGroup({
                    doseQuantity: new FormGroup({
                        value: new FormControl(''),
                        currency: new FormControl('mg')
                    }),
                    rateQuantity: new FormGroup({
                        value: new FormControl(''),
                        currency: new FormControl('pill')
                    })
                })
            ])
        });
    }
}
DosageAddComponent.decorators = [
    { type: Component, args: [{
                selector: 'inc-dosage-add',
                template: "<form [formGroup]=\"form\" (ngSubmit)=\"save(form.value)\">\r\n  <mat-accordion>\r\n    <mat-expansion-panel style=\"box-shadow: none\">\r\n      <mat-expansion-panel-header>\r\n        <mat-panel-title>\r\n          <ion-text color=\"primary\" *ngIf=\"name\">\r\n            <h5><b>{{name}}</b></h5>\r\n          </ion-text>\r\n        </mat-panel-title>\r\n      </mat-expansion-panel-header>\r\n\r\n      <ion-grid class=\"ion-no-padding\" formArrayName=\"doseAndRate\">\r\n        <span formGroupName=\"0\">\r\n          <ion-row>\r\n            <ion-col size=\"6\" size-md=\"3\" formGroupName=\"doseQuantity\">\r\n              <ion-item class=\"ion-margin-end\">\r\n                <ion-label position=\"floating\">{{'DOSE' | translate}}</ion-label>\r\n                <ion-input type=\"number\" formControlName=\"value\" min=\"1\"></ion-input>\r\n              </ion-item>\r\n            </ion-col>\r\n            <ion-col size=\"6\" size-md=\"3\" formGroupName=\"doseQuantity\">\r\n              <mat-form-field class=\"ion-margin-top\" style=\"width: 100%;\">\r\n                <mat-label>{{'DOSE_UNIT' | translate}}</mat-label>\r\n                <mat-select formControlName=\"currency\">\r\n                  <mat-option value=\"mg\">mg</mat-option>\r\n                  <mat-option value=\"g\">g</mat-option>\r\n                  <mat-option value=\"ml\">ml</mat-option>\r\n                </mat-select>\r\n              </mat-form-field>\r\n            </ion-col>\r\n            <ion-col size=\"6\" size-md=\"3\" formGroupName=\"rateQuantity\">\r\n              <ion-item class=\"ion-margin-end\">\r\n                <ion-label position=\"floating\">{{'DOSAGE' | translate}} (eg: 2x3)</ion-label>\r\n                <ion-input type=\"text\" formControlName=\"value\"></ion-input>\r\n              </ion-item>\r\n            </ion-col>\r\n            <ion-col size=\"6\" size-md=\"3\" formGroupName=\"rateQuantity\">\r\n              <mat-form-field class=\"ion-margin-top\" style=\"width: 100%;\">\r\n                <mat-label>{{'DOSE_UNIT' | translate}}</mat-label>\r\n                <mat-select formControlName=\"currency\">\r\n                  <mat-option *ngFor=\"let unit of units\" [value]=\"unit\">{{unit | uppercase | translate}}</mat-option>\r\n                </mat-select>\r\n              </mat-form-field>\r\n            </ion-col>\r\n          </ion-row>\r\n        </span>\r\n      </ion-grid>\r\n      <ion-grid formGroupName=\"timing\">\r\n        <ion-row formGroupName=\"repeat\">\r\n          <ion-col size=\"6\">\r\n            <mat-form-field class=\"ion-margin-end\" style=\"width: 100%;\">\r\n              <mat-label>{{'DAYS' | translate}}</mat-label>\r\n              <mat-select formControlName=\"dayOfWeek\" multiple>\r\n                <!-- <mat-option class=\"filter-option\" [value]=\"days\">\r\n                <span>{{'ALL_L' | translate}}</span>\r\n              </mat-option> -->\r\n                <mat-option *ngFor=\"let day of days\" [value]=\"day.value\">{{day.text | translate}}</mat-option>\r\n              </mat-select>\r\n            </mat-form-field>\r\n          </ion-col>\r\n          <ion-col size=\"6\">\r\n            <mat-form-field style=\"width: 100%;\">\r\n              <mat-label>{{'PERIODS' | translate}}</mat-label>\r\n              <mat-select formControlName=\"periodUnit\">\r\n                <mat-option *ngFor=\"let period of periods\" [value]=\"period\">{{period | uppercase | translate}}\r\n                </mat-option>\r\n              </mat-select>\r\n            </mat-form-field>\r\n          </ion-col>\r\n        </ion-row>\r\n      </ion-grid>\r\n      <ion-grid>\r\n        <ion-row class=\"ion-float-right ion-margin-bottom\">\r\n          <ion-button id=\"submitBtn\" type=\"submit\" [hidden]=\"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      </ion-grid>\r\n    </mat-expansion-panel>\r\n  </mat-accordion>\r\n</form>",
                styles: [""]
            }] }
];
/** @nocollapse */
DosageAddComponent.ctorParameters = () => [];
DosageAddComponent.propDecorators = {
    units: [{ type: Input }],
    periods: [{ type: Input }],
    days: [{ type: Input }],
    name: [{ type: Input }]
};
if (false) {
    /** @type {?} */
    DosageAddComponent.prototype.allDaysAreSelected;
    /** @type {?} */
    DosageAddComponent.prototype.units;
    /** @type {?} */
    DosageAddComponent.prototype.periods;
    /** @type {?} */
    DosageAddComponent.prototype.days;
    /** @type {?} */
    DosageAddComponent.prototype.name;
}
//# sourceMappingURL=data:application/json;base64, 