feat: complete real-time voice-ai engine upgrades and frontend integration guide
This commit is contained in:
@@ -5,10 +5,14 @@ import time
|
||||
from uuid import uuid4
|
||||
from typing import Optional
|
||||
|
||||
from fastapi import APIRouter, Depends, File, Form, HTTPException, Request, UploadFile
|
||||
from fastapi import APIRouter, Depends, File, Form, HTTPException, Request, UploadFile, WebSocket
|
||||
from fastapi.responses import FileResponse
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from app.services.websocket_voice_manager import WebSocketVoiceManager
|
||||
|
||||
ws_manager = WebSocketVoiceManager()
|
||||
|
||||
from app.database.database import get_db
|
||||
from app.database.models import (
|
||||
OnboardingMessage,
|
||||
@@ -476,3 +480,54 @@ async def complete_voice_onboarding(
|
||||
print(f"[CompleteVoiceOnboarding Error]: {err}")
|
||||
traceback.print_exc()
|
||||
raise HTTPException(status_code=500, detail=str(err))
|
||||
|
||||
|
||||
@router.websocket("/ws/{session_id}")
|
||||
async def websocket_voice_onboarding_endpoint(websocket: WebSocket, session_id: str):
|
||||
await ws_manager.handle_websocket_session(websocket, session_id)
|
||||
|
||||
|
||||
@router.get("/fhir/{session_id}")
|
||||
async def get_session_fhir_export(
|
||||
session_id: str,
|
||||
db: Session = Depends(get_db),
|
||||
auth: AuthContext = Depends(get_auth_context)
|
||||
):
|
||||
"""
|
||||
Returns production-grade HL7 FHIR R4 Bundle JSON for 1-click import into hospital EMR/EHR systems (Epic, Cerner, AthenaHealth).
|
||||
Includes Patient, Encounter, Condition (Symptoms & History), MedicationStatement, and AllergyIntolerance resources.
|
||||
"""
|
||||
from app.services.fhir_exporter import export_session_to_fhir_bundle
|
||||
try:
|
||||
fhir_bundle = export_session_to_fhir_bundle(session_id, db)
|
||||
return fhir_bundle
|
||||
except ValueError as e:
|
||||
raise HTTPException(status_code=404, detail=str(e))
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=500, detail=f"FHIR Export Error: {str(e)}")
|
||||
|
||||
|
||||
@router.get("/soap-note/{session_id}")
|
||||
async def get_session_soap_note_export(
|
||||
session_id: str,
|
||||
format: str = "json",
|
||||
db: Session = Depends(get_db),
|
||||
auth: AuthContext = Depends(get_auth_context)
|
||||
):
|
||||
"""
|
||||
Compiles completed intake into a formal Doctor SOAP Note (Subjective, Objective, Assessment, Plan) with candidate ICD-10 & SNOMED CT codes.
|
||||
Pass format=html to download printable HTML report.
|
||||
"""
|
||||
from app.services.soap_note_generator import generate_soap_note, generate_soap_html_report
|
||||
from fastapi.responses import HTMLResponse
|
||||
try:
|
||||
soap_note = generate_soap_note(session_id, db)
|
||||
if format.lower() == "html":
|
||||
html_content = generate_soap_html_report(soap_note)
|
||||
return HTMLResponse(content=html_content)
|
||||
return soap_note
|
||||
except ValueError as e:
|
||||
raise HTTPException(status_code=404, detail=str(e))
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=500, detail=f"SOAP Note Error: {str(e)}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user