Esempio n. 1
0
 private void ExitAndSave()
 {
     if (PatientCurrent != null || RecordCurrent != null)
     {
         Filemanagement.SaveToDatabase(PatientCurrent);
         this.RecordCurrent.BirthInformationList.AddRange(BirthInformationListProperty.Where(x => !RecordCurrent.BirthInformationList.Contains(x)));
         this.RecordCurrent.ContractionIVDripList.AddRange(ContractionListProperty.Where(x => !RecordCurrent.ContractionIVDripList.Contains(x)));
         this.RecordCurrent.MicturitionList.AddRange(MicturitionListProperty.Where(x => !RecordCurrent.MicturitionList.Contains(x)));
         this.RecordCurrent.VaginalExplorationList.AddRange(VaginalExplorationListProperty.Where(x => !RecordCurrent.VaginalExplorationList.Contains(x)));
         this.RecordCurrent.FetusObservationList.AddRange(FetusObservationListProperty.Where(x => !RecordCurrent.FetusObservationList.Contains(x)));
         this.RecordCurrent.CurrentBill.BillItemList.AddRange(MedicalServicesList.Where(x => !RecordCurrent.CurrentBill.BillItemList.Contains(x)));
         Filemanagement.SaveRecord(RecordCurrent);
     }
 }
Esempio n. 2
0
        public RecordViewModel()
        {
            SetValue(ChildBirthDateProperty, DateTime.Today);
            SetValue(ChildBirthTimeProperty, DateTime.Now);

            Messenger.Default.Register <NotificationMessage>(this, "LogOut", parameter =>
            {
                RecordCurrent.Note    = RecordCurrent.NewNote;
                RecordCurrent.NewNote = null;
            });
            Messenger.Default.Register <Record>(this, "NewRecordToRecordView", (ActiveRecord) => { RecordCurrent = ActiveRecord; Note = ActiveRecord.Note; });
            Messenger.Default.Register <Patient>(this, "PatientToRecordView", (ActivePatient) => { PatientCurrent = ActivePatient; });
            Messenger.Default.Register <Employee>(this, "EmployeetoRecordView", (ActiveEmployee) => { EmployeeCurrent = ActiveEmployee; });
            Messenger.Default.Register <String>(this, "SaveToDatabase", (thestring) => ExitAndSave());

            _availableMedicalServices.AddRange(Ward.MedicalServicesList);
            #region Command Definitions
            //Command to add a medical service to the list of medical services
            this.AddMedicalService = new RelayCommand(parameter =>
            {
                MedicalServicesList.Add(SelectedAvailableMedicalServiceInfo);
            });
            //Command to create a new child in the system
            this.CreateChildCommand = new RelayCommand(parameter =>
            {
                Midwife tempMidwife = EmployeeCurrent as Midwife;
                ChildBirthDate      = ChildBirthDate.Add(ChildBirthTime.TimeOfDay);
                tempMidwife.CreatePatient(PatientCurrent, ChildGender, ChildBirthDate);
                Patient tempChild      = PatientCurrent.Children.Last();
                RecordCurrent.ChildCPR = tempChild.CPR;
                new P3_Midwife.Views.NewChildWindow(RecordCurrent);
                Messenger.Default.Send(RecordCurrent, "ChildRecordToNewChildView");
                Messenger.Default.Send(PatientCurrent, "PatientToNewChildView");
                Messenger.Default.Send(EmployeeCurrent, "EmployeetoNewChildView");
                Messenger.Default.Send(tempChild, "ChildToNewChildView");
                Messenger.Default.Send <NotificationMessage>(new NotificationMessage("ToNewChild"));
            });
            //Command to remove a medical service from the list of medical services
            this.RemoveMedicalService = new RelayCommand(parameter =>
            {
                MedicalServicesList.Remove(SelectedMedicalServiceInfo);
            });
            //Command to return to the record view without creating a child
            this.Cancel = new RelayCommand(parameter =>
            {
                Messenger.Default.Send <NotificationMessage>(new NotificationMessage("ToRecord"));
            });
            //Command to log the user out of the system
            this.LogOutCommand = new RelayCommand(parameter =>
            {
                Filemanagement.SaveToDatabase(PatientCurrent);
                this.RecordCurrent.BirthInformationList.AddRange(BirthInformationListProperty.Where(x => !RecordCurrent.BirthInformationList.Contains(x)));
                this.RecordCurrent.ContractionIVDripList.AddRange(ContractionListProperty.Where(x => !RecordCurrent.ContractionIVDripList.Contains(x)));
                this.RecordCurrent.MicturitionList.AddRange(MicturitionListProperty.Where(x => !RecordCurrent.MicturitionList.Contains(x)));
                this.RecordCurrent.VaginalExplorationList.AddRange(VaginalExplorationListProperty.Where(x => !RecordCurrent.VaginalExplorationList.Contains(x)));
                this.RecordCurrent.FetusObservationList.AddRange(FetusObservationListProperty.Where(x => !RecordCurrent.FetusObservationList.Contains(x)));
                this.RecordCurrent.CurrentBill.BillItemList.AddRange(MedicalServicesList.Where(x => !RecordCurrent.CurrentBill.BillItemList.Contains(x)));
                Filemanagement.SaveRecord(RecordCurrent);
                System.Diagnostics.Process.Start(Application.ResourceAssembly.Location);
                Application.Current.Shutdown();
            });
            //Command to close to program
            this.ExitCommand = new RelayCommand(parameter =>
            {
                ExitAndSave();
            });
            //Command to return to the previous view
            this.BackCommand = new RelayCommand(Parameter =>
            {
                Filemanagement.SaveToDatabase(PatientCurrent);
                this.RecordCurrent.BirthInformationList.AddRange(BirthInformationListProperty.Where(x => !RecordCurrent.BirthInformationList.Contains(x)));
                BirthInformationListProperty.Clear();
                this.RecordCurrent.ContractionIVDripList.AddRange(ContractionListProperty.Where(x => !RecordCurrent.ContractionIVDripList.Contains(x)));
                ContractionListProperty.Clear();
                this.RecordCurrent.MicturitionList.AddRange(MicturitionListProperty.Where(x => !RecordCurrent.MicturitionList.Contains(x)));
                MicturitionListProperty.Clear();
                this.RecordCurrent.VaginalExplorationList.AddRange(VaginalExplorationListProperty.Where(x => !RecordCurrent.VaginalExplorationList.Contains(x)));
                VaginalExplorationListProperty.Clear();
                this.RecordCurrent.FetusObservationList.AddRange(FetusObservationListProperty.Where(x => !RecordCurrent.FetusObservationList.Contains(x)));
                FetusObservationListProperty.Clear();
                this.RecordCurrent.CurrentBill.BillItemList.AddRange(MedicalServicesList.Where(x => !RecordCurrent.CurrentBill.BillItemList.Contains(x)));
                MedicalServicesList.Clear();
                Filemanagement.SaveRecord(RecordCurrent);
                Messenger.Default.Send(EmployeeCurrent, "Employee");
                Messenger.Default.Send(PatientCurrent, "Patient");
                Messenger.Default.Send(new NotificationMessage("ToPatient"));
            });
            //Command to open a view where a new child can be created in the system
            this.NewChildDialogCommand = new RelayCommand(parameter =>
            {
                this.RecordCurrent.BirthInformationList.AddRange(BirthInformationListProperty.Where(x => !RecordCurrent.BirthInformationList.Contains(x)));
                this.RecordCurrent.ContractionIVDripList.AddRange(ContractionListProperty.Where(x => !RecordCurrent.ContractionIVDripList.Contains(x)));
                this.RecordCurrent.MicturitionList.AddRange(MicturitionListProperty.Where(x => !RecordCurrent.MicturitionList.Contains(x)));
                this.RecordCurrent.VaginalExplorationList.AddRange(VaginalExplorationListProperty.Where(x => !RecordCurrent.VaginalExplorationList.Contains(x)));
                this.RecordCurrent.FetusObservationList.AddRange(FetusObservationListProperty.Where(x => !RecordCurrent.FetusObservationList.Contains(x)));
                this.RecordCurrent.CurrentBill.BillItemList.AddRange(MedicalServicesList.Where(x => !RecordCurrent.CurrentBill.BillItemList.Contains(x)));
                Messenger.Default.Send(new NotificationMessage("NewChildDialog"));
            });
            //Command to save and archive a record, so that it cannot be edited anymore. The patient is also transfered away from the room
            this.SaveAndCompleteCommand = new RelayCommand(parameter =>
            {
                Messenger.Default.Send(new NotificationMessage("RecordSave"));
                this.RecordCurrent.Note += "\n" + RecordCurrent.NewNote;
                this.RecordCurrent.BirthInformationList.AddRange(BirthInformationListProperty.Where(x => !RecordCurrent.BirthInformationList.Contains(x)));
                this.RecordCurrent.BirthInformationList.AddRange(BirthInformationListProperty);
                BirthInformationListProperty.Clear();
                this.RecordCurrent.ContractionIVDripList.AddRange(ContractionListProperty.Where(x => !RecordCurrent.ContractionIVDripList.Contains(x)));
                ContractionListProperty.Clear();
                this.RecordCurrent.MicturitionList.AddRange(MicturitionListProperty.Where(x => !RecordCurrent.MicturitionList.Contains(x)));
                MicturitionListProperty.Clear();
                this.RecordCurrent.VaginalExplorationList.AddRange(VaginalExplorationListProperty.Where(x => !RecordCurrent.VaginalExplorationList.Contains(x)));
                VaginalExplorationListProperty.Clear();
                this.RecordCurrent.FetusObservationList.AddRange(FetusObservationListProperty.Where(x => !RecordCurrent.FetusObservationList.Contains(x)));
                FetusObservationListProperty.Clear();
                this.RecordCurrent.CurrentBill.BillItemList.AddRange(MedicalServicesList.Where(x => !RecordCurrent.CurrentBill.BillItemList.Contains(x)));
                MedicalServicesList.Clear();
                RecordCurrent.IsActive = false;
                (EmployeeCurrent as Midwife).TransferPatient(PatientCurrent);
                Filemanagement.SaveToDatabase(PatientCurrent);
                Filemanagement.SaveRecord(RecordCurrent);
                Messenger.Default.Send(new NotificationMessage("ToPatient"));
                Messenger.Default.Send(EmployeeCurrent, "Employee");
                Messenger.Default.Send(PatientCurrent, "Patient");
            });
            //Command to add a new line of the type Birth Information in the record view
            this.AddBirthInfo = new RelayCommand(parameter =>
            {
                BirthInfo = new BirthInformation();
                BirthInfo.CurrentEmployee = EmployeeCurrent;
                BirthInformationListProperty.Add(BirthInfo);
            });
            //Command to add a new line of the type ContractionIVDrip Informaion  in the record view
            this.AddContractionIVDripInfo = new RelayCommand(parameter =>
            {
                ContractionIVDripInfo = new ContractionIVDrip();
                ContractionIVDripInfo.CurrentEmployee = EmployeeCurrent;
                ContractionListProperty.Add(ContractionIVDripInfo);
            });
            //Command to add a new line of the type Fetus Observation Information in the record view
            this.AddFetusObservationInfo = new RelayCommand(parameter =>
            {
                FetusObservationInfo = new FetusObservation();
                FetusObservationInfo.CurrentEmployee = EmployeeCurrent;
                FetusObservationListProperty.Add(FetusObservationInfo);
            });
            //Command to add a new line of the type Micturition Information in the record view
            this.AddMicturitionInfo = new RelayCommand(parameter =>
            {
                MicturitionInfo = new Micturition();
                MicturitionInfo.CurrentEmployee = EmployeeCurrent;
                MicturitionListProperty.Add(MicturitionInfo);
            });
            //Command to add a new line of the type Vaginal Exploration Information in the record view
            this.AddVaginalExplorationInfo = new RelayCommand(parameter =>
            {
                VaginalExplorationInfo = new VaginalExploration();
                VaginalExplorationInfo.CurrentEmployee = EmployeeCurrent;
                VaginalExplorationListProperty.Add(VaginalExplorationInfo);
            });
            #endregion
        }