compressedfhir 1.0.0__tar.gz → 1.0.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.
Potentially problematic release.
This version of compressedfhir might be problematic. Click here for more details.
- compressedfhir-1.0.2/PKG-INFO +139 -0
- compressedfhir-1.0.2/README.md +112 -0
- compressedfhir-1.0.2/VERSION +1 -0
- {compressedfhir-1.0.0 → compressedfhir-1.0.2}/compressedfhir/fhir/fhir_bundle_entry_request.py +7 -5
- {compressedfhir-1.0.0 → compressedfhir-1.0.2}/compressedfhir/fhir/fhir_bundle_entry_response.py +9 -5
- compressedfhir-1.0.2/compressedfhir/utilities/fhir_json_encoder.py +71 -0
- compressedfhir-1.0.2/compressedfhir/utilities/test/test_fhir_json_encoder.py +177 -0
- compressedfhir-1.0.2/compressedfhir/utilities/test/test_json_helpers.py +99 -0
- compressedfhir-1.0.2/compressedfhir.egg-info/PKG-INFO +139 -0
- {compressedfhir-1.0.0 → compressedfhir-1.0.2}/compressedfhir.egg-info/SOURCES.txt +3 -0
- compressedfhir-1.0.2/tests/__init__.py +0 -0
- compressedfhir-1.0.0/PKG-INFO +0 -28
- compressedfhir-1.0.0/README.md +0 -1
- compressedfhir-1.0.0/VERSION +0 -1
- compressedfhir-1.0.0/compressedfhir/utilities/fhir_json_encoder.py +0 -30
- compressedfhir-1.0.0/compressedfhir.egg-info/PKG-INFO +0 -28
- {compressedfhir-1.0.0 → compressedfhir-1.0.2}/LICENSE +0 -0
- {compressedfhir-1.0.0 → compressedfhir-1.0.2}/MANIFEST.in +0 -0
- {compressedfhir-1.0.0 → compressedfhir-1.0.2}/Makefile +0 -0
- {compressedfhir-1.0.0 → compressedfhir-1.0.2}/compressedfhir/__init__.py +0 -0
- {compressedfhir-1.0.0 → compressedfhir-1.0.2}/compressedfhir/fhir/__init__.py +0 -0
- {compressedfhir-1.0.0 → compressedfhir-1.0.2}/compressedfhir/fhir/base_resource_list.py +0 -0
- {compressedfhir-1.0.0 → compressedfhir-1.0.2}/compressedfhir/fhir/fhir_bundle.py +0 -0
- {compressedfhir-1.0.0 → compressedfhir-1.0.2}/compressedfhir/fhir/fhir_bundle_entry.py +0 -0
- {compressedfhir-1.0.0 → compressedfhir-1.0.2}/compressedfhir/fhir/fhir_bundle_entry_list.py +0 -0
- {compressedfhir-1.0.0 → compressedfhir-1.0.2}/compressedfhir/fhir/fhir_bundle_entry_search.py +0 -0
- {compressedfhir-1.0.0 → compressedfhir-1.0.2}/compressedfhir/fhir/fhir_identifier.py +0 -0
- {compressedfhir-1.0.0 → compressedfhir-1.0.2}/compressedfhir/fhir/fhir_link.py +0 -0
- {compressedfhir-1.0.0 → compressedfhir-1.0.2}/compressedfhir/fhir/fhir_meta.py +0 -0
- {compressedfhir-1.0.0 → compressedfhir-1.0.2}/compressedfhir/fhir/fhir_resource.py +0 -0
- {compressedfhir-1.0.0 → compressedfhir-1.0.2}/compressedfhir/fhir/fhir_resource_list.py +0 -0
- {compressedfhir-1.0.0 → compressedfhir-1.0.2}/compressedfhir/fhir/fhir_resource_map.py +0 -0
- {compressedfhir-1.0.0 → compressedfhir-1.0.2}/compressedfhir/fhir/test/__init__.py +0 -0
- {compressedfhir-1.0.0 → compressedfhir-1.0.2}/compressedfhir/fhir/test/test_bundle_entry.py +0 -0
- {compressedfhir-1.0.0 → compressedfhir-1.0.2}/compressedfhir/fhir/test/test_bundle_entry_list.py +0 -0
- {compressedfhir-1.0.0 → compressedfhir-1.0.2}/compressedfhir/fhir/test/test_bundle_entry_request.py +0 -0
- {compressedfhir-1.0.0 → compressedfhir-1.0.2}/compressedfhir/fhir/test/test_bundle_entry_response.py +0 -0
- {compressedfhir-1.0.0 → compressedfhir-1.0.2}/compressedfhir/fhir/test/test_fhir_bundle.py +0 -0
- {compressedfhir-1.0.0 → compressedfhir-1.0.2}/compressedfhir/fhir/test/test_fhir_resource.py +0 -0
- {compressedfhir-1.0.0 → compressedfhir-1.0.2}/compressedfhir/fhir/test/test_fhir_resource_list.py +0 -0
- {compressedfhir-1.0.0 → compressedfhir-1.0.2}/compressedfhir/fhir/test/test_fhir_resource_map.py +0 -0
- {compressedfhir-1.0.0 → compressedfhir-1.0.2}/compressedfhir/py.typed +0 -0
- {compressedfhir-1.0.0 → compressedfhir-1.0.2}/compressedfhir/utilities/__init__.py +0 -0
- {compressedfhir-1.0.0 → compressedfhir-1.0.2}/compressedfhir/utilities/compressed_dict/__init__.py +0 -0
- {compressedfhir-1.0.0 → compressedfhir-1.0.2}/compressedfhir/utilities/compressed_dict/v1/__init__.py +0 -0
- {compressedfhir-1.0.0 → compressedfhir-1.0.2}/compressedfhir/utilities/compressed_dict/v1/compressed_dict.py +0 -0
- {compressedfhir-1.0.0 → compressedfhir-1.0.2}/compressedfhir/utilities/compressed_dict/v1/compressed_dict_access_error.py +0 -0
- {compressedfhir-1.0.0 → compressedfhir-1.0.2}/compressedfhir/utilities/compressed_dict/v1/compressed_dict_storage_mode.py +0 -0
- {compressedfhir-1.0.0 → compressedfhir-1.0.2}/compressedfhir/utilities/compressed_dict/v1/test/__init__.py +0 -0
- {compressedfhir-1.0.0 → compressedfhir-1.0.2}/compressedfhir/utilities/compressed_dict/v1/test/test_compressed_dict.py +0 -0
- {compressedfhir-1.0.0 → compressedfhir-1.0.2}/compressedfhir/utilities/json_helpers.py +0 -0
- {compressedfhir-1.0.0/tests → compressedfhir-1.0.2/compressedfhir/utilities/test}/__init__.py +0 -0
- {compressedfhir-1.0.0 → compressedfhir-1.0.2}/compressedfhir.egg-info/dependency_links.txt +0 -0
- {compressedfhir-1.0.0 → compressedfhir-1.0.2}/compressedfhir.egg-info/not-zip-safe +0 -0
- {compressedfhir-1.0.0 → compressedfhir-1.0.2}/compressedfhir.egg-info/requires.txt +0 -0
- {compressedfhir-1.0.0 → compressedfhir-1.0.2}/compressedfhir.egg-info/top_level.txt +0 -0
- {compressedfhir-1.0.0 → compressedfhir-1.0.2}/setup.cfg +0 -0
- {compressedfhir-1.0.0 → compressedfhir-1.0.2}/setup.py +0 -0
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: compressedfhir
|
|
3
|
+
Version: 1.0.2
|
|
4
|
+
Summary: Stores FHIR JSON resources in compressed form in memory
|
|
5
|
+
Home-page: https://github.com/icanbwell/compressed-fhir
|
|
6
|
+
Author: Imran Qureshi
|
|
7
|
+
Author-email: imran.qureshi@icanbwell.com
|
|
8
|
+
Classifier: Development Status :: 4 - Beta
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Requires-Python: >=3.10
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
Requires-Dist: msgpack>=1.0.0
|
|
16
|
+
Requires-Dist: orjson>=3.10.16
|
|
17
|
+
Dynamic: author
|
|
18
|
+
Dynamic: author-email
|
|
19
|
+
Dynamic: classifier
|
|
20
|
+
Dynamic: description
|
|
21
|
+
Dynamic: description-content-type
|
|
22
|
+
Dynamic: home-page
|
|
23
|
+
Dynamic: license-file
|
|
24
|
+
Dynamic: requires-dist
|
|
25
|
+
Dynamic: requires-python
|
|
26
|
+
Dynamic: summary
|
|
27
|
+
|
|
28
|
+
# Compressed FHIR
|
|
29
|
+
|
|
30
|
+
A Python library for storing FHIR JSON resources in a compressed form in memory, optimizing memory usage while maintaining fast access to FHIR data.
|
|
31
|
+
|
|
32
|
+
## Overview
|
|
33
|
+
|
|
34
|
+
Compressed FHIR is a specialized library that provides efficient memory storage for FHIR (Fast Healthcare Interoperability Resources) JSON resources. It uses zlib or msgpack for compression while ensuring quick access to the stored healthcare data.
|
|
35
|
+
|
|
36
|
+
## Features
|
|
37
|
+
|
|
38
|
+
- Efficient memory storage of FHIR resources
|
|
39
|
+
- Fast access to compressed FHIR data
|
|
40
|
+
- Compatible with standard FHIR JSON formats
|
|
41
|
+
- Minimal memory footprint
|
|
42
|
+
- Python 3.10+ support
|
|
43
|
+
|
|
44
|
+
## Installation
|
|
45
|
+
|
|
46
|
+
You can install the package using pip:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
pip install compressedfhir
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Or using pipenv:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
pipenv install compressedfhir
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Requirements
|
|
59
|
+
|
|
60
|
+
- Python 3.10 or higher
|
|
61
|
+
- msgpack >= 1.0.0
|
|
62
|
+
- orjson >= 3.10.16
|
|
63
|
+
|
|
64
|
+
## Usage
|
|
65
|
+
|
|
66
|
+
```python
|
|
67
|
+
from typing import Any
|
|
68
|
+
from collections import OrderedDict
|
|
69
|
+
|
|
70
|
+
from compressedfhir.fhir.fhir_resource import FhirResource
|
|
71
|
+
from compressedfhir.utilities.compressed_dict.v1.compressed_dict_storage_mode import CompressedDictStorageMode
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
resource1 = FhirResource(
|
|
75
|
+
initial_dict={"resourceType": "Observation", "id": "456"},
|
|
76
|
+
storage_mode=CompressedDictStorageMode.default(),
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
my_dict: OrderedDict[str,Any] = resource1.dict()
|
|
80
|
+
my_plain_dict: dict[str, Any] = resource1.to_plain_dict()
|
|
81
|
+
my_json: str = resource1.json()
|
|
82
|
+
|
|
83
|
+
with resource1.transaction():
|
|
84
|
+
assert "email" not in resource1
|
|
85
|
+
assert resource1.get("name") == "Custom Mode User"
|
|
86
|
+
assert resource1.get("active") is True
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Development Setup
|
|
90
|
+
|
|
91
|
+
1. Clone the repository:
|
|
92
|
+
```bash
|
|
93
|
+
git clone https://github.com/icanbwell/compressed-fhir.git
|
|
94
|
+
cd compressed-fhir
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
2. Install dependencies using pipenv:
|
|
98
|
+
```bash
|
|
99
|
+
pipenv install --dev
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
3. Set up pre-commit hooks:
|
|
103
|
+
```bash
|
|
104
|
+
pre-commit install
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Docker Support
|
|
108
|
+
|
|
109
|
+
The project includes Docker support for development and deployment:
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
# Build the Docker image
|
|
113
|
+
docker build -t compressed-fhir .
|
|
114
|
+
|
|
115
|
+
# Run using docker-compose
|
|
116
|
+
docker-compose up
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## Contributing
|
|
120
|
+
|
|
121
|
+
Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduct and the process for submitting pull requests.
|
|
122
|
+
|
|
123
|
+
## License
|
|
124
|
+
|
|
125
|
+
This project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details.
|
|
126
|
+
|
|
127
|
+
## Authors
|
|
128
|
+
|
|
129
|
+
- Imran Qureshi (imran.qureshi@icanbwell.com)
|
|
130
|
+
|
|
131
|
+
## Support
|
|
132
|
+
|
|
133
|
+
For support, please open an issue in the GitHub repository or contact the maintainers.
|
|
134
|
+
|
|
135
|
+
## Project Status
|
|
136
|
+
|
|
137
|
+
Current status: Beta
|
|
138
|
+
|
|
139
|
+
The project is under active development. Please check the GitHub repository for the latest updates and changes.
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# Compressed FHIR
|
|
2
|
+
|
|
3
|
+
A Python library for storing FHIR JSON resources in a compressed form in memory, optimizing memory usage while maintaining fast access to FHIR data.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
Compressed FHIR is a specialized library that provides efficient memory storage for FHIR (Fast Healthcare Interoperability Resources) JSON resources. It uses zlib or msgpack for compression while ensuring quick access to the stored healthcare data.
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
- Efficient memory storage of FHIR resources
|
|
12
|
+
- Fast access to compressed FHIR data
|
|
13
|
+
- Compatible with standard FHIR JSON formats
|
|
14
|
+
- Minimal memory footprint
|
|
15
|
+
- Python 3.10+ support
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
You can install the package using pip:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pip install compressedfhir
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Or using pipenv:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
pipenv install compressedfhir
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Requirements
|
|
32
|
+
|
|
33
|
+
- Python 3.10 or higher
|
|
34
|
+
- msgpack >= 1.0.0
|
|
35
|
+
- orjson >= 3.10.16
|
|
36
|
+
|
|
37
|
+
## Usage
|
|
38
|
+
|
|
39
|
+
```python
|
|
40
|
+
from typing import Any
|
|
41
|
+
from collections import OrderedDict
|
|
42
|
+
|
|
43
|
+
from compressedfhir.fhir.fhir_resource import FhirResource
|
|
44
|
+
from compressedfhir.utilities.compressed_dict.v1.compressed_dict_storage_mode import CompressedDictStorageMode
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
resource1 = FhirResource(
|
|
48
|
+
initial_dict={"resourceType": "Observation", "id": "456"},
|
|
49
|
+
storage_mode=CompressedDictStorageMode.default(),
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
my_dict: OrderedDict[str,Any] = resource1.dict()
|
|
53
|
+
my_plain_dict: dict[str, Any] = resource1.to_plain_dict()
|
|
54
|
+
my_json: str = resource1.json()
|
|
55
|
+
|
|
56
|
+
with resource1.transaction():
|
|
57
|
+
assert "email" not in resource1
|
|
58
|
+
assert resource1.get("name") == "Custom Mode User"
|
|
59
|
+
assert resource1.get("active") is True
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Development Setup
|
|
63
|
+
|
|
64
|
+
1. Clone the repository:
|
|
65
|
+
```bash
|
|
66
|
+
git clone https://github.com/icanbwell/compressed-fhir.git
|
|
67
|
+
cd compressed-fhir
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
2. Install dependencies using pipenv:
|
|
71
|
+
```bash
|
|
72
|
+
pipenv install --dev
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
3. Set up pre-commit hooks:
|
|
76
|
+
```bash
|
|
77
|
+
pre-commit install
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Docker Support
|
|
81
|
+
|
|
82
|
+
The project includes Docker support for development and deployment:
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
# Build the Docker image
|
|
86
|
+
docker build -t compressed-fhir .
|
|
87
|
+
|
|
88
|
+
# Run using docker-compose
|
|
89
|
+
docker-compose up
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Contributing
|
|
93
|
+
|
|
94
|
+
Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduct and the process for submitting pull requests.
|
|
95
|
+
|
|
96
|
+
## License
|
|
97
|
+
|
|
98
|
+
This project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details.
|
|
99
|
+
|
|
100
|
+
## Authors
|
|
101
|
+
|
|
102
|
+
- Imran Qureshi (imran.qureshi@icanbwell.com)
|
|
103
|
+
|
|
104
|
+
## Support
|
|
105
|
+
|
|
106
|
+
For support, please open an issue in the GitHub repository or contact the maintainers.
|
|
107
|
+
|
|
108
|
+
## Project Status
|
|
109
|
+
|
|
110
|
+
Current status: Beta
|
|
111
|
+
|
|
112
|
+
The project is under active development. Please check the GitHub repository for the latest updates and changes.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
1.0.2
|
{compressedfhir-1.0.0 → compressedfhir-1.0.2}/compressedfhir/fhir/fhir_bundle_entry_request.py
RENAMED
|
@@ -43,14 +43,16 @@ class FhirBundleEntryRequest:
|
|
|
43
43
|
def from_dict(
|
|
44
44
|
cls, d: Dict[str, Any] | OrderedDict[str, Any]
|
|
45
45
|
) -> "FhirBundleEntryRequest":
|
|
46
|
+
date_if_modified_since: Optional[datetime] = None
|
|
47
|
+
if "ifModifiedSince" in d:
|
|
48
|
+
if isinstance(d["ifModifiedSince"], datetime):
|
|
49
|
+
date_if_modified_since = d["ifModifiedSince"]
|
|
50
|
+
elif isinstance(d["ifModifiedSince"], str):
|
|
51
|
+
date_if_modified_since = datetime.fromisoformat(d["ifModifiedSince"])
|
|
46
52
|
return cls(
|
|
47
53
|
url=d.get("url", "https://example.com"),
|
|
48
54
|
method=d.get("method", "GET"),
|
|
49
|
-
ifModifiedSince=
|
|
50
|
-
datetime.fromisoformat(d["ifModifiedSince"])
|
|
51
|
-
if "ifModifiedSince" in d
|
|
52
|
-
else None
|
|
53
|
-
),
|
|
55
|
+
ifModifiedSince=date_if_modified_since,
|
|
54
56
|
ifNoneMatch=d["ifNoneMatch"] if "ifNoneMatch" in d else None,
|
|
55
57
|
ifNoneExist=d["ifNoneExist"] if "ifNoneExist" in d else None,
|
|
56
58
|
)
|
{compressedfhir-1.0.0 → compressedfhir-1.0.2}/compressedfhir/fhir/fhir_bundle_entry_response.py
RENAMED
|
@@ -41,13 +41,17 @@ class FhirBundleEntryResponse:
|
|
|
41
41
|
def from_dict(
|
|
42
42
|
cls, d: Dict[str, Any] | OrderedDict[str, Any]
|
|
43
43
|
) -> "FhirBundleEntryResponse":
|
|
44
|
+
|
|
45
|
+
date_last_modified: Optional[datetime] = None
|
|
46
|
+
if "lastModified" in d:
|
|
47
|
+
if isinstance(d["lastModified"], datetime):
|
|
48
|
+
date_last_modified = d["lastModified"]
|
|
49
|
+
elif isinstance(d["lastModified"], str):
|
|
50
|
+
date_last_modified = datetime.fromisoformat(d["lastModified"])
|
|
51
|
+
|
|
44
52
|
return cls(
|
|
45
53
|
status=d["status"] if "status" in d else "200",
|
|
46
|
-
lastModified=
|
|
47
|
-
datetime.fromisoformat(d["lastModified"])
|
|
48
|
-
if "lastModified" in d
|
|
49
|
-
else None
|
|
50
|
-
),
|
|
54
|
+
lastModified=date_last_modified,
|
|
51
55
|
etag=d["etag"] if "etag" in d else None,
|
|
52
56
|
location=d["location"] if "location" in d else None,
|
|
53
57
|
)
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import dataclasses
|
|
2
|
+
import json
|
|
3
|
+
import uuid
|
|
4
|
+
from datetime import datetime, date, time
|
|
5
|
+
from decimal import Decimal
|
|
6
|
+
from enum import Enum
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
from typing import Any
|
|
9
|
+
|
|
10
|
+
# Optional: Import for additional type support
|
|
11
|
+
try:
|
|
12
|
+
import ipaddress
|
|
13
|
+
except ImportError:
|
|
14
|
+
ipaddress = None # type:ignore[assignment]
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class FhirJSONEncoder(json.JSONEncoder):
|
|
18
|
+
def default(self, o: Any) -> Any:
|
|
19
|
+
# Existing type handlers
|
|
20
|
+
if dataclasses.is_dataclass(o):
|
|
21
|
+
return dataclasses.asdict(o) # type:ignore
|
|
22
|
+
|
|
23
|
+
if isinstance(o, Enum):
|
|
24
|
+
return o.value
|
|
25
|
+
|
|
26
|
+
if isinstance(o, Decimal):
|
|
27
|
+
# Custom Decimal conversion
|
|
28
|
+
if o == o.to_integral_value():
|
|
29
|
+
return int(o)
|
|
30
|
+
else:
|
|
31
|
+
return float(o)
|
|
32
|
+
|
|
33
|
+
if isinstance(o, bytes):
|
|
34
|
+
return o.decode("utf-8")
|
|
35
|
+
|
|
36
|
+
if isinstance(o, (datetime, date)):
|
|
37
|
+
return o.isoformat()
|
|
38
|
+
|
|
39
|
+
if isinstance(o, time):
|
|
40
|
+
return o.isoformat()
|
|
41
|
+
|
|
42
|
+
if hasattr(o, "to_dict"):
|
|
43
|
+
return o.to_dict()
|
|
44
|
+
|
|
45
|
+
# New type handlers
|
|
46
|
+
|
|
47
|
+
# UUID handling
|
|
48
|
+
if isinstance(o, uuid.UUID):
|
|
49
|
+
return str(o)
|
|
50
|
+
|
|
51
|
+
# Set and frozenset handling
|
|
52
|
+
if isinstance(o, (set, frozenset)):
|
|
53
|
+
return list(o)
|
|
54
|
+
|
|
55
|
+
# Complex number handling
|
|
56
|
+
if isinstance(o, complex):
|
|
57
|
+
return {"real": o.real, "imag": o.imag}
|
|
58
|
+
|
|
59
|
+
# Path-like objects
|
|
60
|
+
if isinstance(o, (Path, Path)):
|
|
61
|
+
return str(o)
|
|
62
|
+
|
|
63
|
+
# IP Address handling (if ipaddress module is available)
|
|
64
|
+
if ipaddress and isinstance(o, (ipaddress.IPv4Address, ipaddress.IPv6Address)):
|
|
65
|
+
return str(o)
|
|
66
|
+
|
|
67
|
+
# Custom object serialization fallback
|
|
68
|
+
if hasattr(o, "__dict__"):
|
|
69
|
+
return o.__dict__
|
|
70
|
+
|
|
71
|
+
return super().default(o)
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import dataclasses
|
|
2
|
+
import json
|
|
3
|
+
import uuid
|
|
4
|
+
from datetime import datetime, date, time
|
|
5
|
+
from decimal import Decimal
|
|
6
|
+
from enum import Enum
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
from typing import Optional, List
|
|
9
|
+
|
|
10
|
+
import pytest
|
|
11
|
+
|
|
12
|
+
from compressedfhir.utilities.fhir_json_encoder import FhirJSONEncoder
|
|
13
|
+
|
|
14
|
+
# Optional: Import for additional type support
|
|
15
|
+
try:
|
|
16
|
+
import ipaddress
|
|
17
|
+
except ImportError:
|
|
18
|
+
ipaddress = None # type:ignore[assignment]
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
# Test support classes and enums
|
|
22
|
+
class TestEnum(Enum):
|
|
23
|
+
OPTION1 = "value1"
|
|
24
|
+
OPTION2 = "value2"
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
@dataclasses.dataclass
|
|
28
|
+
class TestDataclass:
|
|
29
|
+
name: str
|
|
30
|
+
age: int
|
|
31
|
+
optional_field: Optional[str] = None
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class TestClassWithToDict:
|
|
35
|
+
# noinspection PyMethodMayBeStatic
|
|
36
|
+
def to_dict(self) -> dict[str, str]:
|
|
37
|
+
return {"key": "value"}
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def test_fhir_json_encoder_dataclass() -> None:
|
|
41
|
+
"""Test serialization of dataclass"""
|
|
42
|
+
test_obj = TestDataclass(name="John", age=30)
|
|
43
|
+
encoded = json.dumps(test_obj, cls=FhirJSONEncoder)
|
|
44
|
+
decoded = json.loads(encoded)
|
|
45
|
+
|
|
46
|
+
assert decoded == {"name": "John", "age": 30, "optional_field": None}
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def test_fhir_json_encoder_enum() -> None:
|
|
50
|
+
"""Test serialization of Enum"""
|
|
51
|
+
encoded = json.dumps(TestEnum.OPTION1, cls=FhirJSONEncoder)
|
|
52
|
+
assert encoded == '"value1"'
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def test_fhir_json_encoder_decimal() -> None:
|
|
56
|
+
"""Test Decimal conversion"""
|
|
57
|
+
# Whole number Decimal
|
|
58
|
+
whole_decimal = Decimal("10")
|
|
59
|
+
encoded_whole = json.dumps(whole_decimal, cls=FhirJSONEncoder)
|
|
60
|
+
assert encoded_whole == "10"
|
|
61
|
+
|
|
62
|
+
# Decimal with fractional part
|
|
63
|
+
frac_decimal = Decimal("10.5")
|
|
64
|
+
encoded_frac = json.dumps(frac_decimal, cls=FhirJSONEncoder)
|
|
65
|
+
assert encoded_frac == "10.5"
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def test_fhir_json_encoder_bytes() -> None:
|
|
69
|
+
"""Test bytes conversion"""
|
|
70
|
+
test_bytes = b"hello world"
|
|
71
|
+
encoded = json.dumps(test_bytes, cls=FhirJSONEncoder)
|
|
72
|
+
assert encoded == '"hello world"'
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def test_fhir_json_encoder_datetime() -> None:
|
|
76
|
+
"""Test datetime serialization"""
|
|
77
|
+
test_datetime = datetime(2023, 1, 15, 12, 30, 45)
|
|
78
|
+
encoded = json.dumps(test_datetime, cls=FhirJSONEncoder)
|
|
79
|
+
assert encoded == '"2023-01-15T12:30:45"'
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def test_fhir_json_encoder_date() -> None:
|
|
83
|
+
"""Test date serialization"""
|
|
84
|
+
test_date = date(2023, 1, 15)
|
|
85
|
+
encoded = json.dumps(test_date, cls=FhirJSONEncoder)
|
|
86
|
+
assert encoded == '"2023-01-15"'
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def test_fhir_json_encoder_time() -> None:
|
|
90
|
+
"""Test time serialization"""
|
|
91
|
+
test_time = time(12, 30, 45)
|
|
92
|
+
encoded = json.dumps(test_time, cls=FhirJSONEncoder)
|
|
93
|
+
assert encoded == '"12:30:45"'
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def test_fhir_json_encoder_to_dict() -> None:
|
|
97
|
+
"""Test objects with to_dict method"""
|
|
98
|
+
test_obj = TestClassWithToDict()
|
|
99
|
+
encoded = json.dumps(test_obj, cls=FhirJSONEncoder)
|
|
100
|
+
assert encoded == '{"key": "value"}'
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def test_fhir_json_encoder_unsupported_type() -> None:
|
|
104
|
+
"""Test fallback for unsupported types"""
|
|
105
|
+
|
|
106
|
+
class UnsupportedType:
|
|
107
|
+
__slots__: List[str] = []
|
|
108
|
+
|
|
109
|
+
with pytest.raises(TypeError):
|
|
110
|
+
json.dumps(UnsupportedType(), cls=FhirJSONEncoder)
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def test_extended_json_encoder_uuid() -> None:
|
|
114
|
+
"""Test UUID serialization"""
|
|
115
|
+
test_uuid = uuid.uuid4()
|
|
116
|
+
encoded = json.dumps(test_uuid, cls=FhirJSONEncoder)
|
|
117
|
+
assert isinstance(json.loads(encoded), str)
|
|
118
|
+
assert len(json.loads(encoded)) == 36 # Standard UUID string length
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def test_extended_json_encoder_set() -> None:
|
|
122
|
+
"""Test set and frozenset serialization"""
|
|
123
|
+
test_set = {1, 2, 3}
|
|
124
|
+
test_frozenset = frozenset([4, 5, 6])
|
|
125
|
+
|
|
126
|
+
encoded_set = json.dumps(test_set, cls=FhirJSONEncoder)
|
|
127
|
+
encoded_frozenset = json.dumps(test_frozenset, cls=FhirJSONEncoder)
|
|
128
|
+
|
|
129
|
+
decoded_set = json.loads(encoded_set)
|
|
130
|
+
decoded_frozenset = json.loads(encoded_frozenset)
|
|
131
|
+
|
|
132
|
+
assert set(decoded_set) == test_set
|
|
133
|
+
assert set(decoded_frozenset) == test_frozenset
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
def test_extended_json_encoder_complex() -> None:
|
|
137
|
+
"""Test complex number serialization"""
|
|
138
|
+
test_complex = 3 + 4j
|
|
139
|
+
encoded = json.dumps(test_complex, cls=FhirJSONEncoder)
|
|
140
|
+
decoded = json.loads(encoded)
|
|
141
|
+
|
|
142
|
+
assert decoded == {"real": 3.0, "imag": 4.0}
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
def test_extended_json_encoder_path() -> None:
|
|
146
|
+
"""Test Path object serialization"""
|
|
147
|
+
test_path = Path("/test/path")
|
|
148
|
+
encoded = json.dumps(test_path, cls=FhirJSONEncoder)
|
|
149
|
+
assert json.loads(encoded) == str(test_path)
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
def test_extended_json_encoder_ip_address() -> None:
|
|
153
|
+
"""Test IP Address serialization (if ipaddress module is available)"""
|
|
154
|
+
if ipaddress:
|
|
155
|
+
ipv4 = ipaddress.IPv4Address("192.168.0.1")
|
|
156
|
+
ipv6 = ipaddress.IPv6Address("2001:0db8:85a3:0000:0000:8a2e:0370:7334")
|
|
157
|
+
|
|
158
|
+
encoded_ipv4 = json.dumps(ipv4, cls=FhirJSONEncoder)
|
|
159
|
+
encoded_ipv6 = json.dumps(ipv6, cls=FhirJSONEncoder)
|
|
160
|
+
|
|
161
|
+
assert json.loads(encoded_ipv4) == str(ipv4)
|
|
162
|
+
assert json.loads(encoded_ipv6) == str(ipv6)
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
def test_extended_json_encoder_custom_object() -> None:
|
|
166
|
+
"""Test custom object serialization"""
|
|
167
|
+
|
|
168
|
+
class CustomObject:
|
|
169
|
+
def __init__(self) -> None:
|
|
170
|
+
self.x = 1
|
|
171
|
+
self.y = 2
|
|
172
|
+
|
|
173
|
+
obj = CustomObject()
|
|
174
|
+
encoded = json.dumps(obj, cls=FhirJSONEncoder)
|
|
175
|
+
decoded = json.loads(encoded)
|
|
176
|
+
|
|
177
|
+
assert decoded == {"x": 1, "y": 2}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import json
|
|
2
|
+
from datetime import datetime, date
|
|
3
|
+
from typing import List, Dict, Any
|
|
4
|
+
|
|
5
|
+
from compressedfhir.utilities.json_helpers import FhirClientJsonHelpers
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class TestFhirClientJsonHelpers:
|
|
9
|
+
def test_json_serial(self) -> None:
|
|
10
|
+
# Test datetime serialization
|
|
11
|
+
dt = datetime(2023, 1, 15, 12, 30)
|
|
12
|
+
assert FhirClientJsonHelpers.json_serial(dt) == "2023-01-15T12:30:00"
|
|
13
|
+
|
|
14
|
+
# Test date serialization
|
|
15
|
+
d = date(2023, 1, 15)
|
|
16
|
+
assert FhirClientJsonHelpers.json_serial(d) == "2023-01-15"
|
|
17
|
+
|
|
18
|
+
# Test other types
|
|
19
|
+
assert FhirClientJsonHelpers.json_serial(123) == "123"
|
|
20
|
+
assert FhirClientJsonHelpers.json_serial("test") == "test"
|
|
21
|
+
|
|
22
|
+
def test_remove_empty_elements(self) -> None:
|
|
23
|
+
# Test dictionary removal
|
|
24
|
+
input_dict = {"a": 1, "b": "", "c": None, "d": [], "e": {}, "f": [1, 2, 3]}
|
|
25
|
+
expected_dict = {"a": 1, "f": [1, 2, 3]}
|
|
26
|
+
assert FhirClientJsonHelpers.remove_empty_elements(input_dict) == expected_dict
|
|
27
|
+
|
|
28
|
+
# Test list of dictionaries
|
|
29
|
+
input_list: List[Dict[str, Any]] = [
|
|
30
|
+
{"a": 1, "b": None},
|
|
31
|
+
{"c": [], "d": "test"},
|
|
32
|
+
{"e": {}},
|
|
33
|
+
]
|
|
34
|
+
expected_list: List[Dict[str, Any]] = [{"a": 1}, {"d": "test"}]
|
|
35
|
+
assert FhirClientJsonHelpers.remove_empty_elements(input_list) == expected_list
|
|
36
|
+
|
|
37
|
+
def test_remove_empty_elements_from_ordered_dict(self) -> None:
|
|
38
|
+
from collections import OrderedDict
|
|
39
|
+
|
|
40
|
+
# Test OrderedDict removal
|
|
41
|
+
input_dict = OrderedDict(
|
|
42
|
+
[("a", 1), ("b", ""), ("c", None), ("d", []), ("e", {}), ("f", [1, 2, 3])]
|
|
43
|
+
)
|
|
44
|
+
expected_dict = OrderedDict([("a", 1), ("f", [1, 2, 3])])
|
|
45
|
+
result: List[OrderedDict[str, Any]] | OrderedDict[str, Any] = (
|
|
46
|
+
FhirClientJsonHelpers.remove_empty_elements_from_ordered_dict(input_dict)
|
|
47
|
+
)
|
|
48
|
+
assert result == expected_dict
|
|
49
|
+
|
|
50
|
+
# Test list of OrderedDicts
|
|
51
|
+
input_list: List[OrderedDict[str, Any]] = [
|
|
52
|
+
OrderedDict([("a", 1), ("b", None)]),
|
|
53
|
+
OrderedDict([("c", []), ("d", "test")]),
|
|
54
|
+
OrderedDict([("e", {})]),
|
|
55
|
+
]
|
|
56
|
+
expected_list: List[OrderedDict[str, Any]] = [
|
|
57
|
+
OrderedDict([("a", 1)]),
|
|
58
|
+
OrderedDict([("d", "test")]),
|
|
59
|
+
]
|
|
60
|
+
result = FhirClientJsonHelpers.remove_empty_elements_from_ordered_dict(
|
|
61
|
+
input_list
|
|
62
|
+
)
|
|
63
|
+
assert result == expected_list
|
|
64
|
+
|
|
65
|
+
def test_convert_dict_to_fhir_json(self) -> None:
|
|
66
|
+
input_dict = {"name": "John Doe", "age": 30, "address": None, "hobbies": []}
|
|
67
|
+
result = FhirClientJsonHelpers.convert_dict_to_fhir_json(input_dict)
|
|
68
|
+
parsed_result = json.loads(result)
|
|
69
|
+
assert parsed_result == {"name": "John Doe", "age": 30}
|
|
70
|
+
|
|
71
|
+
def test_orjson_dumps(self) -> None:
|
|
72
|
+
# Test basic serialization
|
|
73
|
+
data = {"a": 1, "b": "test"}
|
|
74
|
+
result = FhirClientJsonHelpers.orjson_dumps(data)
|
|
75
|
+
assert json.loads(result) == data
|
|
76
|
+
|
|
77
|
+
# Test sorting keys
|
|
78
|
+
result_sorted = FhirClientJsonHelpers.orjson_dumps(data, sort_keys=True)
|
|
79
|
+
assert result_sorted == '{"a":1,"b":"test"}'
|
|
80
|
+
|
|
81
|
+
# Test indentation (limited support)
|
|
82
|
+
result_indent = FhirClientJsonHelpers.orjson_dumps(data, indent=2)
|
|
83
|
+
assert isinstance(result_indent, str)
|
|
84
|
+
|
|
85
|
+
def test_orjson_loads(self) -> None:
|
|
86
|
+
# Test string input
|
|
87
|
+
json_str = '{"a": 1, "b": "test"}'
|
|
88
|
+
result = FhirClientJsonHelpers.orjson_loads(json_str)
|
|
89
|
+
assert result == {"a": 1, "b": "test"}
|
|
90
|
+
|
|
91
|
+
# Test bytes input
|
|
92
|
+
json_bytes = b'{"a": 1, "b": "test"}'
|
|
93
|
+
result = FhirClientJsonHelpers.orjson_loads(json_bytes)
|
|
94
|
+
assert result == {"a": 1, "b": "test"}
|
|
95
|
+
|
|
96
|
+
# Test invalid JSON
|
|
97
|
+
invalid_json = "{invalid json}"
|
|
98
|
+
result = FhirClientJsonHelpers.orjson_loads(invalid_json)
|
|
99
|
+
assert result is None
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: compressedfhir
|
|
3
|
+
Version: 1.0.2
|
|
4
|
+
Summary: Stores FHIR JSON resources in compressed form in memory
|
|
5
|
+
Home-page: https://github.com/icanbwell/compressed-fhir
|
|
6
|
+
Author: Imran Qureshi
|
|
7
|
+
Author-email: imran.qureshi@icanbwell.com
|
|
8
|
+
Classifier: Development Status :: 4 - Beta
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Requires-Python: >=3.10
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
Requires-Dist: msgpack>=1.0.0
|
|
16
|
+
Requires-Dist: orjson>=3.10.16
|
|
17
|
+
Dynamic: author
|
|
18
|
+
Dynamic: author-email
|
|
19
|
+
Dynamic: classifier
|
|
20
|
+
Dynamic: description
|
|
21
|
+
Dynamic: description-content-type
|
|
22
|
+
Dynamic: home-page
|
|
23
|
+
Dynamic: license-file
|
|
24
|
+
Dynamic: requires-dist
|
|
25
|
+
Dynamic: requires-python
|
|
26
|
+
Dynamic: summary
|
|
27
|
+
|
|
28
|
+
# Compressed FHIR
|
|
29
|
+
|
|
30
|
+
A Python library for storing FHIR JSON resources in a compressed form in memory, optimizing memory usage while maintaining fast access to FHIR data.
|
|
31
|
+
|
|
32
|
+
## Overview
|
|
33
|
+
|
|
34
|
+
Compressed FHIR is a specialized library that provides efficient memory storage for FHIR (Fast Healthcare Interoperability Resources) JSON resources. It uses zlib or msgpack for compression while ensuring quick access to the stored healthcare data.
|
|
35
|
+
|
|
36
|
+
## Features
|
|
37
|
+
|
|
38
|
+
- Efficient memory storage of FHIR resources
|
|
39
|
+
- Fast access to compressed FHIR data
|
|
40
|
+
- Compatible with standard FHIR JSON formats
|
|
41
|
+
- Minimal memory footprint
|
|
42
|
+
- Python 3.10+ support
|
|
43
|
+
|
|
44
|
+
## Installation
|
|
45
|
+
|
|
46
|
+
You can install the package using pip:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
pip install compressedfhir
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Or using pipenv:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
pipenv install compressedfhir
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Requirements
|
|
59
|
+
|
|
60
|
+
- Python 3.10 or higher
|
|
61
|
+
- msgpack >= 1.0.0
|
|
62
|
+
- orjson >= 3.10.16
|
|
63
|
+
|
|
64
|
+
## Usage
|
|
65
|
+
|
|
66
|
+
```python
|
|
67
|
+
from typing import Any
|
|
68
|
+
from collections import OrderedDict
|
|
69
|
+
|
|
70
|
+
from compressedfhir.fhir.fhir_resource import FhirResource
|
|
71
|
+
from compressedfhir.utilities.compressed_dict.v1.compressed_dict_storage_mode import CompressedDictStorageMode
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
resource1 = FhirResource(
|
|
75
|
+
initial_dict={"resourceType": "Observation", "id": "456"},
|
|
76
|
+
storage_mode=CompressedDictStorageMode.default(),
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
my_dict: OrderedDict[str,Any] = resource1.dict()
|
|
80
|
+
my_plain_dict: dict[str, Any] = resource1.to_plain_dict()
|
|
81
|
+
my_json: str = resource1.json()
|
|
82
|
+
|
|
83
|
+
with resource1.transaction():
|
|
84
|
+
assert "email" not in resource1
|
|
85
|
+
assert resource1.get("name") == "Custom Mode User"
|
|
86
|
+
assert resource1.get("active") is True
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Development Setup
|
|
90
|
+
|
|
91
|
+
1. Clone the repository:
|
|
92
|
+
```bash
|
|
93
|
+
git clone https://github.com/icanbwell/compressed-fhir.git
|
|
94
|
+
cd compressed-fhir
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
2. Install dependencies using pipenv:
|
|
98
|
+
```bash
|
|
99
|
+
pipenv install --dev
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
3. Set up pre-commit hooks:
|
|
103
|
+
```bash
|
|
104
|
+
pre-commit install
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Docker Support
|
|
108
|
+
|
|
109
|
+
The project includes Docker support for development and deployment:
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
# Build the Docker image
|
|
113
|
+
docker build -t compressed-fhir .
|
|
114
|
+
|
|
115
|
+
# Run using docker-compose
|
|
116
|
+
docker-compose up
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## Contributing
|
|
120
|
+
|
|
121
|
+
Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduct and the process for submitting pull requests.
|
|
122
|
+
|
|
123
|
+
## License
|
|
124
|
+
|
|
125
|
+
This project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details.
|
|
126
|
+
|
|
127
|
+
## Authors
|
|
128
|
+
|
|
129
|
+
- Imran Qureshi (imran.qureshi@icanbwell.com)
|
|
130
|
+
|
|
131
|
+
## Support
|
|
132
|
+
|
|
133
|
+
For support, please open an issue in the GitHub repository or contact the maintainers.
|
|
134
|
+
|
|
135
|
+
## Project Status
|
|
136
|
+
|
|
137
|
+
Current status: Beta
|
|
138
|
+
|
|
139
|
+
The project is under active development. Please check the GitHub repository for the latest updates and changes.
|
|
@@ -46,4 +46,7 @@ compressedfhir/utilities/compressed_dict/v1/compressed_dict_access_error.py
|
|
|
46
46
|
compressedfhir/utilities/compressed_dict/v1/compressed_dict_storage_mode.py
|
|
47
47
|
compressedfhir/utilities/compressed_dict/v1/test/__init__.py
|
|
48
48
|
compressedfhir/utilities/compressed_dict/v1/test/test_compressed_dict.py
|
|
49
|
+
compressedfhir/utilities/test/__init__.py
|
|
50
|
+
compressedfhir/utilities/test/test_fhir_json_encoder.py
|
|
51
|
+
compressedfhir/utilities/test/test_json_helpers.py
|
|
49
52
|
tests/__init__.py
|
|
File without changes
|
compressedfhir-1.0.0/PKG-INFO
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: compressedfhir
|
|
3
|
-
Version: 1.0.0
|
|
4
|
-
Summary: Stores FHIR JSON resources in compressed form in memory
|
|
5
|
-
Home-page: https://github.com/icanbwell/compressed-fhir
|
|
6
|
-
Author: Imran Qureshi
|
|
7
|
-
Author-email: imran.qureshi@icanbwell.com
|
|
8
|
-
Classifier: Development Status :: 4 - Beta
|
|
9
|
-
Classifier: Programming Language :: Python :: 3
|
|
10
|
-
Classifier: License :: OSI Approved :: Apache Software License
|
|
11
|
-
Classifier: Operating System :: OS Independent
|
|
12
|
-
Requires-Python: >=3.10
|
|
13
|
-
Description-Content-Type: text/markdown
|
|
14
|
-
License-File: LICENSE
|
|
15
|
-
Requires-Dist: msgpack>=1.0.0
|
|
16
|
-
Requires-Dist: orjson>=3.10.16
|
|
17
|
-
Dynamic: author
|
|
18
|
-
Dynamic: author-email
|
|
19
|
-
Dynamic: classifier
|
|
20
|
-
Dynamic: description
|
|
21
|
-
Dynamic: description-content-type
|
|
22
|
-
Dynamic: home-page
|
|
23
|
-
Dynamic: license-file
|
|
24
|
-
Dynamic: requires-dist
|
|
25
|
-
Dynamic: requires-python
|
|
26
|
-
Dynamic: summary
|
|
27
|
-
|
|
28
|
-
# compressedfhir
|
compressedfhir-1.0.0/README.md
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
# compressedfhir
|
compressedfhir-1.0.0/VERSION
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
1.0.0
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import dataclasses
|
|
2
|
-
import json
|
|
3
|
-
from datetime import datetime, date
|
|
4
|
-
from decimal import Decimal
|
|
5
|
-
from enum import Enum
|
|
6
|
-
from typing import Any
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class FhirJSONEncoder(json.JSONEncoder):
|
|
10
|
-
def default(self, o: Any) -> Any:
|
|
11
|
-
if dataclasses.is_dataclass(o):
|
|
12
|
-
return dataclasses.asdict(o) # type:ignore
|
|
13
|
-
if isinstance(o, Enum):
|
|
14
|
-
return o.value
|
|
15
|
-
if isinstance(o, Decimal):
|
|
16
|
-
# Custom Decimal conversion
|
|
17
|
-
if o == o.to_integral_value():
|
|
18
|
-
# If Decimal is a whole number, return as int
|
|
19
|
-
return int(o)
|
|
20
|
-
else:
|
|
21
|
-
# If Decimal has a non-zero decimal part, return as float
|
|
22
|
-
return float(o)
|
|
23
|
-
if isinstance(o, bytes):
|
|
24
|
-
return o.decode("utf-8")
|
|
25
|
-
if isinstance(o, (datetime, date)):
|
|
26
|
-
return o.isoformat()
|
|
27
|
-
if hasattr(o, "to_dict"):
|
|
28
|
-
return o.dict()
|
|
29
|
-
|
|
30
|
-
return super().default(o)
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: compressedfhir
|
|
3
|
-
Version: 1.0.0
|
|
4
|
-
Summary: Stores FHIR JSON resources in compressed form in memory
|
|
5
|
-
Home-page: https://github.com/icanbwell/compressed-fhir
|
|
6
|
-
Author: Imran Qureshi
|
|
7
|
-
Author-email: imran.qureshi@icanbwell.com
|
|
8
|
-
Classifier: Development Status :: 4 - Beta
|
|
9
|
-
Classifier: Programming Language :: Python :: 3
|
|
10
|
-
Classifier: License :: OSI Approved :: Apache Software License
|
|
11
|
-
Classifier: Operating System :: OS Independent
|
|
12
|
-
Requires-Python: >=3.10
|
|
13
|
-
Description-Content-Type: text/markdown
|
|
14
|
-
License-File: LICENSE
|
|
15
|
-
Requires-Dist: msgpack>=1.0.0
|
|
16
|
-
Requires-Dist: orjson>=3.10.16
|
|
17
|
-
Dynamic: author
|
|
18
|
-
Dynamic: author-email
|
|
19
|
-
Dynamic: classifier
|
|
20
|
-
Dynamic: description
|
|
21
|
-
Dynamic: description-content-type
|
|
22
|
-
Dynamic: home-page
|
|
23
|
-
Dynamic: license-file
|
|
24
|
-
Dynamic: requires-dist
|
|
25
|
-
Dynamic: requires-python
|
|
26
|
-
Dynamic: summary
|
|
27
|
-
|
|
28
|
-
# compressedfhir
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{compressedfhir-1.0.0 → compressedfhir-1.0.2}/compressedfhir/fhir/fhir_bundle_entry_search.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{compressedfhir-1.0.0 → compressedfhir-1.0.2}/compressedfhir/fhir/test/test_bundle_entry_list.py
RENAMED
|
File without changes
|
{compressedfhir-1.0.0 → compressedfhir-1.0.2}/compressedfhir/fhir/test/test_bundle_entry_request.py
RENAMED
|
File without changes
|
{compressedfhir-1.0.0 → compressedfhir-1.0.2}/compressedfhir/fhir/test/test_bundle_entry_response.py
RENAMED
|
File without changes
|
|
File without changes
|
{compressedfhir-1.0.0 → compressedfhir-1.0.2}/compressedfhir/fhir/test/test_fhir_resource.py
RENAMED
|
File without changes
|
{compressedfhir-1.0.0 → compressedfhir-1.0.2}/compressedfhir/fhir/test/test_fhir_resource_list.py
RENAMED
|
File without changes
|
{compressedfhir-1.0.0 → compressedfhir-1.0.2}/compressedfhir/fhir/test/test_fhir_resource_map.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{compressedfhir-1.0.0 → compressedfhir-1.0.2}/compressedfhir/utilities/compressed_dict/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{compressedfhir-1.0.0/tests → compressedfhir-1.0.2/compressedfhir/utilities/test}/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|