File tree 6 files changed +28
-5
lines changed
6 files changed +28
-5
lines changed Original file line number Diff line number Diff line change
1
+ ## 2.0.12
2
+
3
+ * Fix fetch_raw for custom resource class
4
+
1
5
## 2.0.11
2
6
3
7
* Rename dump to dump_resource
Original file line number Diff line number Diff line change 1
1
from .lib import AsyncFHIRClient , SyncFHIRClient
2
2
3
3
__title__ = "fhir-py"
4
- __version__ = "2.0.11 "
4
+ __version__ = "2.0.12 "
5
5
__author__ = "beda.software"
6
6
__license__ = "None"
7
7
__copyright__ = "Copyright 2024 beda.software"
Original file line number Diff line number Diff line change @@ -400,8 +400,8 @@ async def fetch_raw(self) -> Any:
400
400
data = await self .client ._fetch_resource (self .resource_type , self .params )
401
401
data_resource_type = data .get ("resourceType" , None )
402
402
403
- if data_resource_type == "Bundle" :
404
- for item in data [ "entry" ] :
403
+ if data_resource_type == "Bundle" and not self . custom_resource_class :
404
+ for item in data . get ( "entry" , []) :
405
405
item .resource = self ._dict_to_resource (item .resource )
406
406
407
407
return data
Original file line number Diff line number Diff line change @@ -398,8 +398,8 @@ def fetch_raw(self) -> Any:
398
398
data = self .client ._fetch_resource (self .resource_type , self .params )
399
399
data_resource_type = data .get ("resourceType" , None )
400
400
401
- if data_resource_type == "Bundle" :
402
- for item in data [ "entry" ] :
401
+ if data_resource_type == "Bundle" and not self . custom_resource_class :
402
+ for item in data . get ( "entry" , []) :
403
403
item .resource = self ._dict_to_resource (item .resource )
404
404
405
405
return data
Original file line number Diff line number Diff line change @@ -792,6 +792,16 @@ async def test_fetch_raw(self):
792
792
assert isinstance (entry .resource , AsyncFHIRResource )
793
793
assert len (bundle .entry ) == 2 # noqa: PLR2004
794
794
795
+ @pytest .mark .asyncio ()
796
+ async def test_typed_fetch_raw (self ):
797
+ await self .create_resource ("Patient" , name = [{"text" : "RareName" }])
798
+ await self .create_resource ("Patient" , name = [{"text" : "RareName" }])
799
+ bundle = await self .client .resources (Patient ).search (name = "RareName" ).fetch_raw ()
800
+ assert bundle .resourceType == "Bundle"
801
+ for entry in bundle .entry :
802
+ assert not isinstance (entry .resource , AsyncFHIRResource )
803
+ assert len (bundle .entry ) == 2 # noqa: PLR2004
804
+
795
805
async def create_test_patients (self , count = 10 , name = "Not Rare Name" ):
796
806
bundle = {
797
807
"type" : "transaction" ,
Original file line number Diff line number Diff line change @@ -708,6 +708,15 @@ def test_fetch_raw(self):
708
708
assert isinstance (entry .resource , SyncFHIRResource )
709
709
assert len (bundle .entry ) == 2 # noqa: PLR2004
710
710
711
+ def test_typed_fetch_raw (self ):
712
+ self .create_resource ("Patient" , name = [{"text" : "RareName" }])
713
+ self .create_resource ("Patient" , name = [{"text" : "RareName" }])
714
+ bundle = self .client .resources (Patient ).search (name = "RareName" ).fetch_raw ()
715
+ assert bundle .resourceType == "Bundle"
716
+ for entry in bundle .entry :
717
+ assert not isinstance (entry .resource , SyncFHIRResource )
718
+ assert len (bundle .entry ) == 2 # noqa: PLR2004
719
+
711
720
def create_test_patients (self , count = 10 , name = "Not Rare Name" ):
712
721
bundle = {
713
722
"type" : "transaction" ,
You can’t perform that action at this time.
0 commit comments