phenostore-sdk-python 0.1.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.
- phenostore/__init__.py +26 -0
- phenostore/_auth.py +94 -0
- phenostore/client.py +276 -0
- phenostore/errors.py +93 -0
- phenostore/gen/__init__.py +8 -0
- phenostore/gen/api/__init__.py +1 -0
- phenostore/gen/api/bulk/__init__.py +1 -0
- phenostore/gen/api/bulk/get_bulk_status.py +194 -0
- phenostore/gen/api/bulk/submit_bulk.py +223 -0
- phenostore/gen/api/fhir/__init__.py +1 -0
- phenostore/gen/api/fhir/conditional_delete_resource.py +277 -0
- phenostore/gen/api/fhir/create_resource.py +257 -0
- phenostore/gen/api/fhir/delete_resource.py +212 -0
- phenostore/gen/api/fhir/get_docref.py +281 -0
- phenostore/gen/api/fhir/get_metadata.py +185 -0
- phenostore/gen/api/fhir/get_resource_history.py +240 -0
- phenostore/gen/api/fhir/get_smart_configuration.py +169 -0
- phenostore/gen/api/fhir/patch_resource.py +282 -0
- phenostore/gen/api/fhir/post_docref.py +200 -0
- phenostore/gen/api/fhir/process_bundle.py +201 -0
- phenostore/gen/api/fhir/read_resource.py +214 -0
- phenostore/gen/api/fhir/read_resource_version.py +228 -0
- phenostore/gen/api/fhir/search_resources.py +390 -0
- phenostore/gen/api/fhir/search_resources_post.py +228 -0
- phenostore/gen/api/fhir/update_resource.py +281 -0
- phenostore/gen/api/fhir/validate_resource.py +217 -0
- phenostore/gen/api/o_auth/__init__.py +1 -0
- phenostore/gen/api/o_auth/issue_token.py +186 -0
- phenostore/gen/api/system/__init__.py +1 -0
- phenostore/gen/api/system/get_health.py +128 -0
- phenostore/gen/client.py +280 -0
- phenostore/gen/errors.py +16 -0
- phenostore/gen/models/__init__.py +71 -0
- phenostore/gen/models/bulk_operation_accepted.py +79 -0
- phenostore/gen/models/bulk_operation_accepted_status.py +8 -0
- phenostore/gen/models/bulk_operation_status.py +122 -0
- phenostore/gen/models/bulk_operation_status_code.py +11 -0
- phenostore/gen/models/bundle.py +132 -0
- phenostore/gen/models/bundle_entry.py +128 -0
- phenostore/gen/models/bundle_entry_request.py +70 -0
- phenostore/gen/models/bundle_entry_response.py +97 -0
- phenostore/gen/models/bundle_entry_search.py +69 -0
- phenostore/gen/models/bundle_entry_search_mode.py +9 -0
- phenostore/gen/models/bundle_link.py +69 -0
- phenostore/gen/models/bundle_resource_type.py +8 -0
- phenostore/gen/models/bundle_type.py +11 -0
- phenostore/gen/models/fhir_resource.py +47 -0
- phenostore/gen/models/health_response.py +63 -0
- phenostore/gen/models/health_response_status.py +8 -0
- phenostore/gen/models/issue_severity.py +11 -0
- phenostore/gen/models/issue_token_body.py +91 -0
- phenostore/gen/models/issue_token_body_grant_type.py +8 -0
- phenostore/gen/models/json_patch_item.py +90 -0
- phenostore/gen/models/json_patch_op.py +13 -0
- phenostore/gen/models/o_auth_error.py +69 -0
- phenostore/gen/models/operation_outcome.py +85 -0
- phenostore/gen/models/operation_outcome_issue.py +92 -0
- phenostore/gen/models/operation_outcome_resource_type.py +8 -0
- phenostore/gen/models/post_docref_body.py +124 -0
- phenostore/gen/models/resource_type.py +47 -0
- phenostore/gen/models/search_resources_post_body.py +155 -0
- phenostore/gen/models/search_summary_mode.py +12 -0
- phenostore/gen/models/search_total_mode.py +10 -0
- phenostore/gen/models/smart_configuration.py +111 -0
- phenostore/gen/models/token_response.py +87 -0
- phenostore/gen/models/token_response_token_type.py +8 -0
- phenostore/gen/types.py +54 -0
- phenostore/py.typed +0 -0
- phenostore_sdk_python-0.1.1.dist-info/METADATA +196 -0
- phenostore_sdk_python-0.1.1.dist-info/RECORD +72 -0
- phenostore_sdk_python-0.1.1.dist-info/WHEEL +4 -0
- phenostore_sdk_python-0.1.1.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
from http import HTTPStatus
|
|
2
|
+
from typing import Any
|
|
3
|
+
from urllib.parse import quote
|
|
4
|
+
|
|
5
|
+
import httpx
|
|
6
|
+
|
|
7
|
+
from ... import errors
|
|
8
|
+
from ...client import AuthenticatedClient, Client
|
|
9
|
+
from ...models.bundle import Bundle
|
|
10
|
+
from ...models.fhir_resource import FhirResource
|
|
11
|
+
from ...models.operation_outcome import OperationOutcome
|
|
12
|
+
from ...types import Response
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def _get_kwargs(
|
|
16
|
+
tenant_id: str,
|
|
17
|
+
store_id: str,
|
|
18
|
+
*,
|
|
19
|
+
body: FhirResource,
|
|
20
|
+
) -> dict[str, Any]:
|
|
21
|
+
headers: dict[str, Any] = {}
|
|
22
|
+
|
|
23
|
+
_kwargs: dict[str, Any] = {
|
|
24
|
+
"method": "post",
|
|
25
|
+
"url": "/v1/tenants/{tenant_id}/stores/{store_id}".format(
|
|
26
|
+
tenant_id=quote(str(tenant_id), safe=""),
|
|
27
|
+
store_id=quote(str(store_id), safe=""),
|
|
28
|
+
),
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
_kwargs["json"] = body.to_dict()
|
|
32
|
+
|
|
33
|
+
headers["Content-Type"] = "application/fhir+json"
|
|
34
|
+
|
|
35
|
+
_kwargs["headers"] = headers
|
|
36
|
+
return _kwargs
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def _parse_response(
|
|
40
|
+
*, client: AuthenticatedClient | Client, response: httpx.Response
|
|
41
|
+
) -> Bundle | OperationOutcome | None:
|
|
42
|
+
if response.status_code == 200:
|
|
43
|
+
response_200 = Bundle.from_dict(response.json())
|
|
44
|
+
|
|
45
|
+
return response_200
|
|
46
|
+
|
|
47
|
+
if response.status_code == 400:
|
|
48
|
+
response_400 = OperationOutcome.from_dict(response.json())
|
|
49
|
+
|
|
50
|
+
return response_400
|
|
51
|
+
|
|
52
|
+
if response.status_code == 403:
|
|
53
|
+
response_403 = OperationOutcome.from_dict(response.json())
|
|
54
|
+
|
|
55
|
+
return response_403
|
|
56
|
+
|
|
57
|
+
if client.raise_on_unexpected_status:
|
|
58
|
+
raise errors.UnexpectedStatus(response.status_code, response.content)
|
|
59
|
+
else:
|
|
60
|
+
return None
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def _build_response(
|
|
64
|
+
*, client: AuthenticatedClient | Client, response: httpx.Response
|
|
65
|
+
) -> Response[Bundle | OperationOutcome]:
|
|
66
|
+
return Response(
|
|
67
|
+
status_code=HTTPStatus(response.status_code),
|
|
68
|
+
content=response.content,
|
|
69
|
+
headers=response.headers,
|
|
70
|
+
parsed=_parse_response(client=client, response=response),
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def sync_detailed(
|
|
75
|
+
tenant_id: str,
|
|
76
|
+
store_id: str,
|
|
77
|
+
*,
|
|
78
|
+
client: AuthenticatedClient | Client,
|
|
79
|
+
body: FhirResource,
|
|
80
|
+
) -> Response[Bundle | OperationOutcome]:
|
|
81
|
+
"""Process a FHIR transaction or batch Bundle
|
|
82
|
+
|
|
83
|
+
Args:
|
|
84
|
+
tenant_id (str):
|
|
85
|
+
store_id (str):
|
|
86
|
+
body (FhirResource): An arbitrary FHIR resource stored as raw JSON.
|
|
87
|
+
|
|
88
|
+
Raises:
|
|
89
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
90
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
91
|
+
|
|
92
|
+
Returns:
|
|
93
|
+
Response[Bundle | OperationOutcome]
|
|
94
|
+
"""
|
|
95
|
+
|
|
96
|
+
kwargs = _get_kwargs(
|
|
97
|
+
tenant_id=tenant_id,
|
|
98
|
+
store_id=store_id,
|
|
99
|
+
body=body,
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
response = client.get_httpx_client().request(
|
|
103
|
+
**kwargs,
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
return _build_response(client=client, response=response)
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def sync(
|
|
110
|
+
tenant_id: str,
|
|
111
|
+
store_id: str,
|
|
112
|
+
*,
|
|
113
|
+
client: AuthenticatedClient | Client,
|
|
114
|
+
body: FhirResource,
|
|
115
|
+
) -> Bundle | OperationOutcome | None:
|
|
116
|
+
"""Process a FHIR transaction or batch Bundle
|
|
117
|
+
|
|
118
|
+
Args:
|
|
119
|
+
tenant_id (str):
|
|
120
|
+
store_id (str):
|
|
121
|
+
body (FhirResource): An arbitrary FHIR resource stored as raw JSON.
|
|
122
|
+
|
|
123
|
+
Raises:
|
|
124
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
125
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
126
|
+
|
|
127
|
+
Returns:
|
|
128
|
+
Bundle | OperationOutcome
|
|
129
|
+
"""
|
|
130
|
+
|
|
131
|
+
return sync_detailed(
|
|
132
|
+
tenant_id=tenant_id,
|
|
133
|
+
store_id=store_id,
|
|
134
|
+
client=client,
|
|
135
|
+
body=body,
|
|
136
|
+
).parsed
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
async def asyncio_detailed(
|
|
140
|
+
tenant_id: str,
|
|
141
|
+
store_id: str,
|
|
142
|
+
*,
|
|
143
|
+
client: AuthenticatedClient | Client,
|
|
144
|
+
body: FhirResource,
|
|
145
|
+
) -> Response[Bundle | OperationOutcome]:
|
|
146
|
+
"""Process a FHIR transaction or batch Bundle
|
|
147
|
+
|
|
148
|
+
Args:
|
|
149
|
+
tenant_id (str):
|
|
150
|
+
store_id (str):
|
|
151
|
+
body (FhirResource): An arbitrary FHIR resource stored as raw JSON.
|
|
152
|
+
|
|
153
|
+
Raises:
|
|
154
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
155
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
156
|
+
|
|
157
|
+
Returns:
|
|
158
|
+
Response[Bundle | OperationOutcome]
|
|
159
|
+
"""
|
|
160
|
+
|
|
161
|
+
kwargs = _get_kwargs(
|
|
162
|
+
tenant_id=tenant_id,
|
|
163
|
+
store_id=store_id,
|
|
164
|
+
body=body,
|
|
165
|
+
)
|
|
166
|
+
|
|
167
|
+
response = await client.get_async_httpx_client().request(**kwargs)
|
|
168
|
+
|
|
169
|
+
return _build_response(client=client, response=response)
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
async def asyncio(
|
|
173
|
+
tenant_id: str,
|
|
174
|
+
store_id: str,
|
|
175
|
+
*,
|
|
176
|
+
client: AuthenticatedClient | Client,
|
|
177
|
+
body: FhirResource,
|
|
178
|
+
) -> Bundle | OperationOutcome | None:
|
|
179
|
+
"""Process a FHIR transaction or batch Bundle
|
|
180
|
+
|
|
181
|
+
Args:
|
|
182
|
+
tenant_id (str):
|
|
183
|
+
store_id (str):
|
|
184
|
+
body (FhirResource): An arbitrary FHIR resource stored as raw JSON.
|
|
185
|
+
|
|
186
|
+
Raises:
|
|
187
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
188
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
189
|
+
|
|
190
|
+
Returns:
|
|
191
|
+
Bundle | OperationOutcome
|
|
192
|
+
"""
|
|
193
|
+
|
|
194
|
+
return (
|
|
195
|
+
await asyncio_detailed(
|
|
196
|
+
tenant_id=tenant_id,
|
|
197
|
+
store_id=store_id,
|
|
198
|
+
client=client,
|
|
199
|
+
body=body,
|
|
200
|
+
)
|
|
201
|
+
).parsed
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
from http import HTTPStatus
|
|
2
|
+
from typing import Any
|
|
3
|
+
from urllib.parse import quote
|
|
4
|
+
|
|
5
|
+
import httpx
|
|
6
|
+
|
|
7
|
+
from ... import errors
|
|
8
|
+
from ...client import AuthenticatedClient, Client
|
|
9
|
+
from ...models.fhir_resource import FhirResource
|
|
10
|
+
from ...models.operation_outcome import OperationOutcome
|
|
11
|
+
from ...models.resource_type import ResourceType
|
|
12
|
+
from ...types import Response
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def _get_kwargs(
|
|
16
|
+
tenant_id: str,
|
|
17
|
+
store_id: str,
|
|
18
|
+
resource_type: ResourceType,
|
|
19
|
+
id: str,
|
|
20
|
+
) -> dict[str, Any]:
|
|
21
|
+
|
|
22
|
+
_kwargs: dict[str, Any] = {
|
|
23
|
+
"method": "get",
|
|
24
|
+
"url": "/v1/tenants/{tenant_id}/stores/{store_id}/{resource_type}/{id}".format(
|
|
25
|
+
tenant_id=quote(str(tenant_id), safe=""),
|
|
26
|
+
store_id=quote(str(store_id), safe=""),
|
|
27
|
+
resource_type=quote(str(resource_type), safe=""),
|
|
28
|
+
id=quote(str(id), safe=""),
|
|
29
|
+
),
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return _kwargs
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def _parse_response(
|
|
36
|
+
*, client: AuthenticatedClient | Client, response: httpx.Response
|
|
37
|
+
) -> FhirResource | OperationOutcome | None:
|
|
38
|
+
if response.status_code == 200:
|
|
39
|
+
response_200 = FhirResource.from_dict(response.json())
|
|
40
|
+
|
|
41
|
+
return response_200
|
|
42
|
+
|
|
43
|
+
if response.status_code == 403:
|
|
44
|
+
response_403 = OperationOutcome.from_dict(response.json())
|
|
45
|
+
|
|
46
|
+
return response_403
|
|
47
|
+
|
|
48
|
+
if response.status_code == 404:
|
|
49
|
+
response_404 = OperationOutcome.from_dict(response.json())
|
|
50
|
+
|
|
51
|
+
return response_404
|
|
52
|
+
|
|
53
|
+
if response.status_code == 410:
|
|
54
|
+
response_410 = OperationOutcome.from_dict(response.json())
|
|
55
|
+
|
|
56
|
+
return response_410
|
|
57
|
+
|
|
58
|
+
if client.raise_on_unexpected_status:
|
|
59
|
+
raise errors.UnexpectedStatus(response.status_code, response.content)
|
|
60
|
+
else:
|
|
61
|
+
return None
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def _build_response(
|
|
65
|
+
*, client: AuthenticatedClient | Client, response: httpx.Response
|
|
66
|
+
) -> Response[FhirResource | OperationOutcome]:
|
|
67
|
+
return Response(
|
|
68
|
+
status_code=HTTPStatus(response.status_code),
|
|
69
|
+
content=response.content,
|
|
70
|
+
headers=response.headers,
|
|
71
|
+
parsed=_parse_response(client=client, response=response),
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def sync_detailed(
|
|
76
|
+
tenant_id: str,
|
|
77
|
+
store_id: str,
|
|
78
|
+
resource_type: ResourceType,
|
|
79
|
+
id: str,
|
|
80
|
+
*,
|
|
81
|
+
client: AuthenticatedClient | Client,
|
|
82
|
+
) -> Response[FhirResource | OperationOutcome]:
|
|
83
|
+
"""Read a FHIR resource
|
|
84
|
+
|
|
85
|
+
Args:
|
|
86
|
+
tenant_id (str):
|
|
87
|
+
store_id (str):
|
|
88
|
+
resource_type (ResourceType): FHIR resource type
|
|
89
|
+
id (str):
|
|
90
|
+
|
|
91
|
+
Raises:
|
|
92
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
93
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
94
|
+
|
|
95
|
+
Returns:
|
|
96
|
+
Response[FhirResource | OperationOutcome]
|
|
97
|
+
"""
|
|
98
|
+
|
|
99
|
+
kwargs = _get_kwargs(
|
|
100
|
+
tenant_id=tenant_id,
|
|
101
|
+
store_id=store_id,
|
|
102
|
+
resource_type=resource_type,
|
|
103
|
+
id=id,
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
response = client.get_httpx_client().request(
|
|
107
|
+
**kwargs,
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
return _build_response(client=client, response=response)
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def sync(
|
|
114
|
+
tenant_id: str,
|
|
115
|
+
store_id: str,
|
|
116
|
+
resource_type: ResourceType,
|
|
117
|
+
id: str,
|
|
118
|
+
*,
|
|
119
|
+
client: AuthenticatedClient | Client,
|
|
120
|
+
) -> FhirResource | OperationOutcome | None:
|
|
121
|
+
"""Read a FHIR resource
|
|
122
|
+
|
|
123
|
+
Args:
|
|
124
|
+
tenant_id (str):
|
|
125
|
+
store_id (str):
|
|
126
|
+
resource_type (ResourceType): FHIR resource type
|
|
127
|
+
id (str):
|
|
128
|
+
|
|
129
|
+
Raises:
|
|
130
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
131
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
132
|
+
|
|
133
|
+
Returns:
|
|
134
|
+
FhirResource | OperationOutcome
|
|
135
|
+
"""
|
|
136
|
+
|
|
137
|
+
return sync_detailed(
|
|
138
|
+
tenant_id=tenant_id,
|
|
139
|
+
store_id=store_id,
|
|
140
|
+
resource_type=resource_type,
|
|
141
|
+
id=id,
|
|
142
|
+
client=client,
|
|
143
|
+
).parsed
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
async def asyncio_detailed(
|
|
147
|
+
tenant_id: str,
|
|
148
|
+
store_id: str,
|
|
149
|
+
resource_type: ResourceType,
|
|
150
|
+
id: str,
|
|
151
|
+
*,
|
|
152
|
+
client: AuthenticatedClient | Client,
|
|
153
|
+
) -> Response[FhirResource | OperationOutcome]:
|
|
154
|
+
"""Read a FHIR resource
|
|
155
|
+
|
|
156
|
+
Args:
|
|
157
|
+
tenant_id (str):
|
|
158
|
+
store_id (str):
|
|
159
|
+
resource_type (ResourceType): FHIR resource type
|
|
160
|
+
id (str):
|
|
161
|
+
|
|
162
|
+
Raises:
|
|
163
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
164
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
165
|
+
|
|
166
|
+
Returns:
|
|
167
|
+
Response[FhirResource | OperationOutcome]
|
|
168
|
+
"""
|
|
169
|
+
|
|
170
|
+
kwargs = _get_kwargs(
|
|
171
|
+
tenant_id=tenant_id,
|
|
172
|
+
store_id=store_id,
|
|
173
|
+
resource_type=resource_type,
|
|
174
|
+
id=id,
|
|
175
|
+
)
|
|
176
|
+
|
|
177
|
+
response = await client.get_async_httpx_client().request(**kwargs)
|
|
178
|
+
|
|
179
|
+
return _build_response(client=client, response=response)
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
async def asyncio(
|
|
183
|
+
tenant_id: str,
|
|
184
|
+
store_id: str,
|
|
185
|
+
resource_type: ResourceType,
|
|
186
|
+
id: str,
|
|
187
|
+
*,
|
|
188
|
+
client: AuthenticatedClient | Client,
|
|
189
|
+
) -> FhirResource | OperationOutcome | None:
|
|
190
|
+
"""Read a FHIR resource
|
|
191
|
+
|
|
192
|
+
Args:
|
|
193
|
+
tenant_id (str):
|
|
194
|
+
store_id (str):
|
|
195
|
+
resource_type (ResourceType): FHIR resource type
|
|
196
|
+
id (str):
|
|
197
|
+
|
|
198
|
+
Raises:
|
|
199
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
200
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
201
|
+
|
|
202
|
+
Returns:
|
|
203
|
+
FhirResource | OperationOutcome
|
|
204
|
+
"""
|
|
205
|
+
|
|
206
|
+
return (
|
|
207
|
+
await asyncio_detailed(
|
|
208
|
+
tenant_id=tenant_id,
|
|
209
|
+
store_id=store_id,
|
|
210
|
+
resource_type=resource_type,
|
|
211
|
+
id=id,
|
|
212
|
+
client=client,
|
|
213
|
+
)
|
|
214
|
+
).parsed
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
from http import HTTPStatus
|
|
2
|
+
from typing import Any
|
|
3
|
+
from urllib.parse import quote
|
|
4
|
+
|
|
5
|
+
import httpx
|
|
6
|
+
|
|
7
|
+
from ... import errors
|
|
8
|
+
from ...client import AuthenticatedClient, Client
|
|
9
|
+
from ...models.fhir_resource import FhirResource
|
|
10
|
+
from ...models.operation_outcome import OperationOutcome
|
|
11
|
+
from ...models.resource_type import ResourceType
|
|
12
|
+
from ...types import Response
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def _get_kwargs(
|
|
16
|
+
tenant_id: str,
|
|
17
|
+
store_id: str,
|
|
18
|
+
resource_type: ResourceType,
|
|
19
|
+
id: str,
|
|
20
|
+
version_id: int,
|
|
21
|
+
) -> dict[str, Any]:
|
|
22
|
+
|
|
23
|
+
_kwargs: dict[str, Any] = {
|
|
24
|
+
"method": "get",
|
|
25
|
+
"url": "/v1/tenants/{tenant_id}/stores/{store_id}/{resource_type}/{id}/_history/{version_id}".format(
|
|
26
|
+
tenant_id=quote(str(tenant_id), safe=""),
|
|
27
|
+
store_id=quote(str(store_id), safe=""),
|
|
28
|
+
resource_type=quote(str(resource_type), safe=""),
|
|
29
|
+
id=quote(str(id), safe=""),
|
|
30
|
+
version_id=quote(str(version_id), safe=""),
|
|
31
|
+
),
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return _kwargs
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def _parse_response(
|
|
38
|
+
*, client: AuthenticatedClient | Client, response: httpx.Response
|
|
39
|
+
) -> FhirResource | OperationOutcome | None:
|
|
40
|
+
if response.status_code == 200:
|
|
41
|
+
response_200 = FhirResource.from_dict(response.json())
|
|
42
|
+
|
|
43
|
+
return response_200
|
|
44
|
+
|
|
45
|
+
if response.status_code == 400:
|
|
46
|
+
response_400 = OperationOutcome.from_dict(response.json())
|
|
47
|
+
|
|
48
|
+
return response_400
|
|
49
|
+
|
|
50
|
+
if response.status_code == 403:
|
|
51
|
+
response_403 = OperationOutcome.from_dict(response.json())
|
|
52
|
+
|
|
53
|
+
return response_403
|
|
54
|
+
|
|
55
|
+
if response.status_code == 404:
|
|
56
|
+
response_404 = OperationOutcome.from_dict(response.json())
|
|
57
|
+
|
|
58
|
+
return response_404
|
|
59
|
+
|
|
60
|
+
if client.raise_on_unexpected_status:
|
|
61
|
+
raise errors.UnexpectedStatus(response.status_code, response.content)
|
|
62
|
+
else:
|
|
63
|
+
return None
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def _build_response(
|
|
67
|
+
*, client: AuthenticatedClient | Client, response: httpx.Response
|
|
68
|
+
) -> Response[FhirResource | OperationOutcome]:
|
|
69
|
+
return Response(
|
|
70
|
+
status_code=HTTPStatus(response.status_code),
|
|
71
|
+
content=response.content,
|
|
72
|
+
headers=response.headers,
|
|
73
|
+
parsed=_parse_response(client=client, response=response),
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def sync_detailed(
|
|
78
|
+
tenant_id: str,
|
|
79
|
+
store_id: str,
|
|
80
|
+
resource_type: ResourceType,
|
|
81
|
+
id: str,
|
|
82
|
+
version_id: int,
|
|
83
|
+
*,
|
|
84
|
+
client: AuthenticatedClient | Client,
|
|
85
|
+
) -> Response[FhirResource | OperationOutcome]:
|
|
86
|
+
"""Read a specific version of a FHIR resource
|
|
87
|
+
|
|
88
|
+
Args:
|
|
89
|
+
tenant_id (str):
|
|
90
|
+
store_id (str):
|
|
91
|
+
resource_type (ResourceType): FHIR resource type
|
|
92
|
+
id (str):
|
|
93
|
+
version_id (int):
|
|
94
|
+
|
|
95
|
+
Raises:
|
|
96
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
97
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
98
|
+
|
|
99
|
+
Returns:
|
|
100
|
+
Response[FhirResource | OperationOutcome]
|
|
101
|
+
"""
|
|
102
|
+
|
|
103
|
+
kwargs = _get_kwargs(
|
|
104
|
+
tenant_id=tenant_id,
|
|
105
|
+
store_id=store_id,
|
|
106
|
+
resource_type=resource_type,
|
|
107
|
+
id=id,
|
|
108
|
+
version_id=version_id,
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
response = client.get_httpx_client().request(
|
|
112
|
+
**kwargs,
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
return _build_response(client=client, response=response)
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
def sync(
|
|
119
|
+
tenant_id: str,
|
|
120
|
+
store_id: str,
|
|
121
|
+
resource_type: ResourceType,
|
|
122
|
+
id: str,
|
|
123
|
+
version_id: int,
|
|
124
|
+
*,
|
|
125
|
+
client: AuthenticatedClient | Client,
|
|
126
|
+
) -> FhirResource | OperationOutcome | None:
|
|
127
|
+
"""Read a specific version of a FHIR resource
|
|
128
|
+
|
|
129
|
+
Args:
|
|
130
|
+
tenant_id (str):
|
|
131
|
+
store_id (str):
|
|
132
|
+
resource_type (ResourceType): FHIR resource type
|
|
133
|
+
id (str):
|
|
134
|
+
version_id (int):
|
|
135
|
+
|
|
136
|
+
Raises:
|
|
137
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
138
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
139
|
+
|
|
140
|
+
Returns:
|
|
141
|
+
FhirResource | OperationOutcome
|
|
142
|
+
"""
|
|
143
|
+
|
|
144
|
+
return sync_detailed(
|
|
145
|
+
tenant_id=tenant_id,
|
|
146
|
+
store_id=store_id,
|
|
147
|
+
resource_type=resource_type,
|
|
148
|
+
id=id,
|
|
149
|
+
version_id=version_id,
|
|
150
|
+
client=client,
|
|
151
|
+
).parsed
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
async def asyncio_detailed(
|
|
155
|
+
tenant_id: str,
|
|
156
|
+
store_id: str,
|
|
157
|
+
resource_type: ResourceType,
|
|
158
|
+
id: str,
|
|
159
|
+
version_id: int,
|
|
160
|
+
*,
|
|
161
|
+
client: AuthenticatedClient | Client,
|
|
162
|
+
) -> Response[FhirResource | OperationOutcome]:
|
|
163
|
+
"""Read a specific version of a FHIR resource
|
|
164
|
+
|
|
165
|
+
Args:
|
|
166
|
+
tenant_id (str):
|
|
167
|
+
store_id (str):
|
|
168
|
+
resource_type (ResourceType): FHIR resource type
|
|
169
|
+
id (str):
|
|
170
|
+
version_id (int):
|
|
171
|
+
|
|
172
|
+
Raises:
|
|
173
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
174
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
175
|
+
|
|
176
|
+
Returns:
|
|
177
|
+
Response[FhirResource | OperationOutcome]
|
|
178
|
+
"""
|
|
179
|
+
|
|
180
|
+
kwargs = _get_kwargs(
|
|
181
|
+
tenant_id=tenant_id,
|
|
182
|
+
store_id=store_id,
|
|
183
|
+
resource_type=resource_type,
|
|
184
|
+
id=id,
|
|
185
|
+
version_id=version_id,
|
|
186
|
+
)
|
|
187
|
+
|
|
188
|
+
response = await client.get_async_httpx_client().request(**kwargs)
|
|
189
|
+
|
|
190
|
+
return _build_response(client=client, response=response)
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
async def asyncio(
|
|
194
|
+
tenant_id: str,
|
|
195
|
+
store_id: str,
|
|
196
|
+
resource_type: ResourceType,
|
|
197
|
+
id: str,
|
|
198
|
+
version_id: int,
|
|
199
|
+
*,
|
|
200
|
+
client: AuthenticatedClient | Client,
|
|
201
|
+
) -> FhirResource | OperationOutcome | None:
|
|
202
|
+
"""Read a specific version of a FHIR resource
|
|
203
|
+
|
|
204
|
+
Args:
|
|
205
|
+
tenant_id (str):
|
|
206
|
+
store_id (str):
|
|
207
|
+
resource_type (ResourceType): FHIR resource type
|
|
208
|
+
id (str):
|
|
209
|
+
version_id (int):
|
|
210
|
+
|
|
211
|
+
Raises:
|
|
212
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
213
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
214
|
+
|
|
215
|
+
Returns:
|
|
216
|
+
FhirResource | OperationOutcome
|
|
217
|
+
"""
|
|
218
|
+
|
|
219
|
+
return (
|
|
220
|
+
await asyncio_detailed(
|
|
221
|
+
tenant_id=tenant_id,
|
|
222
|
+
store_id=store_id,
|
|
223
|
+
resource_type=resource_type,
|
|
224
|
+
id=id,
|
|
225
|
+
version_id=version_id,
|
|
226
|
+
client=client,
|
|
227
|
+
)
|
|
228
|
+
).parsed
|