labscript 0.1.0

Prescription PDF generator with e-signature and QR verification
<div align="center">

# labscript

**Generate prescription PDFs with e-signatures and QR verification.**

[![Star](https://img.shields.io/github/stars/199-biotechnologies/labscript-cli?style=for-the-badge&color=yellow)](https://github.com/199-biotechnologies/labscript-cli/stargazers)
[![Follow @longevityboris](https://img.shields.io/badge/follow-%40longevityboris-black?style=for-the-badge&logo=x)](https://x.com/longevityboris)
[![Rust](https://img.shields.io/badge/rust-stable-orange?style=for-the-badge&logo=rust)](https://www.rust-lang.org/)
[![PDF](https://img.shields.io/badge/output-PDF-red?style=for-the-badge)](https://github.com/199-biotechnologies/labscript-cli)
[![License](https://img.shields.io/badge/license-proprietary-blue?style=for-the-badge)](https://github.com/199-biotechnologies/labscript-cli)

A Rust CLI that turns structured prescription data into professional PDFs. Each document carries a digital signature and a QR code that anyone can scan to verify it has not been tampered with. Starts in about 2 milliseconds.

[Install](#install) · [Quick Start](#quick-start) · [Features](#features) · [CLI Suite](#part-of-the-longevity-cli-suite) · [Contributing](#contributing)

</div>

---

## Why This Exists

Prescriptions are still written by hand or exported through clunky EMR interfaces. Neither fits into a modern clinical workflow.

labscript takes structured input -- a JSON file, stdin, or CLI flags -- and produces a clean, tamper-evident PDF. The QR code on each document encodes a SHA-256 hash of the prescription contents. Pharmacists or patients scan it to confirm nothing changed after signing.

One command. Deterministic output. No GUI, no cloud, no subscription.

## Install

```bash
cargo install --git https://github.com/199-biotechnologies/labscript-cli
```

Requires Rust 1.70+. Builds to a single static binary.

## How It Works

```
                    ┌──────────────────────────────┐
                    │      Structured Input         │
                    │  (JSON file / stdin / flags)  │
                    └──────────────┬───────────────┘
                    ┌──────────────────────────────┐
                    │      labscript generate       │
                    │                              │
                    │  • Validates all fields       │
                    │  • Renders prescription PDF   │
                    │  • Embeds e-signature (PNG)   │
                    │  • Generates QR verification  │
                    │  • SHA-256 content hash       │
                    └──────────────┬───────────────┘
                    ┌──────────────────────────────┐
                    │     prescription.pdf          │
                    │  Professional layout with     │
                    │  signature + scannable QR     │
                    └──────────────────────────────┘
```

## Quick Start

**From CLI flags:**

```bash
labscript generate \
  --patient-name "Jane Doe" \
  --patient-dob "1985-03-15" \
  --prescriber-name "Dr. Boris Djordjevic" \
  --prescriber-credentials "MD" \
  --prescriber-license "MD-12345" \
  --drug "Metformin" \
  --strength "500mg" \
  --form "tablet" \
  --quantity 60 \
  --sig "Take one tablet twice daily with meals" \
  --refills 3 \
  --diagnosis "Type 2 Diabetes" \
  --signature ./signature.png \
  --output metformin-rx.pdf
```

**From a JSON file:**

```bash
labscript generate --file prescription.json --output rx.pdf
```

**Piped from another tool:**

```bash
cat prescription.json | labscript generate --stdin --output rx.pdf
```

**Verify a prescription QR code:**

```bash
labscript verify "labscript:v1:abc123..."
```

Output is JSON when piped, human-readable tables on a TTY. Force JSON with `--json`.

## Features

### PDF Generation
- Professional prescription layout with patient and prescriber details
- Drug name, strength, form, quantity, sig, refills, and diagnosis fields
- Custom prescription date or automatic dating

### E-Signatures
- Embed a PNG signature image directly into the PDF
- Prescriber credentials and license number on every document

### QR Verification
- Each PDF carries a QR code encoding a SHA-256 hash of the prescription content
- `labscript verify` checks any scanned QR string against the expected hash
- Tamper-evident: changing any field invalidates the QR

### Input Flexibility
- CLI flags for scripting and one-off use
- JSON file input for batch workflows
- Stdin for piping from other tools in the suite

### Agent-Friendly
- `labscript agent-info` exposes machine-readable capabilities
- JSON output mode for AI agent consumption
- Exit codes: 0 success, 1 error, 2 config, 3 parse failure

## Part of the Longevity CLI Suite

labscript is one tool in a set of composable Rust CLIs built by [199 Biotechnologies](https://github.com/199-biotechnologies) for clinical biomarker analysis and longevity medicine.

| Tool | What it does |
|------|-------------|
| [labparse]https://github.com/199-biotechnologies/labparse-cli | Extract biomarkers from lab PDFs |
| [labassess]https://github.com/199-biotechnologies/labassess-cli | Score biomarkers against longevity-optimal ranges |
| [labstore]https://github.com/199-biotechnologies/labstore-cli | SQLite patient database for longitudinal tracking |
| **labscript** | Generate prescription PDFs with e-signatures and QR |

All tools communicate via JSON on stdout. Pipe them together.

## Contributing

199 Biotechnologies owns this software. We are not accepting outside contributions right now. Found a bug or want a feature? Open an issue.

## License

Proprietary. Copyright 2024-2025 [199 Biotechnologies](https://199biotechnologies.com). All rights reserved.

---

<div align="center">

Built by [199 Biotechnologies](https://199biotechnologies.com) · Follow [@longevityboris](https://x.com/longevityboris)

[![Star this repo](https://img.shields.io/github/stars/199-biotechnologies/labscript-cli?style=for-the-badge&color=yellow&label=star%20labscript)](https://github.com/199-biotechnologies/labscript-cli/stargazers)

</div>