Kulcare Docs
DeveloperBilling03 api reference

Medical Records APIs

This document covers all medical records-related endpoints for managing prescriptions, medical documents, patient history, and health records.

Authentication

All medical records endpoints require authentication. Include the JWT token in the Authorization header:

Authorization: Bearer YOUR_AUTH_TOKEN

Base URLs

  • Prescriptions: /prescriptions
  • Medical Documents: /medical_documents
  • Care Plans: /care_plans
  • Medical History: /medical_history
  • Vitals: /vitals

Endpoints Overview

Prescriptions

MethodEndpointDescription
GET/prescriptionsList prescriptions
POST/prescriptionsCreate prescription
GET/prescriptions/:idGet prescription details
PUT/prescriptions/:idUpdate prescription
DELETE/prescriptions/:idDelete prescription
POST/prescriptions/:id/printGenerate prescription PDF
POST/prescriptions/:id/sendSend prescription to patient

Medical Documents

MethodEndpointDescription
GET/medical_documentsList documents
POST/medical_documentsUpload document
GET/medical_documents/:idGet document details
PUT/medical_documents/:idUpdate document
DELETE/medical_documents/:idDelete document
GET/medical_documents/:id/downloadDownload document

Care Plans

MethodEndpointDescription
GET/care_plansList care plans
POST/care_plansCreate care plan
GET/care_plans/:idGet care plan details
PUT/care_plans/:idUpdate care plan
DELETE/care_plans/:idDelete care plan

Medical History

MethodEndpointDescription
GET/patients/:id/medical_historyGet patient medical history
POST/patients/:id/medical_historyAdd medical history entry
PUT/medical_history/:idUpdate history entry

Vitals

MethodEndpointDescription
GET/patients/:id/vitalsGet patient vitals
POST/patients/:id/vitalsRecord vitals
GET/vitals/:idGet specific vital record

Prescriptions

GET /prescriptions

List prescriptions with filtering options.

Query Parameters

ParameterTypeDescription
patient_idIntegerFilter by patient
doctor_idIntegerFilter by doctor
appointment_idIntegerFilter by appointment
start_dateStringDate range start
end_dateStringDate range end
statusStringFilter by status
pageIntegerPage number

Status Values

  • active - Currently valid prescription
  • completed - Treatment completed
  • cancelled - Cancelled by doctor
  • expired - Past validity period

Example Request

curl -X GET "http://localhost:3000/prescriptions?patient_id=456&status=active" \
  -H "Authorization: Bearer YOUR_AUTH_TOKEN"

Example Response

{
  "success": true,
  "data": [
    {
      "id": 123,
      "patient_id": 456,
      "doctor_id": 789,
      "appointment_id": 101,
      "prescription_date": "2025-01-15",
      "status": "active",
      "diagnosis": "Common cold with mild fever",
      "symptoms": ["Fever", "Cough", "Body aches"],
      "patient": {
        "id": 456,
        "first_name": "John",
        "last_name": "Doe",
        "age": 35,
        "gender": "M"
      },
      "doctor": {
        "id": 789,
        "first_name": "Dr. Sarah",
        "last_name": "Smith",
        "speciality": "General Physician",
        "registration_number": "MCI123456"
      },
      "medicines": [
        {
          "id": 1,
          "medicine_name": "Paracetamol",
          "generic_name": "Acetaminophen",
          "dosage": "500mg",
          "frequency": "Twice daily",
          "duration": "5 days",
          "quantity": 10,
          "instructions": "Take after meals",
          "morning": true,
          "afternoon": false,
          "evening": true,
          "before_food": false,
          "after_food": true
        },
        {
          "id": 2,
          "medicine_name": "Azithromycin",
          "generic_name": "Azithromycin",
          "dosage": "250mg",
          "frequency": "Once daily",
          "duration": "3 days",
          "quantity": 3,
          "instructions": "Take on empty stomach",
          "morning": true,
          "afternoon": false,
          "evening": false,
          "before_food": true,
          "after_food": false
        }
      ],
      "investigations": [
        {
          "id": 1,
          "test_name": "Complete Blood Count",
          "notes": "If fever persists after 3 days",
          "urgent": false
        }
      ],
      "advice": [
        "Rest for 2-3 days",
        "Drink plenty of fluids",
        "Avoid cold foods"
      ],
      "follow_up_date": "2025-01-22",
      "created_at": "2025-01-15T10:30:00Z"
    }
  ],
  "meta": {
    "page": 1,
    "per_page": 20,
    "total": 5
  }
}

POST /prescriptions

Create a new prescription.

Request Body

{
  "prescription": {
    "patient_id": 456,
    "appointment_id": 101,
    "diagnosis": "Common cold with mild fever",
    "symptoms": ["Fever", "Cough", "Body aches"],
    "medicines": [
      {
        "medicine_name": "Paracetamol",
        "generic_name": "Acetaminophen",
        "dosage": "500mg",
        "frequency": "Twice daily",
        "duration": "5 days",
        "quantity": 10,
        "instructions": "Take after meals",
        "morning": true,
        "evening": true,
        "after_food": true
      }
    ],
    "investigations": [
      {
        "test_name": "Complete Blood Count",
        "notes": "If fever persists",
        "urgent": false
      }
    ],
    "advice": [
      "Rest for 2-3 days",
      "Drink plenty of fluids"
    ],
    "follow_up_date": "2025-01-22"
  }
}

Example Request

curl -X POST http://localhost:3000/prescriptions \
  -H "Authorization: Bearer YOUR_AUTH_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "prescription": {
      "patient_id": 456,
      "diagnosis": "Common cold",
      "medicines": [
        {
          "medicine_name": "Paracetamol",
          "dosage": "500mg",
          "frequency": "Twice daily",
          "duration": "5 days"
        }
      ]
    }
  }'

Success Response (201 Created)

{
  "success": true,
  "data": {
    "id": 123,
    "prescription_number": "RX-2025-001",
    "patient_id": 456,
    "diagnosis": "Common cold",
    "status": "active",
    "prescription_date": "2025-01-15",
    "medicines": [...],
    "created_at": "2025-01-15T10:30:00Z"
  },
  "message": "Prescription created successfully"
}

POST /prescriptions/:id/print

Generate printable PDF for prescription.

Query Parameters

ParameterTypeDescription
formatStringOutput format (pdf/html)
templateStringTemplate style (default/letterhead)

Example Request

curl -X POST "http://localhost:3000/prescriptions/123/print?format=pdf" \
  -H "Authorization: Bearer YOUR_AUTH_TOKEN"

Success Response

{
  "success": true,
  "data": {
    "download_url": "/downloads/prescriptions/RX-2025-001.pdf",
    "expires_at": "2025-01-15T12:30:00Z"
  }
}

POST /prescriptions/:id/send

Send prescription to patient via SMS/WhatsApp/Email.

Request Body

{
  "send_via": ["sms", "whatsapp"],
  "include_pdf": true,
  "custom_message": "Your prescription is ready for pickup"
}

Example Request

curl -X POST http://localhost:3000/prescriptions/123/send \
  -H "Authorization: Bearer YOUR_AUTH_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "send_via": ["whatsapp"],
    "include_pdf": true
  }'

Medical Documents

GET /medical_documents

List medical documents with filtering.

Query Parameters

ParameterTypeDescription
patient_idIntegerFilter by patient
document_typeStringFilter by document type
start_dateStringDate range start
end_dateStringDate range end
pageIntegerPage number

Document Types

  • lab_report - Laboratory test results
  • scan - Medical imaging (X-ray, MRI, etc.)
  • prescription - Prescription documents
  • discharge_summary - Hospital discharge summary
  • vaccination_record - Vaccination certificates
  • insurance - Insurance documents
  • other - Other medical documents

Example Request

curl -X GET "http://localhost:3000/medical_documents?patient_id=456&document_type=lab_report" \
  -H "Authorization: Bearer YOUR_AUTH_TOKEN"

Example Response

{
  "success": true,
  "data": [
    {
      "id": 789,
      "patient_id": 456,
      "document_type": "lab_report",
      "title": "Complete Blood Count Report",
      "description": "CBC test results from Apollo Lab",
      "document_date": "2025-01-14",
      "file_name": "cbc_report_20250114.pdf",
      "file_size": 245760,
      "mime_type": "application/pdf",
      "url": "/documents/789/cbc_report_20250114.pdf",
      "thumbnail_url": "/documents/789/thumbnail.jpg",
      "tags": ["blood_test", "routine_checkup"],
      "uploaded_by": {
        "id": 101,
        "name": "Dr. Sarah Smith",
        "type": "doctor"
      },
      "patient": {
        "id": 456,
        "name": "John Doe"
      },
      "created_at": "2025-01-14T16:45:00Z"
    }
  ],
  "meta": {
    "page": 1,
    "per_page": 20,
    "total": 12
  }
}

POST /medical_documents

Upload a new medical document.

Request (Multipart Form)

Content-Type: multipart/form-data

patient_id: 456
document_type: lab_report
title: Complete Blood Count Report
description: CBC test results
document_date: 2025-01-14
tags: blood_test,routine
file: [binary file data]

Example Request (using curl)

curl -X POST http://localhost:3000/medical_documents \
  -H "Authorization: Bearer YOUR_AUTH_TOKEN" \
  -F "patient_id=456" \
  -F "document_type=lab_report" \
  -F "title=CBC Report" \
  -F "file=@/path/to/document.pdf"

Success Response (201 Created)

{
  "success": true,
  "data": {
    "id": 789,
    "patient_id": 456,
    "document_type": "lab_report",
    "title": "Complete Blood Count Report",
    "file_name": "cbc_report_20250114.pdf",
    "url": "/documents/789/cbc_report_20250114.pdf",
    "created_at": "2025-01-14T16:45:00Z"
  },
  "message": "Document uploaded successfully"
}

Care Plans

GET /care_plans

List care plans for patients.

Query Parameters

ParameterTypeDescription
patient_idIntegerFilter by patient
statusStringFilter by status (active/completed/cancelled)
conditionStringFilter by medical condition

Example Request

curl -X GET "http://localhost:3000/care_plans?patient_id=456" \
  -H "Authorization: Bearer YOUR_AUTH_TOKEN"

Example Response

{
  "success": true,
  "data": [
    {
      "id": 321,
      "patient_id": 456,
      "title": "Diabetes Management Plan",
      "condition": "Type 2 Diabetes",
      "status": "active",
      "start_date": "2025-01-15",
      "end_date": "2025-04-15",
      "created_by": {
        "id": 789,
        "name": "Dr. Sarah Smith"
      },
      "goals": [
        {
          "id": 1,
          "title": "Maintain HbA1c below 7%",
          "target_value": "7.0",
          "current_value": "8.2",
          "unit": "%",
          "due_date": "2025-04-15"
        },
        {
          "id": 2,
          "title": "Lose 5kg weight",
          "target_value": "70",
          "current_value": "75",
          "unit": "kg",
          "due_date": "2025-04-15"
        }
      ],
      "tasks": [
        {
          "id": 1,
          "title": "Check blood sugar daily",
          "frequency": "daily",
          "status": "active",
          "last_completed": "2025-01-14"
        },
        {
          "id": 2,
          "title": "Take Metformin",
          "frequency": "twice_daily",
          "status": "active",
          "instructions": "500mg with breakfast and dinner"
        }
      ],
      "appointments": [
        {
          "id": 101,
          "appointment_date": "2025-02-15",
          "type": "follow_up",
          "status": "scheduled"
        }
      ],
      "notes": "Patient needs regular monitoring of blood glucose levels",
      "created_at": "2025-01-15T09:00:00Z"
    }
  ]
}

POST /care_plans

Create a new care plan.

Request Body

{
  "care_plan": {
    "patient_id": 456,
    "title": "Diabetes Management Plan",
    "condition": "Type 2 Diabetes",
    "start_date": "2025-01-15",
    "end_date": "2025-04-15",
    "goals": [
      {
        "title": "Maintain HbA1c below 7%",
        "target_value": "7.0",
        "unit": "%",
        "due_date": "2025-04-15"
      }
    ],
    "tasks": [
      {
        "title": "Check blood sugar daily",
        "frequency": "daily",
        "instructions": "Check fasting and post-meal"
      }
    ],
    "notes": "Regular monitoring required"
  }
}

Medical History

GET /patients/:id/medical_history

Get patient's complete medical history.

Query Parameters

ParameterTypeDescription
categoryStringFilter by category (allergies/medications/surgeries)
start_dateStringDate range start
end_dateStringDate range end

Example Request

curl -X GET http://localhost:3000/patients/456/medical_history \
  -H "Authorization: Bearer YOUR_AUTH_TOKEN"

Example Response

{
  "success": true,
  "data": {
    "patient_id": 456,
    "patient": {
      "id": 456,
      "name": "John Doe",
      "age": 35,
      "gender": "M"
    },
    "allergies": [
      {
        "id": 1,
        "allergen": "Penicillin",
        "reaction": "Skin rash",
        "severity": "moderate",
        "notes": "Developed rash after taking antibiotic",
        "recorded_date": "2024-06-15"
      }
    ],
    "chronic_conditions": [
      {
        "id": 1,
        "condition": "Type 2 Diabetes",
        "diagnosed_date": "2023-03-20",
        "status": "active",
        "notes": "Well controlled with Metformin"
      }
    ],
    "medications": [
      {
        "id": 1,
        "medicine_name": "Metformin",
        "dosage": "500mg",
        "frequency": "Twice daily",
        "start_date": "2023-03-20",
        "status": "active",
        "prescribed_by": "Dr. Sarah Smith"
      }
    ],
    "surgeries": [
      {
        "id": 1,
        "procedure": "Appendectomy",
        "date": "2020-08-15",
        "hospital": "City General Hospital",
        "surgeon": "Dr. Michael Johnson",
        "notes": "Laparoscopic procedure, no complications"
      }
    ],
    "family_history": [
      {
        "id": 1,
        "relation": "Father",
        "condition": "Hypertension",
        "age_of_onset": 45
      }
    ],
    "social_history": {
      "smoking": "never",
      "alcohol": "occasional",
      "exercise": "regular",
      "diet": "balanced"
    }
  }
}

POST /patients/:id/medical_history

Add new medical history entry.

Request Body

{
  "medical_history": {
    "category": "allergy",
    "allergen": "Peanuts",
    "reaction": "Anaphylaxis",
    "severity": "severe",
    "notes": "Immediate reaction after eating peanuts"
  }
}

Vitals

GET /patients/:id/vitals

Get patient's vital signs history.

Query Parameters

ParameterTypeDescription
start_dateStringDate range start
end_dateStringDate range end
vital_typeStringFilter by vital type
limitIntegerNumber of records to return

Vital Types

  • all - All vital signs
  • blood_pressure - Blood pressure readings
  • weight - Weight measurements
  • temperature - Temperature readings
  • pulse - Pulse rate
  • blood_sugar - Blood glucose levels

Example Request

curl -X GET "http://localhost:3000/patients/456/vitals?limit=10" \
  -H "Authorization: Bearer YOUR_AUTH_TOKEN"

Example Response

{
  "success": true,
  "data": [
    {
      "id": 567,
      "patient_id": 456,
      "recorded_date": "2025-01-15",
      "recorded_by": {
        "id": 789,
        "name": "Nurse Mary",
        "type": "staff"
      },
      "vitals": {
        "weight": 75.5,
        "height": 175,
        "bmi": 24.6,
        "temperature": 98.6,
        "bp_systolic": 120,
        "bp_diastolic": 80,
        "pulse": 72,
        "respiratory_rate": 16,
        "oxygen_saturation": 98,
        "blood_sugar_fasting": 110,
        "blood_sugar_pp": 140
      },
      "notes": "Patient feeling well",
      "appointment_id": 101,
      "created_at": "2025-01-15T09:30:00Z"
    }
  ],
  "meta": {
    "page": 1,
    "total": 25
  }
}

POST /patients/:id/vitals

Record new vital signs.

Request Body

{
  "vitals": {
    "weight": 75.5,
    "height": 175,
    "temperature": 98.6,
    "bp_systolic": 120,
    "bp_diastolic": 80,
    "pulse": 72,
    "respiratory_rate": 16,
    "oxygen_saturation": 98,
    "blood_sugar_fasting": 110,
    "notes": "Patient feeling well"
  }
}

Example Request

curl -X POST http://localhost:3000/patients/456/vitals \
  -H "Authorization: Bearer YOUR_AUTH_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "vitals": {
      "weight": 75.5,
      "bp_systolic": 120,
      "bp_diastolic": 80,
      "pulse": 72
    }
  }'

Document Templates

GET /document_templates

Get available prescription and document templates.

Example Response

{
  "success": true,
  "data": [
    {
      "id": 1,
      "name": "Standard Prescription",
      "type": "prescription",
      "description": "Standard prescription template with clinic letterhead",
      "fields": ["doctor_info", "patient_info", "medicines", "advice"]
    },
    {
      "id": 2,
      "name": "Discharge Summary",
      "type": "discharge_summary",
      "description": "Hospital discharge summary template",
      "fields": ["admission_details", "diagnosis", "treatment", "discharge_instructions"]
    }
  ]
}

Medical Coding

GET /icd_codes/search

Search ICD-10 diagnosis codes.

Query Parameters

ParameterTypeDescription
queryStringSearch term
limitIntegerNumber of results

Example Request

curl -X GET "http://localhost:3000/icd_codes/search?query=diabetes&limit=10" \
  -H "Authorization: Bearer YOUR_AUTH_TOKEN"

Example Response

{
  "success": true,
  "data": [
    {
      "code": "E11",
      "description": "Type 2 diabetes mellitus",
      "category": "Endocrine, nutritional and metabolic diseases"
    },
    {
      "code": "E11.9",
      "description": "Type 2 diabetes mellitus without complications",
      "category": "Endocrine, nutritional and metabolic diseases"
    }
  ]
}

Error Codes

CodeDescription
400Bad Request - Invalid parameters
401Unauthorized - Invalid or missing token
403Forbidden - No permission to access records
404Not Found - Record doesn't exist
413Payload Too Large - File size too large
415Unsupported Media Type - Invalid file type
422Unprocessable Entity - Validation errors

File Upload Limits

File TypeMax SizeAllowed Formats
Images5MBJPG, PNG, GIF
Documents10MBPDF, DOC, DOCX
Lab Reports20MBPDF, JPG, PNG

Common Error Messages

{
  "success": false,
  "error": "File too large",
  "details": "Maximum file size allowed is 10MB"
}
{
  "success": false,
  "error": "Invalid file type",
  "details": "Only PDF, JPG, PNG files are allowed"
}

On this page