Kulcare Docs
DeveloperSubscriptions

Patient Package Subscriptions API

Overview

The Patient Package Subscriptions API provides endpoints for managing patient subscriptions to care packages. This allows patients to subscribe to service packages that include multiple healthcare services at discounted rates.

Base URL: /api

Authentication: Bearer token required

Headers:

Authorization: Bearer {token}
X-Tenant-ID: {tenant_id}

Endpoints

1. List All Subscriptions

List all patient package subscriptions across the tenant with optional filters.

Endpoint: GET /identity/patient_package_subscriptions

Query Parameters:

ParameterTypeRequiredDefaultDescription
patient_facility_idstringNo-Filter by patient facility ID
patient_idstringNo-Filter by patient ID
service_package_idstringNo-Filter by service package ID
facility_idstringNo-Filter by facility ID
statusstringNo-Filter by status (active, expired, cancelled, pending, on_hold)
include_expiredbooleanNofalseInclude expired subscriptions in results
currently_activebooleanNofalseOnly show currently active subscriptions
pageintegerNo1Page number
per_pageintegerNo25Items per page (max 100)
sort_bystringNocreated_atSort column (created_at, start_ts, expiry_ts, status, name)
sort_orderstringNodescSort order (asc, desc)

Response: 200 OK

{
  "data": [
    {
      "id": "019c89f1-7a31-7637-ab47-16a0c98c4e45",
      "status": "active",
      "start_ts": "2025-01-15T10:30:00Z",
      "expiry_ts": "2026-01-15T10:30:00Z",
      "patient_id": "019c79c4-eae6-7889-a3e2-588b9a02f112",
      "patient_facility_id": "019c79c4-eb06-7157-9a0f-7a7f5146b2db",
      "service_package_id": "019c89ef-5c6b-774b-8409-a589be298ed1",
      "facility_id": "01900002-0000-7000-8000-000000000001",
      "name": "Annual Health Checkup Package",
      "duration_unit": "days",
      "duration_frequency": 365,
      "benefits_consumed": 2,
      "active": true,
      "expired": false
    }
  ],
  "meta": {
    "request_id": "uuid",
    "pagination": {
      "total_entries": 50,
      "total_pages": 2,
      "current_page": 1,
      "per_page": 25
    }
  }
}

2. Show Subscription Details

Get detailed information about a specific subscription including service package details.

Endpoint: GET /identity/patient_package_subscriptions/:id

Path Parameters:

ParameterTypeRequiredDescription
idstringYesSubscription ID

Query Parameters:

ParameterTypeRequiredDefaultDescription
viewstringNodetailedResponse view (normal, detailed)

Response: 200 OK

{
  "data": {
    "id": "019c89f1-7a31-7637-ab47-16a0c98c4e45",
    "status": "active",
    "start_ts": "2025-01-15T10:30:00Z",
    "expiry_ts": "2026-01-15T10:30:00Z",
    "patient_id": "019c79c4-eae6-7889-a3e2-588b9a02f112",
    "patient_facility_id": "019c79c4-eb06-7157-9a0f-7a7f5146b2db",
    "service_package_id": "019c89ef-5c6b-774b-8409-a589be298ed1",
    "facility_id": "01900002-0000-7000-8000-000000000001",
    "name": "Annual Health Checkup Package",
    "duration_unit": "days",
    "duration_frequency": 365,
    "benefits_consumed": 2,
    "remaining_benefits": 8,
    "active": true,
    "expired": false,
    "service_package": {
      "id": "019c89ef-5c6b-774b-8409-a589be298ed1",
      "name": "Annual Health Checkup Package",
      "display_name": "Complete Health Package",
      "package_type": "health_checkup",
      "category": "wellness",
      "is_active": true,
      "total_price": 15000,
      "currency": "INR",
      "display": "Complete Health Package",
      "available": true,
      "formatted_price": "₹15,000"
    }
  },
  "meta": {
    "request_id": "uuid"
  }
}

3. List Subscriptions by Patient Facility

List all subscriptions for a specific patient facility.

Endpoint: GET /clinical/patient_facilities/:patient_facility_id/package_subscriptions

Path Parameters:

ParameterTypeRequiredDescription
patient_facility_idstringYesPatient Facility ID

Query Parameters: Same as List All Subscriptions

Response: 200 OK

Same response format as List All Subscriptions.


4. List Subscriptions by Patient

List all subscriptions for a specific patient across all facilities.

Endpoint: GET /clinical/patients/:patient_id/package_subscriptions

Path Parameters:

ParameterTypeRequiredDescription
patient_idstringYesPatient ID

Query Parameters: Same as List All Subscriptions

Response: 200 OK

Same response format as List All Subscriptions.


5. List Subscriptions by Service Package

List all subscriptions for a specific service package.

Endpoint: GET /identity/service_packages/:service_package_id/subscriptions

Path Parameters:

ParameterTypeRequiredDescription
service_package_idstringYesService Package ID

Query Parameters: Same as List All Subscriptions

Response: 200 OK

Same response format as List All Subscriptions.


Data Models

Subscription Status

StatusDescription
pendingSubscription created but not yet active
activeSubscription is currently active
expiredSubscription has passed expiry date
cancelledSubscription was cancelled
on_holdSubscription is temporarily suspended

Subscription Object Fields

FieldTypeDescription
idstringUnique subscription identifier
statusstringCurrent subscription status
start_tsdatetimeSubscription start timestamp
expiry_tsdatetimeSubscription expiry timestamp (null if no expiry)
patient_idstringAssociated patient ID
patient_facility_idstringAssociated patient facility ID
service_package_idstringAssociated service package ID
facility_idstringFacility where subscription was created
namestringSubscription/package name
duration_unitstringDuration unit (days, months, years)
duration_frequencyintegerDuration value
benefits_consumedintegerNumber of benefits/services used
activebooleanWhether subscription is currently active
expiredbooleanWhether subscription has expired

Pagination Response

FieldTypeDescription
total_entriesintegerTotal number of records
total_pagesintegerTotal number of pages
current_pageintegerCurrent page number
per_pageintegerRecords per page

Common Use Cases

Get Active Subscriptions for a Patient

GET /clinical/patients/{patient_id}/package_subscriptions?status=active&currently_active=true

Get Expired Subscriptions

GET /identity/patient_package_subscriptions?status=expired&include_expired=true&sort_by=expiry_ts&sort_order=desc

Get Subscriptions Near Expiry

GET /identity/patient_package_subscriptions?status=active&sort_by=expiry_ts&sort_order=asc

Get All Subscriptions for a Facility

GET /identity/patient_package_subscriptions?facility_id={facility_id}&include_expired=true

Error Responses

Validation Error (422)

{
  "success": false,
  "errors": [
    {
      "detail": "Patient facility not found"
    }
  ]
}

Not Found (404)

{
  "error": {
    "code": "NOT_FOUND",
    "message": "Resource not found"
  }
}

Unauthorized (401)

{
  "error": "Unauthorized"
}

Notes

  1. Default Filtering: By default, the API excludes expired subscriptions unless include_expired=true is explicitly set.

  2. Active Status: The active field in the response considers both the status field and the expiry timestamp. A subscription is active only if:

    • status is active
    • expiry_ts is null OR in the future
  3. Patient Reference: The patient_id field contains a UUID reference to the patient in the clinical.patients table, but patient details are not included in the subscription response.

  4. Pagination: All list endpoints support pagination. Use page and per_page parameters to navigate through results.

  5. Sorting: Results can be sorted by any field in the sort_by list. Default is created_at in descending order (newest first).


  • Service Packages API: /api/identity/service_packages - Manage care package definitions
  • Patient Facilities API: /api/clinical/patient_facilities - Manage patient-facility associations
  • Patients API: /api/clinical/patients - Manage patient records

On this page