@haau3/sdk 0.0.0 → 0.1.1
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.
- package/LICENSE +21 -0
- package/README.md +146 -2
- package/dist/index.cjs +892 -0
- package/dist/index.d.cts +4501 -0
- package/dist/index.d.mts +4501 -0
- package/dist/index.mjs +886 -0
- package/package.json +65 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Brian K. Fung Media LLC, doing business as haau3
|
|
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.
|
package/README.md
CHANGED
|
@@ -1,9 +1,153 @@
|
|
|
1
1
|
# @haau3/sdk
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The TypeScript SDK for the [haau3 platform API](https://docs.haau3.com): scheduling, the provider
|
|
4
|
+
directory, terminology, questionnaires, plan benefits and MedList, as typed calls.
|
|
5
|
+
|
|
6
|
+
The haau3 platform API is in preview: it may change as we build, usually to add features or improve performance.
|
|
7
|
+
|
|
8
|
+
## Install
|
|
4
9
|
|
|
5
10
|
```sh
|
|
6
11
|
npm install @haau3/sdk
|
|
7
12
|
```
|
|
8
13
|
|
|
9
|
-
The SDK
|
|
14
|
+
Node 22 or newer. The SDK runs on a server only: it refuses to start in a browser, where your API
|
|
15
|
+
key would be public.
|
|
16
|
+
|
|
17
|
+
## Authenticate
|
|
18
|
+
|
|
19
|
+
Create an API key on [platform.haau3.com](https://platform.haau3.com), then set it as
|
|
20
|
+
`HAAU3_API_KEY` or pass it as `apiKey`.
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
import { Haau3 } from "@haau3/sdk";
|
|
24
|
+
|
|
25
|
+
const haau3 = new Haau3(); // reads HAAU3_API_KEY
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## A first call
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
const plan = await haau3.readInsurancePlan("H2406-013-000");
|
|
32
|
+
console.log(plan.name); // "AARP Medicare Advantage from UHC FL-0021 (PPO)"
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
FHIR answers are [@types/fhir](https://www.npmjs.com/package/@types/fhir)'s R4 types, also
|
|
36
|
+
exported as `fhir4` (`import type { fhir4 } from "@haau3/sdk"`).
|
|
37
|
+
|
|
38
|
+
## One call per service
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
// Scheduling: open appointment slots, here in Boston.
|
|
42
|
+
const { slots, total } = await haau3.searchSlots({ city: "Boston", state: "MA", limit: 10 });
|
|
43
|
+
|
|
44
|
+
// Provider directory: a practitioner by NPI, from CMS's National Provider Directory.
|
|
45
|
+
const practitioners = await haau3.searchPractitioner({ identifier: "1093209884" });
|
|
46
|
+
|
|
47
|
+
// Terminology: a LOINC code's display and properties.
|
|
48
|
+
const glucose = await haau3.codeSystemLookup({ system: "http://loinc.org", code: "2345-7" });
|
|
49
|
+
|
|
50
|
+
// Questionnaires: a form by its id, such as the PHQ-9.
|
|
51
|
+
const phq9 = await haau3.readQuestionnaire("44249-1");
|
|
52
|
+
|
|
53
|
+
// Plan Benefits: a Medicare Advantage or ACA Marketplace plan, and which providers are in its network.
|
|
54
|
+
const plan = await haau3.readInsurancePlan("H2406-013-000");
|
|
55
|
+
const network = await haau3.checkInsurancePlanNetwork("H3359-038-000", { npi: ["1518929058"] });
|
|
56
|
+
|
|
57
|
+
// MedList: one reconciled medication list from one patient's FHIR medication records. It receives
|
|
58
|
+
// patient data, so send it only under an executed agreement.
|
|
59
|
+
const list = await haau3.reconcileMedications(records);
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Every method, grouped by service, with its request and a link to its page on docs.haau3.com, is in
|
|
63
|
+
[api.md](https://github.com/haau3/haau3-node/blob/main/api.md). Each is named by its operationId,
|
|
64
|
+
with its parameters and its answer typed from the published spec.
|
|
65
|
+
|
|
66
|
+
## Options
|
|
67
|
+
|
|
68
|
+
| Option | Default | |
|
|
69
|
+
|---|---|---|
|
|
70
|
+
| `apiKey` | `process.env.HAAU3_API_KEY` | Your platform API key. |
|
|
71
|
+
| `baseURL` | `https://api.haau3.com` | Where the API is. |
|
|
72
|
+
| `timeout` | `65000` | Milliseconds one attempt may take. |
|
|
73
|
+
| `maxRetries` | `1` | Retries after a timeout, a network failure, a 429 or a 5xx. |
|
|
74
|
+
| `fetch` | the global `fetch` | The fetch to send requests with. |
|
|
75
|
+
|
|
76
|
+
Each call takes `{ timeout, maxRetries, signal, headers }` as its last argument, for that call only:
|
|
77
|
+
|
|
78
|
+
```ts
|
|
79
|
+
await haau3.searchSlots({ state: "MA" }, { timeout: 10_000, maxRetries: 0 });
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
A retry waits a short, growing interval, or what the API's `Retry-After` header says when that is
|
|
83
|
+
60 seconds or less. A longer `Retry-After` fails at once, carrying it.
|
|
84
|
+
|
|
85
|
+
## Errors
|
|
86
|
+
|
|
87
|
+
Every error is a `Haau3Error`, with the `requestId` the API answered with. There are three kinds:
|
|
88
|
+
|
|
89
|
+
```ts
|
|
90
|
+
import { AuthError, NoAnswerError, RefusedError } from "@haau3/sdk";
|
|
91
|
+
|
|
92
|
+
try {
|
|
93
|
+
await haau3.readInsurancePlan(id);
|
|
94
|
+
} catch (error) {
|
|
95
|
+
if (error instanceof RefusedError) {
|
|
96
|
+
error.status; // 400, 404, 410 and so on
|
|
97
|
+
error.outcome; // the OperationOutcome; Scheduling's errors carry `problem`
|
|
98
|
+
} else if (error instanceof NoAnswerError) {
|
|
99
|
+
error.reason; // "timeout", "network", "rate-limited", "unavailable", "server-error" or "unreadable"
|
|
100
|
+
error.retryAfter; // seconds, when the API said
|
|
101
|
+
} else if (error instanceof AuthError) {
|
|
102
|
+
// the key was missing, unknown or revoked
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
No answer is never reported as an empty result, and an empty result is never an error. An error's
|
|
108
|
+
message never includes the body the API answered with, and the body (`outcome` or `problem`) is
|
|
109
|
+
never printed when the error is logged.
|
|
110
|
+
|
|
111
|
+
## Paging
|
|
112
|
+
|
|
113
|
+
`pages()` yields a FHIR search's first page and every page after it:
|
|
114
|
+
|
|
115
|
+
```ts
|
|
116
|
+
const first = await haau3.searchInsurancePlan({ "coverage-area-state": "NC" });
|
|
117
|
+
for await (const page of haau3.pages(first)) {
|
|
118
|
+
for (const entry of page.entry ?? []) console.log(entry.resource?.id);
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Scheduling's searches page with `limit` and `offset`, and answer with a `total`.
|
|
123
|
+
|
|
124
|
+
## Several requests in one
|
|
125
|
+
|
|
126
|
+
```ts
|
|
127
|
+
const answers = await haau3.fhirBatch({
|
|
128
|
+
resourceType: "Bundle",
|
|
129
|
+
type: "batch",
|
|
130
|
+
entry: [
|
|
131
|
+
{ request: { method: "GET", url: "CodeSystem/$lookup?system=http://loinc.org&code=2345-7" } },
|
|
132
|
+
{ request: { method: "GET", url: "InsurancePlan/$counties?state=NC" } },
|
|
133
|
+
],
|
|
134
|
+
});
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## Any request
|
|
138
|
+
|
|
139
|
+
`request()` sends a request as you give it and returns what the API answered, whatever the
|
|
140
|
+
status, with its headers, request id, attempts and duration:
|
|
141
|
+
|
|
142
|
+
```ts
|
|
143
|
+
const { status, body, requestId } = await haau3.request({ method: "GET", path: "/v1/scheduling/publishers" });
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## Versions
|
|
147
|
+
|
|
148
|
+
The SDK is `0.y.z` while the API is in preview: a minor release may change what a method takes or
|
|
149
|
+
answers, and a patch release never does.
|
|
150
|
+
|
|
151
|
+
## License
|
|
152
|
+
|
|
153
|
+
[MIT](LICENSE)
|