File size: 1,900 Bytes
8af5905
 
022dba9
8af5905
 
 
 
 
 
 
 
 
 
 
f051f2e
 
 
 
 
 
 
 
 
8af5905
022dba9
 
 
 
8af5905
 
 
 
 
 
 
 
 
 
f051f2e
 
 
 
 
 
8af5905
f051f2e
 
8af5905
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
import json
from typing import Dict
from safety import POLICY_NOTICE

DECISION_FRAME = """FRAME:
- SAFETY/RISK: crowding proxy; p95 boarding time; # critical waits; isolation/telemetry constraints.
- CAPACITY: staffed beds now; free beds; unit occupancy & imbalance; EVS/transport turnaround.
- DISCHARGES: # ready now; # by noon; barriers (AH, placement, Rx, paperwork).
- ADMISSIONS: ED admits waiting (by service/needs); forecast next 6–24h; elective admits deferrable.
- STAFFING: RN/RT/Allied gaps; redeploy/OT/agency options.
- MATH: beds needed now to clear ED; additional buffer for next 12h; target occupancy.
- DECISION: ranked actions with owner, ETA, expected beds, and risks.
"""

EXEC_FRAME = """EXECUTIVE FRAME:
- OBJECTIVE: clarify success criteria, time horizon, and constraints.
- CONTEXT: scenario details, population, geography, cultural considerations.
- DATA INPUTS: population/community, health indicators, cost/ops, longitudinal outcomes.
- ANALYTICS: prioritization method, capacity simulation, cost model, outcome deltas.
- OUTPUTS: tables + bullets + assumptions + short narrative justifications.
"""

def build_system_preamble(snapshot: Dict, policy_context: str, computed_numbers: Dict, scenario_text: str = "", session_snips: str = "") -> str:
    return f"""
{POLICY_NOTICE}

Use (a) the snapshot JSON, (b) policy excerpts, (c) computed numbers, and (d) uploaded/scenario evidence
to recommend next actions and provide structured estimates with tables, bullets, and assumptions. Cite specific policies where applicable.

Policies & SOP Excerpts:
{policy_context}

Snapshot (JSON):
{json.dumps(snapshot, indent=2)}

Computed Numbers:
{json.dumps(computed_numbers, indent=2)}

Scenario (if provided):
{scenario_text if scenario_text else "(none)"}

Uploaded Evidence (session):
{session_snips if session_snips else "(none)"}

{DECISION_FRAME}

{EXEC_FRAME}
""".strip()