Ejemplo n.º 1
0
        private void ctrlBSave_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(ctrlName.Text))
            {
                MonitoringStub.Message("Заполните поле \"Название\"!");
                return;
            }
            if (m_ControlTemplate != null)
            {
                using (var transaction = Cl_App.m_DataContext.Database.BeginTransaction())
                {
                    try
                    {
                        var record = m_ControlTemplate.f_GetNewRecord(false);
                        if (record != null)
                        {
                            if (m_SourceRecord == null && m_Log.f_IsChanged(record) == false)
                            {
                                MonitoringStub.Message("Паттерн не изменялся!");
                                transaction.Rollback();
                                return;
                            }
                            var recordPattern = Cl_RecordsFacade.f_GetInstance().f_GetNewRecordPattern(ctrlName.Text, record);
                            if (recordPattern != null)
                            {
                                Cl_App.m_DataContext.p_RecordsPatterns.Add(recordPattern);
                                Cl_App.m_DataContext.SaveChanges();

                                if (m_SourceRecord == null)
                                {
                                    Cl_EntityLog.f_CustomMessageLog(E_EntityTypes.RecordsPatterns, string.Format("Создан новый патерн \"{0}\" по шаблону \"{1}\"", recordPattern.p_Name, recordPattern.p_Template.p_Name), recordPattern.p_Template.p_TemplateID);
                                }
                                else
                                {
                                    Cl_EntityLog.f_CustomMessageLog(E_EntityTypes.RecordsPatterns, string.Format("Сформирован патерн по записи \"{0}\"", m_SourceRecord.p_Title), m_SourceRecord.p_RecordID);
                                }

                                transaction.Commit();
                                f_SetRecordPattern(recordPattern);
                                e_Save?.Invoke(this, new EventArgs());
                            }
                            else
                            {
                                transaction.Rollback();
                                return;
                            }
                        }
                        else
                        {
                            return;
                        }
                    }
                    catch (Exception ex)
                    {
                        transaction.Rollback();
                        MonitoringStub.Error("Error_Editor", "При сохранении изменений паттерна записей произошла ошибка", ex, null, null);
                    }
                }
            }
        }
 /// <summary>Объединение медкарт в одну действующую</summary>
 /// <param name="a_PatientID">ID пациента</param>
 public bool f_MergeMedicalCards(int a_PatientID)
 {
     if (m_DataContextMegaTemplate != null)
     {
         var medicalCards = m_DataContextMegaTemplate.p_MedicalCards.Where(m => m.p_DateArchive == null && m.p_PatientID == a_PatientID).ToList();
         if (medicalCards != null && medicalCards.Count > 0)
         {
             if (medicalCards.Count > 1)
             {
                 Cl_MedicalCard actualMedicalCard = null;
                 foreach (var medicalCard in medicalCards)
                 {
                     if (actualMedicalCard == null || actualMedicalCard.p_DateCreate < medicalCard.p_DateCreate)
                     {
                         actualMedicalCard = medicalCard;
                     }
                 }
                 medicalCards.Remove(actualMedicalCard);
                 try
                 {
                     foreach (var medicalCard in medicalCards)
                     {
                         var records = Cl_RecordsFacade.f_GetInstance().f_GetRecords(medicalCard);
                         if (records != null)
                         {
                             foreach (var record in records)
                             {
                                 record.p_MedicalCardID = actualMedicalCard.p_ID;
                                 record.p_MedicalCard   = actualMedicalCard;
                             }
                         }
                         medicalCard.p_DateDelete = DateTime.Now;
                     }
                     actualMedicalCard.p_DateMerge = DateTime.Now;
                     m_DataContextMegaTemplate.SaveChanges();
                     return(true);
                 }
                 catch (Exception er)
                 {
                     MonitoringStub.Error("Error_MergeMedicalCards", "Не удалось объединить медкарты в одну действующую", er, null, null);
                     return(false);
                 }
             }
             else
             {
                 return(true);
             }
         }
         else
         {
             MonitoringStub.Error("Error_MergeMedicalCards", "Не удалось найти действующую медкарту", null, null, null);
             return(false);
         }
     }
     else
     {
         MonitoringStub.Error("Error_MedicalCardsFacade", "Не инициализирован фасад", null, null, null);
         return(false);
     }
 }
Ejemplo n.º 3
0
        private void CtrlEl_e_ValueChanged(object sender, EventArgs e)
        {
            var curEl = (Ctrl_Element)sender;

            if (!m_IsBlockChanging)
            {
                m_IsBlockChanging = true;
                var record = f_GetNewRecord(false);
                if (record != null)
                {
                    foreach (var el in m_Elements)
                    {
                        if (el.p_Element != null && el != curEl)
                        {
                            el.Visible = Cl_RecordsFacade.f_GetInstance().f_GetElementVisible(record, el.p_Element.p_VisibilityFormula);
                            if (el.p_Element.p_IsNumber && !string.IsNullOrWhiteSpace(el.p_Element.p_NumberFormula))
                            {
                                var val = Cl_RecordsFacade.f_GetInstance().f_GetElementMathematicValue(record, el.p_Element.p_NumberFormula);
                                if (val != null)
                                {
                                    var dVal = (decimal)val;
                                    dVal = Math.Round(dVal, el.p_Element.p_NumberRound);
                                    el.f_SetValue(record, dVal);
                                }
                            }
                        }
                    }
                }
                m_IsBlockChanging = false;
            }
        }
Ejemplo n.º 4
0
 public void f_FormatByPattern(Cl_RecordPattern a_Pattern)
 {
     if (a_Pattern != null)
     {
         Cl_RecordsFacade.f_GetInstance().f_EditRecordFromPattern(m_Record, a_Pattern);
         f_UpdateControls();
         m_Log.f_SetEntity(m_Record);
     }
 }
 /// <summary>Присоединение медкарт</summary>
 /// <param name="a_SourceNumber">Номер источника медкарта</param>
 /// <param name="a_SourcePatientID">ID источника пациента</param>
 /// <param name="a_TargetNumber">Номер адресата медкарта</param>
 /// <param name="a_TargetPatientID">ID адресата пациента</param>
 public bool f_MergeMedicalCards(string a_SourceNumber, int a_SourcePatientID, string a_TargetNumber, int a_TargetPatientID)
 {
     if (m_DataContextMegaTemplate != null)
     {
         var sourceMedicalCard = f_GetMedicalCard(a_SourceNumber, a_SourcePatientID);
         if (sourceMedicalCard != null)
         {
             var targetMedicalCard = f_GetMedicalCard(a_TargetNumber, a_TargetPatientID);
             if (targetMedicalCard != null)
             {
                 try
                 {
                     var records = Cl_RecordsFacade.f_GetInstance().f_GetRecords(sourceMedicalCard);
                     if (records != null)
                     {
                         foreach (var record in records)
                         {
                             record.p_MedicalCardID = targetMedicalCard.p_ID;
                             record.p_MedicalCard   = targetMedicalCard;
                         }
                     }
                     sourceMedicalCard.p_DateDelete = DateTime.Now;
                     targetMedicalCard.p_DateMerge  = DateTime.Now;
                     m_DataContextMegaTemplate.SaveChanges();
                     return(true);
                 }
                 catch (Exception er)
                 {
                     MonitoringStub.Error("Error_MergeMedicalCards", "Не удалось присоединить медкарты", er, null, null);
                     return(false);
                 }
             }
             else
             {
                 MonitoringStub.Error("Error_MergeMedicalCards", "Не удалось найти медкарту адресат", null, null, null);
                 return(false);
             }
         }
         else
         {
             MonitoringStub.Error("Error_MergeMedicalCards", "Не удалось найти медкарту источник", null, null, null);
             return(false);
         }
     }
     else
     {
         MonitoringStub.Error("Error_MedicalCardsFacade", "Не инициализирован фасад", null, null, null);
         return(false);
     }
 }
        public static bool Initialize()
        {
            if (!_IsInit)
            {
                string localResourcesPath = "";
                try
                {
                    Configuration config = ConfigurationManager.OpenExeConfiguration(Assembly.GetExecutingAssembly().Location);
                    var           con    = config.ConnectionStrings.ConnectionStrings["MedicalChartDatabase"];
                    localResourcesPath = config.AppSettings.Settings["LocalResourcesPath"].Value;
                    if (con == null)
                    {
                        MonitoringStub.Error("Error_AppInit", "Отсутствует настройка подключения к БД MedicalChartDatabase в конфигурационном фале", null, null, null);
                        return(false);
                    }
                    m_DataContext = new Cl_DataContextMegaTemplate(con.ConnectionString);

                    m_DataContext.Database.Connection.Open();

                    m_DataContext.f_Init();
                }
                catch (Exception er)
                {
                    MonitoringStub.Error("Error_AppInit", "Не удалось подключиться к базе данных", er, null, null);
                    return(false);
                }
                if (!Cl_TemplatesFacade.f_GetInstance().f_Init(m_DataContext))
                {
                    MonitoringStub.Error("Error_AppInit", "Не удалось инициализировать фасад работы с шаблонами", null, null, null);
                    return(false);
                }
                if (!Cl_RecordsFacade.f_GetInstance().f_Init(m_DataContext, localResourcesPath))
                {
                    MonitoringStub.Error("Error_AppInit", "Не удалось инициализировать фасад работы с записями", null, null, null);
                    return(false);
                }
                if (!Cl_MedicalCardsFacade.f_GetInstance().f_Init(m_DataContext))
                {
                    MonitoringStub.Error("Error_AppInit", "Не удалось инициализировать фасад работы с медкартами", null, null, null);
                    return(false);
                }
                if (!Cl_CatalogsFacade.f_GetInstance().f_Init(m_DataContext))
                {
                    MonitoringStub.Error("Error_AppInit", "Не удалось инициализировать фасад работы со справочниками", null, null, null);
                    return(false);
                }
                _IsInit = true;
            }
            return(_IsInit);
        }
 private void f_AddRecordFromRecord(Cl_Record a_Record)
 {
     if (a_Record != null)
     {
         Cl_TemplatesFacade.f_GetInstance().f_LoadTemplatesElements(a_Record.p_Template);
         Cl_Record record = Cl_RecordsFacade.f_GetInstance().f_GetNewRecord(a_Record);
         record.p_ParentRecord = a_Record;
         if (record != null)
         {
             var dlgRecord = new Dlg_Record();
             dlgRecord.e_Save  += DlgRecord_e_Save;
             dlgRecord.p_Record = record;
             dlgRecord.ShowDialog(this);
         }
     }
 }
Ejemplo n.º 8
0
 internal void FormatPaternFromRecord(Cl_Record a_Record)
 {
     if (a_Record == null)
     {
         return;
     }
     try
     {
         m_SourceRecord = a_Record;
         Cl_TemplatesFacade.f_GetInstance().f_LoadTemplatesElements(a_Record.p_Template);
         Cl_RecordPattern pattern = Cl_RecordsFacade.f_GetInstance().f_GetNewRecordPattern(a_Record);
         pattern.p_ClinicName = Cl_SessionFacade.f_GetInstance().p_Doctor.p_ClinicName;
         pattern.f_SetDoctor(Cl_SessionFacade.f_GetInstance().p_Doctor);
         this.p_RecordPattern = pattern;
     }
     catch (Exception er)
     {
         MonitoringStub.Error("Error_Editor", "Не удалось сформировать паттерн записей по записи", er, null, null);
     }
 }
Ejemplo n.º 9
0
 public void f_SetRecordPattern(Cl_RecordPattern a_RecordPattern)
 {
     m_RecordPattern = a_RecordPattern;
     if (m_RecordPattern != null && m_RecordPattern.p_Template != null)
     {
         try
         {
             Cl_TemplatesFacade.f_GetInstance().f_LoadTemplatesElements(m_RecordPattern.p_Template);
             ctrlDoctorFIO.Text = m_RecordPattern.p_DoctorFIO;
             ctrlName.Text      = m_RecordPattern.p_Name;
             Text     = string.Format("Паттерн записей по шаблону \"{0}\" v{1}", m_RecordPattern.p_Template.p_Name, ConfigurationManager.AppSettings["Version"]);
             m_Record = Cl_RecordsFacade.f_GetInstance().f_GetNewRecord(m_RecordPattern);
             f_UpdateControls();
             m_Log.f_SetEntity(m_Record);
         }
         catch (Exception er)
         {
             MonitoringStub.Error("Error_Editor", "Не удалось установить паттерн записей по шаблону", er, null, null);
         }
     }
 }
Ejemplo n.º 10
0
 /// <summary>Получение конечного текста записи</summary>
 private string f_GetDocumentText(string a_AppStartupPath, bool a_IsDoctor)
 {
     if (p_Type == E_RecordType.FinishedFile)
     {
         p_FileBytes = Cl_RecordsFacade.f_GetInstance().f_GetFileFromSql(this);
         if (p_FileBytes != null)
         {
             if (p_FileType == E_RecordFileType.HTML)
             {
                 return(Encoding.UTF8.GetString(p_FileBytes).Replace("src=\"", "src=\"file:///" + a_AppStartupPath + "/"));
             }
             else if (p_FileType == E_RecordFileType.PDF)
             {
                 return(Encoding.UTF8.GetString(p_FileBytes));
             }
             else if (p_FileType == E_RecordFileType.JFIF || p_FileType == E_RecordFileType.JIF || p_FileType == E_RecordFileType.JPE ||
                      p_FileType == E_RecordFileType.JPEG || p_FileType == E_RecordFileType.JPG || p_FileType == E_RecordFileType.PNG || p_FileType == E_RecordFileType.GIF)
             {
                 return(string.Format(@"<img src=""data:image/{0};base64,{1}"" />", Enum.GetName(typeof(E_RecordFileType), p_FileType).ToLower(), Convert.ToBase64String(p_FileBytes)));
             }
         }
         else
         {
             MonitoringStub.Warning("Файл отсутствует");
         }
     }
     else if (a_IsDoctor && p_HTMLDoctor != null)
     {
         var res = p_HTMLDoctor.Replace("class=\"record_title_img\" src=\"", "class=\"record_title_img\" src=\"file:///" + a_AppStartupPath + "/");
         res = p_HTMLDoctor.Replace("class=record_title_img src=", "class=record_title_img src=file:///" + a_AppStartupPath + "/");
         return(res);
     }
     else if (!a_IsDoctor && p_HTMLPatient != null)
     {
         var res = p_HTMLPatient.Replace("class=\"record_title_img\" src=\"", "class=\"record_title_img\" src=\"file:///" + a_AppStartupPath + "/");
         res = p_HTMLPatient.Replace("class=record_title_img src=", "class=record_title_img src=file:///" + a_AppStartupPath + "/");
         return(res);
     }
     return(null);
 }
Ejemplo n.º 11
0
        private void ctrlBAdd_Click(object sender, System.EventArgs e)
        {
            OpenFileDialog openFile = new OpenFileDialog();

            openFile.Filter = "Файлы изображений (.bmp, .jpg, .png)|*.bmp;*.jpg;*.png|PDF файл (.pdf)|*.pdf|Веб страницы (.htm, .html)|*.htm;*.html";
            if (openFile.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            var recordFileType = Cl_RecordsFacade.f_GetInstance().f_GetFileType(openFile.FileName);

            if (recordFileType != null)
            {
                m_FileType = (E_RecordFileType)recordFileType;
            }
            else
            {
                MonitoringStub.Message("Неизвестный формат файла записи " + openFile.FileName);
                return;
            }
            m_FileBytes        = File.ReadAllBytes(openFile.FileName);
            ctrlLFilePath.Text = openFile.FileName;
        }
        public void f_TestElementVisibleFromFormula()
        {
            //tag_one = "pat2"; tag_dva = 11; tag_tri = 5
            var record = new Cl_Record()
            {
                p_Title = "Тест проверки формул"
            };
            var medicalCard = new Cl_MedicalCard();

            medicalCard.p_PatientSex       = Core.Permision.Cl_User.E_Sex.Man;
            medicalCard.p_PatientDateBirth = new DateTime(1981, 4, 1);
            record.p_MedicalCard           = medicalCard;
            record.p_Values = new List <Cl_RecordValue>();

            var template = new Cl_Template()
            {
                p_Name = "Тест проверки формул", p_Type = Cl_Template.E_TemplateType.Template
            };
            var elements = new List <Cl_TemplateElement>();
            var element  = new Cl_Element()
            {
                p_ID   = 1,
                p_Name = "Формула 1",
                p_Tag  = "one"
            };

            element.p_ParamsValues = new List <Cl_ElementParam>();
            for (int i = 1; i < 4; i++)
            {
                element.p_ParamsValues.Add(new Cl_ElementParam()
                {
                    p_Element = element, p_TypeParam = Cl_ElementParam.E_TypeParam.NormValues, p_Value = "norm" + i.ToString()
                });
                var ep = new Cl_ElementParam()
                {
                    p_Element = element, p_TypeParam = Cl_ElementParam.E_TypeParam.PatValues, p_Value = "pat" + i.ToString()
                };
                if (i == 2)
                {
                    record.p_Values.Add(new Cl_RecordValue()
                    {
                        p_ElementID = element.p_ID,
                        p_Element   = element,
                        p_Params    = new List <Cl_RecordParam>()
                        {
                            new Cl_RecordParam()
                            {
                                p_ElementParam = ep
                            }
                        }
                    });
                }
                element.p_ParamsValues.Add(ep);
            }
            elements.Add(new Cl_TemplateElement()
            {
                p_Template = template, p_ChildElement = element, p_Index = 0
            });

            element = new Cl_Element()
            {
                p_ID          = 2,
                p_Name        = "Формула 2",
                p_Tag         = "dva",
                p_IsNumber    = true,
                p_NumberRound = 2
            };
            element.p_ParamsValues = new List <Cl_ElementParam>();
            for (int i = 1; i < 4; i++)
            {
                element.p_ParamsValues.Add(new Cl_ElementParam()
                {
                    p_Element = element, p_TypeParam = Cl_ElementParam.E_TypeParam.NormValues, p_Value = i.ToString()
                });
                element.p_ParamsValues.Add(new Cl_ElementParam()
                {
                    p_Element = element, p_TypeParam = Cl_ElementParam.E_TypeParam.PatValues, p_Value = i.ToString()
                });
            }
            record.p_Values.Add(new Cl_RecordValue()
            {
                p_ElementID = element.p_ID, p_Element = element, p_ValueUser = "******"
            });
            elements.Add(new Cl_TemplateElement()
            {
                p_Template = template, p_ChildElement = element, p_Index = 1
            });

            element = new Cl_Element()
            {
                p_ID          = 3,
                p_Name        = "Формула 3",
                p_Tag         = "tri",
                p_IsNumber    = true,
                p_NumberRound = 2
            };
            element.p_ParamsValues = new List <Cl_ElementParam>();
            for (int i = 1; i < 4; i++)
            {
                element.p_ParamsValues.Add(new Cl_ElementParam()
                {
                    p_Element = element, p_TypeParam = Cl_ElementParam.E_TypeParam.NormValues, p_Value = i.ToString()
                });
                element.p_ParamsValues.Add(new Cl_ElementParam()
                {
                    p_Element = element, p_TypeParam = Cl_ElementParam.E_TypeParam.PatValues, p_Value = i.ToString()
                });
            }
            record.p_Values.Add(new Cl_RecordValue()
            {
                p_ElementID = element.p_ID, p_Element = element, p_ValueUser = "******"
            });
            elements.Add(new Cl_TemplateElement()
            {
                p_Template = template, p_ChildElement = element, p_Index = 2
            });

            template.p_TemplateElements = elements;
            record.f_SetTemplate(template);

            bool actual = Cl_RecordsFacade.f_GetInstance().f_GetElementVisible(record, "tag_one = \"pat2\"");

            Assert.AreEqual(true, actual);
            actual = Cl_RecordsFacade.f_GetInstance().f_GetElementVisible(record, "tag_one = tag_one");
            Assert.AreEqual(true, actual);

            actual = Cl_RecordsFacade.f_GetInstance().f_GetElementVisible(record, "tag_dva > 10");
            Assert.AreEqual(true, actual);
            actual = Cl_RecordsFacade.f_GetInstance().f_GetElementVisible(record, "tag_dva < 15");
            Assert.AreEqual(true, actual);
            actual = Cl_RecordsFacade.f_GetInstance().f_GetElementVisible(record, "tag_dva = 11");
            Assert.AreEqual(true, actual);
            actual = Cl_RecordsFacade.f_GetInstance().f_GetElementVisible(record, "tag_dva > 14");
            Assert.AreEqual(false, actual);
            actual = Cl_RecordsFacade.f_GetInstance().f_GetElementVisible(record, "tag_dva < 11");
            Assert.AreEqual(false, actual);

            actual = Cl_RecordsFacade.f_GetInstance().f_GetElementVisible(record, "tag_one = \"pat2\" И tag_dva > 10 ИЛИ tag_tri = 3");
            Assert.AreEqual(true, actual);
            actual = Cl_RecordsFacade.f_GetInstance().f_GetElementVisible(record, "tag_one = \"pat2\" И tag_dva < 12 ИЛИ tag_tri = 3");
            Assert.AreEqual(true, actual);
            actual = Cl_RecordsFacade.f_GetInstance().f_GetElementVisible(record, "tag_one = \"pat2\" И tag_dva = 11 ИЛИ tag_tri = 3");
            Assert.AreEqual(true, actual);
            actual = Cl_RecordsFacade.f_GetInstance().f_GetElementVisible(record, "tag_one = \"pat2\" И tag_dva = 13 ИЛИ tag_tri = 5");
            Assert.AreEqual(true, actual);
            actual = Cl_RecordsFacade.f_GetInstance().f_GetElementVisible(record, "tag_one = \"pat2\" И tag_dva = 13 ИЛИ tag_tri > 4");
            Assert.AreEqual(true, actual);
            actual = Cl_RecordsFacade.f_GetInstance().f_GetElementVisible(record, "tag_one = \"pat2\" И tag_dva = 13 ИЛИ tag_tri < 6");
            Assert.AreEqual(true, actual);
            actual = Cl_RecordsFacade.f_GetInstance().f_GetElementVisible(record, "tag_one = \"pat2\" И tag_dva = 13 ИЛИ tag_tri < tag_dva");
            Assert.AreEqual(true, actual);

            actual = Cl_RecordsFacade.f_GetInstance().f_GetElementVisible(record, "tag_one = \"pat2\" И tag_dva = 13 ИЛИ tag_tri > tag_dva");
            Assert.AreEqual(false, actual);
            actual = Cl_RecordsFacade.f_GetInstance().f_GetElementVisible(record, "tag_one = \"pat2\" И tag_dva = 13 ИЛИ tag_tri = 6");
            Assert.AreEqual(false, actual);
            actual = Cl_RecordsFacade.f_GetInstance().f_GetElementVisible(record, "tag_one = \"pat2\" И tag_dva = 13");
            Assert.AreEqual(false, actual);
            actual = Cl_RecordsFacade.f_GetInstance().f_GetElementVisible(record, "tag_one = \"pat2\" И tag_dva > 11");
            Assert.AreEqual(false, actual);
            actual = Cl_RecordsFacade.f_GetInstance().f_GetElementVisible(record, "tag_one = \"pat2\" И tag_dva < 11");
            Assert.AreEqual(false, actual);
            actual = Cl_RecordsFacade.f_GetInstance().f_GetElementVisible(record, "tag_one = \"pat3\" И tag_dva = 11");
            Assert.AreEqual(false, actual);
            actual = Cl_RecordsFacade.f_GetInstance().f_GetElementVisible(record, "tag_one = \"\" И tag_dva = 11");
            Assert.AreEqual(false, actual);

            actual = Cl_RecordsFacade.f_GetInstance().f_GetElementVisible(record, "tag_gender = man И tag_age > 10");
            Assert.AreEqual(true, actual);
            actual = Cl_RecordsFacade.f_GetInstance().f_GetElementVisible(record, "tag_gender = man И tag_age > 40");
            Assert.AreEqual(false, actual);
            actual = Cl_RecordsFacade.f_GetInstance().f_GetElementVisible(record, "tag_gender = female И tag_age > 10");
            Assert.AreEqual(false, actual);
            actual = Cl_RecordsFacade.f_GetInstance().f_GetElementVisible(record, "tag_gender = female");
            Assert.AreEqual(false, actual);
        }
Ejemplo n.º 13
0
        static void Main(string[] args)
        {
            string local        = null;
            string path         = null;
            string dbConnection = null;
            var    medicalCards = new Dictionary <string, Cl_MedicalCard>();

            if (args != null && args.Length >= 4)
            {
                for (var i = 0; i < args.Length; i++)
                {
                    var arg = args[i];
                    if (arg == "-local" && i + 1 < args.Length)
                    {
                        local = args[i + 1];
                    }
                    else if (arg == "-path" && i + 1 < args.Length)
                    {
                        path = args[i + 1];
                    }
                    else if (arg == "-db" && i + 1 < args.Length)
                    {
                        dbConnection = args[i + 1].Replace("Data_Source", "Data Source").Replace("Data_Source", "Data Source").Replace("Initial_Catalog", "Initial Catalog").Replace("Integrated_Security", "Integrated Security");
                    }
                    else if (arg == "-log" && i + 1 < args.Length)
                    {
                        m_Loging = args[i + 1] == "1";
                    }
                }
            }
            if (local != null && path != null && dbConnection != null)
            {
                if (Directory.Exists(path))
                {
                    var db = new Cl_DataContextMegaTemplate(dbConnection);
                    db.f_Init();
                    if (!Cl_CatalogsFacade.f_GetInstance().f_Init(db))
                    {
                        f_WriteLog("Не удалось инициализировать фасад работы со справочниками");
                        Console.ReadKey(true);
                        return;
                    }
                    if (!Cl_MedicalCardsFacade.f_GetInstance().f_Init(db))
                    {
                        f_WriteLog("Не удалось инициализировать фасад работы с мед картами");
                        Console.ReadKey(true);
                        return;
                    }
                    if (!Cl_RecordsFacade.f_GetInstance().f_Init(db, local))
                    {
                        f_WriteLog("Не удалось инициализировать фасад работы с записями");
                        Console.ReadKey(true);
                        return;
                    }
                    var           records  = new List <Cl_Record>();
                    DirectoryInfo _dirInfo = new DirectoryInfo(Cl_RecordsFacade.f_GetInstance().f_GetLocalResourcesPath());
                    f_WriteLog(string.Format("Начало формирования записей папки \"{0}\"", path));
                    int      iVal  = 0;
                    Guid     gVal  = Guid.Empty;
                    DateTime dtVal = DateTime.MinValue;
                    var      dirs  = Directory.GetDirectories(path);
                    foreach (var dir in dirs)
                    {
                        var folderName = dir.Substring(dir.LastIndexOf("\\") + 1).Replace(path, "");
                        f_WriteLog(string.Format("Начало формирования записей пациента \"{0}\"", folderName));
                        var vals = folderName.Split(' ');
                        if (vals.Length >= 6 && vals.Length <= 7)
                        {
                            if (vals[5].Length > 0 && vals[5][0] == '#')
                            {
                                if (int.TryParse(vals[0], out iVal))
                                {
                                    var medicalNumber   = iVal;
                                    var patientSurName  = vals[1];
                                    var patientName     = vals[2];
                                    var patientLastName = vals[3];
                                    if (DateTime.TryParse(vals[4], out dtVal))
                                    {
                                        var  patientDateBirth = dtVal;
                                        bool validID          = false; //ID пациента
                                        int  patientID        = 0;
                                        Guid patientUID       = Guid.Empty;
                                        if (vals.Length == 6)
                                        {
                                            validID = int.TryParse(vals[5].Substring(1), out patientID);
                                        }
                                        else if (vals.Length == 7)
                                        {
                                            validID = Guid.TryParse(vals[6], out patientUID);
                                        }
                                        if (validID)
                                        {
                                            var dirsCliniks = Directory.GetDirectories(dir);
                                            foreach (var dirClinik in dirsCliniks)
                                            {
                                                var clinik         = dirClinik.Substring(dirClinik.LastIndexOf("\\") + 1);
                                                var dirsCategories = Directory.GetDirectories(dirClinik);
                                                foreach (var dirCategory in dirsCategories)
                                                {
                                                    var cat      = dirCategory.Substring(dirCategory.LastIndexOf("\\") + 1);
                                                    var category = Cl_CatalogsFacade.f_GetInstance().f_GetCategory(cat);
                                                    if (category == null)
                                                    {
                                                        category = Cl_CatalogsFacade.f_GetInstance().f_AddCategory(Cl_Category.E_CategoriesTypes.Total, cat);
                                                    }
                                                    if (category != null)
                                                    {
                                                        var curRecords = new Dictionary <string, Cl_Record>();
                                                        //var curImages = new Dictionary<string, List<Cl_ImageFileData>>();
                                                        var filesRecords = Directory.GetFiles(dirCategory);
                                                        foreach (var fileRecord in filesRecords)
                                                        {
                                                            var valsRecord         = fileRecord.Replace(dirCategory + "\\", "");
                                                            var pathRelativeFile   = fileRecord.Replace(path, "");
                                                            var pathRelativeFolder = pathRelativeFile.Replace(valsRecord, "");
                                                            if (DateTime.TryParse(valsRecord.Substring(0, 8), out dtVal))
                                                            {
                                                                var record = new Cl_Record();
                                                                record.p_Version     = 1;
                                                                record.p_Type        = E_RecordType.FinishedFile;
                                                                record.p_IsAutomatic = true;
                                                                record.p_DateCreate  = record.p_DateLastChange = record.p_DateReception = dtVal;

                                                                string         patID          = patientUID != Guid.Empty ? patientUID.ToString() : patientID.ToString();
                                                                string         medicalCardKey = $"{medicalNumber}_{patID}";
                                                                Cl_MedicalCard medicalCard    = null;
                                                                if (!medicalCards.TryGetValue(medicalCardKey, out medicalCard))
                                                                {
                                                                    if (patientUID != Guid.Empty)
                                                                    {
                                                                        medicalCard = Cl_MedicalCardsFacade.f_GetInstance().f_GetMedicalCard(medicalNumber.ToString(), patientUID);
                                                                    }
                                                                    else
                                                                    {
                                                                        medicalCard = Cl_MedicalCardsFacade.f_GetInstance().f_GetMedicalCard(medicalNumber.ToString(), patientID);
                                                                    }
                                                                    if (medicalCard == null)
                                                                    {
                                                                        medicalCard              = new Cl_MedicalCard();
                                                                        medicalCard.p_Number     = medicalNumber.ToString();
                                                                        medicalCard.p_DateCreate = record.p_DateCreate;
                                                                        medicalCard.p_PatientID  = patientID;
                                                                        if (patientUID != Guid.Empty)
                                                                        {
                                                                            medicalCard.p_PatientUID = patientUID;
                                                                        }
                                                                        medicalCard.p_PatientSurName   = patientSurName;
                                                                        medicalCard.p_PatientName      = patientName;
                                                                        medicalCard.p_PatientLastName  = patientLastName;
                                                                        medicalCard.p_PatientDateBirth = patientDateBirth;
                                                                        medicalCards.Add(medicalCardKey, medicalCard);
                                                                    }
                                                                }
                                                                record.p_MedicalCard = medicalCard;

                                                                record.p_ClinicName      = clinik;
                                                                record.p_CategoryTotalID = category.p_ID;
                                                                record.p_CategoryTotal   = category;
                                                                bool isAuthorValid = false;
                                                                var  authorStart   = valsRecord.IndexOf('[');
                                                                if (authorStart == -1 && valsRecord.LastIndexOf('.') > 9)
                                                                {
                                                                    record.p_Title          = valsRecord.Substring(9, valsRecord.LastIndexOf('.') - 9);
                                                                    record.p_DateLastChange = record.p_DateCreate;
                                                                    isAuthorValid           = true;
                                                                }
                                                                else if (authorStart > 10)
                                                                {
                                                                    record.p_Title = valsRecord.Substring(9, valsRecord.IndexOf('[') - 10);
                                                                    var authorEnd = valsRecord.IndexOf(']');
                                                                    if (authorEnd > 11 && authorEnd > authorStart + 22)
                                                                    {
                                                                        if (DateTime.TryParse(valsRecord.Substring(authorStart + 1, 19).Replace("-", ":"), out dtVal))
                                                                        {
                                                                            record.p_DateLastChange = dtVal;
                                                                            var authorName     = valsRecord.Substring(authorStart + 22, authorEnd - authorStart - 22);
                                                                            var valsAuthorName = authorName.Split(' ');
                                                                            if (valsAuthorName.Length == 4)
                                                                            {
                                                                                record.p_DoctorSurName  = valsAuthorName[1];
                                                                                record.p_DoctorName     = valsAuthorName[2];
                                                                                record.p_DoctorLastName = valsAuthorName[3];
                                                                                isAuthorValid           = true;
                                                                            }
                                                                            else
                                                                            {
                                                                                f_WriteLog(string.Format("Не корректные данные имени автора записи {0}", fileRecord), E_MessageType.Warning);
                                                                                continue;
                                                                            }
                                                                        }
                                                                        else if (valsRecord.IndexOf("_[") > 0 && valsRecord.IndexOf("]-") > 0 && valsRecord.LastIndexOf(".") > valsRecord.IndexOf("]-") + 2)
                                                                        {
                                                                            if (int.TryParse(valsRecord.Substring(valsRecord.IndexOf("]-") + 2, valsRecord.LastIndexOf(".") - valsRecord.IndexOf("]-") - 2), out iVal))
                                                                            {
                                                                                //var fileStream = File.OpenRead(fileRecord);
                                                                                //MemoryStream ms = new MemoryStream();
                                                                                //fileStream.CopyTo(ms);
                                                                                //Regex rgx = new Regex("]-\\d*?.");
                                                                                //var keyRecord = rgx.Replace(valsRecord.Replace("_", " "), "]");
                                                                                //keyRecord = keyRecord.Substring(0, keyRecord.LastIndexOf("."));

                                                                                //var recordFileType = f_GetFileType(valsRecord);
                                                                                //if (recordFileType != null)
                                                                                //{
                                                                                //    if (curImages.ContainsKey(keyRecord))
                                                                                //    {
                                                                                //        curImages[keyRecord].Add(new Cl_ImageFileData() { m_FileName = valsRecord, m_FileType = (E_RecordFileType)recordFileType, m_FileData = ms.ToArray() });
                                                                                //    }
                                                                                //    else
                                                                                //    {
                                                                                //        curImages.Add(keyRecord, new List<Cl_ImageFileData>() { new Cl_ImageFileData() { m_FileName = valsRecord, m_FileType = (E_RecordFileType)recordFileType, m_FileData = ms.ToArray() } });
                                                                                //    }
                                                                                //}
                                                                                //ms.Dispose();



                                                                                continue;
                                                                            }
                                                                            else
                                                                            {
                                                                                f_WriteLog(string.Format("Не корректное время изменения записи автором {0}", fileRecord), E_MessageType.Warning);
                                                                                continue;
                                                                            }
                                                                        }
                                                                        else
                                                                        {
                                                                            f_WriteLog(string.Format("Не корректное время изменения записи автором {0}", fileRecord), E_MessageType.Warning);
                                                                            continue;
                                                                        }
                                                                    }
                                                                    else
                                                                    {
                                                                        f_WriteLog(string.Format("Не корректные данные автора записи {0}", fileRecord), E_MessageType.Warning);
                                                                        continue;
                                                                    }
                                                                }
                                                                else
                                                                {
                                                                    f_WriteLog(string.Format("Не корректные данные автора записи {0}", fileRecord), E_MessageType.Warning);
                                                                    continue;
                                                                }
                                                                if (isAuthorValid)
                                                                {
                                                                    var attrs   = File.GetAttributes(fileRecord);
                                                                    var isPrint = attrs.HasFlag(FileAttributes.ReadOnly);
                                                                    if (isPrint)
                                                                    {
                                                                        record.p_DatePrintDoctor = record.p_DatePrintPatient = DateTime.Now;
                                                                    }

                                                                    //var fileStream = File.OpenRead(fileRecord);

                                                                    var fileName  = "";
                                                                    var extension = Path.GetExtension(fileRecord);
                                                                    fileName = fileRecord.Replace(extension, "");
                                                                    if (extension == ".x")
                                                                    {
                                                                        record.p_IsDelete = true;
                                                                        extension         = Path.GetExtension(fileRecord.Substring(0, fileRecord.Length - 2));
                                                                        fileName          = fileRecord.Replace(extension, "");
                                                                    }
                                                                    else if (extension == ".tag")
                                                                    {
                                                                        extension = Path.GetExtension(fileRecord.Substring(0, fileRecord.Length - 4));
                                                                        fileName  = fileRecord.Replace(extension, "");
                                                                    }
                                                                    var recordFileType = f_GetFileType(valsRecord);
                                                                    if (recordFileType != null)
                                                                    {
                                                                        record.p_FileType = (E_RecordFileType)recordFileType;
                                                                    }
                                                                    else
                                                                    {
                                                                        f_WriteLog(string.Format("Неизвестный формат файла записи {0}", fileRecord), E_MessageType.Error);
                                                                        continue;
                                                                    }
                                                                    record.p_FilePath = pathRelativeFile;
                                                                    //MemoryStream ms = new MemoryStream();
                                                                    //fileStream.CopyTo(ms);
                                                                    //record.p_FilePath = $"{local}\\{clinik}\\{patID}\\{valsRecord}";

                                                                    //record.p_FilePath = Cl_RecordsFacade.f_GetInstance().f_GetLocalResourcesRelativeFilePath(record);
                                                                    //var filePath = Cl_RecordsFacade.f_GetInstance().f_GetLocalResourcesPath() + "/" + record.p_FilePath;

                                                                    //if (record.p_FileType == E_RecordFileType.HTML)
                                                                    //{
                                                                    //    ms.Position = 0;
                                                                    //    var sr = new StreamReader(ms);
                                                                    //    var htmlText = sr.ReadToEnd();
                                                                    //    sr.Dispose();
                                                                    //    htmlText = htmlText.Replace(@"img src=\\family-doctor.local\fd$\FD.med\Images\Logo.jpg", @"img class=""record_title_img"" src=""Images/title.jpg""");
                                                                    //    File.WriteAllBytes(filePath, Encoding.UTF8.GetBytes(htmlText));
                                                                    //}
                                                                    //else
                                                                    //{
                                                                    //    File.WriteAllBytes(filePath, ms.ToArray());
                                                                    //}
                                                                    //ms.Dispose();
                                                                    f_WriteLog(string.Format("Сформирована новая запись {0}", fileRecord), E_MessageType.Info);
                                                                    curRecords.Add(valsRecord, record);
                                                                }
                                                                else
                                                                {
                                                                    f_WriteLog(string.Format("Не корректные данные автора записи {0}", fileRecord), E_MessageType.Warning);
                                                                    continue;
                                                                }
                                                            }
                                                            else
                                                            {
                                                                f_WriteLog(string.Format("Не корректная дата записи {0}", fileRecord), E_MessageType.Warning);
                                                                continue;
                                                            }
                                                        }
                                                        //foreach (var record in curRecords)
                                                        //{
                                                        //    var fileName = record.Key.Substring(0, record.Key.IndexOf("].") + 1);
                                                        //    var patID = record.Value.p_MedicalCard.p_PatientUID != Guid.Empty ? record.Value.p_MedicalCard.p_PatientUID.ToString() : record.Value.p_MedicalCard.p_PatientID.ToString();
                                                        //    var folderPath = $"{local}\\{clinik}\\{patID}\\";
                                                        //    if (curImages.ContainsKey(fileName))
                                                        //    {
                                                        //        var images = curImages[fileName];
                                                        //        var html = Encoding.UTF8.GetString(record.Value.p_FileBytes);
                                                        //        foreach (var img in images)
                                                        //        {
                                                        //            html = html.Replace(img.m_FileName, string.Format(@"data:image/{0};base64,{1}", Enum.GetName(typeof(E_RecordFileType), img.m_FileType).ToLower(), Convert.ToBase64String(img.m_FileData)));
                                                        //        }
                                                        //        record.Value.p_FileBytes = Encoding.UTF8.GetBytes(html);
                                                        //    }
                                                        //}
                                                        records.AddRange(curRecords.Values);
                                                    }
                                                    else
                                                    {
                                                        f_WriteLog("Категория записей не найдена", E_MessageType.Error);
                                                    }
                                                }
                                            }
                                        }
                                        else
                                        {
                                            f_WriteLog("Не корректный ID пациента", E_MessageType.Warning);
                                        }
                                    }
                                    else
                                    {
                                        f_WriteLog("Не корректная дата рождения пациента", E_MessageType.Warning);
                                    }
                                }
                                else
                                {
                                    f_WriteLog("Не корректный номер медкарты", E_MessageType.Warning);
                                }
                            }
                            else
                            {
                                f_WriteLog("Не корректное название архива записей", E_MessageType.Warning);
                            }
                        }
                        else
                        {
                            f_WriteLog("Не корректное название архива записей", E_MessageType.Warning);
                        }
                    }
                    f_WriteLog("Начало сохранения сформированных записей", E_MessageType.Info);
                    if (Cl_RecordsFacade.f_GetInstance().f_AddRecords(records))
                    {
                        f_WriteLog("Конец сохранения сформированных записей", E_MessageType.Info);

                        f_WriteLog("Начало копирования папки с файлами", E_MessageType.Info);

                        foreach (string _path in Directory.GetFiles(path, "*.*", SearchOption.AllDirectories))
                        {
                            try
                            {
                                var fileName     = Path.GetFileName(_path);
                                var relativePath = _path.Replace(path, "").Replace("\\" + fileName, "");
                                Cl_RecordsFacade.f_GetInstance().f_SaveFileFromSql(relativePath, fileName, File.ReadAllBytes(_path));
                            }
                            catch (Exception e)
                            {
                                f_WriteLog("Не удалось скопировать файл " + _path, E_MessageType.Info);
                            }
                        }

                        f_WriteLog("Конец копирования папки с файлами", E_MessageType.Info);
                    }
                    else
                    {
                        f_WriteLog("Не удалось сохраненить сформированные записи", E_MessageType.Info);
                    }
                    f_WriteLog(string.Format("Конец формирования записей папки \"{0}\"", path));
                }
                else
                {
                    f_WriteLog("Папка архива записей для загрузки не существует.", E_MessageType.Error);
                }
            }
            else
            {
                f_WriteLog("Не указана папка архива записей для загрузки.", E_MessageType.Error);
            }
            f_FixedLog();
            Console.ReadKey(true);
        }
        /// <summary>Получение первого блока из текста отображения элемента</summary>
        /// <param name="a_Elements">Список элементов</param>
        /// <param name="a_Text">Текст</param>
        /// <returns></returns>
        private Cl_FormulaConditionBlock f_GetFirstConditionBlockFromText(Cl_Element[] a_Elements, string a_Text)
        {
            if (!string.IsNullOrWhiteSpace(a_Text))
            {
                string txt = "";
                if (a_Text.Length >= 3)
                {
                    txt = a_Text.Substring(0, 3);
                    if (txt == " > ")
                    {
                        return(new Cl_FormulaConditionBlock(Cl_FormulaConditionBlock.E_Opers.more));
                    }
                    else if (txt == " < ")
                    {
                        return(new Cl_FormulaConditionBlock(Cl_FormulaConditionBlock.E_Opers.less));
                    }
                    else if (txt == " = ")
                    {
                        return(new Cl_FormulaConditionBlock(Cl_FormulaConditionBlock.E_Opers.equals));
                    }
                    else if (txt == " И ")
                    {
                        return(new Cl_FormulaConditionBlock(Cl_FormulaConditionBlock.E_Opers.and));
                    }
                }
                if (a_Text.Length >= 4)
                {
                    txt = a_Text.Substring(0, 4);
                    if (txt == " != ")
                    {
                        return(new Cl_FormulaConditionBlock(Cl_FormulaConditionBlock.E_Opers.notEquals));
                    }
                }
                if (a_Text.Length >= 5)
                {
                    txt = a_Text.Substring(0, 5);
                    if (txt == " ИЛИ ")
                    {
                        return(new Cl_FormulaConditionBlock(Cl_FormulaConditionBlock.E_Opers.or));
                    }
                }
                if (a_Text.Length > Cl_FormulaConditionBlock.m_OperatorTag.Length)
                {
                    txt = a_Text.Substring(0, Cl_FormulaConditionBlock.m_OperatorTag.Length);
                    if (txt == Cl_FormulaConditionBlock.m_OperatorTag)
                    {
                        int indexEnd = a_Text.IndexOf(" ");
                        if (indexEnd > -1)
                        {
                            txt = a_Text.Substring(Cl_FormulaConditionBlock.m_OperatorTag.Length, indexEnd - Cl_FormulaConditionBlock.m_OperatorTag.Length);
                        }
                        else
                        {
                            txt = a_Text.Replace(Cl_FormulaConditionBlock.m_OperatorTag, "");
                        }

                        Cl_Element element = Cl_RecordsFacade.f_GetInstance().f_GetAgeElement(txt);
                        if (element == null)
                        {
                            element = Cl_RecordsFacade.f_GetInstance().f_GetGenderElement(txt);
                        }
                        if (element == null)
                        {
                            element = a_Elements.FirstOrDefault(el => el.p_Tag == txt);
                        }
                        if (element != null)
                        {
                            return(new Cl_FormulaConditionBlock(element));
                        }
                    }
                }
                if (a_Text.Length > 0)
                {
                    int indexStart = 0;
                    int lenght     = 0;
                    if (a_Text != "" && a_Text[0] == '"')
                    {
                        indexStart = 1;
                        lenght     = a_Text.IndexOf('"', 1) - indexStart;
                    }
                    else
                    {
                        byte[] asdsad = Encoding.ASCII.GetBytes(a_Text);
                        lenght = a_Text.IndexOf(" ");
                    }

                    if (lenght > -1)
                    {
                        txt = a_Text.Substring(indexStart, lenght);
                    }
                    else
                    {
                        txt = a_Text;
                    }

                    int iVal = 0;
                    if (int.TryParse(txt, out iVal))
                    {
                        return(new Cl_FormulaConditionBlock(iVal));
                    }
                    if (!string.IsNullOrWhiteSpace(txt))
                    {
                        return(new Cl_FormulaConditionBlock(txt));
                    }
                }
            }
            return(null);
        }
Ejemplo n.º 15
0
        private void ctrlBSave_Click(object sender, System.EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(ctrlTitle.Text))
            {
                MonitoringStub.Message("Заполните поле \"Заголовок\"!");
                return;
            }
            if (ctrlDTPDateReception.Value == null)
            {
                MonitoringStub.Message("Заполните поле \"Дата приема\"!");
                return;
            }
            if (ctrlDTPTimeReception.Value == null)
            {
                MonitoringStub.Message("Заполните поле \"Время приема\"!");
                return;
            }
            if (m_Record != null)
            {
                Cl_Record record = null;
                if (m_Record.p_Type == E_RecordType.ByTemplate && m_ControlTemplate != null)
                {
                    record = m_ControlTemplate.f_GetNewRecord();
                }
                else if (m_Record.p_Type == E_RecordType.FinishedFile && m_ControlRecordByFile != null)
                {
                    record = m_ControlRecordByFile.f_GetNewRecord();
                    if (record?.p_FileBytes == null)
                    {
                        MonitoringStub.Message("Заполните поле \"Файл записи\"!");
                        return;
                    }
                }
                if (record != null)
                {
                    using (var transaction = Cl_App.m_DataContext.Database.BeginTransaction())
                    {
                        try
                        {
                            if (m_Log.f_IsChanged(record) == false && record.p_Title == ctrlTitle.Text)
                            {
                                MonitoringStub.Message("Элемент не изменялся!");
                                transaction.Rollback();
                                return;
                            }

                            record.p_Title         = ctrlTitle.Text;
                            record.p_DateReception = new DateTime(ctrlDTPDateReception.Value.Year,
                                                                  ctrlDTPDateReception.Value.Month,
                                                                  ctrlDTPDateReception.Value.Day,
                                                                  ctrlDTPTimeReception.Value.Hour,
                                                                  ctrlDTPTimeReception.Value.Minute,
                                                                  0);

                            if (Cl_SessionFacade.f_GetInstance().p_Doctor.p_Permission.p_Role == Core.Permision.E_Roles.Assistant)
                            {
                                record.f_SetDoctor(Cl_SessionFacade.f_GetInstance().p_Doctor.p_ParentUser);
                            }

                            Cl_App.m_DataContext.p_Records.Add(record);
                            Cl_App.m_DataContext.SaveChanges();

                            if (m_Record.p_Type == E_RecordType.FinishedFile)
                            {
                                record.p_FilePath = Cl_RecordsFacade.f_GetInstance().f_GetLocalResourcesRelativeFilePath(record);
                                Cl_RecordsFacade.f_GetInstance().f_SaveFileFromSql(record);
                            }
                            else
                            {
                                record.p_HTMLDoctor  = record.f_GetHTMLDoctor();
                                record.p_HTMLPatient = record.f_GetHTMLPatient();
                            }
                            if (record.p_Version == 1)
                            {
                                record.p_RecordID = record.p_ID;
                            }
                            Cl_App.m_DataContext.SaveChanges();
                            Cl_EntityLog.f_CustomMessageLog(E_EntityTypes.UIEvents, string.Format("Сохранение записи: {0}, дата записи: {1}, клиника: {2}", record.p_Title, record.p_DateCreate, record.p_ClinicName), record.p_RecordID);

                            m_Log.f_SaveEntity(record, record.p_ParentRecord != null ? $"Создана новая запись на основе {record.p_ParentRecord.p_Title}" : "Создана новая запись");

                            transaction.Commit();
                            f_SetRecord(record);
                            e_Save?.Invoke(this, new Cl_Record.Cl_EventArgs()
                            {
                                p_Record = record
                            });
                            this.Close();
                        }
                        catch (Exception ex)
                        {
                            transaction.Rollback();
                            try
                            {
                                Cl_RecordsFacade.f_GetInstance().f_DeleteFileFromSql(record);
                            }
                            catch { };
                            MonitoringStub.Error("Error_Editor", "При сохранении изменений записи произошла ошибка", ex, null, null);
                        }
                    }
                }
            }
        }
        private void f_OnSelectRow(DataGridViewRow row)
        {
            m_SelectedRecord = null;
            m_SelectedRow    = null;
            if (row != null && row is OutlookGridRow && !((OutlookGridRow)row).IsGroupRow && row.Tag != null)
            {
                try
                {
                    var record = m_SelectedRecord = m_Records.FirstOrDefault(r => r.p_ID == ((Cl_Record)row.Tag).p_ID);
                    if (record != null)
                    {
                        m_SelectedRow = row;
                        Cl_EntityLog.f_CustomMessageLog(E_EntityTypes.UIEvents, string.Format("Просмотр записи: {0}, дата записи: {1}, клиника: {2}", record.p_Title, record.p_DateCreate, record.p_ClinicName), record.p_RecordID);

                        ctrlPRecordInfo.Visible = true;
                        ctrlRecordInfo.Text     = string.Format("{0} {1} [{2}, {3}]", record.p_DateCreate.ToShortDateString(), record.p_Title, record.p_DateLastChange, record.p_DoctorFIO);

                        ctrlCMViewer.Enabled             = true;
                        ctrlBAddRecordFromRecord.Visible = ctrlBReportFormatPattern.Visible = !record.p_IsAutomatic && !Cl_SessionFacade.f_GetInstance().p_MedicalCard.p_IsDelete&& !Cl_SessionFacade.f_GetInstance().p_MedicalCard.p_IsArchive&& (m_Permission.p_IsEditAllRecords || m_Permission.p_IsEditSelfRecords);
                        ctrlBReportEdit.Visible          = ctrlMIEdit.Visible = f_GetEdited(record);
                        ctrlBReportDelete.Visible        = ctrlMIDelete.Visible = Cl_SessionFacade.f_GetInstance().p_Doctor.p_Permission.p_IsEditAllRecords || ((m_Permission.p_IsEditArchive || Cl_SessionFacade.f_GetInstance().p_Doctor.p_Permission.p_IsEditSelfRecords) && record.p_DoctorID == Cl_SessionFacade.f_GetInstance().p_Doctor.p_UserID);
                        ctrlBReportRating.Visible        = ctrlMIRating.Visible = m_Permission.p_IsEditAllRatings;
                        ctrlBReportSyncBMK.Visible       = ctrlMISyncBMK.Visible = !record.p_IsSyncBMK && record.p_IsPrintDoctor && m_Permission.p_IsEditArchive;
                        ctrlBReportPrintDoctor.Visible   = ctrlBReportPrintPatient.Visible = ctrlMIPrint.Visible = m_Permission.p_IsPrint;

                        if (record.p_Type == E_RecordType.FinishedFile)
                        {
                            if (record.p_FileType == E_RecordFileType.HTML)
                            {
                                ctrlHTMLViewer.DocumentText = record.f_GetDocumentTextDoctor(Application.StartupPath);
                                ctrlHTMLViewer.Visible      = true;
                                ctrlPDFViewer.Visible       = false;
                            }
                            else if (record.p_FileType == E_RecordFileType.PDF)
                            {
                                var path = string.Format("{0}medicalChartTemp.pdf", Path.GetTempPath());
                                record.p_FileBytes = Cl_RecordsFacade.f_GetInstance().f_GetFileFromSql(record);
                                File.WriteAllBytes(path, record.p_FileBytes);
                                ctrlPDFViewer.src = path;
                                ctrlPDFViewer.Show();
                                ctrlHTMLViewer.Visible = false;
                                ctrlPDFViewer.Visible  = true;
                            }
                            else if (record.p_FileType == E_RecordFileType.JFIF || record.p_FileType == E_RecordFileType.JIF || record.p_FileType == E_RecordFileType.JPE ||
                                     record.p_FileType == E_RecordFileType.JPEG || record.p_FileType == E_RecordFileType.JPG || record.p_FileType == E_RecordFileType.PNG || record.p_FileType == E_RecordFileType.GIF)
                            {
                                ctrlHTMLViewer.DocumentText = record.f_GetDocumentTextDoctor(Application.StartupPath);
                                ctrlHTMLViewer.Visible      = true;
                                ctrlPDFViewer.Visible       = false;
                            }
                        }
                        else
                        {
                            if (record.p_HTMLDoctor != null)
                            {
                                ctrlHTMLViewer.DocumentText = record.f_GetDocumentTextDoctor(Application.StartupPath);
                                ctrlHTMLViewer.Visible      = true;
                                ctrlPDFViewer.Visible       = false;
                            }
                            else
                            {
                                ctrlHTMLViewer.Visible = false;
                                ctrlPDFViewer.Visible  = false;
                            }
                        }
                    }
                    else
                    {
                        ctrlPRecordInfo.Visible = false;
                    }
                }
                catch (Exception er)
                {
                    MonitoringStub.Error("Error_Editor", "Не удалось отобразить запись", er, null, null);
                }
            }
            if (m_SelectedRecord == null)
            {
                ctrlCMViewer.Enabled             = false;
                ctrlPRecordInfo.Visible          = false;
                ctrlBReportFormatPattern.Visible = false;
                ctrlBReportEdit.Visible          = false;
                ctrlBReportRating.Visible        = false;
                ctrlBReportPrintDoctor.Visible   = ctrlBReportPrintPatient.Visible = false;
            }
        }
Ejemplo n.º 17
0
        /// <summary>Получение HTML текста записи</summary>
        private string f_GetHTML(bool a_IsDoctor)
        {
            var template = Properties.Resources.ResourceManager.GetObject("template_report").ToString();

            template = Regex.Replace(template, "<fd\\.document\\.location>.*?<\\/fd\\.document\\.location>", string.Format("<fd.document.location>{0}</fd.document.location>", p_ClinicName));
            template = Regex.Replace(template, "<fd\\.document\\.patient>.*?<\\/fd\\.document\\.patient>", string.Format("<fd.document.patient>{0} {1} {2} {3} {4} {5} ({6}) # {7}</fd.document.patient>",
                                                                                                                         p_RecordID, p_MedicalCard.p_PatientSurName, p_MedicalCard.p_PatientName, p_MedicalCard.p_PatientLastName,
                                                                                                                         p_MedicalCard.p_PatientSex == Cl_User.E_Sex.Man ? "М" : "Ж", p_MedicalCard.p_PatientDateBirth.ToString("dd.MM.yyyy"), p_MedicalCard.f_GetPatientAgeByMonthText(p_DateCreate), p_ID));
            template = Regex.Replace(template, "<fd\\.document\\.date>.*?<\\/fd\\.document\\.date>", string.Format("<fd.document.date>{0}</fd.document.date>", p_DateReception.ToString("dd.MM.yyyy")));
            template = Regex.Replace(template, "<fd\\.document\\.time>.*?<\\/fd\\.document\\.time>", string.Format("<fd.document.time>{0}</fd.document.time>", p_DateReception.ToString("HH:mm")));
            template = Regex.Replace(template, "<fd\\.document\\.title>.*?<\\/fd\\.document\\.title>", string.Format("<fd.document.title>{0}</fd.document.title>", p_Title));
            string htmlContent = "";

            if (p_Type == E_RecordType.FinishedFile)
            {
                htmlContent += $"<div><img src=\"{Cl_RecordsFacade.f_GetInstance().f_GetLocalResourcesRelativeFilePath(this)}\" /></div>";
            }
            else
            {
                string htmlTabling  = null;
                string htmlFloating = null;
                byte   age          = p_MedicalCard.f_GetPatientAgeByYear(p_DateCreate);

                void f_EndTabling()
                {
                    if (htmlTabling != null)
                    {
                        htmlTabling += "</tbody></table>";
                        htmlContent += htmlTabling;
                        htmlTabling  = null;
                    }
                }

                void f_EndFloating()
                {
                    if (htmlFloating != null)
                    {
                        if (htmlFloating.Length > 0)
                        {
                            if (htmlFloating[htmlFloating.Length - 1] != '.')
                            {
                                htmlFloating += ".";
                            }
                            htmlFloating += "</p>";
                            htmlContent  += htmlFloating;
                        }
                        htmlFloating = null;
                    }
                }

                foreach (var value in p_Values)
                {
                    var te = Cl_RecordsFacade.f_GetInstance().f_GetTemplateElement(value);
                    if (te != null && te.p_Template != null)
                    {
                        decimal?min       = 0;
                        decimal?max       = 0;
                        var     partNorm  = value.p_Element.f_GetPartNormValue(p_MedicalCard.p_PatientSex, age, out min, out max);
                        string  htmlBlock = "";
                        if (a_IsDoctor)
                        {
                            htmlBlock = Cl_RecordsFacade.f_GetInstance().f_GetHTMLDoctor(this, value, te.p_Template.p_Type == Cl_Template.E_TemplateType.Table, min, max);
                        }
                        else
                        {
                            htmlBlock = Cl_RecordsFacade.f_GetInstance().f_GetHTMLPatient(this, value, te.p_Template.p_Type == Cl_Template.E_TemplateType.Table, min, max);
                        }
                        if (!string.IsNullOrWhiteSpace(htmlBlock))
                        {
                            if (te.p_Template.p_Type == Cl_Template.E_TemplateType.Table)
                            {
                                f_EndFloating();
                                if (htmlTabling == null)
                                {
                                    htmlTabling = "<table border=\"1\" cellpadding=\"4\" bordercolor=\"black\" width=\"100%\" style=\"border-collapse:collapse;font-family:Verdana;font-size:11px;\"><thead><tr><td>Показатель</td><td>Значение</td><td>Ед. изм.</td><td>Нормa</td></tr></thead><tbody>";
                                }
                                htmlTabling += htmlBlock;
                            }
                            else if (value.p_Element.p_ElementType == Cl_Element.E_ElementsTypes.Float)
                            {
                                f_EndTabling();
                                if (htmlFloating == null)
                                {
                                    htmlFloating = "<p>" + htmlBlock;
                                }
                                else
                                {
                                    htmlFloating += " " + htmlBlock;
                                }
                            }
                            else
                            {
                                f_EndTabling();
                                f_EndFloating();
                                if (a_IsDoctor)
                                {
                                    htmlContent += htmlBlock;
                                }
                                else
                                {
                                    htmlContent += htmlBlock;
                                }
                            }
                        }
                    }
                }
                f_EndTabling();
                f_EndFloating();
            }

            htmlContent += $"<p>MKБ: {p_MKB1} - {p_MKB2} - {p_MKB3} - {p_MKB4}</p>";
            template     = Regex.Replace(template, "<fd\\.document\\.content>.*?<\\/fd\\.document\\.content>", string.Format("<fd.document.content>{0}</fd.document.content>", htmlContent));
            template     = Regex.Replace(template, "<fd\\.document\\.doctor>.*?<\\/fd\\.document\\.doctor>", string.Format("<fd.document.doctor>{0}</fd.document.doctor>", p_DoctorFIO));
            return(template);
        }
        public void f_TestElementMathematicalFormula()
        {
            //tag_one = "14"; tag_dva = 11; tag_tri = 5
            var record = new Cl_Record()
            {
                p_Title = "Тест проверки формул"
            };

            record.p_Values = new List <Cl_RecordValue>();

            var template = new Cl_Template()
            {
                p_Name = "Тест проверки формул", p_Type = Cl_Template.E_TemplateType.Template
            };
            var elements = new List <Cl_TemplateElement>();

            var element = new Cl_Element()
            {
                p_ID          = 1,
                p_Name        = "Формула 1",
                p_Tag         = "one",
                p_IsNumber    = true,
                p_NumberRound = 3
            };

            element.p_ParamsValues = new List <Cl_ElementParam>();
            for (int i = 1; i < 4; i++)
            {
                element.p_ParamsValues.Add(new Cl_ElementParam()
                {
                    p_Element = element, p_TypeParam = Cl_ElementParam.E_TypeParam.NormValues, p_Value = i.ToString()
                });
                element.p_ParamsValues.Add(new Cl_ElementParam()
                {
                    p_Element = element, p_TypeParam = Cl_ElementParam.E_TypeParam.PatValues, p_Value = i.ToString()
                });
            }
            record.p_Values.Add(new Cl_RecordValue()
            {
                p_ElementID = element.p_ID, p_Element = element, p_ValueUser = "******"
            });
            elements.Add(new Cl_TemplateElement()
            {
                p_Template = template, p_ChildElement = element, p_Index = 0
            });
            element = new Cl_Element()
            {
                p_ID          = 2,
                p_Name        = "Формула 2",
                p_Tag         = "dva",
                p_IsNumber    = true,
                p_NumberRound = 2
            };
            element.p_ParamsValues = new List <Cl_ElementParam>();
            for (int i = 1; i < 4; i++)
            {
                element.p_ParamsValues.Add(new Cl_ElementParam()
                {
                    p_Element = element, p_TypeParam = Cl_ElementParam.E_TypeParam.NormValues, p_Value = i.ToString()
                });
                element.p_ParamsValues.Add(new Cl_ElementParam()
                {
                    p_Element = element, p_TypeParam = Cl_ElementParam.E_TypeParam.PatValues, p_Value = i.ToString()
                });
            }
            record.p_Values.Add(new Cl_RecordValue()
            {
                p_ElementID = element.p_ID, p_Element = element, p_ValueUser = "******"
            });
            elements.Add(new Cl_TemplateElement()
            {
                p_Template = template, p_ChildElement = element, p_Index = 1
            });
            element = new Cl_Element()
            {
                p_ID          = 3,
                p_Name        = "Формула 3",
                p_Tag         = "tri",
                p_IsNumber    = true,
                p_NumberRound = 2
            };
            element.p_ParamsValues = new List <Cl_ElementParam>();
            for (int i = 1; i < 4; i++)
            {
                element.p_ParamsValues.Add(new Cl_ElementParam()
                {
                    p_Element = element, p_TypeParam = Cl_ElementParam.E_TypeParam.NormValues, p_Value = i.ToString()
                });
                element.p_ParamsValues.Add(new Cl_ElementParam()
                {
                    p_Element = element, p_TypeParam = Cl_ElementParam.E_TypeParam.PatValues, p_Value = i.ToString()
                });
            }
            record.p_Values.Add(new Cl_RecordValue()
            {
                p_ElementID = element.p_ID, p_Element = element, p_ValueUser = "******"
            });
            elements.Add(new Cl_TemplateElement()
            {
                p_Template = template, p_ChildElement = element, p_Index = 2
            });

            element = new Cl_Element()
            {
                p_ID            = 4,
                p_Name          = "Формула 4",
                p_Tag           = "chet",
                p_IsNumber      = true,
                p_NumberRound   = 2,
                p_NumberFormula = "tag_dva - 100"
            };
            //record.p_Values.Add(new Cl_RecordValue() { p_ElementID = element.p_ID, p_Element = element });
            elements.Add(new Cl_TemplateElement()
            {
                p_Template = template, p_ChildElement = element, p_Index = 4
            });

            template.p_TemplateElements = elements;
            record.f_SetTemplate(template);

            decimal?result = Cl_RecordsFacade.f_GetInstance().f_GetElementMathematicValue(record, "tag_one + 3");

            Assert.AreEqual(17, result);
            result = Cl_RecordsFacade.f_GetInstance().f_GetElementMathematicValue(record, "tag_one + 8");
            Assert.AreEqual(22, result);

            result = Cl_RecordsFacade.f_GetInstance().f_GetElementMathematicValue(record, "tag_one - 3");
            Assert.AreEqual(11, result);
            result = Cl_RecordsFacade.f_GetInstance().f_GetElementMathematicValue(record, "tag_dva - 8");
            Assert.AreEqual(3, result);
            result = Cl_RecordsFacade.f_GetInstance().f_GetElementMathematicValue(record, "tag_dva * 11");
            Assert.AreEqual(121, result);
            result = Cl_RecordsFacade.f_GetInstance().f_GetElementMathematicValue(record, "tag_dva / 2");
            Assert.AreEqual((decimal)5.5, result);
            result = Cl_RecordsFacade.f_GetInstance().f_GetElementMathematicValue(record, "tag_tri - 7");
            Assert.AreEqual(-2, result);

            result = Cl_RecordsFacade.f_GetInstance().f_GetElementMathematicValue(record, "tag_one + tag_dva - tag_tri");
            Assert.AreEqual(20, result);
            result = Cl_RecordsFacade.f_GetInstance().f_GetElementMathematicValue(record, "tag_one * tag_dva / tag_tri");
            Assert.AreEqual((decimal)30.8, result);

            result = Cl_RecordsFacade.f_GetInstance().f_GetElementMathematicValue(record, "tag_one / tag_chet / tag_chet");
            Assert.AreEqual((decimal)0.001767, Math.Round(result.Value, 6));
        }
        public void f_TestCreateRecord()
        {
            var temlName = "Тест проверки создания API работы с записями";
            var dc       = new Cl_DataContextMegaTemplate(f_GetConnectionString());

            dc.f_Init();
            var result = Cl_MedicalCardsFacade.f_GetInstance().f_Init(dc);

            Assert.AreEqual(true, result);
            result = Cl_TemplatesFacade.f_GetInstance().f_Init(dc);
            Assert.AreEqual(true, result);
            result = Cl_RecordsFacade.f_GetInstance().f_Init(dc, f_GetLocalResourcesPath());
            Assert.AreEqual(true, result);
            result = Cl_CatalogsFacade.f_GetInstance().f_Init(dc);
            Assert.AreEqual(true, result);

            var groupTpl = dc.p_Groups.FirstOrDefault(g => g.p_Type == Cl_Group.E_Type.Templates && g.p_Name == "test");

            if (groupTpl == null)
            {
                groupTpl = new Cl_Group()
                {
                    p_Name = "test", p_Type = Cl_Group.E_Type.Elements
                };
                dc.p_Groups.Add(groupTpl);
                dc.SaveChanges();
            }
            var groupEl = dc.p_Groups.FirstOrDefault(g => g.p_Type == Cl_Group.E_Type.Templates && g.p_Name == "test");

            if (groupEl == null)
            {
                groupEl = new Cl_Group()
                {
                    p_Name = "test", p_Type = Cl_Group.E_Type.Elements
                };
                dc.p_Groups.Add(groupEl);
                dc.SaveChanges();
            }

            if (!Cl_CatalogsFacade.f_GetInstance().f_HasCategory("Осмотр"))
            {
                Cl_CatalogsFacade.f_GetInstance().f_AddCategory(Cl_Category.E_CategoriesTypes.Total, "Осмотр");
            }
            if (!Cl_CatalogsFacade.f_GetInstance().f_HasCategory("Клиническая 1"))
            {
                Cl_CatalogsFacade.f_GetInstance().f_AddCategory(Cl_Category.E_CategoriesTypes.Clinic, "Клиническая 1");
            }

            var catTotal = Cl_CatalogsFacade.f_GetInstance().f_GetCategory("Осмотр");

            Assert.AreNotEqual(null, catTotal);
            var catClinic = Cl_CatalogsFacade.f_GetInstance().f_GetCategory("Клиническая 1");

            Assert.AreNotEqual(null, catClinic);

            var tmpl = Cl_TemplatesFacade.f_GetInstance().f_GetTemplateByName(temlName);

            if (tmpl == null)
            {
                tmpl = new Cl_Template()
                {
                    p_Name = temlName, p_Type = Cl_Template.E_TemplateType.Template
                };
                var elements = new List <Cl_TemplateElement>();

                var element = new Cl_Element()
                {
                    p_ParentGroupID = groupEl.p_ID,
                    p_ParentGroup   = groupEl,
                    p_Name          = "Формула 1",
                    p_Tag           = "one",
                    p_IsNumber      = true,
                    p_NumberRound   = 3
                };
                element.p_ParamsValues = new List <Cl_ElementParam>();
                for (int i = 1; i < 4; i++)
                {
                    element.p_ParamsValues.Add(new Cl_ElementParam()
                    {
                        p_Element = element, p_TypeParam = Cl_ElementParam.E_TypeParam.NormValues, p_Value = i.ToString()
                    });
                    element.p_ParamsValues.Add(new Cl_ElementParam()
                    {
                        p_Element = element, p_TypeParam = Cl_ElementParam.E_TypeParam.PatValues, p_Value = i.ToString()
                    });
                }
                elements.Add(new Cl_TemplateElement()
                {
                    p_Template = tmpl, p_ChildElement = element, p_Index = 0
                });

                element = new Cl_Element()
                {
                    p_ParentGroupID = groupEl.p_ID,
                    p_ParentGroup   = groupEl,
                    p_Name          = "Формула 2",
                    p_Tag           = "dva",
                    p_IsNumber      = true,
                    p_NumberRound   = 2
                };
                element.p_ParamsValues = new List <Cl_ElementParam>();
                for (int i = 1; i < 4; i++)
                {
                    element.p_ParamsValues.Add(new Cl_ElementParam()
                    {
                        p_Element = element, p_TypeParam = Cl_ElementParam.E_TypeParam.NormValues, p_Value = i.ToString()
                    });
                    element.p_ParamsValues.Add(new Cl_ElementParam()
                    {
                        p_Element = element, p_TypeParam = Cl_ElementParam.E_TypeParam.PatValues, p_Value = i.ToString()
                    });
                }
                elements.Add(new Cl_TemplateElement()
                {
                    p_Template = tmpl, p_ChildElement = element, p_Index = 1
                });
                element = new Cl_Element()
                {
                    p_ParentGroupID = groupEl.p_ID,
                    p_ParentGroup   = groupEl,
                    p_Name          = "Формула 3",
                    p_Tag           = "tri",
                    p_IsNumber      = true,
                    p_NumberRound   = 2
                };
                element.p_ParamsValues = new List <Cl_ElementParam>();
                for (int i = 1; i < 4; i++)
                {
                    element.p_ParamsValues.Add(new Cl_ElementParam()
                    {
                        p_Element = element, p_TypeParam = Cl_ElementParam.E_TypeParam.NormValues, p_Value = i.ToString()
                    });
                    element.p_ParamsValues.Add(new Cl_ElementParam()
                    {
                        p_Element = element, p_TypeParam = Cl_ElementParam.E_TypeParam.PatValues, p_Value = i.ToString()
                    });
                }
                elements.Add(new Cl_TemplateElement()
                {
                    p_Template = tmpl, p_ChildElement = element, p_Index = 2
                });
                tmpl.p_ParentGroupID    = groupTpl.p_ID;
                tmpl.p_ParentGroup      = groupTpl;
                tmpl.p_TemplateElements = elements;
                tmpl.p_CategoryTotalID  = catTotal.p_ID;
                tmpl.p_CategoryTotal    = catTotal;
                tmpl.p_CategoryClinicID = catClinic.p_ID;
                tmpl.p_CategoryClinic   = catClinic;

                dc.p_Templates.Add(tmpl);
                dc.SaveChanges();
            }
            Assert.AreNotEqual(null, tmpl);

            var elts = Cl_TemplatesFacade.f_GetInstance().f_GetElements(tmpl);

            Assert.AreNotEqual(null, elts);
            var vals = new List <Cl_RecordValue>();

            foreach (var el in elts)
            {
                vals.Add(new Cl_RecordValue()
                {
                    p_ElementID = el.p_ID, p_Element = el, p_ValueUser = "******"
                });
            }
            var medicalCard1 = Cl_MedicalCardsFacade.f_GetInstance().f_GetMedicalCard("777", 1);

            if (medicalCard1 == null)
            {
                medicalCard1 = Cl_MedicalCardsFacade.f_GetInstance().f_CreateMedicalCard("777", 1, Core.Permision.Cl_User.E_Sex.Man, "Иванов", "Иван", "Иванович", new DateTime(1996, 3, 11), "Медкарта API тест 777");
            }
            Assert.IsNotNull(medicalCard1);
            result = Cl_RecordsFacade.f_GetInstance().f_CreateRecord(medicalCard1, catTotal, catClinic, "Заголовок API тест - значения", "Клиника API тест значения", 56369,
                                                                     "Доктор_Фамилия", "Доктор_Имя", "Доктор_Отчество",
                                                                     tmpl, vals);
            Assert.AreEqual(true, result);
            result = Cl_RecordsFacade.f_GetInstance().f_CreateRecord(medicalCard1, catTotal, catClinic, "Заголовок API тест - файл", "Клиника API тест файл", 56369,
                                                                     "Доктор_Фамилия", "Доктор_Имя", "Доктор_Отчество",
                                                                     E_RecordFileType.HTML, Encoding.UTF8.GetBytes("<h1>API тест файл<h1>"));
            Assert.AreEqual(true, result);
        }