Kulcare Docs
DeveloperPatients

Patient Uploads APIs

APIs for uploading patient files (photos, documents) within the Clinical domain.

Overview

Patient Uploads APIs handle individual file uploads for patients.

Base Path: /clinical/patient_uploads

Authentication: Required for all endpoints

Facility Context: Required - facility is derived from session/context

Endpoints

Upload Patient File

Upload a patient file (photos, PDFs, Excel, etc.) to the system.

POST /clinical/patient_uploads/upload_file

Content-Type: multipart/form-data

Parameters:

ParameterTypeRequiredDescription
fileFileYesThe file to upload (max size: 50MB)
document_typeStringNoType of document (e.g., photo, pdf, excel, lab_report)

Headers:

Authorization: Bearer <YOUR_AUTH_TOKEN>

Example Request:

curl -X POST "http://localhost:3000/clinical/patient_uploads/upload_file" \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiJ9..." \
  -F "file=@/path/to/document.pdf" \
  -F "document_type=lab_report"

Success Response (HTTP 201):

{
  "data": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "file_name": "document.pdf",
    "status": "processed",
    "document": {
      "id": "550e8400-e29b-41d4-a716-446655440001",
      "file_name": "document.pdf",
      "file_path": "patient_uploads/550e8400-e29b-41d4-a716-446655440000/document.pdf"
    }
  },
  "meta": {
    "request_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
  }
}

Error Response (HTTP 422):

{
  "data": null,
  "error": {
    "code": "validation_failed",
    "message": "Validation failed: File is required",
    "details": [
      {
        "field": "base",
        "message": "File is required"
      }
    ]
  },
  "meta": {
    "request_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
  }
}

Get Upload Status

Get the status of patient uploads for the current facility.

GET /clinical/patient_uploads/status

Headers:

Authorization: Bearer <YOUR_AUTH_TOKEN>

Example Request:

curl -X GET "http://localhost:3000/clinical/patient_uploads/status" \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiJ9..."

Success Response (HTTP 200):

{
  "data": {
    "patient_file_uploaded": true,
    "patients_uploaded": true,
    "statistics": {
      "total_uploads": 15,
      "csv_uploads": 10,
      "file_uploads": 5,
      "processed_count": 12,
      "failed_count": 2,
      "processing_count": 1,
      "success_rate": 80.0
    }
  },
  "meta": {
    "request_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
  }
}

Generate Patient Report

Generate and export patient data to XLS format. The report is sent to the facility's registered email address.

POST /clinical/patients/generate_report

Headers:

Authorization: Bearer <YOUR_AUTH_TOKEN>

Example Request:

curl -X POST "http://localhost:3000/clinical/patients/generate_report" \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiJ9..."

Success Response (HTTP 200):

{
  "data": {
    "patient_count": 16,
    "message": "Report generated and sent to your email successfully"
  },
  "meta": {
    "request_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
  }
}

Error Response (HTTP 422):

{
  "data": null,
  "error": {
    "code": "validation_failed",
    "message": "Error message here",
    "details": [
      {
        "field": "base",
        "message": "Error message here"
      }
    ]
  },
  "meta": {
    "request_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
  }
}

Notes:

  • Exports all patients linked to the current facility
  • Maximum of 10,000 patients can be exported
  • The XLS file is sent via email to the facility's registered email address
  • Report columns: Patient ID, Patient Name, Phone Number, Gender, Age, Address, City, State, Pincode, Created On

Status Codes

StatusDescription
processingUpload is being processed
processedUpload completed successfully
failedUpload failed

Notes

  • All endpoints require a valid Authorization token
  • Facility context is automatically derived from the user's session
  • Slack notifications are sent when files are uploaded
  • Email notifications are sent to admins for file uploads

On this page