public async void AddNewPatient(string PatientName) { int spaceOcc = PatientName.IndexOf(" "); var patient = new LocalPatient() { Name = spaceOcc > 0 ? PatientName.Substring(spaceOcc + 1, PatientName.Length - spaceOcc - 1) : PatientName, Surname = spaceOcc > 0 ? PatientName.Substring(0, spaceOcc) : "", AllName = PatientName, Brush = BackgroundColors.BackgroundFilled, }; if (!PatientsList.Any(item => item.Surname.Trim() == patient.Surname.Trim() && item.Name.Trim() == patient.Name.Trim())) { patient.Name = patient.Name.TrimEnd(); patient.Surname = patient.Surname.TrimEnd(); patient.AllName = patient.Surname + " " + patient.Name; SelectedPatient = patient; try { SelectedPatient.Id = await DatabaseHandler.Instance.AddPatient(SelectedPatient, LocalCache.Instance.CurrentUser.Id); PatientsList.Add(SelectedPatient); eventAggregator.GetEvent <PatientAddedEvent>().Publish(SelectedPatient); LocalCache.Instance.PatientsRepository.Patients.Add(SelectedPatient); } catch (Exception ex) { MessageBox.Show("Eroare la salvare pacient"); } } }
private void OnPatientSelected(Object patient) { CurrentPatinent = (LocalPatient)patient;//LocalCache.Instance.PatientsRepository.Patients.FirstOrDefault(item => item.Id == patientId); PatientId = CurrentPatinent.Id; PatientInformationViewModel = CurrentPatinent.ToPatientInformationViewModel(this); InterventionsVisibility = Visibility.Visible; MetroLoadingViewModel = new MetroLoadingViewModel(true); //MetroLoadingViewModel.MetroLoadingViewReference = new MetroLoadingView(); // get the Ui thread context TaskScheduler _uiScheduler = TaskScheduler.FromCurrentSynchronizationContext(); Action DoInBackground = new Action(() => { GetInterventions(); }); Action DoOnUiThread = new Action(() => { UpdateInterventionsCollection(); }); // start the background task backgroundTask = Task.Factory.StartNew(() => DoInBackground()); // when t1 is done run t1..on the Ui thread. uiTask = backgroundTask.ContinueWith(t => DoOnUiThread(), _uiScheduler); // Interventions = new ObservableCollection<InterventionDetails>( DatabaseHandler.Instance.GetPatientInterventions(PatientId).Select(item => item.ToInterventionDetails())); }
public static LocalPatient ToLocalPatient(this Patient entityPatient) { var patient = new LocalPatient() { Id = entityPatient.id, Name = entityPatient.name, Surname = entityPatient.surname, Address = entityPatient.Address, City = entityPatient.City, Email = entityPatient.Email, Phone = entityPatient.Phone, BirthDate = entityPatient.BirthDate.HasValue ? entityPatient.BirthDate.Value : new DateTime(1900, 1, 1), Block = entityPatient.Block, Job = entityPatient.Job, StreetNumber = entityPatient.StreetNumber, Street = entityPatient.Street, Ocupation = entityPatient.Ocupation, Country = entityPatient.Country, Brush = BackgroundColors.JurnalColor, AllName = entityPatient.surname + (!string.IsNullOrEmpty(entityPatient.surname) ? " " : "") + entityPatient.name }; patient.Interventions = new List <LocalIntervention>(); foreach (var intervention in entityPatient.Interventions) { patient.Interventions.Add(intervention.ToLocalIntervention()); } return(patient); }
public async void SavePatient(LocalPatient addedPatient) { if (!string.IsNullOrEmpty(SearchedItem)) { Search(SearchedItem); } AddPatientControlVisibility = Visibility.Collapsed; PatientsList.Add(addedPatient); //SelectedPatient = addedPatient; }
// public static PatientViewModel ToPatientViewModel(this LocalPatient localPatient) // { // return new PatientViewModel() // { // Id = localPatient.Id, // Name = localPatient.Name, // Surname = localPatient.Surname, // Address = localPatient.Address, // City = localPatient.City, // Phone = localPatient.Phone, // Email = localPatient.Email // }; // } public static UserDetailsViewModel ToDetailsViewModel(this LocalPatient patient) { return(new UserDetailsViewModel() { Address = patient.Address, Name = patient.Name, Surname = patient.Surname, Phone = patient.Phone, }); }
public int AddPatient(LocalPatient localPatient) { using (DSAEntities dsaModel = new DSAEntities()) { var patient = localPatient.ToEntityPatient(); dsaModel.Patients.AddObject(patient); dsaModel.SaveChanges(); return(patient.id); } }
public static List <LocalPatient> ExcelToPatient(this Dictionary <String, List <string> > excelResult) { List <LocalPatient> patients = new List <LocalPatient>(); excelResult.Remove(excelResult.Keys.Last()); foreach (var key in excelResult.Keys) { LocalPatient patient = new LocalPatient(); patient.Name = excelResult[key][3]; LocalIntervention Intervention = new LocalIntervention(); Intervention.Area = new LocalArea() { Name = excelResult[key][7] }; Intervention.DateHourDetail = new LocalDateHourDetail() { StartHour = DateTime.FromOADate(float.Parse(excelResult[key][9])), EndingHour = DateTime.FromOADate(float.Parse(excelResult[key][10])), Date = Convert.ToDateTime(excelResult[key][2]) }; Intervention.Location = new LocalLocation() { Name = excelResult[key][4] }; Intervention.Material = new LocalMaterial() { Name = excelResult[key][6] }; Intervention.Observation = excelResult[key][8]; Intervention.Revenue = new LocalRevenue() { Amount = Convert.ToDecimal(excelResult[key][12]) }; Intervention.Lucrare = new LocalWork() { Name = excelResult[key][5] }; //patient.Intervention = Intervention; var currPatient = patients.FirstOrDefault(item => item.Name == patient.Name); if (currPatient != null) { currPatient.Interventions.Add(Intervention); } else { patient.Interventions = new List <LocalIntervention>(); patient.Interventions.Add(Intervention); patients.Add(patient); } } return(patients); }
public static Patient ToEntityPatient(this LocalPatient localPatient) { return(new Patient() { id = localPatient.Id, name = localPatient.Name, surname = localPatient.Surname, Address = localPatient.Address, City = localPatient.City, Email = localPatient.Email, Phone = localPatient.Phone }); }
public static PatientViewModel ToPatientViewModel(this LocalPatient localPatient, LeftListViewModel parent) { return(new PatientViewModel(parent) { Id = localPatient.Id, Name = localPatient.Name, Surname = localPatient.Surname, Address = localPatient.Address, City = localPatient.City, Phone = localPatient.Phone, Email = localPatient.Email }); }
public static PatientInformationViewModel ToPatientInformationViewModel(this LocalPatient localPatient, PersonalInfoScreenViewModel parent) { return(new PatientInformationViewModel(parent) { Name = localPatient.Name, Surname = localPatient.Surname, BirthDate = localPatient.BirthDate, Email = localPatient.Email, Phone = localPatient.Phone, Street = localPatient.Street, Number = localPatient.StreetNumber, Bloc = localPatient.Block, Country = localPatient.Country, Job = localPatient.Job, Ocupation = localPatient.Ocupation, City = localPatient.City, }); }
private void InitData() { SelectedArea = null; Revenue = null; SelectedWorkType = new LocalWorkType(); SelectedWork = new LocalWork(); SelectedMaterialType = new SettingsType(); SelectedMaterial = new LocalMaterial(); StartingHour = EndTIme; SelectedPatient = new LocalPatient(); Observation = ""; SelectedLocation = new SettingsItem(); SelectedTechnician = new LocalTechnician(); Durata = ""; IsInEditMode = false; WasPayedByDental = false; SelectedPercentage = null; MaterialCost = null; }
public static LocalPatient ToLocalPatient(this Patient entityPatient) { var patient = new LocalPatient() { Id = entityPatient.id, Name = entityPatient.name, Surname = entityPatient.surname, Address = entityPatient.Address, City = entityPatient.City, Email = entityPatient.Email, Phone = entityPatient.Phone }; patient.Interventions = new List <LocalIntervention>(); foreach (var intervention in entityPatient.Interventions) { patient.Interventions.Add(intervention.ToLocalIntervention()); } return(patient); }
public static bool CopyToLocalPatient(this LocalPatient localPatient, PatientInformationViewModel patientInformationViewModel) { bool toreturn = false; if (localPatient.Name != patientInformationViewModel.Name || localPatient.Surname != patientInformationViewModel.Surname) { toreturn = true; } localPatient.BirthDate = patientInformationViewModel.BirthDate; localPatient.Block = patientInformationViewModel.Bloc; localPatient.Ocupation = patientInformationViewModel.Ocupation; localPatient.Phone = patientInformationViewModel.Phone; localPatient.Street = patientInformationViewModel.Street; localPatient.Name = patientInformationViewModel.Name; localPatient.StreetNumber = patientInformationViewModel.Number; localPatient.Surname = patientInformationViewModel.Surname; localPatient.Email = patientInformationViewModel.Email; localPatient.Country = patientInformationViewModel.Country; localPatient.City = patientInformationViewModel.City; localPatient.Job = patientInformationViewModel.Job; localPatient.AllName = localPatient.Surname + (!string.IsNullOrEmpty(localPatient.Surname) ? " " : "") + localPatient.Name; return(true); }
public int AddPatient(LocalPatient localPatient) { return(DatabaseHandler.Instance.AddPatient(localPatient)); }
public void AddPatient(LocalPatient localPatient) { PatientsDictionary.Add(localPatient.Id, localPatient); }
public static List <LocalPatient> ExcelToPatient(this Dictionary <String, List <string> > excelResult) { List <LocalPatient> patients = new List <LocalPatient>(); excelResult.Remove(excelResult.Keys.Last()); foreach (var key in excelResult.Keys) { LocalPatient patient = new LocalPatient(); patient.Name = excelResult[key][3]; patient.Surname = ""; LocalIntervention Intervention = new LocalIntervention(); Intervention.Area = new LocalArea() { Name = excelResult[key][7] }; try { Intervention.DateHourDetail = new LocalDateHourDetail() { StartHour = DateTime.FromOADate(float.Parse(excelResult[key][9])), EndingHour = DateTime.FromOADate(float.Parse(excelResult[key][10])), Date = Convert.ToDateTime(excelResult[key][2]) }; } catch (Exception e) { Log.Error(string.Format("Patient Name: {0}.Start Date Or Enddate Wrong", patient.Name), e); } Intervention.Location = new LocalLocation() { Name = excelResult[key][4] }; Intervention.Material = new LocalMaterial() { Name = excelResult[key][6] }; Intervention.Observation = excelResult[key][8]; try { Intervention.Revenue = Convert.ToDouble(excelResult[key][12]); } catch (Exception e) { Log.Error(string.Format("Patient Name: {0} .Revenue Wrong", patient.Name), e); } Intervention.Lucrare = new LocalWork() { Name = excelResult[key][5] }; var t = excelResult[key][14]; if (!string.IsNullOrEmpty(t)) { try { Intervention.Percent = Convert.ToDouble(excelResult[key][14]); } catch (Exception e) { Log.Error(string.Format("Patient Name: {0} .Percent Wrong", patient.Name), e); } } //patient.Intervention = Intervention; var currPatient = patients.FirstOrDefault(item => item.Name == patient.Name); if (currPatient != null) { currPatient.Interventions.Add(Intervention); } else { patient.Interventions = new List <LocalIntervention>(); patient.Interventions.Add(Intervention); patients.Add(patient); } } return(patients); }
public Task <int> AddPatient(LocalPatient addedPatient) { return(serverModel.AddPatientAsync(addedPatient)); }