Skip to content
This repository was archived by the owner on Nov 17, 2025. It is now read-only.

Commit ff40b0d

Browse files
committed
bugs on chart distro structure type
1 parent cf38582 commit ff40b0d

1 file changed

Lines changed: 32 additions & 17 deletions

File tree

src/hooks/useChartData.ts

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -153,15 +153,12 @@ export const useChartData = (
153153
if (selectedTask === "Auto-Contouring") {
154154
// Get all auto-contouring products
155155
const autoContouringProducts = filteredProducts.filter(p => p.category === "Auto-Contouring");
156-
157-
// Extract and count all supported structures
156+
// Extract and count all supported structures
158157
const structureCounts: Record<string, number> = {};
159158
autoContouringProducts.forEach((product: ProductDetails) => {
160-
if (product.supportedStructures && product.supportedStructures.length > 0) {
161-
product.supportedStructures.forEach(structure => {
162-
// Extract the structure name (after the colon)
163-
const structureName = structure.split(":")[1]?.trim() || structure;
164-
structureCounts[structureName] = (structureCounts[structureName] || 0) + 1;
159+
if (product.structures && product.structures.length > 0) {
160+
product.structures.forEach(structure => {
161+
structureCounts[structure.name] = (structureCounts[structure.name] || 0) + 1;
165162
});
166163
}
167164
});
@@ -177,26 +174,44 @@ export const useChartData = (
177174
setStructureData([]);
178175
}
179176
}, [selectedTask, selectedLocation, selectedModality, filteredProducts]);
180-
181177
// Process structure type data for auto-contouring products
182178
useEffect(() => {
183179
if (selectedTask === "Auto-Contouring") {
184180
const structureTypeStats = filteredProducts.map(product => {
185-
const oars = product.structures?.filter(s => s.type === "OAR").length || 0;
186-
const gtv = product.structures?.filter(s => s.type === "GTV").length || 0;
187-
const elective = product.structures?.filter(s => s.type === "Elective").length || 0;
181+
// Count structures by looking at the structure names in supportedStructures
182+
const oars = product.supportedStructures?.filter(s =>
183+
!s.toLowerCase().includes('gtv') &&
184+
!s.toLowerCase().includes('ctv') &&
185+
!s.toLowerCase().includes('target') &&
186+
!s.toLowerCase().includes('metastases')
187+
).length || 0;
188+
189+
const gtv = product.supportedStructures?.filter(s =>
190+
s.toLowerCase().includes('gtv') ||
191+
s.toLowerCase().includes('gross tumor') ||
192+
s.toLowerCase().includes('metastases')
193+
).length || 0;
188194

189-
return {
195+
const elective = product.supportedStructures?.filter(s =>
196+
s.toLowerCase().includes('ctv') ||
197+
s.toLowerCase().includes('clinical target') ||
198+
s.toLowerCase().includes('elective')
199+
).length || 0;
200+
const total = oars + gtv + elective;
201+
202+
// Only include products that have at least one structure
203+
return total > 0 ? {
190204
productName: product.name,
191205
OARs: oars,
192206
GTV: gtv,
193207
Elective: elective,
194-
total: oars + gtv + elective
195-
};
196-
});
208+
total: total
209+
} : null;
210+
})
211+
.filter(Boolean) // Remove null entries
212+
.sort((a, b) => b.total - a.total); // Sort by total number of structures
197213

198-
// Sort by total number of structures descending
199-
setStructureTypeData(structureTypeStats.sort((a, b) => b.total - a.total));
214+
setStructureTypeData(structureTypeStats);
200215
}
201216
}, [filteredProducts, selectedTask]);
202217

0 commit comments

Comments
 (0)