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 }
public static void ReadBirthRecords(Patient patient) { if (patient.RecordList.Count == 0) { StreamReader sr; List <List <string> > information = new List <List <string> >(); int CIVDripCounter; int vgExpCounter; int micturitionCounter; int fetusObsCounter; int birthInfoCounter; int variCounter; int fileCounter = 0; Record recordToBeAdded; string tempString; string[] filer = Directory.GetFiles(Path.Combine(_PatientsPath, patient.CPR.ToString())).Where(x => !x.Contains("info") && !x.Contains("Bill")).ToArray(); foreach (string fil in filer) { recordToBeAdded = new Record(patient); CIVDripCounter = 0; vgExpCounter = 0; micturitionCounter = 0; fetusObsCounter = 0; birthInfoCounter = 0; variCounter = 0; sr = new StreamReader(fil); information.Add(sr.ReadToEnd().Split('_').ToList()); information[fileCounter].RemoveAt(0); foreach (string paragraph in information[fileCounter]) { tempString = paragraph.Split('|')[0]; switch (tempString) { case "contractionIVDrip": CIVDripCounter++; break; case "vaginalExp": vgExpCounter++; break; case "micturition": micturitionCounter++; break; case "fetusObservation": fetusObsCounter++; break; case "birthInformation": birthInfoCounter++; break; case "variables": variCounter++; break; default: break; } } int i = 0; if (CIVDripCounter != 0) { string[] CIVDripInfo; for (; i < CIVDripCounter; i++) { CIVDripInfo = information[fileCounter][i].Split('|'); ContractionIVDrip temp = new ContractionIVDrip(); if (!String.IsNullOrEmpty(CIVDripInfo[1])) { temp.Time = DateTime.ParseExact(CIVDripInfo[1], "dd-MM-yyyy HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture); } if (!String.IsNullOrEmpty(CIVDripInfo[2])) { temp.NumberOfContractionsPerMinute = Convert.ToInt32(CIVDripInfo[2]); } if (!String.IsNullOrEmpty(CIVDripInfo[3])) { temp.SDripMlPerHour = Convert.ToInt32(CIVDripInfo[3]); } recordToBeAdded.ContractionIVDripList.Add(temp); } } if (vgExpCounter != 0) { string[] vagExpInfo; int loopCounter = vgExpCounter + i; for (; i < loopCounter; i++) { vagExpInfo = information[fileCounter][i].Split('|'); VaginalExploration temp = new VaginalExploration(); if (!String.IsNullOrEmpty(vagExpInfo[1])) { temp.Time = DateTime.ParseExact(vagExpInfo[1], "dd-MM-yyyy HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture); } if (!String.IsNullOrEmpty(vagExpInfo[2])) { temp.Collum = Convert.ToInt32(vagExpInfo[2]); } if (!String.IsNullOrEmpty(vagExpInfo[3])) { temp.Dialation = Convert.ToInt32(vagExpInfo[3]); } if (!String.IsNullOrEmpty(vagExpInfo[4])) { temp.Position = vagExpInfo[4]; } if (!String.IsNullOrEmpty(vagExpInfo[5])) { temp.Rotation = Convert.ToInt32(vagExpInfo[5]); } if (!String.IsNullOrEmpty(vagExpInfo[6])) { temp.Consistency = vagExpInfo[6]; } if (!String.IsNullOrEmpty(vagExpInfo[7])) { temp.Location = vagExpInfo[7]; } if (!String.IsNullOrEmpty(vagExpInfo[8])) { temp.AmnioticFluid = vagExpInfo[8]; } recordToBeAdded.VaginalExplorationList.Add(temp); } } if (micturitionCounter != 0) { string[] MictuInfo; int loopCounter = micturitionCounter + i; for (; i < loopCounter; i++) { MictuInfo = information[fileCounter][i].Split('|'); Micturition temp = new Micturition(); if (!String.IsNullOrEmpty(MictuInfo[1])) { temp.Time = DateTime.ParseExact(MictuInfo[1], "dd-MM-yyyy HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture); } if (!String.IsNullOrEmpty(MictuInfo[2])) { temp.MicturitionNote = MictuInfo[2]; } recordToBeAdded.MicturitionList.Add(temp); } } if (fetusObsCounter != 0) { string[] fetusObsInfo; int loopCounter = fetusObsCounter + i; for (; i < loopCounter; i++) { fetusObsInfo = information[fileCounter][i].Split('|'); FetusObservation temp = new FetusObservation(); if (!String.IsNullOrEmpty(fetusObsInfo[1])) { temp.Time = DateTime.ParseExact(fetusObsInfo[1], "dd-MM-yyyy HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture); } if (!String.IsNullOrEmpty(fetusObsInfo[2])) { temp.HearthFrequency = fetusObsInfo[2]; } if (!String.IsNullOrEmpty(fetusObsInfo[3])) { temp.CTG = fetusObsInfo[3]; } if (!String.IsNullOrEmpty(fetusObsInfo[4])) { temp.CTGClassification = fetusObsInfo[4]; } if (!String.IsNullOrEmpty(fetusObsInfo[5])) { temp.STAN = fetusObsInfo[5]; } if (!String.IsNullOrEmpty(fetusObsInfo[6])) { temp.ScalppH = Convert.ToDouble(fetusObsInfo[6]); } if (!String.IsNullOrEmpty(fetusObsInfo[7])) { temp.ScalpLactate = Convert.ToDouble(fetusObsInfo[7]); } recordToBeAdded.FetusObservationList.Add(temp); } } if (birthInfoCounter != 0) { string[] birthInfo; int loopCounter = birthInfoCounter + i; for (; i < loopCounter; i++) { birthInfo = information[fileCounter][i].Split('|'); BirthInformation temp = new BirthInformation(); if (!String.IsNullOrEmpty(birthInfo[1])) { temp.Time = DateTime.ParseExact(birthInfo[1], "dd-MM-yyyy HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture); } if (!String.IsNullOrEmpty(birthInfo[2])) { temp.Result = birthInfo[2]; } if (!String.IsNullOrEmpty(birthInfo[3])) { temp.AmnioticFluid = birthInfo[3]; } if (!String.IsNullOrEmpty(birthInfo[4])) { temp.AmountOfFluid = birthInfo[4]; } if (!String.IsNullOrEmpty(birthInfo[5])) { temp.BloodAmount = Convert.ToDouble(birthInfo[5]); } if (!String.IsNullOrEmpty(birthInfo[6])) { temp.BleedingCause = birthInfo[6]; } if (!String.IsNullOrEmpty(birthInfo[7])) { temp.BirthPosition = birthInfo[7]; } recordToBeAdded.BirthInformationList.Add(temp); } } if (variCounter != 0) { string[] VariInfo; int loopCounter = variCounter + i; for (; i < loopCounter; i++) { VariInfo = information[fileCounter][i].Split('|'); //if (!String.IsNullOrEmpty(VariInfo[1])) recordToBeAdded.ThisRecordID = Convert.ToInt32(VariInfo[1]); if (!String.IsNullOrEmpty(VariInfo[2])) { recordToBeAdded.TimeOfBirth = DateTime.ParseExact(VariInfo[2], "dd-MM-yyyy HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture); } if (!String.IsNullOrEmpty(VariInfo[3])) { recordToBeAdded.CircumferenceHead = Convert.ToDouble(VariInfo[3]); } if (!String.IsNullOrEmpty(VariInfo[4])) { recordToBeAdded.CircumferenceStomach = Convert.ToDouble(VariInfo[4]); } if (!String.IsNullOrEmpty(VariInfo[5])) { recordToBeAdded.BloodSugar = Convert.ToDouble(VariInfo[5]); } if (!String.IsNullOrEmpty(VariInfo[6])) { recordToBeAdded.GA = VariInfo[6]; } if (!String.IsNullOrEmpty(VariInfo[7])) { recordToBeAdded.NavelpHVenous = Convert.ToDouble(VariInfo[7]); } if (!String.IsNullOrEmpty(VariInfo[8])) { recordToBeAdded.NavelpHArterial = Convert.ToDouble(VariInfo[8]); } if (!String.IsNullOrEmpty(VariInfo[9])) { recordToBeAdded.NavelBaseExcessArterial = Convert.ToDouble(VariInfo[9]); } if (!String.IsNullOrEmpty(VariInfo[10])) { recordToBeAdded.NavelBaseExcessVenous = Convert.ToDouble(VariInfo[10]); } if (!String.IsNullOrEmpty(VariInfo[11])) { recordToBeAdded.FetusPosition = Convert.ToInt32(VariInfo[11]); } if (!String.IsNullOrEmpty(VariInfo[12])) { recordToBeAdded.PlacentaWeight = Convert.ToDouble(VariInfo[12]); } if (!String.IsNullOrEmpty(VariInfo[13])) { recordToBeAdded.KVitamin = Convert.ToBoolean(VariInfo[13]); } if (!String.IsNullOrEmpty(VariInfo[14])) { recordToBeAdded.ApgarOneMinute = Convert.ToInt32(VariInfo[14]); } if (!String.IsNullOrEmpty(VariInfo[15])) { recordToBeAdded.ApgarFiveMinutes = Convert.ToInt32(VariInfo[15]); } if (!String.IsNullOrEmpty(VariInfo[16])) { recordToBeAdded.ApgarTenMinutes = Convert.ToInt32(VariInfo[16]); } if (!String.IsNullOrEmpty(VariInfo[17])) { recordToBeAdded.AO = Convert.ToInt32(VariInfo[17]); } if (!String.IsNullOrEmpty(VariInfo[18])) { recordToBeAdded.HO = Convert.ToInt32(VariInfo[18]); } if (!String.IsNullOrEmpty(VariInfo[19])) { recordToBeAdded.Weight = Convert.ToDouble(VariInfo[19]); } if (!String.IsNullOrEmpty(VariInfo[20])) { recordToBeAdded.Length = Convert.ToDouble(VariInfo[20]); } if (!String.IsNullOrEmpty(VariInfo[21])) { recordToBeAdded.NumberOfChildren = VariInfo[21]; } if (!String.IsNullOrEmpty(VariInfo[22])) { recordToBeAdded.FurtherNotice = VariInfo[22]; } if (!String.IsNullOrEmpty(VariInfo[23])) { recordToBeAdded.Sucking = Convert.ToBoolean(VariInfo[23]); } if (!String.IsNullOrEmpty(VariInfo[24])) { recordToBeAdded.Nose = Convert.ToBoolean(VariInfo[24]); } if (!String.IsNullOrEmpty(VariInfo[25])) { recordToBeAdded.Pharynx = Convert.ToBoolean(VariInfo[25]); } if (!String.IsNullOrEmpty(VariInfo[26])) { recordToBeAdded.Ventricle = Convert.ToBoolean(VariInfo[26]); } if (!String.IsNullOrEmpty(VariInfo[27])) { recordToBeAdded.Diagnosis = VariInfo[27]; } if (!String.IsNullOrEmpty(VariInfo[28])) { recordToBeAdded.Note = VariInfo[28]; } if (!String.IsNullOrEmpty(VariInfo[29])) { recordToBeAdded.NewNote = VariInfo[29]; } if (!String.IsNullOrEmpty(VariInfo[30])) { recordToBeAdded.ApgarOneMinuteNote = VariInfo[30]; } if (!String.IsNullOrEmpty(VariInfo[31])) { recordToBeAdded.ApgarFiveMinuteNote = VariInfo[31]; } if (!String.IsNullOrEmpty(VariInfo[32])) { recordToBeAdded.ApgarTenMinuteNote = VariInfo[32]; } if (!String.IsNullOrEmpty(VariInfo[33])) { recordToBeAdded.BreastFeedingNote = VariInfo[33]; } if (!String.IsNullOrEmpty(VariInfo[34])) { recordToBeAdded.BirthComplications = Convert.ToBoolean(VariInfo[34]); } if (!String.IsNullOrEmpty(VariInfo[35])) { recordToBeAdded.IsActive = Convert.ToBoolean(VariInfo[35]); } if (!String.IsNullOrEmpty(VariInfo[36])) { recordToBeAdded.ChildCPR = VariInfo[36]; } for (int h = 36; h < VariInfo.Length; h++) { recordToBeAdded.Diseases.Add(VariInfo[h]); } } sr.Close(); } patient.RecordList.Add(recordToBeAdded); new P3_Midwife.Views.RecordWindow(recordToBeAdded); new Views.NewChildWindow(recordToBeAdded); fileCounter++; } } }