Patients Portal

Introduction

Patient Portal is a basic Patient management system, where the user (ie. receptionist) should do the folowing tasks:

  • List Patients:
  • List Patients with a given name:
  • Read a Patient with certain id:
  • Create a Patient:
  • Update the data of a Patient:
  • Delete a Patient:

Prerequisites

  • Install Python (recommended version >= 3.10)
  • Install Gitbash (Optional)

Installation Steps

Follow these steps to install the repository requirements:

  1. Fork this Repository Click on button: image

Then, Rename the repo name to patients-portal and click Create Fork.

  1. Clone the Repository from your list of repositories:
git clone https://github.com/<your-username>/patients-portal.git
  1. Navigate to the Repository:
cd patient-portal
  1. Create a virtual environment
python -m venv venv
  1. Activate the virtual environment

In linux (gitbash)

source venv/bin/activate

In windows

source venv/Scripts/activate
  1. Install python packages to run the application
python -m pip install -r requirements.txt

Development

You can check the whole repository to check how the workflow works.

Here is the breakdown:

  • (src) directory contains the main source code

    1. (src/patient.py) will contain the Patient class for the behaviour of patients. The patient object should be used for testing the application. Details implementations are in the file.
    2. (src/patient_db.py) contains the business logic of sqlalchemy database operations. The module can be imported for the database operation.
    3. (src/config.py) contains basic hardcoded configurations. This needs to be imported for the business logic.
    4. (src/patient_db_config.py) is a script which creates the (patient.db) file and configure the database schema.
    5. (src/api_controller.py) will contain the class for the HTTP REST API controller server. There are predefined routes, so that when the Client sends the request. the server should validate the data and fetch/store the data to the database. You need to implement only the methods
  • (tests) directory contains the tests for your application.

  • (requirements.txt) contains the packages needs to be installed for the application to run. you can append a 3pp (3rd Party Package) in this file if you have used any.

Testing the final application

In Terminal :

First Run the flask server by running the API_CONTROLLER (src/api_controller.py) directly or using linux command:

python src/api_controller.py

Once the Flask server is running, open a new terminal and keep the server running in the first one.

Then,

cd tests

Then,

bash create_patient.sh

If it returns the patient_id in the response then meaning that Patient has been created successfully and added to the database.

Then for listing the created patients,

bash list_patients.sh

Then for listing the created patients with *name* as parameter,

bash list_patient_by_name.sh

Then for getting a patient details with certain id,

bash get_certain_patient.sh

Then, to update the patient,

bash update_patient.sh

Finally, to delete the created patient,

bash delete_patient.sh

You can Refer:

Flask Documentation: https://flask.palletsprojects.com/en/3.0.x/quickstart/#routing

Flask Cheatsheet: https://s3.us-east-2.amazonaws.com/prettyprinted/flask_cheatsheet.pdf

Swagger Editor (Playground): https://editor.swagger.io/

Python OOP : https://docs.python.org/3/tutorial/classes.html

Feedback

If you need more clarification, please ping me. I will update the readme file.