Chain of Care API Documentation

An API to manage the full chain of care for patients in the healthcare system

1. Patient

POST /api/patients

Create a new patient record.

{
  "name": "John Doe",
  "age": 35,
  "condition": ["infection"]
}

GET /api/patients/:id

Retrieve a patient by their unique ID.

Response: {
 {
    "_id": "676af0fa18204c7a86ab9449",
    "patientId": 4,
    "name": "John Doe",
    "age": 35,
    "condition": [
        "infection"
    ],
    "interventions": [],
    "createdAt": "2024-12-24T17:35:54.571Z",
    "updatedAt": "2024-12-24T17:35:54.571Z",
    "__v": 0
}

PUT /api/patients/:id

Update a patient's record by their unique ID.

{
  "name": "John Doe",
  "age": 35,
  "condition": ["Viral infections"]
}

DELETE /api/patients/:id

Delete a patient record by ID.

2. Intervention

POST /api/interventions

Create a new intervention record.

{
  "patientId": 4,
  "description": "john Doe Viral infections get overcome"
}

GET /api/interventions?patientId=patientId

Get interventions for a specific patient.

Response: [
 {
    "_id": "676af0fa18204c7a86ab9449",
    "patientId": 4,
    "name": "john Doe",
    "age": 35,
    "condition": [
        "Viral infections"
    ],
    "interventions": [
        {
            "_id": "676af1b918204c7a86ab9450",
            "patientId": 4,
            "description": "john Doe Viral infections get overcome ",
            "date": "2024-12-24T17:39:05.239Z",
            "createdAt": "2024-12-24T17:39:05.240Z",
            "updatedAt": "2024-12-24T17:39:05.240Z",
            "__v": 0
        }
    ],
    "createdAt": "2024-12-24T17:35:54.571Z",
    "updatedAt": "2024-12-24T17:39:05.316Z",
    "__v": 1
}
]

PUT /api/interventions?patientId=patientId

Update an intervention for a specific patient.

{
  "patientId": 4,
  "description": "Viral infections starting again"
}

DELETE /api/interventions?patientId=patientId

Delete an intervention for a specific patient.

3. Product

POST /api/products

Create a new product or service record.

{
  "patientId": "4",
  "name": "Viral infections Scan",
  "type": "SERVICE",
  "category": "Diagnostic",
  "description": "Full body scan",
  "cost": 1500
}

GET /api/products?patientId=patientId

Get products or services for a specific patient.

Response: [
  [
    {
        "_id": "676af29c18204c7a86ab9457",
        "patientId": 4,
        "name": " Viral infections Scan",
        "type": "SERVICE",
        "category": "Diagnostic",
        "description": "Full body scan",
        "cost": 1500,
        "patient": "676af0fa18204c7a86ab9449",
        "date": "2024-12-24T17:42:52.489Z",
        "createdAt": "2024-12-24T17:42:52.489Z",
        "updatedAt": "2024-12-24T17:42:52.489Z",
        "__v": 0
    }
]

PUT /api/products?patientId=patientId

Update a product/service for a specific patient.

{
  "patientId": "4",
  "name": "Viral infections Scan",
  "cost": 6000
}

DELETE /api/products?patientId=patientId

Delete a product/service for a specific patient.

4. Full Chain

POST /api/chain

Create a new chain entry for a patient.

{
  "patientId": "4",
  "type": "INTERVENTION",
  "notes": "Initial consultation"
}

GET /api/chain?patientId=patientId

Get the full chain of care for a specific patient.

Response: [
 {
    "status": "success",
    "data": {
        "patient": {
            "id": "676af0fa18204c7a86ab9449",
            "patientId": 4,
            "name": "john Doe",
            "age": 35
        },
        "chainEntries": {
            "count": 1,
            "entries": [
                {
                    "_id": "676af2db18204c7a86ab945d",
                    "patientId": 4,
                    "type": "INTERVENTION",
                    "status": "PENDING",
                    "notes": "Initial consultation",
                    "patient": {
                        "_id": "676af0fa18204c7a86ab9449",
                        "patientId": 4,
                        "name": "john Doe",
                        "age": 35
                    },
                    "date": "2024-12-24T17:43:55.180Z",
                    "createdAt": "2024-12-24T17:43:55.180Z",
                    "updatedAt": "2024-12-24T17:43:55.180Z",
                    "__v": 0
                }
            ]
        },
        "products": {
            "count": 1,
            "entries": [
                {
                    "_id": "676af29c18204c7a86ab9457",
                    "patientId": 4,
                    "name": " Viral infections Scan",
                    "type": "SERVICE",
                    "category": "Diagnostic",
                    "description": "Full body scan",
                    "cost": 1500,
                    "patient": "676af0fa18204c7a86ab9449",
                    "date": "2024-12-24T17:42:52.489Z",
                    "createdAt": "2024-12-24T17:42:52.489Z",
                    "updatedAt": "2024-12-24T17:42:52.489Z",
                    "__v": 0
                }
            ]
        },
        "interventions": {
            "count": 2,
            "entries": [
                {
                    "_id": "676af1b918204c7a86ab9450",
                    "patientId": 4,
                    "description": "john Doe Viral infections get overcome ",
                    "date": "2024-12-24T17:39:05.239Z",
                    "createdAt": "2024-12-24T17:39:05.240Z",
                    "updatedAt": "2024-12-24T17:39:05.240Z",
                    "__v": 0
                },
                {
                    "_id": "6769a0491c67c3df65884845",
                    "patientId": 4,
                    "description": "Viral infections starting again",
                    "date": "2024-12-23T17:39:21.553Z",
                    "createdAt": "2024-12-23T17:39:21.557Z",
                    "updatedAt": "2024-12-24T17:41:58.024Z",
                    "__v": 0
                }
            ]
        }
    }
}
]

PUT /api/chain?patientId=patientId

Update the status or notes in the care chain for a specific patient.

{
  "status": "IN_PROGRESS",
  "notes": "Treatment ongoing - Day 2"
}

DELETE /api/chain?patientId=patientId

Delete a chain entry for a specific patient.

Use localhost:3000 for testing

// Footer