ehrextract 0.2.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.
- ehrextract-0.2.0/LICENSE +205 -0
- ehrextract-0.2.0/NOTICE +185 -0
- ehrextract-0.2.0/PKG-INFO +165 -0
- ehrextract-0.2.0/README.md +127 -0
- ehrextract-0.2.0/pyproject.toml +73 -0
- ehrextract-0.2.0/setup.cfg +4 -0
- ehrextract-0.2.0/src/ehrextract/LICENSE +205 -0
- ehrextract-0.2.0/src/ehrextract/NOTICE +185 -0
- ehrextract-0.2.0/src/ehrextract/__init__.py +28 -0
- ehrextract-0.2.0/src/ehrextract/__main__.py +6 -0
- ehrextract-0.2.0/src/ehrextract/_version.py +3 -0
- ehrextract-0.2.0/src/ehrextract/cli.py +136 -0
- ehrextract-0.2.0/src/ehrextract/io.py +70 -0
- ehrextract-0.2.0/src/ehrextract/pipeline.py +551 -0
- ehrextract-0.2.0/src/ehrextract/providers.py +390 -0
- ehrextract-0.2.0/src/ehrextract/py.typed +0 -0
- ehrextract-0.2.0/src/ehrextract/schema.py +330 -0
- ehrextract-0.2.0/src/ehrextract/tasks/clinical_vars.yaml +55 -0
- ehrextract-0.2.0/src/ehrextract/tasks/comorbidity.yaml +129 -0
- ehrextract-0.2.0/src/ehrextract/tasks/full.yaml +180 -0
- ehrextract-0.2.0/src/ehrextract.egg-info/PKG-INFO +165 -0
- ehrextract-0.2.0/src/ehrextract.egg-info/SOURCES.txt +24 -0
- ehrextract-0.2.0/src/ehrextract.egg-info/dependency_links.txt +1 -0
- ehrextract-0.2.0/src/ehrextract.egg-info/entry_points.txt +2 -0
- ehrextract-0.2.0/src/ehrextract.egg-info/requires.txt +19 -0
- ehrextract-0.2.0/src/ehrextract.egg-info/top_level.txt +1 -0
ehrextract-0.2.0/LICENSE
ADDED
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
Copyright (c) 2026 Chen Zhang, Yibing Xia, Sanjay Mahant, Nathan Taback,
|
|
2
|
+
The Hospital for Sick Children, and the University of Toronto.
|
|
3
|
+
All rights reserved.
|
|
4
|
+
|
|
5
|
+
Apache License
|
|
6
|
+
Version 2.0, January 2004
|
|
7
|
+
http://www.apache.org/licenses/
|
|
8
|
+
|
|
9
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
10
|
+
|
|
11
|
+
1. Definitions.
|
|
12
|
+
|
|
13
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
14
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
15
|
+
|
|
16
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
17
|
+
the copyright owner that is granting the License.
|
|
18
|
+
|
|
19
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
20
|
+
other entities that control, are controlled by, or are under common
|
|
21
|
+
control with that entity. For the purposes of this definition,
|
|
22
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
23
|
+
direction or management of such entity, whether by contract or
|
|
24
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
25
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
26
|
+
|
|
27
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
28
|
+
exercising permissions granted by this License.
|
|
29
|
+
|
|
30
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
31
|
+
including but not limited to software source code, documentation
|
|
32
|
+
source, and configuration files.
|
|
33
|
+
|
|
34
|
+
"Object" form shall mean any form resulting from mechanical
|
|
35
|
+
transformation or translation of a Source form, including but
|
|
36
|
+
not limited to compiled object code, generated documentation,
|
|
37
|
+
and conversions to other media types.
|
|
38
|
+
|
|
39
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
40
|
+
Object form, made available under the License, as indicated by a
|
|
41
|
+
copyright notice that is included in or attached to the work
|
|
42
|
+
(an example is provided in the Appendix below).
|
|
43
|
+
|
|
44
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
45
|
+
form, that is based on (or derived from) the Work and for which the
|
|
46
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
47
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
48
|
+
of this License, Derivative Works shall not include works that remain
|
|
49
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
50
|
+
the Work and Derivative Works thereof.
|
|
51
|
+
|
|
52
|
+
"Contribution" shall mean any work of authorship, including
|
|
53
|
+
the original version of the Work and any modifications or additions
|
|
54
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
55
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
56
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
57
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
58
|
+
means any form of electronic, verbal, or written communication sent
|
|
59
|
+
to the Licensor or its representatives, including but not limited to
|
|
60
|
+
communication on electronic mailing lists, source code control systems,
|
|
61
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
62
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
63
|
+
excluding communication that is conspicuously marked or otherwise
|
|
64
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
65
|
+
|
|
66
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
67
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
68
|
+
subsequently incorporated within the Work.
|
|
69
|
+
|
|
70
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
71
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
72
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
73
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
74
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
75
|
+
Work and such Derivative Works in Source or Object form.
|
|
76
|
+
|
|
77
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
78
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
79
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
80
|
+
(except as stated in this section) patent license to make, have made,
|
|
81
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
82
|
+
where such license applies only to those patent claims licensable
|
|
83
|
+
by such Contributor that are necessarily infringed by their
|
|
84
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
85
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
86
|
+
institute patent litigation against any entity (including a
|
|
87
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
88
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
89
|
+
or contributory patent infringement, then any patent licenses
|
|
90
|
+
granted to You under this License for that Work shall terminate
|
|
91
|
+
as of the date such litigation is filed.
|
|
92
|
+
|
|
93
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
94
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
95
|
+
modifications, and in Source or Object form, provided that You
|
|
96
|
+
meet the following conditions:
|
|
97
|
+
|
|
98
|
+
(a) You must give any other recipients of the Work or
|
|
99
|
+
Derivative Works a copy of this License; and
|
|
100
|
+
|
|
101
|
+
(b) You must cause any modified files to carry prominent notices
|
|
102
|
+
stating that You changed the files; and
|
|
103
|
+
|
|
104
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
105
|
+
that You distribute, all copyright, patent, trademark, and
|
|
106
|
+
attribution notices from the Source form of the Work,
|
|
107
|
+
excluding those notices that do not pertain to any part of
|
|
108
|
+
the Derivative Works; and
|
|
109
|
+
|
|
110
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
111
|
+
distribution, then any Derivative Works that You distribute must
|
|
112
|
+
include a readable copy of the attribution notices contained
|
|
113
|
+
within such NOTICE file, excluding those notices that do not
|
|
114
|
+
pertain to any part of the Derivative Works, in at least one
|
|
115
|
+
of the following places: within a NOTICE text file distributed
|
|
116
|
+
as part of the Derivative Works; within the Source form or
|
|
117
|
+
documentation, if provided along with the Derivative Works; or,
|
|
118
|
+
within a display generated by the Derivative Works, if and
|
|
119
|
+
wherever such third-party notices normally appear. The contents
|
|
120
|
+
of the NOTICE file are for informational purposes only and
|
|
121
|
+
do not modify the License. You may add Your own attribution
|
|
122
|
+
notices within Derivative Works that You distribute, alongside
|
|
123
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
124
|
+
that such additional attribution notices cannot be construed
|
|
125
|
+
as modifying the License.
|
|
126
|
+
|
|
127
|
+
You may add Your own copyright statement to Your modifications and
|
|
128
|
+
may provide additional or different license terms and conditions
|
|
129
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
130
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
131
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
132
|
+
the conditions stated in this License.
|
|
133
|
+
|
|
134
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
135
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
136
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
137
|
+
this License, without any additional terms or conditions.
|
|
138
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
139
|
+
the terms of any separate license agreement you may have executed
|
|
140
|
+
with Licensor regarding such Contributions.
|
|
141
|
+
|
|
142
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
143
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
144
|
+
except as required for reasonable and customary use in describing the
|
|
145
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
146
|
+
|
|
147
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
148
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
149
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
150
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
151
|
+
implied, including, without limitation, any warranties or conditions
|
|
152
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
153
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
154
|
+
appropriateness of using or redistributing the Work and assume any
|
|
155
|
+
risks associated with Your exercise of permissions under this License.
|
|
156
|
+
|
|
157
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
158
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
159
|
+
unless required by applicable law (such as deliberate and grossly
|
|
160
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
161
|
+
liable to You for damages, including any direct, indirect, special,
|
|
162
|
+
incidental, or consequential damages of any character arising as a
|
|
163
|
+
result of this License or out of the use or inability to use the
|
|
164
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
165
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
166
|
+
other commercial damages or losses), even if such Contributor
|
|
167
|
+
has been advised of the possibility of such damages.
|
|
168
|
+
|
|
169
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
170
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
171
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
172
|
+
or other liability obligations and/or rights consistent with this
|
|
173
|
+
License. However, in accepting such obligations, You may act only
|
|
174
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
175
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
176
|
+
defend, and hold each Contributor harmless for any liability
|
|
177
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
178
|
+
of your accepting any such warranty or additional liability.
|
|
179
|
+
|
|
180
|
+
END OF TERMS AND CONDITIONS
|
|
181
|
+
|
|
182
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
183
|
+
|
|
184
|
+
To apply the Apache License to your work, attach the following
|
|
185
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
186
|
+
replaced with your own identifying information. (Don't include
|
|
187
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
188
|
+
comment syntax for the file format. We also recommend that a
|
|
189
|
+
file or class name and description of purpose be included on the
|
|
190
|
+
same "printed page" as the copyright notice for easier
|
|
191
|
+
identification within third-party archives.
|
|
192
|
+
|
|
193
|
+
Copyright [yyyy] [name of copyright owner]
|
|
194
|
+
|
|
195
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
196
|
+
you may not use this file except in compliance with the License.
|
|
197
|
+
You may obtain a copy of the License at
|
|
198
|
+
|
|
199
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
200
|
+
|
|
201
|
+
Unless required by applicable law or agreed to in writing, software
|
|
202
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
203
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
204
|
+
See the License for the specific language governing permissions and
|
|
205
|
+
limitations under the License.
|
ehrextract-0.2.0/NOTICE
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
ehrextract
|
|
2
|
+
Copyright (c) 2026 Chen Zhang, Yibing Xia, Sanjay Mahant, Nathan Taback,
|
|
3
|
+
The Hospital for Sick Children, and the University of Toronto.
|
|
4
|
+
All rights reserved.
|
|
5
|
+
|
|
6
|
+
This product is licensed under the Apache License, Version 2.0 (the
|
|
7
|
+
"License"). You may obtain a copy of the License at
|
|
8
|
+
|
|
9
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
|
|
11
|
+
The following terms supplement, but do not override, the License.
|
|
12
|
+
|
|
13
|
+
================================================================
|
|
14
|
+
1. Authors and institutions
|
|
15
|
+
================================================================
|
|
16
|
+
|
|
17
|
+
ehrextract was created by:
|
|
18
|
+
|
|
19
|
+
Chen Zhang (lead author)
|
|
20
|
+
Yibing Xia (co-author)
|
|
21
|
+
Sanjay Mahant, MD (supervisor; The Hospital for Sick Children)
|
|
22
|
+
Nathan Taback, PhD (supervisor; University of Toronto)
|
|
23
|
+
|
|
24
|
+
at:
|
|
25
|
+
|
|
26
|
+
The Hospital for Sick Children (SickKids), Toronto, Canada
|
|
27
|
+
University of Toronto, Toronto, Canada
|
|
28
|
+
|
|
29
|
+
================================================================
|
|
30
|
+
2. Trademark and endorsement
|
|
31
|
+
================================================================
|
|
32
|
+
|
|
33
|
+
Neither the names "The Hospital for Sick Children", "SickKids",
|
|
34
|
+
"University of Toronto", "U of T", nor the names of any of the authors
|
|
35
|
+
listed above may be used to endorse or promote products derived from
|
|
36
|
+
this Software, or to imply institutional review, approval, or
|
|
37
|
+
validation of any derivative work, without prior written permission
|
|
38
|
+
from the relevant institution or individual.
|
|
39
|
+
|
|
40
|
+
The presence of these names in copyright notices, attribution
|
|
41
|
+
documentation, and citations is permitted and required by the License;
|
|
42
|
+
endorsement of derivative products is not.
|
|
43
|
+
|
|
44
|
+
================================================================
|
|
45
|
+
3. Not a medical device
|
|
46
|
+
================================================================
|
|
47
|
+
|
|
48
|
+
ehrextract IS NOT A MEDICAL DEVICE. It has not been cleared, certified,
|
|
49
|
+
or approved by:
|
|
50
|
+
|
|
51
|
+
- the U.S. Food and Drug Administration (FDA),
|
|
52
|
+
- Health Canada,
|
|
53
|
+
- the European Medicines Agency (EMA), or
|
|
54
|
+
- any other regulatory body.
|
|
55
|
+
|
|
56
|
+
It has not been validated for use in clinical decision-making, patient
|
|
57
|
+
diagnosis, treatment planning, triage, prognostic assessment, or any
|
|
58
|
+
other application that affects patient care. Users who deploy
|
|
59
|
+
ehrextract in any setting where its outputs may influence clinical
|
|
60
|
+
decisions do so entirely at their own risk and assume sole
|
|
61
|
+
responsibility for any harm that results.
|
|
62
|
+
|
|
63
|
+
================================================================
|
|
64
|
+
4. Privacy, PHI, and regulatory compliance
|
|
65
|
+
================================================================
|
|
66
|
+
|
|
67
|
+
ehrextract does not detect Protected Health Information (PHI). The
|
|
68
|
+
egress-warning mechanism (consent.py) is informational only -- it is
|
|
69
|
+
NOT a privacy compliance control and MUST NOT be relied upon as such.
|
|
70
|
+
|
|
71
|
+
Users are solely responsible for ensuring that their use of ehrextract
|
|
72
|
+
complies with all applicable privacy, data-protection, and
|
|
73
|
+
data-residency laws, including but not limited to:
|
|
74
|
+
|
|
75
|
+
- the Health Insurance Portability and Accountability Act (HIPAA),
|
|
76
|
+
- the Personal Health Information Protection Act (PHIPA, Ontario),
|
|
77
|
+
- the Personal Information Protection and Electronic Documents
|
|
78
|
+
Act (PIPEDA, Canada),
|
|
79
|
+
- the General Data Protection Regulation (GDPR, EU),
|
|
80
|
+
|
|
81
|
+
and with the policies of any institutional Research Ethics Board (REB)
|
|
82
|
+
or Institutional Review Board (IRB) governing the data they process.
|
|
83
|
+
|
|
84
|
+
Routing PHI through any third-party API requires, at minimum, a signed
|
|
85
|
+
Business Associate Agreement (or local equivalent) and Zero-Data-
|
|
86
|
+
Retention enrollment with that provider. Users must verify these
|
|
87
|
+
arrangements independently; the listing of a provider in ehrextract's
|
|
88
|
+
documentation is not a representation of compliance.
|
|
89
|
+
|
|
90
|
+
================================================================
|
|
91
|
+
5. Acceptable-use restrictions
|
|
92
|
+
================================================================
|
|
93
|
+
|
|
94
|
+
The authors and institutions named above expressly disclaim and do not
|
|
95
|
+
license use of ehrextract for any of the following purposes:
|
|
96
|
+
|
|
97
|
+
- re-identification of de-identified or pseudonymized records;
|
|
98
|
+
- mass surveillance of patient populations or individuals;
|
|
99
|
+
- insurance underwriting, eligibility determination, or claims
|
|
100
|
+
adjudication;
|
|
101
|
+
- employment or admissions decisions;
|
|
102
|
+
- immigration or border-screening decisions;
|
|
103
|
+
- law-enforcement intelligence-gathering;
|
|
104
|
+
- any application that produces or supports decisions of legal,
|
|
105
|
+
financial, or material consequence to an identified individual
|
|
106
|
+
without that individual's informed consent.
|
|
107
|
+
|
|
108
|
+
This list is non-exhaustive. Any use that could reasonably be expected
|
|
109
|
+
to cause disparate harm to individuals or groups is outside the scope
|
|
110
|
+
of the authors' and institutions' intent.
|
|
111
|
+
|
|
112
|
+
================================================================
|
|
113
|
+
6. Research use and output validation
|
|
114
|
+
================================================================
|
|
115
|
+
|
|
116
|
+
ehrextract uses large language models that may produce hallucinated,
|
|
117
|
+
incomplete, or systematically biased outputs. The "parse_success"
|
|
118
|
+
column in ehrextract output indicates that the model's response was
|
|
119
|
+
syntactically valid against the schema; it does NOT indicate that the
|
|
120
|
+
extracted values are correct.
|
|
121
|
+
|
|
122
|
+
Any use of ehrextract output as research data requires human review of
|
|
123
|
+
every row before that data is treated as observed fact. Publications,
|
|
124
|
+
posters, abstracts, or reports that present ehrextract output as
|
|
125
|
+
ground-truth without per-row human validation are misuses of the
|
|
126
|
+
software and are not endorsed by the authors or institutions.
|
|
127
|
+
|
|
128
|
+
================================================================
|
|
129
|
+
7. Bias and fairness
|
|
130
|
+
================================================================
|
|
131
|
+
|
|
132
|
+
ehrextract has not been audited for demographic, linguistic, or
|
|
133
|
+
clinical-context bias. The underlying language models are known to
|
|
134
|
+
exhibit disparate performance across populations defined by race,
|
|
135
|
+
ethnicity, gender, primary language, age, socioeconomic status, and
|
|
136
|
+
condition prevalence.
|
|
137
|
+
|
|
138
|
+
ehrextract MUST NOT be used in triage, resource allocation, eligibility
|
|
139
|
+
determination, or any other setting where disparate model performance
|
|
140
|
+
across demographic subgroups could cause unequal access to care or
|
|
141
|
+
disparate harm.
|
|
142
|
+
|
|
143
|
+
================================================================
|
|
144
|
+
8. Third-party adapters and models
|
|
145
|
+
================================================================
|
|
146
|
+
|
|
147
|
+
ehrextract supports loading external LoRA adapters via the --adapter
|
|
148
|
+
flag and external model weights via --model. The authors and
|
|
149
|
+
institutions do NOT host, vet, validate, or vouch for any third-party
|
|
150
|
+
adapter or model. Use of an adapter does not imply that the adapter's
|
|
151
|
+
training data, license, or output behaviour has been reviewed.
|
|
152
|
+
|
|
153
|
+
Distributors of LoRA adapters or fine-tuned weights that advertise
|
|
154
|
+
compatibility with ehrextract are responsible for the licensing and
|
|
155
|
+
data-handling claims they make about their own artifacts.
|
|
156
|
+
|
|
157
|
+
================================================================
|
|
158
|
+
9. Maintenance and security
|
|
159
|
+
================================================================
|
|
160
|
+
|
|
161
|
+
ehrextract is research-grade software released as a public-good
|
|
162
|
+
artifact. The authors make NO commitment to:
|
|
163
|
+
|
|
164
|
+
- respond to issues or pull requests within any timeframe,
|
|
165
|
+
- provide security patches for reported vulnerabilities,
|
|
166
|
+
- maintain compatibility with future versions of dependencies,
|
|
167
|
+
- support deployment in production environments, or
|
|
168
|
+
- continue development beyond the published version.
|
|
169
|
+
|
|
170
|
+
Operators who deploy ehrextract are solely responsible for monitoring
|
|
171
|
+
its dependencies, patching vulnerabilities, and assessing fitness for
|
|
172
|
+
their environment.
|
|
173
|
+
|
|
174
|
+
================================================================
|
|
175
|
+
10. No warranty
|
|
176
|
+
================================================================
|
|
177
|
+
|
|
178
|
+
EHREXTRACT IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
179
|
+
OR IMPLIED. SEE SECTIONS 7 AND 8 OF THE APACHE LICENSE 2.0 FOR THE
|
|
180
|
+
FULL DISCLAIMER OF WARRANTY AND LIMITATION OF LIABILITY.
|
|
181
|
+
|
|
182
|
+
================================================================
|
|
183
|
+
|
|
184
|
+
For questions about acceptable use or institutional permission, contact
|
|
185
|
+
the corresponding author through the project repository.
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ehrextract
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Structured feature extraction from clinical notes
|
|
5
|
+
Author: Chen Zhang, Yibing Xia, Sanjay Mahant, Nathan Taback
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/shifosss/ehrextract
|
|
8
|
+
Project-URL: Repository, https://github.com/shifosss/ehrextract
|
|
9
|
+
Project-URL: Issues, https://github.com/shifosss/ehrextract/issues
|
|
10
|
+
Project-URL: Changelog, https://github.com/shifosss/ehrextract/blob/main/CHANGELOG.md
|
|
11
|
+
Keywords: clinical,nlp,extraction,llm,structured-output
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Healthcare Industry
|
|
14
|
+
Classifier: Intended Audience :: Science/Research
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Topic :: Scientific/Engineering :: Information Analysis
|
|
18
|
+
Requires-Python: >=3.11
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
License-File: LICENSE
|
|
21
|
+
License-File: NOTICE
|
|
22
|
+
Requires-Dist: pandas>=2.0
|
|
23
|
+
Requires-Dist: pyyaml>=6.0
|
|
24
|
+
Requires-Dist: openpyxl>=3.1
|
|
25
|
+
Provides-Extra: hf
|
|
26
|
+
Requires-Dist: torch>=2.0; extra == "hf"
|
|
27
|
+
Requires-Dist: transformers>=4.56; extra == "hf"
|
|
28
|
+
Requires-Dist: peft>=0.10; extra == "hf"
|
|
29
|
+
Requires-Dist: accelerate>=0.30; extra == "hf"
|
|
30
|
+
Provides-Extra: openai
|
|
31
|
+
Requires-Dist: openai>=1.0; extra == "openai"
|
|
32
|
+
Provides-Extra: anthropic
|
|
33
|
+
Requires-Dist: anthropic>=0.30; extra == "anthropic"
|
|
34
|
+
Provides-Extra: dev
|
|
35
|
+
Requires-Dist: pytest>=7.4; extra == "dev"
|
|
36
|
+
Requires-Dist: pytest-cov>=4.1; extra == "dev"
|
|
37
|
+
Dynamic: license-file
|
|
38
|
+
|
|
39
|
+
# ehrextract
|
|
40
|
+
|
|
41
|
+
Structured feature extraction from clinical notes. Three steps:
|
|
42
|
+
|
|
43
|
+
1. **Bring your notes** — CSV, JSONL, JSON, XLSX, plain text, or a pandas
|
|
44
|
+
DataFrame.
|
|
45
|
+
2. **Pick a task** — a built-in task (`comorbidity`, `clinical_vars`, `full`)
|
|
46
|
+
or your own YAML file with your own fields and prompt.
|
|
47
|
+
3. **Pick a model** — a fine-tuned LoRA adapter on a local base model, your
|
|
48
|
+
own local HuggingFace weights, or an API model (OpenAI-compatible or
|
|
49
|
+
Anthropic).
|
|
50
|
+
|
|
51
|
+
One command (or one function call) later you have a results table —
|
|
52
|
+
CSV, JSONL, JSON, XLSX, or Parquet — with one column per extracted field.
|
|
53
|
+
|
|
54
|
+
> **Important — read before use.**
|
|
55
|
+
> ehrextract is **research-grade software**. It is **NOT a medical device**,
|
|
56
|
+
> is **NOT FDA-cleared / Health Canada-approved**, and **MUST NOT** be used
|
|
57
|
+
> for clinical decision-making, patient triage, eligibility determination,
|
|
58
|
+
> re-identification, surveillance, or any setting where its outputs affect
|
|
59
|
+
> a person's access to care, insurance, employment, or legal status.
|
|
60
|
+
> Outputs may hallucinate; any research use requires per-row human review.
|
|
61
|
+
> The egress-warning system is informational, not a privacy compliance
|
|
62
|
+
> control. **Users are solely responsible for HIPAA / PHIPA / PIPEDA / GDPR
|
|
63
|
+
> / REB compliance.** See [`NOTICE`](https://github.com/shifosss/ehrextract/blob/main/NOTICE) for the
|
|
64
|
+
> full acceptable-use scope.
|
|
65
|
+
|
|
66
|
+
## Install
|
|
67
|
+
|
|
68
|
+
Until the PyPI release, install from source (**current method**):
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
git clone https://github.com/shifosss/ehrextract
|
|
72
|
+
pip install './ehrextract[hf]' # or [openai], [anthropic]
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Once published to PyPI:
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
pip install ehrextract # core (~50 MB)
|
|
79
|
+
pip install 'ehrextract[hf]' # + torch + transformers + peft (~3 GB)
|
|
80
|
+
pip install 'ehrextract[openai]' # + openai SDK
|
|
81
|
+
pip install 'ehrextract[anthropic]' # + anthropic SDK
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## 30-second example
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
ehrextract \
|
|
88
|
+
--task comorbidity \
|
|
89
|
+
--model Qwen/Qwen3.5-27B --adapter /path/to/adapter \
|
|
90
|
+
--input notes.csv --output results.csv
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
or, as a library:
|
|
94
|
+
|
|
95
|
+
```python
|
|
96
|
+
from pathlib import Path
|
|
97
|
+
from ehrextract import extract
|
|
98
|
+
|
|
99
|
+
df = extract(
|
|
100
|
+
Path("notes.csv"),
|
|
101
|
+
"comorbidity",
|
|
102
|
+
model="Qwen/Qwen3.5-27B",
|
|
103
|
+
adapter="/path/to/adapter",
|
|
104
|
+
output="results.csv",
|
|
105
|
+
)
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
The input needs a `note_text` column (configurable via `--text-column`); a
|
|
109
|
+
`note_id` column is added automatically when absent. The output has one
|
|
110
|
+
column per task field plus `parse_success`, `validation_errors`,
|
|
111
|
+
`raw_response`, `finish_reason`, and token counts.
|
|
112
|
+
|
|
113
|
+
## Built-in tasks
|
|
114
|
+
|
|
115
|
+
| Task | Fields | What it extracts |
|
|
116
|
+
|---|---|---|
|
|
117
|
+
| `comorbidity` | 17 | Free-text diagnosis list + 16 Y/N comorbidity categories |
|
|
118
|
+
| `clinical_vars` | 4 | Feeding and neurologic variables (tube/oral feeding, aspiration risk, NI trajectory) |
|
|
119
|
+
| `full` | 20 | Joint task: the 16 comorbidity categories + the 4 clinical variables |
|
|
120
|
+
|
|
121
|
+
Built-in tasks ship inside the package; `--task <name>` works without any
|
|
122
|
+
extra files. Define your own task in YAML — see
|
|
123
|
+
[`schema-reference.md`](https://github.com/shifosss/ehrextract/blob/main/docs/ehrextract/schema-reference.md).
|
|
124
|
+
|
|
125
|
+
> **Note on the `full` task.** The research pipeline that produced the
|
|
126
|
+
> published evaluation numbers for the joint 20-field task used constrained
|
|
127
|
+
> JSON decoding to force the output shape. ehrextract v0.2.0 does **not**
|
|
128
|
+
> constrain decoding (planned as a future feature), so `full`-task outputs
|
|
129
|
+
> can diverge from the published numbers on hard notes — watch the
|
|
130
|
+
> `parse_success` and `validation_errors` columns.
|
|
131
|
+
|
|
132
|
+
## Data handling
|
|
133
|
+
|
|
134
|
+
If your input may contain PHI, read [`data-handling.md`](https://github.com/shifosss/ehrextract/blob/main/docs/ehrextract/data-handling.md)
|
|
135
|
+
BEFORE running with any API provider. The package writes a data-egress
|
|
136
|
+
notice to stderr (once per process per destination) on API use; it never
|
|
137
|
+
blocks, and it does not (and cannot) guarantee compliance for you. The
|
|
138
|
+
local HuggingFace provider keeps all data on your machine.
|
|
139
|
+
|
|
140
|
+
## Documentation
|
|
141
|
+
|
|
142
|
+
- [`quickstart.md`](https://github.com/shifosss/ehrextract/blob/main/docs/ehrextract/quickstart.md) — fine-tuned adapters, custom tasks, API providers
|
|
143
|
+
- [`schema-reference.md`](https://github.com/shifosss/ehrextract/blob/main/docs/ehrextract/schema-reference.md) — the task-file YAML reference
|
|
144
|
+
- [`data-handling.md`](https://github.com/shifosss/ehrextract/blob/main/docs/ehrextract/data-handling.md) — PHI, egress notice, BAA-eligible providers
|
|
145
|
+
- [`extending-providers.md`](https://github.com/shifosss/ehrextract/blob/main/docs/ehrextract/extending-providers.md) — plug in a custom provider
|
|
146
|
+
|
|
147
|
+
## Authors and institutions
|
|
148
|
+
|
|
149
|
+
ehrextract was developed by:
|
|
150
|
+
|
|
151
|
+
- **Chen Zhang** (lead author)
|
|
152
|
+
- **Yibing Xia** (co-author)
|
|
153
|
+
- **Sanjay Mahant, MD** -- supervisor, The Hospital for Sick Children (SickKids)
|
|
154
|
+
- **Nathan Taback, PhD** -- supervisor, University of Toronto
|
|
155
|
+
|
|
156
|
+
at **The Hospital for Sick Children** (Toronto, Canada) and the
|
|
157
|
+
**University of Toronto** (Toronto, Canada). Please cite the project if
|
|
158
|
+
you use it in published work.
|
|
159
|
+
|
|
160
|
+
## License
|
|
161
|
+
|
|
162
|
+
Licensed under the Apache License, Version 2.0. See [`LICENSE`](https://github.com/shifosss/ehrextract/blob/main/LICENSE)
|
|
163
|
+
for the full license text and [`NOTICE`](https://github.com/shifosss/ehrextract/blob/main/NOTICE) for
|
|
164
|
+
attribution, the no-endorsement clause, the clinical-use disclaimer, and the
|
|
165
|
+
acceptable-use restrictions that supplement (but do not override) the License.
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# ehrextract
|
|
2
|
+
|
|
3
|
+
Structured feature extraction from clinical notes. Three steps:
|
|
4
|
+
|
|
5
|
+
1. **Bring your notes** — CSV, JSONL, JSON, XLSX, plain text, or a pandas
|
|
6
|
+
DataFrame.
|
|
7
|
+
2. **Pick a task** — a built-in task (`comorbidity`, `clinical_vars`, `full`)
|
|
8
|
+
or your own YAML file with your own fields and prompt.
|
|
9
|
+
3. **Pick a model** — a fine-tuned LoRA adapter on a local base model, your
|
|
10
|
+
own local HuggingFace weights, or an API model (OpenAI-compatible or
|
|
11
|
+
Anthropic).
|
|
12
|
+
|
|
13
|
+
One command (or one function call) later you have a results table —
|
|
14
|
+
CSV, JSONL, JSON, XLSX, or Parquet — with one column per extracted field.
|
|
15
|
+
|
|
16
|
+
> **Important — read before use.**
|
|
17
|
+
> ehrextract is **research-grade software**. It is **NOT a medical device**,
|
|
18
|
+
> is **NOT FDA-cleared / Health Canada-approved**, and **MUST NOT** be used
|
|
19
|
+
> for clinical decision-making, patient triage, eligibility determination,
|
|
20
|
+
> re-identification, surveillance, or any setting where its outputs affect
|
|
21
|
+
> a person's access to care, insurance, employment, or legal status.
|
|
22
|
+
> Outputs may hallucinate; any research use requires per-row human review.
|
|
23
|
+
> The egress-warning system is informational, not a privacy compliance
|
|
24
|
+
> control. **Users are solely responsible for HIPAA / PHIPA / PIPEDA / GDPR
|
|
25
|
+
> / REB compliance.** See [`NOTICE`](https://github.com/shifosss/ehrextract/blob/main/NOTICE) for the
|
|
26
|
+
> full acceptable-use scope.
|
|
27
|
+
|
|
28
|
+
## Install
|
|
29
|
+
|
|
30
|
+
Until the PyPI release, install from source (**current method**):
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
git clone https://github.com/shifosss/ehrextract
|
|
34
|
+
pip install './ehrextract[hf]' # or [openai], [anthropic]
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Once published to PyPI:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
pip install ehrextract # core (~50 MB)
|
|
41
|
+
pip install 'ehrextract[hf]' # + torch + transformers + peft (~3 GB)
|
|
42
|
+
pip install 'ehrextract[openai]' # + openai SDK
|
|
43
|
+
pip install 'ehrextract[anthropic]' # + anthropic SDK
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## 30-second example
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
ehrextract \
|
|
50
|
+
--task comorbidity \
|
|
51
|
+
--model Qwen/Qwen3.5-27B --adapter /path/to/adapter \
|
|
52
|
+
--input notes.csv --output results.csv
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
or, as a library:
|
|
56
|
+
|
|
57
|
+
```python
|
|
58
|
+
from pathlib import Path
|
|
59
|
+
from ehrextract import extract
|
|
60
|
+
|
|
61
|
+
df = extract(
|
|
62
|
+
Path("notes.csv"),
|
|
63
|
+
"comorbidity",
|
|
64
|
+
model="Qwen/Qwen3.5-27B",
|
|
65
|
+
adapter="/path/to/adapter",
|
|
66
|
+
output="results.csv",
|
|
67
|
+
)
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
The input needs a `note_text` column (configurable via `--text-column`); a
|
|
71
|
+
`note_id` column is added automatically when absent. The output has one
|
|
72
|
+
column per task field plus `parse_success`, `validation_errors`,
|
|
73
|
+
`raw_response`, `finish_reason`, and token counts.
|
|
74
|
+
|
|
75
|
+
## Built-in tasks
|
|
76
|
+
|
|
77
|
+
| Task | Fields | What it extracts |
|
|
78
|
+
|---|---|---|
|
|
79
|
+
| `comorbidity` | 17 | Free-text diagnosis list + 16 Y/N comorbidity categories |
|
|
80
|
+
| `clinical_vars` | 4 | Feeding and neurologic variables (tube/oral feeding, aspiration risk, NI trajectory) |
|
|
81
|
+
| `full` | 20 | Joint task: the 16 comorbidity categories + the 4 clinical variables |
|
|
82
|
+
|
|
83
|
+
Built-in tasks ship inside the package; `--task <name>` works without any
|
|
84
|
+
extra files. Define your own task in YAML — see
|
|
85
|
+
[`schema-reference.md`](https://github.com/shifosss/ehrextract/blob/main/docs/ehrextract/schema-reference.md).
|
|
86
|
+
|
|
87
|
+
> **Note on the `full` task.** The research pipeline that produced the
|
|
88
|
+
> published evaluation numbers for the joint 20-field task used constrained
|
|
89
|
+
> JSON decoding to force the output shape. ehrextract v0.2.0 does **not**
|
|
90
|
+
> constrain decoding (planned as a future feature), so `full`-task outputs
|
|
91
|
+
> can diverge from the published numbers on hard notes — watch the
|
|
92
|
+
> `parse_success` and `validation_errors` columns.
|
|
93
|
+
|
|
94
|
+
## Data handling
|
|
95
|
+
|
|
96
|
+
If your input may contain PHI, read [`data-handling.md`](https://github.com/shifosss/ehrextract/blob/main/docs/ehrextract/data-handling.md)
|
|
97
|
+
BEFORE running with any API provider. The package writes a data-egress
|
|
98
|
+
notice to stderr (once per process per destination) on API use; it never
|
|
99
|
+
blocks, and it does not (and cannot) guarantee compliance for you. The
|
|
100
|
+
local HuggingFace provider keeps all data on your machine.
|
|
101
|
+
|
|
102
|
+
## Documentation
|
|
103
|
+
|
|
104
|
+
- [`quickstart.md`](https://github.com/shifosss/ehrextract/blob/main/docs/ehrextract/quickstart.md) — fine-tuned adapters, custom tasks, API providers
|
|
105
|
+
- [`schema-reference.md`](https://github.com/shifosss/ehrextract/blob/main/docs/ehrextract/schema-reference.md) — the task-file YAML reference
|
|
106
|
+
- [`data-handling.md`](https://github.com/shifosss/ehrextract/blob/main/docs/ehrextract/data-handling.md) — PHI, egress notice, BAA-eligible providers
|
|
107
|
+
- [`extending-providers.md`](https://github.com/shifosss/ehrextract/blob/main/docs/ehrextract/extending-providers.md) — plug in a custom provider
|
|
108
|
+
|
|
109
|
+
## Authors and institutions
|
|
110
|
+
|
|
111
|
+
ehrextract was developed by:
|
|
112
|
+
|
|
113
|
+
- **Chen Zhang** (lead author)
|
|
114
|
+
- **Yibing Xia** (co-author)
|
|
115
|
+
- **Sanjay Mahant, MD** -- supervisor, The Hospital for Sick Children (SickKids)
|
|
116
|
+
- **Nathan Taback, PhD** -- supervisor, University of Toronto
|
|
117
|
+
|
|
118
|
+
at **The Hospital for Sick Children** (Toronto, Canada) and the
|
|
119
|
+
**University of Toronto** (Toronto, Canada). Please cite the project if
|
|
120
|
+
you use it in published work.
|
|
121
|
+
|
|
122
|
+
## License
|
|
123
|
+
|
|
124
|
+
Licensed under the Apache License, Version 2.0. See [`LICENSE`](https://github.com/shifosss/ehrextract/blob/main/LICENSE)
|
|
125
|
+
for the full license text and [`NOTICE`](https://github.com/shifosss/ehrextract/blob/main/NOTICE) for
|
|
126
|
+
attribution, the no-endorsement clause, the clinical-use disclaimer, and the
|
|
127
|
+
acceptable-use restrictions that supplement (but do not override) the License.
|