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,173 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import base64
4
+ import typing
5
+ from json.decoder import JSONDecodeError
6
+
7
+ from ...core.api_error import ApiError
8
+ from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
9
+ from ...core.http_response import AsyncHttpResponse, HttpResponse
10
+ from ...core.pydantic_utilities import parse_obj_as
11
+ from ...core.request_options import RequestOptions
12
+ from ..errors.bad_request_error import BadRequestError
13
+ from ..errors.unauthorized_error import UnauthorizedError
14
+ from .types.auth_generate_token_response import AuthGenerateTokenResponse
15
+
16
+ # this is used as the default value for optional parameters
17
+ OMIT = typing.cast(typing.Any, ...)
18
+
19
+
20
+ class RawAuthClient:
21
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
22
+ self._client_wrapper = client_wrapper
23
+
24
+ def generate_token(
25
+ self, *, username: str, password: str, request_options: typing.Optional[RequestOptions] = None
26
+ ) -> HttpResponse[AuthGenerateTokenResponse]:
27
+ """
28
+ Obtain an access token using client credentials
29
+
30
+ Parameters
31
+ ----------
32
+ username : str
33
+ The user's username or email
34
+
35
+ password : str
36
+ The user's password
37
+
38
+ request_options : typing.Optional[RequestOptions]
39
+ Request-specific configuration.
40
+
41
+ Returns
42
+ -------
43
+ HttpResponse[AuthGenerateTokenResponse]
44
+ Successfully generated token
45
+ """
46
+ # Create basic auth header
47
+ credentials = f"{username}:{password}"
48
+ encoded_credentials = base64.b64encode(credentials.encode()).decode()
49
+
50
+ _response = self._client_wrapper.httpx_client.request(
51
+ "auth/token",
52
+ method="POST",
53
+ headers={
54
+ "Authorization": f"Basic {encoded_credentials}",
55
+ "content-type": "application/json",
56
+ },
57
+ request_options=request_options,
58
+ omit=OMIT,
59
+ )
60
+ try:
61
+ if 200 <= _response.status_code < 300:
62
+ _data = typing.cast(
63
+ AuthGenerateTokenResponse,
64
+ parse_obj_as(
65
+ type_=AuthGenerateTokenResponse, # type: ignore
66
+ object_=_response.json(),
67
+ ),
68
+ )
69
+ return HttpResponse(response=_response, data=_data)
70
+ if _response.status_code == 400:
71
+ raise BadRequestError(
72
+ headers=dict(_response.headers),
73
+ body=typing.cast(
74
+ typing.Optional[typing.Any],
75
+ parse_obj_as(
76
+ type_=typing.Optional[typing.Any], # type: ignore
77
+ object_=_response.json(),
78
+ ),
79
+ ),
80
+ )
81
+ if _response.status_code == 401:
82
+ raise UnauthorizedError(
83
+ headers=dict(_response.headers),
84
+ body=typing.cast(
85
+ typing.Optional[typing.Any],
86
+ parse_obj_as(
87
+ type_=typing.Optional[typing.Any], # type: ignore
88
+ object_=_response.json(),
89
+ ),
90
+ ),
91
+ )
92
+ _response_json = _response.json()
93
+ except JSONDecodeError:
94
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
95
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
96
+
97
+
98
+ class AsyncRawAuthClient:
99
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
100
+ self._client_wrapper = client_wrapper
101
+
102
+ async def generate_token(
103
+ self, *, username: str, password: str, request_options: typing.Optional[RequestOptions] = None
104
+ ) -> AsyncHttpResponse[AuthGenerateTokenResponse]:
105
+ """
106
+ Obtain an access token using client credentials
107
+
108
+ Parameters
109
+ ----------
110
+ username : str
111
+ The user's username or email
112
+
113
+ password : str
114
+ The user's password
115
+
116
+ request_options : typing.Optional[RequestOptions]
117
+ Request-specific configuration.
118
+
119
+ Returns
120
+ -------
121
+ AsyncHttpResponse[AuthGenerateTokenResponse]
122
+ Successfully generated token
123
+ """
124
+ # Create basic auth header
125
+ credentials = f"{username}:{password}"
126
+ encoded_credentials = base64.b64encode(credentials.encode()).decode()
127
+
128
+ _response = await self._client_wrapper.httpx_client.request(
129
+ "auth/token",
130
+ method="POST",
131
+ headers={
132
+ "Authorization": f"Basic {encoded_credentials}",
133
+ "content-type": "application/json",
134
+ },
135
+ request_options=request_options,
136
+ omit=OMIT,
137
+ )
138
+ try:
139
+ if 200 <= _response.status_code < 300:
140
+ _data = typing.cast(
141
+ AuthGenerateTokenResponse,
142
+ parse_obj_as(
143
+ type_=AuthGenerateTokenResponse, # type: ignore
144
+ object_=_response.json(),
145
+ ),
146
+ )
147
+ return AsyncHttpResponse(response=_response, data=_data)
148
+ if _response.status_code == 400:
149
+ raise BadRequestError(
150
+ headers=dict(_response.headers),
151
+ body=typing.cast(
152
+ typing.Optional[typing.Any],
153
+ parse_obj_as(
154
+ type_=typing.Optional[typing.Any], # type: ignore
155
+ object_=_response.json(),
156
+ ),
157
+ ),
158
+ )
159
+ if _response.status_code == 401:
160
+ raise UnauthorizedError(
161
+ headers=dict(_response.headers),
162
+ body=typing.cast(
163
+ typing.Optional[typing.Any],
164
+ parse_obj_as(
165
+ type_=typing.Optional[typing.Any], # type: ignore
166
+ object_=_response.json(),
167
+ ),
168
+ ),
169
+ )
170
+ _response_json = _response.json()
171
+ except JSONDecodeError:
172
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
173
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
@@ -0,0 +1,7 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ # isort: skip_file
4
+
5
+ from .auth_generate_token_response import AuthGenerateTokenResponse
6
+
7
+ __all__ = ["AuthGenerateTokenResponse"]
@@ -0,0 +1,22 @@
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 AuthGenerateTokenResponse(UniversalBaseModel):
10
+ token: str = pydantic.Field()
11
+ """
12
+ JWT token to be used for subsequent authenticated requests
13
+ """
14
+
15
+ if IS_PYDANTIC_V2:
16
+ model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
17
+ else:
18
+
19
+ class Config:
20
+ frozen = True
21
+ smart_union = True
22
+ extra = pydantic.Extra.allow
@@ -0,0 +1,39 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
4
+ from .auth.client import AsyncAuthClient, AuthClient
5
+ from .raw_client import AsyncRawAuthtokenClient, RawAuthtokenClient
6
+
7
+
8
+ class AuthtokenClient:
9
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
10
+ self._raw_client = RawAuthtokenClient(client_wrapper=client_wrapper)
11
+ self.auth = AuthClient(client_wrapper=client_wrapper)
12
+
13
+ @property
14
+ def with_raw_response(self) -> RawAuthtokenClient:
15
+ """
16
+ Retrieves a raw implementation of this client that returns raw responses.
17
+
18
+ Returns
19
+ -------
20
+ RawAuthtokenClient
21
+ """
22
+ return self._raw_client
23
+
24
+
25
+ class AsyncAuthtokenClient:
26
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
27
+ self._raw_client = AsyncRawAuthtokenClient(client_wrapper=client_wrapper)
28
+ self.auth = AsyncAuthClient(client_wrapper=client_wrapper)
29
+
30
+ @property
31
+ def with_raw_response(self) -> AsyncRawAuthtokenClient:
32
+ """
33
+ Retrieves a raw implementation of this client that returns raw responses.
34
+
35
+ Returns
36
+ -------
37
+ AsyncRawAuthtokenClient
38
+ """
39
+ return self._raw_client
@@ -0,0 +1,8 @@
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 .unauthorized_error import UnauthorizedError
7
+
8
+ __all__ = ["BadRequestError", "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 UnauthorizedError(ApiError):
9
+ def __init__(self, body: typing.Optional[typing.Any], headers: typing.Optional[typing.Dict[str, str]] = None):
10
+ super().__init__(status_code=401, headers=headers, body=body)
@@ -0,0 +1,13 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
4
+
5
+
6
+ class RawAuthtokenClient:
7
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
8
+ self._client_wrapper = client_wrapper
9
+
10
+
11
+ class AsyncRawAuthtokenClient:
12
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
13
+ self._client_wrapper = client_wrapper
@@ -0,0 +1,8 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ # isort: skip_file
4
+
5
+ from .bad_request_error_body import BadRequestErrorBody
6
+ from .unauthorized_error_body import UnauthorizedErrorBody
7
+
8
+ __all__ = ["BadRequestErrorBody", "UnauthorizedErrorBody"]
@@ -0,0 +1,21 @@
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 BadRequestErrorBody(UniversalBaseModel):
10
+ code: typing.Optional[int] = None
11
+ message: typing.Optional[str] = None
12
+ data: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = None
13
+
14
+ if IS_PYDANTIC_V2:
15
+ model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
16
+ else:
17
+
18
+ class Config:
19
+ frozen = True
20
+ smart_union = True
21
+ extra = pydantic.Extra.allow
@@ -0,0 +1,21 @@
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 UnauthorizedErrorBody(UniversalBaseModel):
10
+ code: typing.Optional[int] = None
11
+ message: typing.Optional[str] = None
12
+ data: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = None
13
+
14
+ if IS_PYDANTIC_V2:
15
+ model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
16
+ else:
17
+
18
+ class Config:
19
+ frozen = True
20
+ smart_union = True
21
+ extra = pydantic.Extra.allow
phenoml/client.py ADDED
@@ -0,0 +1,168 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ import httpx
6
+ from .agent.client import AgentClient, AsyncAgentClient
7
+ from .authtoken.client import AsyncAuthtokenClient, AuthtokenClient
8
+ from .cohort.client import AsyncCohortClient, CohortClient
9
+ from .construe.client import AsyncConstrueClient, ConstrueClient
10
+ from .core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
11
+ from .environment import phenomlEnvironment
12
+ from .lang2fhir.client import AsyncLang2FhirClient, Lang2FhirClient
13
+ from .tools.client import AsyncToolsClient, ToolsClient
14
+
15
+
16
+ class phenoml:
17
+ """
18
+ Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions.
19
+
20
+ Parameters
21
+ ----------
22
+ base_url : typing.Optional[str]
23
+ The base url to use for requests from the client.
24
+
25
+ environment : phenomlEnvironment
26
+ The environment to use for requests from the client. from .environment import phenomlEnvironment
27
+
28
+
29
+
30
+ Defaults to phenomlEnvironment.DEFAULT
31
+
32
+
33
+
34
+ token : typing.Union[str, typing.Callable[[], str]]
35
+ headers : typing.Optional[typing.Dict[str, str]]
36
+ Additional headers to send with every request.
37
+
38
+ timeout : typing.Optional[float]
39
+ The timeout to be used, in seconds, for requests. By default the timeout is 60 seconds, unless a custom httpx client is used, in which case this default is not enforced.
40
+
41
+ follow_redirects : typing.Optional[bool]
42
+ Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.
43
+
44
+ httpx_client : typing.Optional[httpx.Client]
45
+ The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration.
46
+
47
+ Examples
48
+ --------
49
+ from phenoml import phenoml
50
+
51
+ client = phenoml(
52
+ token="YOUR_TOKEN",
53
+ )
54
+ """
55
+
56
+ def __init__(
57
+ self,
58
+ *,
59
+ base_url: typing.Optional[str] = None,
60
+ environment: phenomlEnvironment = phenomlEnvironment.DEFAULT,
61
+ token: typing.Union[str, typing.Callable[[], str]],
62
+ headers: typing.Optional[typing.Dict[str, str]] = None,
63
+ timeout: typing.Optional[float] = None,
64
+ follow_redirects: typing.Optional[bool] = True,
65
+ httpx_client: typing.Optional[httpx.Client] = None,
66
+ ):
67
+ _defaulted_timeout = (
68
+ timeout if timeout is not None else 60 if httpx_client is None else httpx_client.timeout.read
69
+ )
70
+ self._client_wrapper = SyncClientWrapper(
71
+ base_url=_get_base_url(base_url=base_url, environment=environment),
72
+ token=token,
73
+ headers=headers,
74
+ httpx_client=httpx_client
75
+ if httpx_client is not None
76
+ else httpx.Client(timeout=_defaulted_timeout, follow_redirects=follow_redirects)
77
+ if follow_redirects is not None
78
+ else httpx.Client(timeout=_defaulted_timeout),
79
+ timeout=_defaulted_timeout,
80
+ )
81
+ self.agent = AgentClient(client_wrapper=self._client_wrapper)
82
+ self.authtoken = AuthtokenClient(client_wrapper=self._client_wrapper)
83
+ self.cohort = CohortClient(client_wrapper=self._client_wrapper)
84
+ self.construe = ConstrueClient(client_wrapper=self._client_wrapper)
85
+ self.lang2fhir = Lang2FhirClient(client_wrapper=self._client_wrapper)
86
+ self.tools = ToolsClient(client_wrapper=self._client_wrapper)
87
+
88
+
89
+ class Asyncphenoml:
90
+ """
91
+ Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions.
92
+
93
+ Parameters
94
+ ----------
95
+ base_url : typing.Optional[str]
96
+ The base url to use for requests from the client.
97
+
98
+ environment : phenomlEnvironment
99
+ The environment to use for requests from the client. from .environment import phenomlEnvironment
100
+
101
+
102
+
103
+ Defaults to phenomlEnvironment.DEFAULT
104
+
105
+
106
+
107
+ token : typing.Union[str, typing.Callable[[], str]]
108
+ headers : typing.Optional[typing.Dict[str, str]]
109
+ Additional headers to send with every request.
110
+
111
+ timeout : typing.Optional[float]
112
+ The timeout to be used, in seconds, for requests. By default the timeout is 60 seconds, unless a custom httpx client is used, in which case this default is not enforced.
113
+
114
+ follow_redirects : typing.Optional[bool]
115
+ Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.
116
+
117
+ httpx_client : typing.Optional[httpx.AsyncClient]
118
+ The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration.
119
+
120
+ Examples
121
+ --------
122
+ from phenoml import Asyncphenoml
123
+
124
+ client = Asyncphenoml(
125
+ token="YOUR_TOKEN",
126
+ )
127
+ """
128
+
129
+ def __init__(
130
+ self,
131
+ *,
132
+ base_url: typing.Optional[str] = None,
133
+ environment: phenomlEnvironment = phenomlEnvironment.DEFAULT,
134
+ token: typing.Union[str, typing.Callable[[], str]],
135
+ headers: typing.Optional[typing.Dict[str, str]] = None,
136
+ timeout: typing.Optional[float] = None,
137
+ follow_redirects: typing.Optional[bool] = True,
138
+ httpx_client: typing.Optional[httpx.AsyncClient] = None,
139
+ ):
140
+ _defaulted_timeout = (
141
+ timeout if timeout is not None else 60 if httpx_client is None else httpx_client.timeout.read
142
+ )
143
+ self._client_wrapper = AsyncClientWrapper(
144
+ base_url=_get_base_url(base_url=base_url, environment=environment),
145
+ token=token,
146
+ headers=headers,
147
+ httpx_client=httpx_client
148
+ if httpx_client is not None
149
+ else httpx.AsyncClient(timeout=_defaulted_timeout, follow_redirects=follow_redirects)
150
+ if follow_redirects is not None
151
+ else httpx.AsyncClient(timeout=_defaulted_timeout),
152
+ timeout=_defaulted_timeout,
153
+ )
154
+ self.agent = AsyncAgentClient(client_wrapper=self._client_wrapper)
155
+ self.authtoken = AsyncAuthtokenClient(client_wrapper=self._client_wrapper)
156
+ self.cohort = AsyncCohortClient(client_wrapper=self._client_wrapper)
157
+ self.construe = AsyncConstrueClient(client_wrapper=self._client_wrapper)
158
+ self.lang2fhir = AsyncLang2FhirClient(client_wrapper=self._client_wrapper)
159
+ self.tools = AsyncToolsClient(client_wrapper=self._client_wrapper)
160
+
161
+
162
+ def _get_base_url(*, base_url: typing.Optional[str] = None, environment: phenomlEnvironment) -> str:
163
+ if base_url is not None:
164
+ return base_url
165
+ elif environment is not None:
166
+ return environment.value
167
+ else:
168
+ raise Exception("Please pass in either base_url or environment to construct the client")
@@ -0,0 +1,8 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ # isort: skip_file
4
+
5
+ from .types import CohortResponse, SearchConcept
6
+ from .errors import BadRequestError, InternalServerError, UnauthorizedError
7
+
8
+ __all__ = ["BadRequestError", "CohortResponse", "InternalServerError", "SearchConcept", "UnauthorizedError"]
@@ -0,0 +1,113 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
6
+ from ..core.request_options import RequestOptions
7
+ from .raw_client import AsyncRawCohortClient, RawCohortClient
8
+ from .types.cohort_response import CohortResponse
9
+
10
+ # this is used as the default value for optional parameters
11
+ OMIT = typing.cast(typing.Any, ...)
12
+
13
+
14
+ class CohortClient:
15
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
16
+ self._raw_client = RawCohortClient(client_wrapper=client_wrapper)
17
+
18
+ @property
19
+ def with_raw_response(self) -> RawCohortClient:
20
+ """
21
+ Retrieves a raw implementation of this client that returns raw responses.
22
+
23
+ Returns
24
+ -------
25
+ RawCohortClient
26
+ """
27
+ return self._raw_client
28
+
29
+ def analyze(self, *, text: str, request_options: typing.Optional[RequestOptions] = None) -> CohortResponse:
30
+ """
31
+ Converts natural language text into structured FHIR search queries for patient cohort analysis
32
+
33
+ Parameters
34
+ ----------
35
+ text : str
36
+ Natural language text describing patient cohort criteria
37
+
38
+ request_options : typing.Optional[RequestOptions]
39
+ Request-specific configuration.
40
+
41
+ Returns
42
+ -------
43
+ CohortResponse
44
+ Successfully analyzed cohort criteria
45
+
46
+ Examples
47
+ --------
48
+ from phenoml import phenoml
49
+
50
+ client = phenoml(
51
+ token="YOUR_TOKEN",
52
+ )
53
+ client.cohort.analyze(
54
+ text="female patients over 65 with diabetes but not hypertension",
55
+ )
56
+ """
57
+ _response = self._raw_client.analyze(text=text, request_options=request_options)
58
+ return _response.data
59
+
60
+
61
+ class AsyncCohortClient:
62
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
63
+ self._raw_client = AsyncRawCohortClient(client_wrapper=client_wrapper)
64
+
65
+ @property
66
+ def with_raw_response(self) -> AsyncRawCohortClient:
67
+ """
68
+ Retrieves a raw implementation of this client that returns raw responses.
69
+
70
+ Returns
71
+ -------
72
+ AsyncRawCohortClient
73
+ """
74
+ return self._raw_client
75
+
76
+ async def analyze(self, *, text: str, request_options: typing.Optional[RequestOptions] = None) -> CohortResponse:
77
+ """
78
+ Converts natural language text into structured FHIR search queries for patient cohort analysis
79
+
80
+ Parameters
81
+ ----------
82
+ text : str
83
+ Natural language text describing patient cohort criteria
84
+
85
+ request_options : typing.Optional[RequestOptions]
86
+ Request-specific configuration.
87
+
88
+ Returns
89
+ -------
90
+ CohortResponse
91
+ Successfully analyzed cohort criteria
92
+
93
+ Examples
94
+ --------
95
+ import asyncio
96
+
97
+ from phenoml import Asyncphenoml
98
+
99
+ client = Asyncphenoml(
100
+ token="YOUR_TOKEN",
101
+ )
102
+
103
+
104
+ async def main() -> None:
105
+ await client.cohort.analyze(
106
+ text="female patients over 65 with diabetes but not hypertension",
107
+ )
108
+
109
+
110
+ asyncio.run(main())
111
+ """
112
+ _response = await self._raw_client.analyze(text=text, request_options=request_options)
113
+ return _response.data
@@ -0,0 +1,9 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ # isort: skip_file
4
+
5
+ from .bad_request_error import BadRequestError
6
+ from .internal_server_error import InternalServerError
7
+ from .unauthorized_error import UnauthorizedError
8
+
9
+ __all__ = ["BadRequestError", "InternalServerError", "UnauthorizedError"]
@@ -0,0 +1,10 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ from ...core.api_error import ApiError
6
+
7
+
8
+ class BadRequestError(ApiError):
9
+ def __init__(self, body: typing.Optional[typing.Any], headers: typing.Optional[typing.Dict[str, str]] = None):
10
+ super().__init__(status_code=400, headers=headers, body=body)
@@ -0,0 +1,10 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ from ...core.api_error import ApiError
6
+
7
+
8
+ class InternalServerError(ApiError):
9
+ def __init__(self, body: typing.Optional[typing.Any], headers: typing.Optional[typing.Dict[str, str]] = None):
10
+ super().__init__(status_code=500, headers=headers, body=body)
@@ -0,0 +1,10 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ from ...core.api_error import ApiError
6
+
7
+
8
+ class UnauthorizedError(ApiError):
9
+ def __init__(self, body: typing.Optional[typing.Any], headers: typing.Optional[typing.Dict[str, str]] = None):
10
+ super().__init__(status_code=401, headers=headers, body=body)