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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
use clap::{Parser, Subcommand};
#[derive(Parser)]
#[command(
name = "labscript",
version,
about = "Prescription PDF generator with e-signature and QR verification"
)]
pub struct Cli {
/// Force JSON output (default when piped)
#[arg(long, global = true)]
pub json: bool,
#[command(subcommand)]
pub command: Commands,
}
#[derive(Subcommand)]
pub enum Commands {
/// Generate a prescription PDF
Generate {
// ── Patient fields ──
/// Patient full name
#[arg(long)]
patient_name: Option<String>,
/// Patient date of birth (YYYY-MM-DD)
#[arg(long)]
patient_dob: Option<String>,
/// Patient address
#[arg(long)]
patient_address: Option<String>,
// ── Prescriber fields ──
/// Prescriber name
#[arg(long)]
prescriber_name: Option<String>,
/// Prescriber credentials (e.g. "MD, PhD")
#[arg(long)]
prescriber_credentials: Option<String>,
/// Prescriber license number
#[arg(long)]
prescriber_license: Option<String>,
/// Prescriber address
#[arg(long)]
prescriber_address: Option<String>,
// ── Medication fields (single medication via CLI) ──
/// Drug name
#[arg(long)]
drug: Option<String>,
/// Drug strength (e.g. "500mg")
#[arg(long)]
strength: Option<String>,
/// Drug form (e.g. "tablet")
#[arg(long)]
form: Option<String>,
/// Quantity to dispense
#[arg(long)]
quantity: Option<u32>,
/// Sig (directions for use)
#[arg(long)]
sig: Option<String>,
/// Number of refills
#[arg(long)]
refills: Option<u32>,
// ── Optional fields ──
/// Diagnosis
#[arg(long)]
diagnosis: Option<String>,
/// Additional notes
#[arg(long)]
notes: Option<String>,
/// Prescription date (YYYY-MM-DD, defaults to today)
#[arg(long)]
date: Option<String>,
/// Path to signature image (PNG)
#[arg(long)]
signature: Option<String>,
/// Output PDF file path
#[arg(long, default_value = "prescription.pdf")]
output: String,
/// Read prescription from JSON file
#[arg(long)]
file: Option<String>,
/// Read prescription JSON from stdin
#[arg(long)]
stdin: bool,
},
/// Verify a QR code from a scanned prescription
Verify {
/// QR code string (labscript:v1:uuid:hash:timestamp)
qr_string: String,
},
/// Show agent-info for AI consumption
AgentInfo,
}