Skip to content

Instantly share code, notes, and snippets.

@crazywolf132
Created July 3, 2019 00:08
Show Gist options
  • Save crazywolf132/ffc9e95bf8f7219daa4471a70842dbb0 to your computer and use it in GitHub Desktop.
Save crazywolf132/ffc9e95bf8f7219daa4471a70842dbb0 to your computer and use it in GitHub Desktop.
A hospital REST API case study

Hospital

We are going to build another hospital. This time we are going to work only on api's

Design

 Hospital - Way to access everything.

 Patients - Holding patient information

 Staff - Holding staff information.

 Jobs - Current patients staff are attending, and their notes

 Status - Holds the information on the patients status (released, waiting etc.)

 Department - Holds information about different departments.

API SETUP

Hospital

** All requests are get requests **

    - /API/All
        Returns everything. Each department, what staffmember is in that department, what patients are in it, the status of the
        patients etc.

    - /API/{id}
        Returns everything with that id. (Patient, Staff, Job, Status, Departmnet etc.)

    - /API/Patient/All
        Returns a list of all the patients and their statuses.
    
    - /API/Patient/{id}
        Returns a select patient and their statuses.

    - /API/Staff/All
        Returns all information about all the staff.

    - /API/Staff/{id}
        Returns information about a specific staff member.

    - /API/Department/All
        Returns all information about all departments.

    - /API/Department/{id}
        Returns information about a specific department.

    - /API/Jobs/All
        Returns all informationa about all jobs

    - /API/Jobs/{id}
        Returns information about a specific job

    - /API/Status/All
        Returns all statuses

    - /API/Status/{id}
        Returns information about a specific status.

Patient

    - /API/All
        Returns all patients

    - /API/{id}
        Returns a specific patient

Staff

    - /API/All
        Returns all staff

    - /API/{id}
        Returns specific staff member.

Department

    - /API/All
        Returns all departments.
    
    - /API/{id}
        Returns specific department.

Job

    - /API/All
        Returns all jobs.

    - /API/{id}
        Returns specific job.

Status

    - /API/All
        Returns all statuses.

    - /API/{id}
        Returns specific status.

A look at the tables.

    CREATE TABLE patient (
        id INT PRIMARY KEY AUTO_INCREMENT NOT NULL,
        name VARCHAR(100),
        address VARCHAR(250),
        dob VARCHAR(10),
        bloodType VARCHAR(3)
    );

    CREATE TABLE staff (
        id INT PRIMARY KEY AUTO_INCREMENT NOT NULL,
        name VARCHAR(100),
        address VARCHAR(250),
        dob VARCHAR(10),
        date_started VARCHAR(10),
        bloodType VARCHAR(3),
        role VARCHAR(20)
    );

    CREATE TABLE department (
        id INT PRIMARY KEY AUTO_INCREMENT NOT NULL,
        name VARCHAR(100),
        capacity INT,
        status VARCHAR(6)
    );

    CREATE TABLE department_patient_link (
        id INT PRIMARY KEY AUTO_INCREMENT NOT NULL,
        departmentID INT,
        patientID INT
    );

    CREATE TABLE job (
        id INT PRIMARY KEY AUTO_INCREMENT NOT NULL,
        staffID INT,
        patientID INT,
        description VARCHAR(500)
    );

    CREATE TABLE status (
        id INT PRIMARY KEY AUTO_INCREMENT NOT NULL,
        patientID INT,
        status VARCHAR(100)
    );

What data should look like.

Department

    [
        {
            "id": 1,
            "name" : "Emergency",
            "capcity": 200,
            "patientList": [1, 4, 6]
        },
        {
            "id": 2,
            "name": "Waiting",
            "capcity": 100,
            "patientList": [2, 3, 5]
        }
    ]

Search for everything with id

    {
        "Search": 1,
        "Department":
        [
            {
                "id": 1,
                "name" : "Emergency",
                "capcity": 200,
                "patientList": [1, 4, 6]
            }
        ],
        "Staff":
        [
            {
                "id": 1,
                "name": "some name",
                "blah": "blah"
            }
        ],
        "Patient":
        [
            {
                "id": 1,
                "blah": "blah"
            }
        ],
        "Status":
        [
            {
                "id": 1,
                "blah": "blah"
            }
        ],
        "Job":
        [
            {
                "id": 1,
                "blah": "blah"
            }
        ]
    }

Patient

    [
        {
            "id": 1,
            "name": "Frank walker",
            "address": "some address",
            "dob": "01-01-0001",
            "bloodType": "AB+",
            "status": "waiting"
        }
    ]

Requirements

Everyone must use eureka from the beginning and everyone must use feign. If you don't know how to do either of those I will help you.

You must also use one of the databases. The same table will be on both, so there is no bottle necks.

If you dont have permission to the table, contact me and ill add you.

All API points must be as described as they will be tested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment