| Crates.io | medical_parser |
| lib.rs | medical_parser |
| version | 0.1.1 |
| created_at | 2025-11-05 14:52:56.081211+00 |
| updated_at | 2025-11-05 15:09:22.215744+00 |
| description | A parser for medical-data markup in an XML-like format. |
| homepage | |
| repository | |
| max_upload_size | |
| id | 1918117 |
| size | 18,407 |
This Rust library provides a simple XML-like parser for medical patient records. It extracts structured information about patients, their personal data, and visit histories, using the pest parsing framework.
<patient>, <name>, <age>, and optional <visit> sections.Patient and Visit records that can be consumed programmatically.A XML document consists of one or more <patient> elements. Each patient must define a <name> and <age> tag; visits are optional and may appear multiple times. Every visit is built from optional <diagnosis>, <temperature>, and <notes> tags.
XML file ──► parse medical document ──► Patient & Visit structures ──► CLI summary & analytics helpers
pest parses the XML grammar described below.Patient and Visit structures.src/grammar.pest)file = { SOI ~ patient+ ~ EOI }
patient = { "<patient>" ~ name ~ age ~ visit* ~ "</patient>" }
visit = { "<visit>" ~ (diagnosis | temperature | notes)* ~ "</visit>" }
name = { "<name>" ~ text ~ "</name>" }
age = { "<age>" ~ number ~ "</age>" }
diagnosis = { "<diagnosis>" ~ text ~ "</diagnosis>" }
temperature = { "<temperature>" ~ number ~ "</temperature>" }
notes = { "<notes>" ~ text ~ "</notes>" }
text = @{ (!"<" ~ ANY)+ }
number = @{ "-"? ~ ASCII_DIGIT+ ~ ("." ~ ASCII_DIGIT+)? }
WHITESPACE = _{ " " | "\t" | "\r" | "\n" }
parse_medical_document converts raw XML into typed data.Patient and Visit structs expose parsed fields for further analytics.print_patients, count_patients) support quick reporting.thiserror for library code and anyhow in tests to keep diagnostics ergonomic.Author: Anna Rechkalova (NaUKMA SE-4) with the support of the Ukrainian Rust community.