Add doc to script file
This commit is contained in:
11
src/App.tsx
11
src/App.tsx
@@ -1,3 +1,14 @@
|
|||||||
|
/**
|
||||||
|
* Medication Plan Assistant - Main Application
|
||||||
|
*
|
||||||
|
* A pharmacokinetic simulation tool for lisdexamfetamine (Elvanse/Vyvanse)
|
||||||
|
* medication planning. Helps users visualize drug concentration profiles,
|
||||||
|
* manage deviations, and get dose correction suggestions.
|
||||||
|
*
|
||||||
|
* @author Andreas Weyer
|
||||||
|
* @license MIT
|
||||||
|
*/
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
// Components
|
// Components
|
||||||
|
|||||||
@@ -1,3 +1,14 @@
|
|||||||
|
/**
|
||||||
|
* Deviation List Component
|
||||||
|
*
|
||||||
|
* Tracks and manages deviations from the planned medication schedule.
|
||||||
|
* Supports adding, editing, and deleting deviations with automatic or
|
||||||
|
* manual timestamps. Each deviation can be marked as planned or actual.
|
||||||
|
*
|
||||||
|
* @author Andreas Weyer
|
||||||
|
* @license MIT
|
||||||
|
*/
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { FormTimeInput } from './ui/form-time-input';
|
import { FormTimeInput } from './ui/form-time-input';
|
||||||
import { FormNumericInput } from './ui/form-numeric-input';
|
import { FormNumericInput } from './ui/form-numeric-input';
|
||||||
|
|||||||
@@ -1,3 +1,13 @@
|
|||||||
|
/**
|
||||||
|
* Dose Schedule Component
|
||||||
|
*
|
||||||
|
* Manages up to 5 daily dose time slots with time and dose amount inputs.
|
||||||
|
* Provides validation and allows empty entries for flexible scheduling.
|
||||||
|
*
|
||||||
|
* @author Andreas Weyer
|
||||||
|
* @license MIT
|
||||||
|
*/
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { FormTimeInput } from './ui/form-time-input';
|
import { FormTimeInput } from './ui/form-time-input';
|
||||||
import { FormNumericInput } from './ui/form-numeric-input';
|
import { FormNumericInput } from './ui/form-numeric-input';
|
||||||
|
|||||||
@@ -1,3 +1,13 @@
|
|||||||
|
/**
|
||||||
|
* Language Selector Component
|
||||||
|
*
|
||||||
|
* Provides UI for switching between supported languages (English/German).
|
||||||
|
* Uses shadcn/ui Select component.
|
||||||
|
*
|
||||||
|
* @author Andreas Weyer
|
||||||
|
* @license MIT
|
||||||
|
*/
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from './ui/select';
|
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from './ui/select';
|
||||||
import { Label } from './ui/label';
|
import { Label } from './ui/label';
|
||||||
|
|||||||
@@ -1,3 +1,14 @@
|
|||||||
|
/**
|
||||||
|
* Settings Component
|
||||||
|
*
|
||||||
|
* Provides configuration for pharmacokinetic parameters (half-lives,
|
||||||
|
* absorption rates) and UI settings (chart view, therapeutic ranges,
|
||||||
|
* x-axis format). Includes data management (import/export/reset).
|
||||||
|
*
|
||||||
|
* @author Andreas Weyer
|
||||||
|
* @license MIT
|
||||||
|
*/
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { FormNumericInput } from './ui/form-numeric-input';
|
import { FormNumericInput } from './ui/form-numeric-input';
|
||||||
import { Card, CardContent, CardHeader, CardTitle } from './ui/card';
|
import { Card, CardContent, CardHeader, CardTitle } from './ui/card';
|
||||||
|
|||||||
@@ -1,3 +1,14 @@
|
|||||||
|
/**
|
||||||
|
* Simulation Chart Component
|
||||||
|
*
|
||||||
|
* Visualizes pharmacokinetic concentration profiles over time using Recharts.
|
||||||
|
* Displays ideal plan, deviated profile, and corrected profile with
|
||||||
|
* therapeutic range indicators. Supports multiple chart views and x-axis formats.
|
||||||
|
*
|
||||||
|
* @author Andreas Weyer
|
||||||
|
* @license MIT
|
||||||
|
*/
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, Legend, ReferenceLine, ResponsiveContainer } from 'recharts';
|
import { LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, Legend, ReferenceLine, ResponsiveContainer } from 'recharts';
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,13 @@
|
|||||||
|
/**
|
||||||
|
* Suggestion Panel Component
|
||||||
|
*
|
||||||
|
* Displays dose correction suggestions based on deviations from the plan.
|
||||||
|
* Shows recommended time and dose adjustments with apply button.
|
||||||
|
*
|
||||||
|
* @author Andreas Weyer
|
||||||
|
* @license MIT
|
||||||
|
*/
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Card, CardContent, CardHeader, CardTitle } from './ui/card';
|
import { Card, CardContent, CardHeader, CardTitle } from './ui/card';
|
||||||
import { Button } from './ui/button';
|
import { Button } from './ui/button';
|
||||||
|
|||||||
@@ -1,3 +1,13 @@
|
|||||||
|
/**
|
||||||
|
* Custom Form Component: Numeric Input with Controls
|
||||||
|
*
|
||||||
|
* A numeric input field with increment/decrement buttons, validation,
|
||||||
|
* and error display. Built on top of shadcn/ui components.
|
||||||
|
*
|
||||||
|
* @author Andreas Weyer
|
||||||
|
* @license MIT
|
||||||
|
*/
|
||||||
|
|
||||||
import * as React from "react"
|
import * as React from "react"
|
||||||
import { Minus, Plus, X } from "lucide-react"
|
import { Minus, Plus, X } from "lucide-react"
|
||||||
import { Button } from "./button"
|
import { Button } from "./button"
|
||||||
|
|||||||
@@ -1,3 +1,13 @@
|
|||||||
|
/**
|
||||||
|
* Custom Form Component: Time Input with Picker
|
||||||
|
*
|
||||||
|
* A time input field with interactive hour/minute picker, validation,
|
||||||
|
* and error display. Built on top of shadcn/ui components.
|
||||||
|
*
|
||||||
|
* @author Andreas Weyer
|
||||||
|
* @license MIT
|
||||||
|
*/
|
||||||
|
|
||||||
import * as React from "react"
|
import * as React from "react"
|
||||||
import { Clock } from "lucide-react"
|
import { Clock } from "lucide-react"
|
||||||
import { Button } from "./button"
|
import { Button } from "./button"
|
||||||
|
|||||||
@@ -1,4 +1,13 @@
|
|||||||
// Application constants
|
/**
|
||||||
|
* Application Constants and Type Definitions
|
||||||
|
*
|
||||||
|
* Defines TypeScript interfaces for application state, pharmacokinetic parameters,
|
||||||
|
* and default values. Central configuration for localStorage keys and conversion factors.
|
||||||
|
*
|
||||||
|
* @author Andreas Weyer
|
||||||
|
* @license MIT
|
||||||
|
*/
|
||||||
|
|
||||||
export const LOCAL_STORAGE_KEY = 'medPlanAssistantState_v5';
|
export const LOCAL_STORAGE_KEY = 'medPlanAssistantState_v5';
|
||||||
export const LDX_TO_DAMPH_CONVERSION_FACTOR = 0.2948;
|
export const LDX_TO_DAMPH_CONVERSION_FACTOR = 0.2948;
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,14 @@
|
|||||||
|
/**
|
||||||
|
* Application State Hook
|
||||||
|
*
|
||||||
|
* Manages global application state with localStorage persistence.
|
||||||
|
* Provides type-safe state updates for nested objects and automatic
|
||||||
|
* state saving on changes.
|
||||||
|
*
|
||||||
|
* @author Andreas Weyer
|
||||||
|
* @license MIT
|
||||||
|
*/
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { LOCAL_STORAGE_KEY, getDefaultState, type AppState } from '../constants/defaults';
|
import { LOCAL_STORAGE_KEY, getDefaultState, type AppState } from '../constants/defaults';
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,13 @@
|
|||||||
|
/**
|
||||||
|
* Language Hook
|
||||||
|
*
|
||||||
|
* Manages application language state and provides translation access.
|
||||||
|
* Persists language preference to localStorage.
|
||||||
|
*
|
||||||
|
* @author Andreas Weyer
|
||||||
|
* @license MIT
|
||||||
|
*/
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { translations, getInitialLanguage } from '../locales/index';
|
import { translations, getInitialLanguage } from '../locales/index';
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,14 @@
|
|||||||
|
/**
|
||||||
|
* Simulation Hook
|
||||||
|
*
|
||||||
|
* Manages pharmacokinetic simulation calculations and deviation handling.
|
||||||
|
* Computes ideal, deviated, and corrected concentration profiles.
|
||||||
|
* Generates dose correction suggestions based on deviations.
|
||||||
|
*
|
||||||
|
* @author Andreas Weyer
|
||||||
|
* @license MIT
|
||||||
|
*/
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { calculateCombinedProfile } from '../utils/calculations';
|
import { calculateCombinedProfile } from '../utils/calculations';
|
||||||
import { generateSuggestion } from '../utils/suggestions';
|
import { generateSuggestion } from '../utils/suggestions';
|
||||||
|
|||||||
@@ -1,3 +1,13 @@
|
|||||||
|
/**
|
||||||
|
* Internationalization (i18n) Configuration
|
||||||
|
*
|
||||||
|
* Manages application translations and language detection.
|
||||||
|
* Supports English and German with browser language preference detection.
|
||||||
|
*
|
||||||
|
* @author Andreas Weyer
|
||||||
|
* @license MIT
|
||||||
|
*/
|
||||||
|
|
||||||
import en from './en';
|
import en from './en';
|
||||||
import de from './de';
|
import de from './de';
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,14 @@
|
|||||||
|
/**
|
||||||
|
* Pharmacokinetic Calculation Utilities
|
||||||
|
*
|
||||||
|
* Combines multiple dose profiles over time to create complete concentration
|
||||||
|
* curves. Handles steady-state calculations, dose accumulation, and empty
|
||||||
|
* value filtering for robust simulation.
|
||||||
|
*
|
||||||
|
* @author Andreas Weyer
|
||||||
|
* @license MIT
|
||||||
|
*/
|
||||||
|
|
||||||
import { timeToMinutes } from './timeUtils';
|
import { timeToMinutes } from './timeUtils';
|
||||||
import { calculateSingleDoseConcentration } from './pharmacokinetics';
|
import { calculateSingleDoseConcentration } from './pharmacokinetics';
|
||||||
import type { Dose, Deviation, SteadyStateConfig, PkParams, ConcentrationPoint } from '../constants/defaults';
|
import type { Dose, Deviation, SteadyStateConfig, PkParams, ConcentrationPoint } from '../constants/defaults';
|
||||||
|
|||||||
@@ -1,3 +1,14 @@
|
|||||||
|
/**
|
||||||
|
* Pharmacokinetic Model
|
||||||
|
*
|
||||||
|
* Implements single-dose concentration calculations for lisdexamfetamine (LDX)
|
||||||
|
* and its active metabolite dextroamphetamine (d-amph). Uses first-order
|
||||||
|
* absorption and elimination kinetics.
|
||||||
|
*
|
||||||
|
* @author Andreas Weyer
|
||||||
|
* @license MIT
|
||||||
|
*/
|
||||||
|
|
||||||
import { LDX_TO_DAMPH_CONVERSION_FACTOR, type PkParams } from '../constants/defaults';
|
import { LDX_TO_DAMPH_CONVERSION_FACTOR, type PkParams } from '../constants/defaults';
|
||||||
|
|
||||||
interface ConcentrationResult {
|
interface ConcentrationResult {
|
||||||
|
|||||||
@@ -1,3 +1,14 @@
|
|||||||
|
/**
|
||||||
|
* Dose Correction Suggestion Engine
|
||||||
|
*
|
||||||
|
* Generates dose correction suggestions when deviations occur from the planned
|
||||||
|
* medication schedule. Calculates required dose adjustments and optimal timing
|
||||||
|
* to maintain therapeutic concentrations.
|
||||||
|
*
|
||||||
|
* @author Andreas Weyer
|
||||||
|
* @license MIT
|
||||||
|
*/
|
||||||
|
|
||||||
import { timeToMinutes } from './timeUtils';
|
import { timeToMinutes } from './timeUtils';
|
||||||
import { calculateCombinedProfile } from './calculations';
|
import { calculateCombinedProfile } from './calculations';
|
||||||
import type { Dose, Deviation, SteadyStateConfig, PkParams } from '../constants/defaults';
|
import type { Dose, Deviation, SteadyStateConfig, PkParams } from '../constants/defaults';
|
||||||
|
|||||||
@@ -1,4 +1,13 @@
|
|||||||
// Time utility functions
|
/**
|
||||||
|
* Time Utility Functions
|
||||||
|
*
|
||||||
|
* Provides time format conversion utilities for working with HH:MM time strings
|
||||||
|
* and minute-based calculations throughout the application.
|
||||||
|
*
|
||||||
|
* @author Andreas Weyer
|
||||||
|
* @license MIT
|
||||||
|
*/
|
||||||
|
|
||||||
export const timeToMinutes = (timeStr: string): number => {
|
export const timeToMinutes = (timeStr: string): number => {
|
||||||
if (!timeStr || !timeStr.includes(':')) return 0;
|
if (!timeStr || !timeStr.includes(':')) return 0;
|
||||||
const [hours, minutes] = timeStr.split(':').map(Number);
|
const [hours, minutes] = timeStr.split(':').map(Number);
|
||||||
|
|||||||
Reference in New Issue
Block a user