/// <summary> /// 删除个人模板 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_DelPersonTemplate_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (TemplatePerson.FocusedRowHandle < 0) { return; } DataRow foucesRow = TemplatePerson.GetDataRow(TemplatePerson.FocusedRowHandle); if (foucesRow == null) { return; } if (foucesRow.IsNull("TEMPLATEID")) { return; } PatRecUtil util = new PatRecUtil(m_app, m_app.CurrentPatientInfo); util.DelTemplatePerson(foucesRow["ID"].ToString()); foucesRow.Delete(); //gridViewDepartment.DataSource.AcceptChanges(); }
public void Run() { using (DatabaseSetup db = new DatabaseSetup(Utili.GetCurrentMethodAndClass())) { Simulator sim = new Simulator(db.ConnectionString); ObservableCollection <TemplatePersonPresenter.TraitPrio> traitPrios = new ObservableCollection <TemplatePersonPresenter.TraitPrio>(); TemplatePerson template = sim.TemplatePersons.CreateNewItem(db.ConnectionString); template.SaveToDB(); template.AddTrait(sim.HouseholdTraits.It[0]); TemplatePersonPresenter.RefreshTree(traitPrios, sim, template); traitPrios.Count.Should().BeGreaterThan(0); db.Cleanup(); } }
public static void CreateTemplatePersons([NotNull] Simulator sim) { Logger.Info("Starting the creation of the templated persons"); var tps = sim.TemplatePersons.It.ToList(); foreach (var tpperson in tps) { sim.TemplatePersons.DeleteItem(tpperson); } var tp = 1; var allPersons = new List <PersonEntry>(); foreach (var simPerson in sim.Persons.It) { allPersons.Add(new PersonEntry(simPerson)); } allPersons.Sort(); foreach (var personEntry in allPersons) { var person = personEntry.Person; TemplatePerson tpPerson = null; Logger.Get().SafeExecuteWithWait(() => tpPerson = sim.TemplatePersons.CreateNewItem(sim.ConnectionString)); var tpName = "TP" + tp.ToString("000", CultureInfo.CurrentCulture) + " " + person.Description; Logger.Info("Creating " + tpName); tpPerson.Name = tpName; tpPerson.Gender = person.Gender; tpPerson.Age = person.Age; tpPerson.SickDays = person.SickDays; var mhh = sim.ModularHouseholds.It.First(x => x.Persons.Any(y => y.Person == person)); tpPerson.BaseHousehold = mhh; tpPerson.BasePerson = personEntry.Person; tpPerson.SaveToDB(); var chh = sim.ModularHouseholds.It.First(x => x.Persons.Select(y => y.Person).Any(z => z == person)); Logger.Info("Found " + chh.PrettyName); var traits = chh.Traits.Where(x => x.DstPerson == person).ToList(); traits.ForEach(x => tpPerson.AddTrait(x.HouseholdTrait)); Logger.Info("Added " + traits.Count + " traits"); tp++; } Logger.Info("finished the template persons"); }
public void TemplatePersonTest() { using (var db = new DatabaseSetup(Utili.GetCurrentMethodAndClass())) { db.ClearTable(TemplatePerson.TableName); db.ClearTable(TemplatePersonTrait.TableName); var cat = new CategoryDBBase <TemplatePerson>("TemplatePersons"); var timeBasedProfiles = db.LoadTimeBasedProfiles(); var devices = db.LoadRealDevices(out ObservableCollection <DeviceCategory> deviceCategories, out ObservableCollection <VLoadType> loadTypes, timeBasedProfiles); var locations = db.LoadLocations(devices, deviceCategories, loadTypes); var desires = db.LoadDesires(); var dateBasedProfiles = db.LoadDateBasedProfiles(); var timeLimits = db.LoadTimeLimits(dateBasedProfiles); var deviceActionGroups = db.LoadDeviceActionGroups(); var deviceActions = db.LoadDeviceActions(timeBasedProfiles, devices, loadTypes, deviceActionGroups); var variables = db.LoadVariables(); var affordances = db.LoadAffordances(timeBasedProfiles, out _, deviceCategories, devices, desires, loadTypes, timeLimits, deviceActions, deviceActionGroups, locations, variables); var traitTags = db.LoadTraitTags(); var traits = db.LoadHouseholdTraits(locations, affordances, devices, deviceCategories, timeBasedProfiles, loadTypes, timeLimits, desires, deviceActions, deviceActionGroups, traitTags, variables); var selections = db.LoadDeviceSelections(deviceCategories, devices, deviceActions, deviceActionGroups); var persons = db.LoadPersons(); var vacations = db.LoadVacations(); var tags = db.LoadHouseholdTags(); var chhs = db.LoadModularHouseholds(traits, selections, persons, vacations, tags, traitTags); TemplatePerson.LoadFromDatabase(cat.It, db.ConnectionString, traits, false, chhs, persons); (cat.MyItems.Count).Should().Be(0); cat.CreateNewItem(db.ConnectionString); cat.SaveToDB(); var templatePerson = new ObservableCollection <TemplatePerson>(); TemplatePerson.LoadFromDatabase(templatePerson, db.ConnectionString, traits, false, chhs, persons); (templatePerson.Count).Should().Be(1); db.Cleanup(); } }
private void Commit() { if (xtraTabControl1.SelectedTabPage == xtraTabPageCommon) { //通用模板 DataRow row = gridView1.GetDataRow(gridView1.FocusedRowHandle); if (row == null) { return; } _commitModel = new EmrModel(); _commitModel.InstanceId = -1; _commitModel.TempIdentity = row["TEMPLET_ID"].ToString(); _commitModel.ModelName = row["MR_NAME"].ToString().Replace(" ", "-"); _commitModel.ModelCatalog = row["MR_CLASS"].ToString(); _commitModel.FirstDailyEmrModel = m_IsFristDailyEmr; //首次病程 _commitModel.IsNewPage = row["NEW_PAGE_FLAG"].ToString() == "1" ? true : false; _commitModel.FileName = row["FILE_NAME"].ToString(); _commitModel.IsShowFileName = row["ISSHOWFILENAME"].ToString(); _commitModel.IsYiHuanGouTong = row["ISYIHUANGOUTONG"].ToString(); _commitModel.NewPageEnd = row["NEW_PAGE_END"].ToString() == "1" ? true : false; _commitModel.IsReadConfigPageSize = row["ISCONFIGPAGESIZE"].ToString() == "1" ? true : false; if (!string.IsNullOrEmpty(_commitModel.TempIdentity)) { this.DialogResult = System.Windows.Forms.DialogResult.OK; } } if (xtraTabControl1.SelectedTabPage == xtraTabPageTemplatePerson) { //个人模板 DataRow row = TemplatePerson.GetDataRow(TemplatePerson.FocusedRowHandle); if (row == null) { return; } _commitModel = new EmrModel(); _commitModel.InstanceId = -1; _commitModel.TempIdentity = row["templateid"].ToString(); _commitModel.ModelName = row["MR_NAME"].ToString().Replace(" ", "-"); _commitModel.ModelCatalog = row["SORTID"].ToString(); XmlDocument dom = new XmlDocument(); dom.LoadXml(RecordDal.UnzipEmrXml(m_RecordDal.GetTemplatePersonContent(row["ID"].ToString()))); _commitModel.ModelContent = dom; _commitModel.FirstDailyEmrModel = m_IsFristDailyEmr; //首次病程 _commitModel.IsNewPage = false; _commitModel.IsReadConfigPageSize = row["ISCONFIGPAGESIZE"].ToString() == "1" ? true : false; if (!string.IsNullOrEmpty(_commitModel.ModelContent.OuterXml)) { this.DialogResult = System.Windows.Forms.DialogResult.OK; } } if (xtraTabControl1.SelectedTabPage == xtraTabPageDepartment) { //科室模板 DataRow row = gridViewDepartment.GetDataRow(gridViewDepartment.FocusedRowHandle); if (row == null) { return; } _commitModel = new EmrModel(); _commitModel.InstanceId = -1; _commitModel.TempIdentity = row["templateid"].ToString(); _commitModel.ModelName = row["MR_NAME"].ToString().Replace(" ", "-"); _commitModel.ModelCatalog = row["SORTID"].ToString(); XmlDocument dom = new XmlDocument(); dom.LoadXml(RecordDal.UnzipEmrXml(m_RecordDal.GetTemplatePersonContent(row["ID"].ToString()))); _commitModel.ModelContent = dom; _commitModel.FirstDailyEmrModel = m_IsFristDailyEmr; //首次病程 _commitModel.IsNewPage = false; _commitModel.IsReadConfigPageSize = row["ISCONFIGPAGESIZE"].ToString() == "1" ? true : false; if (!string.IsNullOrEmpty(_commitModel.ModelContent.OuterXml)) { this.DialogResult = System.Windows.Forms.DialogResult.OK; } } if (xtraTabControl1.SelectedTabPage == xtraTabPageHistoryEMR) { //病人历史病历 DataRow row = gridViewHistoryEMR.GetDataRow(gridViewHistoryEMR.FocusedRowHandle); if (row == null) { return; } _commitModel = new EmrModel(); _commitModel.InstanceId = -1; _commitModel.TempIdentity = row["templateid"].ToString(); _commitModel.ModelName = row["MR_NAME"].ToString().Replace(" ", "-"); _commitModel.ModelCatalog = row["SORTID"].ToString(); if (row["content"].ToString() == "") { string recorddetailid = row["ID"].ToString(); string emrContent = m_RecordDal.GetEmrContentByID(recorddetailid); XmlDocument dom = new XmlDocument(); dom.PreserveWhitespace = true; dom.LoadXml(emrContent); _commitModel.ModelContentHistory = dom; } else { string emrContent = row["content"].ToString(); XmlDocument dom = new XmlDocument(); dom.PreserveWhitespace = true; dom.LoadXml(emrContent); _commitModel.ModelContentHistory = dom; } _commitModel.FirstDailyEmrModel = m_IsFristDailyEmr; //首次病程 _commitModel.IsNewPage = row["NEW_PAGE_FLAG"].ToString() == "1" ? true : false; _commitModel.FileName = row["FILE_NAME"].ToString(); _commitModel.IsShowFileName = row["ISSHOWFILENAME"].ToString(); _commitModel.IsYiHuanGouTong = row["ISYIHUANGOUTONG"].ToString(); _commitModel.NewPageEnd = row["NEW_PAGE_END"].ToString() == "1" ? true : false; _commitModel.IsReadConfigPageSize = row["ISCONFIGPAGESIZE"].ToString() == "1" ? true : false; if (!string.IsNullOrEmpty(_commitModel.TempIdentity)) { this.DialogResult = System.Windows.Forms.DialogResult.OK; } } }
public TemplatePersonPresenter([NotNull] ApplicationPresenter applicationPresenter, [NotNull] TemplatePersonView view, [NotNull] TemplatePerson template) : base(view, "ThisTemplate.HeaderString", template, applicationPresenter) { _thisTemplate = template; RefreshTree(TraitPrios, Sim, template); }
private List <LoadingEntry> GetLoadingActions(bool ignoreMissingTables) { var actions = new List <LoadingEntry> { new LoadingEntry("Loadtypes", () => VLoadType.LoadFromDatabase(LoadTypes.MyItems, ConnectionString, ignoreMissingTables), LoadTypes), new LoadingEntry("Holidays", () => Holiday.LoadFromDatabase(Holidays.MyItems, ConnectionString, ignoreMissingTables), Holidays), new LoadingEntry("Variables", () => Variable.LoadFromDatabase(Variables.It, ConnectionString, ignoreMissingTables), Variables), new LoadingEntry("Date Based Profiles", () => DateBasedProfile.LoadFromDatabase(DateBasedProfiles.MyItems, ConnectionString, ignoreMissingTables), DateBasedProfiles), new LoadingEntry("Vacations", () => Vacation.LoadFromDatabase(Vacations.MyItems, ConnectionString, ignoreMissingTables), Vacations), new LoadingEntry("Desires", () => Desire.LoadFromDatabase(Desires.MyItems, ConnectionString, ignoreMissingTables), Desires), new LoadingEntry("Time Profiles", () => TimeBasedProfile.LoadFromDatabase(Timeprofiles.MyItems, ConnectionString, ignoreMissingTables), Timeprofiles), new LoadingEntry("Temperature Profiles", () => TemperatureProfile.LoadFromDatabase(TemperatureProfiles.MyItems, ConnectionString, ignoreMissingTables), TemperatureProfiles), new LoadingEntry("Generators", () => Generator.LoadFromDatabase(Generators.MyItems, ConnectionString, LoadTypes.MyItems, DateBasedProfiles.MyItems, ignoreMissingTables), Generators), new LoadingEntry("Energy Storages", () => EnergyStorage.LoadFromDatabase(EnergyStorages.MyItems, ConnectionString, LoadTypes.MyItems, Variables.MyItems, ignoreMissingTables), EnergyStorages), new LoadingEntry("Transformation Devices", () => TransformationDevice.LoadFromDatabase(TransformationDevices.MyItems, ConnectionString, LoadTypes.MyItems, Variables.MyItems, ignoreMissingTables), TransformationDevices), new LoadingEntry("Device Categories", () => { DeviceCategory.LoadFromDatabase(DeviceCategories.MyItems, out _dcnone, ConnectionString, RealDevices.MyItems, ignoreMissingTables); DeviceCategories.DeviceCategoryNone = _dcnone; }, DeviceCategories), new LoadingEntry("Real Devices", () => RealDevice.LoadFromDatabase(RealDevices.MyItems, DeviceCategories.MyItems, DeviceCategories.DeviceCategoryNone, ConnectionString, LoadTypes.MyItems, Timeprofiles.MyItems, ignoreMissingTables), RealDevices), new LoadingEntry("Device Action Groups", () => DeviceActionGroup.LoadFromDatabase(DeviceActionGroups.MyItems, ConnectionString, ignoreMissingTables), DeviceActionGroups), new LoadingEntry("Device Actions", () => DeviceAction.LoadFromDatabase(DeviceActions.MyItems, ConnectionString, Timeprofiles.MyItems, RealDevices.MyItems, LoadTypes.MyItems, DeviceActionGroups.MyItems, ignoreMissingTables), DeviceActions), new LoadingEntry("Device Tagging Sets", () => DeviceTaggingSet.LoadFromDatabase(DeviceTaggingSets.MyItems, ConnectionString, ignoreMissingTables, RealDevices.MyItems, LoadTypes.It), DeviceTaggingSets), new LoadingEntry("Persons", () => Person.LoadFromDatabase(Persons.MyItems, ConnectionString, ignoreMissingTables), Persons), new LoadingEntry("Locations", () => Location.LoadFromDatabase(Locations.MyItems, ConnectionString, RealDevices.MyItems, DeviceCategories.MyItems, LoadTypes.MyItems, ignoreMissingTables), Locations), new LoadingEntry("Time Limits", () => TimeLimit.LoadFromDatabase(TimeLimits.MyItems, DateBasedProfiles.MyItems, ConnectionString, ignoreMissingTables), TimeLimits), new LoadingEntry("Geographic Locations", () => GeographicLocation.LoadFromDatabase(GeographicLocations.MyItems, ConnectionString, Holidays.MyItems, TimeLimits.MyItems, ignoreMissingTables), GeographicLocations), new LoadingEntry("Subaffordances", () => SubAffordance.LoadFromDatabase(SubAffordances.MyItems, ConnectionString, Desires.MyItems, ignoreMissingTables, Locations.It, Variables.It), SubAffordances), new LoadingEntry("Affordances", () => Affordance.LoadFromDatabase(Affordances.MyItems, ConnectionString, Timeprofiles.MyItems, DeviceCategories.MyItems, RealDevices.MyItems, Desires.MyItems, SubAffordances.MyItems, LoadTypes.MyItems, TimeLimits.MyItems, DeviceActions.MyItems, DeviceActionGroups.MyItems, Locations.It, ignoreMissingTables, Variables.It), Affordances), new LoadingEntry("Affordance Tagging Sets", () => AffordanceTaggingSet.LoadFromDatabase(AffordanceTaggingSets.MyItems, ConnectionString, ignoreMissingTables, Affordances.MyItems, LoadTypes.It), AffordanceTaggingSets), new LoadingEntry("Trait Tags", () => TraitTag.LoadFromDatabase(TraitTags.MyItems, ConnectionString, ignoreMissingTables), TraitTags), new LoadingEntry("Household Traits", () => HouseholdTrait.LoadFromDatabase(HouseholdTraits.MyItems, ConnectionString, Locations.MyItems, Affordances.MyItems, RealDevices.MyItems, DeviceCategories.MyItems, Timeprofiles.MyItems, LoadTypes.MyItems, TimeLimits.MyItems, Desires.MyItems, DeviceActions.It, DeviceActionGroups.It, TraitTags.It, ignoreMissingTables, Variables.It), HouseholdTraits), new LoadingEntry("Device Selections", () => DeviceSelection.LoadFromDatabase(DeviceSelections.MyItems, ConnectionString, DeviceCategories.MyItems, RealDevices.MyItems, DeviceActions.It, DeviceActionGroups.It, ignoreMissingTables), DeviceSelections), new LoadingEntry("Household Tags", () => HouseholdTag.LoadFromDatabase(HouseholdTags.It, ConnectionString, ignoreMissingTables), HouseholdTags), new LoadingEntry("Modular Households", () => ModularHousehold.LoadFromDatabase(ModularHouseholds.MyItems, ConnectionString, HouseholdTraits.MyItems, DeviceSelections.MyItems, ignoreMissingTables, Persons.MyItems, Vacations.It, HouseholdTags.It, TraitTags.It), ModularHouseholds), new LoadingEntry("Household Templates", () => HouseholdTemplate.LoadFromDatabase(HouseholdTemplates.MyItems, ConnectionString, HouseholdTraits.MyItems, ignoreMissingTables, Persons.MyItems, TraitTags.It, Vacations.It, HouseholdTags.It, DateBasedProfiles.It), HouseholdTemplates), new LoadingEntry("Template Persons", () => TemplatePerson.LoadFromDatabase(TemplatePersons.It, ConnectionString, HouseholdTraits.It, ignoreMissingTables, ModularHouseholds.It, Persons.It), TemplatePersons), new LoadingEntry("Household Plans", () => HouseholdPlan.LoadFromDatabase(HouseholdPlans.MyItems, ConnectionString, ignoreMissingTables, Persons.MyItems, AffordanceTaggingSets.MyItems, ModularHouseholds.MyItems), HouseholdPlans), new LoadingEntry("House Types", () => HouseType.LoadFromDatabase(HouseTypes.MyItems, ConnectionString, RealDevices.MyItems, DeviceCategories.MyItems, Timeprofiles.MyItems, TimeLimits.MyItems, LoadTypes.MyItems, TransformationDevices.MyItems, EnergyStorages.MyItems, Generators.MyItems, ignoreMissingTables, Locations.MyItems, DeviceActions.It, DeviceActionGroups.It, Variables.It), HouseTypes), new LoadingEntry("Transportation Device Categories", () => TransportationDeviceCategory.LoadFromDatabase(TransportationDeviceCategories.It, ConnectionString, ignoreMissingTables), TransportationDeviceCategories), new LoadingEntry("Sites", () => Site.LoadFromDatabase(Sites.It, ConnectionString, ignoreMissingTables, Locations.It), Sites), new LoadingEntry("Transportation Devices", () => TransportationDevice.LoadFromDatabase(TransportationDevices.It, ConnectionString, ignoreMissingTables, TransportationDeviceCategories.It, LoadTypes.It), TransportationDevices), new LoadingEntry("Transportation Device Sets", () => TransportationDeviceSet.LoadFromDatabase(TransportationDeviceSets.It, ConnectionString, ignoreMissingTables, TransportationDevices.It), TransportationDeviceSets), new LoadingEntry("Travel Routes", () => TravelRoute.LoadFromDatabase(TravelRoutes.It, ConnectionString, ignoreMissingTables, TransportationDeviceCategories.It, Sites.It), TravelRoutes), new LoadingEntry("Travel Route Sets", () => TravelRouteSet.LoadFromDatabase(TravelRouteSets.It, ConnectionString, ignoreMissingTables, TravelRoutes.It), TravelRouteSets), new LoadingEntry("Charging Station Sets", () => ChargingStationSet.LoadFromDatabase(ChargingStationSets.It, ConnectionString, ignoreMissingTables, LoadTypes.It, TransportationDeviceCategories.It, Sites.It), ChargingStationSets), new LoadingEntry("Houses", () => House.LoadFromDatabase(Houses.MyItems, ConnectionString, TemperatureProfiles.MyItems, GeographicLocations.MyItems, HouseTypes.MyItems, ModularHouseholds.MyItems, ChargingStationSets.MyItems, TransportationDeviceSets.MyItems, TravelRouteSets.MyItems, ignoreMissingTables), Houses), new LoadingEntry("Settlements", () => Settlement.LoadFromDatabase(Settlements.MyItems, ConnectionString, TemperatureProfiles.MyItems, GeographicLocations.MyItems, ModularHouseholds.MyItems, Houses.MyItems, ignoreMissingTables), Settlements), new LoadingEntry("Settlement Templates", () => SettlementTemplate.LoadFromDatabase(SettlementTemplates.It, ConnectionString, HouseholdTemplates.It, HouseTypes.It, ignoreMissingTables, TemperatureProfiles.It, GeographicLocations.It, HouseholdTags.It, HouseholdTraits.It), SettlementTemplates), new LoadingEntry("Settings", () => MyGeneralConfig = GeneralConfig.LoadFromDatabase(ConnectionString, ignoreMissingTables), null), new LoadingEntry("Calculation Outcomes", () => CalculationOutcome.LoadFromDatabase(CalculationOutcomes.MyItems, ConnectionString, ignoreMissingTables), CalculationOutcomes) }; return(actions); }