phenoml 0.0.1__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.

Potentially problematic release.


This version of phenoml might be problematic. Click here for more details.

Files changed (143) hide show
  1. phenoml/__init__.py +30 -0
  2. phenoml/agent/__init__.py +58 -0
  3. phenoml/agent/client.py +820 -0
  4. phenoml/agent/errors/__init__.py +11 -0
  5. phenoml/agent/errors/bad_request_error.py +10 -0
  6. phenoml/agent/errors/forbidden_error.py +10 -0
  7. phenoml/agent/errors/internal_server_error.py +10 -0
  8. phenoml/agent/errors/not_found_error.py +10 -0
  9. phenoml/agent/errors/unauthorized_error.py +10 -0
  10. phenoml/agent/prompts/__init__.py +7 -0
  11. phenoml/agent/prompts/client.py +707 -0
  12. phenoml/agent/prompts/raw_client.py +1345 -0
  13. phenoml/agent/prompts/types/__init__.py +8 -0
  14. phenoml/agent/prompts/types/prompts_delete_response.py +20 -0
  15. phenoml/agent/prompts/types/prompts_list_response.py +22 -0
  16. phenoml/agent/raw_client.py +1501 -0
  17. phenoml/agent/types/__init__.py +45 -0
  18. phenoml/agent/types/agent_chat_response.py +33 -0
  19. phenoml/agent/types/agent_create_request_provider.py +13 -0
  20. phenoml/agent/types/agent_create_request_provider_item.py +7 -0
  21. phenoml/agent/types/agent_delete_response.py +20 -0
  22. phenoml/agent/types/agent_fhir_config.py +31 -0
  23. phenoml/agent/types/agent_list_response.py +22 -0
  24. phenoml/agent/types/agent_prompts_response.py +22 -0
  25. phenoml/agent/types/agent_response.py +22 -0
  26. phenoml/agent/types/agent_template.py +56 -0
  27. phenoml/agent/types/agent_template_provider.py +13 -0
  28. phenoml/agent/types/agent_template_provider_item.py +5 -0
  29. phenoml/agent/types/agent_update_request_provider.py +13 -0
  30. phenoml/agent/types/agent_update_request_provider_item.py +7 -0
  31. phenoml/agent/types/chat_fhir_client_config.py +31 -0
  32. phenoml/agent/types/json_patch.py +7 -0
  33. phenoml/agent/types/json_patch_operation.py +36 -0
  34. phenoml/agent/types/json_patch_operation_op.py +5 -0
  35. phenoml/agent/types/prompt_template.py +52 -0
  36. phenoml/agent/types/success_response.py +20 -0
  37. phenoml/authtoken/__init__.py +17 -0
  38. phenoml/authtoken/auth/__init__.py +7 -0
  39. phenoml/authtoken/auth/client.py +129 -0
  40. phenoml/authtoken/auth/raw_client.py +173 -0
  41. phenoml/authtoken/auth/types/__init__.py +7 -0
  42. phenoml/authtoken/auth/types/auth_generate_token_response.py +22 -0
  43. phenoml/authtoken/client.py +39 -0
  44. phenoml/authtoken/errors/__init__.py +8 -0
  45. phenoml/authtoken/errors/bad_request_error.py +10 -0
  46. phenoml/authtoken/errors/unauthorized_error.py +10 -0
  47. phenoml/authtoken/raw_client.py +13 -0
  48. phenoml/authtoken/types/__init__.py +8 -0
  49. phenoml/authtoken/types/bad_request_error_body.py +21 -0
  50. phenoml/authtoken/types/unauthorized_error_body.py +21 -0
  51. phenoml/client.py +168 -0
  52. phenoml/cohort/__init__.py +8 -0
  53. phenoml/cohort/client.py +113 -0
  54. phenoml/cohort/errors/__init__.py +9 -0
  55. phenoml/cohort/errors/bad_request_error.py +10 -0
  56. phenoml/cohort/errors/internal_server_error.py +10 -0
  57. phenoml/cohort/errors/unauthorized_error.py +10 -0
  58. phenoml/cohort/raw_client.py +185 -0
  59. phenoml/cohort/types/__init__.py +8 -0
  60. phenoml/cohort/types/cohort_response.py +33 -0
  61. phenoml/cohort/types/search_concept.py +37 -0
  62. phenoml/construe/__init__.py +45 -0
  63. phenoml/construe/client.py +399 -0
  64. phenoml/construe/errors/__init__.py +11 -0
  65. phenoml/construe/errors/bad_request_error.py +10 -0
  66. phenoml/construe/errors/conflict_error.py +10 -0
  67. phenoml/construe/errors/failed_dependency_error.py +10 -0
  68. phenoml/construe/errors/internal_server_error.py +10 -0
  69. phenoml/construe/errors/unauthorized_error.py +10 -0
  70. phenoml/construe/raw_client.py +706 -0
  71. phenoml/construe/types/__init__.py +41 -0
  72. phenoml/construe/types/bad_request_error_body.py +27 -0
  73. phenoml/construe/types/construe_cohort_request_config.py +37 -0
  74. phenoml/construe/types/construe_cohort_response.py +33 -0
  75. phenoml/construe/types/construe_cohort_response_queries_item.py +49 -0
  76. phenoml/construe/types/construe_cohort_response_queries_item_code_extract_results_item.py +31 -0
  77. phenoml/construe/types/construe_cohort_response_queries_item_code_extract_results_item_codes_item.py +32 -0
  78. phenoml/construe/types/construe_upload_code_system_response.py +19 -0
  79. phenoml/construe/types/extract_codes_result.py +22 -0
  80. phenoml/construe/types/extract_request_config.py +23 -0
  81. phenoml/construe/types/extract_request_config_chunking_method.py +5 -0
  82. phenoml/construe/types/extract_request_system.py +37 -0
  83. phenoml/construe/types/extracted_code_result.py +41 -0
  84. phenoml/construe/types/internal_server_error_body.py +27 -0
  85. phenoml/construe/types/unauthorized_error_body.py +27 -0
  86. phenoml/construe/types/upload_request_format.py +5 -0
  87. phenoml/core/__init__.py +52 -0
  88. phenoml/core/api_error.py +23 -0
  89. phenoml/core/client_wrapper.py +85 -0
  90. phenoml/core/datetime_utils.py +28 -0
  91. phenoml/core/file.py +67 -0
  92. phenoml/core/force_multipart.py +16 -0
  93. phenoml/core/http_client.py +543 -0
  94. phenoml/core/http_response.py +55 -0
  95. phenoml/core/jsonable_encoder.py +100 -0
  96. phenoml/core/pydantic_utilities.py +255 -0
  97. phenoml/core/query_encoder.py +58 -0
  98. phenoml/core/remove_none_from_dict.py +11 -0
  99. phenoml/core/request_options.py +35 -0
  100. phenoml/core/serialization.py +276 -0
  101. phenoml/environment.py +7 -0
  102. phenoml/lang2fhir/__init__.py +27 -0
  103. phenoml/lang2fhir/client.py +430 -0
  104. phenoml/lang2fhir/errors/__init__.py +11 -0
  105. phenoml/lang2fhir/errors/bad_request_error.py +10 -0
  106. phenoml/lang2fhir/errors/failed_dependency_error.py +10 -0
  107. phenoml/lang2fhir/errors/forbidden_error.py +10 -0
  108. phenoml/lang2fhir/errors/internal_server_error.py +10 -0
  109. phenoml/lang2fhir/errors/unauthorized_error.py +10 -0
  110. phenoml/lang2fhir/raw_client.py +788 -0
  111. phenoml/lang2fhir/types/__init__.py +19 -0
  112. phenoml/lang2fhir/types/create_request_resource.py +25 -0
  113. phenoml/lang2fhir/types/document_request_file_type.py +7 -0
  114. phenoml/lang2fhir/types/document_request_resource.py +5 -0
  115. phenoml/lang2fhir/types/fhir_resource.py +5 -0
  116. phenoml/lang2fhir/types/lang2fhir_upload_profile_response.py +23 -0
  117. phenoml/lang2fhir/types/search_response.py +33 -0
  118. phenoml/py.typed +0 -0
  119. phenoml/tools/__init__.py +33 -0
  120. phenoml/tools/client.py +392 -0
  121. phenoml/tools/errors/__init__.py +11 -0
  122. phenoml/tools/errors/bad_request_error.py +10 -0
  123. phenoml/tools/errors/failed_dependency_error.py +10 -0
  124. phenoml/tools/errors/forbidden_error.py +10 -0
  125. phenoml/tools/errors/internal_server_error.py +10 -0
  126. phenoml/tools/errors/unauthorized_error.py +10 -0
  127. phenoml/tools/raw_client.py +745 -0
  128. phenoml/tools/types/__init__.py +25 -0
  129. phenoml/tools/types/cohort_request_provider.py +5 -0
  130. phenoml/tools/types/cohort_response.py +49 -0
  131. phenoml/tools/types/fhir_client_config.py +31 -0
  132. phenoml/tools/types/lang2fhir_and_create_request_provider.py +7 -0
  133. phenoml/tools/types/lang2fhir_and_create_request_resource.py +25 -0
  134. phenoml/tools/types/lang2fhir_and_create_response.py +33 -0
  135. phenoml/tools/types/lang2fhir_and_search_request_provider.py +7 -0
  136. phenoml/tools/types/lang2fhir_and_search_response.py +40 -0
  137. phenoml/tools/types/search_concept.py +41 -0
  138. phenoml/version.py +3 -0
  139. phenoml/wrapper_client.py +123 -0
  140. phenoml-0.0.1.dist-info/LICENSE +21 -0
  141. phenoml-0.0.1.dist-info/METADATA +192 -0
  142. phenoml-0.0.1.dist-info/RECORD +143 -0
  143. phenoml-0.0.1.dist-info/WHEEL +4 -0
@@ -0,0 +1,19 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ # isort: skip_file
4
+
5
+ from .create_request_resource import CreateRequestResource
6
+ from .document_request_file_type import DocumentRequestFileType
7
+ from .document_request_resource import DocumentRequestResource
8
+ from .fhir_resource import FhirResource
9
+ from .lang2fhir_upload_profile_response import Lang2FhirUploadProfileResponse
10
+ from .search_response import SearchResponse
11
+
12
+ __all__ = [
13
+ "CreateRequestResource",
14
+ "DocumentRequestFileType",
15
+ "DocumentRequestResource",
16
+ "FhirResource",
17
+ "Lang2FhirUploadProfileResponse",
18
+ "SearchResponse",
19
+ ]
@@ -0,0 +1,25 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ CreateRequestResource = typing.Union[
6
+ typing.Literal[
7
+ "auto",
8
+ "appointment",
9
+ "condition-encounter-diagnosis",
10
+ "medicationrequest",
11
+ "careplan",
12
+ "condition-problems-health-concerns",
13
+ "coverage",
14
+ "encounter",
15
+ "observation-clinical-result",
16
+ "observation-lab",
17
+ "patient",
18
+ "procedure",
19
+ "questionnaire",
20
+ "questionnaireresponse",
21
+ "simple-observation",
22
+ "vital-signs",
23
+ ],
24
+ typing.Any,
25
+ ]
@@ -0,0 +1,7 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ DocumentRequestFileType = typing.Union[
6
+ typing.Literal["application/pdf", "image/png", "image/jpeg", "image/jpg"], typing.Any
7
+ ]
@@ -0,0 +1,5 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ DocumentRequestResource = typing.Union[typing.Literal["questionnaire", "questionnaireresponse"], typing.Any]
@@ -0,0 +1,5 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ FhirResource = typing.Dict[str, typing.Optional[typing.Any]]
@@ -0,0 +1,23 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ import pydantic
6
+ from ...core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
7
+
8
+
9
+ class Lang2FhirUploadProfileResponse(UniversalBaseModel):
10
+ message: typing.Optional[str] = None
11
+ id: typing.Optional[str] = None
12
+ resource: typing.Optional[str] = None
13
+ version: typing.Optional[str] = None
14
+ url: typing.Optional[str] = None
15
+
16
+ if IS_PYDANTIC_V2:
17
+ model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
18
+ else:
19
+
20
+ class Config:
21
+ frozen = True
22
+ smart_union = True
23
+ extra = pydantic.Extra.allow
@@ -0,0 +1,33 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ import pydantic
6
+ import typing_extensions
7
+ from ...core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
8
+ from ...core.serialization import FieldMetadata
9
+
10
+
11
+ class SearchResponse(UniversalBaseModel):
12
+ resource_type: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="resourceType")] = (
13
+ pydantic.Field(default=None)
14
+ )
15
+ """
16
+ The FHIR resource type identified for the search
17
+ """
18
+
19
+ search_params: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="searchParams")] = (
20
+ pydantic.Field(default=None)
21
+ )
22
+ """
23
+ FHIR search parameters in standard format
24
+ """
25
+
26
+ if IS_PYDANTIC_V2:
27
+ model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
28
+ else:
29
+
30
+ class Config:
31
+ frozen = True
32
+ smart_union = True
33
+ extra = pydantic.Extra.allow
phenoml/py.typed ADDED
File without changes
@@ -0,0 +1,33 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ # isort: skip_file
4
+
5
+ from .types import (
6
+ CohortRequestProvider,
7
+ CohortResponse,
8
+ FhirClientConfig,
9
+ Lang2FhirAndCreateRequestProvider,
10
+ Lang2FhirAndCreateRequestResource,
11
+ Lang2FhirAndCreateResponse,
12
+ Lang2FhirAndSearchRequestProvider,
13
+ Lang2FhirAndSearchResponse,
14
+ SearchConcept,
15
+ )
16
+ from .errors import BadRequestError, FailedDependencyError, ForbiddenError, InternalServerError, UnauthorizedError
17
+
18
+ __all__ = [
19
+ "BadRequestError",
20
+ "CohortRequestProvider",
21
+ "CohortResponse",
22
+ "FailedDependencyError",
23
+ "FhirClientConfig",
24
+ "ForbiddenError",
25
+ "InternalServerError",
26
+ "Lang2FhirAndCreateRequestProvider",
27
+ "Lang2FhirAndCreateRequestResource",
28
+ "Lang2FhirAndCreateResponse",
29
+ "Lang2FhirAndSearchRequestProvider",
30
+ "Lang2FhirAndSearchResponse",
31
+ "SearchConcept",
32
+ "UnauthorizedError",
33
+ ]
@@ -0,0 +1,392 @@
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 AsyncRawToolsClient, RawToolsClient
8
+ from .types.cohort_request_provider import CohortRequestProvider
9
+ from .types.cohort_response import CohortResponse
10
+ from .types.fhir_client_config import FhirClientConfig
11
+ from .types.lang2fhir_and_create_request_provider import Lang2FhirAndCreateRequestProvider
12
+ from .types.lang2fhir_and_create_request_resource import Lang2FhirAndCreateRequestResource
13
+ from .types.lang2fhir_and_create_response import Lang2FhirAndCreateResponse
14
+ from .types.lang2fhir_and_search_request_provider import Lang2FhirAndSearchRequestProvider
15
+ from .types.lang2fhir_and_search_response import Lang2FhirAndSearchResponse
16
+
17
+ # this is used as the default value for optional parameters
18
+ OMIT = typing.cast(typing.Any, ...)
19
+
20
+
21
+ class ToolsClient:
22
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
23
+ self._raw_client = RawToolsClient(client_wrapper=client_wrapper)
24
+
25
+ @property
26
+ def with_raw_response(self) -> RawToolsClient:
27
+ """
28
+ Retrieves a raw implementation of this client that returns raw responses.
29
+
30
+ Returns
31
+ -------
32
+ RawToolsClient
33
+ """
34
+ return self._raw_client
35
+
36
+ def create_fhir_resource(
37
+ self,
38
+ *,
39
+ resource: Lang2FhirAndCreateRequestResource,
40
+ text: str,
41
+ provider: typing.Optional[Lang2FhirAndCreateRequestProvider] = OMIT,
42
+ meta: typing.Optional[FhirClientConfig] = OMIT,
43
+ request_options: typing.Optional[RequestOptions] = None,
44
+ ) -> Lang2FhirAndCreateResponse:
45
+ """
46
+ Converts natural language to FHIR resource and optionally stores it in a FHIR server
47
+
48
+ Parameters
49
+ ----------
50
+ resource : Lang2FhirAndCreateRequestResource
51
+ Type of FHIR resource to create. Use 'auto' for automatic resource type detection, or specify a supported US Core profile.
52
+
53
+ text : str
54
+ Natural language text to convert to FHIR resource
55
+
56
+ provider : typing.Optional[Lang2FhirAndCreateRequestProvider]
57
+ FHIR provider to use for storing the resource
58
+
59
+ meta : typing.Optional[FhirClientConfig]
60
+
61
+ request_options : typing.Optional[RequestOptions]
62
+ Request-specific configuration.
63
+
64
+ Returns
65
+ -------
66
+ Lang2FhirAndCreateResponse
67
+ Successfully created FHIR resource
68
+
69
+ Examples
70
+ --------
71
+ from phenoml import phenoml
72
+
73
+ client = phenoml(
74
+ token="YOUR_TOKEN",
75
+ )
76
+ client.tools.create_fhir_resource(
77
+ resource="auto",
78
+ text="Patient John Doe has severe asthma with acute exacerbation",
79
+ )
80
+ """
81
+ _response = self._raw_client.create_fhir_resource(
82
+ resource=resource, text=text, provider=provider, meta=meta, request_options=request_options
83
+ )
84
+ return _response.data
85
+
86
+ def search_fhir_resources(
87
+ self,
88
+ *,
89
+ text: str,
90
+ patient_id: typing.Optional[str] = OMIT,
91
+ practitioner_id: typing.Optional[str] = OMIT,
92
+ count: typing.Optional[int] = OMIT,
93
+ provider: typing.Optional[Lang2FhirAndSearchRequestProvider] = OMIT,
94
+ meta: typing.Optional[FhirClientConfig] = OMIT,
95
+ request_options: typing.Optional[RequestOptions] = None,
96
+ ) -> Lang2FhirAndSearchResponse:
97
+ """
98
+ Converts natural language to FHIR search parameters and executes search in FHIR server
99
+
100
+ Parameters
101
+ ----------
102
+ text : str
103
+ Natural language text to convert to FHIR search parameters
104
+
105
+ patient_id : typing.Optional[str]
106
+ Patient ID to filter results
107
+
108
+ practitioner_id : typing.Optional[str]
109
+ Practitioner ID to filter results
110
+
111
+ count : typing.Optional[int]
112
+ Maximum number of results to return
113
+
114
+ provider : typing.Optional[Lang2FhirAndSearchRequestProvider]
115
+ FHIR provider to use for searching
116
+
117
+ meta : typing.Optional[FhirClientConfig]
118
+
119
+ request_options : typing.Optional[RequestOptions]
120
+ Request-specific configuration.
121
+
122
+ Returns
123
+ -------
124
+ Lang2FhirAndSearchResponse
125
+ Successfully generated search and retrieved results
126
+
127
+ Examples
128
+ --------
129
+ from phenoml import phenoml
130
+
131
+ client = phenoml(
132
+ token="YOUR_TOKEN",
133
+ )
134
+ client.tools.search_fhir_resources(
135
+ text="Find all appointments for patient John Doe next week",
136
+ )
137
+ """
138
+ _response = self._raw_client.search_fhir_resources(
139
+ text=text,
140
+ patient_id=patient_id,
141
+ practitioner_id=practitioner_id,
142
+ count=count,
143
+ provider=provider,
144
+ meta=meta,
145
+ request_options=request_options,
146
+ )
147
+ return _response.data
148
+
149
+ def analyze_cohort(
150
+ self,
151
+ *,
152
+ text: str,
153
+ provider: CohortRequestProvider,
154
+ meta: typing.Optional[FhirClientConfig] = OMIT,
155
+ request_options: typing.Optional[RequestOptions] = None,
156
+ ) -> CohortResponse:
157
+ """
158
+ Uses LLM to extract search concepts from natural language and builds patient cohorts with inclusion/exclusion criteria
159
+
160
+ Parameters
161
+ ----------
162
+ text : str
163
+ Natural language text describing the patient cohort criteria
164
+
165
+ provider : CohortRequestProvider
166
+ FHIR provider to use for searching
167
+
168
+ meta : typing.Optional[FhirClientConfig]
169
+
170
+ request_options : typing.Optional[RequestOptions]
171
+ Request-specific configuration.
172
+
173
+ Returns
174
+ -------
175
+ CohortResponse
176
+ Successfully analyzed cohort and retrieved patient list
177
+
178
+ Examples
179
+ --------
180
+ from phenoml import phenoml
181
+
182
+ client = phenoml(
183
+ token="YOUR_TOKEN",
184
+ )
185
+ client.tools.analyze_cohort(
186
+ text="female patients over 20 with diabetes but not hypertension",
187
+ provider="medplum",
188
+ )
189
+ """
190
+ _response = self._raw_client.analyze_cohort(
191
+ text=text, provider=provider, meta=meta, request_options=request_options
192
+ )
193
+ return _response.data
194
+
195
+
196
+ class AsyncToolsClient:
197
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
198
+ self._raw_client = AsyncRawToolsClient(client_wrapper=client_wrapper)
199
+
200
+ @property
201
+ def with_raw_response(self) -> AsyncRawToolsClient:
202
+ """
203
+ Retrieves a raw implementation of this client that returns raw responses.
204
+
205
+ Returns
206
+ -------
207
+ AsyncRawToolsClient
208
+ """
209
+ return self._raw_client
210
+
211
+ async def create_fhir_resource(
212
+ self,
213
+ *,
214
+ resource: Lang2FhirAndCreateRequestResource,
215
+ text: str,
216
+ provider: typing.Optional[Lang2FhirAndCreateRequestProvider] = OMIT,
217
+ meta: typing.Optional[FhirClientConfig] = OMIT,
218
+ request_options: typing.Optional[RequestOptions] = None,
219
+ ) -> Lang2FhirAndCreateResponse:
220
+ """
221
+ Converts natural language to FHIR resource and optionally stores it in a FHIR server
222
+
223
+ Parameters
224
+ ----------
225
+ resource : Lang2FhirAndCreateRequestResource
226
+ Type of FHIR resource to create. Use 'auto' for automatic resource type detection, or specify a supported US Core profile.
227
+
228
+ text : str
229
+ Natural language text to convert to FHIR resource
230
+
231
+ provider : typing.Optional[Lang2FhirAndCreateRequestProvider]
232
+ FHIR provider to use for storing the resource
233
+
234
+ meta : typing.Optional[FhirClientConfig]
235
+
236
+ request_options : typing.Optional[RequestOptions]
237
+ Request-specific configuration.
238
+
239
+ Returns
240
+ -------
241
+ Lang2FhirAndCreateResponse
242
+ Successfully created FHIR resource
243
+
244
+ Examples
245
+ --------
246
+ import asyncio
247
+
248
+ from phenoml import Asyncphenoml
249
+
250
+ client = Asyncphenoml(
251
+ token="YOUR_TOKEN",
252
+ )
253
+
254
+
255
+ async def main() -> None:
256
+ await client.tools.create_fhir_resource(
257
+ resource="auto",
258
+ text="Patient John Doe has severe asthma with acute exacerbation",
259
+ )
260
+
261
+
262
+ asyncio.run(main())
263
+ """
264
+ _response = await self._raw_client.create_fhir_resource(
265
+ resource=resource, text=text, provider=provider, meta=meta, request_options=request_options
266
+ )
267
+ return _response.data
268
+
269
+ async def search_fhir_resources(
270
+ self,
271
+ *,
272
+ text: str,
273
+ patient_id: typing.Optional[str] = OMIT,
274
+ practitioner_id: typing.Optional[str] = OMIT,
275
+ count: typing.Optional[int] = OMIT,
276
+ provider: typing.Optional[Lang2FhirAndSearchRequestProvider] = OMIT,
277
+ meta: typing.Optional[FhirClientConfig] = OMIT,
278
+ request_options: typing.Optional[RequestOptions] = None,
279
+ ) -> Lang2FhirAndSearchResponse:
280
+ """
281
+ Converts natural language to FHIR search parameters and executes search in FHIR server
282
+
283
+ Parameters
284
+ ----------
285
+ text : str
286
+ Natural language text to convert to FHIR search parameters
287
+
288
+ patient_id : typing.Optional[str]
289
+ Patient ID to filter results
290
+
291
+ practitioner_id : typing.Optional[str]
292
+ Practitioner ID to filter results
293
+
294
+ count : typing.Optional[int]
295
+ Maximum number of results to return
296
+
297
+ provider : typing.Optional[Lang2FhirAndSearchRequestProvider]
298
+ FHIR provider to use for searching
299
+
300
+ meta : typing.Optional[FhirClientConfig]
301
+
302
+ request_options : typing.Optional[RequestOptions]
303
+ Request-specific configuration.
304
+
305
+ Returns
306
+ -------
307
+ Lang2FhirAndSearchResponse
308
+ Successfully generated search and retrieved results
309
+
310
+ Examples
311
+ --------
312
+ import asyncio
313
+
314
+ from phenoml import Asyncphenoml
315
+
316
+ client = Asyncphenoml(
317
+ token="YOUR_TOKEN",
318
+ )
319
+
320
+
321
+ async def main() -> None:
322
+ await client.tools.search_fhir_resources(
323
+ text="Find all appointments for patient John Doe next week",
324
+ )
325
+
326
+
327
+ asyncio.run(main())
328
+ """
329
+ _response = await self._raw_client.search_fhir_resources(
330
+ text=text,
331
+ patient_id=patient_id,
332
+ practitioner_id=practitioner_id,
333
+ count=count,
334
+ provider=provider,
335
+ meta=meta,
336
+ request_options=request_options,
337
+ )
338
+ return _response.data
339
+
340
+ async def analyze_cohort(
341
+ self,
342
+ *,
343
+ text: str,
344
+ provider: CohortRequestProvider,
345
+ meta: typing.Optional[FhirClientConfig] = OMIT,
346
+ request_options: typing.Optional[RequestOptions] = None,
347
+ ) -> CohortResponse:
348
+ """
349
+ Uses LLM to extract search concepts from natural language and builds patient cohorts with inclusion/exclusion criteria
350
+
351
+ Parameters
352
+ ----------
353
+ text : str
354
+ Natural language text describing the patient cohort criteria
355
+
356
+ provider : CohortRequestProvider
357
+ FHIR provider to use for searching
358
+
359
+ meta : typing.Optional[FhirClientConfig]
360
+
361
+ request_options : typing.Optional[RequestOptions]
362
+ Request-specific configuration.
363
+
364
+ Returns
365
+ -------
366
+ CohortResponse
367
+ Successfully analyzed cohort and retrieved patient list
368
+
369
+ Examples
370
+ --------
371
+ import asyncio
372
+
373
+ from phenoml import Asyncphenoml
374
+
375
+ client = Asyncphenoml(
376
+ token="YOUR_TOKEN",
377
+ )
378
+
379
+
380
+ async def main() -> None:
381
+ await client.tools.analyze_cohort(
382
+ text="female patients over 20 with diabetes but not hypertension",
383
+ provider="medplum",
384
+ )
385
+
386
+
387
+ asyncio.run(main())
388
+ """
389
+ _response = await self._raw_client.analyze_cohort(
390
+ text=text, provider=provider, meta=meta, request_options=request_options
391
+ )
392
+ 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 .failed_dependency_error import FailedDependencyError
7
+ from .forbidden_error import ForbiddenError
8
+ from .internal_server_error import InternalServerError
9
+ from .unauthorized_error import UnauthorizedError
10
+
11
+ __all__ = ["BadRequestError", "FailedDependencyError", "ForbiddenError", "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 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 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)
@@ -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)