diff --git a/packages/demo/public/catalogues/catalogue-dktk.json b/packages/demo/public/catalogues/catalogue-dktk.json index 8a480e32..1a279666 100644 --- a/packages/demo/public/catalogues/catalogue-dktk.json +++ b/packages/demo/public/catalogues/catalogue-dktk.json @@ -20181,6 +20181,18 @@ { "value": "histology", "name": "tumor-tissue-ffpe" + }, + { + "value": "sample_kind", + "name": "tissue-ffpe" + }, + { + "value": "sample_kind", + "name": "normal-tissue-ffpe" + }, + { + "value": "sample_kind", + "name": "other-tissue-ffpe" } ] ] @@ -20188,7 +20200,27 @@ { "key": "tumor-tissue-frozen", "name": "Gewebe schockgefroren", - "description": "Tumorgewebe (Kryo/Frisch)" + "description": "Tumorgewebe (Kryo/Frisch)", + "aggregatedValue": [ + [ + { + "value": "sample_kind", + "name": "tissue-frozen" + }, + { + "value": "sample_kind", + "name": "tumor-tissue-frozen" + }, + { + "value": "sample_kind", + "name": "normal-tissue-frozen" + }, + { + "value": "sample_kind", + "name": "other-tissue-frozen" + } + ] + ] }, { "key": "tissue-other", diff --git a/packages/demo/public/options.json b/packages/demo/public/options.json index f465f7e8..f88e3cdd 100644 --- a/packages/demo/public/options.json +++ b/packages/demo/public/options.json @@ -83,9 +83,29 @@ "hintText": [ "Verteilung der Probentypen die mit den identifizierten Patienten verbunden sind." ], + "accumulatedValues": [ + { + "name": "ffpe-tissue", + "values": [ + "tissue-ffpe", + "tumor-tissue-ffpe", + "normal-tissue-ffpe", + "other-tissue-ffpe" + ] + }, + { + "name": "frozen-tissue", + "values": [ + "tissue-frozen", + "tumor-tissue-frozen", + "normal-tissue-frozen", + "other-tissue-frozen" + ] + } + ], "tooltips": { - "tissue-ffpe": "Gewebe FFPE", - "tissue-frozen": "Gewebe schockgefroren", + "ffpe-tissue": "Gewebe FFPE", + "frozen-tissue": "Gewebe schockgefroren", "tissue-other": "Gewebe, Andere Konservierungsart", "whole-blood": "Vollblut", "blood-serum": "Serum", @@ -106,8 +126,8 @@ "derivative-other": "Derivat, Andere" }, "legendMapping":{ - "tissue-ffpe": "Gewebe FFPE", - "tissue-frozen": "Gewebe schockgefroren", + "ffpe-tissue": "Gewebe FFPE", + "frozen-tissue": "Gewebe schockgefroren", "tissue-other": "Gewebe, Andere Konservierungsart", "whole-blood": "Vollblut", "blood-serum": "Serum", diff --git a/packages/lib/src/components/results/ChartComponent.wc.svelte b/packages/lib/src/components/results/ChartComponent.wc.svelte index 1e136935..4d7368bb 100644 --- a/packages/lib/src/components/results/ChartComponent.wc.svelte +++ b/packages/lib/src/components/results/ChartComponent.wc.svelte @@ -52,7 +52,6 @@ export let filterRegex: string = ""; export let groupingLabel: string = ""; export let viewScales: boolean = chartType !== "pie" ? true : false; - let options: ChartOption; $: options = ($lensOptions?.chartOptions && @@ -171,6 +170,23 @@ }, }; + const accumulateValues = ( + responseStore: ResponseStore, + valuesToAccumulate: string[], + catalogueGroupCode: string, + ): number => { + let aggregatedData = 0; + + valuesToAccumulate.forEach((value: string) => { + aggregatedData += getAggregatedPopulationForStratumCode( + responseStore, + value, + catalogueGroupCode, + ); + }); + return aggregatedData; + }; + /** * gets the aggregated population for a given stratum code * @param responseStore - the response store @@ -242,6 +258,36 @@ }); } + /** + * if accumulated values are set, accumulate the values of the given stratum codes and adds them to the chart + * e.g. {name: "frozen-tissue", values: ["tissue-frozen","tissue-ffpe"]} + * will remove the values from the chart and add their accumulated value to "frozen-tissue" + */ + if ( + options.accumulatedValues !== undefined && + options.accumulatedValues.length > 0 + ) { + options.accumulatedValues.forEach((valueToAccumulate) => { + const aggregationCount: number = accumulateValues( + responseStore, + valueToAccumulate.values, + catalogueGroupCode, + ); + + combinedSubGroupData.data.push(aggregationCount); + combinedSubGroupData.labels.push(valueToAccumulate.name); + + for (let i = 0; i < combinedSubGroupData.labels.length; i++) { + const element: string = combinedSubGroupData.labels[i]; + if (valueToAccumulate.values.includes(element)) { + combinedSubGroupData.labels.splice(i, 1); + combinedSubGroupData.data.splice(i, 1); + i--; + } + } + }); + } + return { labels: combinedSubGroupData.labels, data: [ @@ -384,7 +430,11 @@ * will be aggregated in groups if a divider is set * eg. 'C30', 'C31.1', 'C31.2' -> 'C31' when divider is '.' */ - let chartData = getChartDataSets(responseStore, chartLabels); + let chartData: ChartDataSets = getChartDataSets( + responseStore, + chartLabels, + ); + chart.data.datasets = chartData.data; chartLabels = chartData.labels; diff --git a/packages/lib/src/stores/query.ts b/packages/lib/src/stores/query.ts index 5c5921a1..90d9ee6d 100644 --- a/packages/lib/src/stores/query.ts +++ b/packages/lib/src/stores/query.ts @@ -219,7 +219,6 @@ export const addStratifier = ({ groupRange, }): void => { let queryItem: QueryItem; - console.log(catalogue); catalogue.forEach((parentCategory: Category) => { if ("childCategories" in parentCategory) { parentCategory.childCategories.forEach(