fhir-reada 0.1.1__py3-none-any.whl → 0.1.3__py3-none-any.whl
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.
- fhir_reada/__init__.py +1 -1
- fhir_reada/cli.py +5 -2
- fhir_reada/deid_utils.py +19 -2
- {fhir_reada-0.1.1.dist-info → fhir_reada-0.1.3.dist-info}/METADATA +3 -3
- fhir_reada-0.1.3.dist-info/RECORD +12 -0
- fhir_reada-0.1.1.dist-info/RECORD +0 -12
- {fhir_reada-0.1.1.dist-info → fhir_reada-0.1.3.dist-info}/LICENSE +0 -0
- {fhir_reada-0.1.1.dist-info → fhir_reada-0.1.3.dist-info}/WHEEL +0 -0
- {fhir_reada-0.1.1.dist-info → fhir_reada-0.1.3.dist-info}/entry_points.txt +0 -0
- {fhir_reada-0.1.1.dist-info → fhir_reada-0.1.3.dist-info}/top_level.txt +0 -0
fhir_reada/__init__.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
__version__ = "0.1.
|
1
|
+
__version__ = "0.1.3"
|
fhir_reada/cli.py
CHANGED
@@ -28,8 +28,11 @@ def run_cli(url, min_age, max_age, diagnosis, output_file):
|
|
28
28
|
|
29
29
|
print("De-identifying and exporting to CSV...")
|
30
30
|
deidentified = [deidentify_patient_bundle(b) for b in bundles]
|
31
|
-
|
32
|
-
|
31
|
+
if deidentified:
|
32
|
+
export_to_csv(deidentified, filename=output_file)
|
33
|
+
print(f"✅ Exported to {output_file}")
|
34
|
+
else:
|
35
|
+
print("⚠️ No data to export; file was not created.")
|
33
36
|
|
34
37
|
def main():
|
35
38
|
parser = argparse.ArgumentParser(description="FHIR Cohort Extractor")
|
fhir_reada/deid_utils.py
CHANGED
@@ -1,4 +1,18 @@
|
|
1
1
|
from hashlib import sha256
|
2
|
+
from datetime import datetime
|
3
|
+
|
4
|
+
def get_birth_year_and_age(birth_date_str):
|
5
|
+
try:
|
6
|
+
birth = datetime.strptime(birth_date_str, "%Y-%m-%d")
|
7
|
+
today = datetime.today()
|
8
|
+
age = today.year - birth.year - ((today.month, today.day) < (birth.month, birth.day))
|
9
|
+
birth_year = birth.year
|
10
|
+
return (
|
11
|
+
"90+" if age >= 90 else str(birth_year),
|
12
|
+
"90+" if age >= 90 else str(age)
|
13
|
+
)
|
14
|
+
except Exception:
|
15
|
+
return ("UNKNOWN", "UNKNOWN")
|
2
16
|
|
3
17
|
def deidentify_patient_bundle(bundle):
|
4
18
|
patient = bundle["patient"]
|
@@ -6,12 +20,15 @@ def deidentify_patient_bundle(bundle):
|
|
6
20
|
observations = bundle["observations"]
|
7
21
|
|
8
22
|
patient_id = patient.get("id", "")
|
9
|
-
pseudo_id = sha256(patient_id.encode()).hexdigest()
|
23
|
+
pseudo_id = sha256(patient_id.encode()).hexdigest()
|
24
|
+
|
25
|
+
birth_year, age = get_birth_year_and_age(patient.get("birthDate"))
|
10
26
|
|
11
27
|
return {
|
12
28
|
"id": pseudo_id,
|
13
29
|
"gender": patient.get("gender"),
|
14
|
-
"
|
30
|
+
"birthYear": birth_year,
|
31
|
+
"age": age,
|
15
32
|
"conditions": "; ".join(conditions) if conditions else "None",
|
16
33
|
"observations": "; ".join(observations) if observations else "None"
|
17
34
|
}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: fhir-reada
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.3
|
4
4
|
Summary: A FHIR cohort extractor and de-identification tool for clinical research.
|
5
5
|
Author-email: Tobenna Oduah <tjlite81@gmail.com>
|
6
6
|
License: MIT
|
@@ -49,7 +49,7 @@ pip install -e .
|
|
49
49
|
## 🚀 Usage (CLI)
|
50
50
|
|
51
51
|
```bash
|
52
|
-
fhir-reada --url https://
|
52
|
+
fhir-reada --url https://r4.smarthealthit.org --min-age 25 --max-age 40 --diagnosis diabetes --out output.csv
|
53
53
|
```
|
54
54
|
|
55
55
|
---
|
@@ -58,7 +58,7 @@ fhir-reada --url https://hapi.fhir.org/baseR4 --min-age 25 --max-age 40 --diagno
|
|
58
58
|
|
59
59
|
| Option | Description |
|
60
60
|
|----------------|------------------------------------------------------|
|
61
|
-
| `--url` | FHIR base URL (e.g. `https://
|
61
|
+
| `--url` | FHIR base URL (e.g. `https://r4.smarthealthit.org`) |
|
62
62
|
| `--min-age` | Minimum age for cohort (e.g. `25`) |
|
63
63
|
| `--max-age` | Maximum age for cohort (e.g. `40`) |
|
64
64
|
| `--diagnosis` | Diagnosis keyword (optional, e.g. `diabetes`) |
|
@@ -0,0 +1,12 @@
|
|
1
|
+
fhir_reada/__init__.py,sha256=R5TtpJu7Qu6sOarfDpp-5Oyy8Pi2Ir3VewCvsCQiAgo,21
|
2
|
+
fhir_reada/cli.py,sha256=-G3oQnXhukBWkS6QS8WkNeJG0Llk61b7_EThh4vyWQM,1860
|
3
|
+
fhir_reada/cohort_builder.py,sha256=92XcLJJZfAZWdUVJBCZ3fPlPNY6AZ-8GPOQSEixO9YM,970
|
4
|
+
fhir_reada/deid_utils.py,sha256=O-W4vGH6XUAnZXsXYfqgz5Nu89mZ78zJbkj6CSKL-rg,1157
|
5
|
+
fhir_reada/exporter.py,sha256=FU19ArPFrcHadm7oL4T0h1tGwbyB2XjwnTM4ctAVdNI,360
|
6
|
+
fhir_reada/fhir_connector.py,sha256=CDGWwj6Pxw2g-4YU3DgftmQp0lwzmyx_6FAbN32GZNk,1423
|
7
|
+
fhir_reada-0.1.3.dist-info/LICENSE,sha256=sb_e78Fe7Dk6yq7gU0w6bytrGEinwYKP527HSihtlio,1111
|
8
|
+
fhir_reada-0.1.3.dist-info/METADATA,sha256=jMUQAsRnpCSxAARR-g3JdFCkBNhMTSPrUj7mT3BS0Aw,2205
|
9
|
+
fhir_reada-0.1.3.dist-info/WHEEL,sha256=iAkIy5fosb7FzIOwONchHf19Qu7_1wCWyFNR5gu9nU0,91
|
10
|
+
fhir_reada-0.1.3.dist-info/entry_points.txt,sha256=WGQ4P92SzyjFFTLUZlo6lSqQumr4MvfF05eOXhpgcpQ,51
|
11
|
+
fhir_reada-0.1.3.dist-info/top_level.txt,sha256=vJum_GABH4sFXP_XWV47DC7L7Yun_8h21vM5L8pdZ_0,11
|
12
|
+
fhir_reada-0.1.3.dist-info/RECORD,,
|
@@ -1,12 +0,0 @@
|
|
1
|
-
fhir_reada/__init__.py,sha256=8oAxKUG747GUokmxjkrWejyJa5yPNEsoJDlXxoedxTw,21
|
2
|
-
fhir_reada/cli.py,sha256=ee-qaFbC9rnRinxDY55CsrAN2jtRApMh_OcU4yyYMVg,1749
|
3
|
-
fhir_reada/cohort_builder.py,sha256=92XcLJJZfAZWdUVJBCZ3fPlPNY6AZ-8GPOQSEixO9YM,970
|
4
|
-
fhir_reada/deid_utils.py,sha256=ZCNrEUm_oq6VrAgGovAwUaIavvyhOBJrU4XNqHAeghA,577
|
5
|
-
fhir_reada/exporter.py,sha256=FU19ArPFrcHadm7oL4T0h1tGwbyB2XjwnTM4ctAVdNI,360
|
6
|
-
fhir_reada/fhir_connector.py,sha256=CDGWwj6Pxw2g-4YU3DgftmQp0lwzmyx_6FAbN32GZNk,1423
|
7
|
-
fhir_reada-0.1.1.dist-info/LICENSE,sha256=sb_e78Fe7Dk6yq7gU0w6bytrGEinwYKP527HSihtlio,1111
|
8
|
-
fhir_reada-0.1.1.dist-info/METADATA,sha256=U8DUGfz8C7cTXqK0qXravIUh0otPMkVwp82Qe6EogCM,2204
|
9
|
-
fhir_reada-0.1.1.dist-info/WHEEL,sha256=iAkIy5fosb7FzIOwONchHf19Qu7_1wCWyFNR5gu9nU0,91
|
10
|
-
fhir_reada-0.1.1.dist-info/entry_points.txt,sha256=WGQ4P92SzyjFFTLUZlo6lSqQumr4MvfF05eOXhpgcpQ,51
|
11
|
-
fhir_reada-0.1.1.dist-info/top_level.txt,sha256=vJum_GABH4sFXP_XWV47DC7L7Yun_8h21vM5L8pdZ_0,11
|
12
|
-
fhir_reada-0.1.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|