/// <summary> /// Adds a prescription to the meds list view. /// </summary> /// <param name="prescription">The prescription to add.</param> public void AddPrescription(CompletedPrescription prescription) { int index = 0; foreach (CompletedPrescription existingPrescription in this.prescriptions) { if (existingPrescription.StartDate.Date > prescription.StartDate.Date) { index++; } else { break; } } this.prescriptions.Insert(index, prescription); this.WrapDataGrid.Reload(); }
/// <summary> /// Convert forward function. /// </summary> /// <param name="value">The source value.</param> /// <param name="targetType">The target type.</param> /// <param name="parameter">The parameter.</param> /// <param name="culture">The culture info.</param> /// <returns>The converted value.</returns> public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { CompletedPrescription prescription = value as CompletedPrescription; if (prescription != null) { TextBlock textBlock = new TextBlock(); textBlock.TextWrapping = TextWrapping.Wrap; if (!string.IsNullOrEmpty(prescription.Name)) { string[] ingredients = prescription.Name.Split("+".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < ingredients.Length; i++) { CompletedPrescriptionToMedsLineConverter.ReplaceHyphensWithNonBreakingCharacter(textBlock, ingredients[i].Trim(), FontWeights.Bold); if (i < ingredients.Length - 1) { CompletedPrescriptionToMedsLineConverter.AddCharacterJoin(textBlock); textBlock.Inlines.Add(new Run() { Text = "+ ", FontWeight = FontWeights.Bold }); } } } if (!string.IsNullOrEmpty(prescription.BrandName)) { AddCharacterJoin(textBlock); textBlock.Inlines.Add(new Run() { Text = "― " }); string[] parts = prescription.BrandName.Split("+".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < parts.Length; i++) { CompletedPrescriptionToMedsLineConverter.ReplaceHyphensWithNonBreakingCharacter(textBlock, parts[i].Trim(), FontWeights.Normal); if (i < parts.Length - 1) { CompletedPrescriptionToMedsLineConverter.AddCharacterJoin(textBlock); textBlock.Inlines.Add(new Run() { Text = "+ ", }); } } } if (!string.IsNullOrEmpty(prescription.Strength)) { textBlock.Inlines.Add(new Run() { Text = " " }); AddNonBreakingInlines(textBlock, prescription.Strength, FontWeights.Normal); } if (!string.IsNullOrEmpty(prescription.Form)) { AddCharacterJoin(textBlock); textBlock.Inlines.Add(new Run() { Text = "― " }); AddNonBreakingInlines(textBlock, prescription.Form, FontWeights.Normal); } if (!string.IsNullOrEmpty(prescription.Dose)) { AddCharacterJoin(textBlock); textBlock.Inlines.Add(new Run() { Text = "― " }); textBlock.Inlines.Add(new Run() { Text = "DOSE", FontFamily = new FontFamily("Courier New"), Foreground = SystemParameters.HighContrast ? new SolidColorBrush(Color.FromArgb(0xff, 0x00, 0xff, 0xf0)) : new SolidColorBrush(Color.FromArgb(0xff, 0x50, 0x8d, 0xc2)) }); AddCharacterJoin(textBlock); AddNonBreakingInlines(textBlock, prescription.Dose, FontWeights.Bold); } if (!string.IsNullOrEmpty(prescription.Method)) { AddCharacterJoin(textBlock); textBlock.Inlines.Add(new Run() { Text = "― " }); textBlock.Inlines.Add(new Run() { Text = "METHOD", FontFamily = new FontFamily("Courier New"), Foreground = SystemParameters.HighContrast ? new SolidColorBrush(Color.FromArgb(0xff, 0x00, 0xff, 0xf0)) : new SolidColorBrush(Color.FromArgb(0xff, 0x50, 0x8d, 0xc2)) }); AddCharacterJoin(textBlock); AddNonBreakingInlines(textBlock, prescription.Method, FontWeights.Normal); } if (!string.IsNullOrEmpty(prescription.Site)) { AddCharacterJoin(textBlock); textBlock.Inlines.Add(new Run() { Text = "― " }); AddNonBreakingInlines(textBlock, prescription.Site, FontWeights.Normal); } if (!string.IsNullOrEmpty(prescription.Route)) { AddCharacterJoin(textBlock); textBlock.Inlines.Add(new Run() { Text = "― " }); AddNonBreakingInlines(textBlock, prescription.Route, FontWeights.Normal); } if (!string.IsNullOrEmpty(prescription.Frequency)) { AddCharacterJoin(textBlock); textBlock.Inlines.Add(new Run() { Text = "― " }); AddNonBreakingInlines(textBlock, prescription.Frequency, FontWeights.Normal); } if (prescription.IsAsRequired) { AddCharacterJoin(textBlock); textBlock.Inlines.Add(new Run() { Text = "― " }); AddNonBreakingInlines(textBlock, "as required", FontWeights.Normal); } return(textBlock); } return(null); }