@healthcloudai/hc-dependents-connector
v0.0.3
Published
Healthcheck Dependents connector for authenticated patient dependent persons flows.
Downloads
204
Maintainers
Readme
Healthcheck Dependents Connector
This library provides a client for authenticated patient dependent persons flows in Healthcheck. It is built on top of the shared Healthcheck HTTP and Login connectors.
Features
- Retrieve dependent persons for the authenticated patient
- Update dependent persons for the authenticated patient
- Built on the shared Healthcheck HttpClient and authentication layer
Installation
npm install @healthcloudai/hc-dependents-connector \
@healthcloudai/hc-login-connector \
@healthcloudai/hc-httpImport
import { HCDependentsClient } from "@healthcloudai/hc-dependents-connector";
import { HCLoginClient } from "@healthcloudai/hc-login-connector";
import { FetchClient } from "@healthcloudai/hc-http";Usage
Configuration
const httpClient = new FetchClient();
const authClient = new HCLoginClient(httpClient);
authClient.configure("demo-tenant", "dev");
await authClient.login("[email protected]", "ExamplePassword123!");
const dependentsClient = new HCDependentsClient(
httpClient,
authClient
);API Key
Use setApiKey(...) to attach an API key header to requests from HCDependentsClient.
const apiKey = process.env.HEALTHCLOUD_API_KEY;
if (!apiKey) {
throw new Error("HEALTHCLOUD_API_KEY is required.");
}
dependentsClient.setApiKey("x-api-key", apiKey);- Header name should be
x-api-key.
Methods
The Dependents connector includes two authenticated patient methods:
getDependents()updateDepentents(dependents)
Dependents methods
getDependents
Returns dependent persons for the authenticated patient.
const dependents = await dependentsClient.getDependents();API response
Status:
200{
"Data": [
{
"FirstName": "Jane",
"LastName": "Doe",
"BirthDate": "01/01/2015",
"Relationship": "Child"
}
],
"IsOK": true,
"ErrorMessage": null
}updateDepentents
Updates dependent persons for the authenticated patient.
const updated = await dependentsClient.updateDepentents([
{
FirstName: "Jane",
LastName: "Doe",
BirthDate: "01/01/2015",
Relationship: "Child"
}
]);Request body
{
"Data": [
{
"FirstName": "Jane",
"LastName": "Doe",
"BirthDate": "01/01/2015",
"Relationship": "Child"
}
]
}API response
Status:
200{
"Data": true,
"IsOK": true,
"ErrorMessage": null
}How It Works
HCLoginClienthandles tenant configuration, authentication, and authenticated headers.HCDependentsClientuses the authenticated login client for the base API URL and authenticated request headers.- If configured through
setApiKey(...),HCDependentsClientalso includes its configured API key header with Dependents connector requests. getDependents()retrieves dependent persons through the authenticated patient session and does not send a request body.updateDepentents()wraps the provided dependent persons array inside the backendDatarequest wrapper.
Notes
HCLoginClientmust be configured and logged in before calling Dependents connector methods.- The connector uses the authenticated patient context from the login client.
getDependents()returns the backend response containing dependent persons inData.
