Skip to content

A React Native application for managing clinic appointments, powered by Express.js.

Notifications You must be signed in to change notification settings

CarneyC/clinic-appointment-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Clinic - Appointment Application

A React Native application for managing clinic appointments, powered by Express.js.

The yellow box warning regarding potential memory-leak is caused by an external node module react-native-calendar

Quickstart

Backend Services

Navigate to /docker directory and execute:

  1. Install server dependencies under docker environment

    docker-compose run api yarn install
  2. Edit the JWT_SECRET entry under .env, a random string should be provided

    echo JWT_SECRET=your-super-secret-string > .env
  3. Start the backend services, the server will be served at port 80 under /api.

    docker-compose up

Frontend Client

Navigate to /app directory and execute:

  1. Install dependencies under docker environment

    yarn add
  2. Edit the API_URL entry under .env, it should be set to your local ip-address

    echo API_URL=http://127.0.0.1/api > .env
  3. Start the application

    yarn start

Server language, and libraries

Typescript is used with conjunction of InversifyJS, this allows an Inversion of Control pattern to be deployed through decorator.

This enables greater decoupling between different components and domains.

Due to the absence of heavy data-flow or transformation, and most of the backend functionalities are implemented with native modules. No unit test has been implemented.

Language Requirements

The codebase can be transpile to ES6 Javascript with tsc if using Native NodeJS is a essential requirement.

API Endpoints

Clinic Management

This section contains the set of endpoints for managing a clinic profile

Clinic Registration

To register a clinic entry, use this snippet:

curl 'https://"$BASE_URL"/api/auth/signup' \
  -X POST \
  -H "Content-Type: application/json" \
  -d @request.json

In request.json:

{
  "name": "The Clinic",
  "email": "clinic@example.com",
  "password": "987654321",
  "phone": "98765432",
  "address": "Address Line 1, Hong Kong"
}

The above command returns JSON structured like this:

{
  "clinic": {
    "id": 90,
    "name": "The Clinic",
    "email": "clinic@example.com",
    "phone": "98765432",
    "address": "Address Line 1, Hong Kong",
    "createdAt": "2020-09-12T23:59:55.925Z",
    "updatedAt": "2020-09-12T23:59:55.926Z"
  },
  "token": "eyJhbGciOiJIUzI1NiIsInR5c..."
}

This endpoint creates a clinic profile in the database

HTTP Request

POST /api/auth/signup

Request Body

Parameter Type Description
name string Required.
email string Required.
password string Required. Must have 8 or more characters.
phone string Required. Must be 8 digit numeric string.
address text Required.

Response Body

Parameter Type Description
clinic Clinic Clinic entity
token string Access token

Password Sign In

To sign in with email and password, use this snippet:

curl 'https://"$BASE_URL"/api/auth/signin' \
  -X POST \
  -H "Content-Type: application/json" \
  -d @request.json

In request.json:

{
  "email": "clinic@example.com",
  "password": "987654321"
}

The above command returns JSON structured like this:

{
  "clinic": {
    "id": 90,
    "name": "The Clinic",
    "email": "clinic@example.com",
    "phone": "98765432",
    "address": "Address Line 1, Hong Kong",
    "createdAt": "2020-09-12T23:59:55.925Z",
    "updatedAt": "2020-09-12T23:59:55.926Z"
  },
  "token": "eyJhbGciOiJIUzI1NiIsInR5c..."
}

This endpoint grants access token for password login

HTTP Request

POST /api/auth/signin

Request Body

Parameter Type Description
email string Required.
password string Required.

Response Body

Parameter Type Description
clinic Clinic Clinic entity
token string Access token

Clinic Info

To create a folder entry, use this snippet:

curl 'https://"$BASE_URL"/api/auth/signin' \
  -X GET \
  -H "Authorization: Bearer  eyJhbGciOiJIUzI1NiIsInR5c..."

The above command returns JSON structured like this:

{
  "clinic": {
    "id": 90,
    "name": "The Clinic",
    "email": "clinic@example.com",
    "phone": "98765432",
    "address": "Address Line 1, Hong Kong",
    "createdAt": "2020-09-12T23:59:55.925Z",
    "updatedAt": "2020-09-12T23:59:55.926Z"
  }
}

This endpoint retrieve the authenticated user's clinic profile

HTTP Request

GET /api/auth/me

Response Body

Parameter Type Description
clinic Clinic Clinic entity

Consultation Administration

This section requires an authenticated user token, for editing consultation records

Consultation Creation

To create a consultation entry, use this snippet:

curl 'https://"$BASE_URL"/api/consultation/create' \
  -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer  eyJhbGciOiJIUzI1NiIsInR5c..." \
  -d @request.json

In request.json:

{
  "patient": "Lily Imane",
  "doctor": "Dr. Snyder",
  "diagnosis": "Lorem ipsum dolor sit amet, consectetur...",
  "medication": "Four dose of...",
  "fee": 1020.5,
  "date": "2020-09-13T12:15:00.000Z"
}

The above command returns JSON structured like this:

{
  "consultation": {
    "id": 200,
    "doctor": "Dr. Snyder",
    "patient": "Lily Imane",
    "diagnosis": "Lorem ipsum dolor sit amet, consectetur...",
    "medication": "Four dose of...",
    "fee": 1020.5,
    "date": "2020-09-13T12:15:00.000Z",
    "createdAt": "2020-09-12T23:59:55.925Z",
    "updatedAt": "2020-09-12T23:59:55.926Z"
  }
}

This endpoint creates a consultation record in the database

HTTP Request

POST /api/consultation/create

Request Body

Parameter Type Description
patient string Required.
doctor string Required.
diagnosis text Required.
medication text Required.
fee number Required.
date Date Required.

Response Body

Parameter Type Description
consultation Consultation Consultation entity

Attach Follow-up Consultation

To attach a follow-up consultation, use this snippet:

curl 'https://"$BASE_URL"/api/consultation/attach/:id' \
  -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer  eyJhbGciOiJIUzI1NiIsInR5c..." \
  -d @request.json

In request.json:

{
  "followUpId": 201
}

The above command returns JSON structured like this:

{
  "consultation": {
    "id": 200,
    "doctor": "Dr. Snyder",
    "patient": "Lily Imane",
    "diagnosis": "Lorem ipsum dolor sit amet, consectetur...",
    "medication": "Four dose of...",
    "fee": 1020.5,
    "date": "2020-09-13T12:15:00.000Z",
    "createdAt": "2020-09-12T23:59:55.925Z",
    "updatedAt": "2020-09-12T23:59:55.926Z",
    "followUp": {
      "id": 201,
      "doctor": "Dr. Malena",
      "patient": "Lily Imane",
      "diagnosis": "Maecenas quis mauris neque. Sed luctus...",
      "medication": "One dose of...",
      "fee": 800.5,
      "date": "2020-09-15T13:30:00.000Z",
      "createdAt": "2020-09-13T12:15:00.000Z",
      "updatedAt": "2020-09-13T12:15:00.000Z"
    }
  }
}

This endpoint attach a consultation as a follow-up to another consultation

HTTP Request

POST /api/consultation/attach/:id

Request Parameters

Parameter Type Description
id string Required. ID of the parent consultation

Request Body

Parameter Type Description
followUpId string Required. ID of the follow-up consultation

Response Body

Parameter Type Description
consultation Consultation Consultation entity

List the authenticated user's consultation records

To query a list of consultations, use this snippet:

curl 'https://"$BASE_URL"/api/consultation/list' \
  -X GET \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer  eyJhbGciOiJIUzI1NiIsInR5c..."

The above command returns JSON structured like this:

{
  "consultations": [
    {
      "id": 200,
      "doctor": "Dr. Snyder",
      "patient": "Lily Imane",
      "diagnosis": "Lorem ipsum dolor sit amet, consectetur...",
      "medication": "Four dose of...",
      "fee": 1020.5,
      "date": "2020-09-13T12:15:00.000Z",
      "createdAt": "2020-09-12T23:59:55.925Z",
      "updatedAt": "2020-09-12T23:59:55.926Z",
      "followUp": {
        "id": 201,
        "doctor": "Dr. Malena",
        "patient": "Lily Imane",
        "diagnosis": "Maecenas quis mauris neque. Sed luctus...",
        "medication": "One dose of...",
        "fee": 800.5,
        "date": "2020-09-15T13:30:00.000Z",
        "createdAt": "2020-09-13T12:15:00.000Z",
        "updatedAt": "2020-09-13T12:15:00.000Z"
      }
    },
    {
      "id": 201,
      "doctor": "Dr. Malena",
      "patient": "Lily Imane",
      "diagnosis": "Maecenas quis mauris neque. Sed luctus...",
      "medication": "One dose of...",
      "fee": 800.5,
      "date": "2020-09-15T13:30:00.000Z",
      "createdAt": "2020-09-13T12:15:00.000Z",
      "updatedAt": "2020-09-13T12:15:00.000Z"
    }
  ]
}

This endpoint query a list of consultations made by the user

HTTP Request

GET /api/consultation/list

Response Body

Parameter Type Description
consultations Consultation[] Consultation entities

About

A React Native application for managing clinic appointments, powered by Express.js.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages