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,169 @@
|
|
|
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.smart_configuration import SmartConfiguration
|
|
10
|
+
from ...types import Response
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def _get_kwargs(
|
|
14
|
+
tenant_id: str,
|
|
15
|
+
store_id: str,
|
|
16
|
+
) -> dict[str, Any]:
|
|
17
|
+
|
|
18
|
+
_kwargs: dict[str, Any] = {
|
|
19
|
+
"method": "get",
|
|
20
|
+
"url": "/v1/tenants/{tenant_id}/stores/{store_id}/.well-known/smart-configuration".format(
|
|
21
|
+
tenant_id=quote(str(tenant_id), safe=""),
|
|
22
|
+
store_id=quote(str(store_id), safe=""),
|
|
23
|
+
),
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return _kwargs
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def _parse_response(
|
|
30
|
+
*, client: AuthenticatedClient | Client, response: httpx.Response
|
|
31
|
+
) -> SmartConfiguration | None:
|
|
32
|
+
if response.status_code == 200:
|
|
33
|
+
response_200 = SmartConfiguration.from_dict(response.json())
|
|
34
|
+
|
|
35
|
+
return response_200
|
|
36
|
+
|
|
37
|
+
if client.raise_on_unexpected_status:
|
|
38
|
+
raise errors.UnexpectedStatus(response.status_code, response.content)
|
|
39
|
+
else:
|
|
40
|
+
return None
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def _build_response(
|
|
44
|
+
*, client: AuthenticatedClient | Client, response: httpx.Response
|
|
45
|
+
) -> Response[SmartConfiguration]:
|
|
46
|
+
return Response(
|
|
47
|
+
status_code=HTTPStatus(response.status_code),
|
|
48
|
+
content=response.content,
|
|
49
|
+
headers=response.headers,
|
|
50
|
+
parsed=_parse_response(client=client, response=response),
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def sync_detailed(
|
|
55
|
+
tenant_id: str,
|
|
56
|
+
store_id: str,
|
|
57
|
+
*,
|
|
58
|
+
client: AuthenticatedClient | Client,
|
|
59
|
+
) -> Response[SmartConfiguration]:
|
|
60
|
+
"""SMART on FHIR well-known configuration
|
|
61
|
+
|
|
62
|
+
Args:
|
|
63
|
+
tenant_id (str):
|
|
64
|
+
store_id (str):
|
|
65
|
+
|
|
66
|
+
Raises:
|
|
67
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
68
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
69
|
+
|
|
70
|
+
Returns:
|
|
71
|
+
Response[SmartConfiguration]
|
|
72
|
+
"""
|
|
73
|
+
|
|
74
|
+
kwargs = _get_kwargs(
|
|
75
|
+
tenant_id=tenant_id,
|
|
76
|
+
store_id=store_id,
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
response = client.get_httpx_client().request(
|
|
80
|
+
**kwargs,
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
return _build_response(client=client, response=response)
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def sync(
|
|
87
|
+
tenant_id: str,
|
|
88
|
+
store_id: str,
|
|
89
|
+
*,
|
|
90
|
+
client: AuthenticatedClient | Client,
|
|
91
|
+
) -> SmartConfiguration | None:
|
|
92
|
+
"""SMART on FHIR well-known configuration
|
|
93
|
+
|
|
94
|
+
Args:
|
|
95
|
+
tenant_id (str):
|
|
96
|
+
store_id (str):
|
|
97
|
+
|
|
98
|
+
Raises:
|
|
99
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
100
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
101
|
+
|
|
102
|
+
Returns:
|
|
103
|
+
SmartConfiguration
|
|
104
|
+
"""
|
|
105
|
+
|
|
106
|
+
return sync_detailed(
|
|
107
|
+
tenant_id=tenant_id,
|
|
108
|
+
store_id=store_id,
|
|
109
|
+
client=client,
|
|
110
|
+
).parsed
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
async def asyncio_detailed(
|
|
114
|
+
tenant_id: str,
|
|
115
|
+
store_id: str,
|
|
116
|
+
*,
|
|
117
|
+
client: AuthenticatedClient | Client,
|
|
118
|
+
) -> Response[SmartConfiguration]:
|
|
119
|
+
"""SMART on FHIR well-known configuration
|
|
120
|
+
|
|
121
|
+
Args:
|
|
122
|
+
tenant_id (str):
|
|
123
|
+
store_id (str):
|
|
124
|
+
|
|
125
|
+
Raises:
|
|
126
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
127
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
128
|
+
|
|
129
|
+
Returns:
|
|
130
|
+
Response[SmartConfiguration]
|
|
131
|
+
"""
|
|
132
|
+
|
|
133
|
+
kwargs = _get_kwargs(
|
|
134
|
+
tenant_id=tenant_id,
|
|
135
|
+
store_id=store_id,
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
response = await client.get_async_httpx_client().request(**kwargs)
|
|
139
|
+
|
|
140
|
+
return _build_response(client=client, response=response)
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
async def asyncio(
|
|
144
|
+
tenant_id: str,
|
|
145
|
+
store_id: str,
|
|
146
|
+
*,
|
|
147
|
+
client: AuthenticatedClient | Client,
|
|
148
|
+
) -> SmartConfiguration | None:
|
|
149
|
+
"""SMART on FHIR well-known configuration
|
|
150
|
+
|
|
151
|
+
Args:
|
|
152
|
+
tenant_id (str):
|
|
153
|
+
store_id (str):
|
|
154
|
+
|
|
155
|
+
Raises:
|
|
156
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
157
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
158
|
+
|
|
159
|
+
Returns:
|
|
160
|
+
SmartConfiguration
|
|
161
|
+
"""
|
|
162
|
+
|
|
163
|
+
return (
|
|
164
|
+
await asyncio_detailed(
|
|
165
|
+
tenant_id=tenant_id,
|
|
166
|
+
store_id=store_id,
|
|
167
|
+
client=client,
|
|
168
|
+
)
|
|
169
|
+
).parsed
|
|
@@ -0,0 +1,282 @@
|
|
|
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.json_patch_item import JsonPatchItem
|
|
11
|
+
from ...models.operation_outcome import OperationOutcome
|
|
12
|
+
from ...models.resource_type import ResourceType
|
|
13
|
+
from ...types import UNSET, Response, Unset
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def _get_kwargs(
|
|
17
|
+
tenant_id: str,
|
|
18
|
+
store_id: str,
|
|
19
|
+
resource_type: ResourceType,
|
|
20
|
+
id: str,
|
|
21
|
+
*,
|
|
22
|
+
body: list[JsonPatchItem],
|
|
23
|
+
if_match: str | Unset = UNSET,
|
|
24
|
+
) -> dict[str, Any]:
|
|
25
|
+
headers: dict[str, Any] = {}
|
|
26
|
+
if not isinstance(if_match, Unset):
|
|
27
|
+
headers["If-Match"] = if_match
|
|
28
|
+
|
|
29
|
+
_kwargs: dict[str, Any] = {
|
|
30
|
+
"method": "patch",
|
|
31
|
+
"url": "/v1/tenants/{tenant_id}/stores/{store_id}/{resource_type}/{id}".format(
|
|
32
|
+
tenant_id=quote(str(tenant_id), safe=""),
|
|
33
|
+
store_id=quote(str(store_id), safe=""),
|
|
34
|
+
resource_type=quote(str(resource_type), safe=""),
|
|
35
|
+
id=quote(str(id), safe=""),
|
|
36
|
+
),
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
_kwargs["json"] = []
|
|
40
|
+
for componentsschemas_json_patch_item_data in body:
|
|
41
|
+
componentsschemas_json_patch_item = (
|
|
42
|
+
componentsschemas_json_patch_item_data.to_dict()
|
|
43
|
+
)
|
|
44
|
+
_kwargs["json"].append(componentsschemas_json_patch_item)
|
|
45
|
+
|
|
46
|
+
headers["Content-Type"] = "application/json-patch+json"
|
|
47
|
+
|
|
48
|
+
_kwargs["headers"] = headers
|
|
49
|
+
return _kwargs
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def _parse_response(
|
|
53
|
+
*, client: AuthenticatedClient | Client, response: httpx.Response
|
|
54
|
+
) -> FhirResource | OperationOutcome | None:
|
|
55
|
+
if response.status_code == 200:
|
|
56
|
+
response_200 = FhirResource.from_dict(response.json())
|
|
57
|
+
|
|
58
|
+
return response_200
|
|
59
|
+
|
|
60
|
+
if response.status_code == 400:
|
|
61
|
+
response_400 = OperationOutcome.from_dict(response.json())
|
|
62
|
+
|
|
63
|
+
return response_400
|
|
64
|
+
|
|
65
|
+
if response.status_code == 403:
|
|
66
|
+
response_403 = OperationOutcome.from_dict(response.json())
|
|
67
|
+
|
|
68
|
+
return response_403
|
|
69
|
+
|
|
70
|
+
if response.status_code == 404:
|
|
71
|
+
response_404 = OperationOutcome.from_dict(response.json())
|
|
72
|
+
|
|
73
|
+
return response_404
|
|
74
|
+
|
|
75
|
+
if response.status_code == 410:
|
|
76
|
+
response_410 = OperationOutcome.from_dict(response.json())
|
|
77
|
+
|
|
78
|
+
return response_410
|
|
79
|
+
|
|
80
|
+
if response.status_code == 412:
|
|
81
|
+
response_412 = OperationOutcome.from_dict(response.json())
|
|
82
|
+
|
|
83
|
+
return response_412
|
|
84
|
+
|
|
85
|
+
if response.status_code == 422:
|
|
86
|
+
response_422 = OperationOutcome.from_dict(response.json())
|
|
87
|
+
|
|
88
|
+
return response_422
|
|
89
|
+
|
|
90
|
+
if client.raise_on_unexpected_status:
|
|
91
|
+
raise errors.UnexpectedStatus(response.status_code, response.content)
|
|
92
|
+
else:
|
|
93
|
+
return None
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def _build_response(
|
|
97
|
+
*, client: AuthenticatedClient | Client, response: httpx.Response
|
|
98
|
+
) -> Response[FhirResource | OperationOutcome]:
|
|
99
|
+
return Response(
|
|
100
|
+
status_code=HTTPStatus(response.status_code),
|
|
101
|
+
content=response.content,
|
|
102
|
+
headers=response.headers,
|
|
103
|
+
parsed=_parse_response(client=client, response=response),
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def sync_detailed(
|
|
108
|
+
tenant_id: str,
|
|
109
|
+
store_id: str,
|
|
110
|
+
resource_type: ResourceType,
|
|
111
|
+
id: str,
|
|
112
|
+
*,
|
|
113
|
+
client: AuthenticatedClient | Client,
|
|
114
|
+
body: list[JsonPatchItem],
|
|
115
|
+
if_match: str | Unset = UNSET,
|
|
116
|
+
) -> Response[FhirResource | OperationOutcome]:
|
|
117
|
+
"""Patch a FHIR resource (JSON Patch)
|
|
118
|
+
|
|
119
|
+
Applies a JSON Patch (RFC 6902) to an existing resource.
|
|
120
|
+
Supports conditional update via the If-Match header.
|
|
121
|
+
|
|
122
|
+
Args:
|
|
123
|
+
tenant_id (str):
|
|
124
|
+
store_id (str):
|
|
125
|
+
resource_type (ResourceType): FHIR resource type
|
|
126
|
+
id (str):
|
|
127
|
+
if_match (str | Unset):
|
|
128
|
+
body (list[JsonPatchItem]): JSON Patch document (RFC 6902)
|
|
129
|
+
|
|
130
|
+
Raises:
|
|
131
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
132
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
133
|
+
|
|
134
|
+
Returns:
|
|
135
|
+
Response[FhirResource | OperationOutcome]
|
|
136
|
+
"""
|
|
137
|
+
|
|
138
|
+
kwargs = _get_kwargs(
|
|
139
|
+
tenant_id=tenant_id,
|
|
140
|
+
store_id=store_id,
|
|
141
|
+
resource_type=resource_type,
|
|
142
|
+
id=id,
|
|
143
|
+
body=body,
|
|
144
|
+
if_match=if_match,
|
|
145
|
+
)
|
|
146
|
+
|
|
147
|
+
response = client.get_httpx_client().request(
|
|
148
|
+
**kwargs,
|
|
149
|
+
)
|
|
150
|
+
|
|
151
|
+
return _build_response(client=client, response=response)
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
def sync(
|
|
155
|
+
tenant_id: str,
|
|
156
|
+
store_id: str,
|
|
157
|
+
resource_type: ResourceType,
|
|
158
|
+
id: str,
|
|
159
|
+
*,
|
|
160
|
+
client: AuthenticatedClient | Client,
|
|
161
|
+
body: list[JsonPatchItem],
|
|
162
|
+
if_match: str | Unset = UNSET,
|
|
163
|
+
) -> FhirResource | OperationOutcome | None:
|
|
164
|
+
"""Patch a FHIR resource (JSON Patch)
|
|
165
|
+
|
|
166
|
+
Applies a JSON Patch (RFC 6902) to an existing resource.
|
|
167
|
+
Supports conditional update via the If-Match header.
|
|
168
|
+
|
|
169
|
+
Args:
|
|
170
|
+
tenant_id (str):
|
|
171
|
+
store_id (str):
|
|
172
|
+
resource_type (ResourceType): FHIR resource type
|
|
173
|
+
id (str):
|
|
174
|
+
if_match (str | Unset):
|
|
175
|
+
body (list[JsonPatchItem]): JSON Patch document (RFC 6902)
|
|
176
|
+
|
|
177
|
+
Raises:
|
|
178
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
179
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
180
|
+
|
|
181
|
+
Returns:
|
|
182
|
+
FhirResource | OperationOutcome
|
|
183
|
+
"""
|
|
184
|
+
|
|
185
|
+
return sync_detailed(
|
|
186
|
+
tenant_id=tenant_id,
|
|
187
|
+
store_id=store_id,
|
|
188
|
+
resource_type=resource_type,
|
|
189
|
+
id=id,
|
|
190
|
+
client=client,
|
|
191
|
+
body=body,
|
|
192
|
+
if_match=if_match,
|
|
193
|
+
).parsed
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
async def asyncio_detailed(
|
|
197
|
+
tenant_id: str,
|
|
198
|
+
store_id: str,
|
|
199
|
+
resource_type: ResourceType,
|
|
200
|
+
id: str,
|
|
201
|
+
*,
|
|
202
|
+
client: AuthenticatedClient | Client,
|
|
203
|
+
body: list[JsonPatchItem],
|
|
204
|
+
if_match: str | Unset = UNSET,
|
|
205
|
+
) -> Response[FhirResource | OperationOutcome]:
|
|
206
|
+
"""Patch a FHIR resource (JSON Patch)
|
|
207
|
+
|
|
208
|
+
Applies a JSON Patch (RFC 6902) to an existing resource.
|
|
209
|
+
Supports conditional update via the If-Match header.
|
|
210
|
+
|
|
211
|
+
Args:
|
|
212
|
+
tenant_id (str):
|
|
213
|
+
store_id (str):
|
|
214
|
+
resource_type (ResourceType): FHIR resource type
|
|
215
|
+
id (str):
|
|
216
|
+
if_match (str | Unset):
|
|
217
|
+
body (list[JsonPatchItem]): JSON Patch document (RFC 6902)
|
|
218
|
+
|
|
219
|
+
Raises:
|
|
220
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
221
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
222
|
+
|
|
223
|
+
Returns:
|
|
224
|
+
Response[FhirResource | OperationOutcome]
|
|
225
|
+
"""
|
|
226
|
+
|
|
227
|
+
kwargs = _get_kwargs(
|
|
228
|
+
tenant_id=tenant_id,
|
|
229
|
+
store_id=store_id,
|
|
230
|
+
resource_type=resource_type,
|
|
231
|
+
id=id,
|
|
232
|
+
body=body,
|
|
233
|
+
if_match=if_match,
|
|
234
|
+
)
|
|
235
|
+
|
|
236
|
+
response = await client.get_async_httpx_client().request(**kwargs)
|
|
237
|
+
|
|
238
|
+
return _build_response(client=client, response=response)
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
async def asyncio(
|
|
242
|
+
tenant_id: str,
|
|
243
|
+
store_id: str,
|
|
244
|
+
resource_type: ResourceType,
|
|
245
|
+
id: str,
|
|
246
|
+
*,
|
|
247
|
+
client: AuthenticatedClient | Client,
|
|
248
|
+
body: list[JsonPatchItem],
|
|
249
|
+
if_match: str | Unset = UNSET,
|
|
250
|
+
) -> FhirResource | OperationOutcome | None:
|
|
251
|
+
"""Patch a FHIR resource (JSON Patch)
|
|
252
|
+
|
|
253
|
+
Applies a JSON Patch (RFC 6902) to an existing resource.
|
|
254
|
+
Supports conditional update via the If-Match header.
|
|
255
|
+
|
|
256
|
+
Args:
|
|
257
|
+
tenant_id (str):
|
|
258
|
+
store_id (str):
|
|
259
|
+
resource_type (ResourceType): FHIR resource type
|
|
260
|
+
id (str):
|
|
261
|
+
if_match (str | Unset):
|
|
262
|
+
body (list[JsonPatchItem]): JSON Patch document (RFC 6902)
|
|
263
|
+
|
|
264
|
+
Raises:
|
|
265
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
266
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
267
|
+
|
|
268
|
+
Returns:
|
|
269
|
+
FhirResource | OperationOutcome
|
|
270
|
+
"""
|
|
271
|
+
|
|
272
|
+
return (
|
|
273
|
+
await asyncio_detailed(
|
|
274
|
+
tenant_id=tenant_id,
|
|
275
|
+
store_id=store_id,
|
|
276
|
+
resource_type=resource_type,
|
|
277
|
+
id=id,
|
|
278
|
+
client=client,
|
|
279
|
+
body=body,
|
|
280
|
+
if_match=if_match,
|
|
281
|
+
)
|
|
282
|
+
).parsed
|
|
@@ -0,0 +1,200 @@
|
|
|
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.operation_outcome import OperationOutcome
|
|
11
|
+
from ...models.post_docref_body import PostDocrefBody
|
|
12
|
+
from ...types import Response
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def _get_kwargs(
|
|
16
|
+
tenant_id: str,
|
|
17
|
+
store_id: str,
|
|
18
|
+
*,
|
|
19
|
+
body: PostDocrefBody,
|
|
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}/DocumentReference/$docref".format(
|
|
26
|
+
tenant_id=quote(str(tenant_id), safe=""),
|
|
27
|
+
store_id=quote(str(store_id), safe=""),
|
|
28
|
+
),
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
_kwargs["data"] = body.to_dict()
|
|
32
|
+
headers["Content-Type"] = "application/x-www-form-urlencoded"
|
|
33
|
+
|
|
34
|
+
_kwargs["headers"] = headers
|
|
35
|
+
return _kwargs
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def _parse_response(
|
|
39
|
+
*, client: AuthenticatedClient | Client, response: httpx.Response
|
|
40
|
+
) -> Bundle | OperationOutcome | None:
|
|
41
|
+
if response.status_code == 200:
|
|
42
|
+
response_200 = Bundle.from_dict(response.json())
|
|
43
|
+
|
|
44
|
+
return response_200
|
|
45
|
+
|
|
46
|
+
if response.status_code == 400:
|
|
47
|
+
response_400 = OperationOutcome.from_dict(response.json())
|
|
48
|
+
|
|
49
|
+
return response_400
|
|
50
|
+
|
|
51
|
+
if response.status_code == 403:
|
|
52
|
+
response_403 = OperationOutcome.from_dict(response.json())
|
|
53
|
+
|
|
54
|
+
return response_403
|
|
55
|
+
|
|
56
|
+
if client.raise_on_unexpected_status:
|
|
57
|
+
raise errors.UnexpectedStatus(response.status_code, response.content)
|
|
58
|
+
else:
|
|
59
|
+
return None
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def _build_response(
|
|
63
|
+
*, client: AuthenticatedClient | Client, response: httpx.Response
|
|
64
|
+
) -> Response[Bundle | OperationOutcome]:
|
|
65
|
+
return Response(
|
|
66
|
+
status_code=HTTPStatus(response.status_code),
|
|
67
|
+
content=response.content,
|
|
68
|
+
headers=response.headers,
|
|
69
|
+
parsed=_parse_response(client=client, response=response),
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def sync_detailed(
|
|
74
|
+
tenant_id: str,
|
|
75
|
+
store_id: str,
|
|
76
|
+
*,
|
|
77
|
+
client: AuthenticatedClient | Client,
|
|
78
|
+
body: PostDocrefBody,
|
|
79
|
+
) -> Response[Bundle | OperationOutcome]:
|
|
80
|
+
"""US Core $docref operation (POST)
|
|
81
|
+
|
|
82
|
+
Args:
|
|
83
|
+
tenant_id (str):
|
|
84
|
+
store_id (str):
|
|
85
|
+
body (PostDocrefBody):
|
|
86
|
+
|
|
87
|
+
Raises:
|
|
88
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
89
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
90
|
+
|
|
91
|
+
Returns:
|
|
92
|
+
Response[Bundle | OperationOutcome]
|
|
93
|
+
"""
|
|
94
|
+
|
|
95
|
+
kwargs = _get_kwargs(
|
|
96
|
+
tenant_id=tenant_id,
|
|
97
|
+
store_id=store_id,
|
|
98
|
+
body=body,
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
response = client.get_httpx_client().request(
|
|
102
|
+
**kwargs,
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
return _build_response(client=client, response=response)
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
def sync(
|
|
109
|
+
tenant_id: str,
|
|
110
|
+
store_id: str,
|
|
111
|
+
*,
|
|
112
|
+
client: AuthenticatedClient | Client,
|
|
113
|
+
body: PostDocrefBody,
|
|
114
|
+
) -> Bundle | OperationOutcome | None:
|
|
115
|
+
"""US Core $docref operation (POST)
|
|
116
|
+
|
|
117
|
+
Args:
|
|
118
|
+
tenant_id (str):
|
|
119
|
+
store_id (str):
|
|
120
|
+
body (PostDocrefBody):
|
|
121
|
+
|
|
122
|
+
Raises:
|
|
123
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
124
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
125
|
+
|
|
126
|
+
Returns:
|
|
127
|
+
Bundle | OperationOutcome
|
|
128
|
+
"""
|
|
129
|
+
|
|
130
|
+
return sync_detailed(
|
|
131
|
+
tenant_id=tenant_id,
|
|
132
|
+
store_id=store_id,
|
|
133
|
+
client=client,
|
|
134
|
+
body=body,
|
|
135
|
+
).parsed
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
async def asyncio_detailed(
|
|
139
|
+
tenant_id: str,
|
|
140
|
+
store_id: str,
|
|
141
|
+
*,
|
|
142
|
+
client: AuthenticatedClient | Client,
|
|
143
|
+
body: PostDocrefBody,
|
|
144
|
+
) -> Response[Bundle | OperationOutcome]:
|
|
145
|
+
"""US Core $docref operation (POST)
|
|
146
|
+
|
|
147
|
+
Args:
|
|
148
|
+
tenant_id (str):
|
|
149
|
+
store_id (str):
|
|
150
|
+
body (PostDocrefBody):
|
|
151
|
+
|
|
152
|
+
Raises:
|
|
153
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
154
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
155
|
+
|
|
156
|
+
Returns:
|
|
157
|
+
Response[Bundle | OperationOutcome]
|
|
158
|
+
"""
|
|
159
|
+
|
|
160
|
+
kwargs = _get_kwargs(
|
|
161
|
+
tenant_id=tenant_id,
|
|
162
|
+
store_id=store_id,
|
|
163
|
+
body=body,
|
|
164
|
+
)
|
|
165
|
+
|
|
166
|
+
response = await client.get_async_httpx_client().request(**kwargs)
|
|
167
|
+
|
|
168
|
+
return _build_response(client=client, response=response)
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
async def asyncio(
|
|
172
|
+
tenant_id: str,
|
|
173
|
+
store_id: str,
|
|
174
|
+
*,
|
|
175
|
+
client: AuthenticatedClient | Client,
|
|
176
|
+
body: PostDocrefBody,
|
|
177
|
+
) -> Bundle | OperationOutcome | None:
|
|
178
|
+
"""US Core $docref operation (POST)
|
|
179
|
+
|
|
180
|
+
Args:
|
|
181
|
+
tenant_id (str):
|
|
182
|
+
store_id (str):
|
|
183
|
+
body (PostDocrefBody):
|
|
184
|
+
|
|
185
|
+
Raises:
|
|
186
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
187
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
188
|
+
|
|
189
|
+
Returns:
|
|
190
|
+
Bundle | OperationOutcome
|
|
191
|
+
"""
|
|
192
|
+
|
|
193
|
+
return (
|
|
194
|
+
await asyncio_detailed(
|
|
195
|
+
tenant_id=tenant_id,
|
|
196
|
+
store_id=store_id,
|
|
197
|
+
client=client,
|
|
198
|
+
body=body,
|
|
199
|
+
)
|
|
200
|
+
).parsed
|