Kulcare Docs
DeveloperCare plansLhrTesting

Manual Test Plan: FHIR Longitudinal Health Records APIs

Overview

This document provides a comprehensive manual test plan for the FHIR-compliant Longitudinal Health Records APIs. These APIs support the frontend CMS interface at /cms/prescription/patient/{patientId}/{appointmentId} with 6 tabs.

Prerequisites

1. Environment Setup

  • Backend server running on http://localhost:3000 (or your configured port)
  • Valid authentication token
  • Test clinic with at least one doctor, patient, and appointment

2. Authentication Setup

All API requests require JWT authentication:

Authorization: Bearer <your_jwt_token>
Content-Type: application/json

3. Test Data Requirements

You'll need the following test data:

  • Clinic ID: Valid clinic identifier
  • Patient ID: Valid patient identifier
  • Appointment ID: Valid appointment identifier
  • Doctor ID: Valid doctor identifier

API Endpoints Overview

TabEndpointPurpose
VitalsGET/PUT /appointments/{appointment_id}/clinical_observations/vitalsManage patient vital signs
ObservationsGET/PUT /appointments/{appointment_id}/clinical_impressionsClinical assessments and observations
MedicationsGET/POST /appointments/{appointment_id}/medication_requestsMedication management
InvestigationsGET/POST /appointments/{appointment_id}/service_requestsLab tests and investigations
AdviceGET/PUT /appointments/{appointment_id}/care_plans/advicePatient care advice
Next VisitGET/POST /appointments/{appointment_id}/care_plans/follow_upFollow-up planning

Test Cases

1. Vitals Tab Tests

Test Case 1.1: Get Vitals Data

Endpoint: GET /appointments/{appointment_id}/clinical_observations/vitals

Request:

GET /appointments/123/clinical_observations/vitals
Authorization: Bearer <token>

Expected Response (200 OK):

{
  "appointment_id": "123",
  "patient_id": "456", 
  "vital_signs": {
    "blood_pressure": {
      "systolic": 120,
      "diastolic": 80,
      "unit": "mmHg",
      "measured_at": "2025-09-16T10:30:00Z"
    },
    "heart_rate": {
      "value": 72,
      "unit": "bpm",
      "measured_at": "2025-09-16T10:30:00Z"
    }
  },
  "normal_ranges": {
    "blood_pressure": {"systolic": [90, 140], "diastolic": [60, 90]},
    "heart_rate": [60, 100]
  }
}

Test Case 1.2: Update Vitals Data

Endpoint: PUT /appointments/{appointment_id}/clinical_observations/vitals

Request:

PUT /appointments/123/clinical_observations/vitals
Authorization: Bearer <token>
Content-Type: application/json

{
  "vital_signs": {
    "blood_pressure": {
      "systolic": 130,
      "diastolic": 85,
      "unit": "mmHg",
      "measured_at": "2025-09-16T11:00:00Z"
    },
    "heart_rate": {
      "value": 78,
      "unit": "bpm", 
      "measured_at": "2025-09-16T11:00:00Z"
    },
    "temperature": {
      "value": 98.6,
      "unit": "°F",
      "measured_at": "2025-09-16T11:00:00Z"
    }
  }
}

Expected Response (200 OK):

{
  "appointment_id": "123",
  "patient_id": "456",
  "vital_signs": {
    // Updated vital signs data
  }
}

2. Observations Tab Tests

Test Case 2.1: Get Clinical Impressions

Endpoint: GET /appointments/{appointment_id}/clinical_impressions

Request:

GET /appointments/123/clinical_impressions
Authorization: Bearer <token>

Expected Response (200 OK):

{
  "appointment_id": "123",
  "patient_id": "456",
  "clinical_assessment": {
    "chief_complaint": "Chest pain for 2 hours",
    "history_present_illness": "Patient reports sharp chest pain...",
    "past_medical_history": "Hypertension, controlled on medication"
  },
  "physical_examination": {
    "general_appearance": "Well-appearing, no acute distress",
    "cardiovascular": "Regular rate and rhythm, no murmurs"
  },
  "assessment": {
    "provisional_diagnosis": ["Chest pain, likely muscular"],
    "clinical_impression": "Low risk for cardiac etiology"
  }
}

Test Case 2.2: Update Clinical Impressions

Endpoint: PUT /appointments/{appointment_id}/clinical_impressions

Request:

PUT /appointments/123/clinical_impressions
Authorization: Bearer <token>
Content-Type: application/json

{
  "clinical_assessment": {
    "chief_complaint": "Updated chest pain assessment",
    "history_present_illness": "Patient reports improved symptoms"
  },
  "assessment": {
    "provisional_diagnosis": ["Resolved chest pain"],
    "clinical_impression": "Symptoms resolved with treatment"
  }
}

3. Medications Tab Tests

Test Case 3.1: Get Medication Requests

Endpoint: GET /appointments/{appointment_id}/medication_requests

Request:

GET /appointments/123/medication_requests
Authorization: Bearer <token>

Expected Response (200 OK):

{
  "appointment_id": "123",
  "patient_id": "456",
  "active_medications": [
    {
      "id": "med-001",
      "medication_name": "Lisinopril",
      "strength": "10mg",
      "form": "Tablet",
      "dosage_instruction": "Take 1 tablet by mouth once daily",
      "status": "active"
    }
  ],
  "current_prescription_medications": [],
  "drug_interactions": [],
  "allergies": ["Penicillin"]
}

Test Case 3.2: Add New Medication

Endpoint: POST /appointments/{appointment_id}/medication_requests

Request:

POST /appointments/123/medication_requests
Authorization: Bearer <token>
Content-Type: application/json

{
  "medication": {
    "medication_name": "Ibuprofen",
    "strength": "400mg",
    "form": "Tablet", 
    "dosage_instruction": "Take 1 tablet by mouth every 6 hours as needed",
    "frequency": "q6h PRN",
    "quantity": 20,
    "duration": "7 days",
    "instructions": "Take with food"
  }
}

Expected Response (201 Created):

{
  "id": "med-002",
  "medication_name": "Ibuprofen",
  "status": "active",
  "created_at": "2025-09-16T11:00:00Z"
}

4. Investigations Tab Tests

Test Case 4.1: Get Service Requests

Endpoint: GET /appointments/{appointment_id}/service_requests

Request:

GET /appointments/123/service_requests
Authorization: Bearer <token>

Expected Response (200 OK):

{
  "appointment_id": "123",
  "patient_id": "456",
  "ordered_tests": [
    {
      "id": "test-001",
      "service_name": "Complete Blood Count",
      "service_type": "lab_test",
      "status": "ordered",
      "urgency": "routine",
      "ordered_date": "2025-09-16"
    }
  ],
  "completed_tests": [],
  "imaging_studies": []
}

Test Case 4.2: Order New Investigation

Endpoint: POST /appointments/{appointment_id}/service_requests

Request:

POST /appointments/123/service_requests
Authorization: Bearer <token>
Content-Type: application/json

{
  "service": {
    "service_name": "Basic Metabolic Panel",
    "service_type": "lab_test",
    "category": "Chemistry", 
    "urgency": "routine",
    "clinical_notes": "Check electrolyte balance"
  }
}

Expected Response (201 Created):

{
  "id": "test-002",
  "service_name": "Basic Metabolic Panel",
  "status": "ordered",
  "created_at": "2025-09-16T11:00:00Z"
}

5. Advice Tab Tests

Test Case 5.1: Get Care Plan Advice

Endpoint: GET /appointments/{appointment_id}/care_plans/advice

Request:

GET /appointments/123/care_plans/advice
Authorization: Bearer <token>

Expected Response (200 OK):

{
  "appointment_id": "123",
  "patient_id": "456",
  "advice_categories": {
    "medications": {
      "instructions": [
        "Take all medications as prescribed",
        "Do not stop medications without consulting your doctor"
      ]
    },
    "diet": {
      "instructions": [
        "Follow low-sodium diet",
        "Limit alcohol consumption"
      ]
    }
  },
  "custom_advice": [
    "Monitor blood pressure daily"
  ]
}

Test Case 5.2: Update Care Plan Advice

Endpoint: PUT /appointments/{appointment_id}/care_plans/advice

Request:

PUT /appointments/123/care_plans/advice
Authorization: Bearer <token>
Content-Type: application/json

{
  "advice_categories": {
    "medications": {
      "instructions": [
        "Take all medications as prescribed",
        "Monitor for side effects"
      ]
    }
  },
  "custom_advice": [
    "Monitor blood pressure daily",
    "Schedule cardiology follow-up"
  ]
}

6. Next Visit Tab Tests

Test Case 6.1: Get Follow-up Plan

Endpoint: GET /appointments/{appointment_id}/care_plans/follow_up

Request:

GET /appointments/123/care_plans/follow_up
Authorization: Bearer <token>

Expected Response (200 OK):

{
  "appointment_id": "123",
  "patient_id": "456",
  "follow_up_plan": {
    "recommended_interval": "2 weeks",
    "follow_up_type": "routine",
    "priority": "standard"
  },
  "scheduled_appointments": [],
  "available_slots": [
    {
      "date": "2025-09-30",
      "time_slots": ["09:00", "10:00", "11:00"]
    }
  ]
}

Test Case 6.2: Schedule Follow-up

Endpoint: POST /appointments/{appointment_id}/care_plans/follow_up

Request:

POST /appointments/123/care_plans/follow_up
Authorization: Bearer <token>
Content-Type: application/json

{
  "follow_up": {
    "scheduled_date": "2025-09-30T10:00:00Z",
    "appointment_type": "follow-up",
    "duration": 30,
    "notes": "Follow-up for chest pain evaluation"
  }
}

Error Test Cases

Test Case E1: Unauthorized Access

Request:

GET /appointments/123/clinical_observations/vitals
# No Authorization header

Expected Response (401 Unauthorized):

{
  "success": false,
  "error": {
    "code": "unauthorized",
    "message": "Authentication required"
  }
}

Test Case E2: Invalid Appointment ID

Request:

GET /appointments/999999/clinical_observations/vitals
Authorization: Bearer <token>

Expected Response (404 Not Found):

{
  "success": false,
  "error": {
    "code": "not_found",
    "message": "Appointment not found"
  }
}

Test Case E3: Validation Error

Request:

PUT /appointments/123/clinical_observations/vitals
Authorization: Bearer <token>
Content-Type: application/json

{
  "vital_signs": {
    "blood_pressure": {
      "systolic": "invalid",
      "diastolic": 80
    }
  }
}

Expected Response (422 Unprocessable Entity):

{
  "success": false,
  "error": {
    "code": "validation_error",
    "message": "Invalid vital signs data",
    "details": {
      "systolic": "must be a number"
    }
  }
}

Postman Collection Setup

1. Environment Variables

Create a Postman environment with these variables:

  • base_url: http://localhost:3000 (or your server URL)
  • auth_token: Your JWT authentication token
  • clinic_id: Test clinic ID
  • appointment_id: Test appointment ID
  • patient_id: Test patient ID
  • doctor_id: Test doctor ID

2. Pre-request Script (Global)

Add this pre-request script to automatically include authentication:

pm.request.headers.add({
    key: 'Authorization',
    value: 'Bearer ' + pm.environment.get('auth_token')
});

pm.request.headers.add({
    key: 'Content-Type', 
    value: 'application/json'
});

3. Collection Structure

Kulcare FHIR APIs/
├── Authentication/
│   └── Get Auth Token
├── Vitals Tab/
│   ├── Get Vitals
│   └── Update Vitals  
├── Observations Tab/
│   ├── Get Clinical Impressions
│   └── Update Clinical Impressions
├── Medications Tab/
│   ├── Get Medications
│   ├── Add Medication
│   └── Search Medications
├── Investigations Tab/
│   ├── Get Service Requests
│   ├── Order Investigation
│   └── Search Investigations
├── Advice Tab/
│   ├── Get Advice
│   └── Update Advice
├── Next Visit Tab/
│   ├── Get Follow-up Plan
│   └── Schedule Follow-up
└── Error Cases/
    ├── Unauthorized Request
    ├── Invalid Appointment
    └── Validation Error

Test Data Setup

Before running tests, ensure you have this test data in your database:

1. Create Test Clinic

INSERT INTO clinics (name, city, state, country, phone_number, owner_id, verified, created_at, updated_at)
VALUES ('Test Clinic', 'Mumbai', 'Maharashtra', 'India', '9876543210', 1, true, NOW(), NOW());

2. Create Test Patient

INSERT INTO clinic_patients (clinic_id, patient_id, created_at, updated_at)
VALUES (1, 1, NOW(), NOW());

3. Create Test Appointment

INSERT INTO appointments (clinic_id, clinic_patient_id, clinic_doctor_id, appointment_date, appointment_time, status, created_at, updated_at)
VALUES (1, 1, 1, '2025-09-16', '10:00', 'scheduled', NOW(), NOW());

Running the Tests

1. Manual Testing Steps

  1. Setup Environment: Configure Postman environment variables
  2. Authentication: Get a valid JWT token first
  3. Sequential Testing: Run tests in the order listed above
  4. Verify Responses: Check response status codes and data structure
  5. Error Testing: Verify error cases return appropriate responses

2. Automated Testing

You can also run these tests using Newman (Postman CLI):

# Install Newman
npm install -g newman

# Run collection
newman run kulcare-fhir-apis.postman_collection.json \
  -e kulcare-test.postman_environment.json \
  --reporters cli,html \
  --reporter-html-export test-results.html

Expected Results

All tests should:

  • Return appropriate HTTP status codes
  • Follow the documented JSON response format
  • Include proper error handling
  • Maintain data consistency
  • Support the frontend requirements

Troubleshooting

Common Issues

  1. Authentication Failures: Ensure JWT token is valid and not expired
  2. 404 Errors: Verify test data exists in database
  3. Validation Errors: Check request payload format matches API specs
  4. Database Errors: Ensure migrations have been run and database is accessible

Debug Steps

  1. Check server logs for detailed error messages
  2. Verify database contains required test data
  3. Confirm environment variables are set correctly
  4. Test authentication endpoint separately first

This test plan provides comprehensive coverage of all FHIR APIs and should help ensure the implementation works correctly with the frontend CMS interface.

On this page