- Add FastAPI routes for surgery start/end, results, pending confirmation (WAV upload), and health checks. - Implement RTSP/Hikvision capture, consumable classification, session manager, MinIO/Baidu voice resolution, and DB persistence. - Add documentation (client API, video backends, staging checklist) and sample camera/RTSP config. - Add pytest suite (API contract, session manager, voice, repositories, pipeline persistence) and httpx dev dependency. - Replace deprecated HTTP_422_UNPROCESSABLE_ENTITY with HTTP_422_UNPROCESSABLE_CONTENT. - Fix SurgeryPipeline DB reads to use an explicit transaction with autobegin disabled. Made-with: Cursor
47 lines
1.4 KiB
Python
47 lines
1.4 KiB
Python
from __future__ import annotations
|
|
|
|
from datetime import datetime, timezone
|
|
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
|
|
from app.db.models import VoiceConfirmationAudit
|
|
|
|
|
|
class VoiceAuditRepository:
|
|
"""Persist voice confirmation audit rows."""
|
|
|
|
async def save_audit(
|
|
self,
|
|
session: AsyncSession,
|
|
*,
|
|
surgery_id: str,
|
|
confirmation_id: str,
|
|
status: str,
|
|
audio_object_key: str | None,
|
|
audio_content_type: str | None,
|
|
audio_size_bytes: int | None,
|
|
audio_sha256: str | None,
|
|
asr_text: str | None,
|
|
resolved_label: str | None,
|
|
options_snapshot_json: str | None,
|
|
error_message: str | None,
|
|
created_at: datetime | None = None,
|
|
) -> None:
|
|
when = created_at or datetime.now(timezone.utc)
|
|
row = VoiceConfirmationAudit(
|
|
surgery_id=surgery_id,
|
|
confirmation_id=confirmation_id,
|
|
status=status,
|
|
audio_object_key=audio_object_key,
|
|
audio_content_type=audio_content_type,
|
|
audio_size_bytes=audio_size_bytes,
|
|
audio_sha256=audio_sha256,
|
|
asr_text=asr_text,
|
|
resolved_label=resolved_label,
|
|
options_snapshot_json=options_snapshot_json,
|
|
error_message=error_message,
|
|
created_at=when,
|
|
)
|
|
session.add(row)
|
|
await session.flush()
|