110 lines
2.4 KiB
TypeScript
110 lines
2.4 KiB
TypeScript
/**
|
|
* 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_v6';
|
|
export const LDX_TO_DAMPH_CONVERSION_FACTOR = 0.2948;
|
|
|
|
// Type definitions
|
|
export interface PkParams {
|
|
damph: { halfLife: string };
|
|
ldx: { halfLife: string; absorptionRate: string };
|
|
}
|
|
|
|
export interface DayDose {
|
|
id: string;
|
|
time: string;
|
|
ldx: string;
|
|
damph?: string; // Optional, kept for backwards compatibility but not used in UI
|
|
}
|
|
|
|
export interface DayGroup {
|
|
id: string;
|
|
isTemplate: boolean;
|
|
doses: DayDose[];
|
|
}
|
|
|
|
export interface SteadyStateConfig {
|
|
daysOnMedication: string;
|
|
}
|
|
|
|
export interface TherapeuticRange {
|
|
min: string;
|
|
max: string;
|
|
}
|
|
|
|
export interface UiSettings {
|
|
showDayTimeOnXAxis: boolean;
|
|
showTemplateDay: boolean;
|
|
chartView: 'ldx' | 'damph' | 'both';
|
|
yAxisMin: string;
|
|
yAxisMax: string;
|
|
simulationDays: string;
|
|
displayedDays: string;
|
|
}
|
|
|
|
export interface AppState {
|
|
pkParams: PkParams;
|
|
days: DayGroup[];
|
|
steadyStateConfig: SteadyStateConfig;
|
|
therapeuticRange: TherapeuticRange;
|
|
doseIncrement: string;
|
|
uiSettings: UiSettings;
|
|
}
|
|
|
|
// Legacy interfaces for backwards compatibility (will be removed later)
|
|
export interface Dose {
|
|
time: string;
|
|
dose: string;
|
|
label: string;
|
|
}
|
|
|
|
export interface Deviation extends Dose {
|
|
dayOffset?: number;
|
|
isAdditional: boolean;
|
|
}
|
|
|
|
export interface ConcentrationPoint {
|
|
timeHours: number;
|
|
ldx: number;
|
|
damph: number;
|
|
}
|
|
|
|
// Default application state
|
|
export const getDefaultState = (): AppState => ({
|
|
pkParams: {
|
|
damph: { halfLife: '11' },
|
|
ldx: { halfLife: '0.8', absorptionRate: '1.5' },
|
|
},
|
|
days: [
|
|
{
|
|
id: 'day-template',
|
|
isTemplate: true,
|
|
doses: [
|
|
{ id: 'dose-1', time: '06:30', ldx: '25' },
|
|
{ id: 'dose-2', time: '12:30', ldx: '10' },
|
|
{ id: 'dose-3', time: '17:00', ldx: '10' },
|
|
{ id: 'dose-4', time: '22:00', ldx: '10' },
|
|
]
|
|
}
|
|
],
|
|
steadyStateConfig: { daysOnMedication: '7' },
|
|
therapeuticRange: { min: '10.5', max: '11.5' },
|
|
doseIncrement: '2.5',
|
|
uiSettings: {
|
|
showDayTimeOnXAxis: true,
|
|
showTemplateDay: false,
|
|
chartView: 'both',
|
|
yAxisMin: '0',
|
|
yAxisMax: '16',
|
|
simulationDays: '3',
|
|
displayedDays: '2',
|
|
}
|
|
});
|