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
|
@@ -0,0 +1,668 @@
|
|
|
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 AsyncRawSummaryClient, RawSummaryClient
|
|
8
|
+
from .types.create_summary_request_fhir_resources import CreateSummaryRequestFhirResources
|
|
9
|
+
from .types.create_summary_request_mode import CreateSummaryRequestMode
|
|
10
|
+
from .types.create_summary_response import CreateSummaryResponse
|
|
11
|
+
from .types.create_summary_template_response import CreateSummaryTemplateResponse
|
|
12
|
+
from .types.summary_delete_template_response import SummaryDeleteTemplateResponse
|
|
13
|
+
from .types.summary_get_template_response import SummaryGetTemplateResponse
|
|
14
|
+
from .types.summary_list_templates_response import SummaryListTemplatesResponse
|
|
15
|
+
from .types.summary_update_template_response import SummaryUpdateTemplateResponse
|
|
16
|
+
|
|
17
|
+
# this is used as the default value for optional parameters
|
|
18
|
+
OMIT = typing.cast(typing.Any, ...)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class SummaryClient:
|
|
22
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
23
|
+
self._raw_client = RawSummaryClient(client_wrapper=client_wrapper)
|
|
24
|
+
|
|
25
|
+
@property
|
|
26
|
+
def with_raw_response(self) -> RawSummaryClient:
|
|
27
|
+
"""
|
|
28
|
+
Retrieves a raw implementation of this client that returns raw responses.
|
|
29
|
+
|
|
30
|
+
Returns
|
|
31
|
+
-------
|
|
32
|
+
RawSummaryClient
|
|
33
|
+
"""
|
|
34
|
+
return self._raw_client
|
|
35
|
+
|
|
36
|
+
def list_templates(
|
|
37
|
+
self, *, request_options: typing.Optional[RequestOptions] = None
|
|
38
|
+
) -> SummaryListTemplatesResponse:
|
|
39
|
+
"""
|
|
40
|
+
Retrieves all summary templates for the authenticated user
|
|
41
|
+
|
|
42
|
+
Parameters
|
|
43
|
+
----------
|
|
44
|
+
request_options : typing.Optional[RequestOptions]
|
|
45
|
+
Request-specific configuration.
|
|
46
|
+
|
|
47
|
+
Returns
|
|
48
|
+
-------
|
|
49
|
+
SummaryListTemplatesResponse
|
|
50
|
+
Templates retrieved successfully
|
|
51
|
+
|
|
52
|
+
Examples
|
|
53
|
+
--------
|
|
54
|
+
from phenoml import phenoml
|
|
55
|
+
|
|
56
|
+
client = phenoml(
|
|
57
|
+
token="YOUR_TOKEN",
|
|
58
|
+
)
|
|
59
|
+
client.summary.list_templates()
|
|
60
|
+
"""
|
|
61
|
+
_response = self._raw_client.list_templates(request_options=request_options)
|
|
62
|
+
return _response.data
|
|
63
|
+
|
|
64
|
+
def create_template(
|
|
65
|
+
self,
|
|
66
|
+
*,
|
|
67
|
+
name: str,
|
|
68
|
+
example_summary: str,
|
|
69
|
+
target_resources: typing.Sequence[str],
|
|
70
|
+
mode: str,
|
|
71
|
+
description: typing.Optional[str] = OMIT,
|
|
72
|
+
example_fhir_data: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
|
|
73
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
74
|
+
) -> CreateSummaryTemplateResponse:
|
|
75
|
+
"""
|
|
76
|
+
Creates a summary template from an example using LLM function calling
|
|
77
|
+
|
|
78
|
+
Parameters
|
|
79
|
+
----------
|
|
80
|
+
name : str
|
|
81
|
+
Name of the template
|
|
82
|
+
|
|
83
|
+
example_summary : str
|
|
84
|
+
Example summary note to generate template from
|
|
85
|
+
|
|
86
|
+
target_resources : typing.Sequence[str]
|
|
87
|
+
List of target FHIR resources
|
|
88
|
+
|
|
89
|
+
mode : str
|
|
90
|
+
Template mode (stored with the template)
|
|
91
|
+
|
|
92
|
+
description : typing.Optional[str]
|
|
93
|
+
Description of the template
|
|
94
|
+
|
|
95
|
+
example_fhir_data : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
|
|
96
|
+
Optional example FHIR data that corresponds to the example summary
|
|
97
|
+
|
|
98
|
+
request_options : typing.Optional[RequestOptions]
|
|
99
|
+
Request-specific configuration.
|
|
100
|
+
|
|
101
|
+
Returns
|
|
102
|
+
-------
|
|
103
|
+
CreateSummaryTemplateResponse
|
|
104
|
+
Template created successfully
|
|
105
|
+
|
|
106
|
+
Examples
|
|
107
|
+
--------
|
|
108
|
+
from phenoml import phenoml
|
|
109
|
+
|
|
110
|
+
client = phenoml(
|
|
111
|
+
token="YOUR_TOKEN",
|
|
112
|
+
)
|
|
113
|
+
client.summary.create_template(
|
|
114
|
+
name="name",
|
|
115
|
+
example_summary="Patient John Doe, age 45, presents with hypertension diagnosed on 2024-01-15.",
|
|
116
|
+
target_resources=["Patient", "Condition", "Observation"],
|
|
117
|
+
mode="mode",
|
|
118
|
+
)
|
|
119
|
+
"""
|
|
120
|
+
_response = self._raw_client.create_template(
|
|
121
|
+
name=name,
|
|
122
|
+
example_summary=example_summary,
|
|
123
|
+
target_resources=target_resources,
|
|
124
|
+
mode=mode,
|
|
125
|
+
description=description,
|
|
126
|
+
example_fhir_data=example_fhir_data,
|
|
127
|
+
request_options=request_options,
|
|
128
|
+
)
|
|
129
|
+
return _response.data
|
|
130
|
+
|
|
131
|
+
def get_template(
|
|
132
|
+
self, id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
133
|
+
) -> SummaryGetTemplateResponse:
|
|
134
|
+
"""
|
|
135
|
+
Retrieves a specific summary template
|
|
136
|
+
|
|
137
|
+
Parameters
|
|
138
|
+
----------
|
|
139
|
+
id : str
|
|
140
|
+
Template ID
|
|
141
|
+
|
|
142
|
+
request_options : typing.Optional[RequestOptions]
|
|
143
|
+
Request-specific configuration.
|
|
144
|
+
|
|
145
|
+
Returns
|
|
146
|
+
-------
|
|
147
|
+
SummaryGetTemplateResponse
|
|
148
|
+
Template retrieved successfully
|
|
149
|
+
|
|
150
|
+
Examples
|
|
151
|
+
--------
|
|
152
|
+
from phenoml import phenoml
|
|
153
|
+
|
|
154
|
+
client = phenoml(
|
|
155
|
+
token="YOUR_TOKEN",
|
|
156
|
+
)
|
|
157
|
+
client.summary.get_template(
|
|
158
|
+
id="id",
|
|
159
|
+
)
|
|
160
|
+
"""
|
|
161
|
+
_response = self._raw_client.get_template(id, request_options=request_options)
|
|
162
|
+
return _response.data
|
|
163
|
+
|
|
164
|
+
def update_template(
|
|
165
|
+
self,
|
|
166
|
+
id: str,
|
|
167
|
+
*,
|
|
168
|
+
name: str,
|
|
169
|
+
template: str,
|
|
170
|
+
target_resources: typing.Sequence[str],
|
|
171
|
+
mode: str,
|
|
172
|
+
description: typing.Optional[str] = OMIT,
|
|
173
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
174
|
+
) -> SummaryUpdateTemplateResponse:
|
|
175
|
+
"""
|
|
176
|
+
Updates an existing summary template
|
|
177
|
+
|
|
178
|
+
Parameters
|
|
179
|
+
----------
|
|
180
|
+
id : str
|
|
181
|
+
Template ID
|
|
182
|
+
|
|
183
|
+
name : str
|
|
184
|
+
|
|
185
|
+
template : str
|
|
186
|
+
Updated template with placeholders
|
|
187
|
+
|
|
188
|
+
target_resources : typing.Sequence[str]
|
|
189
|
+
|
|
190
|
+
mode : str
|
|
191
|
+
Template mode
|
|
192
|
+
|
|
193
|
+
description : typing.Optional[str]
|
|
194
|
+
|
|
195
|
+
request_options : typing.Optional[RequestOptions]
|
|
196
|
+
Request-specific configuration.
|
|
197
|
+
|
|
198
|
+
Returns
|
|
199
|
+
-------
|
|
200
|
+
SummaryUpdateTemplateResponse
|
|
201
|
+
Template updated successfully
|
|
202
|
+
|
|
203
|
+
Examples
|
|
204
|
+
--------
|
|
205
|
+
from phenoml import phenoml
|
|
206
|
+
|
|
207
|
+
client = phenoml(
|
|
208
|
+
token="YOUR_TOKEN",
|
|
209
|
+
)
|
|
210
|
+
client.summary.update_template(
|
|
211
|
+
id="id",
|
|
212
|
+
name="name",
|
|
213
|
+
template="template",
|
|
214
|
+
target_resources=["target_resources"],
|
|
215
|
+
mode="mode",
|
|
216
|
+
)
|
|
217
|
+
"""
|
|
218
|
+
_response = self._raw_client.update_template(
|
|
219
|
+
id,
|
|
220
|
+
name=name,
|
|
221
|
+
template=template,
|
|
222
|
+
target_resources=target_resources,
|
|
223
|
+
mode=mode,
|
|
224
|
+
description=description,
|
|
225
|
+
request_options=request_options,
|
|
226
|
+
)
|
|
227
|
+
return _response.data
|
|
228
|
+
|
|
229
|
+
def delete_template(
|
|
230
|
+
self, id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
231
|
+
) -> SummaryDeleteTemplateResponse:
|
|
232
|
+
"""
|
|
233
|
+
Deletes a summary template
|
|
234
|
+
|
|
235
|
+
Parameters
|
|
236
|
+
----------
|
|
237
|
+
id : str
|
|
238
|
+
Template ID
|
|
239
|
+
|
|
240
|
+
request_options : typing.Optional[RequestOptions]
|
|
241
|
+
Request-specific configuration.
|
|
242
|
+
|
|
243
|
+
Returns
|
|
244
|
+
-------
|
|
245
|
+
SummaryDeleteTemplateResponse
|
|
246
|
+
Template deleted successfully
|
|
247
|
+
|
|
248
|
+
Examples
|
|
249
|
+
--------
|
|
250
|
+
from phenoml import phenoml
|
|
251
|
+
|
|
252
|
+
client = phenoml(
|
|
253
|
+
token="YOUR_TOKEN",
|
|
254
|
+
)
|
|
255
|
+
client.summary.delete_template(
|
|
256
|
+
id="id",
|
|
257
|
+
)
|
|
258
|
+
"""
|
|
259
|
+
_response = self._raw_client.delete_template(id, request_options=request_options)
|
|
260
|
+
return _response.data
|
|
261
|
+
|
|
262
|
+
def create(
|
|
263
|
+
self,
|
|
264
|
+
*,
|
|
265
|
+
fhir_resources: CreateSummaryRequestFhirResources,
|
|
266
|
+
mode: typing.Optional[CreateSummaryRequestMode] = OMIT,
|
|
267
|
+
template_id: typing.Optional[str] = OMIT,
|
|
268
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
269
|
+
) -> CreateSummaryResponse:
|
|
270
|
+
"""
|
|
271
|
+
Creates a summary from FHIR resources using one of three modes:
|
|
272
|
+
- **narrative**: Uses a template to substitute FHIR data into placeholders (requires template_id)
|
|
273
|
+
- **flatten**: Flattens FHIR resources into a searchable format for RAG/search (no template needed)
|
|
274
|
+
- **ips**: Generates an International Patient Summary (IPS) narrative per ISO 27269/HL7 FHIR IPS IG. Requires a Bundle with exactly one Patient resource (returns 400 error if no Patient or multiple Patients are present). Automatically filters resources to those referencing the patient and generates sections for allergies, medications, problems, immunizations, procedures, and vital signs.
|
|
275
|
+
|
|
276
|
+
Parameters
|
|
277
|
+
----------
|
|
278
|
+
fhir_resources : CreateSummaryRequestFhirResources
|
|
279
|
+
FHIR resources (single resource or Bundle).
|
|
280
|
+
For IPS mode, must be a Bundle containing exactly one Patient resource with at least one
|
|
281
|
+
identifier (id, fullUrl, or identifier field). Returns an error if no Patient is found,
|
|
282
|
+
if multiple Patients are present, or if the Patient has no identifiers. Resources are
|
|
283
|
+
automatically filtered to only include those referencing the patient.
|
|
284
|
+
|
|
285
|
+
mode : typing.Optional[CreateSummaryRequestMode]
|
|
286
|
+
Summary generation mode:
|
|
287
|
+
- narrative: Substitute FHIR data into a template (requires template_id)
|
|
288
|
+
- flatten: Flatten FHIR resources for RAG/search (no template needed)
|
|
289
|
+
- ips: Generate International Patient Summary (IPS) narrative per ISO 27269/HL7 FHIR IPS IG
|
|
290
|
+
|
|
291
|
+
template_id : typing.Optional[str]
|
|
292
|
+
ID of the template to use (required for narrative mode)
|
|
293
|
+
|
|
294
|
+
request_options : typing.Optional[RequestOptions]
|
|
295
|
+
Request-specific configuration.
|
|
296
|
+
|
|
297
|
+
Returns
|
|
298
|
+
-------
|
|
299
|
+
CreateSummaryResponse
|
|
300
|
+
Summary generated successfully
|
|
301
|
+
|
|
302
|
+
Examples
|
|
303
|
+
--------
|
|
304
|
+
from phenoml import phenoml
|
|
305
|
+
from phenoml.summary import FhirResource
|
|
306
|
+
|
|
307
|
+
client = phenoml(
|
|
308
|
+
token="YOUR_TOKEN",
|
|
309
|
+
)
|
|
310
|
+
client.summary.create(
|
|
311
|
+
fhir_resources=FhirResource(
|
|
312
|
+
resource_type="resourceType",
|
|
313
|
+
),
|
|
314
|
+
)
|
|
315
|
+
"""
|
|
316
|
+
_response = self._raw_client.create(
|
|
317
|
+
fhir_resources=fhir_resources, mode=mode, template_id=template_id, request_options=request_options
|
|
318
|
+
)
|
|
319
|
+
return _response.data
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
class AsyncSummaryClient:
|
|
323
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
324
|
+
self._raw_client = AsyncRawSummaryClient(client_wrapper=client_wrapper)
|
|
325
|
+
|
|
326
|
+
@property
|
|
327
|
+
def with_raw_response(self) -> AsyncRawSummaryClient:
|
|
328
|
+
"""
|
|
329
|
+
Retrieves a raw implementation of this client that returns raw responses.
|
|
330
|
+
|
|
331
|
+
Returns
|
|
332
|
+
-------
|
|
333
|
+
AsyncRawSummaryClient
|
|
334
|
+
"""
|
|
335
|
+
return self._raw_client
|
|
336
|
+
|
|
337
|
+
async def list_templates(
|
|
338
|
+
self, *, request_options: typing.Optional[RequestOptions] = None
|
|
339
|
+
) -> SummaryListTemplatesResponse:
|
|
340
|
+
"""
|
|
341
|
+
Retrieves all summary templates for the authenticated user
|
|
342
|
+
|
|
343
|
+
Parameters
|
|
344
|
+
----------
|
|
345
|
+
request_options : typing.Optional[RequestOptions]
|
|
346
|
+
Request-specific configuration.
|
|
347
|
+
|
|
348
|
+
Returns
|
|
349
|
+
-------
|
|
350
|
+
SummaryListTemplatesResponse
|
|
351
|
+
Templates retrieved successfully
|
|
352
|
+
|
|
353
|
+
Examples
|
|
354
|
+
--------
|
|
355
|
+
import asyncio
|
|
356
|
+
|
|
357
|
+
from phenoml import Asyncphenoml
|
|
358
|
+
|
|
359
|
+
client = Asyncphenoml(
|
|
360
|
+
token="YOUR_TOKEN",
|
|
361
|
+
)
|
|
362
|
+
|
|
363
|
+
|
|
364
|
+
async def main() -> None:
|
|
365
|
+
await client.summary.list_templates()
|
|
366
|
+
|
|
367
|
+
|
|
368
|
+
asyncio.run(main())
|
|
369
|
+
"""
|
|
370
|
+
_response = await self._raw_client.list_templates(request_options=request_options)
|
|
371
|
+
return _response.data
|
|
372
|
+
|
|
373
|
+
async def create_template(
|
|
374
|
+
self,
|
|
375
|
+
*,
|
|
376
|
+
name: str,
|
|
377
|
+
example_summary: str,
|
|
378
|
+
target_resources: typing.Sequence[str],
|
|
379
|
+
mode: str,
|
|
380
|
+
description: typing.Optional[str] = OMIT,
|
|
381
|
+
example_fhir_data: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
|
|
382
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
383
|
+
) -> CreateSummaryTemplateResponse:
|
|
384
|
+
"""
|
|
385
|
+
Creates a summary template from an example using LLM function calling
|
|
386
|
+
|
|
387
|
+
Parameters
|
|
388
|
+
----------
|
|
389
|
+
name : str
|
|
390
|
+
Name of the template
|
|
391
|
+
|
|
392
|
+
example_summary : str
|
|
393
|
+
Example summary note to generate template from
|
|
394
|
+
|
|
395
|
+
target_resources : typing.Sequence[str]
|
|
396
|
+
List of target FHIR resources
|
|
397
|
+
|
|
398
|
+
mode : str
|
|
399
|
+
Template mode (stored with the template)
|
|
400
|
+
|
|
401
|
+
description : typing.Optional[str]
|
|
402
|
+
Description of the template
|
|
403
|
+
|
|
404
|
+
example_fhir_data : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
|
|
405
|
+
Optional example FHIR data that corresponds to the example summary
|
|
406
|
+
|
|
407
|
+
request_options : typing.Optional[RequestOptions]
|
|
408
|
+
Request-specific configuration.
|
|
409
|
+
|
|
410
|
+
Returns
|
|
411
|
+
-------
|
|
412
|
+
CreateSummaryTemplateResponse
|
|
413
|
+
Template created successfully
|
|
414
|
+
|
|
415
|
+
Examples
|
|
416
|
+
--------
|
|
417
|
+
import asyncio
|
|
418
|
+
|
|
419
|
+
from phenoml import Asyncphenoml
|
|
420
|
+
|
|
421
|
+
client = Asyncphenoml(
|
|
422
|
+
token="YOUR_TOKEN",
|
|
423
|
+
)
|
|
424
|
+
|
|
425
|
+
|
|
426
|
+
async def main() -> None:
|
|
427
|
+
await client.summary.create_template(
|
|
428
|
+
name="name",
|
|
429
|
+
example_summary="Patient John Doe, age 45, presents with hypertension diagnosed on 2024-01-15.",
|
|
430
|
+
target_resources=["Patient", "Condition", "Observation"],
|
|
431
|
+
mode="mode",
|
|
432
|
+
)
|
|
433
|
+
|
|
434
|
+
|
|
435
|
+
asyncio.run(main())
|
|
436
|
+
"""
|
|
437
|
+
_response = await self._raw_client.create_template(
|
|
438
|
+
name=name,
|
|
439
|
+
example_summary=example_summary,
|
|
440
|
+
target_resources=target_resources,
|
|
441
|
+
mode=mode,
|
|
442
|
+
description=description,
|
|
443
|
+
example_fhir_data=example_fhir_data,
|
|
444
|
+
request_options=request_options,
|
|
445
|
+
)
|
|
446
|
+
return _response.data
|
|
447
|
+
|
|
448
|
+
async def get_template(
|
|
449
|
+
self, id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
450
|
+
) -> SummaryGetTemplateResponse:
|
|
451
|
+
"""
|
|
452
|
+
Retrieves a specific summary template
|
|
453
|
+
|
|
454
|
+
Parameters
|
|
455
|
+
----------
|
|
456
|
+
id : str
|
|
457
|
+
Template ID
|
|
458
|
+
|
|
459
|
+
request_options : typing.Optional[RequestOptions]
|
|
460
|
+
Request-specific configuration.
|
|
461
|
+
|
|
462
|
+
Returns
|
|
463
|
+
-------
|
|
464
|
+
SummaryGetTemplateResponse
|
|
465
|
+
Template retrieved successfully
|
|
466
|
+
|
|
467
|
+
Examples
|
|
468
|
+
--------
|
|
469
|
+
import asyncio
|
|
470
|
+
|
|
471
|
+
from phenoml import Asyncphenoml
|
|
472
|
+
|
|
473
|
+
client = Asyncphenoml(
|
|
474
|
+
token="YOUR_TOKEN",
|
|
475
|
+
)
|
|
476
|
+
|
|
477
|
+
|
|
478
|
+
async def main() -> None:
|
|
479
|
+
await client.summary.get_template(
|
|
480
|
+
id="id",
|
|
481
|
+
)
|
|
482
|
+
|
|
483
|
+
|
|
484
|
+
asyncio.run(main())
|
|
485
|
+
"""
|
|
486
|
+
_response = await self._raw_client.get_template(id, request_options=request_options)
|
|
487
|
+
return _response.data
|
|
488
|
+
|
|
489
|
+
async def update_template(
|
|
490
|
+
self,
|
|
491
|
+
id: str,
|
|
492
|
+
*,
|
|
493
|
+
name: str,
|
|
494
|
+
template: str,
|
|
495
|
+
target_resources: typing.Sequence[str],
|
|
496
|
+
mode: str,
|
|
497
|
+
description: typing.Optional[str] = OMIT,
|
|
498
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
499
|
+
) -> SummaryUpdateTemplateResponse:
|
|
500
|
+
"""
|
|
501
|
+
Updates an existing summary template
|
|
502
|
+
|
|
503
|
+
Parameters
|
|
504
|
+
----------
|
|
505
|
+
id : str
|
|
506
|
+
Template ID
|
|
507
|
+
|
|
508
|
+
name : str
|
|
509
|
+
|
|
510
|
+
template : str
|
|
511
|
+
Updated template with placeholders
|
|
512
|
+
|
|
513
|
+
target_resources : typing.Sequence[str]
|
|
514
|
+
|
|
515
|
+
mode : str
|
|
516
|
+
Template mode
|
|
517
|
+
|
|
518
|
+
description : typing.Optional[str]
|
|
519
|
+
|
|
520
|
+
request_options : typing.Optional[RequestOptions]
|
|
521
|
+
Request-specific configuration.
|
|
522
|
+
|
|
523
|
+
Returns
|
|
524
|
+
-------
|
|
525
|
+
SummaryUpdateTemplateResponse
|
|
526
|
+
Template updated successfully
|
|
527
|
+
|
|
528
|
+
Examples
|
|
529
|
+
--------
|
|
530
|
+
import asyncio
|
|
531
|
+
|
|
532
|
+
from phenoml import Asyncphenoml
|
|
533
|
+
|
|
534
|
+
client = Asyncphenoml(
|
|
535
|
+
token="YOUR_TOKEN",
|
|
536
|
+
)
|
|
537
|
+
|
|
538
|
+
|
|
539
|
+
async def main() -> None:
|
|
540
|
+
await client.summary.update_template(
|
|
541
|
+
id="id",
|
|
542
|
+
name="name",
|
|
543
|
+
template="template",
|
|
544
|
+
target_resources=["target_resources"],
|
|
545
|
+
mode="mode",
|
|
546
|
+
)
|
|
547
|
+
|
|
548
|
+
|
|
549
|
+
asyncio.run(main())
|
|
550
|
+
"""
|
|
551
|
+
_response = await self._raw_client.update_template(
|
|
552
|
+
id,
|
|
553
|
+
name=name,
|
|
554
|
+
template=template,
|
|
555
|
+
target_resources=target_resources,
|
|
556
|
+
mode=mode,
|
|
557
|
+
description=description,
|
|
558
|
+
request_options=request_options,
|
|
559
|
+
)
|
|
560
|
+
return _response.data
|
|
561
|
+
|
|
562
|
+
async def delete_template(
|
|
563
|
+
self, id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
564
|
+
) -> SummaryDeleteTemplateResponse:
|
|
565
|
+
"""
|
|
566
|
+
Deletes a summary template
|
|
567
|
+
|
|
568
|
+
Parameters
|
|
569
|
+
----------
|
|
570
|
+
id : str
|
|
571
|
+
Template ID
|
|
572
|
+
|
|
573
|
+
request_options : typing.Optional[RequestOptions]
|
|
574
|
+
Request-specific configuration.
|
|
575
|
+
|
|
576
|
+
Returns
|
|
577
|
+
-------
|
|
578
|
+
SummaryDeleteTemplateResponse
|
|
579
|
+
Template deleted successfully
|
|
580
|
+
|
|
581
|
+
Examples
|
|
582
|
+
--------
|
|
583
|
+
import asyncio
|
|
584
|
+
|
|
585
|
+
from phenoml import Asyncphenoml
|
|
586
|
+
|
|
587
|
+
client = Asyncphenoml(
|
|
588
|
+
token="YOUR_TOKEN",
|
|
589
|
+
)
|
|
590
|
+
|
|
591
|
+
|
|
592
|
+
async def main() -> None:
|
|
593
|
+
await client.summary.delete_template(
|
|
594
|
+
id="id",
|
|
595
|
+
)
|
|
596
|
+
|
|
597
|
+
|
|
598
|
+
asyncio.run(main())
|
|
599
|
+
"""
|
|
600
|
+
_response = await self._raw_client.delete_template(id, request_options=request_options)
|
|
601
|
+
return _response.data
|
|
602
|
+
|
|
603
|
+
async def create(
|
|
604
|
+
self,
|
|
605
|
+
*,
|
|
606
|
+
fhir_resources: CreateSummaryRequestFhirResources,
|
|
607
|
+
mode: typing.Optional[CreateSummaryRequestMode] = OMIT,
|
|
608
|
+
template_id: typing.Optional[str] = OMIT,
|
|
609
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
610
|
+
) -> CreateSummaryResponse:
|
|
611
|
+
"""
|
|
612
|
+
Creates a summary from FHIR resources using one of three modes:
|
|
613
|
+
- **narrative**: Uses a template to substitute FHIR data into placeholders (requires template_id)
|
|
614
|
+
- **flatten**: Flattens FHIR resources into a searchable format for RAG/search (no template needed)
|
|
615
|
+
- **ips**: Generates an International Patient Summary (IPS) narrative per ISO 27269/HL7 FHIR IPS IG. Requires a Bundle with exactly one Patient resource (returns 400 error if no Patient or multiple Patients are present). Automatically filters resources to those referencing the patient and generates sections for allergies, medications, problems, immunizations, procedures, and vital signs.
|
|
616
|
+
|
|
617
|
+
Parameters
|
|
618
|
+
----------
|
|
619
|
+
fhir_resources : CreateSummaryRequestFhirResources
|
|
620
|
+
FHIR resources (single resource or Bundle).
|
|
621
|
+
For IPS mode, must be a Bundle containing exactly one Patient resource with at least one
|
|
622
|
+
identifier (id, fullUrl, or identifier field). Returns an error if no Patient is found,
|
|
623
|
+
if multiple Patients are present, or if the Patient has no identifiers. Resources are
|
|
624
|
+
automatically filtered to only include those referencing the patient.
|
|
625
|
+
|
|
626
|
+
mode : typing.Optional[CreateSummaryRequestMode]
|
|
627
|
+
Summary generation mode:
|
|
628
|
+
- narrative: Substitute FHIR data into a template (requires template_id)
|
|
629
|
+
- flatten: Flatten FHIR resources for RAG/search (no template needed)
|
|
630
|
+
- ips: Generate International Patient Summary (IPS) narrative per ISO 27269/HL7 FHIR IPS IG
|
|
631
|
+
|
|
632
|
+
template_id : typing.Optional[str]
|
|
633
|
+
ID of the template to use (required for narrative mode)
|
|
634
|
+
|
|
635
|
+
request_options : typing.Optional[RequestOptions]
|
|
636
|
+
Request-specific configuration.
|
|
637
|
+
|
|
638
|
+
Returns
|
|
639
|
+
-------
|
|
640
|
+
CreateSummaryResponse
|
|
641
|
+
Summary generated successfully
|
|
642
|
+
|
|
643
|
+
Examples
|
|
644
|
+
--------
|
|
645
|
+
import asyncio
|
|
646
|
+
|
|
647
|
+
from phenoml import Asyncphenoml
|
|
648
|
+
from phenoml.summary import FhirResource
|
|
649
|
+
|
|
650
|
+
client = Asyncphenoml(
|
|
651
|
+
token="YOUR_TOKEN",
|
|
652
|
+
)
|
|
653
|
+
|
|
654
|
+
|
|
655
|
+
async def main() -> None:
|
|
656
|
+
await client.summary.create(
|
|
657
|
+
fhir_resources=FhirResource(
|
|
658
|
+
resource_type="resourceType",
|
|
659
|
+
),
|
|
660
|
+
)
|
|
661
|
+
|
|
662
|
+
|
|
663
|
+
asyncio.run(main())
|
|
664
|
+
"""
|
|
665
|
+
_response = await self._raw_client.create(
|
|
666
|
+
fhir_resources=fhir_resources, mode=mode, template_id=template_id, request_options=request_options
|
|
667
|
+
)
|
|
668
|
+
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 .forbidden_error import ForbiddenError
|
|
7
|
+
from .internal_server_error import InternalServerError
|
|
8
|
+
from .not_found_error import NotFoundError
|
|
9
|
+
from .unauthorized_error import UnauthorizedError
|
|
10
|
+
|
|
11
|
+
__all__ = ["BadRequestError", "ForbiddenError", "InternalServerError", "NotFoundError", "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 ForbiddenError(ApiError):
|
|
9
|
+
def __init__(self, body: typing.Optional[typing.Any], headers: typing.Optional[typing.Dict[str, str]] = None):
|
|
10
|
+
super().__init__(status_code=403, 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)
|