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
phenoml/cohort/client.py
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
|
|
5
|
+
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
|
6
|
+
from ..core.request_options import RequestOptions
|
|
7
|
+
from .raw_client import AsyncRawCohortClient, RawCohortClient
|
|
8
|
+
from .types.cohort_response import CohortResponse
|
|
9
|
+
|
|
10
|
+
# this is used as the default value for optional parameters
|
|
11
|
+
OMIT = typing.cast(typing.Any, ...)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class CohortClient:
|
|
15
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
16
|
+
self._raw_client = RawCohortClient(client_wrapper=client_wrapper)
|
|
17
|
+
|
|
18
|
+
@property
|
|
19
|
+
def with_raw_response(self) -> RawCohortClient:
|
|
20
|
+
"""
|
|
21
|
+
Retrieves a raw implementation of this client that returns raw responses.
|
|
22
|
+
|
|
23
|
+
Returns
|
|
24
|
+
-------
|
|
25
|
+
RawCohortClient
|
|
26
|
+
"""
|
|
27
|
+
return self._raw_client
|
|
28
|
+
|
|
29
|
+
def analyze(self, *, text: str, request_options: typing.Optional[RequestOptions] = None) -> CohortResponse:
|
|
30
|
+
"""
|
|
31
|
+
Converts natural language text into structured FHIR search queries for patient cohort analysis
|
|
32
|
+
|
|
33
|
+
Parameters
|
|
34
|
+
----------
|
|
35
|
+
text : str
|
|
36
|
+
Natural language text describing patient cohort criteria
|
|
37
|
+
|
|
38
|
+
request_options : typing.Optional[RequestOptions]
|
|
39
|
+
Request-specific configuration.
|
|
40
|
+
|
|
41
|
+
Returns
|
|
42
|
+
-------
|
|
43
|
+
CohortResponse
|
|
44
|
+
Successfully analyzed cohort criteria
|
|
45
|
+
|
|
46
|
+
Examples
|
|
47
|
+
--------
|
|
48
|
+
from phenoml import phenoml
|
|
49
|
+
|
|
50
|
+
client = phenoml(
|
|
51
|
+
token="YOUR_TOKEN",
|
|
52
|
+
)
|
|
53
|
+
client.cohort.analyze(
|
|
54
|
+
text="female patients over 65 with diabetes but not hypertension",
|
|
55
|
+
)
|
|
56
|
+
"""
|
|
57
|
+
_response = self._raw_client.analyze(text=text, request_options=request_options)
|
|
58
|
+
return _response.data
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
class AsyncCohortClient:
|
|
62
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
63
|
+
self._raw_client = AsyncRawCohortClient(client_wrapper=client_wrapper)
|
|
64
|
+
|
|
65
|
+
@property
|
|
66
|
+
def with_raw_response(self) -> AsyncRawCohortClient:
|
|
67
|
+
"""
|
|
68
|
+
Retrieves a raw implementation of this client that returns raw responses.
|
|
69
|
+
|
|
70
|
+
Returns
|
|
71
|
+
-------
|
|
72
|
+
AsyncRawCohortClient
|
|
73
|
+
"""
|
|
74
|
+
return self._raw_client
|
|
75
|
+
|
|
76
|
+
async def analyze(self, *, text: str, request_options: typing.Optional[RequestOptions] = None) -> CohortResponse:
|
|
77
|
+
"""
|
|
78
|
+
Converts natural language text into structured FHIR search queries for patient cohort analysis
|
|
79
|
+
|
|
80
|
+
Parameters
|
|
81
|
+
----------
|
|
82
|
+
text : str
|
|
83
|
+
Natural language text describing patient cohort criteria
|
|
84
|
+
|
|
85
|
+
request_options : typing.Optional[RequestOptions]
|
|
86
|
+
Request-specific configuration.
|
|
87
|
+
|
|
88
|
+
Returns
|
|
89
|
+
-------
|
|
90
|
+
CohortResponse
|
|
91
|
+
Successfully analyzed cohort criteria
|
|
92
|
+
|
|
93
|
+
Examples
|
|
94
|
+
--------
|
|
95
|
+
import asyncio
|
|
96
|
+
|
|
97
|
+
from phenoml import Asyncphenoml
|
|
98
|
+
|
|
99
|
+
client = Asyncphenoml(
|
|
100
|
+
token="YOUR_TOKEN",
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
async def main() -> None:
|
|
105
|
+
await client.cohort.analyze(
|
|
106
|
+
text="female patients over 65 with diabetes but not hypertension",
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
asyncio.run(main())
|
|
111
|
+
"""
|
|
112
|
+
_response = await self._raw_client.analyze(text=text, request_options=request_options)
|
|
113
|
+
return _response.data
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
# isort: skip_file
|
|
4
|
+
|
|
5
|
+
from .bad_request_error import BadRequestError
|
|
6
|
+
from .internal_server_error import InternalServerError
|
|
7
|
+
from .unauthorized_error import UnauthorizedError
|
|
8
|
+
|
|
9
|
+
__all__ = ["BadRequestError", "InternalServerError", "UnauthorizedError"]
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
|
|
5
|
+
from ...core.api_error import ApiError
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class BadRequestError(ApiError):
|
|
9
|
+
def __init__(self, body: typing.Optional[typing.Any], headers: typing.Optional[typing.Dict[str, str]] = None):
|
|
10
|
+
super().__init__(status_code=400, headers=headers, body=body)
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
|
|
5
|
+
from ...core.api_error import ApiError
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class InternalServerError(ApiError):
|
|
9
|
+
def __init__(self, body: typing.Optional[typing.Any], headers: typing.Optional[typing.Dict[str, str]] = None):
|
|
10
|
+
super().__init__(status_code=500, headers=headers, body=body)
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
|
|
5
|
+
from ...core.api_error import ApiError
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class UnauthorizedError(ApiError):
|
|
9
|
+
def __init__(self, body: typing.Optional[typing.Any], headers: typing.Optional[typing.Dict[str, str]] = None):
|
|
10
|
+
super().__init__(status_code=401, headers=headers, body=body)
|
|
@@ -0,0 +1,185 @@
|
|
|
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.internal_server_error import InternalServerError
|
|
13
|
+
from .errors.unauthorized_error import UnauthorizedError
|
|
14
|
+
from .types.cohort_response import CohortResponse
|
|
15
|
+
|
|
16
|
+
# this is used as the default value for optional parameters
|
|
17
|
+
OMIT = typing.cast(typing.Any, ...)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class RawCohortClient:
|
|
21
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
22
|
+
self._client_wrapper = client_wrapper
|
|
23
|
+
|
|
24
|
+
def analyze(
|
|
25
|
+
self, *, text: str, request_options: typing.Optional[RequestOptions] = None
|
|
26
|
+
) -> HttpResponse[CohortResponse]:
|
|
27
|
+
"""
|
|
28
|
+
Converts natural language text into structured FHIR search queries for patient cohort analysis
|
|
29
|
+
|
|
30
|
+
Parameters
|
|
31
|
+
----------
|
|
32
|
+
text : str
|
|
33
|
+
Natural language text describing patient cohort criteria
|
|
34
|
+
|
|
35
|
+
request_options : typing.Optional[RequestOptions]
|
|
36
|
+
Request-specific configuration.
|
|
37
|
+
|
|
38
|
+
Returns
|
|
39
|
+
-------
|
|
40
|
+
HttpResponse[CohortResponse]
|
|
41
|
+
Successfully analyzed cohort criteria
|
|
42
|
+
"""
|
|
43
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
44
|
+
"cohort",
|
|
45
|
+
method="POST",
|
|
46
|
+
json={
|
|
47
|
+
"text": text,
|
|
48
|
+
},
|
|
49
|
+
headers={
|
|
50
|
+
"content-type": "application/json",
|
|
51
|
+
},
|
|
52
|
+
request_options=request_options,
|
|
53
|
+
omit=OMIT,
|
|
54
|
+
)
|
|
55
|
+
try:
|
|
56
|
+
if 200 <= _response.status_code < 300:
|
|
57
|
+
_data = typing.cast(
|
|
58
|
+
CohortResponse,
|
|
59
|
+
parse_obj_as(
|
|
60
|
+
type_=CohortResponse, # type: ignore
|
|
61
|
+
object_=_response.json(),
|
|
62
|
+
),
|
|
63
|
+
)
|
|
64
|
+
return HttpResponse(response=_response, data=_data)
|
|
65
|
+
if _response.status_code == 400:
|
|
66
|
+
raise BadRequestError(
|
|
67
|
+
headers=dict(_response.headers),
|
|
68
|
+
body=typing.cast(
|
|
69
|
+
typing.Optional[typing.Any],
|
|
70
|
+
parse_obj_as(
|
|
71
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
72
|
+
object_=_response.json(),
|
|
73
|
+
),
|
|
74
|
+
),
|
|
75
|
+
)
|
|
76
|
+
if _response.status_code == 401:
|
|
77
|
+
raise UnauthorizedError(
|
|
78
|
+
headers=dict(_response.headers),
|
|
79
|
+
body=typing.cast(
|
|
80
|
+
typing.Optional[typing.Any],
|
|
81
|
+
parse_obj_as(
|
|
82
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
83
|
+
object_=_response.json(),
|
|
84
|
+
),
|
|
85
|
+
),
|
|
86
|
+
)
|
|
87
|
+
if _response.status_code == 500:
|
|
88
|
+
raise InternalServerError(
|
|
89
|
+
headers=dict(_response.headers),
|
|
90
|
+
body=typing.cast(
|
|
91
|
+
typing.Optional[typing.Any],
|
|
92
|
+
parse_obj_as(
|
|
93
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
94
|
+
object_=_response.json(),
|
|
95
|
+
),
|
|
96
|
+
),
|
|
97
|
+
)
|
|
98
|
+
_response_json = _response.json()
|
|
99
|
+
except JSONDecodeError:
|
|
100
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
101
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
class AsyncRawCohortClient:
|
|
105
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
106
|
+
self._client_wrapper = client_wrapper
|
|
107
|
+
|
|
108
|
+
async def analyze(
|
|
109
|
+
self, *, text: str, request_options: typing.Optional[RequestOptions] = None
|
|
110
|
+
) -> AsyncHttpResponse[CohortResponse]:
|
|
111
|
+
"""
|
|
112
|
+
Converts natural language text into structured FHIR search queries for patient cohort analysis
|
|
113
|
+
|
|
114
|
+
Parameters
|
|
115
|
+
----------
|
|
116
|
+
text : str
|
|
117
|
+
Natural language text describing patient cohort criteria
|
|
118
|
+
|
|
119
|
+
request_options : typing.Optional[RequestOptions]
|
|
120
|
+
Request-specific configuration.
|
|
121
|
+
|
|
122
|
+
Returns
|
|
123
|
+
-------
|
|
124
|
+
AsyncHttpResponse[CohortResponse]
|
|
125
|
+
Successfully analyzed cohort criteria
|
|
126
|
+
"""
|
|
127
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
128
|
+
"cohort",
|
|
129
|
+
method="POST",
|
|
130
|
+
json={
|
|
131
|
+
"text": text,
|
|
132
|
+
},
|
|
133
|
+
headers={
|
|
134
|
+
"content-type": "application/json",
|
|
135
|
+
},
|
|
136
|
+
request_options=request_options,
|
|
137
|
+
omit=OMIT,
|
|
138
|
+
)
|
|
139
|
+
try:
|
|
140
|
+
if 200 <= _response.status_code < 300:
|
|
141
|
+
_data = typing.cast(
|
|
142
|
+
CohortResponse,
|
|
143
|
+
parse_obj_as(
|
|
144
|
+
type_=CohortResponse, # type: ignore
|
|
145
|
+
object_=_response.json(),
|
|
146
|
+
),
|
|
147
|
+
)
|
|
148
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
149
|
+
if _response.status_code == 400:
|
|
150
|
+
raise BadRequestError(
|
|
151
|
+
headers=dict(_response.headers),
|
|
152
|
+
body=typing.cast(
|
|
153
|
+
typing.Optional[typing.Any],
|
|
154
|
+
parse_obj_as(
|
|
155
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
156
|
+
object_=_response.json(),
|
|
157
|
+
),
|
|
158
|
+
),
|
|
159
|
+
)
|
|
160
|
+
if _response.status_code == 401:
|
|
161
|
+
raise UnauthorizedError(
|
|
162
|
+
headers=dict(_response.headers),
|
|
163
|
+
body=typing.cast(
|
|
164
|
+
typing.Optional[typing.Any],
|
|
165
|
+
parse_obj_as(
|
|
166
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
167
|
+
object_=_response.json(),
|
|
168
|
+
),
|
|
169
|
+
),
|
|
170
|
+
)
|
|
171
|
+
if _response.status_code == 500:
|
|
172
|
+
raise InternalServerError(
|
|
173
|
+
headers=dict(_response.headers),
|
|
174
|
+
body=typing.cast(
|
|
175
|
+
typing.Optional[typing.Any],
|
|
176
|
+
parse_obj_as(
|
|
177
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
178
|
+
object_=_response.json(),
|
|
179
|
+
),
|
|
180
|
+
),
|
|
181
|
+
)
|
|
182
|
+
_response_json = _response.json()
|
|
183
|
+
except JSONDecodeError:
|
|
184
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
185
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
|
|
5
|
+
import pydantic
|
|
6
|
+
from ...core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
|
|
7
|
+
from .search_concept import SearchConcept
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class CohortResponse(UniversalBaseModel):
|
|
11
|
+
success: typing.Optional[bool] = pydantic.Field(default=None)
|
|
12
|
+
"""
|
|
13
|
+
Whether the cohort analysis was successful
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
message: typing.Optional[str] = pydantic.Field(default=None)
|
|
17
|
+
"""
|
|
18
|
+
Human-readable message about the analysis result
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
queries: typing.Optional[typing.List[SearchConcept]] = pydantic.Field(default=None)
|
|
22
|
+
"""
|
|
23
|
+
Array of search concepts converted to FHIR search queries
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
if IS_PYDANTIC_V2:
|
|
27
|
+
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
|
|
28
|
+
else:
|
|
29
|
+
|
|
30
|
+
class Config:
|
|
31
|
+
frozen = True
|
|
32
|
+
smart_union = True
|
|
33
|
+
extra = pydantic.Extra.allow
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
|
|
5
|
+
import pydantic
|
|
6
|
+
from ...core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class SearchConcept(UniversalBaseModel):
|
|
10
|
+
resource_type: typing.Optional[str] = pydantic.Field(default=None)
|
|
11
|
+
"""
|
|
12
|
+
The FHIR resource type for this search concept
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
search_params: typing.Optional[str] = pydantic.Field(default=None)
|
|
16
|
+
"""
|
|
17
|
+
FHIR search parameters in standard format
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
concept: typing.Optional[str] = pydantic.Field(default=None)
|
|
21
|
+
"""
|
|
22
|
+
The original concept description
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
exclude: typing.Optional[bool] = pydantic.Field(default=None)
|
|
26
|
+
"""
|
|
27
|
+
Whether this concept should be excluded from the search
|
|
28
|
+
"""
|
|
29
|
+
|
|
30
|
+
if IS_PYDANTIC_V2:
|
|
31
|
+
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
|
|
32
|
+
else:
|
|
33
|
+
|
|
34
|
+
class Config:
|
|
35
|
+
frozen = True
|
|
36
|
+
smart_union = True
|
|
37
|
+
extra = pydantic.Extra.allow
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
# isort: skip_file
|
|
4
|
+
|
|
5
|
+
from .types import (
|
|
6
|
+
BadRequestErrorBody,
|
|
7
|
+
ConstrueCohortRequestConfig,
|
|
8
|
+
ConstrueCohortResponse,
|
|
9
|
+
ConstrueCohortResponseQueriesItem,
|
|
10
|
+
ConstrueCohortResponseQueriesItemCodeExtractResultsItem,
|
|
11
|
+
ConstrueCohortResponseQueriesItemCodeExtractResultsItemCodesItem,
|
|
12
|
+
ConstrueUploadCodeSystemResponse,
|
|
13
|
+
ExtractCodesResult,
|
|
14
|
+
ExtractRequestConfig,
|
|
15
|
+
ExtractRequestConfigChunkingMethod,
|
|
16
|
+
ExtractRequestSystem,
|
|
17
|
+
ExtractedCodeResult,
|
|
18
|
+
InternalServerErrorBody,
|
|
19
|
+
UnauthorizedErrorBody,
|
|
20
|
+
UploadRequestFormat,
|
|
21
|
+
)
|
|
22
|
+
from .errors import BadRequestError, ConflictError, FailedDependencyError, InternalServerError, UnauthorizedError
|
|
23
|
+
|
|
24
|
+
__all__ = [
|
|
25
|
+
"BadRequestError",
|
|
26
|
+
"BadRequestErrorBody",
|
|
27
|
+
"ConflictError",
|
|
28
|
+
"ConstrueCohortRequestConfig",
|
|
29
|
+
"ConstrueCohortResponse",
|
|
30
|
+
"ConstrueCohortResponseQueriesItem",
|
|
31
|
+
"ConstrueCohortResponseQueriesItemCodeExtractResultsItem",
|
|
32
|
+
"ConstrueCohortResponseQueriesItemCodeExtractResultsItemCodesItem",
|
|
33
|
+
"ConstrueUploadCodeSystemResponse",
|
|
34
|
+
"ExtractCodesResult",
|
|
35
|
+
"ExtractRequestConfig",
|
|
36
|
+
"ExtractRequestConfigChunkingMethod",
|
|
37
|
+
"ExtractRequestSystem",
|
|
38
|
+
"ExtractedCodeResult",
|
|
39
|
+
"FailedDependencyError",
|
|
40
|
+
"InternalServerError",
|
|
41
|
+
"InternalServerErrorBody",
|
|
42
|
+
"UnauthorizedError",
|
|
43
|
+
"UnauthorizedErrorBody",
|
|
44
|
+
"UploadRequestFormat",
|
|
45
|
+
]
|