public DialogPreOperationViewModel(IUnitOfWork UnitOfWork) { CurrentPanelViewModel = new OperationTypePanelViewModel(this); SelectedOpTypeID = 0; Commentary = ""; OpTypes = new ObservableCollection <OperationType>(UnitOfWork.OperationType.GetAll.ToList()); this.confirmCommand = new RelayCommand(OnReturnClicked); this.returnCommand = new RelayCommand(OnConfirmClicked); OpenPanelCommand = new DelegateCommand(() => { CurrentPanelViewModel.ClearPanel(); CurrentPanelViewModel.PanelOpened = true; }); SaveCommand = new DelegateCommand(() => { OperationType newType = CurrentPanelViewModel.GetPanelType(); MessageBus.Default.Call("AddOperationTypeForDialogBox", this, newType); OpTypes = new ObservableCollection <OperationType>(UnitOfWork.OperationType.GetAll.ToList()); SelectedOpTypeID = OpTypes.Count - 1; CurrentPanelViewModel.ClearPanel(); CurrentPanelViewModel.PanelOpened = false; }); RevertCommand = new DelegateCommand(() => { CurrentPanelViewModel.ClearPanel(); CurrentPanelViewModel.PanelOpened = false; }); }
public ViewModelAddOperation(NavigationController controller) : base(controller) { Doctors = new ObservableCollection <DoctorDataSource>(); DoctorsSelected = new ObservableCollection <DoctorDataSource>(); ShowDoctors = true; ShowMeds = true; ShowMedsSelected = true; ShowDoctorsSelected = true; TextBoxMinute = Brushes.Gray; TextBoxHour = Brushes.Gray; MinuteHour = DateTime.Now; TimeCheckHour = true; TimeCheckMinute = true; ButtonSaveText = "Назначить операцию"; MessageBus.Default.Subscribe("AddOperationTypeForDialogBox", AddOperationTypeForDialogBox); MessageBus.Default.Subscribe("SetOperationResult", SetOperResult); MessageBus.Default.Subscribe("SetCurrentPatientForOperation", SetCurrentPatientID); MessageBus.Default.Subscribe("SetRightDiagnosisListForOperation", SetRightDiagnosisList); MessageBus.Default.Subscribe("SetLeftDiagnosisListForOperation", SetLeftDiagnosisList); MessageBus.Default.Subscribe("UpdateSelectedDoctors", UpdateSelectedDoctors); MessageBus.Default.Subscribe("SetRightOperationListForOperation", SetRightOpList); MessageBus.Default.Subscribe("SetLeftOperationListForOperation", SetLeftOpList); Controller = controller; HasNavigation = false; Operation = new Operation(); // Operation.Date = DateTime.Now; LeftDiagnosisList = new CollectionViewSource(); RightDiagnosisList = new CollectionViewSource(); LeftOperationList = new CollectionViewSource(); RightOperationList = new CollectionViewSource(); var timeItem = Data.OperationDateTime.GetAll.Where(e => e.Operation_id == 0); foreach (var OpTImeWithNULL in timeItem) { if (Data.OperationDateTime.GetAll.Where(e => e.Operation_id != null && e.Operation_id != 0 && e.Datetime.Year == OpTImeWithNULL.Datetime.Year && e.Datetime.Month == OpTImeWithNULL.Datetime.Month && e.Datetime.Day == OpTImeWithNULL.Datetime.Day).FirstOrDefault() == null) { foreach (var opDate in Data.OperationDateTime.GetAll.Where(e => e.Datetime.Year == OpTImeWithNULL.Datetime.Year && e.Datetime.Month == OpTImeWithNULL.Datetime.Month && e.Datetime.Day == OpTImeWithNULL.Datetime.Day)) { Data.OperationDateTime.Remove(Data.OperationDateTime.Get(opDate.Id)); } } else { var opDate1 = Data.OperationDateTime.Get(OpTImeWithNULL.Id); opDate1.Doctor_id = null; opDate1.Note = "Время свободно"; opDate1.Operation_id = null; Data.Complete(); } } Data.Complete(); GetLeftFromLastObs = new DelegateCommand( () => { var ExamsOfCurrPatient = Data.Examination.GetAll.ToList().Where(s => s.PatientId == CurrentPatient.Id).ToList(); if (ExamsOfCurrPatient.Count > 0) { DateTime MaxExam = ExamsOfCurrPatient.Max(s => s.Date); var ExamsOfCurrPatientLatest = ExamsOfCurrPatient.Where(s => s.Date == MaxExam).ToList(); List <DiagnosisObs> DiagOfCurrPatienLt = Data.DiagnosisObs.GetAll.ToList().Where(s => s.id_leg_examination == ExamsOfCurrPatientLatest[0].Id && s.isLeft == true).ToList(); // List<DiagnosisObs> DiagOfCurrPatientRt = DiagObsRep.GetAll.ToList().Where(s => s.id_обследование_ноги == ExamsOfCurrPatientLatest[0].Id && s.isLeft == false).ToList(); // MessageBus.Default.Call("SetDiagnosisListRight", null, DiagOfCurrPatientRt); MessageBus.Default.Call("SetDiagnosisListLeft", null, DiagOfCurrPatienLt); // ExaminationLeg leftLegExam = LegExamRep.Get(ExamsOfCurrPatientLatest[0].idLeftLegExamination.Value); // ExaminationLeg rightLegExam = LegExamRep.Get(ExamsOfCurrPatientLatest[0].idRightLegExamination.Value); // Letters bufLetter = new Letters(); Controller.NavigateTo <ViewModelAddOperation>(); } else { MessageBox.Show("Нет диагноза слева последнего обследования"); } } ); GetRightFromLastObs = new DelegateCommand( () => { var ExamsOfCurrPatient = Data.Examination.GetAll.ToList().Where(s => s.PatientId == CurrentPatient.Id).ToList(); if (ExamsOfCurrPatient.Count > 0) { DateTime MaxExam = ExamsOfCurrPatient.Max(s => s.Date); var ExamsOfCurrPatientLatest = ExamsOfCurrPatient.Where(s => s.Date == MaxExam).ToList(); // List<DiagnosisObs> DiagOfCurrPatienLt = DiagObsRep.GetAll.ToList().Where(s => s.id_обследование_ноги == ExamsOfCurrPatientLatest[0].Id && s.isLeft == true).ToList(); List <DiagnosisObs> DiagOfCurrPatientRt = Data.DiagnosisObs.GetAll.ToList().Where(s => s.id_leg_examination == ExamsOfCurrPatientLatest[0].Id && s.isLeft == false).ToList(); MessageBus.Default.Call("SetDiagnosisListRight", null, DiagOfCurrPatientRt); // MessageBus.Default.Call("SetDiagnosisListLeft", null, DiagOfCurrPatienLt); // ExaminationLeg leftLegExam = LegExamRep.Get(ExamsOfCurrPatientLatest[0].idLeftLegExamination.Value); // ExaminationLeg rightLegExam = LegExamRep.Get(ExamsOfCurrPatientLatest[0].idRightLegExamination.Value); // Letters bufLetter = new Letters(); Controller.NavigateTo <ViewModelAddOperation>(); } else { MessageBox.Show("Нет диагноза справа последнего обследования"); } } ); ToCurrentPatientCommand = new DelegateCommand( () => { if (Operation.Datetime_id != null && Operation.Datetime_id != 0) { var OpDate = Data.OperationDateTime.Get(Operation.Datetime_id.Value); OpDate.Doctor_id = null; OpDate.Note = "Время свободно"; OpDate.Operation_id = null; Data.Complete(); var timeItem1 = Data.OperationDateTime.Where(e => e.Operation_id != null && e.Datetime.Year == OpDate.Datetime.Year && e.Datetime.Month == OpDate.Datetime.Month && e.Datetime.Day == OpDate.Datetime.Day).FirstOrDefault(); if (timeItem1 == null) { foreach (var opDate in Data.OperationDateTime.Where(e => e.Datetime.Year == OpDate.Datetime.Year && e.Datetime.Month == OpDate.Datetime.Month && e.Datetime.Day == OpDate.Datetime.Day)) { Data.OperationDateTime.Remove(Data.OperationDateTime.Get(opDate.Id)); } } Data.Complete(); CurrentPanelSelectTime.SelectedOpTimeView = null; CurrentPanelSelectTime.SelectedOpTimeViewCopy = null; CurrentPanelSelectTime.BuffSelectedOpTimeView = null; } Controller.NavigateTo <ViewModelCurrentPatient>(); } ); ToOperationOverviewCommand = new DelegateCommand( () => { bool test = false; if (SelectedLegId == 0) { // ObservableCollection<OperationTypesDataSource> aray = (ObservableCollection<OperationTypesDataSource>)LeftOperationList.Source; if (LeftOperationList.Source == null || ((ObservableCollection <OperationTypesDataSource>)LeftOperationList.Source).Count == 0 || ((ObservableCollection <DiagnosisDataSource>)LeftDiagnosisList.Source).Count == 0 || LeftDiagnosisList.Source == null || RightDiagnosisList.Source == null || ((ObservableCollection <DiagnosisDataSource>)RightDiagnosisList.Source).Count == 0 || ((ObservableCollection <DiagnosisDataSource>)LeftDiagnosisList.Source).Count == 0 || DoctorsSelected.Count == 0 || TimeCheckHour == false || TimeCheckMinute == false || Operation.Datetime_id == null) { MessageBox.Show("Не всё заполнено!"); if (Operation.Datetime_id == null) { Button_time_B = Brushes.Red; } else { Button_time_B = Brushes.Gray; } } else { test = true; } } else if (SelectedLegId == 1) { if (RightOperationList.Source == null || ((ObservableCollection <OperationTypesDataSource>)RightOperationList.Source).Count == 0 || RightDiagnosisList.Source == null || ((ObservableCollection <DiagnosisDataSource>)RightDiagnosisList.Source).Count == 0 || ((ObservableCollection <DiagnosisDataSource>)LeftDiagnosisList.Source).Count == 0 || DoctorsSelected.Count == 0 || TimeCheckHour == false || TimeCheckMinute == false || Operation.Datetime_id == null) { MessageBox.Show("Не всё заполнено!"); } else { test = true; } } else if (RightOperationList.Source == null || ((ObservableCollection <OperationTypesDataSource>)RightOperationList.Source).Count == 0 || LeftOperationList.Source == null || ((ObservableCollection <OperationTypesDataSource>)LeftOperationList.Source).Count == 0 || LeftDiagnosisList.Source == null || RightDiagnosisList.Source == null || ((ObservableCollection <DiagnosisDataSource>)LeftDiagnosisList.Source).Count == 0 || ((ObservableCollection <DiagnosisDataSource>)RightDiagnosisList.Source).Count == 0 || DoctorsSelected.Count == 0 || TimeCheckHour == false || TimeCheckMinute == false || Operation.Datetime_id == null) { MessageBox.Show("Не всё заполнено!"); } else { test = true; } if (test) { // Operation.Date = new DateTime(Operation.Date.Year,// Operation.Date.Month,// Operation.Date.Day, MinuteHour.Hour, MinuteHour.Minute, 0); // Operation.Time = MinuteHour.Hour + ":" + MinuteHour.Minute + ":" + 0; var opDate = Data.OperationDateTime.Get(Operation.Datetime_id.Value); Operation.PatientId = CurrentPatient.Id; Operation.AnestheticId = AnestethicTypesID[AnesteticSelected]; Operation.OnWhatLegOp = SelectedLegId.ToString(); Data.Operation.Add(Operation); Data.Complete(); opDate.Operation_id = Operation.Id; // var opDataToRemove = new OperationDateTime(); // var test = true; // var OperationRep = new OperationRepository(context); var SelectedOpDate = Data.OperationDateTime.Get(Operation.Datetime_id.Value); opDate.Doctor_id = SelectedOpDate.Doctor_id; opDate.Note = SelectedOpDate.Note; foreach (var Doctor in DoctorsSelected) { if (Doctor.isDoctor) { Brigade buf = new Brigade(); buf.id_doctor = Doctor.id; buf.id_operation = Operation.Id; Data.Brigade.Add(buf); Data.Complete(); } else { BrigadeMedPersonal buf = new BrigadeMedPersonal(); buf.id_med_staff = Doctor.id; buf.id_operation = Operation.Id; Data.BrigadeMedPersonal.Add(buf); Data.Complete(); } } if (LeftOperationList.Source != null) { foreach (var OpL in (ObservableCollection <OperationTypesDataSource>)LeftOperationList.Source) { OperationTypeOperations buf = new OperationTypeOperations(); buf.id_operation_type = OpL.Data.Id; buf.id_operation = Operation.Id; buf.isLeft = true; Data.OperationTypeOperations.Add(buf); Data.Complete(); } } if (RightOperationList.Source != null) { foreach (var OpR in (ObservableCollection <OperationTypesDataSource>)RightOperationList.Source) { OperationTypeOperations buf = new OperationTypeOperations(); buf.id_operation_type = OpR.Data.Id; buf.id_operation = Operation.Id; buf.isLeft = false; Data.OperationTypeOperations.Add(buf); Data.Complete(); } } if (LeftDiagnosisList.Source != null) { foreach (var diagnozL in (ObservableCollection <DiagnosisDataSource>)LeftDiagnosisList.Source) { Diagnosis buf = new Diagnosis(); buf.id_diagnosis = diagnozL.Data.Id; buf.id_operation = Operation.Id; buf.isLeft = true; Data.Diagnosis.Add(buf); Data.Complete(); } } if (RightDiagnosisList.Source != null) { foreach (var diagnozR in (ObservableCollection <DiagnosisDataSource>)RightDiagnosisList.Source) { Diagnosis buf = new Diagnosis(); buf.id_diagnosis = diagnozR.Data.Id; buf.id_operation = Operation.Id; buf.isLeft = false; Data.Diagnosis.Add(buf); Data.Complete(); } } // Data.Complete(); if (isSetOperResult == true) { OperationResult.IdNextOperation = Operation.Id; Data.Complete(); isSetOperResult = false; } CurrentPanelSelectTime.SelectedOpTimeView = null; CurrentPanelSelectTime.SelectedOpTimeViewCopy = null; CurrentPanelSelectTime.BuffSelectedOpTimeView = null; MessageBus.Default.Call("SetCurrentACCOp", this, null); MessageBus.Default.Call("GetOperationForOverwiev", this, Operation.Id); Controller.NavigateTo <ViewModelOperationOverview>(); // Data.Complete(); Operation = new Operation(); OperationResult = new OperationResult(); } } ); IsLeftLegInOperation = Visibility.Visible; IsRightLegInOperation = Visibility.Visible; ToLeftOprCommand = new DelegateCommand( () => { MessageBus.Default.Call("SetleftOrRightOpForOp", this, "Left"); Controller.NavigateTo <ViewModelOperationListForOperation>(); } ); ToRightOprCommand = new DelegateCommand( () => { MessageBus.Default.Call("SetleftOrRightOpForOp", this, "Right"); Controller.NavigateTo <ViewModelOperationListForOperation>(); } ); ToLeftDiagCommand = new DelegateCommand( () => { MessageBus.Default.Call("SetleftOrRight", this, "Left"); Controller.NavigateTo <ViewModelDiagnosisListForOperation>(); } ); ToRightDiagCommand = new DelegateCommand( () => { MessageBus.Default.Call("SetleftOrRight", this, "Right"); Controller.NavigateTo <ViewModelDiagnosisListForOperation>(); } ); //for right panel CurrentPanelViewModel = new OperationTypePanelViewModel(this); OpenPanelCommand = new DelegateCommand(() => { CurrentPanelViewModel.ClearPanel(); CurrentPanelViewModel.PanelOpened = true; }); #region Select time comands CurrentPanelSelectTime = new SelectTimePanelViewModel(this); OpenPanelSelectTime = new DelegateCommand(() => { CurrentPanelSelectTime.ClearPanel(); CurrentPanelSelectTime.PanelOpened = true; }); RevertSelectTimeCommand = new DelegateCommand(() => { CurrentPanelSelectTime.PanelOpened = false; Handled = false; //if (Operation.Datetime_id == null || Operation.Datetime_id == 0) //{ CurrentPanelSelectTime.SelectedOpTimeView = null; CurrentPanelSelectTime.SelectedOpTimeViewCopy = null; CurrentPanelSelectTime.BuffSelectedOpTimeView = null; //} }); TextForDate = "Время не выбрано"; SaveSelectTimeCommand = new DelegateCommand(() => { if (CurrentPanelSelectTime.SelectedOpTimeView != null) { Button_time_B = Brushes.Gray; Operation.Datetime_id = CurrentPanelSelectTime.SelectedOpTimeView.Id; TextForDate = CurrentPanelSelectTime.SelectedOpTimeView.Datetime.ToString("HH:mm\ndd MMMM yyyy\n", CultureInfo.GetCultureInfo("ru-ru")); string buff = FirstCharToUpper(CurrentPanelSelectTime.SelectedOpTimeView.Datetime.ToString("dddd", CultureInfo.GetCultureInfo("ru-ru"))); //buff = buff.First().ToString().ToUpper() + buff.Substring(1); TextForDate += buff; } else { Operation.Datetime_id = null; TextForDate = "Время не выбрано"; } CurrentPanelSelectTime.PanelOpened = false; }); #endregion #region Anestetic New type comands CurrentPanelAnestViewModel = new AnetheticTypePanelViewModel(this); OpenPanelAnesteticCommand = new DelegateCommand(() => { CurrentPanelAnestViewModel.ClearPanel(); CurrentPanelAnestViewModel.PanelOpened = true; }); SaveAnesteticCommand = new DelegateCommand(() => { var newType = CurrentPanelAnestViewModel.GetPanelType(); if (!string.IsNullOrWhiteSpace(newType.Str)) { CurrentPanelAnestViewModel.PanelOpened = false; Handled = false; Data.Anestethic.Add((newType)); Data.Complete(); AnestethicTypes = new ObservableCollection <string>(); foreach (var OprType in Data.Anestethic.GetAll) { AnestethicTypes.Add(OprType.Str); AnestethicTypesID.Add(OprType.Id); } AnesteticSelected = AnestethicTypes.Count - 1; } else { MessageBox.Show("Не все поля заполнены"); } }); RevertAnesteticCommand = new DelegateCommand(() => { CurrentPanelAnestViewModel.PanelOpened = false; Handled = false; }); #endregion SaveCommand = new DelegateCommand(() => { if (SelectedLegId == 0) { IsLeftLegInOperation = Visibility.Visible; IsRightLegInOperation = Visibility.Collapsed; } else if (SelectedLegId == 1) { IsLeftLegInOperation = Visibility.Collapsed; IsRightLegInOperation = Visibility.Visible; } else { IsLeftLegInOperation = Visibility.Visible; IsRightLegInOperation = Visibility.Visible; } CurrentPanelViewModel.ClearPanel(); CurrentPanelViewModel.PanelOpened = false; }); RevertCommand = new DelegateCommand(() => { Controller.NavigateTo <ViewModelCurrentPatient>(); }); }
public ViewModelOperationListForOperation(NavigationController controller) : base(controller) { TextOFNewType = "Новый тип операции"; VisOfNothingFaund = Visibility.Collapsed; CurrentPanelViewModel = new OperationTypePanelViewModel(this); OpenCommand = new DelegateCommand(() => { CurrentPanelViewModel.ClearPanel(); CurrentPanelViewModel.PanelOpened = true; }); // SetClear MessageBus.Default.Subscribe("SetClearOperationListLeftRightOperation", SetClear); //MessageBus.Default.Subscribe("SetDiagnosisListRight", SetDiagnosisListRight); //MessageBus.Default.Subscribe("SetDiagnosisListLeft", SetDiagnosisListLeft); SaveCommand = new DelegateCommand(() => { FilterText = ""; var newType = CurrentPanelViewModel.GetPanelType(); if (!string.IsNullOrWhiteSpace(newType.ToString())) { CurrentPanelViewModel.PanelOpened = false; Handled = false; Data.OperationType.Add((newType)); Data.Complete(); var DataSourceListbuf = DataSourceList; var LeftDiagbuf = LeftDiag; var RightDiagbuf = RightDiag; DataSourceList = new ObservableCollection <OperationTypesDataSource>(); LeftDiag = new List <OperationTypesDataSource>(); RightDiag = new List <OperationTypesDataSource>(); FullCopy = new List <OperationTypesDataSource>(); foreach (var DiagnosisType in Data.OperationType.GetAll) { FullCopy.Add(new OperationTypesDataSource(DiagnosisType)); DataSourceList.Add(new OperationTypesDataSource(DiagnosisType)); LeftDiag.Add(new OperationTypesDataSource(DiagnosisType)); RightDiag.Add(new OperationTypesDataSource(DiagnosisType)); } foreach (var DiagnosisType in DataSourceListbuf) { if (DiagnosisType.IsChecked.Value) { DataSourceList.Where(s => s.Data.Id == DiagnosisType.Data.Id).ToList()[0].IsChecked = true; FullCopy.Where(s => s.Data.Id == DiagnosisType.Data.Id).ToList()[0].IsChecked = true; } } foreach (var DiagnosisType in LeftDiagbuf) { if (DiagnosisType.IsChecked.Value) { LeftDiag.Where(s => s.Data.Id == DiagnosisType.Data.Id).ToList()[0].IsChecked = true; } } foreach (var DiagnosisType in RightDiagbuf) { if (DiagnosisType.IsChecked.Value) { RightDiag.Where(s => s.Data.Id == DiagnosisType.Data.Id).ToList()[0].IsChecked = true; } } Controller.NavigateTo <ViewModelOperationListForOperation>(); } else { MessageBox.Show("Не все поля заполнены"); } }); RevertCommand = new DelegateCommand(() => { CurrentPanelViewModel.PanelOpened = false; Handled = false; }); TextName = "Вернуться к обследованию"; HeaderText = "Типы операции"; AddButtonText = "Другой тип операции"; MessageBus.Default.Subscribe("SetleftOrRightOpForOp", SetDiagnosisList); DataSourceList = new ObservableCollection <OperationTypesDataSource>(); LeftDiag = new List <OperationTypesDataSource>(); RightDiag = new List <OperationTypesDataSource>(); // DataSourceList = new ObservableCollection<OperationForAmbullatorCardDataSource>(); FullCopy = new List <OperationTypesDataSource>(); foreach (var DiagnosisType in Data.OperationType.GetAll) { FullCopy.Add(new OperationTypesDataSource(DiagnosisType)); DataSourceList.Add(new OperationTypesDataSource(DiagnosisType)); LeftDiag.Add(new OperationTypesDataSource(DiagnosisType)); RightDiag.Add(new OperationTypesDataSource(DiagnosisType)); } ToPhysicalCommand = new DelegateCommand( () => { FilterText = ""; List <OperationTypesDataSource> DataSourceListBuffer = new List <OperationTypesDataSource>(); foreach (var Data in FullCopy) { if (Data.IsChecked == true) { DataSourceListBuffer.Add(Data); } } if (ld == "Left") { MessageBus.Default.Call("SetLeftOperationListForOperation", this, DataSourceListBuffer); LeftDiag = new List <OperationTypesDataSource>(DataSourceList); } else { MessageBus.Default.Call("SetRightOperationListForOperation", this, DataSourceListBuffer); RightDiag = new List <OperationTypesDataSource>(DataSourceList); } Controller.NavigateTo <ViewModelAddOperation>(); } ); SaveChangesCommand = new DelegateCommand( () => { // FilterText = ""; List <OperationTypesDataSource> DataSourceListBuffer = new List <OperationTypesDataSource>(); foreach (var Data in DataSourceList) { if (Data.IsChecked == true) { DataSourceListBuffer.Add(Data); } } if (ld == "Left") { MessageBus.Default.Call("SetLeftDiagnosisListForOperation", this, DataSourceListBuffer); LeftDiag = new List <OperationTypesDataSource>(DataSourceList); } else { MessageBus.Default.Call("SetRightDiagnosisListForOperation", this, DataSourceListBuffer); RightDiag = new List <OperationTypesDataSource>(DataSourceList); } Controller.NavigateTo <ViewModelAddOperation>(); } ); }