phenoml 0.0.2__py3-none-any.whl → 0.0.17__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/agent/__init__.py +6 -8
- phenoml/agent/client.py +85 -67
- phenoml/agent/raw_client.py +61 -77
- phenoml/agent/types/__init__.py +6 -8
- phenoml/agent/types/agent_create_request.py +53 -0
- phenoml/agent/types/agent_create_request_provider.py +5 -0
- phenoml/agent/types/agent_template.py +3 -6
- phenoml/agent/types/agent_template_provider.py +5 -0
- phenoml/agent/types/json_patch_operation.py +5 -1
- phenoml/client.py +12 -0
- phenoml/construe/__init__.py +2 -16
- phenoml/construe/client.py +0 -90
- phenoml/construe/raw_client.py +0 -180
- phenoml/construe/types/__init__.py +2 -20
- phenoml/construe/types/extract_request_config.py +33 -4
- phenoml/construe/types/extract_request_config_chunking_method.py +3 -1
- phenoml/construe/types/extract_request_config_validation_method.py +5 -0
- phenoml/construe/types/extract_request_system.py +2 -0
- phenoml/core/client_wrapper.py +2 -2
- phenoml/fhir/__init__.py +36 -0
- phenoml/fhir/client.py +1072 -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 +1469 -0
- phenoml/fhir/types/__init__.py +29 -0
- phenoml/{agent/types/chat_fhir_client_config.py → fhir/types/error_response.py} +11 -6
- 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/{construe/types/bad_request_error_body.py → fhir/types/fhir_bundle_entry_item_response.py} +4 -7
- 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 +45 -0
- phenoml/fhir_provider/client.py +748 -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 +1462 -0
- phenoml/fhir_provider/types/__init__.py +37 -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/role.py +27 -0
- phenoml/fhir_provider/types/service_account_key.py +35 -0
- phenoml/fhir_provider/types/smart_configuration.py +46 -0
- phenoml/lang2fhir/__init__.py +10 -0
- phenoml/lang2fhir/client.py +111 -6
- phenoml/lang2fhir/raw_client.py +189 -0
- phenoml/lang2fhir/types/__init__.py +10 -0
- phenoml/lang2fhir/types/create_multi_response.py +39 -0
- phenoml/lang2fhir/types/create_multi_response_bundle.py +28 -0
- phenoml/lang2fhir/types/create_multi_response_bundle_entry_item.py +24 -0
- phenoml/lang2fhir/types/create_multi_response_bundle_entry_item_request.py +20 -0
- phenoml/{construe/types/construe_cohort_response_queries_item_code_extract_results_item_codes_item.py → lang2fhir/types/create_multi_response_resources_item.py} +13 -7
- phenoml/summary/__init__.py +41 -0
- phenoml/summary/client.py +668 -0
- phenoml/summary/errors/__init__.py +11 -0
- phenoml/summary/errors/bad_request_error.py +10 -0
- phenoml/summary/errors/forbidden_error.py +10 -0
- phenoml/summary/errors/internal_server_error.py +10 -0
- phenoml/summary/errors/not_found_error.py +10 -0
- phenoml/summary/errors/unauthorized_error.py +10 -0
- phenoml/summary/raw_client.py +1202 -0
- phenoml/summary/types/__init__.py +33 -0
- phenoml/summary/types/create_summary_request_fhir_resources.py +8 -0
- phenoml/summary/types/create_summary_request_mode.py +5 -0
- phenoml/{agent/types/agent_fhir_config.py → summary/types/create_summary_response.py} +7 -9
- phenoml/summary/types/create_summary_template_response.py +23 -0
- phenoml/{construe/types/unauthorized_error_body.py → summary/types/error_response.py} +4 -8
- phenoml/summary/types/fhir_bundle.py +23 -0
- phenoml/summary/types/fhir_bundle_entry_item.py +20 -0
- phenoml/summary/types/fhir_resource.py +24 -0
- phenoml/summary/types/summary_delete_template_response.py +20 -0
- phenoml/summary/types/summary_get_template_response.py +21 -0
- phenoml/summary/types/summary_list_templates_response.py +21 -0
- phenoml/summary/types/summary_template.py +41 -0
- phenoml/summary/types/summary_update_template_response.py +22 -0
- phenoml/tools/__init__.py +6 -8
- phenoml/tools/client.py +259 -44
- phenoml/tools/raw_client.py +347 -55
- phenoml/tools/types/__init__.py +6 -8
- phenoml/tools/types/lang2fhir_and_create_multi_response.py +41 -0
- phenoml/{construe/types/construe_cohort_response_queries_item_code_extract_results_item.py → tools/types/lang2fhir_and_create_multi_response_resource_info_item.py} +14 -7
- phenoml/tools/types/lang2fhir_and_create_multi_response_response_bundle.py +27 -0
- phenoml/workflows/__init__.py +61 -0
- phenoml/workflows/client.py +694 -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/raw_client.py +1266 -0
- phenoml/workflows/types/__init__.py +53 -0
- phenoml/workflows/types/create_workflow_request_fhir_provider_id.py +5 -0
- phenoml/workflows/types/create_workflow_response.py +44 -0
- phenoml/{tools/types/fhir_client_config.py → workflows/types/decision_node_definition.py} +7 -6
- phenoml/workflows/types/execute_workflow_response.py +30 -0
- phenoml/{construe/types/internal_server_error_body.py → workflows/types/execute_workflow_response_results.py} +3 -8
- 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/update_workflow_request_fhir_provider_id.py +5 -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/types/workflows_delete_response.py +20 -0
- phenoml/workflows/types/workflows_get_response.py +26 -0
- phenoml/workflows/types/workflows_update_response.py +31 -0
- phenoml-0.0.17.dist-info/LICENSE +21 -0
- {phenoml-0.0.2.dist-info → phenoml-0.0.17.dist-info}/METADATA +1 -1
- phenoml-0.0.17.dist-info/RECORD +251 -0
- phenoml/agent/types/agent_provider.py +0 -7
- phenoml/agent/types/provider_type.py +0 -5
- phenoml/construe/types/construe_cohort_request_config.py +0 -37
- phenoml/construe/types/construe_cohort_response.py +0 -33
- phenoml/construe/types/construe_cohort_response_queries_item.py +0 -49
- phenoml/tools/types/cohort_request_provider.py +0 -5
- phenoml/tools/types/lang2fhir_and_create_request_provider.py +0 -7
- phenoml/tools/types/lang2fhir_and_search_request_provider.py +0 -7
- phenoml-0.0.2.dist-info/RECORD +0 -153
- {phenoml-0.0.2.dist-info → phenoml-0.0.17.dist-info}/WHEEL +0 -0
phenoml/tools/client.py
CHANGED
|
@@ -6,13 +6,10 @@ from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
|
|
6
6
|
from ..core.request_options import RequestOptions
|
|
7
7
|
from .mcp_server.client import AsyncMcpServerClient, McpServerClient
|
|
8
8
|
from .raw_client import AsyncRawToolsClient, RawToolsClient
|
|
9
|
-
from .types.cohort_request_provider import CohortRequestProvider
|
|
10
9
|
from .types.cohort_response import CohortResponse
|
|
11
|
-
from .types.
|
|
12
|
-
from .types.lang2fhir_and_create_request_provider import Lang2FhirAndCreateRequestProvider
|
|
10
|
+
from .types.lang2fhir_and_create_multi_response import Lang2FhirAndCreateMultiResponse
|
|
13
11
|
from .types.lang2fhir_and_create_request_resource import Lang2FhirAndCreateRequestResource
|
|
14
12
|
from .types.lang2fhir_and_create_response import Lang2FhirAndCreateResponse
|
|
15
|
-
from .types.lang2fhir_and_search_request_provider import Lang2FhirAndSearchRequestProvider
|
|
16
13
|
from .types.lang2fhir_and_search_response import Lang2FhirAndSearchResponse
|
|
17
14
|
|
|
18
15
|
# this is used as the default value for optional parameters
|
|
@@ -40,8 +37,9 @@ class ToolsClient:
|
|
|
40
37
|
*,
|
|
41
38
|
resource: Lang2FhirAndCreateRequestResource,
|
|
42
39
|
text: str,
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
phenoml_on_behalf_of: typing.Optional[str] = None,
|
|
41
|
+
phenoml_fhir_provider: typing.Optional[str] = None,
|
|
42
|
+
provider: typing.Optional[str] = OMIT,
|
|
45
43
|
request_options: typing.Optional[RequestOptions] = None,
|
|
46
44
|
) -> Lang2FhirAndCreateResponse:
|
|
47
45
|
"""
|
|
@@ -55,10 +53,16 @@ class ToolsClient:
|
|
|
55
53
|
text : str
|
|
56
54
|
Natural language text to convert to FHIR resource
|
|
57
55
|
|
|
58
|
-
|
|
59
|
-
|
|
56
|
+
phenoml_on_behalf_of : typing.Optional[str]
|
|
57
|
+
Optional header for on-behalf-of authentication. Used when making requests on behalf of another user or entity.
|
|
58
|
+
Must be in the format: Patient/{uuid} or Practitioner/{uuid}
|
|
60
59
|
|
|
61
|
-
|
|
60
|
+
phenoml_fhir_provider : typing.Optional[str]
|
|
61
|
+
Optional header for FHIR provider authentication. Contains credentials in the format {fhir_provider_id}:{oauth2_token}.
|
|
62
|
+
Multiple FHIR provider integrations can be provided as comma-separated values.
|
|
63
|
+
|
|
64
|
+
provider : typing.Optional[str]
|
|
65
|
+
FHIR provider ID - must be a valid UUID from existing FHIR providers. also supports provider by name (e.g. medplum)
|
|
62
66
|
|
|
63
67
|
request_options : typing.Optional[RequestOptions]
|
|
64
68
|
Request-specific configuration.
|
|
@@ -76,12 +80,87 @@ class ToolsClient:
|
|
|
76
80
|
token="YOUR_TOKEN",
|
|
77
81
|
)
|
|
78
82
|
client.tools.create_fhir_resource(
|
|
83
|
+
phenoml_on_behalf_of="Patient/550e8400-e29b-41d4-a716-446655440000",
|
|
84
|
+
phenoml_fhir_provider="550e8400-e29b-41d4-a716-446655440000:eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c...",
|
|
79
85
|
resource="auto",
|
|
80
86
|
text="Patient John Doe has severe asthma with acute exacerbation",
|
|
81
87
|
)
|
|
82
88
|
"""
|
|
83
89
|
_response = self._raw_client.create_fhir_resource(
|
|
84
|
-
resource=resource,
|
|
90
|
+
resource=resource,
|
|
91
|
+
text=text,
|
|
92
|
+
phenoml_on_behalf_of=phenoml_on_behalf_of,
|
|
93
|
+
phenoml_fhir_provider=phenoml_fhir_provider,
|
|
94
|
+
provider=provider,
|
|
95
|
+
request_options=request_options,
|
|
96
|
+
)
|
|
97
|
+
return _response.data
|
|
98
|
+
|
|
99
|
+
def create_fhir_resources_multi(
|
|
100
|
+
self,
|
|
101
|
+
*,
|
|
102
|
+
text: str,
|
|
103
|
+
provider: str,
|
|
104
|
+
phenoml_on_behalf_of: typing.Optional[str] = None,
|
|
105
|
+
phenoml_fhir_provider: typing.Optional[str] = None,
|
|
106
|
+
version: typing.Optional[str] = OMIT,
|
|
107
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
108
|
+
) -> Lang2FhirAndCreateMultiResponse:
|
|
109
|
+
"""
|
|
110
|
+
Extracts multiple FHIR resources from natural language text and stores them in a FHIR server.
|
|
111
|
+
Automatically detects Patient, Condition, MedicationRequest, Observation, and other resource types.
|
|
112
|
+
Resources are linked with proper references and submitted as a transaction bundle.
|
|
113
|
+
For FHIR servers that don't auto-resolve urn:uuid references, this endpoint will automatically
|
|
114
|
+
resolve them via PUT requests after the initial bundle creation.
|
|
115
|
+
|
|
116
|
+
Parameters
|
|
117
|
+
----------
|
|
118
|
+
text : str
|
|
119
|
+
Natural language text containing multiple clinical concepts to extract
|
|
120
|
+
|
|
121
|
+
provider : str
|
|
122
|
+
FHIR provider ID or name
|
|
123
|
+
|
|
124
|
+
phenoml_on_behalf_of : typing.Optional[str]
|
|
125
|
+
Optional header for on-behalf-of authentication. Used when making requests on behalf of another user or entity.
|
|
126
|
+
Must be in the format: Patient/{uuid} or Practitioner/{uuid}
|
|
127
|
+
|
|
128
|
+
phenoml_fhir_provider : typing.Optional[str]
|
|
129
|
+
Optional header for FHIR provider authentication. Contains credentials in the format {fhir_provider_id}:{oauth2_token}.
|
|
130
|
+
Multiple FHIR provider integrations can be provided as comma-separated values.
|
|
131
|
+
|
|
132
|
+
version : typing.Optional[str]
|
|
133
|
+
FHIR version to use
|
|
134
|
+
|
|
135
|
+
request_options : typing.Optional[RequestOptions]
|
|
136
|
+
Request-specific configuration.
|
|
137
|
+
|
|
138
|
+
Returns
|
|
139
|
+
-------
|
|
140
|
+
Lang2FhirAndCreateMultiResponse
|
|
141
|
+
Successfully created FHIR resources
|
|
142
|
+
|
|
143
|
+
Examples
|
|
144
|
+
--------
|
|
145
|
+
from phenoml import phenoml
|
|
146
|
+
|
|
147
|
+
client = phenoml(
|
|
148
|
+
token="YOUR_TOKEN",
|
|
149
|
+
)
|
|
150
|
+
client.tools.create_fhir_resources_multi(
|
|
151
|
+
phenoml_on_behalf_of="Patient/550e8400-e29b-41d4-a716-446655440000",
|
|
152
|
+
phenoml_fhir_provider="550e8400-e29b-41d4-a716-446655440000:eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c...",
|
|
153
|
+
text="John Smith, 45-year-old male, diagnosed with Type 2 Diabetes. Prescribed Metformin 500mg twice daily.",
|
|
154
|
+
provider="medplum",
|
|
155
|
+
)
|
|
156
|
+
"""
|
|
157
|
+
_response = self._raw_client.create_fhir_resources_multi(
|
|
158
|
+
text=text,
|
|
159
|
+
provider=provider,
|
|
160
|
+
phenoml_on_behalf_of=phenoml_on_behalf_of,
|
|
161
|
+
phenoml_fhir_provider=phenoml_fhir_provider,
|
|
162
|
+
version=version,
|
|
163
|
+
request_options=request_options,
|
|
85
164
|
)
|
|
86
165
|
return _response.data
|
|
87
166
|
|
|
@@ -89,11 +168,12 @@ class ToolsClient:
|
|
|
89
168
|
self,
|
|
90
169
|
*,
|
|
91
170
|
text: str,
|
|
171
|
+
phenoml_on_behalf_of: typing.Optional[str] = None,
|
|
172
|
+
phenoml_fhir_provider: typing.Optional[str] = None,
|
|
92
173
|
patient_id: typing.Optional[str] = OMIT,
|
|
93
174
|
practitioner_id: typing.Optional[str] = OMIT,
|
|
94
175
|
count: typing.Optional[int] = OMIT,
|
|
95
|
-
provider: typing.Optional[
|
|
96
|
-
meta: typing.Optional[FhirClientConfig] = OMIT,
|
|
176
|
+
provider: typing.Optional[str] = OMIT,
|
|
97
177
|
request_options: typing.Optional[RequestOptions] = None,
|
|
98
178
|
) -> Lang2FhirAndSearchResponse:
|
|
99
179
|
"""
|
|
@@ -104,6 +184,14 @@ class ToolsClient:
|
|
|
104
184
|
text : str
|
|
105
185
|
Natural language text to convert to FHIR search parameters
|
|
106
186
|
|
|
187
|
+
phenoml_on_behalf_of : typing.Optional[str]
|
|
188
|
+
Optional header for on-behalf-of authentication. Used when making requests on behalf of another user or entity.
|
|
189
|
+
Must be in the format: Patient/{uuid} or Practitioner/{uuid}
|
|
190
|
+
|
|
191
|
+
phenoml_fhir_provider : typing.Optional[str]
|
|
192
|
+
Optional header for FHIR provider authentication. Contains credentials in the format {fhir_provider_id}:{oauth2_token}.
|
|
193
|
+
Multiple FHIR provider integrations can be provided as comma-separated values.
|
|
194
|
+
|
|
107
195
|
patient_id : typing.Optional[str]
|
|
108
196
|
Patient ID to filter results
|
|
109
197
|
|
|
@@ -113,10 +201,8 @@ class ToolsClient:
|
|
|
113
201
|
count : typing.Optional[int]
|
|
114
202
|
Maximum number of results to return
|
|
115
203
|
|
|
116
|
-
provider : typing.Optional[
|
|
117
|
-
FHIR provider
|
|
118
|
-
|
|
119
|
-
meta : typing.Optional[FhirClientConfig]
|
|
204
|
+
provider : typing.Optional[str]
|
|
205
|
+
FHIR provider ID - must be a valid UUID from existing FHIR providers. also supports provider by name (e.g. medplum)
|
|
120
206
|
|
|
121
207
|
request_options : typing.Optional[RequestOptions]
|
|
122
208
|
Request-specific configuration.
|
|
@@ -134,16 +220,19 @@ class ToolsClient:
|
|
|
134
220
|
token="YOUR_TOKEN",
|
|
135
221
|
)
|
|
136
222
|
client.tools.search_fhir_resources(
|
|
223
|
+
phenoml_on_behalf_of="Patient/550e8400-e29b-41d4-a716-446655440000",
|
|
224
|
+
phenoml_fhir_provider="550e8400-e29b-41d4-a716-446655440000:eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c...",
|
|
137
225
|
text="Find all appointments for patient John Doe next week",
|
|
138
226
|
)
|
|
139
227
|
"""
|
|
140
228
|
_response = self._raw_client.search_fhir_resources(
|
|
141
229
|
text=text,
|
|
230
|
+
phenoml_on_behalf_of=phenoml_on_behalf_of,
|
|
231
|
+
phenoml_fhir_provider=phenoml_fhir_provider,
|
|
142
232
|
patient_id=patient_id,
|
|
143
233
|
practitioner_id=practitioner_id,
|
|
144
234
|
count=count,
|
|
145
235
|
provider=provider,
|
|
146
|
-
meta=meta,
|
|
147
236
|
request_options=request_options,
|
|
148
237
|
)
|
|
149
238
|
return _response.data
|
|
@@ -152,8 +241,9 @@ class ToolsClient:
|
|
|
152
241
|
self,
|
|
153
242
|
*,
|
|
154
243
|
text: str,
|
|
155
|
-
provider:
|
|
156
|
-
|
|
244
|
+
provider: str,
|
|
245
|
+
phenoml_on_behalf_of: typing.Optional[str] = None,
|
|
246
|
+
phenoml_fhir_provider: typing.Optional[str] = None,
|
|
157
247
|
request_options: typing.Optional[RequestOptions] = None,
|
|
158
248
|
) -> CohortResponse:
|
|
159
249
|
"""
|
|
@@ -164,10 +254,16 @@ class ToolsClient:
|
|
|
164
254
|
text : str
|
|
165
255
|
Natural language text describing the patient cohort criteria
|
|
166
256
|
|
|
167
|
-
provider :
|
|
168
|
-
FHIR provider
|
|
257
|
+
provider : str
|
|
258
|
+
FHIR provider ID - must be a valid UUID from existing FHIR providers. also supports provider by name (e.g. medplum)
|
|
169
259
|
|
|
170
|
-
|
|
260
|
+
phenoml_on_behalf_of : typing.Optional[str]
|
|
261
|
+
Optional header for on-behalf-of authentication. Used when making requests on behalf of another user or entity.
|
|
262
|
+
Must be in the format: Patient/{uuid} or Practitioner/{uuid}
|
|
263
|
+
|
|
264
|
+
phenoml_fhir_provider : typing.Optional[str]
|
|
265
|
+
Optional header for FHIR provider authentication. Contains credentials in the format {fhir_provider_id}:{oauth2_token}.
|
|
266
|
+
Multiple FHIR provider integrations can be provided as comma-separated values.
|
|
171
267
|
|
|
172
268
|
request_options : typing.Optional[RequestOptions]
|
|
173
269
|
Request-specific configuration.
|
|
@@ -185,12 +281,18 @@ class ToolsClient:
|
|
|
185
281
|
token="YOUR_TOKEN",
|
|
186
282
|
)
|
|
187
283
|
client.tools.analyze_cohort(
|
|
284
|
+
phenoml_on_behalf_of="Patient/550e8400-e29b-41d4-a716-446655440000",
|
|
285
|
+
phenoml_fhir_provider="550e8400-e29b-41d4-a716-446655440000:eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c...",
|
|
188
286
|
text="female patients over 20 with diabetes but not hypertension",
|
|
189
|
-
provider="
|
|
287
|
+
provider="550e8400-e29b-41d4-a716-446655440000",
|
|
190
288
|
)
|
|
191
289
|
"""
|
|
192
290
|
_response = self._raw_client.analyze_cohort(
|
|
193
|
-
text=text,
|
|
291
|
+
text=text,
|
|
292
|
+
provider=provider,
|
|
293
|
+
phenoml_on_behalf_of=phenoml_on_behalf_of,
|
|
294
|
+
phenoml_fhir_provider=phenoml_fhir_provider,
|
|
295
|
+
request_options=request_options,
|
|
194
296
|
)
|
|
195
297
|
return _response.data
|
|
196
298
|
|
|
@@ -216,8 +318,9 @@ class AsyncToolsClient:
|
|
|
216
318
|
*,
|
|
217
319
|
resource: Lang2FhirAndCreateRequestResource,
|
|
218
320
|
text: str,
|
|
219
|
-
|
|
220
|
-
|
|
321
|
+
phenoml_on_behalf_of: typing.Optional[str] = None,
|
|
322
|
+
phenoml_fhir_provider: typing.Optional[str] = None,
|
|
323
|
+
provider: typing.Optional[str] = OMIT,
|
|
221
324
|
request_options: typing.Optional[RequestOptions] = None,
|
|
222
325
|
) -> Lang2FhirAndCreateResponse:
|
|
223
326
|
"""
|
|
@@ -231,10 +334,16 @@ class AsyncToolsClient:
|
|
|
231
334
|
text : str
|
|
232
335
|
Natural language text to convert to FHIR resource
|
|
233
336
|
|
|
234
|
-
|
|
235
|
-
|
|
337
|
+
phenoml_on_behalf_of : typing.Optional[str]
|
|
338
|
+
Optional header for on-behalf-of authentication. Used when making requests on behalf of another user or entity.
|
|
339
|
+
Must be in the format: Patient/{uuid} or Practitioner/{uuid}
|
|
340
|
+
|
|
341
|
+
phenoml_fhir_provider : typing.Optional[str]
|
|
342
|
+
Optional header for FHIR provider authentication. Contains credentials in the format {fhir_provider_id}:{oauth2_token}.
|
|
343
|
+
Multiple FHIR provider integrations can be provided as comma-separated values.
|
|
236
344
|
|
|
237
|
-
|
|
345
|
+
provider : typing.Optional[str]
|
|
346
|
+
FHIR provider ID - must be a valid UUID from existing FHIR providers. also supports provider by name (e.g. medplum)
|
|
238
347
|
|
|
239
348
|
request_options : typing.Optional[RequestOptions]
|
|
240
349
|
Request-specific configuration.
|
|
@@ -257,6 +366,8 @@ class AsyncToolsClient:
|
|
|
257
366
|
|
|
258
367
|
async def main() -> None:
|
|
259
368
|
await client.tools.create_fhir_resource(
|
|
369
|
+
phenoml_on_behalf_of="Patient/550e8400-e29b-41d4-a716-446655440000",
|
|
370
|
+
phenoml_fhir_provider="550e8400-e29b-41d4-a716-446655440000:eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c...",
|
|
260
371
|
resource="auto",
|
|
261
372
|
text="Patient John Doe has severe asthma with acute exacerbation",
|
|
262
373
|
)
|
|
@@ -265,7 +376,88 @@ class AsyncToolsClient:
|
|
|
265
376
|
asyncio.run(main())
|
|
266
377
|
"""
|
|
267
378
|
_response = await self._raw_client.create_fhir_resource(
|
|
268
|
-
resource=resource,
|
|
379
|
+
resource=resource,
|
|
380
|
+
text=text,
|
|
381
|
+
phenoml_on_behalf_of=phenoml_on_behalf_of,
|
|
382
|
+
phenoml_fhir_provider=phenoml_fhir_provider,
|
|
383
|
+
provider=provider,
|
|
384
|
+
request_options=request_options,
|
|
385
|
+
)
|
|
386
|
+
return _response.data
|
|
387
|
+
|
|
388
|
+
async def create_fhir_resources_multi(
|
|
389
|
+
self,
|
|
390
|
+
*,
|
|
391
|
+
text: str,
|
|
392
|
+
provider: str,
|
|
393
|
+
phenoml_on_behalf_of: typing.Optional[str] = None,
|
|
394
|
+
phenoml_fhir_provider: typing.Optional[str] = None,
|
|
395
|
+
version: typing.Optional[str] = OMIT,
|
|
396
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
397
|
+
) -> Lang2FhirAndCreateMultiResponse:
|
|
398
|
+
"""
|
|
399
|
+
Extracts multiple FHIR resources from natural language text and stores them in a FHIR server.
|
|
400
|
+
Automatically detects Patient, Condition, MedicationRequest, Observation, and other resource types.
|
|
401
|
+
Resources are linked with proper references and submitted as a transaction bundle.
|
|
402
|
+
For FHIR servers that don't auto-resolve urn:uuid references, this endpoint will automatically
|
|
403
|
+
resolve them via PUT requests after the initial bundle creation.
|
|
404
|
+
|
|
405
|
+
Parameters
|
|
406
|
+
----------
|
|
407
|
+
text : str
|
|
408
|
+
Natural language text containing multiple clinical concepts to extract
|
|
409
|
+
|
|
410
|
+
provider : str
|
|
411
|
+
FHIR provider ID or name
|
|
412
|
+
|
|
413
|
+
phenoml_on_behalf_of : typing.Optional[str]
|
|
414
|
+
Optional header for on-behalf-of authentication. Used when making requests on behalf of another user or entity.
|
|
415
|
+
Must be in the format: Patient/{uuid} or Practitioner/{uuid}
|
|
416
|
+
|
|
417
|
+
phenoml_fhir_provider : typing.Optional[str]
|
|
418
|
+
Optional header for FHIR provider authentication. Contains credentials in the format {fhir_provider_id}:{oauth2_token}.
|
|
419
|
+
Multiple FHIR provider integrations can be provided as comma-separated values.
|
|
420
|
+
|
|
421
|
+
version : typing.Optional[str]
|
|
422
|
+
FHIR version to use
|
|
423
|
+
|
|
424
|
+
request_options : typing.Optional[RequestOptions]
|
|
425
|
+
Request-specific configuration.
|
|
426
|
+
|
|
427
|
+
Returns
|
|
428
|
+
-------
|
|
429
|
+
Lang2FhirAndCreateMultiResponse
|
|
430
|
+
Successfully created FHIR resources
|
|
431
|
+
|
|
432
|
+
Examples
|
|
433
|
+
--------
|
|
434
|
+
import asyncio
|
|
435
|
+
|
|
436
|
+
from phenoml import Asyncphenoml
|
|
437
|
+
|
|
438
|
+
client = Asyncphenoml(
|
|
439
|
+
token="YOUR_TOKEN",
|
|
440
|
+
)
|
|
441
|
+
|
|
442
|
+
|
|
443
|
+
async def main() -> None:
|
|
444
|
+
await client.tools.create_fhir_resources_multi(
|
|
445
|
+
phenoml_on_behalf_of="Patient/550e8400-e29b-41d4-a716-446655440000",
|
|
446
|
+
phenoml_fhir_provider="550e8400-e29b-41d4-a716-446655440000:eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c...",
|
|
447
|
+
text="John Smith, 45-year-old male, diagnosed with Type 2 Diabetes. Prescribed Metformin 500mg twice daily.",
|
|
448
|
+
provider="medplum",
|
|
449
|
+
)
|
|
450
|
+
|
|
451
|
+
|
|
452
|
+
asyncio.run(main())
|
|
453
|
+
"""
|
|
454
|
+
_response = await self._raw_client.create_fhir_resources_multi(
|
|
455
|
+
text=text,
|
|
456
|
+
provider=provider,
|
|
457
|
+
phenoml_on_behalf_of=phenoml_on_behalf_of,
|
|
458
|
+
phenoml_fhir_provider=phenoml_fhir_provider,
|
|
459
|
+
version=version,
|
|
460
|
+
request_options=request_options,
|
|
269
461
|
)
|
|
270
462
|
return _response.data
|
|
271
463
|
|
|
@@ -273,11 +465,12 @@ class AsyncToolsClient:
|
|
|
273
465
|
self,
|
|
274
466
|
*,
|
|
275
467
|
text: str,
|
|
468
|
+
phenoml_on_behalf_of: typing.Optional[str] = None,
|
|
469
|
+
phenoml_fhir_provider: typing.Optional[str] = None,
|
|
276
470
|
patient_id: typing.Optional[str] = OMIT,
|
|
277
471
|
practitioner_id: typing.Optional[str] = OMIT,
|
|
278
472
|
count: typing.Optional[int] = OMIT,
|
|
279
|
-
provider: typing.Optional[
|
|
280
|
-
meta: typing.Optional[FhirClientConfig] = OMIT,
|
|
473
|
+
provider: typing.Optional[str] = OMIT,
|
|
281
474
|
request_options: typing.Optional[RequestOptions] = None,
|
|
282
475
|
) -> Lang2FhirAndSearchResponse:
|
|
283
476
|
"""
|
|
@@ -288,6 +481,14 @@ class AsyncToolsClient:
|
|
|
288
481
|
text : str
|
|
289
482
|
Natural language text to convert to FHIR search parameters
|
|
290
483
|
|
|
484
|
+
phenoml_on_behalf_of : typing.Optional[str]
|
|
485
|
+
Optional header for on-behalf-of authentication. Used when making requests on behalf of another user or entity.
|
|
486
|
+
Must be in the format: Patient/{uuid} or Practitioner/{uuid}
|
|
487
|
+
|
|
488
|
+
phenoml_fhir_provider : typing.Optional[str]
|
|
489
|
+
Optional header for FHIR provider authentication. Contains credentials in the format {fhir_provider_id}:{oauth2_token}.
|
|
490
|
+
Multiple FHIR provider integrations can be provided as comma-separated values.
|
|
491
|
+
|
|
291
492
|
patient_id : typing.Optional[str]
|
|
292
493
|
Patient ID to filter results
|
|
293
494
|
|
|
@@ -297,10 +498,8 @@ class AsyncToolsClient:
|
|
|
297
498
|
count : typing.Optional[int]
|
|
298
499
|
Maximum number of results to return
|
|
299
500
|
|
|
300
|
-
provider : typing.Optional[
|
|
301
|
-
FHIR provider
|
|
302
|
-
|
|
303
|
-
meta : typing.Optional[FhirClientConfig]
|
|
501
|
+
provider : typing.Optional[str]
|
|
502
|
+
FHIR provider ID - must be a valid UUID from existing FHIR providers. also supports provider by name (e.g. medplum)
|
|
304
503
|
|
|
305
504
|
request_options : typing.Optional[RequestOptions]
|
|
306
505
|
Request-specific configuration.
|
|
@@ -323,6 +522,8 @@ class AsyncToolsClient:
|
|
|
323
522
|
|
|
324
523
|
async def main() -> None:
|
|
325
524
|
await client.tools.search_fhir_resources(
|
|
525
|
+
phenoml_on_behalf_of="Patient/550e8400-e29b-41d4-a716-446655440000",
|
|
526
|
+
phenoml_fhir_provider="550e8400-e29b-41d4-a716-446655440000:eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c...",
|
|
326
527
|
text="Find all appointments for patient John Doe next week",
|
|
327
528
|
)
|
|
328
529
|
|
|
@@ -331,11 +532,12 @@ class AsyncToolsClient:
|
|
|
331
532
|
"""
|
|
332
533
|
_response = await self._raw_client.search_fhir_resources(
|
|
333
534
|
text=text,
|
|
535
|
+
phenoml_on_behalf_of=phenoml_on_behalf_of,
|
|
536
|
+
phenoml_fhir_provider=phenoml_fhir_provider,
|
|
334
537
|
patient_id=patient_id,
|
|
335
538
|
practitioner_id=practitioner_id,
|
|
336
539
|
count=count,
|
|
337
540
|
provider=provider,
|
|
338
|
-
meta=meta,
|
|
339
541
|
request_options=request_options,
|
|
340
542
|
)
|
|
341
543
|
return _response.data
|
|
@@ -344,8 +546,9 @@ class AsyncToolsClient:
|
|
|
344
546
|
self,
|
|
345
547
|
*,
|
|
346
548
|
text: str,
|
|
347
|
-
provider:
|
|
348
|
-
|
|
549
|
+
provider: str,
|
|
550
|
+
phenoml_on_behalf_of: typing.Optional[str] = None,
|
|
551
|
+
phenoml_fhir_provider: typing.Optional[str] = None,
|
|
349
552
|
request_options: typing.Optional[RequestOptions] = None,
|
|
350
553
|
) -> CohortResponse:
|
|
351
554
|
"""
|
|
@@ -356,10 +559,16 @@ class AsyncToolsClient:
|
|
|
356
559
|
text : str
|
|
357
560
|
Natural language text describing the patient cohort criteria
|
|
358
561
|
|
|
359
|
-
provider :
|
|
360
|
-
FHIR provider
|
|
562
|
+
provider : str
|
|
563
|
+
FHIR provider ID - must be a valid UUID from existing FHIR providers. also supports provider by name (e.g. medplum)
|
|
564
|
+
|
|
565
|
+
phenoml_on_behalf_of : typing.Optional[str]
|
|
566
|
+
Optional header for on-behalf-of authentication. Used when making requests on behalf of another user or entity.
|
|
567
|
+
Must be in the format: Patient/{uuid} or Practitioner/{uuid}
|
|
361
568
|
|
|
362
|
-
|
|
569
|
+
phenoml_fhir_provider : typing.Optional[str]
|
|
570
|
+
Optional header for FHIR provider authentication. Contains credentials in the format {fhir_provider_id}:{oauth2_token}.
|
|
571
|
+
Multiple FHIR provider integrations can be provided as comma-separated values.
|
|
363
572
|
|
|
364
573
|
request_options : typing.Optional[RequestOptions]
|
|
365
574
|
Request-specific configuration.
|
|
@@ -382,14 +591,20 @@ class AsyncToolsClient:
|
|
|
382
591
|
|
|
383
592
|
async def main() -> None:
|
|
384
593
|
await client.tools.analyze_cohort(
|
|
594
|
+
phenoml_on_behalf_of="Patient/550e8400-e29b-41d4-a716-446655440000",
|
|
595
|
+
phenoml_fhir_provider="550e8400-e29b-41d4-a716-446655440000:eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c...",
|
|
385
596
|
text="female patients over 20 with diabetes but not hypertension",
|
|
386
|
-
provider="
|
|
597
|
+
provider="550e8400-e29b-41d4-a716-446655440000",
|
|
387
598
|
)
|
|
388
599
|
|
|
389
600
|
|
|
390
601
|
asyncio.run(main())
|
|
391
602
|
"""
|
|
392
603
|
_response = await self._raw_client.analyze_cohort(
|
|
393
|
-
text=text,
|
|
604
|
+
text=text,
|
|
605
|
+
provider=provider,
|
|
606
|
+
phenoml_on_behalf_of=phenoml_on_behalf_of,
|
|
607
|
+
phenoml_fhir_provider=phenoml_fhir_provider,
|
|
608
|
+
request_options=request_options,
|
|
394
609
|
)
|
|
395
610
|
return _response.data
|