@care-portals/patient-sdk
v1.13.0
Published
CarePortal patient API SDK
Readme
@care-portals/patient-sdk
A TypeScript SDK for interacting with the CarePortal Patient API.
Installation
npm install @care-portals/patient-sdkUsage
import { createPatientApiClient } from '@care-portals/patient-sdk';
// Initialize the client
const client = new PatientApi({
organization: 'your-organization-id',
baseUrl: 'url to api instance' // optional, defaults to https://patient-api.portals.care and can be used to point to other envionments
token: 'your-auth-token' // Optional, can be set later
});
// Set token if not provided during initialization
client.setToken('your-auth-token');
// Use the client
const profile = await client.customer.profile.get();
const orders = await client.orders.list('cart-id');
const subscriptions = await client.subscriptions.list();API Reference
Authentication
client.setToken(token: string)- Set the authentication token
Customer Management
client.customer.profile.get()- Get customer profileclient.customer.profile.update(data)- Update customer profileclient.customer.account.get()- Get account informationclient.customer.addresses.list()- List customer addressesclient.customer.addresses.updateDefault(data)- Update default addressclient.customer.password.update(currentPassword, newPassword)- Update passwordclient.customer.requirements.list()- Get account requirementsclient.customer.persona.getStatus()- Get persona verification statusclient.customer.persona.getLink(redirectUri)- Get persona verification linkclient.customer.paymentMethods.list()- List payment methodsclient.customer.ids.upload(files)- Upload ID documentsclient.customer.email.check(email, origin)- Check email availability
Orders
client.orders.retrieve(orderId)- Get order detailsclient.orders.list(cartId)- List orders for a cartclient.orders.payments.create(orderId, paymentMethodId, returnUrl)- Create paymentclient.orders.payments.confirm(orderId)- Confirm paymentclient.orders.prescriptions.list(orderId)- List prescriptions for an orderclient.orders.shippingAddress.update(orderId, address)- Update shipping address
Checkout
client.checkout.start(cartId)- Start checkout processclient.checkout.session.retrieve(cartId, couponCode?)- Get checkout sessionclient.checkout.payments.create(cartId, paymentData)- Create checkout paymentclient.checkout.payments.confirm(cartId)- Confirm checkout payment
Subscriptions
client.subscriptions.list()- List subscriptionsclient.subscriptions.retrieve(id, populate?)- Get subscription detailsclient.subscriptions.cancel(id)- Cancel subscriptionclient.subscriptions.update(id, data)- Update subscriptionclient.subscriptions.history.list(id)- Get subscription historyclient.subscriptions.renewal.skip(id)- Skip renewalclient.subscriptions.renewal.renew(id)- Renew subscriptionclient.subscriptions.billing.getPortalLink()- Get billing portal link
Messages
client.messages.list(params?)- List messagesclient.messages.retrieve(id)- Get message detailsclient.messages.reply(inboundDto)- Reply to message
Files
client.files.retrieve(fileName)- Get file detailsclient.files.upload(files)- Upload multiple filesclient.files.uploadSingle(file)- Upload single file
Logs
client.logs.all(params?)- Get all logs (weight + injections combined, sorted by date)client.logs.recentActivity(params?)- Get recent activity (limited list of recent logs)client.logs.weight.list(params?)- List weight logsclient.logs.weight.create(data)- Create weight logclient.logs.weight.update(id, data)- Update weight logclient.logs.weight.delete(id)- Delete weight logclient.logs.injections.list(params?)- List injection logsclient.logs.injections.create(data)- Create injection logclient.logs.injections.update(id, data)- Update injection logclient.logs.injections.delete(id)- Delete injection log
Purchases
client.purchases.list()- List purchasesclient.purchases.retrieve(orderId, purchaseId)- Get purchase detailsclient.purchases.history.list(id)- Get purchase history
Authentication
client.auth.login(username, password)- Loginclient.auth.password.requestReset(email)- Request password resetclient.auth.password.validateResetToken(token)- Validate reset tokenclient.auth.password.reset(token, password)- Reset passwordclient.auth.signup(user)- Sign up new user
Types
The SDK includes comprehensive TypeScript types for all API responses and request parameters. All types are exported from the main package.
Error Handling
The SDK throws errors for HTTP errors and network issues. Error objects include:
status: HTTP status code (0 for network errors)data: Error response datamethod: HTTP methodurl: Request URLbody: Request bodyparams: Query parametersheaders: Request headers
License
MIT
