更新
This commit is contained in:
@@ -8,6 +8,7 @@ import time
|
||||
from collections.abc import Mapping
|
||||
from contextlib import suppress
|
||||
from datetime import date
|
||||
from io import BytesIO
|
||||
from os import PathLike
|
||||
from pathlib import Path
|
||||
from typing import Any, Final, Literal, Protocol
|
||||
@@ -109,6 +110,15 @@ class DoctorRepository(Protocol):
|
||||
) -> str:
|
||||
"""Upload one local note material and return its server URI."""
|
||||
|
||||
def upload_material_bytes(
|
||||
self,
|
||||
content: bytes,
|
||||
filename: str,
|
||||
material_type: Literal["image", "video", "file"],
|
||||
cid: int = 0,
|
||||
) -> str:
|
||||
"""Upload an in-memory capture and return its server URI."""
|
||||
|
||||
def get_prescription_template(self, template_id: int) -> PrescriptionTemplate:
|
||||
"""Return one prescription-library record."""
|
||||
|
||||
@@ -960,6 +970,34 @@ class RemoteDoctorRepository:
|
||||
)
|
||||
return _normalise_material_reference(payload, endpoint)
|
||||
|
||||
def upload_material_bytes(
|
||||
self,
|
||||
content: bytes,
|
||||
filename: str,
|
||||
material_type: Literal["image", "video", "file"],
|
||||
cid: int = 0,
|
||||
) -> str:
|
||||
"""Upload a trusted in-memory capture without a local plaintext file."""
|
||||
|
||||
if cid < 0:
|
||||
raise ValueError("cid must be non-negative")
|
||||
if not content:
|
||||
raise ValueError("material content must not be empty")
|
||||
if len(content) > 10 * 1024 * 1024:
|
||||
raise ValueError("material content exceeds 10 MB")
|
||||
safe_name = Path(filename).name.strip()
|
||||
if not safe_name or safe_name in {".", ".."}:
|
||||
raise ValueError("filename is required")
|
||||
kind = _material_kind(material_type)
|
||||
mime_type = mimetypes.guess_type(safe_name)[0] or "application/octet-stream"
|
||||
endpoint = f"upload/{kind}"
|
||||
payload = self.client.post_multipart(
|
||||
endpoint,
|
||||
files={"file": (safe_name, BytesIO(content), mime_type)},
|
||||
data={"cid": str(cid)},
|
||||
)
|
||||
return _normalise_material_reference(payload, endpoint)
|
||||
|
||||
def notify_assistant(self, appointment_id: int) -> Any:
|
||||
"""Ask the server to notify the assigned medical assistant."""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user