public override void AfterConstruction()
        {
            base.AfterConstruction();

            EditableProtocol = new EditableProtocol(Session);
            CommonProtocol   = new CommonProtocol(Session);

            DateIn = DateTime.Now;

            // определяем текущего пользователя
            var createdBy = SecuritySystem.CurrentUser as Doctor;

            if (createdBy != null)
            {
                // находим доктора с таким же Логином
                var doctor = Session.FindObject <Doctor>(CriteriaOperator.Parse("UserName=?", createdBy.UserName));
                if (doctor != null)
                {
                    this.Doctor = doctor;
                }
            }
        }
        public void AcceptServiceTemplate()
        {
            if (ServiceTemplate != null)
            {
                string teethText         = null;
                string milkbyteTeethText = null;

                if (Teeth != Enums.Teeth.None)
                {
                    List <string> list = new List <string>();
                    foreach (Teeth tooth in Enum.GetValues(typeof(Teeth)))
                    {
                        if (tooth == Enums.Teeth.None)
                        {
                            continue;
                        }
                        if (Teeth.HasFlag(tooth))
                        {
                            list.Add(CaptionHelper.GetDisplayText(tooth));
                        }
                    }

                    teethText = string.Join(", ", list);
                }
                if (MilkByteTeeth != Enums.MilkByteTeeth.None)
                {
                    List <string> list = new List <string>();
                    foreach (MilkByteTeeth tooth in Enum.GetValues(typeof(MilkByteTeeth)))
                    {
                        if (tooth == Enums.MilkByteTeeth.None)
                        {
                            continue;
                        }
                        if (MilkByteTeeth.HasFlag(tooth))
                        {
                            list.Add(CaptionHelper.GetDisplayText(tooth));
                        }
                    }

                    milkbyteTeethText = string.Join(", ", list);
                }

                string replacement = !string.IsNullOrEmpty(teethText) && !string.IsNullOrEmpty(milkbyteTeethText) ?
                                     string.Concat(teethText, ", ", milkbyteTeethText) :
                                     string.Concat(teethText, milkbyteTeethText);

                CommonProtocol.Anamnez         = (serviceTemplate.Anamnez ?? string.Empty).Replace("{replacement}", replacement);
                CommonProtocol.Complain        = (serviceTemplate.Complain ?? string.Empty).Replace("{replacement}", replacement);
                CommonProtocol.ObjectiveStatus = (serviceTemplate.ObjectiveStatus ?? string.Empty).Replace("{replacement}", replacement);
                CommonProtocol.Recommendation  = (serviceTemplate.Recommendations ?? string.Empty).Replace("{replacement}", replacement);
                Usluga = serviceTemplate.Service;
                Diagnoses.Add(new MKBWithType(Session)
                {
                    Diagnose = serviceTemplate.Diagnose
                });

                OnChanged("CommonProtocol");
                OnChanged("Usluga");
                OnChanged("Diagnoses");

                CommonProtocol.Save();
            }
        }