public void f_SetRecord(Cl_Record a_Record) { m_Record = a_Record; if (m_Record != null) { if (m_Record.p_MedicalCard != null) { ctrlPatientFIO.Text = string.Format("{0}, {1}, {2} ({3})", m_Record.p_MedicalCard.p_PatientFIO, m_Record.p_MedicalCard.p_PatientSex == Core.Permision.Cl_User.E_Sex.Man ? "М" : m_Record.p_MedicalCard.p_PatientSex == Core.Permision.Cl_User.E_Sex.Female ? "Ж" : "Нет данных", m_Record.p_MedicalCard.p_PatientDateBirth.ToShortDateString(), m_Record.p_MedicalCard.f_GetPatientAgeByMonthText(m_Record.p_DateCreate)); ctrlTitle.Text = m_Record.p_Title; if (m_Record.p_DateReception.Year >= 1980) { ctrlDTPDateReception.Value = m_Record.p_DateReception; ctrlDTPTimeReception.Value = m_Record.p_DateReception; } else { ctrlDTPDateReception.Value = DateTime.Now; ctrlDTPTimeReception.Value = DateTime.Now; } if (m_Record.p_Version == 0) { ctrl_Version.Text = "Черновик"; } else { ctrl_Version.Text = m_Record.p_Version.ToString(); } } if (m_Record.p_Template != null) { try { Cl_TemplatesFacade.f_GetInstance().f_LoadTemplatesElements(m_Record.p_Template); Text = string.Format("Запись \"{0}\" v{1}", m_Record.p_Template.p_Name, ConfigurationManager.AppSettings["Version"]); f_UpdateControls(); } catch (Exception er) { MonitoringStub.Error("Error_Editor", "Не удалось установить запись", er, null, null); } } else if (m_Record.p_Type == E_RecordType.FinishedFile) { try { Text = string.Format("Запись c готовым файлом v{0}", ConfigurationManager.AppSettings["Version"]); f_UpdateControls(); } catch (Exception er) { MonitoringStub.Error("Error_Editor", "Не удалось установить запись", er, null, null); } } m_Log.f_SetEntity(m_Record); } }
private void ctrl_B_UpSave_Click(object sender, EventArgs e) { I_Element[] templates = new I_Element[ctrl_EditorPanel.Items.Count]; ctrl_EditorPanel.Items.CopyTo(templates, 0); Cl_Template tpl = Cl_TemplatesFacade.f_GetInstance().f_UpSaveTemplate(p_EditingTemplate, templates, m_Log); f_SetTemplate(tpl); }
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); } } }
private void Ctrl_TreeTemplates_e_EditTemplate(object sender, TreeViewEventArgs e) { Ctrl_TreeNodeTemplate treeNode = (Ctrl_TreeNodeTemplate)e.Node; var tpl = Cl_App.m_DataContext.p_Templates .Where(t => t.p_TemplateID == treeNode.p_Template.p_TemplateID && !t.p_IsDelete).OrderByDescending(v => v.p_Version).FirstOrDefault(); if (tpl != null) { Cl_TemplatesFacade.f_GetInstance().f_LoadTemplatesElements(tpl); treeNode.p_Template = tpl; F_DesignerTemplate editor = new F_DesignerTemplate(); editor.p_ActiveTemplate = treeNode.p_Template; editor.WindowState = FormWindowState.Maximized; editor.ShowDialog(ParentForm); ctrl_TreeTemplates.f_Update(); } }
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); } }
private void f_DragNewTemplate(Ctrl_TreeNodeTemplate a_NodeTemplate, int a_PosX, int a_PosY) { if (a_NodeTemplate == null) { return; } if (a_NodeTemplate.p_Template == null) { return; } Ctrl_Template ctrlEl = new Ctrl_Template(); Cl_TemplatesFacade.f_GetInstance().f_LoadTemplatesElements(a_NodeTemplate.p_Template); ctrlEl.p_Template = a_NodeTemplate.p_Template; ctrlEl.Name = f_CreateName(ctrlEl.p_Name); Items.Add(ctrlEl); this.Invalidate(this.InsertionIndex); this.InsertionIndex = InvalidIndex; ctrlMenuDel.Visible = Items.Count > 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); } } }
public void f_SetTemplate(Cl_Template a_Template) { if (a_Template == null) { return; } p_EditingTemplate = a_Template; if (p_EditingTemplate.p_Version == 0) { ctrl_Version.Text = "Черновик"; } else { ctrl_Version.Text = p_EditingTemplate.p_Version.ToString(); } Cl_TemplatesFacade.f_GetInstance().f_LoadTemplatesElements(a_Template); m_Log.f_SetEntity(a_Template); if (a_Template.p_TemplateElements != null) { ctrl_EditorPanel.f_SetTemplatesElements(a_Template.p_TemplateElements.ToArray()); } }
protected override void OnDrawItem(DrawItemEventArgs e) { e.DrawBackground(); e.DrawFocusRectangle(); if (e.Index != -1 && Items.Count > e.Index) { if (Items[e.Index] is I_Element) { var el = (I_Element)Items[e.Index]; Color foreColor = ForeColor; if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) { foreColor = Color.White; } if (el is Ctrl_Element) { Ctrl_Element elm = (Ctrl_Element)el; if (Cl_TemplatesFacade.f_GetInstance().f_IsActualElement(elm.p_Element) == false) { foreColor = Color.Red; } } else if (el is Ctrl_Template) { Ctrl_Template tmpl = (Ctrl_Template)el; if (Cl_TemplatesFacade.f_GetInstance().f_IsActualElementsOnTemplate(tmpl.p_Template) == false) { foreColor = Color.Red; } } el.f_Draw(e.Graphics, e.Bounds, Font, foreColor); } } }
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); }
/// <summary>Обновление части дерева</summary> public void f_Update() { m_Template = Cl_TemplatesFacade.f_GetInstance().f_GetActualTemplate(m_Template); f_ReDraw(); }