// ============================================================ // ENCOUNTER — live encounter → HPI via /api/generate-hpi-encounter // Minimum-viable port: same shape as Dictation (same endpoint family). // Audio capture + save/load + refine deferred to follow-up commits. // ============================================================ import { useState } from 'react'; import { useMutation } from '@tanstack/react-query'; import { api, ApiError } from '@/lib/api'; import type { HpiOk } from '@/shared/types'; import { HpiEncounterRequestSchema, type HpiEncounterRequest } from '@/shared/schemas'; type Setting = 'outpatient' | 'inpatient'; export default function Encounter() { const [patientAge, setPatientAge] = useState(''); const [patientGender, setPatientGender] = useState(''); const [setting, setSetting] = useState('outpatient'); const [transcript, setTranscript] = useState(''); const [result, setResult] = useState(null); const [validationError, setValidationError] = useState(null); const generate = useMutation({ mutationFn: (body) => api.post('/api/generate-hpi-encounter', body), onSuccess: (data) => setResult(data.hpi), }); function submit(e: React.FormEvent) { e.preventDefault(); setValidationError(null); const body: HpiEncounterRequest = { transcript, patientAge, patientGender, setting }; const parsed = HpiEncounterRequestSchema.safeParse(body); if (!parsed.success) { setValidationError(parsed.error.issues.map((i: { message: string }) => i.message).join(', ')); return; } setResult(null); generate.mutate(parsed.data); } const input = 'w-full rounded-md border border-input bg-background px-3 py-2 text-sm'; return (

Live Encounter → HPI

Record or paste an encounter transcript; generate a structured HPI.