fhir-reada 0.1.0__py3-none-any.whl → 0.1.2__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 CHANGED
@@ -1 +1 @@
1
- __version__ = "0.1.0"
1
+ __version__ = "0.1.2"
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()[:10]
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
- "birthDate": patient.get("birthDate"),
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
  }
@@ -0,0 +1,86 @@
1
+ Metadata-Version: 2.1
2
+ Name: fhir-reada
3
+ Version: 0.1.2
4
+ Summary: A FHIR cohort extractor and de-identification tool for clinical research.
5
+ Author-email: Tobenna Oduah <tjlite81@gmail.com>
6
+ License: MIT
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE
9
+ Requires-Dist: requests
10
+ Requires-Dist: python-dateutil
11
+
12
+ # FHIR-READA
13
+
14
+ **FHIR Research Extractor And De-identified Analyzer**
15
+
16
+ A Python CLI tool for extracting, de-identifying, and exporting patient data from FHIR servers — built for research teams, clinicians, and medical institutions.
17
+
18
+ ---
19
+
20
+ ## 🔍 Features
21
+
22
+ - Filter patients by age range and diagnosis
23
+ - Extract from any FHIR-compliant server
24
+ - Fetch Conditions and Observations
25
+ - Automatically de-identify patient IDs
26
+ - Export results to CSV
27
+ - Easy-to-use CLI with flexible filters
28
+
29
+ ---
30
+
31
+ ## 💻 Installation
32
+
33
+ **From PyPI**
34
+
35
+ ```bash
36
+ pip install fhir-reada
37
+ ```
38
+
39
+ **From Source (for development or testing)**
40
+
41
+ ```bash
42
+ git clone https://github.com/TOduah/fhir-reada.git
43
+ cd fhir-reada
44
+ pip install -e .
45
+ ```
46
+
47
+ ---
48
+
49
+ ## 🚀 Usage (CLI)
50
+
51
+ ```bash
52
+ fhir-reada --url https://hapi.fhir.org/baseR4 --min-age 25 --max-age 40 --diagnosis diabetes --out output.csv
53
+ ```
54
+
55
+ ---
56
+
57
+ ## ⚙️ CLI Options
58
+
59
+ | Option | Description |
60
+ |----------------|------------------------------------------------------|
61
+ | `--url` | FHIR base URL (e.g. `https://hapi.fhir.org/baseR4`) |
62
+ | `--min-age` | Minimum age for cohort (e.g. `25`) |
63
+ | `--max-age` | Maximum age for cohort (e.g. `40`) |
64
+ | `--diagnosis` | Diagnosis keyword (optional, e.g. `diabetes`) |
65
+ | `--out` | Output filename for CSV export |
66
+
67
+ ---
68
+
69
+ ## 🏥 Who Is This For?
70
+
71
+ - Research institutions running clinical studies
72
+ - Hospital data science or IT departments
73
+ - Medical schools teaching FHIR and analytics
74
+ - Independent developers working with public or private FHIR APIs
75
+
76
+ ---
77
+
78
+ ## 📄 License
79
+
80
+ This project is licensed under the [MIT License](LICENSE).
81
+
82
+ ---
83
+
84
+ ## 💬 Author
85
+
86
+ Built by [Tobenna Oduah](https://github.com/toduah).
@@ -0,0 +1,12 @@
1
+ fhir_reada/__init__.py,sha256=K5SiDdEGYMpdqXThrqwTqECJJBOQNTQDrnpc2K5mzKs,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=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.2.dist-info/LICENSE,sha256=sb_e78Fe7Dk6yq7gU0w6bytrGEinwYKP527HSihtlio,1111
8
+ fhir_reada-0.1.2.dist-info/METADATA,sha256=fiDNbsi5mN0rokMpMtoCz8kJzVdvPn4uONLGHW7iYN4,2204
9
+ fhir_reada-0.1.2.dist-info/WHEEL,sha256=iAkIy5fosb7FzIOwONchHf19Qu7_1wCWyFNR5gu9nU0,91
10
+ fhir_reada-0.1.2.dist-info/entry_points.txt,sha256=WGQ4P92SzyjFFTLUZlo6lSqQumr4MvfF05eOXhpgcpQ,51
11
+ fhir_reada-0.1.2.dist-info/top_level.txt,sha256=vJum_GABH4sFXP_XWV47DC7L7Yun_8h21vM5L8pdZ_0,11
12
+ fhir_reada-0.1.2.dist-info/RECORD,,
@@ -1,10 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: fhir-reada
3
- Version: 0.1.0
4
- Summary: A FHIR cohort extractor and de-identification tool for clinical research.
5
- Author-email: Tobenna Oduah <tjlite81@gmail.com>
6
- License: MIT
7
- License-File: LICENSE
8
- Requires-Dist: requests
9
- Requires-Dist: python-dateutil
10
-
@@ -1,12 +0,0 @@
1
- fhir_reada/__init__.py,sha256=Pru0BlFBASFCFo7McHdohtKkUtgMPDwbGfyUZlE2_Vw,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.0.dist-info/LICENSE,sha256=sb_e78Fe7Dk6yq7gU0w6bytrGEinwYKP527HSihtlio,1111
8
- fhir_reada-0.1.0.dist-info/METADATA,sha256=GWZjuwC_yHKzHkf8kgyYIpQgVa1zdln9PyYGsv4bwtU,287
9
- fhir_reada-0.1.0.dist-info/WHEEL,sha256=iAkIy5fosb7FzIOwONchHf19Qu7_1wCWyFNR5gu9nU0,91
10
- fhir_reada-0.1.0.dist-info/entry_points.txt,sha256=WGQ4P92SzyjFFTLUZlo6lSqQumr4MvfF05eOXhpgcpQ,51
11
- fhir_reada-0.1.0.dist-info/top_level.txt,sha256=vJum_GABH4sFXP_XWV47DC7L7Yun_8h21vM5L8pdZ_0,11
12
- fhir_reada-0.1.0.dist-info/RECORD,,