hebrah 0.8.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.
- SECURITY.md +31 -0
- hebrah/__init__.py +15 -0
- hebrah/client.py +515 -0
- hebrah/errors.py +7 -0
- hebrah/harness.py +125 -0
- hebrah/py.typed +0 -0
- hebrah/types.py +121 -0
- hebrah/webhooks.py +33 -0
- hebrah-0.8.1.dist-info/METADATA +147 -0
- hebrah-0.8.1.dist-info/RECORD +12 -0
- hebrah-0.8.1.dist-info/WHEEL +4 -0
- hebrah-0.8.1.dist-info/licenses/LICENSE +21 -0
SECURITY.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Security Policy
|
|
2
|
+
|
|
3
|
+
## Supported versions
|
|
4
|
+
|
|
5
|
+
| Version | Supported |
|
|
6
|
+
| ------- | --------- |
|
|
7
|
+
| 0.8.x | Yes |
|
|
8
|
+
|
|
9
|
+
## Reporting a vulnerability
|
|
10
|
+
|
|
11
|
+
Please report security issues privately to **security@hebrah.com**.
|
|
12
|
+
|
|
13
|
+
Include:
|
|
14
|
+
|
|
15
|
+
- A description of the issue and potential impact
|
|
16
|
+
- Steps to reproduce
|
|
17
|
+
- Affected SDK version(s)
|
|
18
|
+
|
|
19
|
+
We aim to acknowledge reports within 2 business days. Do not open public GitHub issues for undisclosed vulnerabilities.
|
|
20
|
+
|
|
21
|
+
## Scope
|
|
22
|
+
|
|
23
|
+
This SDK is a thin HTTP client for the hebrah control plane API. It does not store credentials; callers supply API keys and webhook secrets at runtime.
|
|
24
|
+
|
|
25
|
+
## Integrator guidance
|
|
26
|
+
|
|
27
|
+
- Keep `HEBRAH_API_KEY`, `HEBRAH_WEBHOOK_SECRET`, and MCP PATs in server-side environment variables or a secrets manager — never in client-side code, browser bundles, or committed `.env` files.
|
|
28
|
+
- Do not log API keys, webhook secrets, or raw webhook payloads containing PHI.
|
|
29
|
+
- `HebrahApiError.detail` contains the raw control-plane response body for operator diagnostics. Do not return or log `detail` to end users or untrusted clients. Pass `include_error_detail=False` to `HebrahClient` to omit `detail` from thrown errors.
|
|
30
|
+
- `base_url` must use `https://` or `http://localhost` / `http://127.0.0.1` for local development; other `http://` hosts are rejected at client construction.
|
|
31
|
+
- The SDK holds credentials only in memory for the lifetime of a `HebrahClient` instance; it does not write them to disk or cache them.
|
hebrah/__init__.py
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
from hebrah.client import HebrahClient
|
|
2
|
+
from hebrah.errors import HebrahApiError
|
|
3
|
+
from hebrah.harness import HebrahAgentHarness
|
|
4
|
+
from hebrah.types import DEFAULT_BASE_URL
|
|
5
|
+
from hebrah.webhooks import verify_webhook_signature
|
|
6
|
+
|
|
7
|
+
__all__ = [
|
|
8
|
+
"DEFAULT_BASE_URL",
|
|
9
|
+
"HebrahAgentHarness",
|
|
10
|
+
"HebrahApiError",
|
|
11
|
+
"HebrahClient",
|
|
12
|
+
"verify_webhook_signature",
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
__version__ = "0.8.1"
|
hebrah/client.py
ADDED
|
@@ -0,0 +1,515 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import warnings
|
|
4
|
+
from typing import Any
|
|
5
|
+
|
|
6
|
+
import httpx
|
|
7
|
+
|
|
8
|
+
from hebrah.errors import HebrahApiError
|
|
9
|
+
from hebrah.types import (
|
|
10
|
+
PatientListResponse,
|
|
11
|
+
PayerRules,
|
|
12
|
+
RunScenarioResponse,
|
|
13
|
+
SandboxCatalog,
|
|
14
|
+
SandboxDomainSummary,
|
|
15
|
+
SandboxResourceListResponse,
|
|
16
|
+
TriggerMockEventResponse,
|
|
17
|
+
resolve_base_url,
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class _SandboxResource:
|
|
22
|
+
def __init__(self, client: HebrahClient) -> None:
|
|
23
|
+
self._client = client
|
|
24
|
+
|
|
25
|
+
def catalog(self, connection_id: str | None = None) -> SandboxCatalog:
|
|
26
|
+
return self._client._request(
|
|
27
|
+
"GET",
|
|
28
|
+
"/v1/sandbox/catalog",
|
|
29
|
+
params=self._client._connection_params(connection_id),
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
def domains(self) -> list[SandboxDomainSummary]:
|
|
33
|
+
return self._client._request("GET", "/v1/sandbox/domains")
|
|
34
|
+
|
|
35
|
+
def domain(self, domain_id: str) -> SandboxDomainSummary:
|
|
36
|
+
from urllib.parse import quote
|
|
37
|
+
|
|
38
|
+
return self._client._request(
|
|
39
|
+
"GET",
|
|
40
|
+
f"/v1/sandbox/domains/{quote(domain_id, safe='')}",
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
def resource(
|
|
44
|
+
self,
|
|
45
|
+
resource_type: str,
|
|
46
|
+
resource_id: str,
|
|
47
|
+
*,
|
|
48
|
+
patient_id: str | None = None,
|
|
49
|
+
) -> dict[str, Any]:
|
|
50
|
+
from urllib.parse import quote
|
|
51
|
+
|
|
52
|
+
params = {"patient_id": patient_id} if patient_id else None
|
|
53
|
+
return self._client._request(
|
|
54
|
+
"GET",
|
|
55
|
+
f"/v1/sandbox/resources/{quote(resource_type, safe='')}/{quote(resource_id, safe='')}",
|
|
56
|
+
params=params,
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
def list_synthetic_resources(
|
|
60
|
+
self,
|
|
61
|
+
resource_type: str,
|
|
62
|
+
*,
|
|
63
|
+
connection_id: str | None = None,
|
|
64
|
+
) -> SandboxResourceListResponse:
|
|
65
|
+
from urllib.parse import quote
|
|
66
|
+
|
|
67
|
+
params = self._client._connection_params(connection_id)
|
|
68
|
+
return self._client._request(
|
|
69
|
+
"GET",
|
|
70
|
+
f"/v1/sandbox/resources/{quote(resource_type, safe='')}",
|
|
71
|
+
params=params,
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
def run_scenario(
|
|
75
|
+
self,
|
|
76
|
+
scenario_id: str,
|
|
77
|
+
*,
|
|
78
|
+
patient_id: str | None = None,
|
|
79
|
+
connection_id: str | None = None,
|
|
80
|
+
delay_seconds: float | None = None,
|
|
81
|
+
) -> RunScenarioResponse:
|
|
82
|
+
from urllib.parse import quote
|
|
83
|
+
|
|
84
|
+
body: dict[str, str | float] = {}
|
|
85
|
+
if patient_id:
|
|
86
|
+
body["patient_id"] = patient_id
|
|
87
|
+
resolved_connection = self._client._resolve_connection_id(connection_id)
|
|
88
|
+
if resolved_connection:
|
|
89
|
+
body["connection_id"] = resolved_connection
|
|
90
|
+
if delay_seconds is not None:
|
|
91
|
+
body["delay_seconds"] = delay_seconds
|
|
92
|
+
return self._client._request(
|
|
93
|
+
"POST",
|
|
94
|
+
f"/v1/sandbox/scenarios/{quote(scenario_id, safe='')}/run",
|
|
95
|
+
json=body,
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
def payer_rules(self, payer_id: str) -> PayerRules:
|
|
99
|
+
from urllib.parse import quote
|
|
100
|
+
|
|
101
|
+
return self._client._request(
|
|
102
|
+
"GET",
|
|
103
|
+
f"/v1/sandbox/payer-rules/{quote(payer_id, safe='')}",
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
def hl7_templates(self) -> list[dict[str, Any]]:
|
|
107
|
+
return self._client._request("GET", "/v1/sandbox/hl7/templates")
|
|
108
|
+
|
|
109
|
+
def inject_hl7(
|
|
110
|
+
self,
|
|
111
|
+
*,
|
|
112
|
+
message: str | None = None,
|
|
113
|
+
template_id: str | None = None,
|
|
114
|
+
patient_id: str | None = None,
|
|
115
|
+
connection_id: str | None = None,
|
|
116
|
+
event: str | None = None,
|
|
117
|
+
deliver: bool | None = None,
|
|
118
|
+
) -> dict[str, Any]:
|
|
119
|
+
body: dict[str, str | bool] = {}
|
|
120
|
+
if message:
|
|
121
|
+
body["message"] = message
|
|
122
|
+
if template_id:
|
|
123
|
+
body["template_id"] = template_id
|
|
124
|
+
if patient_id:
|
|
125
|
+
body["patient_id"] = patient_id
|
|
126
|
+
resolved_connection = self._client._resolve_connection_id(connection_id)
|
|
127
|
+
if resolved_connection:
|
|
128
|
+
body["connection_id"] = resolved_connection
|
|
129
|
+
if event:
|
|
130
|
+
body["event"] = event
|
|
131
|
+
if deliver is not None:
|
|
132
|
+
body["deliver"] = deliver
|
|
133
|
+
return self._client._request("POST", "/v1/sandbox/hl7/inject", json=body)
|
|
134
|
+
|
|
135
|
+
def configure_webhook_reliability(self, **profile: Any) -> dict[str, Any]:
|
|
136
|
+
return self._client._request(
|
|
137
|
+
"PATCH",
|
|
138
|
+
"/v1/sandbox/webhook-reliability",
|
|
139
|
+
json=profile,
|
|
140
|
+
)
|
|
141
|
+
|
|
142
|
+
def run_webhook_reliability_scenario(
|
|
143
|
+
self,
|
|
144
|
+
scenario_id: str,
|
|
145
|
+
*,
|
|
146
|
+
patient_id: str | None = None,
|
|
147
|
+
connection_id: str | None = None,
|
|
148
|
+
) -> RunScenarioResponse:
|
|
149
|
+
return self.run_scenario(
|
|
150
|
+
scenario_id,
|
|
151
|
+
patient_id=patient_id,
|
|
152
|
+
connection_id=connection_id,
|
|
153
|
+
)
|
|
154
|
+
|
|
155
|
+
def run_mpi_match(
|
|
156
|
+
self,
|
|
157
|
+
*,
|
|
158
|
+
first_name: str | None = None,
|
|
159
|
+
last_name: str | None = None,
|
|
160
|
+
birth_date: str | None = None,
|
|
161
|
+
identifier: str | None = None,
|
|
162
|
+
) -> dict[str, Any]:
|
|
163
|
+
body: dict[str, str] = {}
|
|
164
|
+
if first_name:
|
|
165
|
+
body["first_name"] = first_name
|
|
166
|
+
if last_name:
|
|
167
|
+
body["last_name"] = last_name
|
|
168
|
+
if birth_date:
|
|
169
|
+
body["birth_date"] = birth_date
|
|
170
|
+
if identifier:
|
|
171
|
+
body["identifier"] = identifier
|
|
172
|
+
return self._client._request("POST", "/v1/sandbox/mpi/match", json=body)
|
|
173
|
+
|
|
174
|
+
def run_aggregator_query(
|
|
175
|
+
self,
|
|
176
|
+
*,
|
|
177
|
+
patient_id: str,
|
|
178
|
+
include_consent: bool = True,
|
|
179
|
+
include_provenance: bool = True,
|
|
180
|
+
) -> dict[str, Any]:
|
|
181
|
+
return self._client._request(
|
|
182
|
+
"POST",
|
|
183
|
+
"/v1/sandbox/aggregator/query",
|
|
184
|
+
json={
|
|
185
|
+
"patient_id": patient_id,
|
|
186
|
+
"include_consent": include_consent,
|
|
187
|
+
"include_provenance": include_provenance,
|
|
188
|
+
},
|
|
189
|
+
)
|
|
190
|
+
|
|
191
|
+
def get_practitioner_credentialing(self, practitioner_id: str) -> dict[str, Any]:
|
|
192
|
+
from urllib.parse import quote
|
|
193
|
+
|
|
194
|
+
return self._client._request(
|
|
195
|
+
"GET",
|
|
196
|
+
f"/v1/sandbox/credentialing/practitioners/{quote(practitioner_id, safe='')}",
|
|
197
|
+
)
|
|
198
|
+
|
|
199
|
+
def synthetic_ehr_profile(self, *, connection_id: str | None = None) -> dict[str, Any]:
|
|
200
|
+
return self._client._request(
|
|
201
|
+
"GET",
|
|
202
|
+
"/v1/sandbox/synthetic-ehr/profile",
|
|
203
|
+
params=self._client._connection_params(connection_id),
|
|
204
|
+
)
|
|
205
|
+
|
|
206
|
+
def list_ehr_models(self) -> list[dict[str, Any]]:
|
|
207
|
+
return self._client._request("GET", "/v1/sandbox/ehr-models")
|
|
208
|
+
|
|
209
|
+
def reset_synthetic_ehr(self, *, connection_id: str | None = None) -> dict[str, Any]:
|
|
210
|
+
return self._client._request(
|
|
211
|
+
"POST",
|
|
212
|
+
"/v1/sandbox/synthetic-ehr/reset",
|
|
213
|
+
params=self._client._connection_params(connection_id),
|
|
214
|
+
)
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
class _SmartResource:
|
|
218
|
+
def __init__(self, client: HebrahClient) -> None:
|
|
219
|
+
self._client = client
|
|
220
|
+
|
|
221
|
+
def launch(
|
|
222
|
+
self,
|
|
223
|
+
*,
|
|
224
|
+
patient_id: str,
|
|
225
|
+
encounter_id: str | None = None,
|
|
226
|
+
smart_app_url: str | None = None,
|
|
227
|
+
) -> dict[str, Any]:
|
|
228
|
+
return self._client._request(
|
|
229
|
+
"POST",
|
|
230
|
+
"/v1/smart/launch",
|
|
231
|
+
json={
|
|
232
|
+
"patient_id": patient_id,
|
|
233
|
+
"encounter_id": encounter_id,
|
|
234
|
+
"smart_app_url": smart_app_url,
|
|
235
|
+
},
|
|
236
|
+
)
|
|
237
|
+
|
|
238
|
+
def register_client(
|
|
239
|
+
self,
|
|
240
|
+
*,
|
|
241
|
+
client_id: str,
|
|
242
|
+
redirect_uris: list[str],
|
|
243
|
+
name: str | None = None,
|
|
244
|
+
) -> dict[str, Any]:
|
|
245
|
+
return self._client._request(
|
|
246
|
+
"POST",
|
|
247
|
+
"/v1/smart/clients",
|
|
248
|
+
json={
|
|
249
|
+
"client_id": client_id,
|
|
250
|
+
"name": name or "Python SDK SMART client",
|
|
251
|
+
"redirect_uris": redirect_uris,
|
|
252
|
+
},
|
|
253
|
+
)
|
|
254
|
+
|
|
255
|
+
def exchange_token(
|
|
256
|
+
self,
|
|
257
|
+
*,
|
|
258
|
+
code: str,
|
|
259
|
+
redirect_uri: str,
|
|
260
|
+
client_id: str,
|
|
261
|
+
code_verifier: str,
|
|
262
|
+
) -> dict[str, Any]:
|
|
263
|
+
try:
|
|
264
|
+
response = httpx.post(
|
|
265
|
+
f"{self._client._base_url}/oauth/token",
|
|
266
|
+
data={
|
|
267
|
+
"grant_type": "authorization_code",
|
|
268
|
+
"code": code,
|
|
269
|
+
"redirect_uri": redirect_uri,
|
|
270
|
+
"client_id": client_id,
|
|
271
|
+
"code_verifier": code_verifier,
|
|
272
|
+
},
|
|
273
|
+
headers={"Content-Type": "application/x-www-form-urlencoded"},
|
|
274
|
+
timeout=30.0,
|
|
275
|
+
)
|
|
276
|
+
except httpx.TimeoutException as exc:
|
|
277
|
+
raise HebrahApiError("SMART token exchange timed out", 504) from exc
|
|
278
|
+
except httpx.RequestError as exc:
|
|
279
|
+
raise HebrahApiError(
|
|
280
|
+
"SMART token exchange failed: control plane unreachable",
|
|
281
|
+
503,
|
|
282
|
+
) from exc
|
|
283
|
+
if not response.is_success:
|
|
284
|
+
raise HebrahApiError(
|
|
285
|
+
f"SMART token exchange failed ({response.status_code})",
|
|
286
|
+
response.status_code,
|
|
287
|
+
self._client._error_detail(response.text),
|
|
288
|
+
)
|
|
289
|
+
return response.json()
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
class _FhirResource:
|
|
293
|
+
def __init__(self, client: HebrahClient) -> None:
|
|
294
|
+
self._client = client
|
|
295
|
+
|
|
296
|
+
def read_patient(self, patient_id: str, access_token: str) -> dict[str, Any]:
|
|
297
|
+
from urllib.parse import quote
|
|
298
|
+
|
|
299
|
+
try:
|
|
300
|
+
response = httpx.get(
|
|
301
|
+
f"{self._client._base_url}/fhir/R4/Patient/{quote(patient_id, safe='')}",
|
|
302
|
+
headers={
|
|
303
|
+
"Authorization": f"Bearer {access_token}",
|
|
304
|
+
"Accept": "application/fhir+json",
|
|
305
|
+
},
|
|
306
|
+
timeout=30.0,
|
|
307
|
+
)
|
|
308
|
+
except httpx.TimeoutException as exc:
|
|
309
|
+
raise HebrahApiError("FHIR Patient read timed out", 504) from exc
|
|
310
|
+
except httpx.RequestError as exc:
|
|
311
|
+
raise HebrahApiError(
|
|
312
|
+
"FHIR Patient read failed: control plane unreachable",
|
|
313
|
+
503,
|
|
314
|
+
) from exc
|
|
315
|
+
if not response.is_success:
|
|
316
|
+
raise HebrahApiError(
|
|
317
|
+
f"FHIR Patient read failed ({response.status_code})",
|
|
318
|
+
response.status_code,
|
|
319
|
+
self._client._error_detail(response.text),
|
|
320
|
+
)
|
|
321
|
+
return response.json()
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
class _PatientsResource:
|
|
325
|
+
def __init__(self, client: HebrahClient) -> None:
|
|
326
|
+
self._client = client
|
|
327
|
+
|
|
328
|
+
def list(self, *, connection_id: str | None = None) -> PatientListResponse:
|
|
329
|
+
warnings.warn(
|
|
330
|
+
"patients.list() is deprecated; use "
|
|
331
|
+
"sandbox.list_synthetic_resources('Patient', connection_id=...).",
|
|
332
|
+
DeprecationWarning,
|
|
333
|
+
stacklevel=2,
|
|
334
|
+
)
|
|
335
|
+
return self._client._request(
|
|
336
|
+
"GET",
|
|
337
|
+
"/v1/patients",
|
|
338
|
+
params=self._client._connection_params(connection_id),
|
|
339
|
+
)
|
|
340
|
+
|
|
341
|
+
def get(self, patient_id: str, *, connection_id: str | None = None) -> dict[str, Any]:
|
|
342
|
+
warnings.warn(
|
|
343
|
+
"patients.get() is deprecated; use sandbox.resource('Patient', patient_id) "
|
|
344
|
+
"for connection-scoped reads.",
|
|
345
|
+
DeprecationWarning,
|
|
346
|
+
stacklevel=2,
|
|
347
|
+
)
|
|
348
|
+
from urllib.parse import quote
|
|
349
|
+
|
|
350
|
+
return self._client._request(
|
|
351
|
+
"GET",
|
|
352
|
+
f"/v1/patients/{quote(patient_id, safe='')}",
|
|
353
|
+
params=self._client._connection_params(connection_id),
|
|
354
|
+
)
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
class _WebhooksResource:
|
|
358
|
+
def __init__(self, client: HebrahClient) -> None:
|
|
359
|
+
self._client = client
|
|
360
|
+
|
|
361
|
+
def trigger_mock_event(
|
|
362
|
+
self,
|
|
363
|
+
*,
|
|
364
|
+
event: str | None = None,
|
|
365
|
+
patient_id: str | None = None,
|
|
366
|
+
connection_id: str | None = None,
|
|
367
|
+
domain_id: str | None = None,
|
|
368
|
+
scenario_id: str | None = None,
|
|
369
|
+
) -> TriggerMockEventResponse:
|
|
370
|
+
body: dict[str, str] = {}
|
|
371
|
+
if event:
|
|
372
|
+
body["event"] = event
|
|
373
|
+
if patient_id:
|
|
374
|
+
body["patient_id"] = patient_id
|
|
375
|
+
resolved_connection = self._client._resolve_connection_id(connection_id)
|
|
376
|
+
if resolved_connection:
|
|
377
|
+
body["connection_id"] = resolved_connection
|
|
378
|
+
if domain_id:
|
|
379
|
+
body["domain_id"] = domain_id
|
|
380
|
+
if scenario_id:
|
|
381
|
+
body["scenario_id"] = scenario_id
|
|
382
|
+
return self._client._request(
|
|
383
|
+
"POST",
|
|
384
|
+
"/v1/webhooks/trigger-mock-event",
|
|
385
|
+
json=body,
|
|
386
|
+
)
|
|
387
|
+
|
|
388
|
+
def list_deliveries(
|
|
389
|
+
self,
|
|
390
|
+
*,
|
|
391
|
+
connection_id: str | None = None,
|
|
392
|
+
status: str | None = None,
|
|
393
|
+
event: str | None = None,
|
|
394
|
+
limit: int | None = None,
|
|
395
|
+
) -> dict[str, Any]:
|
|
396
|
+
params: dict[str, str] = {}
|
|
397
|
+
resolved_connection = self._client._resolve_connection_id(connection_id)
|
|
398
|
+
if resolved_connection:
|
|
399
|
+
params["connection_id"] = resolved_connection
|
|
400
|
+
if status:
|
|
401
|
+
params["status"] = status
|
|
402
|
+
if event:
|
|
403
|
+
params["event"] = event
|
|
404
|
+
if limit is not None:
|
|
405
|
+
params["limit"] = str(limit)
|
|
406
|
+
return self._client._request("GET", "/v1/webhooks/deliveries", params=params or None)
|
|
407
|
+
|
|
408
|
+
def replay_delivery(self, delivery_id: str) -> dict[str, Any]:
|
|
409
|
+
from urllib.parse import quote
|
|
410
|
+
|
|
411
|
+
return self._client._request(
|
|
412
|
+
"POST",
|
|
413
|
+
f"/v1/webhooks/deliveries/{quote(delivery_id, safe='')}/replay",
|
|
414
|
+
)
|
|
415
|
+
|
|
416
|
+
|
|
417
|
+
class HebrahClient:
|
|
418
|
+
"""Sync client for the hebrah control plane API."""
|
|
419
|
+
|
|
420
|
+
def __init__(
|
|
421
|
+
self,
|
|
422
|
+
*,
|
|
423
|
+
api_key: str,
|
|
424
|
+
base_url: str | None = None,
|
|
425
|
+
default_connection_id: str | None = None,
|
|
426
|
+
include_error_detail: bool = True,
|
|
427
|
+
) -> None:
|
|
428
|
+
if not api_key or not api_key.strip():
|
|
429
|
+
raise ValueError("api_key is required")
|
|
430
|
+
self._api_key = api_key.strip()
|
|
431
|
+
self._base_url = resolve_base_url(base_url)
|
|
432
|
+
self._default_connection_id = (
|
|
433
|
+
default_connection_id.strip() if default_connection_id else None
|
|
434
|
+
)
|
|
435
|
+
self._include_error_detail = include_error_detail
|
|
436
|
+
self._http = httpx.Client(
|
|
437
|
+
base_url=self._base_url,
|
|
438
|
+
headers={"Authorization": f"Bearer {self._api_key}"},
|
|
439
|
+
timeout=30.0,
|
|
440
|
+
)
|
|
441
|
+
self.sandbox = _SandboxResource(self)
|
|
442
|
+
self.patients = _PatientsResource(self)
|
|
443
|
+
self.webhooks = _WebhooksResource(self)
|
|
444
|
+
self.smart = _SmartResource(self)
|
|
445
|
+
self.fhir = _FhirResource(self)
|
|
446
|
+
|
|
447
|
+
@property
|
|
448
|
+
def base_url(self) -> str:
|
|
449
|
+
return self._base_url
|
|
450
|
+
|
|
451
|
+
def _resolve_connection_id(self, connection_id: str | None) -> str | None:
|
|
452
|
+
return connection_id or self._default_connection_id
|
|
453
|
+
|
|
454
|
+
def _connection_params(self, connection_id: str | None = None) -> dict[str, str] | None:
|
|
455
|
+
resolved = self._resolve_connection_id(connection_id)
|
|
456
|
+
return {"connection_id": resolved} if resolved else None
|
|
457
|
+
|
|
458
|
+
def _error_detail(self, raw: str | None) -> str | None:
|
|
459
|
+
return raw if self._include_error_detail else None
|
|
460
|
+
|
|
461
|
+
def close(self) -> None:
|
|
462
|
+
self._http.close()
|
|
463
|
+
|
|
464
|
+
def __enter__(self) -> HebrahClient:
|
|
465
|
+
return self
|
|
466
|
+
|
|
467
|
+
def __exit__(self, *args: object) -> None:
|
|
468
|
+
self.close()
|
|
469
|
+
|
|
470
|
+
def health(self) -> dict[str, str]:
|
|
471
|
+
try:
|
|
472
|
+
response = httpx.get(f"{self._base_url}/health", timeout=30.0)
|
|
473
|
+
except httpx.TimeoutException as exc:
|
|
474
|
+
raise HebrahApiError("Health check timed out", 504) from exc
|
|
475
|
+
except httpx.RequestError as exc:
|
|
476
|
+
raise HebrahApiError(
|
|
477
|
+
f"Control plane unreachable at {self._base_url}. Is hebrah-api running?",
|
|
478
|
+
503,
|
|
479
|
+
) from exc
|
|
480
|
+
if not response.is_success:
|
|
481
|
+
raise HebrahApiError(
|
|
482
|
+
f"Health check failed ({response.status_code})",
|
|
483
|
+
response.status_code,
|
|
484
|
+
self._error_detail(response.text),
|
|
485
|
+
)
|
|
486
|
+
return response.json()
|
|
487
|
+
|
|
488
|
+
def _request(
|
|
489
|
+
self,
|
|
490
|
+
method: str,
|
|
491
|
+
path: str,
|
|
492
|
+
*,
|
|
493
|
+
params: dict[str, str] | None = None,
|
|
494
|
+
json: dict[str, str | float | bool] | None = None,
|
|
495
|
+
) -> Any:
|
|
496
|
+
try:
|
|
497
|
+
response = self._http.request(method, path, params=params, json=json)
|
|
498
|
+
except httpx.TimeoutException as exc:
|
|
499
|
+
raise HebrahApiError("Control plane request timed out", 504) from exc
|
|
500
|
+
except httpx.RequestError as exc:
|
|
501
|
+
raise HebrahApiError(
|
|
502
|
+
f"Control plane unreachable at {self._base_url}. Is hebrah-api running?",
|
|
503
|
+
503,
|
|
504
|
+
) from exc
|
|
505
|
+
|
|
506
|
+
if not response.is_success:
|
|
507
|
+
raise HebrahApiError(
|
|
508
|
+
f"Control plane request failed ({response.status_code})",
|
|
509
|
+
response.status_code,
|
|
510
|
+
self._error_detail(response.text),
|
|
511
|
+
)
|
|
512
|
+
|
|
513
|
+
if not response.content:
|
|
514
|
+
return None
|
|
515
|
+
return response.json()
|
hebrah/errors.py
ADDED
hebrah/harness.py
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
from typing import Any
|
|
5
|
+
|
|
6
|
+
import httpx
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class HebrahAgentHarness:
|
|
10
|
+
"""Thin orchestration layer: MCP tools + integration-agent for BYOM EHR modeling."""
|
|
11
|
+
|
|
12
|
+
def __init__(
|
|
13
|
+
self,
|
|
14
|
+
*,
|
|
15
|
+
mcp_url: str,
|
|
16
|
+
pat: str,
|
|
17
|
+
integration_agent_url: str = "http://localhost:3050",
|
|
18
|
+
) -> None:
|
|
19
|
+
self.mcp_url = mcp_url.rstrip("/")
|
|
20
|
+
self.pat = pat
|
|
21
|
+
self.integration_agent_url = integration_agent_url.rstrip("/")
|
|
22
|
+
|
|
23
|
+
def _mcp_call(self, tool: str, args: dict[str, Any] | None = None) -> Any:
|
|
24
|
+
payload = {
|
|
25
|
+
"jsonrpc": "2.0",
|
|
26
|
+
"id": 1,
|
|
27
|
+
"method": "tools/call",
|
|
28
|
+
"params": {"name": tool, "arguments": args or {}},
|
|
29
|
+
}
|
|
30
|
+
with httpx.Client(timeout=60.0) as client:
|
|
31
|
+
res = client.post(
|
|
32
|
+
f"{self.mcp_url}/mcp",
|
|
33
|
+
headers={
|
|
34
|
+
"Content-Type": "application/json",
|
|
35
|
+
"Authorization": f"Bearer {self.pat}",
|
|
36
|
+
},
|
|
37
|
+
json=payload,
|
|
38
|
+
)
|
|
39
|
+
res.raise_for_status()
|
|
40
|
+
body = res.json()
|
|
41
|
+
if body.get("error"):
|
|
42
|
+
raise RuntimeError(body["error"].get("message", "MCP tool error"))
|
|
43
|
+
content = (body.get("result") or {}).get("content") or []
|
|
44
|
+
if content and content[0].get("text"):
|
|
45
|
+
return json.loads(content[0]["text"])
|
|
46
|
+
return body.get("result")
|
|
47
|
+
|
|
48
|
+
def get_developer_doc(self, connection_id: str | None = None) -> Any:
|
|
49
|
+
return self._mcp_call(
|
|
50
|
+
"get_connection_developer_doc",
|
|
51
|
+
{"connectionId": connection_id} if connection_id else {},
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
def get_synthetic_ehr_profile(self, connection_id: str | None = None) -> Any:
|
|
55
|
+
return self._mcp_call(
|
|
56
|
+
"get_synthetic_ehr_profile",
|
|
57
|
+
{"connectionId": connection_id} if connection_id else {},
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
def list_base_ehr_models(self) -> Any:
|
|
61
|
+
return self._mcp_call("list_ehr_base_models")
|
|
62
|
+
|
|
63
|
+
def research_and_model_ehr(
|
|
64
|
+
self,
|
|
65
|
+
*,
|
|
66
|
+
vendor: str,
|
|
67
|
+
connection_id: str,
|
|
68
|
+
doc_urls: list[str] | None = None,
|
|
69
|
+
doc_text: str | None = None,
|
|
70
|
+
) -> Any:
|
|
71
|
+
chunk_ids: list[str] = []
|
|
72
|
+
with httpx.Client(timeout=60.0) as client:
|
|
73
|
+
for url in doc_urls or []:
|
|
74
|
+
res = client.post(
|
|
75
|
+
f"{self.integration_agent_url}/v1/ingest",
|
|
76
|
+
json={"connection_id": connection_id, "url": url},
|
|
77
|
+
)
|
|
78
|
+
if res.is_success:
|
|
79
|
+
chunk_ids.append(res.json()["chunk_id"])
|
|
80
|
+
if doc_text:
|
|
81
|
+
res = client.post(
|
|
82
|
+
f"{self.integration_agent_url}/v1/ingest",
|
|
83
|
+
json={"connection_id": connection_id, "text": doc_text},
|
|
84
|
+
)
|
|
85
|
+
if res.is_success:
|
|
86
|
+
chunk_ids.append(res.json()["chunk_id"])
|
|
87
|
+
gen = client.post(
|
|
88
|
+
f"{self.integration_agent_url}/v1/generate",
|
|
89
|
+
json={
|
|
90
|
+
"connection_id": connection_id,
|
|
91
|
+
"vendor": vendor,
|
|
92
|
+
"doc_chunk_ids": chunk_ids,
|
|
93
|
+
},
|
|
94
|
+
)
|
|
95
|
+
gen.raise_for_status()
|
|
96
|
+
return gen.json()
|
|
97
|
+
|
|
98
|
+
def validate_sandbox(self, connection_id: str | None = None) -> dict[str, Any]:
|
|
99
|
+
profile = self.get_synthetic_ehr_profile(connection_id)
|
|
100
|
+
doc = self.get_developer_doc(connection_id)
|
|
101
|
+
return {"profile": profile, "doc": doc, "ok": bool(profile and doc)}
|
|
102
|
+
|
|
103
|
+
def apply_custom_ehr_model(
|
|
104
|
+
self,
|
|
105
|
+
*,
|
|
106
|
+
connection_id: str,
|
|
107
|
+
model_pack: dict[str, Any],
|
|
108
|
+
dashboard_url: str = "http://localhost:3000",
|
|
109
|
+
confirm_token: str | None = None,
|
|
110
|
+
) -> Any:
|
|
111
|
+
token = confirm_token or f"confirm_{connection_id}"
|
|
112
|
+
with httpx.Client(timeout=60.0) as client:
|
|
113
|
+
res = client.post(
|
|
114
|
+
f"{dashboard_url.rstrip('/')}/api/connections/{connection_id}/byom/apply",
|
|
115
|
+
headers={
|
|
116
|
+
"Authorization": f"Bearer {self.pat}",
|
|
117
|
+
"Content-Type": "application/json",
|
|
118
|
+
},
|
|
119
|
+
json={"modelPack": model_pack, "confirmToken": token},
|
|
120
|
+
)
|
|
121
|
+
if not res.is_success:
|
|
122
|
+
raise RuntimeError(
|
|
123
|
+
f"BYOM apply failed ({res.status_code}): {res.text}"
|
|
124
|
+
)
|
|
125
|
+
return res.json()
|
hebrah/py.typed
ADDED
|
File without changes
|
hebrah/types.py
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
from typing import Any, TypedDict
|
|
5
|
+
|
|
6
|
+
DEFAULT_BASE_URL = "https://api.hebrah.com"
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class SandboxScenarioSummary(TypedDict, total=False):
|
|
10
|
+
id: str
|
|
11
|
+
name: str
|
|
12
|
+
description: str
|
|
13
|
+
events: list[str]
|
|
14
|
+
delay_seconds: float | int
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class SandboxDomainSummary(TypedDict, total=False):
|
|
18
|
+
id: str
|
|
19
|
+
name: str
|
|
20
|
+
description: str
|
|
21
|
+
events: list[str]
|
|
22
|
+
resource_types: list[str]
|
|
23
|
+
hl7_message_types: dict[str, str]
|
|
24
|
+
scenarios: list[SandboxScenarioSummary]
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class SandboxCatalog(TypedDict, total=False):
|
|
28
|
+
org_id: str
|
|
29
|
+
org_name: str
|
|
30
|
+
connection_id: str
|
|
31
|
+
environment: str
|
|
32
|
+
sample_patient_ids: list[str]
|
|
33
|
+
supported_events: list[str]
|
|
34
|
+
example_patient_response: dict[str, Any]
|
|
35
|
+
example_webhook_envelope: dict[str, Any]
|
|
36
|
+
sandbox_domains: list[SandboxDomainSummary]
|
|
37
|
+
event_groups: dict[str, list[str]]
|
|
38
|
+
example_envelopes: dict[str, dict[str, Any]]
|
|
39
|
+
ehr_vendor: str | None
|
|
40
|
+
data_format: str | None
|
|
41
|
+
resource_types: list[str] | None
|
|
42
|
+
field_mappings: list[dict[str, Any]] | None
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
class SandboxResourceListResponse(TypedDict):
|
|
46
|
+
resource_type: str
|
|
47
|
+
ids: list[str]
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
class PayerRules(TypedDict):
|
|
51
|
+
id: str
|
|
52
|
+
name: str
|
|
53
|
+
required_documents: list[str]
|
|
54
|
+
typical_pend_reasons: list[str]
|
|
55
|
+
typical_denial_reasons: list[str]
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
class RunScenarioResponse(TypedDict):
|
|
59
|
+
status: str
|
|
60
|
+
scenario_id: str
|
|
61
|
+
connection_id: str
|
|
62
|
+
events: list[str]
|
|
63
|
+
envelope_previews: list[dict[str, Any]]
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
class PatientSummary(TypedDict):
|
|
67
|
+
id: str
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
class PatientListResponse(TypedDict):
|
|
71
|
+
patients: list[PatientSummary]
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
class TriggerMockEventResponse(TypedDict, total=False):
|
|
75
|
+
status: str
|
|
76
|
+
event: str
|
|
77
|
+
patient_id: str
|
|
78
|
+
connection_id: str
|
|
79
|
+
envelope_preview: dict[str, Any]
|
|
80
|
+
scenario_id: str
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
class WebhookEventEnvelope(TypedDict, total=False):
|
|
84
|
+
event: str
|
|
85
|
+
resource: dict[str, Any]
|
|
86
|
+
connection_id: str
|
|
87
|
+
environment: str
|
|
88
|
+
timestamp: str
|
|
89
|
+
org_id: str
|
|
90
|
+
method: str
|
|
91
|
+
path: str
|
|
92
|
+
status_code: int
|
|
93
|
+
latency_ms: int
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
LOCAL_HTTP_HOSTS = frozenset({"localhost", "127.0.0.1", "[::1]"})
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def assert_safe_base_url(url: str) -> None:
|
|
100
|
+
from urllib.parse import urlparse
|
|
101
|
+
|
|
102
|
+
parsed = urlparse(url)
|
|
103
|
+
if not parsed.scheme or not parsed.netloc:
|
|
104
|
+
raise ValueError(f"Invalid base_url: {url}")
|
|
105
|
+
|
|
106
|
+
if parsed.scheme == "https":
|
|
107
|
+
return
|
|
108
|
+
|
|
109
|
+
if parsed.scheme == "http" and parsed.hostname in LOCAL_HTTP_HOSTS:
|
|
110
|
+
return
|
|
111
|
+
|
|
112
|
+
raise ValueError(
|
|
113
|
+
"base_url must use https:// or http://localhost/127.0.0.1 for local development "
|
|
114
|
+
f"(got {parsed.scheme}://{parsed.hostname})"
|
|
115
|
+
)
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
def resolve_base_url(base_url: str | None = None) -> str:
|
|
119
|
+
url = (base_url or os.environ.get("HEBRAH_API_BASE_URL") or DEFAULT_BASE_URL).rstrip("/")
|
|
120
|
+
assert_safe_base_url(url)
|
|
121
|
+
return url
|
hebrah/webhooks.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import hashlib
|
|
4
|
+
import hmac
|
|
5
|
+
import json
|
|
6
|
+
|
|
7
|
+
from hebrah.types import WebhookEventEnvelope
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def verify_webhook_signature(
|
|
11
|
+
raw_body: bytes | str,
|
|
12
|
+
signature_header: str | None,
|
|
13
|
+
webhook_secret: str,
|
|
14
|
+
) -> WebhookEventEnvelope:
|
|
15
|
+
"""Verify X-Hebrah-Signature (HMAC-SHA256 hex) and return the parsed payload."""
|
|
16
|
+
if not signature_header:
|
|
17
|
+
raise ValueError("Missing X-Hebrah-Signature header")
|
|
18
|
+
|
|
19
|
+
raw = raw_body.encode("utf-8") if isinstance(raw_body, str) else raw_body
|
|
20
|
+
|
|
21
|
+
expected = hmac.new(
|
|
22
|
+
webhook_secret.encode("utf-8"),
|
|
23
|
+
raw,
|
|
24
|
+
hashlib.sha256,
|
|
25
|
+
).hexdigest()
|
|
26
|
+
|
|
27
|
+
if len(signature_header) != len(expected):
|
|
28
|
+
raise ValueError("Invalid webhook signature")
|
|
29
|
+
|
|
30
|
+
if not hmac.compare_digest(expected, signature_header):
|
|
31
|
+
raise ValueError("Invalid webhook signature")
|
|
32
|
+
|
|
33
|
+
return json.loads(raw.decode("utf-8"))
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: hebrah
|
|
3
|
+
Version: 0.8.1
|
|
4
|
+
Summary: Official Python SDK for the hebrah control plane API
|
|
5
|
+
Project-URL: Homepage, https://hebrah.com
|
|
6
|
+
Project-URL: Documentation, https://app.hebrah.com/docs/sdk
|
|
7
|
+
Project-URL: Repository, https://github.com/Hebrah-inc/hebrah-sdk-python
|
|
8
|
+
Author: hebrah
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: fhir,healthcare,hebrah,sdk,webhooks
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Typing :: Typed
|
|
20
|
+
Requires-Python: >=3.10
|
|
21
|
+
Requires-Dist: httpx>=0.27.0
|
|
22
|
+
Provides-Extra: dev
|
|
23
|
+
Requires-Dist: pytest>=8.0.0; extra == 'dev'
|
|
24
|
+
Requires-Dist: respx>=0.21.0; extra == 'dev'
|
|
25
|
+
Requires-Dist: ruff>=0.9.0; extra == 'dev'
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
|
|
28
|
+
# hebrah
|
|
29
|
+
|
|
30
|
+
Official Python SDK for the [hebrah](https://hebrah.com) control plane API (hebrah-api).
|
|
31
|
+
|
|
32
|
+
## Install
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
pip install hebrah
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Requires **Python 3.10+**.
|
|
39
|
+
|
|
40
|
+
## Quick start
|
|
41
|
+
|
|
42
|
+
```python
|
|
43
|
+
import os
|
|
44
|
+
from hebrah import HebrahClient, verify_webhook_signature
|
|
45
|
+
|
|
46
|
+
with HebrahClient(
|
|
47
|
+
api_key=os.environ["HEBRAH_API_KEY"],
|
|
48
|
+
default_connection_id=os.environ.get("HEBRAH_CONNECTION_ID"),
|
|
49
|
+
) as client:
|
|
50
|
+
catalog = client.sandbox.catalog()
|
|
51
|
+
patient_id = catalog["sample_patient_ids"][0]
|
|
52
|
+
patient = client.sandbox.resource("Patient", patient_id)
|
|
53
|
+
|
|
54
|
+
client.webhooks.trigger_mock_event(
|
|
55
|
+
event="patient.admitted",
|
|
56
|
+
patient_id=patient_id,
|
|
57
|
+
)
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
> **v0.8:** `default_connection_id` is applied when sandbox methods omit `connection_id`. `client.patients.list()` / `get()` emit `DeprecationWarning` — use `sandbox.list_synthetic_resources("Patient")` instead.
|
|
61
|
+
|
|
62
|
+
### Webhook verification
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
from hebrah import verify_webhook_signature
|
|
66
|
+
|
|
67
|
+
payload = verify_webhook_signature(
|
|
68
|
+
request.get_data(),
|
|
69
|
+
request.headers.get("X-Hebrah-Signature"),
|
|
70
|
+
webhook_secret,
|
|
71
|
+
)
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Security
|
|
75
|
+
|
|
76
|
+
- Store `HEBRAH_API_KEY` and `HEBRAH_WEBHOOK_SECRET` in server-side environment variables or a secrets manager only — never expose them to browsers or commit `.env` files.
|
|
77
|
+
- The SDK does not persist credentials; they live in memory for the lifetime of each `HebrahClient` instance.
|
|
78
|
+
- `base_url` must be `https://` in production, or `http://localhost` / `http://127.0.0.1` for local dev — other `http://` hosts are rejected at construction to reduce API-key exfiltration risk.
|
|
79
|
+
- Treat `HebrahApiError.detail` as operator-only diagnostics. Do not log or return it to end users — it may contain internal paths or sensitive API error payloads. Set `include_error_detail=False` on `HebrahClient` to omit `detail` from errors.
|
|
80
|
+
|
|
81
|
+
See [SECURITY.md](./SECURITY.md) for supported versions and vulnerability reporting.
|
|
82
|
+
|
|
83
|
+
## API surface (v0.8)
|
|
84
|
+
|
|
85
|
+
### Sandbox & resources
|
|
86
|
+
|
|
87
|
+
| Method | Description |
|
|
88
|
+
|--------|-------------|
|
|
89
|
+
| `client.health()` | `GET /health` (no API key on separate httpx call) |
|
|
90
|
+
| `client.sandbox.catalog(connection_id=None)` | `GET /v1/sandbox/catalog` — uses `default_connection_id` when omitted |
|
|
91
|
+
| `client.sandbox.domains()` | `GET /v1/sandbox/domains` |
|
|
92
|
+
| `client.sandbox.domain(domain_id)` | `GET /v1/sandbox/domains/{id}` |
|
|
93
|
+
| `client.sandbox.list_synthetic_resources(resource_type, connection_id=None)` | `GET /v1/sandbox/resources/{type}` |
|
|
94
|
+
| `client.sandbox.resource(resource_type, resource_id, patient_id=None)` | `GET /v1/sandbox/resources/{type}/{id}` |
|
|
95
|
+
| `client.sandbox.run_scenario(scenario_id, ...)` | `POST /v1/sandbox/scenarios/{id}/run` |
|
|
96
|
+
| `client.sandbox.synthetic_ehr_profile(connection_id=...)` | `GET /v1/sandbox/synthetic-ehr/profile` |
|
|
97
|
+
| `client.sandbox.list_ehr_models()` | `GET /v1/sandbox/ehr-models` |
|
|
98
|
+
| `client.sandbox.reset_synthetic_ehr(connection_id=...)` | `POST /v1/sandbox/synthetic-ehr/reset` |
|
|
99
|
+
| `client.sandbox.payer_rules(payer_id)` | `GET /v1/sandbox/payer-rules/{id}` |
|
|
100
|
+
| `client.patients.list(connection_id=None)` | **Deprecated** — `GET /v1/patients` |
|
|
101
|
+
| `client.patients.get(id, connection_id=None)` | **Deprecated** — `GET /v1/patients/{id}` |
|
|
102
|
+
|
|
103
|
+
### HL7, webhooks, interop
|
|
104
|
+
|
|
105
|
+
| Method | Description |
|
|
106
|
+
|--------|-------------|
|
|
107
|
+
| `client.sandbox.hl7_templates()` | `GET /v1/sandbox/hl7/templates` |
|
|
108
|
+
| `client.sandbox.inject_hl7(...)` | `POST /v1/sandbox/hl7/inject` |
|
|
109
|
+
| `client.sandbox.configure_webhook_reliability(**profile)` | `PATCH /v1/sandbox/webhook-reliability` |
|
|
110
|
+
| `client.sandbox.run_webhook_reliability_scenario(scenario_id, ...)` | `POST /v1/sandbox/scenarios/{id}/run` (alias) |
|
|
111
|
+
| `client.sandbox.run_mpi_match(...)` | `POST /v1/sandbox/mpi/match` |
|
|
112
|
+
| `client.sandbox.run_aggregator_query(...)` | `POST /v1/sandbox/aggregator/query` |
|
|
113
|
+
| `client.sandbox.get_practitioner_credentialing(practitioner_id)` | `GET /v1/sandbox/credentialing/practitioners/{id}` |
|
|
114
|
+
| `client.webhooks.trigger_mock_event(...)` | `POST /v1/webhooks/trigger-mock-event` |
|
|
115
|
+
| `client.webhooks.list_deliveries(...)` | `GET /v1/webhooks/deliveries` |
|
|
116
|
+
| `client.webhooks.replay_delivery(delivery_id)` | `POST /v1/webhooks/deliveries/{id}/replay` |
|
|
117
|
+
| `verify_webhook_signature(raw_body, signature, secret)` | Local HMAC-SHA256 verify |
|
|
118
|
+
|
|
119
|
+
### SMART & FHIR
|
|
120
|
+
|
|
121
|
+
| Method | Description |
|
|
122
|
+
|--------|-------------|
|
|
123
|
+
| `client.smart.launch(...)` | `POST /v1/smart/launch` |
|
|
124
|
+
| `client.smart.register_client(...)` | `POST /v1/smart/clients` |
|
|
125
|
+
| `client.smart.exchange_token(...)` | `POST /oauth/token` (form-encoded; no API key) |
|
|
126
|
+
| `client.fhir.read_patient(patient_id, access_token)` | `GET /fhir/R4/Patient/{id}` (SMART access token) |
|
|
127
|
+
|
|
128
|
+
### Advanced: BYOM agent harness
|
|
129
|
+
|
|
130
|
+
`HebrahAgentHarness` is exported for bring-your-own-model EHR workflows (MCP + integration-agent). It is **not** part of the core integrator quick start — harness improvements are tracked separately from the core client.
|
|
131
|
+
|
|
132
|
+
## Configuration
|
|
133
|
+
|
|
134
|
+
| Variable | Description |
|
|
135
|
+
|----------|-------------|
|
|
136
|
+
| `HEBRAH_API_KEY` | Pass to `HebrahClient(api_key=...)` |
|
|
137
|
+
| `HEBRAH_API_BASE_URL` | Optional; default `https://api.hebrah.com` |
|
|
138
|
+
| `HEBRAH_CONNECTION_ID` | Optional; pass to `default_connection_id` for sandbox reads |
|
|
139
|
+
| `HEBRAH_WEBHOOK_SECRET` | For `verify_webhook_signature` |
|
|
140
|
+
|
|
141
|
+
## Docs
|
|
142
|
+
|
|
143
|
+
Full integrator reference: [hebrah-app `/docs/sdk`](https://app.hebrah.com/docs/sdk).
|
|
144
|
+
|
|
145
|
+
## License
|
|
146
|
+
|
|
147
|
+
MIT
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
hebrah/__init__.py,sha256=qcOEZDBw9CWPTmW9hF4FDlD4DZa_kQu_yi228SVTavE,383
|
|
2
|
+
hebrah/client.py,sha256=GO8VWylmeA1CAaYo0Nr9aOpZRjrjqLZLqHrmkwYPAKg,16686
|
|
3
|
+
hebrah/errors.py,sha256=VuNSyhZyr72K3WjeFLc4YsZ8MzjWw8wBOFhcjrpocV4,287
|
|
4
|
+
hebrah/harness.py,sha256=zgVxBbVrTSZmXeYxQY64jrCn6kgLukGi9zoEbVJfsQo,4472
|
|
5
|
+
hebrah/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
+
hebrah/types.py,sha256=ub1hs2qGLD76OZ_--Yi_JkW2PJg7WM-K7x6qMy4uFxs,2843
|
|
7
|
+
hebrah/webhooks.py,sha256=KobTpOmJP648YN9fCkpqh177FgN0ZgM8kbdBE6FAWCA,903
|
|
8
|
+
SECURITY.md,sha256=UetLWOPGRi6hLKSkkv-CdMQTpQUntzbAk3sCa8zwlUM,1451
|
|
9
|
+
hebrah-0.8.1.dist-info/METADATA,sha256=drC-L1GjpztFRi-SgazUc7yjU8T-l1xfGW3K-Fx1I0k,6408
|
|
10
|
+
hebrah-0.8.1.dist-info/WHEEL,sha256=lCkmxWfQsSc9CfIClYeavTdQeEX2toPqufh9gI35EQA,87
|
|
11
|
+
hebrah-0.8.1.dist-info/licenses/LICENSE,sha256=HElH-jMejKWrn_uksovpqgADmPChn2mGdADHDmJ0IOg,1069
|
|
12
|
+
hebrah-0.8.1.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Hebrah, Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|