Skip to content
fevungePublic

About

An ETL pipeline aimed at automating and visualization of hospital statistical data, taking as its case study the National Ophthalmology Institute of Angola.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

Β 

History

50 Commits

Folders and files

Repository files navigation

Project Banner

Version License Build Coverage PRS


etl-lar

An ETL pipeline aimed at automating and visualization of hospital statistical data, taking as its case study the National Ophthalmology Institute of Angola.


Report Bug Β Β·Β  Request Feature


πŸ“‹ Table of Contents


Overview

ETL-lar is a comprehensive ETL (Extract, Transform, Load) pipeline designed to automate the processing and visualization of hospital statistical data. The project focuses on the National Ophthalmology Institute of Angola, aiming to streamline data management and provide actionable insights through interactive dashboards. By leveraging modern technologies and best practices in data engineering, ETL-lar enables healthcare professionals to make informed decisions based on accurate and timely data.


Features

  • Data Extraction: Implement robust data extraction mechanisms to pull data from various sources, including databases, APIs, and flat files.
  • Data Transformation: Develop a flexible transformation layer to clean, normalize, and enrich the extracted data, ensuring it is in the correct format for analysis and visualization.
  • Data Loading: Set up efficient loading processes to store the transformed data in a centralized data warehouse, optimizing for query performance and scalability.
  • Visualization: Create interactive dashboards and reports that allow users to explore the data, identify trends, and derive insights relevant to ophthalmology care and hospital management.
  • Automation: Schedule and automate the entire ETL process to ensure that the data is always up-to-date, reducing manual intervention and minimizing errors.
  • Extract to CSV, XLSX, SQL: Implement functionality to export the processed data into various formats such as CSV, XLSX, and SQL for further analysis or sharing with stakeholders.

Tech Stack

Layer Technology
Dashboard Streamlit (version 1.55.0)
Backend Python (3.13.9)
Post-Processing Pandas, NumPy
Database MySQL
Data Visualization Power BI
DevOps Docker, Git

Getting Started

Prerequisites

This Python project dependencies:

  • pandas>=2.2.0

  • numpy>=1.26.0

  • SQLAlchemy>=2.0.0

  • PyMySQL>=1.1.0

  • openpyxl>=3.1.0

  • python-dotenv>=1.0.0

  • streamlit>=1.34.0

  • altair<5

Installation

1. Clone the repository

git clone https://github.com/fevunge/etl-lar.git
cd etl-lar

2. Install dependencies

If you are using Linux, macOS, WSL or another Unix-like system, is highly recommended to use a virtual environment to manage dependencies.

You can create one using venv:

python -m venv venv
source venv/bin/activate

Otherwise, if you are a experienced Windows user, you decide create a virtual environment or not.

pip install -r requirements.txt

3. Set up environment variables

cp .env.example .env

4. Run database

  • Unix-like systems (use docker):

  docker compose up -d
  • Windows (Options):

    • Install MySQL/MySQL Workbench and create a database named etl_lar on Workbench interface.

    • Use Docker Desktop to download and run MySQL image, then create a database named etl_lar on MySQL Workbench interface or using MySQL CLI (RECOMMENDED).

    • Use WSL to run the same commands as Unix-like systems.

5. Start the development server

  • Command Line Interface:
  python src/main.py
  • Dashboard Interface:
  python -m streamlit run src/dashboard.py

By default, the dashboard will be available at http://localhost:8501.
You can change the port by adding --server.port <PORT_NUMBER> to the command above.
Or it can change automatically if the default port is already in use.


Environment Variables

Create a .env file in the root directory. See .env.example for reference.

Variable Description Required
DB_HOST MySQL Database host (e.g 0.0.0.0) βœ…
DB_PORT MySQL Database port (e.g 3306) βœ…
DB_USER MySQL Database username (e.g root) βœ…
DB_PASSWORD MySQL Database password βœ…
DB_NAME MySQL Database name (e.g etl_lar) βœ…

With are you using Docker, this variables are already set in docker-compose.yml, you must have the same values in your .env file to connect to the database container.


Usage

... Soon ...


πŸ“ Project Structure

etl-lar
β”œβ”€β”€ data_raw
β”‚   β”œβ”€β”€ cirurgias.csv
β”‚   β”œβ”€β”€ consultas.csv
β”‚   β”œβ”€β”€ exames_complementares.csv
β”‚   β”œβ”€β”€ exames_laboratoriais.csv
β”‚   β”œβ”€β”€ farmacia_consumo.csv
β”‚   β”œβ”€β”€ internamentos.csv
β”‚   β”œβ”€β”€ medicos.csv
β”‚   β”œβ”€β”€ pacientes.csv
β”‚   └── patologias.csv
β”œβ”€β”€ logs
β”‚   └── etl.log
β”œβ”€β”€ src
β”‚   β”œβ”€β”€ config.py
β”‚   β”œβ”€β”€ dashboard.py
β”‚   β”œβ”€β”€ export.py
β”‚   β”œβ”€β”€ extract.py
β”‚   β”œβ”€β”€ load.py
β”‚   β”œβ”€β”€ logs.py
β”‚   β”œβ”€β”€ main.py
β”‚   └── transform.py
β”œβ”€β”€ .env.example
β”œβ”€β”€ .gitignore
β”œβ”€β”€ etlar.cmd
β”œβ”€β”€ etllar.sh
β”œβ”€β”€ LICENSE
β”œβ”€β”€ Makefile
β”œβ”€β”€ README.md
β”œβ”€β”€ requirements.txt
└── SPEC.md

API Reference

extract_data()

Extracts data from the source files and returns a dictionary of DataFrames. Returns:

  • Dict[str, pd.DataFrame]: A dictionary where keys are table names and values are the corresponding DataFrames.

transform_data(data: Dict[str, pd.DataFrame])

Transforms the extracted data by performing cleaning, normalization, and enrichment operations. Parameters:

  • data (Dict[str, pd.DataFrame]): A dictionary of DataFrames to be transformed. Returns:
  • Dict[str, pd.DataFrame]: A dictionary of transformed DataFrames.

load_data(data: Dict[str, pd.DataFrame])

Loads the transformed data into the MySQL database. Parameters:

  • data (Dict[str, pd.DataFrame]): A dictionary of DataFrames to be loaded into the database.

πŸ“Έ Screenshots

Screenshot Logs ETL process logs


Roadmap

... Soon ...


Contributing

❌ Contributions are not accepted at this time.

Please check back later for updates on how to contribute to this project.


License

Distributed under the MIT License.


Authors

Fernando Vunge
GitHub LinkedIn Twitter

Acknowledgements

  • Power BI β€” Data visualization tool
  • Streamlit β€” Dashboard framework
  • MySQL β€” Database management system
  • Pandas β€” Data manipulation library
  • NumPy β€” Numerical computing library
  • SQLAlchemy β€” SQL toolkit and Object-Relational Mapping (ORM) library
  • PyMySQL β€” MySQL client library
  • openpyxl β€” Excel file handling library

Made with 🧠 and β˜• by fevunge

⭐ Star this repo if you found it insightful!

About

An ETL pipeline aimed at automating and visualization of hospital statistical data, taking as its case study the National Ophthalmology Institute of Angola.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Contributors

Languages