fhir-reada 0.1.1__tar.gz → 0.1.2__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: fhir-reada
3
- Version: 0.1.1
3
+ Version: 0.1.2
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
@@ -0,0 +1 @@
1
+ __version__ = "0.1.2"
@@ -0,0 +1,34 @@
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")
16
+
17
+ def deidentify_patient_bundle(bundle):
18
+ patient = bundle["patient"]
19
+ conditions = bundle["conditions"]
20
+ observations = bundle["observations"]
21
+
22
+ patient_id = patient.get("id", "")
23
+ pseudo_id = sha256(patient_id.encode()).hexdigest()
24
+
25
+ birth_year, age = get_birth_year_and_age(patient.get("birthDate"))
26
+
27
+ return {
28
+ "id": pseudo_id,
29
+ "gender": patient.get("gender"),
30
+ "birthYear": birth_year,
31
+ "age": age,
32
+ "conditions": "; ".join(conditions) if conditions else "None",
33
+ "observations": "; ".join(observations) if observations else "None"
34
+ }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: fhir-reada
3
- Version: 0.1.1
3
+ Version: 0.1.2
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
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "fhir-reada"
3
- version = "0.1.1"
3
+ version = "0.1.2"
4
4
  description = "A FHIR cohort extractor and de-identification tool for clinical research."
5
5
  readme = "README.md"
6
6
  authors = [{name = "Tobenna Oduah", email = "tjlite81@gmail.com"}]
@@ -1 +0,0 @@
1
- __version__ = "0.1.1"
@@ -1,17 +0,0 @@
1
- from hashlib import sha256
2
-
3
- def deidentify_patient_bundle(bundle):
4
- patient = bundle["patient"]
5
- conditions = bundle["conditions"]
6
- observations = bundle["observations"]
7
-
8
- patient_id = patient.get("id", "")
9
- pseudo_id = sha256(patient_id.encode()).hexdigest()[:10]
10
-
11
- return {
12
- "id": pseudo_id,
13
- "gender": patient.get("gender"),
14
- "birthDate": patient.get("birthDate"),
15
- "conditions": "; ".join(conditions) if conditions else "None",
16
- "observations": "; ".join(observations) if observations else "None"
17
- }
File without changes
File without changes
File without changes
File without changes