Overview
Innovaccer's data platform empowers healthcare organizations to derive actionable insights from vast amounts of patient data. A crucial aspect of this platform is the ability for users to dynamically explore and visualize data without needing complex queries. This problem focuses on building a configurable component for our internal analytics dashboard, allowing users to aggregate raw patient data based on chosen dimensions and metrics.
What you need to do / Task
Your task is to build a React component that displays raw patient data and provides a control panel for dynamic aggregation. The component should then display the aggregated results.
- Display Raw Data: Render the provided
initialPatientData in a simple table format.
- Build a Control Panel: Implement a UI panel that includes:
- A dropdown/select input labeled "Group By" to choose a categorical field from the raw data (e.g.,
diseaseType, physician).
- A dropdown/select input labeled "Aggregate Metric" to choose a numeric field from the raw data (e.g.,
lengthOfStayDays, billAmount).
- A dropdown/select input labeled "Aggregation Type" with options:
SUM, AVERAGE, COUNT.
- Implement Dynamic Aggregation: Based on the user's selections in the control panel, process the
initialPatientData to group and aggregate it accordingly.
- If no "Group By" field is selected, the aggregation should apply to the entire dataset.
- If no "Aggregate Metric" is selected, disable the "Aggregation Type" dropdown or display an appropriate message.
COUNT should count the number of records in each group.
- Display Aggregated Data: Render the resulting aggregated data in a clear format (e.g., a new table or a list of key-value pairs). The output should show the group identifier and the aggregated value.
UI/UX expectations
- The raw data table, control panel, and aggregated output should be clearly separated on the screen.
- Changes in the control panel selections (Group By, Aggregate Metric, Aggregation Type) must trigger immediate updates to the aggregated data display.
- Dropdowns should be populated dynamically from the keys of the
PatientRecord interface where appropriate.
- Ensure a clean, functional layout. Pixel-perfect design is not required, but readability and usability are key.
Acceptance criteria
- Raw
initialPatientData is displayed correctly.
- Control panel dropdowns are populated with relevant fields and aggregation types.
- Selecting a "Group By" field, "Aggregate Metric," and "Aggregation Type" correctly transforms the data.
SUM aggregation accurately calculates the sum of the chosen metric per group.
AVERAGE aggregation accurately calculates the average of the chosen metric per group.
COUNT aggregation accurately calculates the number of records per group.
- Aggregated data display updates dynamically and accurately reflects current selections.
- The component handles cases where no group by field is selected (aggregates entire dataset).
- The component handles cases where no numeric metric is suitable for aggregation (e.g., disables aggregation type dropdown).