pa810p / bps2

Blood Parameters Storage System
GNU General Public License v3.0
1 stars 0 forks source link

BPS2 - Blood Parameters Storage System

BPS2 is a simple command line interface written in bash to store previous measured blood parameters such as pressure (diastolic, systolic and pulse) and sugar level. By default, data is stored in sqlite file named blood.db in local directory. There is possibility to synchronize blood.db with postgresql server.

Installation

Prerequisites

Install BPS2

Download and configure

Clone GitHub repository:

$ git clone git@github.com:pa810p/bps2.git

Copy blood_template.properties to blood.properties:

$ cp blood_template.properties blood.properties

Edit blood.properties according to your needs (database access :arrow_down:).

Initialize database:

Usage

$ ./blood.sh
Version: 1.2.6
Usage: ./blood.sh [OPTIONS]
OPTIONS include:
-a --urine-acid URINE_ACID           urine acid in blood in µmol/l using format of: 370/'comment'
-b --database-port DATABASE_PORT     database port
-A --import-urine-acid FILENAME      import urine acid from csv FILENAME
-c --cholesterol CHOLESTEROL         cholesterol in blood in µmol/l using format of: 370/'comment'
-C --import-cholesterol FILENAME     import cholesterol from csv FILENME
-D --dbname DATABASE_NAME            database name
-e --engine DATABASE_ENGINE          database engine can be either sqlite or pgsql
-f --format                          format display (column names, formatting, colors)
-h --help                            help screen
-H --host DATABASE_HOST              database host
-i --initialize INIT_FILENAME        initialize filename
-l [LIST_ENTRIES]                    list last LIST_ENTRIES (default from properties) entries of both pressure and sugar
   --list-cholesterol [LIST_ENTRIES] list last LIST_ENTRIES (default from properties) entries of cholesterol
   --list-pressure [LIST_ENTRIES]    list last LIST ENTRIES (default from properties) entries of pressure
   --list-sugar [LIST_ENTRIES]       list last LIST_ENTRIES (default from properties) entries of sugar
   --list-urine-acid [LIST_ENTRIES]  list last LIST_ENTRIES (default from properties) entries of urine acid
   --log-level [LEVEL]               logging level where LEVEL may be (0=critical, 1=error, 2=warning, 3=info
                                     4=debug)
-p --pressure MEASUREMENT            blood pressure measurement in format of: 120/80/90/'comment'
-P --import_pressure FILENAME        import pressure from csv FILENAME
                                     (systolic/diastolic/pulse/'comment') where comment is optional
-q --query QUERY                     SQL query provided to sqlite database (query should correspond with engine -e option)
-s --sugar SUGAR_LEVEL               sugar level in blood in mg/dL using format of: 123/'comment'
                                     where 'comment' is optional
   --empty                           measurement on empty stomach
   --full                            measurement on full stomach
-S --import-sugar FILENAME           import sugar from csv FILENAME
                                     where 'comment' is optional
-t --time TIME                       sets time in format 'yyyy-MM-dd HH:mm' or 'HH:mm'
                                     if 'HH:mm' format is used date is set to today
-U --user USERNAME                   database user name
-v --version                         displays version information and exits
-X --sync SOURCE:DESTINATION         synchronize databases (copy data from SOURCE to DESTINATION database
                                     either SOURCE or DESTINATION may be: sqlite, pgsql

Example: 
./blood.sh -e pgsql -i createdb.sql
./blood.sh -p 123/80/90/'my fancy comment'
./blood.sh -p 123/80/90/'my fancy comment' -t '2024-05-30 06:26'
./blood.sh -p 123/80/90/'my fancy comment' -t '06:31'

Example usage

Store blood pressure to sqlite database:

$ ./blood.sh -p 120/80/80/'after jogging'
$ ./blood.sh -p 120/80/80/

Store sugar level to sqlite database:

$ ./blood.sh -s 95/'2 hours after lunch'
$ ./blood.sh -s 95/

Synchronize local sqlite database with postgresql

$ ./blood.sh -X sqlite:pgsql

Web interface

Not implemented yet, see TODO section

Visualization

Grafana

Testing

Prerequisites

Tests are launched in dockerized environment Make sure you have installed:

Install bats wherever you want, then copy directories : bats and test_helper into tests folder:

$ git init
$ git submodule add https://github.com/bats-core/bats-core.git test/bats
$ git submodule add https://github.com/bats-core/bats-support.git test/test_helper/bats-support
$ git submodule add https://github.com/bats-core/bats-assert.git test/test_helper/bats-assert
$ git submodule add https://github.com/bats-core/bats-assert.git test/test_helper/bats-files

:warning: Probably you'll need to rename ./tests/test_helper/bats_files to ./tests/test_helper/bats_file

$ mv ./tests/test_helper/bats_files ./tests/test_helper/bats_files
$ ls ./tests
bats  blood.bats  test_helper

Run tests

$ ./run_blood_tests.sh

TODO