Skip to content

Commit

Permalink
updated readme onboarding instructions (#60)
Browse files Browse the repository at this point in the history
* updated readme onboarding instructions

Problem
Readme contained a few errors and lacked install instructions for docker

Solution
- added install instructions for docker and make
- moved api usage instructions to app/api/readme
- updated api usage instructions to fix /api/ error and add authentication token instructions

Ticket URL
https://mediform.atlassian.net/browse/MEDI-7

Documentation
N/A

Tests Run
Tested readme instructions on mac os

Updates to address comments:
* updated readme headers to use sentence case
  • Loading branch information
MadelaineJ authored Jan 9, 2024
1 parent 8a967c4 commit 9f93cac
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 29 deletions.
39 changes: 18 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,31 @@ This project requires the following to run locally:
- Make
- Docker compose v2.2.1+

# Development
The project Makefile provides a central entrypoint for interacting with the project, to get started simply run: `make env && make all`

## Install Docker Compose

Refer to the Makefile for further commands
For Linux you can install [docker compose](https://docs.docker.com/compose/install/) directly
For Windows it is recommend to use wsl2 and follow the linux instructions. Otherwise you can install the desktop version.
On Mac you must install [docker desktop](https://docs.docker.com/desktop/install/mac-install/) as it is the only way to get docker compose (as of this writing).

See the [docker compose install page](https://docs.docker.com/compose/install/) for the latest information.

- For API development, refer to the API [documentation](https://github.com/jon-funk/project-ct/blob/main/app/api/README.md)
- For Web development, refer to the Web [documentation](https://github.com/jon-funk/project-ct/blob/main/app/web/README.md)
- For Operations development, refer to the Operations [documentation](https://github.com/jon-funk/project-ct/blob/main/operations/README.md)
## Install Make
[Linux installation](https://linuxhint.com/install-make-ubuntu/)

[Mac installation](https://docs.docker.com/desktop/install/mac-install/) via homebrew

### Manually test API endpoints
# Development
If using docker desktop you *must have the application open* for the below command to work.

Note that you can also access localhost:5000/api/docs and execute perform this step much more easily...
The project Makefile provides a central entrypoint for interacting with the project.

Create a User against the locally running API:
To get started simply run: `make env && make all`

```bash
curl -X POST http://localhost:5000/sign-in \
-H 'Content-Type: application/json' \
-d '{"email":"[email protected]","password":"Password123#"}'
```
Refer to the Makefile for further commands

Get an authorization token by signing in:
Note: if you run into any issues with port 5000 on mac, [this stackoverflow post](https://stackoverflow.com/questions/72369320/why-always-something-is-running-at-port-5000-on-my-mac) may help.

```bash
curl -X POST http://localhost:5000/login \
-H 'Content-Type: application/json' \
-d '{"email":"[email protected]","password":"Password123#"}'
```
## Next
- For API development, refer to the API [documentation](https://github.com/jon-funk/project-ct/blob/main/app/api/README.md)
- For Web development, refer to the Web [documentation](https://github.com/jon-funk/project-ct/blob/main/app/web/README.md)
- For Operations development, refer to the Operations [documentation](https://github.com/jon-funk/project-ct/blob/main/operations/README.md)
89 changes: 83 additions & 6 deletions app/api/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# FastAPI Example

Example template to demonstrate FastAPI, has a basic local dev and CI for OpenShift

## Local dev
# Local dev
The following commands should be run from the main directory project-ct/
* Start by setting up your `env` file via: `make env`

* Start the api for local testing via: `make api`
Expand Down Expand Up @@ -32,7 +31,7 @@ After you've generated your migrations, you can apply them with `make mig`

While your `api` container is running, you can open: http://localhost:5000/api/docs to view OpenAPI swagger docs and interact with your API.

## Environment Variables:
## Environment variables:
### Defines database connection details
`POSTGRES_USER`

Expand All @@ -45,10 +44,88 @@ While your `api` container is running, you can open: http://localhost:5000/api/d
`POSTGRES_PORT`


### Run Tests Locally
## Run tests locally
This should be done inside your dev container

To run API tests locally, run the following commands:

```bash
docker-compose up --detach db
pytest
```
```

## Manually test API endpoints
Note that you can also access localhost:5000/api/docs in your browser and perform these steps without the terminal.

### Create a user
Create a User against the locally running API:

```bash
curl -X POST http://localhost:5000/api/sign-up \
-H 'Content-Type: application/json' \
-d '{"email":"[email protected]","password":"Password123#"}'
```

Get an authorization token by signing in:

```bash
curl -X POST http://localhost:5000/api/login \
-H 'Content-Type: application/json' \
-d '{"email": "[email protected]", "password": "Password123#"}'
```
This will return an authorization token like below:
```
{"access_token":"<your_token>","token_type":"bearer"}
```

You will need your token to send further requests.

### Create a new form
Replace <your_token> with the token you just copied.
You can update any of the patient intake form values as well.
```bash
curl -X POST 'http://localhost:5000/api/create-patient-encounter' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer <your_token>' \
-d '{
"age": 0,
"arrival_method": "string",
"arrival_date": "2024-01-08T21:41:11.335Z",
"arrival_time": "2024-01-08T21:41:11.335Z",
"chief_complaints": "string",
"comment": "string",
"departure_time": "2024-01-08T21:41:11.335Z",
"departure_date": "2024-01-08T21:41:11.335Z",
"departure_dest": "string",
"document_num": "64",
"gender": "string",
"handover_from": "string",
"handover_too": "string",
"location": "string",
"on_shift": true,
"patient_rfid": "string",
"qr_code": "string",
"triage_acuity": "string"
}'
```

This command will return your patient encounter form. Example:
```
{"age":0,"arrival_method":"string","arrival_date":"2024-01-08T21:41:11.335000","arrival_time":"2024-01-08T21:41:11.335000","chief_complaints":"string","comment":"string","departure_time":"2024-01-08T21:41:11.335000","departure_date":"2024-01-08T21:41:11.335000","departure_dest":"string","document_num":"64","gender":"string","handover_from":"string","handover_too":"string","location":"string","on_shift":true,"patient_rfid":"$argon2id$v=19$m=65536,t=3,p=4$PyeE8H6vVQqB8L53ztnbmw$1EmhTeuWJ/fQAYCIxTBcV1FJJKdvfADHTHhM10GIPuw","qr_code":"string","triage_acuity":"string","patient_encounter_uuid":"e641bbca-d906-47d8-a269-9f73fe5cdef2"}
```

Copy the value for "patient_encounter_uuid"

### Get patient encounter form
```
curl -X 'GET' \
'http://localhost:5000/api/patient-encounter?uuid=<patient_encounter_uuid>' \
-H 'accept: application/json' \
-H 'Authorization: Bearer <your_token>'
```

Replace **<patient_encounter_uuid>** with the UUID you copied in the last step and **<your_token>** with your access token.


You can view other available requests here: http://localhost:5000/api/docs
14 changes: 12 additions & 2 deletions app/web/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).

## Getting Started
# Requirements
This project requires the following to run locally:
- Yarn
Or
- npm

First, run the development server:
## Install Yarn
Yarn or npm is required to start this project. Yarn is recommended.

[Linux installation](https://linuxize.com/post/how-to-install-yarn-on-ubuntu-20-04/)
[Mac installation](https://tecadmin.net/install-yarn-macos/) via homebrew is easiest.

## Run the server
Run the development server from the app/web directory
```bash
npm run dev
# or
Expand Down

0 comments on commit 9f93cac

Please sign in to comment.