diff --git a/packages/demo/public/options.json b/packages/demo/public/options.json index 90c4793..b376dfe 100644 --- a/packages/demo/public/options.json +++ b/packages/demo/public/options.json @@ -44,6 +44,9 @@ "\"unbekannt\": kein Geburtsdatum oder Todesdatum bekannt." ] }, + "therapy_of_tumor": { + "aggregations": ["medicationStatements"] + }, "medicationStatements": { "hintText": [ "Art der systemischen oder abwartenden Therapie (ADT Basisdatensatz Versionen 2014, 2021)" diff --git a/packages/lib/src/components/informational/ModifiedSearchComponent.wc.svelte b/packages/lib/src/components/informational/ModifiedSearchComponent.wc.svelte index 0e9d826..359adb1 100644 --- a/packages/lib/src/components/informational/ModifiedSearchComponent.wc.svelte +++ b/packages/lib/src/components/informational/ModifiedSearchComponent.wc.svelte @@ -6,8 +6,6 @@ {#if $queryModified} diff --git a/packages/lib/src/components/results/ChartComponent.wc.svelte b/packages/lib/src/components/results/ChartComponent.wc.svelte index c087e62..246e0ad 100644 --- a/packages/lib/src/components/results/ChartComponent.wc.svelte +++ b/packages/lib/src/components/results/ChartComponent.wc.svelte @@ -15,6 +15,7 @@ import Chart, { type ChartTypeRegistry } from "chart.js/auto"; import { onMount } from "svelte"; import { + getAggregatedPopulation, getAggregatedPopulationForStratumCode, getStratifierCodesForGroupCode, responseStore, @@ -163,16 +164,6 @@ }, }; - /** - * searches the catalogue for the criteria names for the given catalogueGroupCode - * and sets them as chart labels - * DISCUSSION: needed? if so how do we implement this for bar charts? - */ - // $: { - // if(chartType === 'pie') - // initialChartData.data.labels = getCriteriaNamesFromKey($catalogue, catalogueGroupCode); - // } - /** * @param chartLabels * @returns an array of chart data sets from the response store @@ -209,24 +200,28 @@ }, ], }; - } else { - dataSet = chartLabels.map((label: string): number => { - const stratifierCode = label; - const stratifierCodeCount: number = - getAggregatedPopulationForStratumCode( - responseStore, - stratifierCode, - responseGroupCode - ); - return stratifierCodeCount; - }); - } + } + const combinedSubGroupData = combineSubGroups( groupingDivider, responseStore, chartLabels ); + + + /** + * if aggregations are set, aggregate the data from other groups and adds them to the chart + * e.g. add aggregated number of medical statements to the chart for therapy of tumor + */ + if(options.aggregations){ + options.aggregations.forEach((aggregation) => { + const aggregationCount = getAggregatedPopulation(responseStore, aggregation); + combinedSubGroupData.data.push(aggregationCount); + combinedSubGroupData.labels.push(aggregation); + }); + } + return { labels: combinedSubGroupData.labels, data: [ @@ -390,7 +385,6 @@ * if a legend mapping is set, use the legend mapping */ chart.data.labels = options.legendMapping ? chartLabels.map(label => { - console.log(label, options ) return options.legendMapping[label] }): chartLabels; @@ -504,7 +498,6 @@ addItemToQuery(queryItem, $activeQueryGroupIndex); }; - // console.log(hintText);