KompleteCare Front End Test

  1. To test the application, kindly use the login details:
    Email: [email protected]
    Password: password
  2. On successful login, use the token returned to make your api calls.
  3. Download the Postman collection linked below and use for your tests. If you run the /login endpoint, the access_token will be automatically updated.

Run in Postman

View Postman API document

Table of Contents

Response Format

For every successful request with a 200 or 201 response code, the response is formatted like this:

{
    "success": true (boolean),
    "data": (null or an object),
    "message": (string)
}


For every failed request, the response is formatted like this:

{
    "success": false (boolean),
    "message": (string),
    "data": (null or an object)
}

Response Codes

200 - OK
201 - OK
429 - Too much request, try again after 30 secs
401 - Unauthorized
422 - Unprocessed request due to invalid data

Headers

  • Accept set to application/json
  • Authorization set to Bearer {TOKEN} where required

API Endpoints

API: http://testdrive.kompletecare.com/api GraphQL: http://testdrive.kompletecare.com/graphql

Login

  • Endpoint: {URL} + '/login'
  • Method: POST
  • Body:
{ 
    'email' => 'required' (can be username, email or phone),
    'password' => 'required'
}
  • Successful Response:
{
    "success": true,
    "data": {
        "token": "1|xxxxxxxxxxxxxxxxxxxxxxxxxx"
    },
    "message": "Logged in successfully"
}

Get Medical Investigations

  • Endpoint: {URL} + '/investigations'
  • Method: GET
  • Header: Authorization: Bearer {token}
  • Failed Response
{
    "message": "Unauthenticated."
}
  • Successful Response
{
    "success": true,
    "data": [
        {
            "id": 1,
            "title": "X-Ray",
            "investigations": [
                {
                    "id": 1,
                    "investigation_type_id": 1,
                    "title": "Chest"
                },
                {
                    "id": 2,
                    "investigation_type_id": 1,
                    "title": "Cervical Vertebrae"
                },
                {
                    "id": 3,
                    "investigation_type_id": 1,
                    "title": "Thoracic Vertebrae"
                },
                {
                    "id": 4,
                    "investigation_type_id": 1,
                    "title": "Lumbar Vartebrae"
                },
                {
                    "id": 5,
                    "investigation_type_id": 1,
                    "title": "Lumbo Sacral Vertebrae"
                },
                {
                    "id": 6,
                    "investigation_type_id": 1,
                    "title": "Wrist Joint"
                },
                {
                    "id": 7,
                    "investigation_type_id": 1,
                    "title": "Ankle"
                },
                {
                    "id": 8,
                    "investigation_type_id": 1,
                    "title": "Fingers"
                },
                {
                    "id": 9,
                    "investigation_type_id": 1,
                    "title": "Toes"
                }
            ]
        },
        {
            "id": 2,
            "title": "Ultrasound Scan",
            "investigations": [
                {
                    "id": 10,
                    "investigation_type_id": 2,
                    "title": "Breast"
                },
                {
                    "id": 11,
                    "investigation_type_id": 2,
                    "title": "Pelvis"
                },
                {
                    "id": 12,
                    "investigation_type_id": 2,
                    "title": "Prostate"
                },
                {
                    "id": 13,
                    "investigation_type_id": 2,
                    "title": "Thyroid"
                }
            ]
        }
    ],
    "message": "Records retrieved successfully"
}

Create Medical Record

  • Endpoint: {URL} + '/investigations'
  • Method: POST
  • Header: Authorization: Bearer {token}
  • Failed Response
{
    "message": "Unauthenticated."
}
  • Body
{
    'investigations' => 'required|array',
    'ctscan' => 'required',
    'mri' => 'required',
    'developer' => 'required'
}

Note: investigations is an array of Laboratory Investigation IDs retrieved using the Get Medical Categories endpoint in this format [1, 5, 39, 2]

  • Successful Response
{
    "success": true,
    "data": {
        "patient": {
            "id": 1,
            "name": "KompleteCare User",
            "email": "[email protected]"
        },
        "ctscan": "Scan Needed In The Left Cerebral Hemisphere",
        "mri": "Full Body MRI",
        "created_at": "2022-05-29T22:50:34.000000Z"
    },
    "message": "Record saved successfully"
}

GraphQL Endpoints

URL: http://test.kompletecare.com/graphql
Method: POST

GraphQL Login

  • Body:
mutation {
    login(email:"[email protected]", password:"password")
}
  • Successful Response:
{
    "data": {
        "login": "1|xxxxxxxxxxxxxxxxxxxxxxxxxx"
    }
}

GraphQL Medical Investigations

  • Header: Authorization: Bearer {token}
  • Body:
{
    investigations {
        id
        title
        type {
            id
            title
        }
    }
}
  • Successful Response
{
    "data": {
        "investigations": [
            {
                "id": "1",
                "title": "Chest",
                "type": {
                    "id": "1",
                    "title": "X-Ray"
                }
            },
            {
                "id": "2",
                "title": "Cervical Vertebrae",
                "type": {
                    "id": "1",
                    "title": "X-Ray"
                }
            },
            {
                "id": "3",
                "title": "Thoracic Vertebrae",
                "type": {
                    "id": "1",
                    "title": "X-Ray"
                }
            },
            {
                "id": "4",
                "title": "Lumbar Vartebrae",
                "type": {
                    "id": "1",
                    "title": "X-Ray"
                }
            },
            {
                "id": "5",
                "title": "Lumbo Sacral Vertebrae",
                "type": {
                    "id": "1",
                    "title": "X-Ray"
                }
            },
            {
                "id": "6",
                "title": "Wrist Joint",
                "type": {
                    "id": "1",
                    "title": "X-Ray"
                }
            },
            {
                "id": "7",
                "title": "Ankle",
                "type": {
                    "id": "1",
                    "title": "X-Ray"
                }
            },
            {
                "id": "8",
                "title": "Fingers",
                "type": {
                    "id": "1",
                    "title": "X-Ray"
                }
            },
            {
                "id": "9",
                "title": "Toes",
                "type": {
                    "id": "1",
                    "title": "X-Ray"
                }
            },
            {
                "id": "10",
                "title": "Breast",
                "type": {
                    "id": "2",
                    "title": "Ultrasound Scan"
                }
            },
            {
                "id": "11",
                "title": "Pelvis",
                "type": {
                    "id": "2",
                    "title": "Ultrasound Scan"
                }
            },
            {
                "id": "12",
                "title": "Prostate",
                "type": {
                    "id": "2",
                    "title": "Ultrasound Scan"
                }
            },
            {
                "id": "13",
                "title": "Thyroid",
                "type": {
                    "id": "2",
                    "title": "Ultrasound Scan"
                }
            }
        ]
    }
}

GraphQL Create Medical Record

  • Header: Authorization: Bearer {token}
  • Body:
mutation {
    add_medical_record(
        investigations: [8,9,5]
        ctscan: "Scan needed in the left cerebral hemisphere"
        mri: "Full body MRI"
        developer: "Developer"
    ) {
        id
        patient {
            id
            name
            email
        }
        investigations { id title type { id title } }
        ctscan
        mri
        created_at
    }
}
  • Successful Response
{
    "data": {
        "add_medical_record": {
            "id": "16",
            "patient": {
                "id": "1",
                "name": "KompleteCare User",
                "email": "[email protected]"
            },
            "investigations": [
                {
                    "id": "8",
                    "title": "Fingers",
                    "type": {
                        "id": "1",
                        "title": "X-Ray"
                    }
                },
                {
                    "id": "9",
                    "title": "Toes",
                    "type": {
                        "id": "1",
                        "title": "X-Ray"
                    }
                },
                {
                    "id": "5",
                    "title": "Lumbo Sacral Vertebrae",
                    "type": {
                        "id": "1",
                        "title": "X-Ray"
                    }
                }
            ],
            "ctscan": "Scan Needed In The Left Cerebral Hemisphere",
            "mri": "Full Body MRI",
            "created_at": "2022-05-29 23:04:42"
        }
    }
}