Update README.md

This commit is contained in:
2026-03-30 14:04:01 -05:00
parent 516f43308f
commit 3f427f25a0

152
README.md
View File

@@ -1,75 +1,109 @@
# React + TypeScript + Vite # Patient Risk Scoring System
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules. A take-home assessment project built with React, TypeScript, and Vite. The application fetches patient data from a paginated REST API, calculates risk scores across three clinical categories, identifies patients of concern, and submits the results to a graded assessment endpoint.
Currently, two official plugins are available: ## Assessment Results
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Oxc](https://oxc.rs) ### Attempt 1: 97%
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) ![Attempt 1](./screenshots/attempt1.png)
## React Compiler High Risk and Data Quality were perfect (20/20 and 8/8 respectively), but one fever patient was missed — DEMO023 with a temperature of 99.7°F. This was a simple error where the fever threshold in the submission payload was mistakenly set to 99.8°F instead of the correct 99.6°F, causing any patient with a temperature between 99.6°F and 99.7°F to be excluded. The fix was a one-line change in the scoring logic.
The React Compiler is enabled on this template. See [this documentation](https://react.dev/learn/react-compiler) for more information. ### Attempt 2: 100%
![Attempt 2](./screenshots/attempt2.png)
Note: This will impact Vite dev & build performances. Perfect score across all three categories after correcting the fever threshold.
## Expanding the ESLint configuration ---
If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules: ## Features
```js - Fetches all patient records sequentially across paginated API pages, with per-page rate-limit retry and exponential backoff
export default defineConfig([ - Calculates a risk score per patient across three categories: blood pressure, temperature, and age
globalIgnores(['dist']), - Identifies high-risk patients, fever patients, and records with data quality issues
{ - Client-side pagination — all pages are loaded once and cached for 5 minutes; navigating the table makes no additional API calls
files: ['**/*.{ts,tsx}'], - Submission panel with a full payload preview before posting, and a structured results display after
extends: [
// Other configs...
// Remove tseslint.configs.recommended and replace with this ## Risk Scoring
tseslint.configs.recommendedTypeChecked,
// Alternatively, use this for stricter rules
tseslint.configs.strictTypeChecked,
// Optionally, add this for stylistic rules
tseslint.configs.stylisticTypeChecked,
// Other configs... Total risk score = BP score + Temperature score + Age score
],
languageOptions: { **Blood Pressure**
parserOptions: { | Category | Criteria | Points |
project: ['./tsconfig.node.json', './tsconfig.app.json'], |---|---|---|
tsconfigRootDir: import.meta.dirname, | Normal | Systolic < 120 AND Diastolic < 80 | 0 |
}, | Elevated | Systolic 120129 AND Diastolic < 80 | 1 |
// other options... | Stage 1 | Systolic 130139 OR Diastolic 8089 | 2 |
}, | Stage 2 | Systolic ≥ 140 OR Diastolic ≥ 90 | 3 |
},
]) If systolic and diastolic fall into different categories, the higher score is used. Missing or non-numeric values score 0 and are flagged as data quality issues.
**Temperature**
| Category | Criteria | Points |
|---|---|---|
| Normal | ≤ 99.5°F | 0 |
| Low Fever | 99.6100.9°F | 1 |
| High Fever | ≥ 101.0°F | 2 |
**Age**
| Category | Criteria | Points |
|---|---|---|
| Under 40 | < 40 years | 0 |
| Middle | 4065 years | 1 |
| Over 65 | > 65 years | 2 |
## Alert Lists
- **High Risk:** patients with a total risk score ≥ 4
- **Fever:** patients with a valid temperature ≥ 99.6°F
- **Data Quality Issues:** patients with missing or malformed BP, temperature, or age values
## Project Structure
```
src/
api/
patients.ts # Fetch + normalization for paginated patient data; fetchAllPatients
submit.ts # POST to assessment submission endpoint
components/
AlertsPanel.tsx # High-risk / fever / data quality alert cards
PatientTable.tsx # Paginated table with per-row risk badges
SubmissionPanel.tsx # Payload preview and submission with result breakdown
index.tsx # Component barrel export
hooks/
useAllPatients.ts # Fetches all pages sequentially, 5-min cache
usePatients.ts # Single-page patient fetching hook
usePatientRiskAnalysis.ts # Derives scores + alerts from the shared cache
useSubmitAssessment.ts # TanStack Query mutation for assessment submission
index.ts # Hook barrel export
lib/
scoring.ts # Pure risk scoring functions and alert/payload computation
queryConfig.ts # Shared retry + backoff config for API queries
App.tsx
main.tsx
``` ```
You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules: ## Tech Stack
```js - [React 19](https://react.dev)
// eslint.config.js - [TypeScript](https://www.typescriptlang.org)
import reactX from 'eslint-plugin-react-x' - [Vite](https://vite.dev)
import reactDom from 'eslint-plugin-react-dom' - [TanStack Query v5](https://tanstack.com/query/latest)
export default defineConfig([ ## Setup
globalIgnores(['dist']),
{ 1. Install dependencies:
files: ['**/*.{ts,tsx}'], ```bash
extends: [ bun install
// Other configs... ```
// Enable lint rules for React
reactX.configs['recommended-typescript'], 2. Set environment variables in `.env`:
// Enable lint rules for React DOM ```
reactDom.configs.recommended, VITE_BASE_URL=https://your-api-base-url.com
], VITE_API_KEY=your_api_key_here
languageOptions: { ```
parserOptions: {
project: ['./tsconfig.node.json', './tsconfig.app.json'], 3. Start the dev server:
tsconfigRootDir: import.meta.dirname, ```bash
}, bun run dev
// other options...
},
},
])
``` ```