CLI Usage
Testing / QA
Run these commands to confirm StructaMed works end-to-end (recommended before submission).
# Run full test suite
cargo test --all
# One-command smoke test
./scripts/smoke.sh
# Strict fixtures must exit 0
cargo run -- selftest --fixtures tests/fixtures/clean/soap --template soap --strict
cargo run -- selftest --fixtures tests/fixtures/clean/hp --template hp --strict
cargo run -- selftest --fixtures tests/fixtures/clean/discharge --template discharge --strict
Note: Product name is StructaMed; the CLI command/binary name is clinote.
clinote parse --input note.txt --format soap \
--out out.json --out-format json --bundle auto
clinote batch --input-dir notes --glob "*.txt" \
--format hp --out-dir outputs --out-format csv
clinote sample --out-dir samples --n 6 --bundles 2
clinote validate --config clinote.toml
CLI Commands
# Validate a note (strict mode + exit code 2 on errors)
clinote validate notes.txt --template soap --strict
# Preview detected sections with line counts
clinote preview notes.txt --template hp
# Selftest a directory (recursive) and export outputs
clinote selftest --fixtures tests/fixtures --template soap --out selftest_outputs
# Selftest with glob + JSON summary
clinote selftest --fixtures "tests/fixtures/*.txt" --template discharge --json
- Validate strict: missing required sections are errors (exit code 2). Non-strict treats them as warnings (exit code 0).
- Preview: prints detected sections plus line/character counts.
- Selftest: scans a folder or glob, validates notes, and reports totals + top failures.
Config reference
[formats.soap]
section_order = ["Subjective", "Objective", "Assessment", "Plan"]
heading_aliases = { "Hx" = "PMH", "Dx" = "Assessment" }
enable_fallback_heuristics = true
[bundle]
mode_default = "auto"
delimiters = ["----- NOTE -----", "=== VISIT ==="]
[csv]
layout = "wide"
glob_default = "*.txt"
Bundle mode
- auto: split only when delimiters or timestamps appear multiple times.
- on: attempt to split and warn if delimiters are not found.
- off: treat input as a single note.
Interactive mode
Use --interactive with parse to:
- Decide whether fallback heuristics should run.
- Select which sections to keep.
- Rename sections before rendering.
Complex bundles: issues and mitigations
- Ambiguous delimiters can cause false splits. StructaMed logs warnings and keeps the note intact when unsure.
- Mixed formats in a single file can map headings to the wrong target sections; interactive mode lets you confirm.
- Timestamp-only splits may fail when the same date appears inside a note; auto mode refuses weak splits.
- Heuristic headings can misclassify narrative text; you can disable heuristics or drop sections interactively.
Warnings
Warnings are serialized in JSON output and included in batch reports. They include codes, severity, and line spans.