In-process port of
circlehealthai-web/app/api/case-review/[caseId]/chat/route.ts.
The HTTP boundary, Supabase auth, and case-id -> patient-id lookup are all
stripped — those become concerns of the trpc handler that calls this
function (which already has the authenticated user and PatientId in
scope). The langchain/Pinecone glue is preserved verbatim from v1:
Load session and pdf vector stores unconditionally.
Load extracted and emr stores under try/catch (these are optional).
Construct a ChatOpenAI instance and hand it to processCaseChat.
Shape the result as { id, role: 'assistant', content, citations }
to match what v1's POST handler returned.
Chat is synchronous — no Jobbable, no queue. The trpc mutation awaits
this call directly.
In-process port of
circlehealthai-web/app/api/case-review/[caseId]/chat/route.ts.The HTTP boundary, Supabase auth, and case-id -> patient-id lookup are all stripped — those become concerns of the trpc handler that calls this function (which already has the authenticated user and
PatientIdin scope). The langchain/Pinecone glue is preserved verbatim from v1:sessionandpdfvector stores unconditionally.extractedandemrstores under try/catch (these are optional).ChatOpenAIinstance and hand it toprocessCaseChat.{ id, role: 'assistant', content, citations }to match what v1's POST handler returned.Chat is synchronous — no Jobbable, no queue. The trpc mutation awaits this call directly.