diff --git a/client/src/pages/WellVisit.tsx b/client/src/pages/WellVisit.tsx index de27974..4d2dfd2 100644 --- a/client/src/pages/WellVisit.tsx +++ b/client/src/pages/WellVisit.tsx @@ -1,176 +1,83 @@ // ============================================================ -// WELL VISIT — /api/well-visit/note (minimum-viable single-pane -// port; the vanilla tab has 4 sub-panes for byvisit / milestones / -// SSHADESS / note — each becomes its own sub-route or tab in a -// follow-up commit). +// WELL VISIT — sub-tab shell. Mirrors public/components/wellvisit.html: +// • By Visit Age — AAP Bright Futures recs per visit +// • Milestones — developmental checklist → AI narrative +// • SSHADESS — psychosocial screening (12+ only) +// • Visit Note — final preventive-care note generator +// +// SSHADESS pill is hidden for under-12 visits to match vanilla. +// Each panel lazy-loads so the initial WellVisit bundle stays small. // ============================================================ -import { useState } from 'react'; -import { useMutation } from '@tanstack/react-query'; -import { api, ApiError } from '@/lib/api'; -import type { VisitNoteOk } from '@/shared/types'; -import EncounterToolbar from '@/components/EncounterToolbar'; -import OutputActions from '@/components/OutputActions'; +import { Suspense, lazy, useState } from 'react'; -const TYPE = 'wellvisit' as const; +const ByVisitAge = lazy(() => import('./wellvisit/ByVisitAge')); +const Milestones = lazy(() => import('./wellvisit/Milestones')); +const Shadess = lazy(() => import('./wellvisit/Shadess')); +const VisitNote = lazy(() => import('./wellvisit/VisitNote')); + +type SubTab = 'byvisit' | 'milestones' | 'shadess' | 'note'; + +const TABS: { id: SubTab; icon: string; label: string }[] = [ + { id: 'byvisit', icon: '👶', label: 'By Visit Age' }, + { id: 'milestones', icon: '🍼', label: 'Milestones' }, + { id: 'shadess', icon: '🧠', label: 'SSHADESS (12+)' }, + { id: 'note', icon: '📄', label: 'Visit Note' }, +]; + +const STORAGE_KEY = 'ped_wellvisit_subtab'; + +function loadSubTab(): SubTab { + try { + const v = localStorage.getItem(STORAGE_KEY); + if (v === 'byvisit' || v === 'milestones' || v === 'shadess' || v === 'note') return v; + } catch { /* ignore */ } + return 'byvisit'; +} export default function WellVisit() { - const [label, setLabel] = useState(''); - const [patientAge, setPatientAge] = useState(''); - const [patientGender, setPatientGender] = useState(''); - const [visitAge, setVisitAge] = useState(''); - const [vitals, setVitals] = useState(''); - const [measurements, setMeasurements] = useState(''); - const [parentConcerns, setParentConcerns] = useState(''); - const [transcript, setTranscript] = useState(''); - const [screenings, setScreenings] = useState(''); - const [vaccines, setVaccines] = useState(''); - const [noteStyle, setNoteStyle] = useState<'full' | 'short'>('full'); - const [result, setResult] = useState(null); + const [active, setActive] = useState(loadSubTab); - const generate = useMutation({ - mutationFn: (body) => api.post('/api/well-visit/note', body), - onSuccess: (data) => setResult(data.note), - }); - - function submit(e: React.FormEvent) { - e.preventDefault(); - setResult(null); - generate.mutate({ - patientAge, patientGender, visitAge, - vitals, measurements, parentConcerns, - transcript, screenings, vaccines, - noteStyle, - }); + function pick(tab: SubTab) { + setActive(tab); + try { localStorage.setItem(STORAGE_KEY, tab); } catch { /* ignore */ } } - const input = 'w-full rounded-md border border-input bg-background px-3 py-2 text-sm'; - return ( -
+
-

Well Visit

+

Well Visit / Preventive Care

- Preventive-care note generation. Milestones and SSHADESS sub-tabs land in a follow-up; this first port covers the Visit Note pane. + AAP 2025 Bright Futures periodicity — vaccines, screenings, billing codes, milestones, SSHADESS, and the encounter note.

- { - setTranscript(enc.transcript || ''); - setResult(enc.generated_note || null); - try { - const pd = enc.partial_data ? JSON.parse(enc.partial_data) : null; - if (pd?.age) setPatientAge(pd.age); - if (pd?.gender) setPatientGender(pd.gender); - if (pd?.visitAge) setVisitAge(pd.visitAge); - if (pd?.vitals) setVitals(pd.vitals); - if (pd?.measurements) setMeasurements(pd.measurements); - if (pd?.parentConcerns) setParentConcerns(pd.parentConcerns); - if (pd?.screenings) setScreenings(pd.screenings); - if (pd?.vaccines) setVaccines(pd.vaccines); - if (pd?.noteStyle) setNoteStyle(pd.noteStyle); - } catch { /* ignore */ } - setLabel(enc.label || ''); - }} - onClear={() => { - setTranscript(''); setResult(null); - setPatientAge(''); setPatientGender(''); setVisitAge(''); - setVitals(''); setMeasurements(''); setParentConcerns(''); - setScreenings(''); setVaccines(''); setNoteStyle('full'); - }} - /> +
+ {TABS.map((t) => ( + + ))} +
-
-
- - - -
- -
-