phenoml 0.0.2__py3-none-any.whl → 0.0.15__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.
Files changed (137) hide show
  1. phenoml/agent/__init__.py +6 -8
  2. phenoml/agent/client.py +85 -67
  3. phenoml/agent/raw_client.py +61 -77
  4. phenoml/agent/types/__init__.py +6 -8
  5. phenoml/agent/types/agent_create_request.py +53 -0
  6. phenoml/agent/types/agent_create_request_provider.py +5 -0
  7. phenoml/agent/types/agent_template.py +3 -6
  8. phenoml/agent/types/agent_template_provider.py +5 -0
  9. phenoml/agent/types/json_patch_operation.py +5 -1
  10. phenoml/client.py +12 -0
  11. phenoml/construe/__init__.py +2 -16
  12. phenoml/construe/client.py +0 -90
  13. phenoml/construe/raw_client.py +0 -180
  14. phenoml/construe/types/__init__.py +2 -20
  15. phenoml/construe/types/extract_request_config.py +33 -4
  16. phenoml/construe/types/extract_request_config_chunking_method.py +3 -1
  17. phenoml/construe/types/extract_request_config_validation_method.py +5 -0
  18. phenoml/construe/types/extract_request_system.py +2 -0
  19. phenoml/core/client_wrapper.py +2 -2
  20. phenoml/fhir/__init__.py +36 -0
  21. phenoml/fhir/client.py +1072 -0
  22. phenoml/fhir/errors/__init__.py +10 -0
  23. phenoml/fhir/errors/bad_request_error.py +10 -0
  24. phenoml/fhir/errors/internal_server_error.py +10 -0
  25. phenoml/fhir/errors/not_found_error.py +10 -0
  26. phenoml/fhir/errors/unauthorized_error.py +10 -0
  27. phenoml/fhir/raw_client.py +1469 -0
  28. phenoml/fhir/types/__init__.py +29 -0
  29. phenoml/{agent/types/chat_fhir_client_config.py → fhir/types/error_response.py} +11 -6
  30. phenoml/fhir/types/fhir_bundle.py +43 -0
  31. phenoml/fhir/types/fhir_bundle_entry_item.py +34 -0
  32. phenoml/fhir/types/fhir_bundle_entry_item_request.py +25 -0
  33. phenoml/fhir/types/fhir_bundle_entry_item_request_method.py +5 -0
  34. phenoml/{construe/types/bad_request_error_body.py → fhir/types/fhir_bundle_entry_item_response.py} +4 -7
  35. phenoml/fhir/types/fhir_patch_request_body_item.py +40 -0
  36. phenoml/fhir/types/fhir_patch_request_body_item_op.py +7 -0
  37. phenoml/fhir/types/fhir_resource.py +40 -0
  38. phenoml/fhir/types/fhir_resource_meta.py +28 -0
  39. phenoml/fhir/types/fhir_search_response.py +8 -0
  40. phenoml/fhir_provider/__init__.py +45 -0
  41. phenoml/fhir_provider/client.py +748 -0
  42. phenoml/fhir_provider/errors/__init__.py +11 -0
  43. phenoml/fhir_provider/errors/bad_request_error.py +10 -0
  44. phenoml/fhir_provider/errors/forbidden_error.py +10 -0
  45. phenoml/fhir_provider/errors/internal_server_error.py +10 -0
  46. phenoml/fhir_provider/errors/not_found_error.py +10 -0
  47. phenoml/fhir_provider/errors/unauthorized_error.py +10 -0
  48. phenoml/fhir_provider/raw_client.py +1462 -0
  49. phenoml/fhir_provider/types/__init__.py +37 -0
  50. phenoml/fhir_provider/types/auth_method.py +7 -0
  51. phenoml/fhir_provider/types/fhir_provider_auth_config.py +53 -0
  52. phenoml/fhir_provider/types/fhir_provider_delete_response.py +20 -0
  53. phenoml/fhir_provider/types/fhir_provider_list_response.py +22 -0
  54. phenoml/fhir_provider/types/fhir_provider_remove_auth_config_response.py +22 -0
  55. phenoml/fhir_provider/types/fhir_provider_response.py +22 -0
  56. phenoml/fhir_provider/types/fhir_provider_set_active_auth_config_response.py +22 -0
  57. phenoml/fhir_provider/types/fhir_provider_template.py +66 -0
  58. phenoml/fhir_provider/types/fhir_query_response.py +27 -0
  59. phenoml/fhir_provider/types/fhir_query_response_data.py +5 -0
  60. phenoml/fhir_provider/types/json_web_key.py +51 -0
  61. phenoml/fhir_provider/types/provider.py +8 -0
  62. phenoml/fhir_provider/types/role.py +27 -0
  63. phenoml/fhir_provider/types/service_account_key.py +35 -0
  64. phenoml/fhir_provider/types/smart_configuration.py +46 -0
  65. phenoml/summary/__init__.py +39 -0
  66. phenoml/summary/client.py +656 -0
  67. phenoml/summary/errors/__init__.py +11 -0
  68. phenoml/summary/errors/bad_request_error.py +10 -0
  69. phenoml/summary/errors/forbidden_error.py +10 -0
  70. phenoml/summary/errors/internal_server_error.py +10 -0
  71. phenoml/summary/errors/not_found_error.py +10 -0
  72. phenoml/summary/errors/unauthorized_error.py +10 -0
  73. phenoml/summary/raw_client.py +1190 -0
  74. phenoml/summary/types/__init__.py +31 -0
  75. phenoml/summary/types/create_summary_request_fhir_resources.py +8 -0
  76. phenoml/summary/types/create_summary_request_mode.py +5 -0
  77. phenoml/{agent/types/agent_fhir_config.py → summary/types/create_summary_response.py} +7 -9
  78. phenoml/summary/types/create_summary_template_response.py +23 -0
  79. phenoml/summary/types/fhir_bundle.py +23 -0
  80. phenoml/summary/types/fhir_bundle_entry_item.py +20 -0
  81. phenoml/summary/types/fhir_resource.py +24 -0
  82. phenoml/summary/types/summary_delete_template_response.py +20 -0
  83. phenoml/summary/types/summary_get_template_response.py +21 -0
  84. phenoml/summary/types/summary_list_templates_response.py +21 -0
  85. phenoml/summary/types/summary_template.py +41 -0
  86. phenoml/summary/types/summary_update_template_response.py +22 -0
  87. phenoml/tools/__init__.py +0 -8
  88. phenoml/tools/client.py +114 -44
  89. phenoml/tools/raw_client.py +86 -55
  90. phenoml/tools/types/__init__.py +0 -8
  91. phenoml/workflows/__init__.py +61 -0
  92. phenoml/workflows/client.py +694 -0
  93. phenoml/workflows/errors/__init__.py +11 -0
  94. phenoml/workflows/errors/bad_request_error.py +10 -0
  95. phenoml/workflows/errors/forbidden_error.py +10 -0
  96. phenoml/workflows/errors/internal_server_error.py +10 -0
  97. phenoml/workflows/errors/not_found_error.py +10 -0
  98. phenoml/workflows/errors/unauthorized_error.py +10 -0
  99. phenoml/workflows/raw_client.py +1266 -0
  100. phenoml/workflows/types/__init__.py +53 -0
  101. phenoml/workflows/types/create_workflow_request_fhir_provider_id.py +5 -0
  102. phenoml/workflows/types/create_workflow_response.py +44 -0
  103. phenoml/{tools/types/fhir_client_config.py → workflows/types/decision_node_definition.py} +7 -6
  104. phenoml/workflows/types/execute_workflow_response.py +30 -0
  105. phenoml/{construe/types/unauthorized_error_body.py → workflows/types/execute_workflow_response_results.py} +3 -8
  106. phenoml/workflows/types/lang2fhir_create_definition.py +37 -0
  107. phenoml/workflows/types/lang2fhir_search_definition.py +42 -0
  108. phenoml/workflows/types/list_workflows_response.py +39 -0
  109. phenoml/workflows/types/step_operation.py +26 -0
  110. phenoml/{construe/types/construe_cohort_response_queries_item_code_extract_results_item_codes_item.py → workflows/types/sub_workflow_definition.py} +7 -7
  111. phenoml/workflows/types/update_workflow_request_fhir_provider_id.py +5 -0
  112. phenoml/workflows/types/workflow_config.py +27 -0
  113. phenoml/workflows/types/workflow_definition.py +57 -0
  114. phenoml/{construe/types/internal_server_error_body.py → workflows/types/workflow_graph.py} +4 -8
  115. phenoml/workflows/types/workflow_response.py +61 -0
  116. phenoml/workflows/types/workflow_response_graph.py +23 -0
  117. phenoml/workflows/types/workflow_step.py +55 -0
  118. phenoml/workflows/types/workflow_step_summary.py +47 -0
  119. phenoml/workflows/types/workflow_step_summary_type.py +5 -0
  120. phenoml/workflows/types/workflow_step_type.py +5 -0
  121. phenoml/workflows/types/workflows_delete_response.py +20 -0
  122. phenoml/workflows/types/workflows_get_response.py +26 -0
  123. phenoml/workflows/types/workflows_update_response.py +31 -0
  124. phenoml-0.0.15.dist-info/LICENSE +21 -0
  125. {phenoml-0.0.2.dist-info → phenoml-0.0.15.dist-info}/METADATA +1 -1
  126. phenoml-0.0.15.dist-info/RECORD +242 -0
  127. phenoml/agent/types/agent_provider.py +0 -7
  128. phenoml/agent/types/provider_type.py +0 -5
  129. phenoml/construe/types/construe_cohort_request_config.py +0 -37
  130. phenoml/construe/types/construe_cohort_response.py +0 -33
  131. phenoml/construe/types/construe_cohort_response_queries_item.py +0 -49
  132. phenoml/construe/types/construe_cohort_response_queries_item_code_extract_results_item.py +0 -31
  133. phenoml/tools/types/cohort_request_provider.py +0 -5
  134. phenoml/tools/types/lang2fhir_and_create_request_provider.py +0 -7
  135. phenoml/tools/types/lang2fhir_and_search_request_provider.py +0 -7
  136. phenoml-0.0.2.dist-info/RECORD +0 -153
  137. {phenoml-0.0.2.dist-info → phenoml-0.0.15.dist-info}/WHEEL +0 -0
@@ -0,0 +1,1190 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+ from json.decoder import JSONDecodeError
5
+
6
+ from ..core.api_error import ApiError
7
+ from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
8
+ from ..core.http_response import AsyncHttpResponse, HttpResponse
9
+ from ..core.jsonable_encoder import jsonable_encoder
10
+ from ..core.pydantic_utilities import parse_obj_as
11
+ from ..core.request_options import RequestOptions
12
+ from ..core.serialization import convert_and_respect_annotation_metadata
13
+ from .errors.bad_request_error import BadRequestError
14
+ from .errors.forbidden_error import ForbiddenError
15
+ from .errors.internal_server_error import InternalServerError
16
+ from .errors.not_found_error import NotFoundError
17
+ from .errors.unauthorized_error import UnauthorizedError
18
+ from .types.create_summary_request_fhir_resources import CreateSummaryRequestFhirResources
19
+ from .types.create_summary_request_mode import CreateSummaryRequestMode
20
+ from .types.create_summary_response import CreateSummaryResponse
21
+ from .types.create_summary_template_response import CreateSummaryTemplateResponse
22
+ from .types.summary_delete_template_response import SummaryDeleteTemplateResponse
23
+ from .types.summary_get_template_response import SummaryGetTemplateResponse
24
+ from .types.summary_list_templates_response import SummaryListTemplatesResponse
25
+ from .types.summary_update_template_response import SummaryUpdateTemplateResponse
26
+
27
+ # this is used as the default value for optional parameters
28
+ OMIT = typing.cast(typing.Any, ...)
29
+
30
+
31
+ class RawSummaryClient:
32
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
33
+ self._client_wrapper = client_wrapper
34
+
35
+ def list_templates(
36
+ self, *, request_options: typing.Optional[RequestOptions] = None
37
+ ) -> HttpResponse[SummaryListTemplatesResponse]:
38
+ """
39
+ Retrieves all summary templates for the authenticated user
40
+
41
+ Parameters
42
+ ----------
43
+ request_options : typing.Optional[RequestOptions]
44
+ Request-specific configuration.
45
+
46
+ Returns
47
+ -------
48
+ HttpResponse[SummaryListTemplatesResponse]
49
+ Templates retrieved successfully
50
+ """
51
+ _response = self._client_wrapper.httpx_client.request(
52
+ "fhir2summary/templates",
53
+ method="GET",
54
+ request_options=request_options,
55
+ )
56
+ try:
57
+ if 200 <= _response.status_code < 300:
58
+ _data = typing.cast(
59
+ SummaryListTemplatesResponse,
60
+ parse_obj_as(
61
+ type_=SummaryListTemplatesResponse, # type: ignore
62
+ object_=_response.json(),
63
+ ),
64
+ )
65
+ return HttpResponse(response=_response, data=_data)
66
+ if _response.status_code == 401:
67
+ raise UnauthorizedError(
68
+ headers=dict(_response.headers),
69
+ body=typing.cast(
70
+ typing.Optional[typing.Any],
71
+ parse_obj_as(
72
+ type_=typing.Optional[typing.Any], # type: ignore
73
+ object_=_response.json(),
74
+ ),
75
+ ),
76
+ )
77
+ if _response.status_code == 500:
78
+ raise InternalServerError(
79
+ headers=dict(_response.headers),
80
+ body=typing.cast(
81
+ typing.Optional[typing.Any],
82
+ parse_obj_as(
83
+ type_=typing.Optional[typing.Any], # type: ignore
84
+ object_=_response.json(),
85
+ ),
86
+ ),
87
+ )
88
+ _response_json = _response.json()
89
+ except JSONDecodeError:
90
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
91
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
92
+
93
+ def create_template(
94
+ self,
95
+ *,
96
+ name: str,
97
+ example_summary: str,
98
+ target_resources: typing.Sequence[str],
99
+ mode: str,
100
+ description: typing.Optional[str] = OMIT,
101
+ example_fhir_data: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
102
+ request_options: typing.Optional[RequestOptions] = None,
103
+ ) -> HttpResponse[CreateSummaryTemplateResponse]:
104
+ """
105
+ Creates a summary template from an example using LLM function calling
106
+
107
+ Parameters
108
+ ----------
109
+ name : str
110
+ Name of the template
111
+
112
+ example_summary : str
113
+ Example summary note to generate template from
114
+
115
+ target_resources : typing.Sequence[str]
116
+ List of target FHIR resources
117
+
118
+ mode : str
119
+ Template mode (stored with the template)
120
+
121
+ description : typing.Optional[str]
122
+ Description of the template
123
+
124
+ example_fhir_data : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
125
+ Optional example FHIR data that corresponds to the example summary
126
+
127
+ request_options : typing.Optional[RequestOptions]
128
+ Request-specific configuration.
129
+
130
+ Returns
131
+ -------
132
+ HttpResponse[CreateSummaryTemplateResponse]
133
+ Template created successfully
134
+ """
135
+ _response = self._client_wrapper.httpx_client.request(
136
+ "fhir2summary/template",
137
+ method="POST",
138
+ json={
139
+ "name": name,
140
+ "description": description,
141
+ "example_summary": example_summary,
142
+ "target_resources": target_resources,
143
+ "example_fhir_data": example_fhir_data,
144
+ "mode": mode,
145
+ },
146
+ headers={
147
+ "content-type": "application/json",
148
+ },
149
+ request_options=request_options,
150
+ omit=OMIT,
151
+ )
152
+ try:
153
+ if 200 <= _response.status_code < 300:
154
+ _data = typing.cast(
155
+ CreateSummaryTemplateResponse,
156
+ parse_obj_as(
157
+ type_=CreateSummaryTemplateResponse, # type: ignore
158
+ object_=_response.json(),
159
+ ),
160
+ )
161
+ return HttpResponse(response=_response, data=_data)
162
+ if _response.status_code == 400:
163
+ raise BadRequestError(
164
+ headers=dict(_response.headers),
165
+ body=typing.cast(
166
+ typing.Optional[typing.Any],
167
+ parse_obj_as(
168
+ type_=typing.Optional[typing.Any], # type: ignore
169
+ object_=_response.json(),
170
+ ),
171
+ ),
172
+ )
173
+ if _response.status_code == 401:
174
+ raise UnauthorizedError(
175
+ headers=dict(_response.headers),
176
+ body=typing.cast(
177
+ typing.Optional[typing.Any],
178
+ parse_obj_as(
179
+ type_=typing.Optional[typing.Any], # type: ignore
180
+ object_=_response.json(),
181
+ ),
182
+ ),
183
+ )
184
+ if _response.status_code == 500:
185
+ raise InternalServerError(
186
+ headers=dict(_response.headers),
187
+ body=typing.cast(
188
+ typing.Optional[typing.Any],
189
+ parse_obj_as(
190
+ type_=typing.Optional[typing.Any], # type: ignore
191
+ object_=_response.json(),
192
+ ),
193
+ ),
194
+ )
195
+ _response_json = _response.json()
196
+ except JSONDecodeError:
197
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
198
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
199
+
200
+ def get_template(
201
+ self, id: str, *, request_options: typing.Optional[RequestOptions] = None
202
+ ) -> HttpResponse[SummaryGetTemplateResponse]:
203
+ """
204
+ Retrieves a specific summary template
205
+
206
+ Parameters
207
+ ----------
208
+ id : str
209
+ Template ID
210
+
211
+ request_options : typing.Optional[RequestOptions]
212
+ Request-specific configuration.
213
+
214
+ Returns
215
+ -------
216
+ HttpResponse[SummaryGetTemplateResponse]
217
+ Template retrieved successfully
218
+ """
219
+ _response = self._client_wrapper.httpx_client.request(
220
+ f"fhir2summary/template/{jsonable_encoder(id)}",
221
+ method="GET",
222
+ request_options=request_options,
223
+ )
224
+ try:
225
+ if 200 <= _response.status_code < 300:
226
+ _data = typing.cast(
227
+ SummaryGetTemplateResponse,
228
+ parse_obj_as(
229
+ type_=SummaryGetTemplateResponse, # type: ignore
230
+ object_=_response.json(),
231
+ ),
232
+ )
233
+ return HttpResponse(response=_response, data=_data)
234
+ if _response.status_code == 401:
235
+ raise UnauthorizedError(
236
+ headers=dict(_response.headers),
237
+ body=typing.cast(
238
+ typing.Optional[typing.Any],
239
+ parse_obj_as(
240
+ type_=typing.Optional[typing.Any], # type: ignore
241
+ object_=_response.json(),
242
+ ),
243
+ ),
244
+ )
245
+ if _response.status_code == 403:
246
+ raise ForbiddenError(
247
+ headers=dict(_response.headers),
248
+ body=typing.cast(
249
+ typing.Optional[typing.Any],
250
+ parse_obj_as(
251
+ type_=typing.Optional[typing.Any], # type: ignore
252
+ object_=_response.json(),
253
+ ),
254
+ ),
255
+ )
256
+ if _response.status_code == 404:
257
+ raise NotFoundError(
258
+ headers=dict(_response.headers),
259
+ body=typing.cast(
260
+ typing.Optional[typing.Any],
261
+ parse_obj_as(
262
+ type_=typing.Optional[typing.Any], # type: ignore
263
+ object_=_response.json(),
264
+ ),
265
+ ),
266
+ )
267
+ if _response.status_code == 500:
268
+ raise InternalServerError(
269
+ headers=dict(_response.headers),
270
+ body=typing.cast(
271
+ typing.Optional[typing.Any],
272
+ parse_obj_as(
273
+ type_=typing.Optional[typing.Any], # type: ignore
274
+ object_=_response.json(),
275
+ ),
276
+ ),
277
+ )
278
+ _response_json = _response.json()
279
+ except JSONDecodeError:
280
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
281
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
282
+
283
+ def update_template(
284
+ self,
285
+ id: str,
286
+ *,
287
+ name: str,
288
+ template: str,
289
+ target_resources: typing.Sequence[str],
290
+ mode: str,
291
+ description: typing.Optional[str] = OMIT,
292
+ request_options: typing.Optional[RequestOptions] = None,
293
+ ) -> HttpResponse[SummaryUpdateTemplateResponse]:
294
+ """
295
+ Updates an existing summary template
296
+
297
+ Parameters
298
+ ----------
299
+ id : str
300
+ Template ID
301
+
302
+ name : str
303
+
304
+ template : str
305
+ Updated template with placeholders
306
+
307
+ target_resources : typing.Sequence[str]
308
+
309
+ mode : str
310
+ Template mode
311
+
312
+ description : typing.Optional[str]
313
+
314
+ request_options : typing.Optional[RequestOptions]
315
+ Request-specific configuration.
316
+
317
+ Returns
318
+ -------
319
+ HttpResponse[SummaryUpdateTemplateResponse]
320
+ Template updated successfully
321
+ """
322
+ _response = self._client_wrapper.httpx_client.request(
323
+ f"fhir2summary/template/{jsonable_encoder(id)}",
324
+ method="PUT",
325
+ json={
326
+ "name": name,
327
+ "description": description,
328
+ "template": template,
329
+ "target_resources": target_resources,
330
+ "mode": mode,
331
+ },
332
+ headers={
333
+ "content-type": "application/json",
334
+ },
335
+ request_options=request_options,
336
+ omit=OMIT,
337
+ )
338
+ try:
339
+ if 200 <= _response.status_code < 300:
340
+ _data = typing.cast(
341
+ SummaryUpdateTemplateResponse,
342
+ parse_obj_as(
343
+ type_=SummaryUpdateTemplateResponse, # type: ignore
344
+ object_=_response.json(),
345
+ ),
346
+ )
347
+ return HttpResponse(response=_response, data=_data)
348
+ if _response.status_code == 400:
349
+ raise BadRequestError(
350
+ headers=dict(_response.headers),
351
+ body=typing.cast(
352
+ typing.Optional[typing.Any],
353
+ parse_obj_as(
354
+ type_=typing.Optional[typing.Any], # type: ignore
355
+ object_=_response.json(),
356
+ ),
357
+ ),
358
+ )
359
+ if _response.status_code == 401:
360
+ raise UnauthorizedError(
361
+ headers=dict(_response.headers),
362
+ body=typing.cast(
363
+ typing.Optional[typing.Any],
364
+ parse_obj_as(
365
+ type_=typing.Optional[typing.Any], # type: ignore
366
+ object_=_response.json(),
367
+ ),
368
+ ),
369
+ )
370
+ if _response.status_code == 403:
371
+ raise ForbiddenError(
372
+ headers=dict(_response.headers),
373
+ body=typing.cast(
374
+ typing.Optional[typing.Any],
375
+ parse_obj_as(
376
+ type_=typing.Optional[typing.Any], # type: ignore
377
+ object_=_response.json(),
378
+ ),
379
+ ),
380
+ )
381
+ if _response.status_code == 404:
382
+ raise NotFoundError(
383
+ headers=dict(_response.headers),
384
+ body=typing.cast(
385
+ typing.Optional[typing.Any],
386
+ parse_obj_as(
387
+ type_=typing.Optional[typing.Any], # type: ignore
388
+ object_=_response.json(),
389
+ ),
390
+ ),
391
+ )
392
+ if _response.status_code == 500:
393
+ raise InternalServerError(
394
+ headers=dict(_response.headers),
395
+ body=typing.cast(
396
+ typing.Optional[typing.Any],
397
+ parse_obj_as(
398
+ type_=typing.Optional[typing.Any], # type: ignore
399
+ object_=_response.json(),
400
+ ),
401
+ ),
402
+ )
403
+ _response_json = _response.json()
404
+ except JSONDecodeError:
405
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
406
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
407
+
408
+ def delete_template(
409
+ self, id: str, *, request_options: typing.Optional[RequestOptions] = None
410
+ ) -> HttpResponse[SummaryDeleteTemplateResponse]:
411
+ """
412
+ Deletes a summary template
413
+
414
+ Parameters
415
+ ----------
416
+ id : str
417
+ Template ID
418
+
419
+ request_options : typing.Optional[RequestOptions]
420
+ Request-specific configuration.
421
+
422
+ Returns
423
+ -------
424
+ HttpResponse[SummaryDeleteTemplateResponse]
425
+ Template deleted successfully
426
+ """
427
+ _response = self._client_wrapper.httpx_client.request(
428
+ f"fhir2summary/template/{jsonable_encoder(id)}",
429
+ method="DELETE",
430
+ request_options=request_options,
431
+ )
432
+ try:
433
+ if 200 <= _response.status_code < 300:
434
+ _data = typing.cast(
435
+ SummaryDeleteTemplateResponse,
436
+ parse_obj_as(
437
+ type_=SummaryDeleteTemplateResponse, # type: ignore
438
+ object_=_response.json(),
439
+ ),
440
+ )
441
+ return HttpResponse(response=_response, data=_data)
442
+ if _response.status_code == 401:
443
+ raise UnauthorizedError(
444
+ headers=dict(_response.headers),
445
+ body=typing.cast(
446
+ typing.Optional[typing.Any],
447
+ parse_obj_as(
448
+ type_=typing.Optional[typing.Any], # type: ignore
449
+ object_=_response.json(),
450
+ ),
451
+ ),
452
+ )
453
+ if _response.status_code == 403:
454
+ raise ForbiddenError(
455
+ headers=dict(_response.headers),
456
+ body=typing.cast(
457
+ typing.Optional[typing.Any],
458
+ parse_obj_as(
459
+ type_=typing.Optional[typing.Any], # type: ignore
460
+ object_=_response.json(),
461
+ ),
462
+ ),
463
+ )
464
+ if _response.status_code == 404:
465
+ raise NotFoundError(
466
+ headers=dict(_response.headers),
467
+ body=typing.cast(
468
+ typing.Optional[typing.Any],
469
+ parse_obj_as(
470
+ type_=typing.Optional[typing.Any], # type: ignore
471
+ object_=_response.json(),
472
+ ),
473
+ ),
474
+ )
475
+ if _response.status_code == 500:
476
+ raise InternalServerError(
477
+ headers=dict(_response.headers),
478
+ body=typing.cast(
479
+ typing.Optional[typing.Any],
480
+ parse_obj_as(
481
+ type_=typing.Optional[typing.Any], # type: ignore
482
+ object_=_response.json(),
483
+ ),
484
+ ),
485
+ )
486
+ _response_json = _response.json()
487
+ except JSONDecodeError:
488
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
489
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
490
+
491
+ def create(
492
+ self,
493
+ *,
494
+ fhir_resources: CreateSummaryRequestFhirResources,
495
+ mode: typing.Optional[CreateSummaryRequestMode] = OMIT,
496
+ template_id: typing.Optional[str] = OMIT,
497
+ request_options: typing.Optional[RequestOptions] = None,
498
+ ) -> HttpResponse[CreateSummaryResponse]:
499
+ """
500
+ Creates a summary from FHIR resources using one of two modes:
501
+ - **narrative**: Uses a template to substitute FHIR data into placeholders (requires template_id)
502
+ - **flatten**: Flattens FHIR resources into a searchable format for RAG/search (no template needed)
503
+
504
+ Parameters
505
+ ----------
506
+ fhir_resources : CreateSummaryRequestFhirResources
507
+ FHIR resources (single resource or Bundle)
508
+
509
+ mode : typing.Optional[CreateSummaryRequestMode]
510
+ Summary generation mode:
511
+ - narrative: Substitute FHIR data into a template (requires template_id)
512
+ - flatten: Flatten FHIR resources for RAG/search (no template needed)
513
+
514
+ template_id : typing.Optional[str]
515
+ ID of the template to use (required for narrative mode)
516
+
517
+ request_options : typing.Optional[RequestOptions]
518
+ Request-specific configuration.
519
+
520
+ Returns
521
+ -------
522
+ HttpResponse[CreateSummaryResponse]
523
+ Summary generated successfully
524
+ """
525
+ _response = self._client_wrapper.httpx_client.request(
526
+ "fhir2summary/create",
527
+ method="POST",
528
+ json={
529
+ "mode": mode,
530
+ "template_id": template_id,
531
+ "fhir_resources": convert_and_respect_annotation_metadata(
532
+ object_=fhir_resources, annotation=CreateSummaryRequestFhirResources, direction="write"
533
+ ),
534
+ },
535
+ headers={
536
+ "content-type": "application/json",
537
+ },
538
+ request_options=request_options,
539
+ omit=OMIT,
540
+ )
541
+ try:
542
+ if 200 <= _response.status_code < 300:
543
+ _data = typing.cast(
544
+ CreateSummaryResponse,
545
+ parse_obj_as(
546
+ type_=CreateSummaryResponse, # type: ignore
547
+ object_=_response.json(),
548
+ ),
549
+ )
550
+ return HttpResponse(response=_response, data=_data)
551
+ if _response.status_code == 400:
552
+ raise BadRequestError(
553
+ headers=dict(_response.headers),
554
+ body=typing.cast(
555
+ typing.Optional[typing.Any],
556
+ parse_obj_as(
557
+ type_=typing.Optional[typing.Any], # type: ignore
558
+ object_=_response.json(),
559
+ ),
560
+ ),
561
+ )
562
+ if _response.status_code == 401:
563
+ raise UnauthorizedError(
564
+ headers=dict(_response.headers),
565
+ body=typing.cast(
566
+ typing.Optional[typing.Any],
567
+ parse_obj_as(
568
+ type_=typing.Optional[typing.Any], # type: ignore
569
+ object_=_response.json(),
570
+ ),
571
+ ),
572
+ )
573
+ if _response.status_code == 403:
574
+ raise ForbiddenError(
575
+ headers=dict(_response.headers),
576
+ body=typing.cast(
577
+ typing.Optional[typing.Any],
578
+ parse_obj_as(
579
+ type_=typing.Optional[typing.Any], # type: ignore
580
+ object_=_response.json(),
581
+ ),
582
+ ),
583
+ )
584
+ if _response.status_code == 404:
585
+ raise NotFoundError(
586
+ headers=dict(_response.headers),
587
+ body=typing.cast(
588
+ typing.Optional[typing.Any],
589
+ parse_obj_as(
590
+ type_=typing.Optional[typing.Any], # type: ignore
591
+ object_=_response.json(),
592
+ ),
593
+ ),
594
+ )
595
+ if _response.status_code == 500:
596
+ raise InternalServerError(
597
+ headers=dict(_response.headers),
598
+ body=typing.cast(
599
+ typing.Optional[typing.Any],
600
+ parse_obj_as(
601
+ type_=typing.Optional[typing.Any], # type: ignore
602
+ object_=_response.json(),
603
+ ),
604
+ ),
605
+ )
606
+ _response_json = _response.json()
607
+ except JSONDecodeError:
608
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
609
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
610
+
611
+
612
+ class AsyncRawSummaryClient:
613
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
614
+ self._client_wrapper = client_wrapper
615
+
616
+ async def list_templates(
617
+ self, *, request_options: typing.Optional[RequestOptions] = None
618
+ ) -> AsyncHttpResponse[SummaryListTemplatesResponse]:
619
+ """
620
+ Retrieves all summary templates for the authenticated user
621
+
622
+ Parameters
623
+ ----------
624
+ request_options : typing.Optional[RequestOptions]
625
+ Request-specific configuration.
626
+
627
+ Returns
628
+ -------
629
+ AsyncHttpResponse[SummaryListTemplatesResponse]
630
+ Templates retrieved successfully
631
+ """
632
+ _response = await self._client_wrapper.httpx_client.request(
633
+ "fhir2summary/templates",
634
+ method="GET",
635
+ request_options=request_options,
636
+ )
637
+ try:
638
+ if 200 <= _response.status_code < 300:
639
+ _data = typing.cast(
640
+ SummaryListTemplatesResponse,
641
+ parse_obj_as(
642
+ type_=SummaryListTemplatesResponse, # type: ignore
643
+ object_=_response.json(),
644
+ ),
645
+ )
646
+ return AsyncHttpResponse(response=_response, data=_data)
647
+ if _response.status_code == 401:
648
+ raise UnauthorizedError(
649
+ headers=dict(_response.headers),
650
+ body=typing.cast(
651
+ typing.Optional[typing.Any],
652
+ parse_obj_as(
653
+ type_=typing.Optional[typing.Any], # type: ignore
654
+ object_=_response.json(),
655
+ ),
656
+ ),
657
+ )
658
+ if _response.status_code == 500:
659
+ raise InternalServerError(
660
+ headers=dict(_response.headers),
661
+ body=typing.cast(
662
+ typing.Optional[typing.Any],
663
+ parse_obj_as(
664
+ type_=typing.Optional[typing.Any], # type: ignore
665
+ object_=_response.json(),
666
+ ),
667
+ ),
668
+ )
669
+ _response_json = _response.json()
670
+ except JSONDecodeError:
671
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
672
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
673
+
674
+ async def create_template(
675
+ self,
676
+ *,
677
+ name: str,
678
+ example_summary: str,
679
+ target_resources: typing.Sequence[str],
680
+ mode: str,
681
+ description: typing.Optional[str] = OMIT,
682
+ example_fhir_data: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
683
+ request_options: typing.Optional[RequestOptions] = None,
684
+ ) -> AsyncHttpResponse[CreateSummaryTemplateResponse]:
685
+ """
686
+ Creates a summary template from an example using LLM function calling
687
+
688
+ Parameters
689
+ ----------
690
+ name : str
691
+ Name of the template
692
+
693
+ example_summary : str
694
+ Example summary note to generate template from
695
+
696
+ target_resources : typing.Sequence[str]
697
+ List of target FHIR resources
698
+
699
+ mode : str
700
+ Template mode (stored with the template)
701
+
702
+ description : typing.Optional[str]
703
+ Description of the template
704
+
705
+ example_fhir_data : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
706
+ Optional example FHIR data that corresponds to the example summary
707
+
708
+ request_options : typing.Optional[RequestOptions]
709
+ Request-specific configuration.
710
+
711
+ Returns
712
+ -------
713
+ AsyncHttpResponse[CreateSummaryTemplateResponse]
714
+ Template created successfully
715
+ """
716
+ _response = await self._client_wrapper.httpx_client.request(
717
+ "fhir2summary/template",
718
+ method="POST",
719
+ json={
720
+ "name": name,
721
+ "description": description,
722
+ "example_summary": example_summary,
723
+ "target_resources": target_resources,
724
+ "example_fhir_data": example_fhir_data,
725
+ "mode": mode,
726
+ },
727
+ headers={
728
+ "content-type": "application/json",
729
+ },
730
+ request_options=request_options,
731
+ omit=OMIT,
732
+ )
733
+ try:
734
+ if 200 <= _response.status_code < 300:
735
+ _data = typing.cast(
736
+ CreateSummaryTemplateResponse,
737
+ parse_obj_as(
738
+ type_=CreateSummaryTemplateResponse, # type: ignore
739
+ object_=_response.json(),
740
+ ),
741
+ )
742
+ return AsyncHttpResponse(response=_response, data=_data)
743
+ if _response.status_code == 400:
744
+ raise BadRequestError(
745
+ headers=dict(_response.headers),
746
+ body=typing.cast(
747
+ typing.Optional[typing.Any],
748
+ parse_obj_as(
749
+ type_=typing.Optional[typing.Any], # type: ignore
750
+ object_=_response.json(),
751
+ ),
752
+ ),
753
+ )
754
+ if _response.status_code == 401:
755
+ raise UnauthorizedError(
756
+ headers=dict(_response.headers),
757
+ body=typing.cast(
758
+ typing.Optional[typing.Any],
759
+ parse_obj_as(
760
+ type_=typing.Optional[typing.Any], # type: ignore
761
+ object_=_response.json(),
762
+ ),
763
+ ),
764
+ )
765
+ if _response.status_code == 500:
766
+ raise InternalServerError(
767
+ headers=dict(_response.headers),
768
+ body=typing.cast(
769
+ typing.Optional[typing.Any],
770
+ parse_obj_as(
771
+ type_=typing.Optional[typing.Any], # type: ignore
772
+ object_=_response.json(),
773
+ ),
774
+ ),
775
+ )
776
+ _response_json = _response.json()
777
+ except JSONDecodeError:
778
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
779
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
780
+
781
+ async def get_template(
782
+ self, id: str, *, request_options: typing.Optional[RequestOptions] = None
783
+ ) -> AsyncHttpResponse[SummaryGetTemplateResponse]:
784
+ """
785
+ Retrieves a specific summary template
786
+
787
+ Parameters
788
+ ----------
789
+ id : str
790
+ Template ID
791
+
792
+ request_options : typing.Optional[RequestOptions]
793
+ Request-specific configuration.
794
+
795
+ Returns
796
+ -------
797
+ AsyncHttpResponse[SummaryGetTemplateResponse]
798
+ Template retrieved successfully
799
+ """
800
+ _response = await self._client_wrapper.httpx_client.request(
801
+ f"fhir2summary/template/{jsonable_encoder(id)}",
802
+ method="GET",
803
+ request_options=request_options,
804
+ )
805
+ try:
806
+ if 200 <= _response.status_code < 300:
807
+ _data = typing.cast(
808
+ SummaryGetTemplateResponse,
809
+ parse_obj_as(
810
+ type_=SummaryGetTemplateResponse, # type: ignore
811
+ object_=_response.json(),
812
+ ),
813
+ )
814
+ return AsyncHttpResponse(response=_response, data=_data)
815
+ if _response.status_code == 401:
816
+ raise UnauthorizedError(
817
+ headers=dict(_response.headers),
818
+ body=typing.cast(
819
+ typing.Optional[typing.Any],
820
+ parse_obj_as(
821
+ type_=typing.Optional[typing.Any], # type: ignore
822
+ object_=_response.json(),
823
+ ),
824
+ ),
825
+ )
826
+ if _response.status_code == 403:
827
+ raise ForbiddenError(
828
+ headers=dict(_response.headers),
829
+ body=typing.cast(
830
+ typing.Optional[typing.Any],
831
+ parse_obj_as(
832
+ type_=typing.Optional[typing.Any], # type: ignore
833
+ object_=_response.json(),
834
+ ),
835
+ ),
836
+ )
837
+ if _response.status_code == 404:
838
+ raise NotFoundError(
839
+ headers=dict(_response.headers),
840
+ body=typing.cast(
841
+ typing.Optional[typing.Any],
842
+ parse_obj_as(
843
+ type_=typing.Optional[typing.Any], # type: ignore
844
+ object_=_response.json(),
845
+ ),
846
+ ),
847
+ )
848
+ if _response.status_code == 500:
849
+ raise InternalServerError(
850
+ headers=dict(_response.headers),
851
+ body=typing.cast(
852
+ typing.Optional[typing.Any],
853
+ parse_obj_as(
854
+ type_=typing.Optional[typing.Any], # type: ignore
855
+ object_=_response.json(),
856
+ ),
857
+ ),
858
+ )
859
+ _response_json = _response.json()
860
+ except JSONDecodeError:
861
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
862
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
863
+
864
+ async def update_template(
865
+ self,
866
+ id: str,
867
+ *,
868
+ name: str,
869
+ template: str,
870
+ target_resources: typing.Sequence[str],
871
+ mode: str,
872
+ description: typing.Optional[str] = OMIT,
873
+ request_options: typing.Optional[RequestOptions] = None,
874
+ ) -> AsyncHttpResponse[SummaryUpdateTemplateResponse]:
875
+ """
876
+ Updates an existing summary template
877
+
878
+ Parameters
879
+ ----------
880
+ id : str
881
+ Template ID
882
+
883
+ name : str
884
+
885
+ template : str
886
+ Updated template with placeholders
887
+
888
+ target_resources : typing.Sequence[str]
889
+
890
+ mode : str
891
+ Template mode
892
+
893
+ description : typing.Optional[str]
894
+
895
+ request_options : typing.Optional[RequestOptions]
896
+ Request-specific configuration.
897
+
898
+ Returns
899
+ -------
900
+ AsyncHttpResponse[SummaryUpdateTemplateResponse]
901
+ Template updated successfully
902
+ """
903
+ _response = await self._client_wrapper.httpx_client.request(
904
+ f"fhir2summary/template/{jsonable_encoder(id)}",
905
+ method="PUT",
906
+ json={
907
+ "name": name,
908
+ "description": description,
909
+ "template": template,
910
+ "target_resources": target_resources,
911
+ "mode": mode,
912
+ },
913
+ headers={
914
+ "content-type": "application/json",
915
+ },
916
+ request_options=request_options,
917
+ omit=OMIT,
918
+ )
919
+ try:
920
+ if 200 <= _response.status_code < 300:
921
+ _data = typing.cast(
922
+ SummaryUpdateTemplateResponse,
923
+ parse_obj_as(
924
+ type_=SummaryUpdateTemplateResponse, # type: ignore
925
+ object_=_response.json(),
926
+ ),
927
+ )
928
+ return AsyncHttpResponse(response=_response, data=_data)
929
+ if _response.status_code == 400:
930
+ raise BadRequestError(
931
+ headers=dict(_response.headers),
932
+ body=typing.cast(
933
+ typing.Optional[typing.Any],
934
+ parse_obj_as(
935
+ type_=typing.Optional[typing.Any], # type: ignore
936
+ object_=_response.json(),
937
+ ),
938
+ ),
939
+ )
940
+ if _response.status_code == 401:
941
+ raise UnauthorizedError(
942
+ headers=dict(_response.headers),
943
+ body=typing.cast(
944
+ typing.Optional[typing.Any],
945
+ parse_obj_as(
946
+ type_=typing.Optional[typing.Any], # type: ignore
947
+ object_=_response.json(),
948
+ ),
949
+ ),
950
+ )
951
+ if _response.status_code == 403:
952
+ raise ForbiddenError(
953
+ headers=dict(_response.headers),
954
+ body=typing.cast(
955
+ typing.Optional[typing.Any],
956
+ parse_obj_as(
957
+ type_=typing.Optional[typing.Any], # type: ignore
958
+ object_=_response.json(),
959
+ ),
960
+ ),
961
+ )
962
+ if _response.status_code == 404:
963
+ raise NotFoundError(
964
+ headers=dict(_response.headers),
965
+ body=typing.cast(
966
+ typing.Optional[typing.Any],
967
+ parse_obj_as(
968
+ type_=typing.Optional[typing.Any], # type: ignore
969
+ object_=_response.json(),
970
+ ),
971
+ ),
972
+ )
973
+ if _response.status_code == 500:
974
+ raise InternalServerError(
975
+ headers=dict(_response.headers),
976
+ body=typing.cast(
977
+ typing.Optional[typing.Any],
978
+ parse_obj_as(
979
+ type_=typing.Optional[typing.Any], # type: ignore
980
+ object_=_response.json(),
981
+ ),
982
+ ),
983
+ )
984
+ _response_json = _response.json()
985
+ except JSONDecodeError:
986
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
987
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
988
+
989
+ async def delete_template(
990
+ self, id: str, *, request_options: typing.Optional[RequestOptions] = None
991
+ ) -> AsyncHttpResponse[SummaryDeleteTemplateResponse]:
992
+ """
993
+ Deletes a summary template
994
+
995
+ Parameters
996
+ ----------
997
+ id : str
998
+ Template ID
999
+
1000
+ request_options : typing.Optional[RequestOptions]
1001
+ Request-specific configuration.
1002
+
1003
+ Returns
1004
+ -------
1005
+ AsyncHttpResponse[SummaryDeleteTemplateResponse]
1006
+ Template deleted successfully
1007
+ """
1008
+ _response = await self._client_wrapper.httpx_client.request(
1009
+ f"fhir2summary/template/{jsonable_encoder(id)}",
1010
+ method="DELETE",
1011
+ request_options=request_options,
1012
+ )
1013
+ try:
1014
+ if 200 <= _response.status_code < 300:
1015
+ _data = typing.cast(
1016
+ SummaryDeleteTemplateResponse,
1017
+ parse_obj_as(
1018
+ type_=SummaryDeleteTemplateResponse, # type: ignore
1019
+ object_=_response.json(),
1020
+ ),
1021
+ )
1022
+ return AsyncHttpResponse(response=_response, data=_data)
1023
+ if _response.status_code == 401:
1024
+ raise UnauthorizedError(
1025
+ headers=dict(_response.headers),
1026
+ body=typing.cast(
1027
+ typing.Optional[typing.Any],
1028
+ parse_obj_as(
1029
+ type_=typing.Optional[typing.Any], # type: ignore
1030
+ object_=_response.json(),
1031
+ ),
1032
+ ),
1033
+ )
1034
+ if _response.status_code == 403:
1035
+ raise ForbiddenError(
1036
+ headers=dict(_response.headers),
1037
+ body=typing.cast(
1038
+ typing.Optional[typing.Any],
1039
+ parse_obj_as(
1040
+ type_=typing.Optional[typing.Any], # type: ignore
1041
+ object_=_response.json(),
1042
+ ),
1043
+ ),
1044
+ )
1045
+ if _response.status_code == 404:
1046
+ raise NotFoundError(
1047
+ headers=dict(_response.headers),
1048
+ body=typing.cast(
1049
+ typing.Optional[typing.Any],
1050
+ parse_obj_as(
1051
+ type_=typing.Optional[typing.Any], # type: ignore
1052
+ object_=_response.json(),
1053
+ ),
1054
+ ),
1055
+ )
1056
+ if _response.status_code == 500:
1057
+ raise InternalServerError(
1058
+ headers=dict(_response.headers),
1059
+ body=typing.cast(
1060
+ typing.Optional[typing.Any],
1061
+ parse_obj_as(
1062
+ type_=typing.Optional[typing.Any], # type: ignore
1063
+ object_=_response.json(),
1064
+ ),
1065
+ ),
1066
+ )
1067
+ _response_json = _response.json()
1068
+ except JSONDecodeError:
1069
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1070
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1071
+
1072
+ async def create(
1073
+ self,
1074
+ *,
1075
+ fhir_resources: CreateSummaryRequestFhirResources,
1076
+ mode: typing.Optional[CreateSummaryRequestMode] = OMIT,
1077
+ template_id: typing.Optional[str] = OMIT,
1078
+ request_options: typing.Optional[RequestOptions] = None,
1079
+ ) -> AsyncHttpResponse[CreateSummaryResponse]:
1080
+ """
1081
+ Creates a summary from FHIR resources using one of two modes:
1082
+ - **narrative**: Uses a template to substitute FHIR data into placeholders (requires template_id)
1083
+ - **flatten**: Flattens FHIR resources into a searchable format for RAG/search (no template needed)
1084
+
1085
+ Parameters
1086
+ ----------
1087
+ fhir_resources : CreateSummaryRequestFhirResources
1088
+ FHIR resources (single resource or Bundle)
1089
+
1090
+ mode : typing.Optional[CreateSummaryRequestMode]
1091
+ Summary generation mode:
1092
+ - narrative: Substitute FHIR data into a template (requires template_id)
1093
+ - flatten: Flatten FHIR resources for RAG/search (no template needed)
1094
+
1095
+ template_id : typing.Optional[str]
1096
+ ID of the template to use (required for narrative mode)
1097
+
1098
+ request_options : typing.Optional[RequestOptions]
1099
+ Request-specific configuration.
1100
+
1101
+ Returns
1102
+ -------
1103
+ AsyncHttpResponse[CreateSummaryResponse]
1104
+ Summary generated successfully
1105
+ """
1106
+ _response = await self._client_wrapper.httpx_client.request(
1107
+ "fhir2summary/create",
1108
+ method="POST",
1109
+ json={
1110
+ "mode": mode,
1111
+ "template_id": template_id,
1112
+ "fhir_resources": convert_and_respect_annotation_metadata(
1113
+ object_=fhir_resources, annotation=CreateSummaryRequestFhirResources, direction="write"
1114
+ ),
1115
+ },
1116
+ headers={
1117
+ "content-type": "application/json",
1118
+ },
1119
+ request_options=request_options,
1120
+ omit=OMIT,
1121
+ )
1122
+ try:
1123
+ if 200 <= _response.status_code < 300:
1124
+ _data = typing.cast(
1125
+ CreateSummaryResponse,
1126
+ parse_obj_as(
1127
+ type_=CreateSummaryResponse, # type: ignore
1128
+ object_=_response.json(),
1129
+ ),
1130
+ )
1131
+ return AsyncHttpResponse(response=_response, data=_data)
1132
+ if _response.status_code == 400:
1133
+ raise BadRequestError(
1134
+ headers=dict(_response.headers),
1135
+ body=typing.cast(
1136
+ typing.Optional[typing.Any],
1137
+ parse_obj_as(
1138
+ type_=typing.Optional[typing.Any], # type: ignore
1139
+ object_=_response.json(),
1140
+ ),
1141
+ ),
1142
+ )
1143
+ if _response.status_code == 401:
1144
+ raise UnauthorizedError(
1145
+ headers=dict(_response.headers),
1146
+ body=typing.cast(
1147
+ typing.Optional[typing.Any],
1148
+ parse_obj_as(
1149
+ type_=typing.Optional[typing.Any], # type: ignore
1150
+ object_=_response.json(),
1151
+ ),
1152
+ ),
1153
+ )
1154
+ if _response.status_code == 403:
1155
+ raise ForbiddenError(
1156
+ headers=dict(_response.headers),
1157
+ body=typing.cast(
1158
+ typing.Optional[typing.Any],
1159
+ parse_obj_as(
1160
+ type_=typing.Optional[typing.Any], # type: ignore
1161
+ object_=_response.json(),
1162
+ ),
1163
+ ),
1164
+ )
1165
+ if _response.status_code == 404:
1166
+ raise NotFoundError(
1167
+ headers=dict(_response.headers),
1168
+ body=typing.cast(
1169
+ typing.Optional[typing.Any],
1170
+ parse_obj_as(
1171
+ type_=typing.Optional[typing.Any], # type: ignore
1172
+ object_=_response.json(),
1173
+ ),
1174
+ ),
1175
+ )
1176
+ if _response.status_code == 500:
1177
+ raise InternalServerError(
1178
+ headers=dict(_response.headers),
1179
+ body=typing.cast(
1180
+ typing.Optional[typing.Any],
1181
+ parse_obj_as(
1182
+ type_=typing.Optional[typing.Any], # type: ignore
1183
+ object_=_response.json(),
1184
+ ),
1185
+ ),
1186
+ )
1187
+ _response_json = _response.json()
1188
+ except JSONDecodeError:
1189
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1190
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)