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,399 @@
|
|
|
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 AsyncRawConstrueClient, RawConstrueClient
|
|
8
|
+
from .types.construe_cohort_request_config import ConstrueCohortRequestConfig
|
|
9
|
+
from .types.construe_cohort_response import ConstrueCohortResponse
|
|
10
|
+
from .types.construe_upload_code_system_response import ConstrueUploadCodeSystemResponse
|
|
11
|
+
from .types.extract_codes_result import ExtractCodesResult
|
|
12
|
+
from .types.extract_request_config import ExtractRequestConfig
|
|
13
|
+
from .types.extract_request_system import ExtractRequestSystem
|
|
14
|
+
from .types.upload_request_format import UploadRequestFormat
|
|
15
|
+
|
|
16
|
+
# this is used as the default value for optional parameters
|
|
17
|
+
OMIT = typing.cast(typing.Any, ...)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class ConstrueClient:
|
|
21
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
22
|
+
self._raw_client = RawConstrueClient(client_wrapper=client_wrapper)
|
|
23
|
+
|
|
24
|
+
@property
|
|
25
|
+
def with_raw_response(self) -> RawConstrueClient:
|
|
26
|
+
"""
|
|
27
|
+
Retrieves a raw implementation of this client that returns raw responses.
|
|
28
|
+
|
|
29
|
+
Returns
|
|
30
|
+
-------
|
|
31
|
+
RawConstrueClient
|
|
32
|
+
"""
|
|
33
|
+
return self._raw_client
|
|
34
|
+
|
|
35
|
+
def upload_code_system(
|
|
36
|
+
self,
|
|
37
|
+
*,
|
|
38
|
+
name: str,
|
|
39
|
+
version: str,
|
|
40
|
+
format: UploadRequestFormat,
|
|
41
|
+
file: str,
|
|
42
|
+
revision: typing.Optional[float] = OMIT,
|
|
43
|
+
code_col: typing.Optional[str] = OMIT,
|
|
44
|
+
desc_col: typing.Optional[str] = OMIT,
|
|
45
|
+
defn_col: typing.Optional[str] = OMIT,
|
|
46
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
47
|
+
) -> ConstrueUploadCodeSystemResponse:
|
|
48
|
+
"""
|
|
49
|
+
Upload a custom medical code system with codes and descriptions for use in code extraction.
|
|
50
|
+
Upon upload, construe generates embeddings for all of the codes in the code system and stores them in the vector database so you can
|
|
51
|
+
subsequently use the code system for construe/extract and lang2fhir/create (coming soon!)
|
|
52
|
+
|
|
53
|
+
Parameters
|
|
54
|
+
----------
|
|
55
|
+
name : str
|
|
56
|
+
Name of the code system
|
|
57
|
+
|
|
58
|
+
version : str
|
|
59
|
+
Version of the code system
|
|
60
|
+
|
|
61
|
+
format : UploadRequestFormat
|
|
62
|
+
Format of the uploaded file
|
|
63
|
+
|
|
64
|
+
file : str
|
|
65
|
+
The file contents as a base64-encoded string
|
|
66
|
+
|
|
67
|
+
revision : typing.Optional[float]
|
|
68
|
+
Optional revision number
|
|
69
|
+
|
|
70
|
+
code_col : typing.Optional[str]
|
|
71
|
+
Column name containing codes (required for CSV format)
|
|
72
|
+
|
|
73
|
+
desc_col : typing.Optional[str]
|
|
74
|
+
Column name containing descriptions (required for CSV format)
|
|
75
|
+
|
|
76
|
+
defn_col : typing.Optional[str]
|
|
77
|
+
Optional column name containing long definitions (for CSV format)
|
|
78
|
+
|
|
79
|
+
request_options : typing.Optional[RequestOptions]
|
|
80
|
+
Request-specific configuration.
|
|
81
|
+
|
|
82
|
+
Returns
|
|
83
|
+
-------
|
|
84
|
+
ConstrueUploadCodeSystemResponse
|
|
85
|
+
Successfully uploaded code system
|
|
86
|
+
|
|
87
|
+
Examples
|
|
88
|
+
--------
|
|
89
|
+
from phenoml import phenoml
|
|
90
|
+
|
|
91
|
+
client = phenoml(
|
|
92
|
+
token="YOUR_TOKEN",
|
|
93
|
+
)
|
|
94
|
+
client.construe.upload_code_system(
|
|
95
|
+
name="CUSTOM_CODES",
|
|
96
|
+
version="1.0",
|
|
97
|
+
format="json",
|
|
98
|
+
file="file",
|
|
99
|
+
)
|
|
100
|
+
"""
|
|
101
|
+
_response = self._raw_client.upload_code_system(
|
|
102
|
+
name=name,
|
|
103
|
+
version=version,
|
|
104
|
+
format=format,
|
|
105
|
+
file=file,
|
|
106
|
+
revision=revision,
|
|
107
|
+
code_col=code_col,
|
|
108
|
+
desc_col=desc_col,
|
|
109
|
+
defn_col=defn_col,
|
|
110
|
+
request_options=request_options,
|
|
111
|
+
)
|
|
112
|
+
return _response.data
|
|
113
|
+
|
|
114
|
+
def extract_codes(
|
|
115
|
+
self,
|
|
116
|
+
*,
|
|
117
|
+
text: str,
|
|
118
|
+
system: typing.Optional[ExtractRequestSystem] = OMIT,
|
|
119
|
+
config: typing.Optional[ExtractRequestConfig] = OMIT,
|
|
120
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
121
|
+
) -> ExtractCodesResult:
|
|
122
|
+
"""
|
|
123
|
+
Converts natural language text into structured medical codes
|
|
124
|
+
|
|
125
|
+
Parameters
|
|
126
|
+
----------
|
|
127
|
+
text : str
|
|
128
|
+
Natural language text to extract codes from
|
|
129
|
+
|
|
130
|
+
system : typing.Optional[ExtractRequestSystem]
|
|
131
|
+
|
|
132
|
+
config : typing.Optional[ExtractRequestConfig]
|
|
133
|
+
|
|
134
|
+
request_options : typing.Optional[RequestOptions]
|
|
135
|
+
Request-specific configuration.
|
|
136
|
+
|
|
137
|
+
Returns
|
|
138
|
+
-------
|
|
139
|
+
ExtractCodesResult
|
|
140
|
+
Successfully extracted codes
|
|
141
|
+
|
|
142
|
+
Examples
|
|
143
|
+
--------
|
|
144
|
+
from phenoml import phenoml
|
|
145
|
+
|
|
146
|
+
client = phenoml(
|
|
147
|
+
token="YOUR_TOKEN",
|
|
148
|
+
)
|
|
149
|
+
client.construe.extract_codes(
|
|
150
|
+
text="Patient is a 14-year-old female, previously healthy, who is here for evaluation of abnormal renal ultrasound with atrophic right kidney",
|
|
151
|
+
)
|
|
152
|
+
"""
|
|
153
|
+
_response = self._raw_client.extract_codes(
|
|
154
|
+
text=text, system=system, config=config, request_options=request_options
|
|
155
|
+
)
|
|
156
|
+
return _response.data
|
|
157
|
+
|
|
158
|
+
def cohort(
|
|
159
|
+
self,
|
|
160
|
+
*,
|
|
161
|
+
text: str,
|
|
162
|
+
config: typing.Optional[ConstrueCohortRequestConfig] = OMIT,
|
|
163
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
164
|
+
) -> ConstrueCohortResponse:
|
|
165
|
+
"""
|
|
166
|
+
Creates a patient cohort based on a natural language description.
|
|
167
|
+
Translates the description into FHIR search queries and optional SQL queries.
|
|
168
|
+
|
|
169
|
+
Parameters
|
|
170
|
+
----------
|
|
171
|
+
text : str
|
|
172
|
+
Natural language description of the desired patient cohort.
|
|
173
|
+
|
|
174
|
+
config : typing.Optional[ConstrueCohortRequestConfig]
|
|
175
|
+
|
|
176
|
+
request_options : typing.Optional[RequestOptions]
|
|
177
|
+
Request-specific configuration.
|
|
178
|
+
|
|
179
|
+
Returns
|
|
180
|
+
-------
|
|
181
|
+
ConstrueCohortResponse
|
|
182
|
+
Cohort creation successful
|
|
183
|
+
|
|
184
|
+
Examples
|
|
185
|
+
--------
|
|
186
|
+
from phenoml import phenoml
|
|
187
|
+
|
|
188
|
+
client = phenoml(
|
|
189
|
+
token="YOUR_TOKEN",
|
|
190
|
+
)
|
|
191
|
+
client.construe.cohort(
|
|
192
|
+
text="Between 20 and 40 years old with hyperlipidemia",
|
|
193
|
+
)
|
|
194
|
+
"""
|
|
195
|
+
_response = self._raw_client.cohort(text=text, config=config, request_options=request_options)
|
|
196
|
+
return _response.data
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
class AsyncConstrueClient:
|
|
200
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
201
|
+
self._raw_client = AsyncRawConstrueClient(client_wrapper=client_wrapper)
|
|
202
|
+
|
|
203
|
+
@property
|
|
204
|
+
def with_raw_response(self) -> AsyncRawConstrueClient:
|
|
205
|
+
"""
|
|
206
|
+
Retrieves a raw implementation of this client that returns raw responses.
|
|
207
|
+
|
|
208
|
+
Returns
|
|
209
|
+
-------
|
|
210
|
+
AsyncRawConstrueClient
|
|
211
|
+
"""
|
|
212
|
+
return self._raw_client
|
|
213
|
+
|
|
214
|
+
async def upload_code_system(
|
|
215
|
+
self,
|
|
216
|
+
*,
|
|
217
|
+
name: str,
|
|
218
|
+
version: str,
|
|
219
|
+
format: UploadRequestFormat,
|
|
220
|
+
file: str,
|
|
221
|
+
revision: typing.Optional[float] = OMIT,
|
|
222
|
+
code_col: typing.Optional[str] = OMIT,
|
|
223
|
+
desc_col: typing.Optional[str] = OMIT,
|
|
224
|
+
defn_col: typing.Optional[str] = OMIT,
|
|
225
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
226
|
+
) -> ConstrueUploadCodeSystemResponse:
|
|
227
|
+
"""
|
|
228
|
+
Upload a custom medical code system with codes and descriptions for use in code extraction.
|
|
229
|
+
Upon upload, construe generates embeddings for all of the codes in the code system and stores them in the vector database so you can
|
|
230
|
+
subsequently use the code system for construe/extract and lang2fhir/create (coming soon!)
|
|
231
|
+
|
|
232
|
+
Parameters
|
|
233
|
+
----------
|
|
234
|
+
name : str
|
|
235
|
+
Name of the code system
|
|
236
|
+
|
|
237
|
+
version : str
|
|
238
|
+
Version of the code system
|
|
239
|
+
|
|
240
|
+
format : UploadRequestFormat
|
|
241
|
+
Format of the uploaded file
|
|
242
|
+
|
|
243
|
+
file : str
|
|
244
|
+
The file contents as a base64-encoded string
|
|
245
|
+
|
|
246
|
+
revision : typing.Optional[float]
|
|
247
|
+
Optional revision number
|
|
248
|
+
|
|
249
|
+
code_col : typing.Optional[str]
|
|
250
|
+
Column name containing codes (required for CSV format)
|
|
251
|
+
|
|
252
|
+
desc_col : typing.Optional[str]
|
|
253
|
+
Column name containing descriptions (required for CSV format)
|
|
254
|
+
|
|
255
|
+
defn_col : typing.Optional[str]
|
|
256
|
+
Optional column name containing long definitions (for CSV format)
|
|
257
|
+
|
|
258
|
+
request_options : typing.Optional[RequestOptions]
|
|
259
|
+
Request-specific configuration.
|
|
260
|
+
|
|
261
|
+
Returns
|
|
262
|
+
-------
|
|
263
|
+
ConstrueUploadCodeSystemResponse
|
|
264
|
+
Successfully uploaded code system
|
|
265
|
+
|
|
266
|
+
Examples
|
|
267
|
+
--------
|
|
268
|
+
import asyncio
|
|
269
|
+
|
|
270
|
+
from phenoml import Asyncphenoml
|
|
271
|
+
|
|
272
|
+
client = Asyncphenoml(
|
|
273
|
+
token="YOUR_TOKEN",
|
|
274
|
+
)
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
async def main() -> None:
|
|
278
|
+
await client.construe.upload_code_system(
|
|
279
|
+
name="CUSTOM_CODES",
|
|
280
|
+
version="1.0",
|
|
281
|
+
format="json",
|
|
282
|
+
file="file",
|
|
283
|
+
)
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
asyncio.run(main())
|
|
287
|
+
"""
|
|
288
|
+
_response = await self._raw_client.upload_code_system(
|
|
289
|
+
name=name,
|
|
290
|
+
version=version,
|
|
291
|
+
format=format,
|
|
292
|
+
file=file,
|
|
293
|
+
revision=revision,
|
|
294
|
+
code_col=code_col,
|
|
295
|
+
desc_col=desc_col,
|
|
296
|
+
defn_col=defn_col,
|
|
297
|
+
request_options=request_options,
|
|
298
|
+
)
|
|
299
|
+
return _response.data
|
|
300
|
+
|
|
301
|
+
async def extract_codes(
|
|
302
|
+
self,
|
|
303
|
+
*,
|
|
304
|
+
text: str,
|
|
305
|
+
system: typing.Optional[ExtractRequestSystem] = OMIT,
|
|
306
|
+
config: typing.Optional[ExtractRequestConfig] = OMIT,
|
|
307
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
308
|
+
) -> ExtractCodesResult:
|
|
309
|
+
"""
|
|
310
|
+
Converts natural language text into structured medical codes
|
|
311
|
+
|
|
312
|
+
Parameters
|
|
313
|
+
----------
|
|
314
|
+
text : str
|
|
315
|
+
Natural language text to extract codes from
|
|
316
|
+
|
|
317
|
+
system : typing.Optional[ExtractRequestSystem]
|
|
318
|
+
|
|
319
|
+
config : typing.Optional[ExtractRequestConfig]
|
|
320
|
+
|
|
321
|
+
request_options : typing.Optional[RequestOptions]
|
|
322
|
+
Request-specific configuration.
|
|
323
|
+
|
|
324
|
+
Returns
|
|
325
|
+
-------
|
|
326
|
+
ExtractCodesResult
|
|
327
|
+
Successfully extracted codes
|
|
328
|
+
|
|
329
|
+
Examples
|
|
330
|
+
--------
|
|
331
|
+
import asyncio
|
|
332
|
+
|
|
333
|
+
from phenoml import Asyncphenoml
|
|
334
|
+
|
|
335
|
+
client = Asyncphenoml(
|
|
336
|
+
token="YOUR_TOKEN",
|
|
337
|
+
)
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
async def main() -> None:
|
|
341
|
+
await client.construe.extract_codes(
|
|
342
|
+
text="Patient is a 14-year-old female, previously healthy, who is here for evaluation of abnormal renal ultrasound with atrophic right kidney",
|
|
343
|
+
)
|
|
344
|
+
|
|
345
|
+
|
|
346
|
+
asyncio.run(main())
|
|
347
|
+
"""
|
|
348
|
+
_response = await self._raw_client.extract_codes(
|
|
349
|
+
text=text, system=system, config=config, request_options=request_options
|
|
350
|
+
)
|
|
351
|
+
return _response.data
|
|
352
|
+
|
|
353
|
+
async def cohort(
|
|
354
|
+
self,
|
|
355
|
+
*,
|
|
356
|
+
text: str,
|
|
357
|
+
config: typing.Optional[ConstrueCohortRequestConfig] = OMIT,
|
|
358
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
359
|
+
) -> ConstrueCohortResponse:
|
|
360
|
+
"""
|
|
361
|
+
Creates a patient cohort based on a natural language description.
|
|
362
|
+
Translates the description into FHIR search queries and optional SQL queries.
|
|
363
|
+
|
|
364
|
+
Parameters
|
|
365
|
+
----------
|
|
366
|
+
text : str
|
|
367
|
+
Natural language description of the desired patient cohort.
|
|
368
|
+
|
|
369
|
+
config : typing.Optional[ConstrueCohortRequestConfig]
|
|
370
|
+
|
|
371
|
+
request_options : typing.Optional[RequestOptions]
|
|
372
|
+
Request-specific configuration.
|
|
373
|
+
|
|
374
|
+
Returns
|
|
375
|
+
-------
|
|
376
|
+
ConstrueCohortResponse
|
|
377
|
+
Cohort creation successful
|
|
378
|
+
|
|
379
|
+
Examples
|
|
380
|
+
--------
|
|
381
|
+
import asyncio
|
|
382
|
+
|
|
383
|
+
from phenoml import Asyncphenoml
|
|
384
|
+
|
|
385
|
+
client = Asyncphenoml(
|
|
386
|
+
token="YOUR_TOKEN",
|
|
387
|
+
)
|
|
388
|
+
|
|
389
|
+
|
|
390
|
+
async def main() -> None:
|
|
391
|
+
await client.construe.cohort(
|
|
392
|
+
text="Between 20 and 40 years old with hyperlipidemia",
|
|
393
|
+
)
|
|
394
|
+
|
|
395
|
+
|
|
396
|
+
asyncio.run(main())
|
|
397
|
+
"""
|
|
398
|
+
_response = await self._raw_client.cohort(text=text, config=config, request_options=request_options)
|
|
399
|
+
return _response.data
|
|
@@ -0,0 +1,11 @@
|
|
|
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 .conflict_error import ConflictError
|
|
7
|
+
from .failed_dependency_error import FailedDependencyError
|
|
8
|
+
from .internal_server_error import InternalServerError
|
|
9
|
+
from .unauthorized_error import UnauthorizedError
|
|
10
|
+
|
|
11
|
+
__all__ = ["BadRequestError", "ConflictError", "FailedDependencyError", "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 ConflictError(ApiError):
|
|
9
|
+
def __init__(self, body: typing.Optional[typing.Any], headers: typing.Optional[typing.Dict[str, str]] = None):
|
|
10
|
+
super().__init__(status_code=409, 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 FailedDependencyError(ApiError):
|
|
9
|
+
def __init__(self, body: typing.Optional[typing.Any], headers: typing.Optional[typing.Dict[str, str]] = None):
|
|
10
|
+
super().__init__(status_code=424, 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)
|