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
Navigate to /docker
directory and execute:
-
Install server dependencies under docker environment
docker-compose run api yarn install
-
Edit the
JWT_SECRET
entry under.env
, a random string should be providedecho JWT_SECRET=your-super-secret-string > .env
-
Start the backend services, the server will be served at port
80
under/api
.docker-compose up
Navigate to /app
directory and execute:
-
Install dependencies under docker environment
yarn add
-
Edit the
API_URL
entry under.env
, it should be set to your local ip-addressecho API_URL=http://127.0.0.1/api > .env
-
Start the application
yarn start
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.
The codebase can be transpile to ES6 Javascript with tsc
if using Native NodeJS is a essential requirement.
This section contains the set of endpoints for managing a clinic profile
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
POST /api/auth/signup
Parameter | Type | Description |
---|---|---|
name | string | Required. |
string | Required. | |
password | string | Required. Must have 8 or more characters. |
phone | string | Required. Must be 8 digit numeric string. |
address | text | Required. |
Parameter | Type | Description |
---|---|---|
clinic | Clinic | Clinic entity |
token | string | Access token |
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
POST /api/auth/signin
Parameter | Type | Description |
---|---|---|
string | Required. | |
password | string | Required. |
Parameter | Type | Description |
---|---|---|
clinic | Clinic | Clinic entity |
token | string | Access token |
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
GET /api/auth/me
Parameter | Type | Description |
---|---|---|
clinic | Clinic | Clinic entity |
This section requires an authenticated user token, for editing consultation records
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
POST /api/consultation/create
Parameter | Type | Description |
---|---|---|
patient | string | Required. |
doctor | string | Required. |
diagnosis | text | Required. |
medication | text | Required. |
fee | number | Required. |
date | Date | Required. |
Parameter | Type | Description |
---|---|---|
consultation | Consultation | Consultation entity |
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
POST /api/consultation/attach/:id
Parameter | Type | Description |
---|---|---|
id | string | Required. ID of the parent consultation |
Parameter | Type | Description |
---|---|---|
followUpId | string | Required. ID of the follow-up consultation |
Parameter | Type | Description |
---|---|---|
consultation | Consultation | Consultation entity |
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
GET /api/consultation/list
Parameter | Type | Description |
---|---|---|
consultations | Consultation[] | Consultation entities |