private void WindowLoaded(object sender, RoutedEventArgs e) { try { this.dtPickerStartDate.SelectedDate = DateTime.Now.Date; var medicationDataRepository = new MedicationDataRepository(EHealthCareDesktopApp.Properties.Settings.Default.UniqueIdentifier); // Get all medication stregths var medicationStrengths = medicationDataRepository.GetAllMedicationStrengths(); cmbStrength.ItemsSource = medicationStrengths; cmbStrength.DisplayMemberPath = "Unit"; cmbStrength.SelectedValuePath = "Value"; // Get all medication doses var medicationDoses = medicationDataRepository.GetAllMedicationDoses(); cmbDose.ItemsSource = medicationDoses; cmbDose.DisplayMemberPath = "Name"; cmbDose.SelectedValuePath = "Value"; // Get all medication takens var medicationTakens = medicationDataRepository.GetAllMedicationTakens(); cmbHowTaken.ItemsSource = medicationTakens; cmbHowTaken.DisplayMemberPath = "Name"; cmbHowTaken.SelectedValuePath = "Value"; this.Title = "Manage Medication for: " + EHealthCareDesktopApp.Properties.Settings.Default.PatientName; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void DeleteClick(object sender, RoutedEventArgs e) { try { var id = int.Parse(((Button)sender).CommandParameter.ToString()); var medicationDataRepository = new MedicationDataRepository(EHealthCareDesktopApp.Properties.Settings.Default.UniqueIdentifier); medicationDataRepository.DeleteMedication(EHealthCareDesktopApp.Properties.Settings.Default.PatientID, id); LoadMedications(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
public List <MedicationViewModel> GetViewModel() { var medicationDataRepository = new MedicationDataRepository(Guid.Parse(uniqueGuid)); var medications = medicationDataRepository.GetAllMedicationData(this.patientId); foreach (var medication in medications) { medicationViewModelList.Add(new MedicationViewModel { MedicationName = medication.MedicationName, StartDate = medication.StartDate.ToShortDateString(), EndDate = medication.EndDate == null ? "" : medication.EndDate.ToString(), HowTaken = medication.HowTaken, Dose = medication.DoseText + " " + medication.DoseUnit, Strength = medication.StrengthText + " " + medication.StrengthUnit, ReasonForTaking = medication.ReasonForTaking }); } return(medicationViewModelList); }
private void SaveMedicationClick(object sender, RoutedEventArgs e) { try { var medicationDataRepository = new MedicationDataRepository(EHealthCareDesktopApp.Properties.Settings.Default.UniqueIdentifier); var medication = new Medication() { PatientId = EHealthCareDesktopApp.Properties.Settings.Default.PatientID, DoseText = cmbDose.SelectedValue.ToString(), DoseUnit = int.Parse(txtDose.Text.Trim()), HowTaken = ((MedicationTaken)cmbHowTaken.SelectedItem).Name, MedicationName = txtMedicationName.Text.Trim(), Notes = txtNotes.Text.Trim(), StartDate = dtPickerStartDate.SelectedDate.Value, StrengthText = cmbStrength.SelectedValue.ToString(), StrengthUnit = int.Parse(txtStrength.Text), ReasonForTaking = txtReasonForTaking.Text.Trim() }; if (dtPickerEndDate.SelectedDate != null) { medication.EndDate = dtPickerEndDate.SelectedDate.Value; } medicationDataRepository.SaveMedication(medication); if (MedicationAddedEvent != null) { MedicationAddedEvent("Success"); } } catch (Exception ex) { if (MedicationAddedEvent != null) { MedicationAddedEvent(string.Format("Problem in adding Medications: {0}", ex.Message)); } } }