File size: 1,606 Bytes
8d6e5f8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
"""Standalone Documentation Agent CLI. OWNER: Person A.

Run the agent without the orchestrator or UI::

    python -m app.agents.documentation.cli --patient p-001 --transcript "Doctor: ..."
    python -m app.agents.documentation.cli --patient p-001 --audio consult.wav
    python -m app.agents.documentation.cli --patient p-001 --transcript "..." --approve

Without an LLM key set the draft step will error from the router — use
``app.agents.documentation.mocks.fake_soap_draft`` for offline UI work.
"""

from __future__ import annotations

import argparse
import sys
from pathlib import Path

from app.agents.documentation.api import approve_draft, draft_soap


def _main() -> None:
    parser = argparse.ArgumentParser(description="Draft a SOAP note from a consult")
    parser.add_argument("--patient", required=True, help="patient id, e.g. p-001")
    src = parser.add_mutually_exclusive_group(required=True)
    src.add_argument("--transcript", help="consult transcript text")
    src.add_argument("--audio", type=Path, help="path to a consult audio file")
    parser.add_argument(
        "--approve",
        action="store_true",
        help="persist the draft to the patient wiki page after drafting",
    )
    args = parser.parse_args()

    draft = draft_soap(
        patient_id=args.patient,
        transcript=args.transcript,
        audio_path=args.audio,
    )

    print(draft.model_dump_json(indent=2))

    if args.approve:
        ref = approve_draft(draft)
        print(f"\nApproved -> {ref.page_path} @ {ref.version}", file=sys.stderr)


if __name__ == "__main__":
    _main()