TypeScript SDK Kotlin (Android) SDK Codex Prompts

SDKs & Client Libraries

PatientPulse ships a TypeScript SDK for web/Node integrations and a Kotlin SDK (generated contracts) for the PulseVault Android app. Both are generated from the OpenAPI spec to stay in sync with the API.

📦
TypeScript SDK
For web apps, Next.js, Node.js backends, and React frontends
TypeScript
Language
ESM + CJS
Modules
Auto-gen
Source
@patientpulse/sdk v2.0.0 MIT License
INSTALL
$npm install @patientpulse/sdk
OR WITH YARN
$yarn add @patientpulse/sdk

Quick Start — TypeScript

TypeScript
import { PatientPulseClient } from '@patientpulse/sdk';

// Initialize client
const client = new PatientPulseClient({
  apiKey: process.env.PP_API_KEY,
  baseUrl: 'https://api.patientpulse.in',
  env: 'production',
});

// Request OTP for patient login
const otpRes = await client.auth.requestOtp({
  phone: '+919876543210',
  channel: 'sms',
});

// Verify OTP and get session
const session = await client.auth.verifyOtp({
  phone: '+919876543210',
  otp: '123456',
});

// Book an appointment
const appointment = await client.appointments.book({
  patientId: session.user.id,
  doctorId: 'doc_xyz',
  slotId: 'slot_abc',
  visitType: 'opd',
});

// Interpret a lab report with AI
const result = await client.ai.interpretLabReport({
  recordId: 'rec_lab_001',
  patientId: session.user.id,
  includeHistory: true,
});

console.log(result.interpretation.summary);
// → "HbA1c elevated at 7.8% — borderline diabetic range."

// Export patient as FHIR R4 bundle
const fhirBundle = await client.interop.exportFhirR4(session.user.id);
console.log(fhirBundle.resourceType); // → "Bundle"

SDK Modules

client.auth

OTP, Google OAuth, SSO, MFA, session management

client.appointments

Book, reschedule, cancel, availability slots

client.patients

Profiles, records, check-in, uploads

client.ai

Lab interpretation, ambient scribe, forecasting

client.interop

FHIR R4, ABDM linking, PHR push/pull

client.insurance

Claims, NHCX submission, payer rules

client.payments

Razorpay orders, verification, receipts

client.analytics

Benchmarks, operational insights, command center

client.bureau

Data contracts, patient snapshots, consent

client.admin

Platform provisioning, org onboarding, governance

📦 TypeScript SDK — Codex Generation Prompt

The TypeScript SDK does not yet exist as a published package. See the Codex Prompts section below for the exact prompt to generate it from the OpenAPI spec.

🤖
Kotlin Android SDK
Generated contracts for PulseVault — Retrofit interfaces + Kotlin data models
Kotlin 2.3
Language
Retrofit
Networking
KSP
Code Gen
packages/kotlin-sdk Multi-module Hilt DI
GRADLE (build.gradle.kts)
implementation("in.patientpulse:kotlin-sdk:2.0.0")

Quick Start — Kotlin (Android)

Kotlin
// Hilt-provided via core:network module
class VaultRepository @Inject constructor(
    private val api: PulseVaultApi,
    private val db: VaultDatabase,
) {
    suspend fun getVault(profileId: String): VaultScreen {
        return api.getVault(profileId)
    }

    suspend fun uploadRecord(
        profileId: String,
        file: MultipartBody.Part,
    ): HealthRecord {
        val session = api.initiateUpload(profileId)
        // Upload to object storage, then complete
        return api.completeUpload(session.uploadSessionId)
    }

    suspend fun startAiExtraction(
        profileId: String,
        recordId: String,
    ): ExtractionJob {
        return api.createExtractionJob(profileId, recordId)
    }
}

// In your Composable screen:
val vault by viewModel.vaultState.collectAsState()
VaultScreen(vault = vault)

Android Module Structure

core:model

Kotlin data classes — all API request/response contracts

core:network

Retrofit interfaces + OkHttp client + generated SDK

core:database

Room entities for offline-first persistence

core:data

Repository pattern + sync orchestration

core:auth

EncryptedSharedPreferences session storage

core:ui

Shared Compose design system components

⚠ Health Connect Permission

To read wearable data (steps, heart rate, sleep), declare android.permission.health.READ_STEPS etc. in AndroidManifest.xml and request runtime permissions before calling Health Connect APIs.

Codex Prompts

The following are ready-to-use prompts you can run in Codex / Claude to extend the SDK or add missing pieces — without touching the core repos.

Generate TypeScript SDK from OpenAPI

High Priority

Creates the publishable @patientpulse/sdk npm package from the OpenAPI 3.0 spec exported from PatientPulse.

Codex Prompt
Generate a TypeScript SDK package (@patientpulse/sdk) from the PatientPulse
OpenAPI 3.0 specification located at /backend/app/main_monolith.py (FastAPI
auto-generates the spec at /openapi.json).

Requirements:
- Use openapi-typescript-codegen or similar tool
- Output to packages/typescript-sdk/src/
- Export a PatientPulseClient class with typed sub-clients for each domain:
  auth, appointments, patients, ai, interop, insurance, payments, analytics, bureau
- All methods should be async and return typed response objects
- Include error handling with typed PatientPulseError class
- Add README.md with installation and quick-start examples
- Target: ESM + CommonJS dual build via tsup
- Include types for all 50+ Pydantic request/response schemas

Publish Kotlin SDK to Maven Central

Medium Priority

Converts the existing packages/kotlin-sdk into a publishable Maven artifact.

Codex Prompt
Configure the existing Kotlin SDK at packages/kotlin-sdk to be publishable
to Maven Central (or GitHub Packages as a first step).

Requirements:
- Add maven-publish plugin to build.gradle.kts
- Group: in.patientpulse, artifactId: kotlin-sdk, version from git tag
- Generate sources JAR and Javadoc JAR
- Add signing configuration (use environment variables for CI)
- Create GitHub Actions workflow: .github/workflows/publish-kotlin-sdk.yml
  that triggers on tag push (v*.*.*)
- Update README with Gradle and Maven installation instructions

Add Developer Portal API Key Management Backend

High Priority

Adds real API key issuance, rotation, and scoping to the PatientPulse backend to power this developer portal.

Codex Prompt
Add a developer API key management system to the PatientPulse FastAPI backend.

New endpoints to add in a new route file backend/app/routes/developer_keys.py:
- POST   /developer/keys          — issue new API key (sandbox or production)
- GET    /developer/keys          — list all keys for authenticated developer
- DELETE /developer/keys/{key_id} — revoke a key
- POST   /developer/keys/{key_id}/rotate — rotate a key

Schema requirements:
- ApiKey: id, prefix (first 8 chars), hashed_secret, environment (sandbox/production),
  scopes (list), created_at, last_used_at, revoked_at
- Store only the SHA-256 hash of the secret; return plaintext only on creation
- Scopes: read:patients, write:appointments, read:claims, ai:interpret, interop:fhir
- Register routes in main_domains/ registry under a new 'developer' chunk
- Add middleware to validate pp_sandbox_sk_ and pp_live_sk_ key format on all /v2/ routes

OpenAPI Spec Export Endpoint

Quick Win

FastAPI already generates an OpenAPI spec — this prompt exposes it with proper versioning and auth bypass.

Codex Prompt
In backend/app/main_monolith.py, ensure the FastAPI OpenAPI spec is:
1. Accessible at GET /openapi.json without authentication
2. Versioned as "2.0.0" in the info block
3. Includes x-patientpulse-env tag on each endpoint (clinical, ai, interop, billing, admin)
4. Has proper security scheme defined: BearerAuth (HTTP bearer JWT)
5. Export a static copy to docs/openapi.json on app startup when APP_ENV=development
   using app.openapi() and json.dump()

Also expose Swagger UI at /docs and ReDoc at /redoc (FastAPI does this by default —
just confirm they are not disabled in production via DISABLE_DOCS env var check).
Getting Started Guide → API Reference