From d021f9c412888c9e9bcbe5e70831faf363c3950b Mon Sep 17 00:00:00 2001 From: HirschleM Date: Tue, 17 Dec 2024 09:52:43 +0100 Subject: [PATCH] MH: Bewertungsstatistik Wirksamkeitskontrolle --- BeWo/View/Report/Rating/RatingReportView.xaml | 7 +- .../Report/Rating/RatingReportView.xaml.cs | 83 ++++++++++++++++++- Host/ReportView.aspx.cs | 10 ++- Report/DefaultReportCreator.cs | 18 +++- Report/ReportObjects/BewertungsstatistikRO.cs | 65 +++++++-------- 5 files changed, 137 insertions(+), 46 deletions(-) diff --git a/BeWo/View/Report/Rating/RatingReportView.xaml b/BeWo/View/Report/Rating/RatingReportView.xaml index 227201c07..b8f055824 100644 --- a/BeWo/View/Report/Rating/RatingReportView.xaml +++ b/BeWo/View/Report/Rating/RatingReportView.xaml @@ -32,11 +32,16 @@ - + + + diff --git a/BeWo/View/Report/Rating/RatingReportView.xaml.cs b/BeWo/View/Report/Rating/RatingReportView.xaml.cs index 7cdbb4053..c57bcc191 100644 --- a/BeWo/View/Report/Rating/RatingReportView.xaml.cs +++ b/BeWo/View/Report/Rating/RatingReportView.xaml.cs @@ -79,9 +79,19 @@ namespace BeWo.View.Report.Rating private void LinkPdfExport_OnRequestNavigate(object sender, RequestNavigateEventArgs e) { - string url = GenerateURL(); - BeWoUtils.NavigateToReportUri(url, Translator.Translate("Bewertungsstatistik")); - //System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo((sender as System.Windows.Documents.Hyperlink).NavigateUri.ToString())); + // Wenn das Häkchen für alle Hilfepläne gesetzt ist wird eine andere URL erstellt, in der der Hilfeplan null ist + if (chkAllSupportConcepts.IsChecked.HasValue && chkAllSupportConcepts.IsChecked.Value) + { + string url = GenerateURLForAllSupportConcepts(); + BeWoUtils.NavigateToReportUri(url, Translator.Translate("Bewertungsstatistik")); + } + // Sonst Standard + else + { + string url = GenerateURL(); + BeWoUtils.NavigateToReportUri(url, Translator.Translate("Bewertungsstatistik")); + //System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo((sender as System.Windows.Documents.Hyperlink).NavigateUri.ToString())); + } } private string GenerateURL() @@ -144,6 +154,57 @@ namespace BeWo.View.Report.Rating return url; } + private string GenerateURLForAllSupportConcepts() + { + string url = ""; + url += BeWoApp.SiteOfOrigin + "/ReportView.aspx?"; + + DateTime? start = SupportConceptRatingView.StartDate; + DateTime? end = SupportConceptRatingView.EndDate; + + try + { + // Ist das Häkchen für den gesamten Zeitraum gesetzt, werden auf dem Server Start und Ende auf den ersten bzw. letzten Hilfeplan gesetzt + if (chkTotalTimeSpan.IsChecked == true) + { + SupportConceptRatingView.StartDate = null; + SupportConceptRatingView.EndDate = null; + start = null; + end = null; + } + // Sonst den Wert aus den Datumsfeldern nehmen + else + { + SupportConceptRatingView.StartDate = dp_start.DateTime; + SupportConceptRatingView.EndDate = dp_end.DateTime; + start = dp_start.DateTime; + end = dp_end.DateTime; + } + + } + catch + { + // nix + } + + if (start != null) + { + url += "&start=" + start; + } + if (end != null) + { + url += "&end=" + end; + } + + url += "&type=" + Utils.EnumName(ReportTypes.BewertungsstatistikReport); + url = BeWoWpfUtils.GetHTMLEncodedURL(url); + + this.linkPdfExport.NavigateUri = new Uri(url); + + return url; + } + + private void UpdateRatingView() { VMFactory.CreateSupportConceptVMAsync(_SelectedSupportConcept.SupportConceptOid, @@ -177,7 +238,21 @@ namespace BeWo.View.Report.Rating } - + private void chkAllSupportConcepts_Checked(object sender, RoutedEventArgs e) + { + button_generate.Visibility = Visibility.Hidden; + popupedit_CostBeaerer.Visibility = Visibility.Hidden; + BorderRatingView.Visibility = Visibility.Hidden; + textblockHilfeplan.Visibility = Visibility.Hidden; + + GenerateURLForAllSupportConcepts(); + } + private void chkAllSupportConcepts_Unchecked(object sender, RoutedEventArgs e) + { + button_generate.Visibility = Visibility.Visible; + popupedit_CostBeaerer.Visibility = Visibility.Visible; + textblockHilfeplan.Visibility = Visibility.Visible; + } } } diff --git a/Host/ReportView.aspx.cs b/Host/ReportView.aspx.cs index 0df34b24f..99d2f4e76 100644 --- a/Host/ReportView.aspx.cs +++ b/Host/ReportView.aspx.cs @@ -587,12 +587,18 @@ namespace Host supportConcept = MapperFactory.SupportConceptDC_SupportConcept.MapToNewDC(DAOFactory.GenericDAO.GetByID(long.Parse(Request.Params["scOid"]))); if (Request.Params["start"] != null) start = DateTime.Parse(Request.Params["start"]); - else + else if (supportConcept != null) start = supportConcept.Ratings[0].StartDate; + else + start = null; + if (Request.Params["end"] != null) end = DateTime.Parse(Request.Params["end"]); - else + else if (supportConcept != null) end = supportConcept.Ratings[supportConcept.Ratings.Count - 1].StartDate; + else + end = null; + if (Request.Params["ze"] != null) inclZeiterfassung = (Request.Params["ze"] == "1") ? true : false; if (Request.Params["goals"] != null) diff --git a/Report/DefaultReportCreator.cs b/Report/DefaultReportCreator.cs index a44cb7cae..9c41281eb 100644 --- a/Report/DefaultReportCreator.cs +++ b/Report/DefaultReportCreator.cs @@ -972,10 +972,20 @@ namespace BeWo.Report public override XtraReport CreateBewertungsstatistikReport(DateTime? start, DateTime? end, SupportConceptDC supportConcept, bool inclZeiterfassung, List ziele, List scZiele) { - var report = FindReportImp(); - report.SetReportDataSource(BewertungsstatistikRO.Create(start, end, supportConcept, inclZeiterfassung, ziele, scZiele)); - return report as XtraReport; - + // Ist kein Hilfeplan gesetzt, wird die Tabelle für die Auswertung aller Bewertungen in einem Zeitraum gebaut + if (supportConcept == null) + { + var report = new Bewertungsstatistik(); + report.SetReportDataSource(BewertungsstatistikRO.Create(start, end, supportConcept, inclZeiterfassung, null, null)); + return report as XtraReport; + } + // Ist der Hilfeplan als Parameter gesetzt, Bericht für einen HP erstellen + else + { + var report = FindReportImp(); + report.SetReportDataSource(BewertungsstatistikRO.Create(start, end, supportConcept, inclZeiterfassung, ziele, scZiele)); + return report as XtraReport; + } } public override XtraReport CreateCustomReport(long employeeOid, String reportName) diff --git a/Report/ReportObjects/BewertungsstatistikRO.cs b/Report/ReportObjects/BewertungsstatistikRO.cs index e9057fe67..eb61621a1 100644 --- a/Report/ReportObjects/BewertungsstatistikRO.cs +++ b/Report/ReportObjects/BewertungsstatistikRO.cs @@ -53,12 +53,36 @@ namespace BeWo.Report.ReportObjects result.StartDay = start; result.EndDay = end; + // Ist kein Hilfeplan gesetzt und die Listen null, dann wird für ALLE Hilfepläne erstellt if (supportConcept == null && ausgewaehlteZiele == null && scZiele == null) { - // Hier neu + // In diesem Dictionary wird jeder Benotung aus der Verwaltung die vergebene Menge im Zeitraum zugeordnet Dictionary ratingTypeZuAnzahl = new Dictionary(); - // Zuerst alle GoalRating holen und in ein Dict packen, damit man schon mal nach der Bewertung sortiert hat - var allGoalRatings = MapperFactory.GoalRatingDC_GoalRating.MapToNewDCs(DAOFactory.GenericDAO.GetAllActive()); + + // Alle Ratings (Hilfeplanbewertungen) holen, die (im gewählten Zeitraum) gemacht wurden, und nachfolgend nur die GoalRatings (einzelne Zielbewertungen) + // ins Dict holen, deren RatingOid hier drin sind + List allRatings = new List(); + if (start != null && end != null) + allRatings = MapperFactory.RatingDC_Rating.MapToNewDCs(DAOFactory.GenericDAO.GetAllActive()) + .Where(r => r.StartDate >= start && r.StartDate <= end).ToList(); + else + allRatings = MapperFactory.RatingDC_Rating.MapToNewDCs(DAOFactory.GenericDAO.GetAllActive()); + + // Wurde in der RatingReportView kein Start- und Enddatum angegeben, dann hier die neuste und die älteste Bewertung als Datum setzen + if (start == null && end == null && allRatings != null && allRatings.Count > 0) + { + allRatings = allRatings.OrderBy(r => r.StartDate).ToList(); + result.StartDay = allRatings[0].StartDate; + result.EndDay = allRatings[allRatings.Count - 1].StartDate; + } + + // Zuerst GoalRatings (einzelne Zielbewertungen) aus Hilfeplanbewertungen in Liste packen + List allGoalRatings = new List(); + foreach (var rating in allRatings) + foreach (var goalRating in rating.GoalRatingList) + allGoalRatings.Add(goalRating); + + // Dann in oben genanntes Dictionary packen, um nach Bewertung zu gruppieren und die Anzahl der vergebenen Bewertung zu zählen foreach (var rating in allGoalRatings) { if (!ratingTypeZuAnzahl.ContainsKey(rating.RatingType.DisplayName)) @@ -67,8 +91,10 @@ namespace BeWo.Report.ReportObjects ratingTypeZuAnzahl[rating.RatingType.DisplayName]++; } + // Gesamte Anzahl an Bewertungen im Zeitraum ausrechnen decimal gesamt = ratingTypeZuAnzahl.Sum(r => r.Value); + // Für jede Benotung, die vergeben wurde, eine Spalte erstellen mit Name, Anzahl und % foreach (var pair in ratingTypeZuAnzahl) { result.Wirkungskontolle.Add(new Wirkungskontrolle() @@ -79,6 +105,7 @@ namespace BeWo.Report.ReportObjects }); } } + // Ist SupportConcept gesetzt, nur für einen Hilfeplan Auswertung erstellen else { result.ZeiterfassungEinbinden = inclZeiterfassung; @@ -121,37 +148,6 @@ namespace BeWo.Report.ReportObjects datensatz.GesamtzeitInvestiert = 0; datensatz.BewertungsstatistikZielDetailList = new List(); - //foreach (var sr in serviceRecords) - //{ - // var detail = new BewertungsstatistikZielDetail(); - - // foreach (var item in passendeZielBewertungen) - // { - // if (item.GoalEntry.ValueListEntryOid == ziel.ValueListEntryOid) - // { - // if (item.ServiceRecord.ServiceRecordOid == sr.Oid && item.GoalRatingOid == null && item.RatingType?.RatingId != null) - // { - // if (item.ServiceRecord.Start >= start && item.ServiceRecord.Start <= end) - // { - // detail.Note = item.RatingType.RatingId.Value; - // anzahl++; // Zähler für Schnittberechnung - // detail.MinutenInvestiert = sr.DurationMinutes; - // detail.Datum = sr.Start; - // passendeZielBewertungen.Remove(item); - // break; - // } - // } - // } - // } - - // if (detail.MinutenInvestiert != 0) - // { - // datensatz.GesamtzeitInvestiert += detail.MinutenInvestiert; - // datensatz.Durchschnitt += detail.Note; - // } - // if (detail.Datum != null) - // datensatz.BewertungsstatistikZielDetailList.Add(detail); - //} foreach (var item in passendeZielBewertungen) { @@ -173,7 +169,6 @@ namespace BeWo.Report.ReportObjects datensatz.BewertungsstatistikZielDetailList.Add(detail); } - //} } datensatz.Durchschnitt /= anzahl;