compressedfhir 1.0.5__py3-none-any.whl → 1.0.7__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.
Potentially problematic release.
This version of compressedfhir might be problematic. Click here for more details.
- compressedfhir/fhir/fhir_resource.py +8 -0
- compressedfhir/utilities/compressed_dict/v1/compressed_dict.py +5 -1
- compressedfhir/utilities/json_serializers/test/test_type_preservation_serializer.py +9 -4
- {compressedfhir-1.0.5.dist-info → compressedfhir-1.0.7.dist-info}/METADATA +1 -1
- {compressedfhir-1.0.5.dist-info → compressedfhir-1.0.7.dist-info}/RECORD +8 -8
- {compressedfhir-1.0.5.dist-info → compressedfhir-1.0.7.dist-info}/WHEEL +0 -0
- {compressedfhir-1.0.5.dist-info → compressedfhir-1.0.7.dist-info}/licenses/LICENSE +0 -0
- {compressedfhir-1.0.5.dist-info → compressedfhir-1.0.7.dist-info}/top_level.txt +0 -0
|
@@ -156,3 +156,11 @@ class FhirResource(CompressedDict[str, Any]):
|
|
|
156
156
|
raw_dict
|
|
157
157
|
)
|
|
158
158
|
return json.dumps(obj=raw_dict, cls=FhirJSONEncoder)
|
|
159
|
+
|
|
160
|
+
def to_fhir_dict(self) -> Dict[str, Any]:
|
|
161
|
+
"""
|
|
162
|
+
Convert the resource to a FHIR-compliant dictionary.
|
|
163
|
+
|
|
164
|
+
:return: A dictionary representation of the resource.
|
|
165
|
+
"""
|
|
166
|
+
return cast(Dict[str, Any], json.loads(self.json()))
|
|
@@ -429,6 +429,7 @@ class CompressedDict[K, V](MutableMapping[K, V]):
|
|
|
429
429
|
"""
|
|
430
430
|
Returns the raw dictionary. Deserializes if necessary.
|
|
431
431
|
Note that this dictionary preserves the python types so it is not FHIR friendly.
|
|
432
|
+
For example, datetime will be represented as a datetime object instead of iso format string per FHIR.
|
|
432
433
|
Use dict() if you want a FHIR friendly version.
|
|
433
434
|
|
|
434
435
|
Returns:
|
|
@@ -437,12 +438,14 @@ class CompressedDict[K, V](MutableMapping[K, V]):
|
|
|
437
438
|
if self._working_dict:
|
|
438
439
|
return self._working_dict
|
|
439
440
|
else:
|
|
440
|
-
# if the working dict is
|
|
441
|
+
# if the working dict is None, create and return it but don't store it
|
|
442
|
+
# in the self._working_dict to keep memory low
|
|
441
443
|
return self.create_working_dict()
|
|
442
444
|
|
|
443
445
|
def dict(self) -> OrderedDict[K, V]:
|
|
444
446
|
"""
|
|
445
447
|
Convert to a FHIR friendly dictionary where the python types like datetime are converted to string versions
|
|
448
|
+
For example, datetime will be represented as a iso format string per FHIR instead of a python datetime object.
|
|
446
449
|
|
|
447
450
|
Returns:
|
|
448
451
|
FHIR friendly dictionary
|
|
@@ -585,6 +588,7 @@ class CompressedDict[K, V](MutableMapping[K, V]):
|
|
|
585
588
|
"""
|
|
586
589
|
# Create a new instance with the same storage mode
|
|
587
590
|
new_instance = CompressedDict(
|
|
591
|
+
# we use raw_dict() instead of dict() so we can preserve python data types like datetime
|
|
588
592
|
initial_dict=copy.deepcopy(self.raw_dict()),
|
|
589
593
|
storage_mode=self._storage_mode,
|
|
590
594
|
properties_to_cache=self._properties_to_cache,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import logging
|
|
2
|
+
from collections import OrderedDict
|
|
2
3
|
from datetime import datetime, timezone, date
|
|
3
4
|
from decimal import Decimal
|
|
4
5
|
from logging import Logger
|
|
@@ -68,6 +69,8 @@ def test_nested_dict() -> None:
|
|
|
68
69
|
"""
|
|
69
70
|
logger: Logger = logging.getLogger(__name__)
|
|
70
71
|
nested_dict = {
|
|
72
|
+
"resourceType": "Coverage",
|
|
73
|
+
"id": "3456789012345670304",
|
|
71
74
|
"beneficiary": {"reference": "Patient/1234567890123456703", "type": "Patient"},
|
|
72
75
|
"class": [
|
|
73
76
|
{
|
|
@@ -94,7 +97,6 @@ def test_nested_dict() -> None:
|
|
|
94
97
|
},
|
|
95
98
|
}
|
|
96
99
|
],
|
|
97
|
-
"id": "3456789012345670304",
|
|
98
100
|
"identifier": [
|
|
99
101
|
{
|
|
100
102
|
"system": "https://sources.aetna.com/coverage/identifier/membershipid/59",
|
|
@@ -144,7 +146,6 @@ def test_nested_dict() -> None:
|
|
|
144
146
|
}
|
|
145
147
|
]
|
|
146
148
|
},
|
|
147
|
-
"resourceType": "Coverage",
|
|
148
149
|
"status": "active",
|
|
149
150
|
"subscriber": {"reference": "Patient/1234567890123456703", "type": "Patient"},
|
|
150
151
|
"subscriberId": "435679010300",
|
|
@@ -160,12 +161,16 @@ def test_nested_dict() -> None:
|
|
|
160
161
|
}
|
|
161
162
|
|
|
162
163
|
logger.info("-------- Serialized --------")
|
|
163
|
-
serialized = TypePreservationSerializer.serialize(nested_dict)
|
|
164
|
+
serialized: str = TypePreservationSerializer.serialize(nested_dict)
|
|
164
165
|
logger.info(serialized)
|
|
165
166
|
logger.info("-------- Deserialized --------")
|
|
166
|
-
deserialized = TypePreservationSerializer.deserialize(
|
|
167
|
+
deserialized: OrderedDict[str, Any] = TypePreservationSerializer.deserialize(
|
|
168
|
+
serialized
|
|
169
|
+
)
|
|
167
170
|
logger.info(deserialized)
|
|
168
171
|
|
|
172
|
+
assert isinstance(deserialized, OrderedDict)
|
|
173
|
+
|
|
169
174
|
assert isinstance(deserialized["period"]["start"], date)
|
|
170
175
|
assert isinstance(deserialized["period"]["end"], date)
|
|
171
176
|
assert nested_dict == deserialized
|
|
@@ -11,7 +11,7 @@ compressedfhir/fhir/fhir_bundle_entry_search.py,sha256=uYVJxuNN3gt3Q6BZ5FhRs47x7
|
|
|
11
11
|
compressedfhir/fhir/fhir_identifier.py,sha256=tA_nmhBaYHu5zjJdE0IWMFEF8lrIPV3_nu-yairiIKw,2711
|
|
12
12
|
compressedfhir/fhir/fhir_link.py,sha256=jf2RrwmsPrKW3saP77y42xVqI0xwHFYXxm6YHQJk7gU,1922
|
|
13
13
|
compressedfhir/fhir/fhir_meta.py,sha256=vNI4O6SoG4hJRHyd-bJ_QnYFTfBHyR3UA6h21ByQmWo,1669
|
|
14
|
-
compressedfhir/fhir/fhir_resource.py,sha256=
|
|
14
|
+
compressedfhir/fhir/fhir_resource.py,sha256=WDrS6ZAQARsTfEsKNhNIgCw8vir_U-1nBzFGt510OBw,5340
|
|
15
15
|
compressedfhir/fhir/fhir_resource_list.py,sha256=qlAAwWWphtFicBxPG8iriz2eOHGcrWJk5kGThmvkbPE,4480
|
|
16
16
|
compressedfhir/fhir/fhir_resource_map.py,sha256=XFJ0o5_kLUeHYKp1q_Bxsoyp2-rLX7P4c9FwQ7YfGWM,6571
|
|
17
17
|
compressedfhir/fhir/test/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -28,7 +28,7 @@ compressedfhir/utilities/fhir_json_encoder.py,sha256=hn-ZuDrTEdYZmILk_5_k4R72PQB
|
|
|
28
28
|
compressedfhir/utilities/json_helpers.py,sha256=lEiPapLN0p-kLu6PFm-h971ieXRxwPB2M-8FCZ2Buo8,5642
|
|
29
29
|
compressedfhir/utilities/compressed_dict/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
30
30
|
compressedfhir/utilities/compressed_dict/v1/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
31
|
-
compressedfhir/utilities/compressed_dict/v1/compressed_dict.py,sha256=
|
|
31
|
+
compressedfhir/utilities/compressed_dict/v1/compressed_dict.py,sha256=fvsIxizmOfLohXkoHxN6jEBvQ66La9K5P-5DfESU5bk,22400
|
|
32
32
|
compressedfhir/utilities/compressed_dict/v1/compressed_dict_access_error.py,sha256=xuwED0KGZcQORIcZRfi--5CdXplHJ5vYLBUqpbDi344,132
|
|
33
33
|
compressedfhir/utilities/compressed_dict/v1/compressed_dict_storage_mode.py,sha256=mEdtJjPX2I9DqP0Ly_VsZZWhEMNTI1psqQ8iJtUQ2oE,1412
|
|
34
34
|
compressedfhir/utilities/compressed_dict/v1/test/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -40,7 +40,7 @@ compressedfhir/utilities/json_serializers/type_preservation_serializer.py,sha256
|
|
|
40
40
|
compressedfhir/utilities/json_serializers/test/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
41
41
|
compressedfhir/utilities/json_serializers/test/test_type_preservation_decoder.py,sha256=GQotwYQJe9VZQotvLWmQWMkSIBne53bolmgflBoR7DU,4752
|
|
42
42
|
compressedfhir/utilities/json_serializers/test/test_type_preservation_encoder.py,sha256=O4VczBdsJF35WozZiwSdJ8638qDn01JQsai2wTXu5Vo,1737
|
|
43
|
-
compressedfhir/utilities/json_serializers/test/test_type_preservation_serializer.py,sha256=
|
|
43
|
+
compressedfhir/utilities/json_serializers/test/test_type_preservation_serializer.py,sha256=jRl0UEzvsjj1Kl2_7VYCf3kaJch9UZ2-8VHdKZC69xo,6171
|
|
44
44
|
compressedfhir/utilities/ordered_dict_to_dict_converter/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
45
45
|
compressedfhir/utilities/ordered_dict_to_dict_converter/ordered_dict_to_dict_converter.py,sha256=CMerJQD7O0vMyGtUp1rKSerZA1tDZeY5GTQT3AykL4w,831
|
|
46
46
|
compressedfhir/utilities/string_compressor/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -51,9 +51,9 @@ compressedfhir/utilities/string_compressor/v1/test/test_string_compressor.py,sha
|
|
|
51
51
|
compressedfhir/utilities/test/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
52
52
|
compressedfhir/utilities/test/test_fhir_json_encoder.py,sha256=6pbNmZp5eBWY66bHjgjm_pZVhs5HDKP8hCGnwNFzpEw,5171
|
|
53
53
|
compressedfhir/utilities/test/test_json_helpers.py,sha256=V0R9oHDQAs0m0012niEz50sHJxMSUQvA3km7kK8HgjE,3860
|
|
54
|
-
compressedfhir-1.0.
|
|
54
|
+
compressedfhir-1.0.7.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
55
55
|
tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
56
|
-
compressedfhir-1.0.
|
|
57
|
-
compressedfhir-1.0.
|
|
58
|
-
compressedfhir-1.0.
|
|
59
|
-
compressedfhir-1.0.
|
|
56
|
+
compressedfhir-1.0.7.dist-info/METADATA,sha256=9KZZ4ummH8dgEpDshUgDVmwg2MY87xjZ8qVsII9IPx4,3456
|
|
57
|
+
compressedfhir-1.0.7.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
|
58
|
+
compressedfhir-1.0.7.dist-info/top_level.txt,sha256=YMKdvBBdiCzFbpI9fG8BUDjaRd-f4R0qAvUoVETpoWw,21
|
|
59
|
+
compressedfhir-1.0.7.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|