phenoml 0.0.6__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.
- phenoml/__init__.py +30 -0
- phenoml/agent/__init__.py +56 -0
- phenoml/agent/client.py +939 -0
- phenoml/agent/errors/__init__.py +11 -0
- phenoml/agent/errors/bad_request_error.py +10 -0
- phenoml/agent/errors/forbidden_error.py +10 -0
- phenoml/agent/errors/internal_server_error.py +10 -0
- phenoml/agent/errors/not_found_error.py +10 -0
- phenoml/agent/errors/unauthorized_error.py +10 -0
- phenoml/agent/prompts/__init__.py +7 -0
- phenoml/agent/prompts/client.py +707 -0
- phenoml/agent/prompts/raw_client.py +1345 -0
- phenoml/agent/prompts/types/__init__.py +8 -0
- phenoml/agent/prompts/types/prompts_delete_response.py +20 -0
- phenoml/agent/prompts/types/prompts_list_response.py +22 -0
- phenoml/agent/raw_client.py +1668 -0
- phenoml/agent/types/__init__.py +43 -0
- phenoml/agent/types/agent_chat_response.py +33 -0
- phenoml/agent/types/agent_create_request.py +53 -0
- phenoml/agent/types/agent_create_request_provider.py +5 -0
- phenoml/agent/types/agent_delete_response.py +20 -0
- phenoml/agent/types/agent_get_chat_messages_request_order.py +5 -0
- phenoml/agent/types/agent_get_chat_messages_response.py +22 -0
- phenoml/agent/types/agent_list_response.py +22 -0
- phenoml/agent/types/agent_prompts_response.py +22 -0
- phenoml/agent/types/agent_response.py +22 -0
- phenoml/agent/types/agent_template.py +58 -0
- phenoml/agent/types/agent_template_provider.py +5 -0
- phenoml/agent/types/chat_message_template.py +72 -0
- phenoml/agent/types/chat_session_template.py +67 -0
- phenoml/agent/types/json_patch.py +7 -0
- phenoml/agent/types/json_patch_operation.py +40 -0
- phenoml/agent/types/json_patch_operation_op.py +5 -0
- phenoml/agent/types/prompt_template.py +52 -0
- phenoml/agent/types/success_response.py +20 -0
- phenoml/authtoken/__init__.py +17 -0
- phenoml/authtoken/auth/__init__.py +7 -0
- phenoml/authtoken/auth/client.py +129 -0
- phenoml/authtoken/auth/raw_client.py +173 -0
- phenoml/authtoken/auth/types/__init__.py +7 -0
- phenoml/authtoken/auth/types/auth_generate_token_response.py +22 -0
- phenoml/authtoken/client.py +39 -0
- phenoml/authtoken/errors/__init__.py +8 -0
- phenoml/authtoken/errors/bad_request_error.py +10 -0
- phenoml/authtoken/errors/unauthorized_error.py +10 -0
- phenoml/authtoken/raw_client.py +13 -0
- phenoml/authtoken/types/__init__.py +8 -0
- phenoml/authtoken/types/bad_request_error_body.py +21 -0
- phenoml/authtoken/types/unauthorized_error_body.py +21 -0
- phenoml/client.py +177 -0
- phenoml/cohort/__init__.py +8 -0
- phenoml/cohort/client.py +113 -0
- phenoml/cohort/errors/__init__.py +9 -0
- phenoml/cohort/errors/bad_request_error.py +10 -0
- phenoml/cohort/errors/internal_server_error.py +10 -0
- phenoml/cohort/errors/unauthorized_error.py +10 -0
- phenoml/cohort/raw_client.py +185 -0
- phenoml/cohort/types/__init__.py +8 -0
- phenoml/cohort/types/cohort_response.py +33 -0
- phenoml/cohort/types/search_concept.py +37 -0
- phenoml/construe/__init__.py +45 -0
- phenoml/construe/client.py +399 -0
- phenoml/construe/errors/__init__.py +11 -0
- phenoml/construe/errors/bad_request_error.py +10 -0
- phenoml/construe/errors/conflict_error.py +10 -0
- phenoml/construe/errors/failed_dependency_error.py +10 -0
- phenoml/construe/errors/internal_server_error.py +10 -0
- phenoml/construe/errors/unauthorized_error.py +10 -0
- phenoml/construe/raw_client.py +706 -0
- phenoml/construe/types/__init__.py +41 -0
- phenoml/construe/types/bad_request_error_body.py +27 -0
- phenoml/construe/types/construe_cohort_request_config.py +37 -0
- phenoml/construe/types/construe_cohort_response.py +33 -0
- phenoml/construe/types/construe_cohort_response_queries_item.py +49 -0
- phenoml/construe/types/construe_cohort_response_queries_item_code_extract_results_item.py +31 -0
- phenoml/construe/types/construe_cohort_response_queries_item_code_extract_results_item_codes_item.py +32 -0
- phenoml/construe/types/construe_upload_code_system_response.py +19 -0
- phenoml/construe/types/extract_codes_result.py +22 -0
- phenoml/construe/types/extract_request_config.py +23 -0
- phenoml/construe/types/extract_request_config_chunking_method.py +5 -0
- phenoml/construe/types/extract_request_system.py +37 -0
- phenoml/construe/types/extracted_code_result.py +41 -0
- phenoml/construe/types/internal_server_error_body.py +27 -0
- phenoml/construe/types/unauthorized_error_body.py +27 -0
- phenoml/construe/types/upload_request_format.py +5 -0
- phenoml/core/__init__.py +52 -0
- phenoml/core/api_error.py +23 -0
- phenoml/core/client_wrapper.py +87 -0
- phenoml/core/datetime_utils.py +28 -0
- phenoml/core/file.py +67 -0
- phenoml/core/force_multipart.py +16 -0
- phenoml/core/http_client.py +543 -0
- phenoml/core/http_response.py +55 -0
- phenoml/core/jsonable_encoder.py +100 -0
- phenoml/core/pydantic_utilities.py +255 -0
- phenoml/core/query_encoder.py +58 -0
- phenoml/core/remove_none_from_dict.py +11 -0
- phenoml/core/request_options.py +35 -0
- phenoml/core/serialization.py +276 -0
- phenoml/environment.py +7 -0
- phenoml/fhir/__init__.py +36 -0
- phenoml/fhir/client.py +970 -0
- phenoml/fhir/errors/__init__.py +10 -0
- phenoml/fhir/errors/bad_request_error.py +10 -0
- phenoml/fhir/errors/internal_server_error.py +10 -0
- phenoml/fhir/errors/not_found_error.py +10 -0
- phenoml/fhir/errors/unauthorized_error.py +10 -0
- phenoml/fhir/raw_client.py +1385 -0
- phenoml/fhir/types/__init__.py +29 -0
- phenoml/fhir/types/error_response.py +36 -0
- phenoml/fhir/types/fhir_bundle.py +43 -0
- phenoml/fhir/types/fhir_bundle_entry_item.py +34 -0
- phenoml/fhir/types/fhir_bundle_entry_item_request.py +25 -0
- phenoml/fhir/types/fhir_bundle_entry_item_request_method.py +5 -0
- phenoml/fhir/types/fhir_bundle_entry_item_response.py +24 -0
- phenoml/fhir/types/fhir_patch_request_body_item.py +40 -0
- phenoml/fhir/types/fhir_patch_request_body_item_op.py +7 -0
- phenoml/fhir/types/fhir_resource.py +40 -0
- phenoml/fhir/types/fhir_resource_meta.py +28 -0
- phenoml/fhir/types/fhir_search_response.py +8 -0
- phenoml/fhir_provider/__init__.py +43 -0
- phenoml/fhir_provider/client.py +731 -0
- phenoml/fhir_provider/errors/__init__.py +11 -0
- phenoml/fhir_provider/errors/bad_request_error.py +10 -0
- phenoml/fhir_provider/errors/forbidden_error.py +10 -0
- phenoml/fhir_provider/errors/internal_server_error.py +10 -0
- phenoml/fhir_provider/errors/not_found_error.py +10 -0
- phenoml/fhir_provider/errors/unauthorized_error.py +10 -0
- phenoml/fhir_provider/raw_client.py +1445 -0
- phenoml/fhir_provider/types/__init__.py +35 -0
- phenoml/fhir_provider/types/auth_method.py +7 -0
- phenoml/fhir_provider/types/fhir_provider_auth_config.py +53 -0
- phenoml/fhir_provider/types/fhir_provider_delete_response.py +20 -0
- phenoml/fhir_provider/types/fhir_provider_list_response.py +22 -0
- phenoml/fhir_provider/types/fhir_provider_remove_auth_config_response.py +22 -0
- phenoml/fhir_provider/types/fhir_provider_response.py +22 -0
- phenoml/fhir_provider/types/fhir_provider_set_active_auth_config_response.py +22 -0
- phenoml/fhir_provider/types/fhir_provider_template.py +66 -0
- phenoml/fhir_provider/types/fhir_query_response.py +27 -0
- phenoml/fhir_provider/types/fhir_query_response_data.py +5 -0
- phenoml/fhir_provider/types/json_web_key.py +51 -0
- phenoml/fhir_provider/types/provider.py +8 -0
- phenoml/fhir_provider/types/service_account_key.py +35 -0
- phenoml/fhir_provider/types/smart_configuration.py +46 -0
- phenoml/lang2fhir/__init__.py +27 -0
- phenoml/lang2fhir/client.py +430 -0
- phenoml/lang2fhir/errors/__init__.py +11 -0
- phenoml/lang2fhir/errors/bad_request_error.py +10 -0
- phenoml/lang2fhir/errors/failed_dependency_error.py +10 -0
- phenoml/lang2fhir/errors/forbidden_error.py +10 -0
- phenoml/lang2fhir/errors/internal_server_error.py +10 -0
- phenoml/lang2fhir/errors/unauthorized_error.py +10 -0
- phenoml/lang2fhir/raw_client.py +788 -0
- phenoml/lang2fhir/types/__init__.py +19 -0
- phenoml/lang2fhir/types/create_request_resource.py +25 -0
- phenoml/lang2fhir/types/document_request_file_type.py +7 -0
- phenoml/lang2fhir/types/document_request_resource.py +5 -0
- phenoml/lang2fhir/types/fhir_resource.py +5 -0
- phenoml/lang2fhir/types/lang2fhir_upload_profile_response.py +23 -0
- phenoml/lang2fhir/types/search_response.py +33 -0
- phenoml/py.typed +0 -0
- phenoml/tools/__init__.py +37 -0
- phenoml/tools/client.py +359 -0
- phenoml/tools/errors/__init__.py +11 -0
- phenoml/tools/errors/bad_request_error.py +10 -0
- phenoml/tools/errors/failed_dependency_error.py +10 -0
- phenoml/tools/errors/forbidden_error.py +10 -0
- phenoml/tools/errors/internal_server_error.py +10 -0
- phenoml/tools/errors/unauthorized_error.py +10 -0
- phenoml/tools/mcp_server/__init__.py +7 -0
- phenoml/tools/mcp_server/client.py +336 -0
- phenoml/tools/mcp_server/raw_client.py +641 -0
- phenoml/tools/mcp_server/tools/__init__.py +4 -0
- phenoml/tools/mcp_server/tools/client.py +358 -0
- phenoml/tools/mcp_server/tools/raw_client.py +656 -0
- phenoml/tools/raw_client.py +696 -0
- phenoml/tools/types/__init__.py +27 -0
- phenoml/tools/types/cohort_response.py +49 -0
- phenoml/tools/types/lang2fhir_and_create_request_resource.py +25 -0
- phenoml/tools/types/lang2fhir_and_create_response.py +33 -0
- phenoml/tools/types/lang2fhir_and_search_response.py +40 -0
- phenoml/tools/types/mcp_server_response.py +33 -0
- phenoml/tools/types/mcp_server_response_data.py +51 -0
- phenoml/tools/types/mcp_server_tool_call_response.py +37 -0
- phenoml/tools/types/mcp_server_tool_response.py +33 -0
- phenoml/tools/types/mcp_server_tool_response_data.py +61 -0
- phenoml/tools/types/search_concept.py +41 -0
- phenoml/types/__init__.py +21 -0
- phenoml/types/cohort_response.py +5 -0
- phenoml/types/lang2fhir_and_create_response.py +5 -0
- phenoml/types/lang2fhir_and_search_response.py +5 -0
- phenoml/types/mcp_server_response.py +5 -0
- phenoml/types/mcp_server_tool_call_response.py +5 -0
- phenoml/types/mcp_server_tool_response.py +5 -0
- phenoml/types/search_concept.py +5 -0
- phenoml/version.py +3 -0
- phenoml/workflows/__init__.py +66 -0
- phenoml/workflows/client.py +210 -0
- phenoml/workflows/errors/__init__.py +11 -0
- phenoml/workflows/errors/bad_request_error.py +10 -0
- phenoml/workflows/errors/forbidden_error.py +10 -0
- phenoml/workflows/errors/internal_server_error.py +10 -0
- phenoml/workflows/errors/not_found_error.py +10 -0
- phenoml/workflows/errors/unauthorized_error.py +10 -0
- phenoml/workflows/mcp_server/__init__.py +7 -0
- phenoml/workflows/mcp_server/client.py +274 -0
- phenoml/workflows/mcp_server/raw_client.py +226 -0
- phenoml/workflows/mcp_server/tools/__init__.py +4 -0
- phenoml/workflows/mcp_server/tools/client.py +287 -0
- phenoml/workflows/mcp_server/tools/raw_client.py +244 -0
- phenoml/workflows/raw_client.py +169 -0
- phenoml/workflows/types/__init__.py +43 -0
- phenoml/workflows/types/create_workflow_response.py +44 -0
- phenoml/workflows/types/decision_node_definition.py +32 -0
- phenoml/workflows/types/execute_workflow_response.py +30 -0
- phenoml/workflows/types/execute_workflow_response_results.py +22 -0
- phenoml/workflows/types/lang2fhir_create_definition.py +37 -0
- phenoml/workflows/types/lang2fhir_search_definition.py +42 -0
- phenoml/workflows/types/list_workflows_response.py +39 -0
- phenoml/workflows/types/step_operation.py +26 -0
- phenoml/workflows/types/sub_workflow_definition.py +32 -0
- phenoml/workflows/types/workflow_config.py +27 -0
- phenoml/workflows/types/workflow_definition.py +57 -0
- phenoml/workflows/types/workflow_graph.py +23 -0
- phenoml/workflows/types/workflow_response.py +61 -0
- phenoml/workflows/types/workflow_response_graph.py +23 -0
- phenoml/workflows/types/workflow_step.py +55 -0
- phenoml/workflows/types/workflow_step_summary.py +47 -0
- phenoml/workflows/types/workflow_step_summary_type.py +5 -0
- phenoml/workflows/types/workflow_step_type.py +5 -0
- phenoml/workflows/workflows/__init__.py +19 -0
- phenoml/workflows/workflows/client.py +694 -0
- phenoml/workflows/workflows/raw_client.py +1266 -0
- phenoml/workflows/workflows/types/__init__.py +17 -0
- phenoml/workflows/workflows/types/create_workflow_request_fhir_provider_id.py +5 -0
- phenoml/workflows/workflows/types/update_workflow_request_fhir_provider_id.py +5 -0
- phenoml/workflows/workflows/types/workflows_delete_response.py +20 -0
- phenoml/workflows/workflows/types/workflows_get_response.py +26 -0
- phenoml/workflows/workflows/types/workflows_update_response.py +31 -0
- phenoml/wrapper_client.py +123 -0
- phenoml-0.0.6.dist-info/LICENSE +21 -0
- phenoml-0.0.6.dist-info/METADATA +192 -0
- phenoml-0.0.6.dist-info/RECORD +244 -0
- phenoml-0.0.6.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,696 @@
|
|
|
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.pydantic_utilities import parse_obj_as
|
|
10
|
+
from ..core.request_options import RequestOptions
|
|
11
|
+
from .errors.bad_request_error import BadRequestError
|
|
12
|
+
from .errors.failed_dependency_error import FailedDependencyError
|
|
13
|
+
from .errors.forbidden_error import ForbiddenError
|
|
14
|
+
from .errors.internal_server_error import InternalServerError
|
|
15
|
+
from .errors.unauthorized_error import UnauthorizedError
|
|
16
|
+
from .types.cohort_response import CohortResponse
|
|
17
|
+
from .types.lang2fhir_and_create_request_resource import Lang2FhirAndCreateRequestResource
|
|
18
|
+
from .types.lang2fhir_and_create_response import Lang2FhirAndCreateResponse
|
|
19
|
+
from .types.lang2fhir_and_search_response import Lang2FhirAndSearchResponse
|
|
20
|
+
|
|
21
|
+
# this is used as the default value for optional parameters
|
|
22
|
+
OMIT = typing.cast(typing.Any, ...)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class RawToolsClient:
|
|
26
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
27
|
+
self._client_wrapper = client_wrapper
|
|
28
|
+
|
|
29
|
+
def create_fhir_resource(
|
|
30
|
+
self,
|
|
31
|
+
*,
|
|
32
|
+
resource: Lang2FhirAndCreateRequestResource,
|
|
33
|
+
text: str,
|
|
34
|
+
provider: typing.Optional[str] = OMIT,
|
|
35
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
36
|
+
) -> HttpResponse[Lang2FhirAndCreateResponse]:
|
|
37
|
+
"""
|
|
38
|
+
Converts natural language to FHIR resource and optionally stores it in a FHIR server
|
|
39
|
+
|
|
40
|
+
Parameters
|
|
41
|
+
----------
|
|
42
|
+
resource : Lang2FhirAndCreateRequestResource
|
|
43
|
+
Type of FHIR resource to create. Use 'auto' for automatic resource type detection, or specify a supported US Core profile.
|
|
44
|
+
|
|
45
|
+
text : str
|
|
46
|
+
Natural language text to convert to FHIR resource
|
|
47
|
+
|
|
48
|
+
provider : typing.Optional[str]
|
|
49
|
+
FHIR provider ID - must be a valid UUID from existing FHIR providers. also supports provider by name (e.g. medplum)
|
|
50
|
+
|
|
51
|
+
request_options : typing.Optional[RequestOptions]
|
|
52
|
+
Request-specific configuration.
|
|
53
|
+
|
|
54
|
+
Returns
|
|
55
|
+
-------
|
|
56
|
+
HttpResponse[Lang2FhirAndCreateResponse]
|
|
57
|
+
Successfully created FHIR resource
|
|
58
|
+
"""
|
|
59
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
60
|
+
"tools/lang2fhir-and-create",
|
|
61
|
+
method="POST",
|
|
62
|
+
json={
|
|
63
|
+
"resource": resource,
|
|
64
|
+
"text": text,
|
|
65
|
+
"provider": provider,
|
|
66
|
+
},
|
|
67
|
+
headers={
|
|
68
|
+
"content-type": "application/json",
|
|
69
|
+
},
|
|
70
|
+
request_options=request_options,
|
|
71
|
+
omit=OMIT,
|
|
72
|
+
)
|
|
73
|
+
try:
|
|
74
|
+
if 200 <= _response.status_code < 300:
|
|
75
|
+
_data = typing.cast(
|
|
76
|
+
Lang2FhirAndCreateResponse,
|
|
77
|
+
parse_obj_as(
|
|
78
|
+
type_=Lang2FhirAndCreateResponse, # type: ignore
|
|
79
|
+
object_=_response.json(),
|
|
80
|
+
),
|
|
81
|
+
)
|
|
82
|
+
return HttpResponse(response=_response, data=_data)
|
|
83
|
+
if _response.status_code == 400:
|
|
84
|
+
raise BadRequestError(
|
|
85
|
+
headers=dict(_response.headers),
|
|
86
|
+
body=typing.cast(
|
|
87
|
+
typing.Optional[typing.Any],
|
|
88
|
+
parse_obj_as(
|
|
89
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
90
|
+
object_=_response.json(),
|
|
91
|
+
),
|
|
92
|
+
),
|
|
93
|
+
)
|
|
94
|
+
if _response.status_code == 401:
|
|
95
|
+
raise UnauthorizedError(
|
|
96
|
+
headers=dict(_response.headers),
|
|
97
|
+
body=typing.cast(
|
|
98
|
+
typing.Optional[typing.Any],
|
|
99
|
+
parse_obj_as(
|
|
100
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
101
|
+
object_=_response.json(),
|
|
102
|
+
),
|
|
103
|
+
),
|
|
104
|
+
)
|
|
105
|
+
if _response.status_code == 403:
|
|
106
|
+
raise ForbiddenError(
|
|
107
|
+
headers=dict(_response.headers),
|
|
108
|
+
body=typing.cast(
|
|
109
|
+
typing.Optional[typing.Any],
|
|
110
|
+
parse_obj_as(
|
|
111
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
112
|
+
object_=_response.json(),
|
|
113
|
+
),
|
|
114
|
+
),
|
|
115
|
+
)
|
|
116
|
+
if _response.status_code == 424:
|
|
117
|
+
raise FailedDependencyError(
|
|
118
|
+
headers=dict(_response.headers),
|
|
119
|
+
body=typing.cast(
|
|
120
|
+
typing.Optional[typing.Any],
|
|
121
|
+
parse_obj_as(
|
|
122
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
123
|
+
object_=_response.json(),
|
|
124
|
+
),
|
|
125
|
+
),
|
|
126
|
+
)
|
|
127
|
+
if _response.status_code == 500:
|
|
128
|
+
raise InternalServerError(
|
|
129
|
+
headers=dict(_response.headers),
|
|
130
|
+
body=typing.cast(
|
|
131
|
+
typing.Optional[typing.Any],
|
|
132
|
+
parse_obj_as(
|
|
133
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
134
|
+
object_=_response.json(),
|
|
135
|
+
),
|
|
136
|
+
),
|
|
137
|
+
)
|
|
138
|
+
_response_json = _response.json()
|
|
139
|
+
except JSONDecodeError:
|
|
140
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
141
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
142
|
+
|
|
143
|
+
def search_fhir_resources(
|
|
144
|
+
self,
|
|
145
|
+
*,
|
|
146
|
+
text: str,
|
|
147
|
+
patient_id: typing.Optional[str] = OMIT,
|
|
148
|
+
practitioner_id: typing.Optional[str] = OMIT,
|
|
149
|
+
count: typing.Optional[int] = OMIT,
|
|
150
|
+
provider: typing.Optional[str] = OMIT,
|
|
151
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
152
|
+
) -> HttpResponse[Lang2FhirAndSearchResponse]:
|
|
153
|
+
"""
|
|
154
|
+
Converts natural language to FHIR search parameters and executes search in FHIR server
|
|
155
|
+
|
|
156
|
+
Parameters
|
|
157
|
+
----------
|
|
158
|
+
text : str
|
|
159
|
+
Natural language text to convert to FHIR search parameters
|
|
160
|
+
|
|
161
|
+
patient_id : typing.Optional[str]
|
|
162
|
+
Patient ID to filter results
|
|
163
|
+
|
|
164
|
+
practitioner_id : typing.Optional[str]
|
|
165
|
+
Practitioner ID to filter results
|
|
166
|
+
|
|
167
|
+
count : typing.Optional[int]
|
|
168
|
+
Maximum number of results to return
|
|
169
|
+
|
|
170
|
+
provider : typing.Optional[str]
|
|
171
|
+
FHIR provider ID - must be a valid UUID from existing FHIR providers. also supports provider by name (e.g. medplum)
|
|
172
|
+
|
|
173
|
+
request_options : typing.Optional[RequestOptions]
|
|
174
|
+
Request-specific configuration.
|
|
175
|
+
|
|
176
|
+
Returns
|
|
177
|
+
-------
|
|
178
|
+
HttpResponse[Lang2FhirAndSearchResponse]
|
|
179
|
+
Successfully generated search and retrieved results
|
|
180
|
+
"""
|
|
181
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
182
|
+
"tools/lang2fhir-and-search",
|
|
183
|
+
method="POST",
|
|
184
|
+
json={
|
|
185
|
+
"text": text,
|
|
186
|
+
"patient_id": patient_id,
|
|
187
|
+
"practitioner_id": practitioner_id,
|
|
188
|
+
"count": count,
|
|
189
|
+
"provider": provider,
|
|
190
|
+
},
|
|
191
|
+
headers={
|
|
192
|
+
"content-type": "application/json",
|
|
193
|
+
},
|
|
194
|
+
request_options=request_options,
|
|
195
|
+
omit=OMIT,
|
|
196
|
+
)
|
|
197
|
+
try:
|
|
198
|
+
if 200 <= _response.status_code < 300:
|
|
199
|
+
_data = typing.cast(
|
|
200
|
+
Lang2FhirAndSearchResponse,
|
|
201
|
+
parse_obj_as(
|
|
202
|
+
type_=Lang2FhirAndSearchResponse, # type: ignore
|
|
203
|
+
object_=_response.json(),
|
|
204
|
+
),
|
|
205
|
+
)
|
|
206
|
+
return HttpResponse(response=_response, data=_data)
|
|
207
|
+
if _response.status_code == 400:
|
|
208
|
+
raise BadRequestError(
|
|
209
|
+
headers=dict(_response.headers),
|
|
210
|
+
body=typing.cast(
|
|
211
|
+
typing.Optional[typing.Any],
|
|
212
|
+
parse_obj_as(
|
|
213
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
214
|
+
object_=_response.json(),
|
|
215
|
+
),
|
|
216
|
+
),
|
|
217
|
+
)
|
|
218
|
+
if _response.status_code == 401:
|
|
219
|
+
raise UnauthorizedError(
|
|
220
|
+
headers=dict(_response.headers),
|
|
221
|
+
body=typing.cast(
|
|
222
|
+
typing.Optional[typing.Any],
|
|
223
|
+
parse_obj_as(
|
|
224
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
225
|
+
object_=_response.json(),
|
|
226
|
+
),
|
|
227
|
+
),
|
|
228
|
+
)
|
|
229
|
+
if _response.status_code == 403:
|
|
230
|
+
raise ForbiddenError(
|
|
231
|
+
headers=dict(_response.headers),
|
|
232
|
+
body=typing.cast(
|
|
233
|
+
typing.Optional[typing.Any],
|
|
234
|
+
parse_obj_as(
|
|
235
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
236
|
+
object_=_response.json(),
|
|
237
|
+
),
|
|
238
|
+
),
|
|
239
|
+
)
|
|
240
|
+
if _response.status_code == 424:
|
|
241
|
+
raise FailedDependencyError(
|
|
242
|
+
headers=dict(_response.headers),
|
|
243
|
+
body=typing.cast(
|
|
244
|
+
typing.Optional[typing.Any],
|
|
245
|
+
parse_obj_as(
|
|
246
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
247
|
+
object_=_response.json(),
|
|
248
|
+
),
|
|
249
|
+
),
|
|
250
|
+
)
|
|
251
|
+
if _response.status_code == 500:
|
|
252
|
+
raise InternalServerError(
|
|
253
|
+
headers=dict(_response.headers),
|
|
254
|
+
body=typing.cast(
|
|
255
|
+
typing.Optional[typing.Any],
|
|
256
|
+
parse_obj_as(
|
|
257
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
258
|
+
object_=_response.json(),
|
|
259
|
+
),
|
|
260
|
+
),
|
|
261
|
+
)
|
|
262
|
+
_response_json = _response.json()
|
|
263
|
+
except JSONDecodeError:
|
|
264
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
265
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
266
|
+
|
|
267
|
+
def analyze_cohort(
|
|
268
|
+
self, *, text: str, provider: str, request_options: typing.Optional[RequestOptions] = None
|
|
269
|
+
) -> HttpResponse[CohortResponse]:
|
|
270
|
+
"""
|
|
271
|
+
Uses LLM to extract search concepts from natural language and builds patient cohorts with inclusion/exclusion criteria
|
|
272
|
+
|
|
273
|
+
Parameters
|
|
274
|
+
----------
|
|
275
|
+
text : str
|
|
276
|
+
Natural language text describing the patient cohort criteria
|
|
277
|
+
|
|
278
|
+
provider : str
|
|
279
|
+
FHIR provider ID - must be a valid UUID from existing FHIR providers. also supports provider by name (e.g. medplum)
|
|
280
|
+
|
|
281
|
+
request_options : typing.Optional[RequestOptions]
|
|
282
|
+
Request-specific configuration.
|
|
283
|
+
|
|
284
|
+
Returns
|
|
285
|
+
-------
|
|
286
|
+
HttpResponse[CohortResponse]
|
|
287
|
+
Successfully analyzed cohort and retrieved patient list
|
|
288
|
+
"""
|
|
289
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
290
|
+
"tools/cohort",
|
|
291
|
+
method="POST",
|
|
292
|
+
json={
|
|
293
|
+
"text": text,
|
|
294
|
+
"provider": provider,
|
|
295
|
+
},
|
|
296
|
+
headers={
|
|
297
|
+
"content-type": "application/json",
|
|
298
|
+
},
|
|
299
|
+
request_options=request_options,
|
|
300
|
+
omit=OMIT,
|
|
301
|
+
)
|
|
302
|
+
try:
|
|
303
|
+
if 200 <= _response.status_code < 300:
|
|
304
|
+
_data = typing.cast(
|
|
305
|
+
CohortResponse,
|
|
306
|
+
parse_obj_as(
|
|
307
|
+
type_=CohortResponse, # type: ignore
|
|
308
|
+
object_=_response.json(),
|
|
309
|
+
),
|
|
310
|
+
)
|
|
311
|
+
return HttpResponse(response=_response, data=_data)
|
|
312
|
+
if _response.status_code == 400:
|
|
313
|
+
raise BadRequestError(
|
|
314
|
+
headers=dict(_response.headers),
|
|
315
|
+
body=typing.cast(
|
|
316
|
+
typing.Optional[typing.Any],
|
|
317
|
+
parse_obj_as(
|
|
318
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
319
|
+
object_=_response.json(),
|
|
320
|
+
),
|
|
321
|
+
),
|
|
322
|
+
)
|
|
323
|
+
if _response.status_code == 401:
|
|
324
|
+
raise UnauthorizedError(
|
|
325
|
+
headers=dict(_response.headers),
|
|
326
|
+
body=typing.cast(
|
|
327
|
+
typing.Optional[typing.Any],
|
|
328
|
+
parse_obj_as(
|
|
329
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
330
|
+
object_=_response.json(),
|
|
331
|
+
),
|
|
332
|
+
),
|
|
333
|
+
)
|
|
334
|
+
if _response.status_code == 403:
|
|
335
|
+
raise ForbiddenError(
|
|
336
|
+
headers=dict(_response.headers),
|
|
337
|
+
body=typing.cast(
|
|
338
|
+
typing.Optional[typing.Any],
|
|
339
|
+
parse_obj_as(
|
|
340
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
341
|
+
object_=_response.json(),
|
|
342
|
+
),
|
|
343
|
+
),
|
|
344
|
+
)
|
|
345
|
+
if _response.status_code == 500:
|
|
346
|
+
raise InternalServerError(
|
|
347
|
+
headers=dict(_response.headers),
|
|
348
|
+
body=typing.cast(
|
|
349
|
+
typing.Optional[typing.Any],
|
|
350
|
+
parse_obj_as(
|
|
351
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
352
|
+
object_=_response.json(),
|
|
353
|
+
),
|
|
354
|
+
),
|
|
355
|
+
)
|
|
356
|
+
_response_json = _response.json()
|
|
357
|
+
except JSONDecodeError:
|
|
358
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
359
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
360
|
+
|
|
361
|
+
|
|
362
|
+
class AsyncRawToolsClient:
|
|
363
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
364
|
+
self._client_wrapper = client_wrapper
|
|
365
|
+
|
|
366
|
+
async def create_fhir_resource(
|
|
367
|
+
self,
|
|
368
|
+
*,
|
|
369
|
+
resource: Lang2FhirAndCreateRequestResource,
|
|
370
|
+
text: str,
|
|
371
|
+
provider: typing.Optional[str] = OMIT,
|
|
372
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
373
|
+
) -> AsyncHttpResponse[Lang2FhirAndCreateResponse]:
|
|
374
|
+
"""
|
|
375
|
+
Converts natural language to FHIR resource and optionally stores it in a FHIR server
|
|
376
|
+
|
|
377
|
+
Parameters
|
|
378
|
+
----------
|
|
379
|
+
resource : Lang2FhirAndCreateRequestResource
|
|
380
|
+
Type of FHIR resource to create. Use 'auto' for automatic resource type detection, or specify a supported US Core profile.
|
|
381
|
+
|
|
382
|
+
text : str
|
|
383
|
+
Natural language text to convert to FHIR resource
|
|
384
|
+
|
|
385
|
+
provider : typing.Optional[str]
|
|
386
|
+
FHIR provider ID - must be a valid UUID from existing FHIR providers. also supports provider by name (e.g. medplum)
|
|
387
|
+
|
|
388
|
+
request_options : typing.Optional[RequestOptions]
|
|
389
|
+
Request-specific configuration.
|
|
390
|
+
|
|
391
|
+
Returns
|
|
392
|
+
-------
|
|
393
|
+
AsyncHttpResponse[Lang2FhirAndCreateResponse]
|
|
394
|
+
Successfully created FHIR resource
|
|
395
|
+
"""
|
|
396
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
397
|
+
"tools/lang2fhir-and-create",
|
|
398
|
+
method="POST",
|
|
399
|
+
json={
|
|
400
|
+
"resource": resource,
|
|
401
|
+
"text": text,
|
|
402
|
+
"provider": provider,
|
|
403
|
+
},
|
|
404
|
+
headers={
|
|
405
|
+
"content-type": "application/json",
|
|
406
|
+
},
|
|
407
|
+
request_options=request_options,
|
|
408
|
+
omit=OMIT,
|
|
409
|
+
)
|
|
410
|
+
try:
|
|
411
|
+
if 200 <= _response.status_code < 300:
|
|
412
|
+
_data = typing.cast(
|
|
413
|
+
Lang2FhirAndCreateResponse,
|
|
414
|
+
parse_obj_as(
|
|
415
|
+
type_=Lang2FhirAndCreateResponse, # type: ignore
|
|
416
|
+
object_=_response.json(),
|
|
417
|
+
),
|
|
418
|
+
)
|
|
419
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
420
|
+
if _response.status_code == 400:
|
|
421
|
+
raise BadRequestError(
|
|
422
|
+
headers=dict(_response.headers),
|
|
423
|
+
body=typing.cast(
|
|
424
|
+
typing.Optional[typing.Any],
|
|
425
|
+
parse_obj_as(
|
|
426
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
427
|
+
object_=_response.json(),
|
|
428
|
+
),
|
|
429
|
+
),
|
|
430
|
+
)
|
|
431
|
+
if _response.status_code == 401:
|
|
432
|
+
raise UnauthorizedError(
|
|
433
|
+
headers=dict(_response.headers),
|
|
434
|
+
body=typing.cast(
|
|
435
|
+
typing.Optional[typing.Any],
|
|
436
|
+
parse_obj_as(
|
|
437
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
438
|
+
object_=_response.json(),
|
|
439
|
+
),
|
|
440
|
+
),
|
|
441
|
+
)
|
|
442
|
+
if _response.status_code == 403:
|
|
443
|
+
raise ForbiddenError(
|
|
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 == 424:
|
|
454
|
+
raise FailedDependencyError(
|
|
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 == 500:
|
|
465
|
+
raise InternalServerError(
|
|
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
|
+
_response_json = _response.json()
|
|
476
|
+
except JSONDecodeError:
|
|
477
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
478
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
479
|
+
|
|
480
|
+
async def search_fhir_resources(
|
|
481
|
+
self,
|
|
482
|
+
*,
|
|
483
|
+
text: str,
|
|
484
|
+
patient_id: typing.Optional[str] = OMIT,
|
|
485
|
+
practitioner_id: typing.Optional[str] = OMIT,
|
|
486
|
+
count: typing.Optional[int] = OMIT,
|
|
487
|
+
provider: typing.Optional[str] = OMIT,
|
|
488
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
489
|
+
) -> AsyncHttpResponse[Lang2FhirAndSearchResponse]:
|
|
490
|
+
"""
|
|
491
|
+
Converts natural language to FHIR search parameters and executes search in FHIR server
|
|
492
|
+
|
|
493
|
+
Parameters
|
|
494
|
+
----------
|
|
495
|
+
text : str
|
|
496
|
+
Natural language text to convert to FHIR search parameters
|
|
497
|
+
|
|
498
|
+
patient_id : typing.Optional[str]
|
|
499
|
+
Patient ID to filter results
|
|
500
|
+
|
|
501
|
+
practitioner_id : typing.Optional[str]
|
|
502
|
+
Practitioner ID to filter results
|
|
503
|
+
|
|
504
|
+
count : typing.Optional[int]
|
|
505
|
+
Maximum number of results to return
|
|
506
|
+
|
|
507
|
+
provider : typing.Optional[str]
|
|
508
|
+
FHIR provider ID - must be a valid UUID from existing FHIR providers. also supports provider by name (e.g. medplum)
|
|
509
|
+
|
|
510
|
+
request_options : typing.Optional[RequestOptions]
|
|
511
|
+
Request-specific configuration.
|
|
512
|
+
|
|
513
|
+
Returns
|
|
514
|
+
-------
|
|
515
|
+
AsyncHttpResponse[Lang2FhirAndSearchResponse]
|
|
516
|
+
Successfully generated search and retrieved results
|
|
517
|
+
"""
|
|
518
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
519
|
+
"tools/lang2fhir-and-search",
|
|
520
|
+
method="POST",
|
|
521
|
+
json={
|
|
522
|
+
"text": text,
|
|
523
|
+
"patient_id": patient_id,
|
|
524
|
+
"practitioner_id": practitioner_id,
|
|
525
|
+
"count": count,
|
|
526
|
+
"provider": provider,
|
|
527
|
+
},
|
|
528
|
+
headers={
|
|
529
|
+
"content-type": "application/json",
|
|
530
|
+
},
|
|
531
|
+
request_options=request_options,
|
|
532
|
+
omit=OMIT,
|
|
533
|
+
)
|
|
534
|
+
try:
|
|
535
|
+
if 200 <= _response.status_code < 300:
|
|
536
|
+
_data = typing.cast(
|
|
537
|
+
Lang2FhirAndSearchResponse,
|
|
538
|
+
parse_obj_as(
|
|
539
|
+
type_=Lang2FhirAndSearchResponse, # type: ignore
|
|
540
|
+
object_=_response.json(),
|
|
541
|
+
),
|
|
542
|
+
)
|
|
543
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
544
|
+
if _response.status_code == 400:
|
|
545
|
+
raise BadRequestError(
|
|
546
|
+
headers=dict(_response.headers),
|
|
547
|
+
body=typing.cast(
|
|
548
|
+
typing.Optional[typing.Any],
|
|
549
|
+
parse_obj_as(
|
|
550
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
551
|
+
object_=_response.json(),
|
|
552
|
+
),
|
|
553
|
+
),
|
|
554
|
+
)
|
|
555
|
+
if _response.status_code == 401:
|
|
556
|
+
raise UnauthorizedError(
|
|
557
|
+
headers=dict(_response.headers),
|
|
558
|
+
body=typing.cast(
|
|
559
|
+
typing.Optional[typing.Any],
|
|
560
|
+
parse_obj_as(
|
|
561
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
562
|
+
object_=_response.json(),
|
|
563
|
+
),
|
|
564
|
+
),
|
|
565
|
+
)
|
|
566
|
+
if _response.status_code == 403:
|
|
567
|
+
raise ForbiddenError(
|
|
568
|
+
headers=dict(_response.headers),
|
|
569
|
+
body=typing.cast(
|
|
570
|
+
typing.Optional[typing.Any],
|
|
571
|
+
parse_obj_as(
|
|
572
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
573
|
+
object_=_response.json(),
|
|
574
|
+
),
|
|
575
|
+
),
|
|
576
|
+
)
|
|
577
|
+
if _response.status_code == 424:
|
|
578
|
+
raise FailedDependencyError(
|
|
579
|
+
headers=dict(_response.headers),
|
|
580
|
+
body=typing.cast(
|
|
581
|
+
typing.Optional[typing.Any],
|
|
582
|
+
parse_obj_as(
|
|
583
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
584
|
+
object_=_response.json(),
|
|
585
|
+
),
|
|
586
|
+
),
|
|
587
|
+
)
|
|
588
|
+
if _response.status_code == 500:
|
|
589
|
+
raise InternalServerError(
|
|
590
|
+
headers=dict(_response.headers),
|
|
591
|
+
body=typing.cast(
|
|
592
|
+
typing.Optional[typing.Any],
|
|
593
|
+
parse_obj_as(
|
|
594
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
595
|
+
object_=_response.json(),
|
|
596
|
+
),
|
|
597
|
+
),
|
|
598
|
+
)
|
|
599
|
+
_response_json = _response.json()
|
|
600
|
+
except JSONDecodeError:
|
|
601
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
602
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
603
|
+
|
|
604
|
+
async def analyze_cohort(
|
|
605
|
+
self, *, text: str, provider: str, request_options: typing.Optional[RequestOptions] = None
|
|
606
|
+
) -> AsyncHttpResponse[CohortResponse]:
|
|
607
|
+
"""
|
|
608
|
+
Uses LLM to extract search concepts from natural language and builds patient cohorts with inclusion/exclusion criteria
|
|
609
|
+
|
|
610
|
+
Parameters
|
|
611
|
+
----------
|
|
612
|
+
text : str
|
|
613
|
+
Natural language text describing the patient cohort criteria
|
|
614
|
+
|
|
615
|
+
provider : str
|
|
616
|
+
FHIR provider ID - must be a valid UUID from existing FHIR providers. also supports provider by name (e.g. medplum)
|
|
617
|
+
|
|
618
|
+
request_options : typing.Optional[RequestOptions]
|
|
619
|
+
Request-specific configuration.
|
|
620
|
+
|
|
621
|
+
Returns
|
|
622
|
+
-------
|
|
623
|
+
AsyncHttpResponse[CohortResponse]
|
|
624
|
+
Successfully analyzed cohort and retrieved patient list
|
|
625
|
+
"""
|
|
626
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
627
|
+
"tools/cohort",
|
|
628
|
+
method="POST",
|
|
629
|
+
json={
|
|
630
|
+
"text": text,
|
|
631
|
+
"provider": provider,
|
|
632
|
+
},
|
|
633
|
+
headers={
|
|
634
|
+
"content-type": "application/json",
|
|
635
|
+
},
|
|
636
|
+
request_options=request_options,
|
|
637
|
+
omit=OMIT,
|
|
638
|
+
)
|
|
639
|
+
try:
|
|
640
|
+
if 200 <= _response.status_code < 300:
|
|
641
|
+
_data = typing.cast(
|
|
642
|
+
CohortResponse,
|
|
643
|
+
parse_obj_as(
|
|
644
|
+
type_=CohortResponse, # type: ignore
|
|
645
|
+
object_=_response.json(),
|
|
646
|
+
),
|
|
647
|
+
)
|
|
648
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
649
|
+
if _response.status_code == 400:
|
|
650
|
+
raise BadRequestError(
|
|
651
|
+
headers=dict(_response.headers),
|
|
652
|
+
body=typing.cast(
|
|
653
|
+
typing.Optional[typing.Any],
|
|
654
|
+
parse_obj_as(
|
|
655
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
656
|
+
object_=_response.json(),
|
|
657
|
+
),
|
|
658
|
+
),
|
|
659
|
+
)
|
|
660
|
+
if _response.status_code == 401:
|
|
661
|
+
raise UnauthorizedError(
|
|
662
|
+
headers=dict(_response.headers),
|
|
663
|
+
body=typing.cast(
|
|
664
|
+
typing.Optional[typing.Any],
|
|
665
|
+
parse_obj_as(
|
|
666
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
667
|
+
object_=_response.json(),
|
|
668
|
+
),
|
|
669
|
+
),
|
|
670
|
+
)
|
|
671
|
+
if _response.status_code == 403:
|
|
672
|
+
raise ForbiddenError(
|
|
673
|
+
headers=dict(_response.headers),
|
|
674
|
+
body=typing.cast(
|
|
675
|
+
typing.Optional[typing.Any],
|
|
676
|
+
parse_obj_as(
|
|
677
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
678
|
+
object_=_response.json(),
|
|
679
|
+
),
|
|
680
|
+
),
|
|
681
|
+
)
|
|
682
|
+
if _response.status_code == 500:
|
|
683
|
+
raise InternalServerError(
|
|
684
|
+
headers=dict(_response.headers),
|
|
685
|
+
body=typing.cast(
|
|
686
|
+
typing.Optional[typing.Any],
|
|
687
|
+
parse_obj_as(
|
|
688
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
689
|
+
object_=_response.json(),
|
|
690
|
+
),
|
|
691
|
+
),
|
|
692
|
+
)
|
|
693
|
+
_response_json = _response.json()
|
|
694
|
+
except JSONDecodeError:
|
|
695
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
696
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|