medforge 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
medforge-0.1.0/.envrc ADDED
@@ -0,0 +1 @@
1
+ use flake
@@ -0,0 +1,52 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main, master]
6
+ pull_request:
7
+ branches: [main, master]
8
+
9
+ env:
10
+ CARGO_TERM_COLOR: always
11
+
12
+ jobs:
13
+ # ── Rust tests ──────────────────────────────────────────────────────────────
14
+ rust-tests:
15
+ runs-on: ubuntu-latest
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+ - uses: dtolnay/rust-toolchain@stable
19
+ - run: cargo test --verbose
20
+
21
+ # ── Python tests (build extension + pytest) ────────────────────────────────
22
+ python-tests:
23
+ runs-on: ${{ matrix.os }}
24
+ strategy:
25
+ matrix:
26
+ os: [ubuntu-latest, macos-latest]
27
+ python-version: ["3.11", "3.12", "3.13"]
28
+ steps:
29
+ - uses: actions/checkout@v4
30
+ - uses: dtolnay/rust-toolchain@stable
31
+ - uses: actions/setup-python@v5
32
+ with:
33
+ python-version: ${{ matrix.python-version }}
34
+ - name: Install dependencies
35
+ run: |
36
+ python -m pip install --upgrade pip
37
+ pip install maturin pytest
38
+ - name: Build and install
39
+ run: maturin develop
40
+ - name: Run tests
41
+ run: python -m pytest tests/ -v
42
+
43
+ # ── Lint ────────────────────────────────────────────────────────────────────
44
+ lint:
45
+ runs-on: ubuntu-latest
46
+ steps:
47
+ - uses: actions/checkout@v4
48
+ - uses: dtolnay/rust-toolchain@stable
49
+ with:
50
+ components: clippy, rustfmt
51
+ - run: cargo fmt --check
52
+ - run: cargo clippy -- -D warnings
@@ -0,0 +1,77 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*"
7
+
8
+ permissions:
9
+ contents: read
10
+
11
+ jobs:
12
+ # ── Build wheels for each platform ─────────────────────────────────────────
13
+ build:
14
+ runs-on: ${{ matrix.os }}
15
+ strategy:
16
+ fail-fast: false
17
+ matrix:
18
+ include:
19
+ # Linux x86_64
20
+ - os: ubuntu-latest
21
+ target: x86_64
22
+ # Linux aarch64
23
+ - os: ubuntu-latest
24
+ target: aarch64
25
+ # macOS Apple Silicon
26
+ - os: macos-latest
27
+ target: aarch64
28
+ # Windows
29
+ - os: windows-latest
30
+ target: x64
31
+ steps:
32
+ - uses: actions/checkout@v4
33
+ - uses: actions/setup-python@v5
34
+ with:
35
+ python-version: "3.12"
36
+ - name: Build wheels
37
+ uses: PyO3/maturin-action@v1
38
+ with:
39
+ target: ${{ matrix.target }}
40
+ args: --release --out dist --interpreter 3.11 3.12 3.13
41
+ manylinux: auto
42
+ - uses: actions/upload-artifact@v4
43
+ with:
44
+ name: wheels-${{ matrix.os }}-${{ matrix.target }}
45
+ path: dist
46
+
47
+ # ── Build source distribution ──────────────────────────────────────────────
48
+ sdist:
49
+ runs-on: ubuntu-latest
50
+ steps:
51
+ - uses: actions/checkout@v4
52
+ - name: Build sdist
53
+ uses: PyO3/maturin-action@v1
54
+ with:
55
+ command: sdist
56
+ args: --out dist
57
+ - uses: actions/upload-artifact@v4
58
+ with:
59
+ name: wheels-sdist
60
+ path: dist
61
+
62
+ # ── Publish to PyPI ────────────────────────────────────────────────────────
63
+ publish:
64
+ needs: [build, sdist]
65
+ runs-on: ubuntu-latest
66
+ environment:
67
+ name: pypi
68
+ url: https://pypi.org/p/medforge
69
+ permissions:
70
+ id-token: write # trusted publishing
71
+ steps:
72
+ - uses: actions/download-artifact@v4
73
+ with:
74
+ pattern: wheels-*
75
+ merge-multiple: true
76
+ path: dist
77
+ - uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,23 @@
1
+ # Rust
2
+ /target
3
+ **/*.rs.bk
4
+ Cargo.lock
5
+
6
+ # Python
7
+ __pycache__/
8
+ *.py[cod]
9
+ *.egg-info/
10
+ dist/
11
+ *.so
12
+ *.dylib
13
+ *.whl
14
+
15
+ # Nix
16
+ .direnv/
17
+ result
18
+
19
+ # IDE
20
+ .idea/
21
+ .vscode/
22
+ *.swp
23
+ .venv-dev/
@@ -0,0 +1,243 @@
1
+ # This file is automatically @generated by Cargo.
2
+ # It is not intended for manual editing.
3
+ version = 4
4
+
5
+ [[package]]
6
+ name = "autocfg"
7
+ version = "1.5.0"
8
+ source = "registry+https://github.com/rust-lang/crates.io-index"
9
+ checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8"
10
+
11
+ [[package]]
12
+ name = "cfg-if"
13
+ version = "1.0.4"
14
+ source = "registry+https://github.com/rust-lang/crates.io-index"
15
+ checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
16
+
17
+ [[package]]
18
+ name = "heck"
19
+ version = "0.5.0"
20
+ source = "registry+https://github.com/rust-lang/crates.io-index"
21
+ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
22
+
23
+ [[package]]
24
+ name = "indoc"
25
+ version = "2.0.7"
26
+ source = "registry+https://github.com/rust-lang/crates.io-index"
27
+ checksum = "79cf5c93f93228cf8efb3ba362535fb11199ac548a09ce117c9b1adc3030d706"
28
+ dependencies = [
29
+ "rustversion",
30
+ ]
31
+
32
+ [[package]]
33
+ name = "itoa"
34
+ version = "1.0.17"
35
+ source = "registry+https://github.com/rust-lang/crates.io-index"
36
+ checksum = "92ecc6618181def0457392ccd0ee51198e065e016d1d527a7ac1b6dc7c1f09d2"
37
+
38
+ [[package]]
39
+ name = "libc"
40
+ version = "0.2.183"
41
+ source = "registry+https://github.com/rust-lang/crates.io-index"
42
+ checksum = "b5b646652bf6661599e1da8901b3b9522896f01e736bad5f723fe7a3a27f899d"
43
+
44
+ [[package]]
45
+ name = "medforge"
46
+ version = "0.1.0"
47
+ dependencies = [
48
+ "pyo3",
49
+ "serde",
50
+ "serde_json",
51
+ ]
52
+
53
+ [[package]]
54
+ name = "memchr"
55
+ version = "2.8.0"
56
+ source = "registry+https://github.com/rust-lang/crates.io-index"
57
+ checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79"
58
+
59
+ [[package]]
60
+ name = "memoffset"
61
+ version = "0.9.1"
62
+ source = "registry+https://github.com/rust-lang/crates.io-index"
63
+ checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a"
64
+ dependencies = [
65
+ "autocfg",
66
+ ]
67
+
68
+ [[package]]
69
+ name = "once_cell"
70
+ version = "1.21.4"
71
+ source = "registry+https://github.com/rust-lang/crates.io-index"
72
+ checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
73
+
74
+ [[package]]
75
+ name = "portable-atomic"
76
+ version = "1.13.1"
77
+ source = "registry+https://github.com/rust-lang/crates.io-index"
78
+ checksum = "c33a9471896f1c69cecef8d20cbe2f7accd12527ce60845ff44c153bb2a21b49"
79
+
80
+ [[package]]
81
+ name = "proc-macro2"
82
+ version = "1.0.106"
83
+ source = "registry+https://github.com/rust-lang/crates.io-index"
84
+ checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934"
85
+ dependencies = [
86
+ "unicode-ident",
87
+ ]
88
+
89
+ [[package]]
90
+ name = "pyo3"
91
+ version = "0.23.5"
92
+ source = "registry+https://github.com/rust-lang/crates.io-index"
93
+ checksum = "7778bffd85cf38175ac1f545509665d0b9b92a198ca7941f131f85f7a4f9a872"
94
+ dependencies = [
95
+ "cfg-if",
96
+ "indoc",
97
+ "libc",
98
+ "memoffset",
99
+ "once_cell",
100
+ "portable-atomic",
101
+ "pyo3-build-config",
102
+ "pyo3-ffi",
103
+ "pyo3-macros",
104
+ "unindent",
105
+ ]
106
+
107
+ [[package]]
108
+ name = "pyo3-build-config"
109
+ version = "0.23.5"
110
+ source = "registry+https://github.com/rust-lang/crates.io-index"
111
+ checksum = "94f6cbe86ef3bf18998d9df6e0f3fc1050a8c5efa409bf712e661a4366e010fb"
112
+ dependencies = [
113
+ "once_cell",
114
+ "target-lexicon",
115
+ ]
116
+
117
+ [[package]]
118
+ name = "pyo3-ffi"
119
+ version = "0.23.5"
120
+ source = "registry+https://github.com/rust-lang/crates.io-index"
121
+ checksum = "e9f1b4c431c0bb1c8fb0a338709859eed0d030ff6daa34368d3b152a63dfdd8d"
122
+ dependencies = [
123
+ "libc",
124
+ "pyo3-build-config",
125
+ ]
126
+
127
+ [[package]]
128
+ name = "pyo3-macros"
129
+ version = "0.23.5"
130
+ source = "registry+https://github.com/rust-lang/crates.io-index"
131
+ checksum = "fbc2201328f63c4710f68abdf653c89d8dbc2858b88c5d88b0ff38a75288a9da"
132
+ dependencies = [
133
+ "proc-macro2",
134
+ "pyo3-macros-backend",
135
+ "quote",
136
+ "syn",
137
+ ]
138
+
139
+ [[package]]
140
+ name = "pyo3-macros-backend"
141
+ version = "0.23.5"
142
+ source = "registry+https://github.com/rust-lang/crates.io-index"
143
+ checksum = "fca6726ad0f3da9c9de093d6f116a93c1a38e417ed73bf138472cf4064f72028"
144
+ dependencies = [
145
+ "heck",
146
+ "proc-macro2",
147
+ "pyo3-build-config",
148
+ "quote",
149
+ "syn",
150
+ ]
151
+
152
+ [[package]]
153
+ name = "quote"
154
+ version = "1.0.45"
155
+ source = "registry+https://github.com/rust-lang/crates.io-index"
156
+ checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924"
157
+ dependencies = [
158
+ "proc-macro2",
159
+ ]
160
+
161
+ [[package]]
162
+ name = "rustversion"
163
+ version = "1.0.22"
164
+ source = "registry+https://github.com/rust-lang/crates.io-index"
165
+ checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d"
166
+
167
+ [[package]]
168
+ name = "serde"
169
+ version = "1.0.228"
170
+ source = "registry+https://github.com/rust-lang/crates.io-index"
171
+ checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e"
172
+ dependencies = [
173
+ "serde_core",
174
+ "serde_derive",
175
+ ]
176
+
177
+ [[package]]
178
+ name = "serde_core"
179
+ version = "1.0.228"
180
+ source = "registry+https://github.com/rust-lang/crates.io-index"
181
+ checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad"
182
+ dependencies = [
183
+ "serde_derive",
184
+ ]
185
+
186
+ [[package]]
187
+ name = "serde_derive"
188
+ version = "1.0.228"
189
+ source = "registry+https://github.com/rust-lang/crates.io-index"
190
+ checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79"
191
+ dependencies = [
192
+ "proc-macro2",
193
+ "quote",
194
+ "syn",
195
+ ]
196
+
197
+ [[package]]
198
+ name = "serde_json"
199
+ version = "1.0.149"
200
+ source = "registry+https://github.com/rust-lang/crates.io-index"
201
+ checksum = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86"
202
+ dependencies = [
203
+ "itoa",
204
+ "memchr",
205
+ "serde",
206
+ "serde_core",
207
+ "zmij",
208
+ ]
209
+
210
+ [[package]]
211
+ name = "syn"
212
+ version = "2.0.117"
213
+ source = "registry+https://github.com/rust-lang/crates.io-index"
214
+ checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99"
215
+ dependencies = [
216
+ "proc-macro2",
217
+ "quote",
218
+ "unicode-ident",
219
+ ]
220
+
221
+ [[package]]
222
+ name = "target-lexicon"
223
+ version = "0.12.16"
224
+ source = "registry+https://github.com/rust-lang/crates.io-index"
225
+ checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1"
226
+
227
+ [[package]]
228
+ name = "unicode-ident"
229
+ version = "1.0.24"
230
+ source = "registry+https://github.com/rust-lang/crates.io-index"
231
+ checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
232
+
233
+ [[package]]
234
+ name = "unindent"
235
+ version = "0.2.4"
236
+ source = "registry+https://github.com/rust-lang/crates.io-index"
237
+ checksum = "7264e107f553ccae879d21fbea1d6724ac785e8c3bfc762137959b5802826ef3"
238
+
239
+ [[package]]
240
+ name = "zmij"
241
+ version = "1.0.21"
242
+ source = "registry+https://github.com/rust-lang/crates.io-index"
243
+ checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa"
@@ -0,0 +1,16 @@
1
+ [package]
2
+ name = "medforge"
3
+ version = "0.1.0"
4
+ edition = "2024"
5
+ description = "High-performance HL7v2 message parser with Python bindings"
6
+ license = "MIT"
7
+ readme = "README.md"
8
+
9
+ [lib]
10
+ name = "medforge"
11
+ crate-type = ["cdylib"]
12
+
13
+ [dependencies]
14
+ pyo3 = { version = "0.23", features = ["extension-module"] }
15
+ serde = { version = "1", features = ["derive"] }
16
+ serde_json = "1"
medforge-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ironpipe contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,101 @@
1
+ Metadata-Version: 2.4
2
+ Name: medforge
3
+ Version: 0.1.0
4
+ Classifier: Programming Language :: Rust
5
+ Classifier: Programming Language :: Python :: Implementation :: CPython
6
+ Classifier: Programming Language :: Python :: 3.11
7
+ Classifier: Programming Language :: Python :: 3.12
8
+ Classifier: Programming Language :: Python :: 3.13
9
+ Classifier: Intended Audience :: Healthcare Industry
10
+ Classifier: Topic :: Scientific/Engineering :: Medical Science Apps.
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Typing :: Typed
14
+ Requires-Dist: pytest ; extra == 'dev'
15
+ Requires-Dist: pytest-benchmark ; extra == 'dev'
16
+ Provides-Extra: dev
17
+ License-File: LICENSE
18
+ Summary: High-performance HL7v2 message parser powered by Rust
19
+ Keywords: hl7,hl7v2,parser,healthcare,medical,rust
20
+ License: MIT
21
+ Requires-Python: >=3.11
22
+ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
23
+ Project-URL: Issues, https://github.com/medforge/medforge/issues
24
+ Project-URL: Repository, https://github.com/medforge/medforge
25
+
26
+ # medforge 🔧
27
+
28
+ High-performance HL7v2 message parser for Python, powered by Rust.
29
+
30
+ ## Features
31
+
32
+ - **Fast** — Rust core for 10-50× faster parsing vs pure-Python HL7 libraries
33
+ - **Complete** — Full HL7v2 hierarchy: Message → Segment → Field → Component → Sub-component
34
+ - **Ergonomic** — Pythonic API with terser-style path access (`msg["PID-5-1"]`)
35
+ - **MLLP-aware** — Automatic detection and stripping of MLLP framing
36
+ - **Escape-aware** — Decodes HL7 escape sequences (`\F\`, `\S\`, `\T\`, `\R\`, `\E\`)
37
+ - **Serializable** — Built-in `.to_dict()` and `.to_json()` methods
38
+
39
+ ## Installation
40
+
41
+ ```bash
42
+ pip install medforge
43
+ ```
44
+
45
+ ### From source (requires Rust)
46
+
47
+ ```bash
48
+ git clone https://github.com/your-org/medforge.git
49
+ cd medforge
50
+ nix develop # or install Rust + maturin manually
51
+ maturin develop
52
+ ```
53
+
54
+ ## Quick Start
55
+
56
+ ```python
57
+ import medforge
58
+
59
+ msg = medforge.parse(
60
+ "MSH|^~\\&|EPIC|HOSPITAL|RECV|FAC|20260318||ADT^A01^ADT_A01|MSG001|P|2.5.1\r"
61
+ "PID|1||MRN12345^^^MRN||DOE^JANE^M^^DR||19850315|F\r"
62
+ "PV1|1|I|4EAST^401^1^^^N||||1234^SMITH^ROBERT^J^^^MD\r"
63
+ "DG1|1||I10^Essential Hypertension^ICD10||20260318|A"
64
+ )
65
+
66
+ # Segment access
67
+ pid = msg.segment("PID")
68
+ all_dg1 = msg.segments_by_name("DG1")
69
+
70
+ # Field access (1-indexed, per HL7 spec)
71
+ patient_name = pid.field(5) # Field("DOE^JANE^M^^DR")
72
+ patient_name.component(1) # "DOE"
73
+ patient_name.component(2) # "JANE"
74
+
75
+ # Terser-style shorthand
76
+ msg["PID-5-1"] # "DOE"
77
+ msg["MSH-9-1"] # "ADT"
78
+
79
+ # MSH convenience properties
80
+ msg.message_type # ("ADT", "A01")
81
+ msg.control_id # "MSG001"
82
+ msg.version # "2.5.1"
83
+
84
+ # Serialization
85
+ msg.to_dict() # Python dict
86
+ msg.to_json() # JSON string
87
+ ```
88
+
89
+ ## Development
90
+
91
+ ```bash
92
+ nix develop # enter dev shell
93
+ maturin develop # build + install in dev mode
94
+ cargo test # Rust tests
95
+ python -m pytest tests/ -v # Python tests
96
+ ```
97
+
98
+ ## License
99
+
100
+ MIT
101
+
@@ -0,0 +1,75 @@
1
+ # medforge 🔧
2
+
3
+ High-performance HL7v2 message parser for Python, powered by Rust.
4
+
5
+ ## Features
6
+
7
+ - **Fast** — Rust core for 10-50× faster parsing vs pure-Python HL7 libraries
8
+ - **Complete** — Full HL7v2 hierarchy: Message → Segment → Field → Component → Sub-component
9
+ - **Ergonomic** — Pythonic API with terser-style path access (`msg["PID-5-1"]`)
10
+ - **MLLP-aware** — Automatic detection and stripping of MLLP framing
11
+ - **Escape-aware** — Decodes HL7 escape sequences (`\F\`, `\S\`, `\T\`, `\R\`, `\E\`)
12
+ - **Serializable** — Built-in `.to_dict()` and `.to_json()` methods
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ pip install medforge
18
+ ```
19
+
20
+ ### From source (requires Rust)
21
+
22
+ ```bash
23
+ git clone https://github.com/your-org/medforge.git
24
+ cd medforge
25
+ nix develop # or install Rust + maturin manually
26
+ maturin develop
27
+ ```
28
+
29
+ ## Quick Start
30
+
31
+ ```python
32
+ import medforge
33
+
34
+ msg = medforge.parse(
35
+ "MSH|^~\\&|EPIC|HOSPITAL|RECV|FAC|20260318||ADT^A01^ADT_A01|MSG001|P|2.5.1\r"
36
+ "PID|1||MRN12345^^^MRN||DOE^JANE^M^^DR||19850315|F\r"
37
+ "PV1|1|I|4EAST^401^1^^^N||||1234^SMITH^ROBERT^J^^^MD\r"
38
+ "DG1|1||I10^Essential Hypertension^ICD10||20260318|A"
39
+ )
40
+
41
+ # Segment access
42
+ pid = msg.segment("PID")
43
+ all_dg1 = msg.segments_by_name("DG1")
44
+
45
+ # Field access (1-indexed, per HL7 spec)
46
+ patient_name = pid.field(5) # Field("DOE^JANE^M^^DR")
47
+ patient_name.component(1) # "DOE"
48
+ patient_name.component(2) # "JANE"
49
+
50
+ # Terser-style shorthand
51
+ msg["PID-5-1"] # "DOE"
52
+ msg["MSH-9-1"] # "ADT"
53
+
54
+ # MSH convenience properties
55
+ msg.message_type # ("ADT", "A01")
56
+ msg.control_id # "MSG001"
57
+ msg.version # "2.5.1"
58
+
59
+ # Serialization
60
+ msg.to_dict() # Python dict
61
+ msg.to_json() # JSON string
62
+ ```
63
+
64
+ ## Development
65
+
66
+ ```bash
67
+ nix develop # enter dev shell
68
+ maturin develop # build + install in dev mode
69
+ cargo test # Rust tests
70
+ python -m pytest tests/ -v # Python tests
71
+ ```
72
+
73
+ ## License
74
+
75
+ MIT