Fix various issues with pharmacokinetics, improved parameters, distinction between adult/child

This commit is contained in:
2026-01-17 20:27:00 +00:00
parent b911fa1e16
commit 6983ce3853
13 changed files with 1505 additions and 115 deletions

View File

@@ -17,7 +17,7 @@ import { FormNumericInput } from './ui/form-numeric-input';
import { Tooltip, TooltipContent, TooltipTrigger } from './ui/tooltip';
import { IconButtonWithTooltip } from './ui/icon-button-with-tooltip';
import CollapsibleCardHeader from './ui/collapsible-card-header';
import { Plus, Copy, Trash2, ArrowDownAZ, TrendingUp, TrendingDown } from 'lucide-react';
import { Plus, Copy, Trash2, ArrowDownAZ, TrendingUp, TrendingDown, Utensils } from 'lucide-react';
import type { DayGroup } from '../constants/defaults';
interface DayScheduleProps {
@@ -28,6 +28,7 @@ interface DayScheduleProps {
onAddDose: (dayId: string) => void;
onRemoveDose: (dayId: string, doseId: string) => void;
onUpdateDose: (dayId: string, doseId: string, field: 'time' | 'ldx' | 'damph', value: string) => void;
onUpdateDoseField: (dayId: string, doseId: string, field: string, value: any) => void; // For non-string fields like isFed
onSortDoses: (dayId: string) => void;
t: any;
}
@@ -40,6 +41,7 @@ const DaySchedule: React.FC<DayScheduleProps> = ({
onAddDose,
onRemoveDose,
onUpdateDose,
onUpdateDoseField,
onSortDoses,
t
}) => {
@@ -199,8 +201,8 @@ const DaySchedule: React.FC<DayScheduleProps> = ({
{!collapsedDays.has(day.id) && (
<CardContent className="space-y-3">
{/* Dose table header */}
<div className="grid grid-cols-[120px_1fr_auto] gap-3 text-sm font-medium text-muted-foreground">
<div className="flex items-center gap-2">
<div className="grid grid-cols-[100px_1fr_auto_auto] gap-2 text-sm font-medium text-muted-foreground">
<div className="flex items-center gap-1">
<span>{t('time')}</span>
<Tooltip>
<TooltipTrigger asChild>
@@ -227,7 +229,10 @@ const DaySchedule: React.FC<DayScheduleProps> = ({
</Tooltip>
</div>
<div>{t('ldx')} (mg)</div>
<div></div>
<div className="text-center">
<Utensils className="h-4 w-4 inline" />
</div>
<div className="invisible">-</div>
</div>
{/* Dose rows */}
@@ -240,7 +245,7 @@ const DaySchedule: React.FC<DayScheduleProps> = ({
const isZeroDose = dose.ldx === '0' || dose.ldx === '0.0';
return (
<div key={dose.id} className="grid grid-cols-[120px_1fr_auto] gap-3 items-center">
<div key={dose.id} className="grid grid-cols-[120px_1fr_auto_auto] gap-2 items-center">
<FormTimeInput
value={dose.time}
onChange={(value) => onUpdateDose(day.id, dose.id, 'time', value)}
@@ -260,14 +265,22 @@ const DaySchedule: React.FC<DayScheduleProps> = ({
errorMessage={t('errorNumberRequired')}
warningMessage={t('warningZeroDose')}
/>
<IconButtonWithTooltip
onClick={() => onUpdateDoseField(day.id, dose.id, 'isFed', !dose.isFed)}
icon={<Utensils className="h-4 w-4" />}
tooltip={dose.isFed ? t('doseWithFood') : t('doseFasted')}
size="sm"
variant={dose.isFed ? "default" : "outline"}
className={`h-9 w-9 p-0 ${dose.isFed ? 'bg-orange-500 hover:bg-orange-600' : ''}`}
/>
<IconButtonWithTooltip
onClick={() => onRemoveDose(day.id, dose.id)}
icon={<Trash2 className="h-4 w-4" />}
tooltip={t('removeDose')}
size="sm"
variant="ghost"
variant="outline"
disabled={day.isTemplate && day.doses.length === 1}
className="h-9 w-9 p-0"
className="h-9 w-9 p-0 border-destructive text-destructive hover:bg-destructive hover:text-destructive-foreground disabled:border-muted"
/>
</div>
);