@@ -145,19 +145,18 @@ def create_diagnostics_error(value):
145145def form_json (response , _element , identifier , baseurl ):
146146 self_url = f"{ baseurl } ?identifier={ identifier } " + (f"&_elements={ _element } " if _element else "" )
147147 meta = {"versionId" : response ["version" ]} if response and "version" in response else {}
148- fhir_bundle = FhirBundle (resourceType = "Bundle" , type = "searchset" , link = [BundleLink (relation = "self" , url = self_url )])
148+ fhir_bundle = FhirBundle (resourceType = "Bundle" , type = "searchset" , link = [BundleLink (relation = "self" , url = self_url )], entry = [],
149+ total = 0 )
149150
150151 if not response :
151- fhir_bundle .entry = []
152- fhir_bundle .total = 0
153- return fhir_bundle
152+ return fhir_bundle .dict (by_alias = True )
154153
155154 # Full Immunization payload to be returned if only the identifier parameter was provided
156155 if identifier and not _element :
157156 resource = response ["resource" ]
158157 resource ["meta" ] = meta
159158
160- imms = Immunization .parse_obj ( resource )
159+ imms = Immunization .construct ( ** resource )
161160
162161 elif identifier and _element :
163162 element = {e .strip ().lower () for e in _element .split ("," ) if e .strip ()}
@@ -169,11 +168,11 @@ def form_json(response, _element, identifier, baseurl):
169168 if "meta" in element :
170169 resource ["id" ] = response ["id" ]
171170 resource ["meta" ] = meta
172-
171+
173172 imms = Immunization .construct (** resource )
174173
175174 entry = BundleEntry (
176- fullUrl = f"{ baseurl } /Immunization/ { response ['id' ]} " ,
175+ fullUrl = f"{ baseurl } /{ response ['id' ]} " ,
177176 resource = imms ,
178177 search = BundleEntrySearch .construct (mode = "match" ),
179178 )
0 commit comments