hubble-sdk-python 0.1.0__tar.gz → 0.2.1__tar.gz

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.
Files changed (69) hide show
  1. {hubble_sdk_python-0.1.0 → hubble_sdk_python-0.2.1}/CHANGELOG.md +31 -0
  2. {hubble_sdk_python-0.1.0 → hubble_sdk_python-0.2.1}/PKG-INFO +31 -2
  3. {hubble_sdk_python-0.1.0 → hubble_sdk_python-0.2.1}/README.md +30 -1
  4. {hubble_sdk_python-0.1.0 → hubble_sdk_python-0.2.1}/hubble_sdk/__init__.py +12 -0
  5. {hubble_sdk_python-0.1.0 → hubble_sdk_python-0.2.1}/hubble_sdk/_generated/api/default/attach_client_authorization.py +32 -8
  6. hubble_sdk_python-0.2.1/hubble_sdk/_generated/api/default/export_patient_fhir.py +262 -0
  7. {hubble_sdk_python-0.1.0 → hubble_sdk_python-0.2.1}/hubble_sdk/_generated/api/default/export_patient_pdf.py +64 -14
  8. hubble_sdk_python-0.2.1/hubble_sdk/_generated/api/default/get_patient_pdf_export.py +261 -0
  9. {hubble_sdk_python-0.1.0 → hubble_sdk_python-0.2.1}/hubble_sdk/_generated/api/default/list_consents.py +46 -0
  10. {hubble_sdk_python-0.1.0 → hubble_sdk_python-0.2.1}/hubble_sdk/_generated/models/__init__.py +20 -0
  11. {hubble_sdk_python-0.1.0 → hubble_sdk_python-0.2.1}/hubble_sdk/_generated/models/consent.py +18 -10
  12. {hubble_sdk_python-0.1.0 → hubble_sdk_python-0.2.1}/hubble_sdk/_generated/models/consent_link_request.py +14 -13
  13. {hubble_sdk_python-0.1.0 → hubble_sdk_python-0.2.1}/hubble_sdk/_generated/models/consent_list.py +16 -1
  14. {hubble_sdk_python-0.1.0 → hubble_sdk_python-0.2.1}/hubble_sdk/_generated/models/consent_source.py +29 -4
  15. hubble_sdk_python-0.2.1/hubble_sdk/_generated/models/consent_source_status.py +30 -0
  16. hubble_sdk_python-0.2.1/hubble_sdk/_generated/models/consent_source_type.py +28 -0
  17. hubble_sdk_python-0.2.1/hubble_sdk/_generated/models/consent_status.py +31 -0
  18. {hubble_sdk_python-0.1.0 → hubble_sdk_python-0.2.1}/hubble_sdk/_generated/models/device_authorization_request.py +16 -15
  19. hubble_sdk_python-0.2.1/hubble_sdk/_generated/models/export_patient_fhir_prefer.py +27 -0
  20. hubble_sdk_python-0.2.1/hubble_sdk/_generated/models/export_patient_fhir_response_202.py +105 -0
  21. hubble_sdk_python-0.2.1/hubble_sdk/_generated/models/export_patient_fhir_response_202_status.py +28 -0
  22. hubble_sdk_python-0.2.1/hubble_sdk/_generated/models/export_patient_pdf_prefer.py +27 -0
  23. hubble_sdk_python-0.2.1/hubble_sdk/_generated/models/export_patient_pdf_response_202.py +105 -0
  24. hubble_sdk_python-0.2.1/hubble_sdk/_generated/models/export_patient_pdf_response_202_status.py +28 -0
  25. hubble_sdk_python-0.2.1/hubble_sdk/_generated/models/get_patient_pdf_export_download.py +27 -0
  26. hubble_sdk_python-0.2.1/hubble_sdk/_generated/models/get_patient_pdf_export_response_200.py +114 -0
  27. hubble_sdk_python-0.2.1/hubble_sdk/_generated/models/get_patient_pdf_export_response_200_status.py +27 -0
  28. {hubble_sdk_python-0.1.0 → hubble_sdk_python-0.2.1}/hubble_sdk/_generated/models/o_auth_error.py +1 -1
  29. hubble_sdk_python-0.2.1/hubble_sdk/_generated/models/o_auth_error_error.py +35 -0
  30. {hubble_sdk_python-0.1.0 → hubble_sdk_python-0.2.1}/hubble_sdk/_generated/models/provider_seed.py +11 -0
  31. {hubble_sdk_python-0.1.0 → hubble_sdk_python-0.2.1}/hubble_sdk/_generated/models/token_request.py +2 -2
  32. hubble_sdk_python-0.2.1/hubble_sdk/_generated/models/token_request_grant_type.py +30 -0
  33. {hubble_sdk_python-0.1.0 → hubble_sdk_python-0.2.1}/hubble_sdk/_hubble.py +47 -18
  34. hubble_sdk_python-0.2.1/hubble_sdk/_webhooks.py +207 -0
  35. {hubble_sdk_python-0.1.0 → hubble_sdk_python-0.2.1}/pydoc-markdown.yml +6 -4
  36. {hubble_sdk_python-0.1.0 → hubble_sdk_python-0.2.1}/pyproject.toml +1 -1
  37. hubble_sdk_python-0.2.1/templates/property_templates/enum_property.py.jinja +33 -0
  38. hubble_sdk_python-0.2.1/templates/str_enum.py.jinja +28 -0
  39. {hubble_sdk_python-0.1.0 → hubble_sdk_python-0.2.1}/tests/test_hubble.py +115 -10
  40. hubble_sdk_python-0.2.1/tests/test_webhooks.py +198 -0
  41. hubble_sdk_python-0.1.0/hubble_sdk/_generated/models/consent_source_status.py +0 -10
  42. hubble_sdk_python-0.1.0/hubble_sdk/_generated/models/consent_source_type.py +0 -9
  43. hubble_sdk_python-0.1.0/hubble_sdk/_generated/models/consent_status.py +0 -12
  44. hubble_sdk_python-0.1.0/hubble_sdk/_generated/models/o_auth_error_error.py +0 -16
  45. hubble_sdk_python-0.1.0/hubble_sdk/_generated/models/token_request_grant_type.py +0 -12
  46. {hubble_sdk_python-0.1.0 → hubble_sdk_python-0.2.1}/.gitignore +0 -0
  47. {hubble_sdk_python-0.1.0 → hubble_sdk_python-0.2.1}/LICENSE +0 -0
  48. {hubble_sdk_python-0.1.0 → hubble_sdk_python-0.2.1}/config.yaml +0 -0
  49. {hubble_sdk_python-0.1.0 → hubble_sdk_python-0.2.1}/hubble_sdk/_generated/__init__.py +0 -0
  50. {hubble_sdk_python-0.1.0 → hubble_sdk_python-0.2.1}/hubble_sdk/_generated/api/__init__.py +0 -0
  51. {hubble_sdk_python-0.1.0 → hubble_sdk_python-0.2.1}/hubble_sdk/_generated/api/default/__init__.py +0 -0
  52. {hubble_sdk_python-0.1.0 → hubble_sdk_python-0.2.1}/hubble_sdk/_generated/api/default/create_consent_link.py +0 -0
  53. {hubble_sdk_python-0.1.0 → hubble_sdk_python-0.2.1}/hubble_sdk/_generated/api/default/exchange_token.py +0 -0
  54. {hubble_sdk_python-0.1.0 → hubble_sdk_python-0.2.1}/hubble_sdk/_generated/api/default/get_consent.py +0 -0
  55. {hubble_sdk_python-0.1.0 → hubble_sdk_python-0.2.1}/hubble_sdk/_generated/api/default/read_fhir.py +0 -0
  56. {hubble_sdk_python-0.1.0 → hubble_sdk_python-0.2.1}/hubble_sdk/_generated/api/default/revoke_consent.py +0 -0
  57. {hubble_sdk_python-0.1.0 → hubble_sdk_python-0.2.1}/hubble_sdk/_generated/client.py +0 -0
  58. {hubble_sdk_python-0.1.0 → hubble_sdk_python-0.2.1}/hubble_sdk/_generated/errors.py +0 -0
  59. {hubble_sdk_python-0.1.0 → hubble_sdk_python-0.2.1}/hubble_sdk/_generated/models/api_error.py +0 -0
  60. {hubble_sdk_python-0.1.0 → hubble_sdk_python-0.2.1}/hubble_sdk/_generated/models/attach_client_authorization_body.py +0 -0
  61. {hubble_sdk_python-0.1.0 → hubble_sdk_python-0.2.1}/hubble_sdk/_generated/models/consent_error.py +0 -0
  62. {hubble_sdk_python-0.1.0 → hubble_sdk_python-0.2.1}/hubble_sdk/_generated/models/device_authorization_response.py +0 -0
  63. {hubble_sdk_python-0.1.0 → hubble_sdk_python-0.2.1}/hubble_sdk/_generated/models/fhir_resource.py +0 -0
  64. {hubble_sdk_python-0.1.0 → hubble_sdk_python-0.2.1}/hubble_sdk/_generated/models/operation_outcome.py +0 -0
  65. {hubble_sdk_python-0.1.0 → hubble_sdk_python-0.2.1}/hubble_sdk/_generated/models/operation_outcome_issue_item.py +0 -0
  66. {hubble_sdk_python-0.1.0 → hubble_sdk_python-0.2.1}/hubble_sdk/_generated/models/patient_address.py +0 -0
  67. {hubble_sdk_python-0.1.0 → hubble_sdk_python-0.2.1}/hubble_sdk/_generated/models/patient_demographics.py +0 -0
  68. {hubble_sdk_python-0.1.0 → hubble_sdk_python-0.2.1}/hubble_sdk/_generated/models/token_response.py +0 -0
  69. {hubble_sdk_python-0.1.0 → hubble_sdk_python-0.2.1}/hubble_sdk/_generated/types.py +0 -0
@@ -1,5 +1,36 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.2.1](https://github.com/hubble-dot-ai/hubble-sdks/compare/hubble-sdk-python-v0.2.0...hubble-sdk-python-v0.2.1) (2026-10-14)
4
+
5
+
6
+ ### Features
7
+
8
+ * echo provider_ref on sources from a seeded provider ([#57](https://github.com/hubble-dot-ai/hubble-sdks/issues/57)) ([dbfc576](https://github.com/hubble-dot-ai/hubble-sdks/commit/dbfc5763b2514aecbc520bd0406eeefedae1f6ac))
9
+ * mark Consent.error deprecated and optional ([#58](https://github.com/hubble-dot-ai/hubble-sdks/issues/58)) ([dacf748](https://github.com/hubble-dot-ai/hubble-sdks/commit/dacf7488d5d4b073b9781914d20bdd6897075c50))
10
+
11
+
12
+ ### Bug Fixes
13
+
14
+ * accept enum values this SDK version does not know ([#56](https://github.com/hubble-dot-ai/hubble-sdks/issues/56)) ([45d69ad](https://github.com/hubble-dot-ai/hubble-sdks/commit/45d69ad44d67de470f122803e842a914b9342915))
15
+
16
+
17
+ ### Documentation
18
+
19
+ * state the BYO attestation and who checks the authorization ([#54](https://github.com/hubble-dot-ai/hubble-sdks/issues/54)) ([7ddecdd](https://github.com/hubble-dot-ai/hubble-sdks/commit/7ddecddf1d1ffc61e92825aa202d5105c7647092))
20
+
21
+ ## [0.2.0](https://github.com/hubble-dot-ai/hubble-sdks/compare/hubble-sdk-python-v0.1.0...hubble-sdk-python-v0.2.0) (2026-09-30)
22
+
23
+
24
+ ### ⚠ BREAKING CHANGES
25
+
26
+ * the `authorization_code` value is removed from the token `grant_type` enum (it was never available), and `ConsentList.next_cursor` / `ConsentSource.id` are now required response fields.
27
+
28
+ ### Features
29
+
30
+ * add revoked consent source status ([#51](https://github.com/hubble-dot-ai/hubble-sdks/issues/51)) ([b2dc24d](https://github.com/hubble-dot-ai/hubble-sdks/commit/b2dc24d3359ce1ea245bd881303ada2c425e3132))
31
+ * async record exports, consent pagination, and per-source ids ([#47](https://github.com/hubble-dot-ai/hubble-sdks/issues/47)) ([ddf8e5b](https://github.com/hubble-dot-ai/hubble-sdks/commit/ddf8e5b02436d6ae69d0ca20e723752ee21349a9))
32
+ * verify and parse webhook events ([#50](https://github.com/hubble-dot-ai/hubble-sdks/issues/50)) ([e71b0bc](https://github.com/hubble-dot-ai/hubble-sdks/commit/e71b0bc80b38fbd070a4b6fd5ddfcbada1e8e311))
33
+
3
34
  ## [0.1.0](https://github.com/hubble-dot-ai/hubble-sdks/compare/hubble-sdk-python-v0.0.3...hubble-sdk-python-v0.1.0) (2026-09-02)
4
35
 
5
36
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: hubble-sdk-python
3
- Version: 0.1.0
3
+ Version: 0.2.1
4
4
  Summary: Python client for the Hubble Patient Access API.
5
5
  Project-URL: Homepage, https://github.com/hubble-dot-ai/hubble-sdks
6
6
  Project-URL: Repository, https://github.com/hubble-dot-ai/hubble-sdks
@@ -64,6 +64,35 @@ for consent in hub.list_consents(status="active"):
64
64
  hub.revoke_consent(session.consent_id)
65
65
  ```
66
66
 
67
+ ## Receiving webhooks
68
+
69
+ Verify each delivery against your endpoint's signing secret (from the portal's
70
+ Webhooks page) and get the event back. Pass the **raw** body: a body that was
71
+ parsed and re-serialized will not verify.
72
+
73
+ ```python
74
+ from hubble_sdk import WebhookSignatureError, construct_webhook_event
75
+
76
+ # e.g. Flask
77
+ @app.post("/hubble/webhooks")
78
+ def hubble_webhook():
79
+ try:
80
+ event = construct_webhook_event(
81
+ request.get_data(), request.headers.get("Hubble-Signature"), WEBHOOK_SECRET
82
+ )
83
+ except WebhookSignatureError:
84
+ return "bad signature", 400
85
+ if event.type == "consent.source.available":
86
+ print(event.consent_id, event.source.id)
87
+ # newer event types may arrive; ignore what you don't handle
88
+ return "", 204
89
+ ```
90
+
91
+ In FastAPI, read the body with `await request.body()`. Deliveries are
92
+ at-least-once, so dedupe on `event.id`. Pass `secret` as a list to accept the old
93
+ and new secret during a rotation, and `tolerance` to change the default 5-minute
94
+ replay window.
95
+
67
96
  ## What the client handles for you
68
97
 
69
98
  - **Auth per plane** — HTTP Basic (your app credentials) for consent management
@@ -82,7 +111,7 @@ hub.revoke_consent(session.consent_id)
82
111
 
83
112
  ## Layout
84
113
 
85
- `Hubble` / `PatientSession` are hand-written. The low-level client generated
114
+ `Hubble` / `PatientSession` and the webhook helpers are hand-written. The low-level client generated
86
115
  from the OpenAPI contract with
87
116
  [openapi-python-client](https://github.com/openapi-generators/openapi-python-client)
88
117
  lives under `hubble_sdk._generated` (regenerated on every spec change;
@@ -32,6 +32,35 @@ for consent in hub.list_consents(status="active"):
32
32
  hub.revoke_consent(session.consent_id)
33
33
  ```
34
34
 
35
+ ## Receiving webhooks
36
+
37
+ Verify each delivery against your endpoint's signing secret (from the portal's
38
+ Webhooks page) and get the event back. Pass the **raw** body: a body that was
39
+ parsed and re-serialized will not verify.
40
+
41
+ ```python
42
+ from hubble_sdk import WebhookSignatureError, construct_webhook_event
43
+
44
+ # e.g. Flask
45
+ @app.post("/hubble/webhooks")
46
+ def hubble_webhook():
47
+ try:
48
+ event = construct_webhook_event(
49
+ request.get_data(), request.headers.get("Hubble-Signature"), WEBHOOK_SECRET
50
+ )
51
+ except WebhookSignatureError:
52
+ return "bad signature", 400
53
+ if event.type == "consent.source.available":
54
+ print(event.consent_id, event.source.id)
55
+ # newer event types may arrive; ignore what you don't handle
56
+ return "", 204
57
+ ```
58
+
59
+ In FastAPI, read the body with `await request.body()`. Deliveries are
60
+ at-least-once, so dedupe on `event.id`. Pass `secret` as a list to accept the old
61
+ and new secret during a rotation, and `tolerance` to change the default 5-minute
62
+ replay window.
63
+
35
64
  ## What the client handles for you
36
65
 
37
66
  - **Auth per plane** — HTTP Basic (your app credentials) for consent management
@@ -50,7 +79,7 @@ hub.revoke_consent(session.consent_id)
50
79
 
51
80
  ## Layout
52
81
 
53
- `Hubble` / `PatientSession` are hand-written. The low-level client generated
82
+ `Hubble` / `PatientSession` and the webhook helpers are hand-written. The low-level client generated
54
83
  from the OpenAPI contract with
55
84
  [openapi-python-client](https://github.com/openapi-generators/openapi-python-client)
56
85
  lives under `hubble_sdk._generated` (regenerated on every spec change;
@@ -28,6 +28,13 @@ from ._hubble import (
28
28
  PdfExport,
29
29
  TokenSet,
30
30
  )
31
+ from ._webhooks import (
32
+ WEBHOOK_SIGNATURE_HEADER,
33
+ WebhookEvent,
34
+ WebhookEventSource,
35
+ WebhookSignatureError,
36
+ construct_webhook_event,
37
+ )
31
38
 
32
39
  __all__ = [
33
40
  "Hubble",
@@ -36,6 +43,11 @@ __all__ = [
36
43
  "ConsentTimeout",
37
44
  "TokenSet",
38
45
  "PdfExport",
46
+ "construct_webhook_event",
47
+ "WebhookEvent",
48
+ "WebhookEventSource",
49
+ "WebhookSignatureError",
50
+ "WEBHOOK_SIGNATURE_HEADER",
39
51
  "Consent",
40
52
  "ConsentStatus",
41
53
  "DeviceAuthorizationResponse",
@@ -98,8 +98,14 @@ def sync_detailed(
98
98
  """Attach a customer-supplied HIPAA authorization
99
99
 
100
100
  Upload an already-signed HIPAA authorization for a consent and grant delegated retrieval from the
101
- providers it names. The artifact IS the evidence, so the consent is granted at once with no patient
102
- step. Requires the `byo_hipaa_authorization` entitlement on your organization.
101
+ providers it names. Hubble keeps a copy of the signed authorization on file and, based on your
102
+ attestation, makes the consent `active` right away with no patient step. If your organization also
103
+ uses EHR sign-in, health plans, or the health information network, the consent stays `pending` until
104
+ the patient finishes the link. Requires the `byo_hipaa_authorization` entitlement on your
105
+ organization. Attaching an authorization is your organization's attestation that it holds a valid
106
+ HIPAA authorization signed by the patient, and that it covers the providers you name. Hubble does
107
+ not review the document or ask the patient to confirm it, so your organization is responsible for
108
+ checking that the authorization is correct before you attach it.
103
109
 
104
110
  Args:
105
111
  id (str):
@@ -134,8 +140,14 @@ def sync(
134
140
  """Attach a customer-supplied HIPAA authorization
135
141
 
136
142
  Upload an already-signed HIPAA authorization for a consent and grant delegated retrieval from the
137
- providers it names. The artifact IS the evidence, so the consent is granted at once with no patient
138
- step. Requires the `byo_hipaa_authorization` entitlement on your organization.
143
+ providers it names. Hubble keeps a copy of the signed authorization on file and, based on your
144
+ attestation, makes the consent `active` right away with no patient step. If your organization also
145
+ uses EHR sign-in, health plans, or the health information network, the consent stays `pending` until
146
+ the patient finishes the link. Requires the `byo_hipaa_authorization` entitlement on your
147
+ organization. Attaching an authorization is your organization's attestation that it holds a valid
148
+ HIPAA authorization signed by the patient, and that it covers the providers you name. Hubble does
149
+ not review the document or ask the patient to confirm it, so your organization is responsible for
150
+ checking that the authorization is correct before you attach it.
139
151
 
140
152
  Args:
141
153
  id (str):
@@ -165,8 +177,14 @@ async def asyncio_detailed(
165
177
  """Attach a customer-supplied HIPAA authorization
166
178
 
167
179
  Upload an already-signed HIPAA authorization for a consent and grant delegated retrieval from the
168
- providers it names. The artifact IS the evidence, so the consent is granted at once with no patient
169
- step. Requires the `byo_hipaa_authorization` entitlement on your organization.
180
+ providers it names. Hubble keeps a copy of the signed authorization on file and, based on your
181
+ attestation, makes the consent `active` right away with no patient step. If your organization also
182
+ uses EHR sign-in, health plans, or the health information network, the consent stays `pending` until
183
+ the patient finishes the link. Requires the `byo_hipaa_authorization` entitlement on your
184
+ organization. Attaching an authorization is your organization's attestation that it holds a valid
185
+ HIPAA authorization signed by the patient, and that it covers the providers you name. Hubble does
186
+ not review the document or ask the patient to confirm it, so your organization is responsible for
187
+ checking that the authorization is correct before you attach it.
170
188
 
171
189
  Args:
172
190
  id (str):
@@ -199,8 +217,14 @@ async def asyncio(
199
217
  """Attach a customer-supplied HIPAA authorization
200
218
 
201
219
  Upload an already-signed HIPAA authorization for a consent and grant delegated retrieval from the
202
- providers it names. The artifact IS the evidence, so the consent is granted at once with no patient
203
- step. Requires the `byo_hipaa_authorization` entitlement on your organization.
220
+ providers it names. Hubble keeps a copy of the signed authorization on file and, based on your
221
+ attestation, makes the consent `active` right away with no patient step. If your organization also
222
+ uses EHR sign-in, health plans, or the health information network, the consent stays `pending` until
223
+ the patient finishes the link. Requires the `byo_hipaa_authorization` entitlement on your
224
+ organization. Attaching an authorization is your organization's attestation that it holds a valid
225
+ HIPAA authorization signed by the patient, and that it covers the providers you name. Hubble does
226
+ not review the document or ask the patient to confirm it, so your organization is responsible for
227
+ checking that the authorization is correct before you attach it.
204
228
 
205
229
  Args:
206
230
  id (str):
@@ -0,0 +1,262 @@
1
+ from http import HTTPStatus
2
+ from typing import Any
3
+
4
+ import httpx
5
+
6
+ from ... import errors
7
+ from ...client import AuthenticatedClient, Client
8
+ from ...models.export_patient_fhir_prefer import ExportPatientFhirPrefer
9
+ from ...models.export_patient_fhir_response_202 import ExportPatientFhirResponse202
10
+ from ...models.fhir_resource import FhirResource
11
+ from ...models.operation_outcome import OperationOutcome
12
+ from ...types import UNSET, Response, Unset
13
+
14
+
15
+ def _get_kwargs(
16
+ *,
17
+ field_count: int | Unset = UNSET,
18
+ field_offset: int | Unset = UNSET,
19
+ prefer: ExportPatientFhirPrefer | Unset = UNSET,
20
+ ) -> dict[str, Any]:
21
+ headers: dict[str, Any] = {}
22
+ if not isinstance(prefer, Unset):
23
+ headers["Prefer"] = str(prefer)
24
+
25
+ params: dict[str, Any] = {}
26
+
27
+ params["_count"] = field_count
28
+
29
+ params["_offset"] = field_offset
30
+
31
+ params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
32
+
33
+ _kwargs: dict[str, Any] = {
34
+ "method": "get",
35
+ "url": "/api/v1/fhir/Patient/$everything",
36
+ "params": params,
37
+ }
38
+
39
+ _kwargs["headers"] = headers
40
+ return _kwargs
41
+
42
+
43
+ def _parse_response(
44
+ *, client: AuthenticatedClient | Client, response: httpx.Response
45
+ ) -> ExportPatientFhirResponse202 | FhirResource | OperationOutcome | None:
46
+ if response.status_code == 200:
47
+ response_200 = FhirResource.from_dict(response.json())
48
+
49
+ return response_200
50
+
51
+ if response.status_code == 202:
52
+ response_202 = ExportPatientFhirResponse202.from_dict(response.json())
53
+
54
+ return response_202
55
+
56
+ if response.status_code == 400:
57
+ response_400 = OperationOutcome.from_dict(response.json())
58
+
59
+ return response_400
60
+
61
+ if response.status_code == 401:
62
+ response_401 = OperationOutcome.from_dict(response.json())
63
+
64
+ return response_401
65
+
66
+ if response.status_code == 403:
67
+ response_403 = OperationOutcome.from_dict(response.json())
68
+
69
+ return response_403
70
+
71
+ if response.status_code == 404:
72
+ response_404 = OperationOutcome.from_dict(response.json())
73
+
74
+ return response_404
75
+
76
+ if response.status_code == 429:
77
+ response_429 = OperationOutcome.from_dict(response.json())
78
+
79
+ return response_429
80
+
81
+ if response.status_code == 503:
82
+ response_503 = OperationOutcome.from_dict(response.json())
83
+
84
+ return response_503
85
+
86
+ if client.raise_on_unexpected_status:
87
+ raise errors.UnexpectedStatus(response.status_code, response.content)
88
+ else:
89
+ return None
90
+
91
+
92
+ def _build_response(
93
+ *, client: AuthenticatedClient | Client, response: httpx.Response
94
+ ) -> Response[ExportPatientFhirResponse202 | FhirResource | OperationOutcome]:
95
+ return Response(
96
+ status_code=HTTPStatus(response.status_code),
97
+ content=response.content,
98
+ headers=response.headers,
99
+ parsed=_parse_response(client=client, response=response),
100
+ )
101
+
102
+
103
+ def sync_detailed(
104
+ *,
105
+ client: AuthenticatedClient,
106
+ field_count: int | Unset = UNSET,
107
+ field_offset: int | Unset = UNSET,
108
+ prefer: ExportPatientFhirPrefer | Unset = UNSET,
109
+ ) -> Response[ExportPatientFhirResponse202 | FhirResource | OperationOutcome]:
110
+ """Read or asynchronously export the patient's FHIR record
111
+
112
+ Without Prefer, returns the existing paginated FHIR searchset. Send Prefer: respond-async without
113
+ query parameters to prepare health-records.json in the background. The file is a FHIR collection
114
+ Bundle containing the captured provider sources, including each source's Patient and warnings for
115
+ incomplete sources. It has no paging links, search metadata or total field, and is not a Bulk Data
116
+ $export/NDJSON response. Poll Content-Location with the same consent token no sooner than Retry-
117
+ After for a 303 download redirect. An organization can hold 20 exports in flight at once; a repeat
118
+ request for one already running reuses it. Payer records are not included.
119
+
120
+ Args:
121
+ field_count (int | Unset):
122
+ field_offset (int | Unset):
123
+ prefer (ExportPatientFhirPrefer | Unset):
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[ExportPatientFhirResponse202 | FhirResource | OperationOutcome]
131
+ """
132
+
133
+ kwargs = _get_kwargs(
134
+ field_count=field_count,
135
+ field_offset=field_offset,
136
+ prefer=prefer,
137
+ )
138
+
139
+ response = client.get_httpx_client().request(
140
+ **kwargs,
141
+ )
142
+
143
+ return _build_response(client=client, response=response)
144
+
145
+
146
+ def sync(
147
+ *,
148
+ client: AuthenticatedClient,
149
+ field_count: int | Unset = UNSET,
150
+ field_offset: int | Unset = UNSET,
151
+ prefer: ExportPatientFhirPrefer | Unset = UNSET,
152
+ ) -> ExportPatientFhirResponse202 | FhirResource | OperationOutcome | None:
153
+ """Read or asynchronously export the patient's FHIR record
154
+
155
+ Without Prefer, returns the existing paginated FHIR searchset. Send Prefer: respond-async without
156
+ query parameters to prepare health-records.json in the background. The file is a FHIR collection
157
+ Bundle containing the captured provider sources, including each source's Patient and warnings for
158
+ incomplete sources. It has no paging links, search metadata or total field, and is not a Bulk Data
159
+ $export/NDJSON response. Poll Content-Location with the same consent token no sooner than Retry-
160
+ After for a 303 download redirect. An organization can hold 20 exports in flight at once; a repeat
161
+ request for one already running reuses it. Payer records are not included.
162
+
163
+ Args:
164
+ field_count (int | Unset):
165
+ field_offset (int | Unset):
166
+ prefer (ExportPatientFhirPrefer | Unset):
167
+
168
+ Raises:
169
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
170
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
171
+
172
+ Returns:
173
+ ExportPatientFhirResponse202 | FhirResource | OperationOutcome
174
+ """
175
+
176
+ return sync_detailed(
177
+ client=client,
178
+ field_count=field_count,
179
+ field_offset=field_offset,
180
+ prefer=prefer,
181
+ ).parsed
182
+
183
+
184
+ async def asyncio_detailed(
185
+ *,
186
+ client: AuthenticatedClient,
187
+ field_count: int | Unset = UNSET,
188
+ field_offset: int | Unset = UNSET,
189
+ prefer: ExportPatientFhirPrefer | Unset = UNSET,
190
+ ) -> Response[ExportPatientFhirResponse202 | FhirResource | OperationOutcome]:
191
+ """Read or asynchronously export the patient's FHIR record
192
+
193
+ Without Prefer, returns the existing paginated FHIR searchset. Send Prefer: respond-async without
194
+ query parameters to prepare health-records.json in the background. The file is a FHIR collection
195
+ Bundle containing the captured provider sources, including each source's Patient and warnings for
196
+ incomplete sources. It has no paging links, search metadata or total field, and is not a Bulk Data
197
+ $export/NDJSON response. Poll Content-Location with the same consent token no sooner than Retry-
198
+ After for a 303 download redirect. An organization can hold 20 exports in flight at once; a repeat
199
+ request for one already running reuses it. Payer records are not included.
200
+
201
+ Args:
202
+ field_count (int | Unset):
203
+ field_offset (int | Unset):
204
+ prefer (ExportPatientFhirPrefer | Unset):
205
+
206
+ Raises:
207
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
208
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
209
+
210
+ Returns:
211
+ Response[ExportPatientFhirResponse202 | FhirResource | OperationOutcome]
212
+ """
213
+
214
+ kwargs = _get_kwargs(
215
+ field_count=field_count,
216
+ field_offset=field_offset,
217
+ prefer=prefer,
218
+ )
219
+
220
+ response = await client.get_async_httpx_client().request(**kwargs)
221
+
222
+ return _build_response(client=client, response=response)
223
+
224
+
225
+ async def asyncio(
226
+ *,
227
+ client: AuthenticatedClient,
228
+ field_count: int | Unset = UNSET,
229
+ field_offset: int | Unset = UNSET,
230
+ prefer: ExportPatientFhirPrefer | Unset = UNSET,
231
+ ) -> ExportPatientFhirResponse202 | FhirResource | OperationOutcome | None:
232
+ """Read or asynchronously export the patient's FHIR record
233
+
234
+ Without Prefer, returns the existing paginated FHIR searchset. Send Prefer: respond-async without
235
+ query parameters to prepare health-records.json in the background. The file is a FHIR collection
236
+ Bundle containing the captured provider sources, including each source's Patient and warnings for
237
+ incomplete sources. It has no paging links, search metadata or total field, and is not a Bulk Data
238
+ $export/NDJSON response. Poll Content-Location with the same consent token no sooner than Retry-
239
+ After for a 303 download redirect. An organization can hold 20 exports in flight at once; a repeat
240
+ request for one already running reuses it. Payer records are not included.
241
+
242
+ Args:
243
+ field_count (int | Unset):
244
+ field_offset (int | Unset):
245
+ prefer (ExportPatientFhirPrefer | Unset):
246
+
247
+ Raises:
248
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
249
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
250
+
251
+ Returns:
252
+ ExportPatientFhirResponse202 | FhirResource | OperationOutcome
253
+ """
254
+
255
+ return (
256
+ await asyncio_detailed(
257
+ client=client,
258
+ field_count=field_count,
259
+ field_offset=field_offset,
260
+ prefer=prefer,
261
+ )
262
+ ).parsed