From 5d5f430a2d86185c5d7ba0cf07487f58c7b0a474 Mon Sep 17 00:00:00 2001 From: Patrick Gregorio Date: Thu, 3 Apr 2025 12:32:35 -0600 Subject: [PATCH] Removed image mapping in the config.json file --- config.json | 9 +- docker/Dockerfile.redis.arm64 | 2 +- docker/Dockerfile.statistics.arm64 | 35 +- docker/Dockerfile.streamline-emr.amd64 | 78 -- docker/Dockerfile.streamline-emr.arm64 | 3 +- docker/start_up.sh | 84 -- docker/statistics/composer.json | 7 - docker/statistics/composer.lock | 1228 ------------------------ docker/statistics/crontab | 1 - docker/statistics/supervisord.conf | 32 - docker/statistics/sync.php | 422 -------- hosted-app-utils | 2 +- src/docker-compose.yml | 12 +- 13 files changed, 11 insertions(+), 1904 deletions(-) delete mode 100644 docker/Dockerfile.streamline-emr.amd64 delete mode 100755 docker/start_up.sh delete mode 100644 docker/statistics/composer.json delete mode 100644 docker/statistics/composer.lock delete mode 100644 docker/statistics/crontab delete mode 100644 docker/statistics/supervisord.conf delete mode 100644 docker/statistics/sync.php diff --git a/config.json b/config.json index 676b2288..bfe93151 100644 --- a/config.json +++ b/config.json @@ -4,12 +4,5 @@ "version": "2.3", "platforms": [ "linux/arm64" - ], - "images": { - "linux/arm64": { - "registry.gitlab.com/signalytic/client-external/streamline/streamline-emr/streamline-emr/arm64:2.3": "streamline-emr:latest", - "registry.gitlab.com/signalytic/client-external/streamline/streamline-emr/statistics/arm64:2.3": "streamline-emr-statistics:latest", - "registry.gitlab.com/signalytic/client-external/streamline/streamline-emr/redis/arm64:2.3": "streamline-emr-redis:latest" - } - } + ] } diff --git a/docker/Dockerfile.redis.arm64 b/docker/Dockerfile.redis.arm64 index 01160078..f3b227ca 100644 --- a/docker/Dockerfile.redis.arm64 +++ b/docker/Dockerfile.redis.arm64 @@ -1 +1 @@ -FROM redis:alpine \ No newline at end of file +FROM streamline-emr-redis:latest \ No newline at end of file diff --git a/docker/Dockerfile.statistics.arm64 b/docker/Dockerfile.statistics.arm64 index 10e89345..64fa8138 100644 --- a/docker/Dockerfile.statistics.arm64 +++ b/docker/Dockerfile.statistics.arm64 @@ -1,34 +1 @@ -FROM php:cli - -RUN apt-get update && apt-get install -y \ - cron \ - unzip \ - curl \ - libpng-dev \ - libjpeg-dev \ - supervisor \ - && pecl install redis \ - && docker-php-ext-install pdo pdo_mysql gd \ - && docker-php-ext-enable redis \ - && rm -rf /var/lib/apt/lists/* - -RUN curl -sS https://getcomposer.org/installer | \ - php -- --install-dir=/usr/local/bin --filename=composer - -WORKDIR /app - -# install composer dependencies -COPY statistics /app - -RUN composer install - -COPY statistics/crontab /etc/cron.d/crontab - -COPY statistics/supervisord.conf /etc/supervisor/conf.d/supervisord.conf - -RUN chmod 0644 /etc/cron.d/crontab \ - && crontab /etc/cron.d/crontab \ - && touch /var/log/cron.log /app/sync.log \ - && chmod +x /app/sync.php - -CMD ["supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"] \ No newline at end of file +FROM streamlinehealth/streamline:statistics \ No newline at end of file diff --git a/docker/Dockerfile.streamline-emr.amd64 b/docker/Dockerfile.streamline-emr.amd64 deleted file mode 100644 index d1ff96b6..00000000 --- a/docker/Dockerfile.streamline-emr.amd64 +++ /dev/null @@ -1,78 +0,0 @@ -################################################################################ -# Use known working image to pull in working wkhtmltopdf libraries -################################################################################ - -FROM surnet/alpine-wkhtmltopdf:3.16.2-0.12.6-full as wkhtmltopdf -FROM php:8.2-fpm-alpine3.17 AS app - -# wkhtmltopdf install dependencies -RUN apk add --no-cache \ - libstdc++ \ - libx11 \ - libxrender \ - libxext \ - libssl1.1 \ - ca-certificates \ - fontconfig \ - freetype \ - ttf-droid \ - ttf-freefont \ - ttf-liberation \ - # more fonts - ; -# wkhtmltopdf copy bins from ext image -COPY --from=wkhtmltopdf /bin/wkhtmltopdf /bin/wkhtmltoimage /bin/libwkhtmltox.so /usr/bin/ - - -################################################################################ -# Copied from previous Streamline Dockerfile -################################################################################ - -# Install necessary packages and cleanup -RUN set -ex; \ - apk update && \ - apk add --no-cache curl gnupg mysql mysql-client pwgen && \ - docker-php-ext-install pdo pdo_mysql && \ - rm -rf /var/cache/apk/* - -# Install Composer -RUN curl -sS https://getcomposer.org/installer | \ - php -- --install-dir=/usr/bin/ --filename=composer - -# Set the working directory and copy the application code -COPY streamline-src /var/www/html - -COPY my.cnf /etc/mysql/my.cnf - -WORKDIR /var/www/html - -# Create the 'streamline' user and adjust permissions -RUN addgroup -g 1000 streamline && adduser -G streamline -g streamline -s /bin/sh -D streamline && \ - composer install && \ - chmod -R 777 /var/www/html/storage/ && \ - chown -R streamline:streamline /var/www/html && \ - mkdir -p /docker-entrypoint-initdb.d/ - -# Initialize MySQL -COPY streamline_initial.sql /docker-entrypoint-initdb.d/ - -RUN mkdir /scripts && \ - mkdir /scripts/pre-exec.d && \ - mkdir /scripts/pre-init.d && \ - chmod -R 755 /scripts - -VOLUME ["/var/lib/mysql"] - -# Set the startup script as executable -RUN chmod +x /var/www/html/start_up.sh - -# Define the entry point and expose port 80, 3306 -ENTRYPOINT ["/bin/sh", "/var/www/html/start_up.sh"] - -EXPOSE 80 3306 - - -################################################################################ -# Update snappy config to fix issues with wkhtmltopdf -################################################################################ -COPY snappy.php /var/www/html/config/snappy.php \ No newline at end of file diff --git a/docker/Dockerfile.streamline-emr.arm64 b/docker/Dockerfile.streamline-emr.arm64 index cdc299db..53c93670 100644 --- a/docker/Dockerfile.streamline-emr.arm64 +++ b/docker/Dockerfile.streamline-emr.arm64 @@ -1,2 +1 @@ -FROM streamlinehealth/streamline:signalytic -COPY ./start_up.sh /var/www/html/start_up.sh \ No newline at end of file +FROM streamlinehealth/streamline:signalytic \ No newline at end of file diff --git a/docker/start_up.sh b/docker/start_up.sh deleted file mode 100755 index eca61403..00000000 --- a/docker/start_up.sh +++ /dev/null @@ -1,84 +0,0 @@ -#! /bin/sh - -# Required script variables -APP_NAME=${APP_NAME:-'streamline'} -export MYSQL_DATABASE=${DB_DATABASE:-'streamline'} -export MYSQL_USER=${DB_USERNAME:-'root'} -export MYSQL_PASSWORD=${DB_PASSWORD:-'streamline'} -export MYSQL_ROOT_PASSWORD=${DB_ROOT_PASSWORD:-'streamline'} - -# execute run.sh script for MySQL initialisation -chmod +x .docker/mysql/mysql-init.sh - -# run the MariaDB initialization script -echo "[info] running mariadb init script" -./.docker/mysql/mysql-init.sh - -if [ $? -eq 0 ]; then - - echo "[info] waiting for DB to start..." - for i in $(seq 1 30); do - mariadb-admin ping -u $MYSQL_USER -p$MYSQL_PASSWORD &>/dev/null - if [ $? -eq 0 ]; then - echo "[info] DB ready" - break - fi - sleep 1 - done - mariadb-admin ping -u $MYSQL_USER -p$MYSQL_PASSWORD - if [ $? -ne 0 ]; then - echo "[info] timed out waiting for DB" - exit 1 - fi - - echo "[info] MySQL server started. checking for '$MYSQL_DATABASE' database. " - - mysql -u $MYSQL_USER -p$MYSQL_PASSWORD -e "use streamline;" - - # Guard condition to re-check existence of database schema - # If it doesnt exist, create it and import streamline_initial.sql file - if [ $? -eq 1 ]; then - - mysql -u $MYSQL_USER -p$MYSQL_PASSWORD -e "CREATE DATABASE $MYSQL_DATABASE;" - - if [ $? -eq 0 ]; then - echo "[info] Database: $MYSQL_DATABASE created." - - mysql -u $MYSQL_USER -p$MYSQL_PASSWORD $MYSQL_DATABASE < ./.docker/mysql/scripts/streamline_initial.sql - if [ $? -eq 0 ]; then - echo "[info] populated database." - else - echo "[error] database not populated." - fi - - else - echo "[error] database not created." - fi - - else - echo "[info] Database: $MYSQL_DATABASE exists. " - fi - - echo "[info] starting $APP_NAME ..." - - echo "[info] artisan migrate" - php /var/www/html/artisan migrate - echo "[info] migrate result: $?" - - echo "[info] seed: PermissionTableSeeder" - php /var/www/html/artisan db:seed --class=PermissionTableSeeder - echo "[info] seed result: $?" - - echo "[info] seed: PermissionsCategoryTableSeeder" - php /var/www/html/artisan db:seed --class=PermissionsCategoryTableSeeder - echo "[info] seed result: $?" - - echo "serving app..." - php /var/www/html/artisan serve --host=0.0.0.0 --port=80 - -else - echo "[error] MariaDB server couldnt be started." - - # terminate script if database isnt running - exit 1; -fi diff --git a/docker/statistics/composer.json b/docker/statistics/composer.json deleted file mode 100644 index 6bc8d678..00000000 --- a/docker/statistics/composer.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "require": { - "monolog/monolog": "^3.9", - "guzzlehttp/guzzle": "^7.0", - "vlucas/phpdotenv": "^5.6" - } -} diff --git a/docker/statistics/composer.lock b/docker/statistics/composer.lock deleted file mode 100644 index 83d4444e..00000000 --- a/docker/statistics/composer.lock +++ /dev/null @@ -1,1228 +0,0 @@ -{ - "_readme": [ - "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", - "This file is @generated automatically" - ], - "content-hash": "a7ce4b351e6b2e954e45fdbc6dfaad41", - "packages": [ - { - "name": "graham-campbell/result-type", - "version": "v1.1.3", - "source": { - "type": "git", - "url": "https://github.com/GrahamCampbell/Result-Type.git", - "reference": "3ba905c11371512af9d9bdd27d99b782216b6945" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/GrahamCampbell/Result-Type/zipball/3ba905c11371512af9d9bdd27d99b782216b6945", - "reference": "3ba905c11371512af9d9bdd27d99b782216b6945", - "shasum": "" - }, - "require": { - "php": "^7.2.5 || ^8.0", - "phpoption/phpoption": "^1.9.3" - }, - "require-dev": { - "phpunit/phpunit": "^8.5.39 || ^9.6.20 || ^10.5.28" - }, - "type": "library", - "autoload": { - "psr-4": { - "GrahamCampbell\\ResultType\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Graham Campbell", - "email": "hello@gjcampbell.co.uk", - "homepage": "https://github.com/GrahamCampbell" - } - ], - "description": "An Implementation Of The Result Type", - "keywords": [ - "Graham Campbell", - "GrahamCampbell", - "Result Type", - "Result-Type", - "result" - ], - "support": { - "issues": "https://github.com/GrahamCampbell/Result-Type/issues", - "source": "https://github.com/GrahamCampbell/Result-Type/tree/v1.1.3" - }, - "funding": [ - { - "url": "https://github.com/GrahamCampbell", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/graham-campbell/result-type", - "type": "tidelift" - } - ], - "time": "2024-07-20T21:45:45+00:00" - }, - { - "name": "guzzlehttp/guzzle", - "version": "7.9.2", - "source": { - "type": "git", - "url": "https://github.com/guzzle/guzzle.git", - "reference": "d281ed313b989f213357e3be1a179f02196ac99b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/d281ed313b989f213357e3be1a179f02196ac99b", - "reference": "d281ed313b989f213357e3be1a179f02196ac99b", - "shasum": "" - }, - "require": { - "ext-json": "*", - "guzzlehttp/promises": "^1.5.3 || ^2.0.3", - "guzzlehttp/psr7": "^2.7.0", - "php": "^7.2.5 || ^8.0", - "psr/http-client": "^1.0", - "symfony/deprecation-contracts": "^2.2 || ^3.0" - }, - "provide": { - "psr/http-client-implementation": "1.0" - }, - "require-dev": { - "bamarni/composer-bin-plugin": "^1.8.2", - "ext-curl": "*", - "guzzle/client-integration-tests": "3.0.2", - "php-http/message-factory": "^1.1", - "phpunit/phpunit": "^8.5.39 || ^9.6.20", - "psr/log": "^1.1 || ^2.0 || ^3.0" - }, - "suggest": { - "ext-curl": "Required for CURL handler support", - "ext-intl": "Required for Internationalized Domain Name (IDN) support", - "psr/log": "Required for using the Log middleware" - }, - "type": "library", - "extra": { - "bamarni-bin": { - "bin-links": true, - "forward-command": false - } - }, - "autoload": { - "files": [ - "src/functions_include.php" - ], - "psr-4": { - "GuzzleHttp\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Graham Campbell", - "email": "hello@gjcampbell.co.uk", - "homepage": "https://github.com/GrahamCampbell" - }, - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - }, - { - "name": "Jeremy Lindblom", - "email": "jeremeamia@gmail.com", - "homepage": "https://github.com/jeremeamia" - }, - { - "name": "George Mponos", - "email": "gmponos@gmail.com", - "homepage": "https://github.com/gmponos" - }, - { - "name": "Tobias Nyholm", - "email": "tobias.nyholm@gmail.com", - "homepage": "https://github.com/Nyholm" - }, - { - "name": "Márk Sági-Kazár", - "email": "mark.sagikazar@gmail.com", - "homepage": "https://github.com/sagikazarmark" - }, - { - "name": "Tobias Schultze", - "email": "webmaster@tubo-world.de", - "homepage": "https://github.com/Tobion" - } - ], - "description": "Guzzle is a PHP HTTP client library", - "keywords": [ - "client", - "curl", - "framework", - "http", - "http client", - "psr-18", - "psr-7", - "rest", - "web service" - ], - "support": { - "issues": "https://github.com/guzzle/guzzle/issues", - "source": "https://github.com/guzzle/guzzle/tree/7.9.2" - }, - "funding": [ - { - "url": "https://github.com/GrahamCampbell", - "type": "github" - }, - { - "url": "https://github.com/Nyholm", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/guzzle", - "type": "tidelift" - } - ], - "time": "2024-07-24T11:22:20+00:00" - }, - { - "name": "guzzlehttp/promises", - "version": "2.0.4", - "source": { - "type": "git", - "url": "https://github.com/guzzle/promises.git", - "reference": "f9c436286ab2892c7db7be8c8da4ef61ccf7b455" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/guzzle/promises/zipball/f9c436286ab2892c7db7be8c8da4ef61ccf7b455", - "reference": "f9c436286ab2892c7db7be8c8da4ef61ccf7b455", - "shasum": "" - }, - "require": { - "php": "^7.2.5 || ^8.0" - }, - "require-dev": { - "bamarni/composer-bin-plugin": "^1.8.2", - "phpunit/phpunit": "^8.5.39 || ^9.6.20" - }, - "type": "library", - "extra": { - "bamarni-bin": { - "bin-links": true, - "forward-command": false - } - }, - "autoload": { - "psr-4": { - "GuzzleHttp\\Promise\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Graham Campbell", - "email": "hello@gjcampbell.co.uk", - "homepage": "https://github.com/GrahamCampbell" - }, - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - }, - { - "name": "Tobias Nyholm", - "email": "tobias.nyholm@gmail.com", - "homepage": "https://github.com/Nyholm" - }, - { - "name": "Tobias Schultze", - "email": "webmaster@tubo-world.de", - "homepage": "https://github.com/Tobion" - } - ], - "description": "Guzzle promises library", - "keywords": [ - "promise" - ], - "support": { - "issues": "https://github.com/guzzle/promises/issues", - "source": "https://github.com/guzzle/promises/tree/2.0.4" - }, - "funding": [ - { - "url": "https://github.com/GrahamCampbell", - "type": "github" - }, - { - "url": "https://github.com/Nyholm", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/promises", - "type": "tidelift" - } - ], - "time": "2024-10-17T10:06:22+00:00" - }, - { - "name": "guzzlehttp/psr7", - "version": "2.7.0", - "source": { - "type": "git", - "url": "https://github.com/guzzle/psr7.git", - "reference": "a70f5c95fb43bc83f07c9c948baa0dc1829bf201" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/a70f5c95fb43bc83f07c9c948baa0dc1829bf201", - "reference": "a70f5c95fb43bc83f07c9c948baa0dc1829bf201", - "shasum": "" - }, - "require": { - "php": "^7.2.5 || ^8.0", - "psr/http-factory": "^1.0", - "psr/http-message": "^1.1 || ^2.0", - "ralouphie/getallheaders": "^3.0" - }, - "provide": { - "psr/http-factory-implementation": "1.0", - "psr/http-message-implementation": "1.0" - }, - "require-dev": { - "bamarni/composer-bin-plugin": "^1.8.2", - "http-interop/http-factory-tests": "0.9.0", - "phpunit/phpunit": "^8.5.39 || ^9.6.20" - }, - "suggest": { - "laminas/laminas-httphandlerrunner": "Emit PSR-7 responses" - }, - "type": "library", - "extra": { - "bamarni-bin": { - "bin-links": true, - "forward-command": false - } - }, - "autoload": { - "psr-4": { - "GuzzleHttp\\Psr7\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Graham Campbell", - "email": "hello@gjcampbell.co.uk", - "homepage": "https://github.com/GrahamCampbell" - }, - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - }, - { - "name": "George Mponos", - "email": "gmponos@gmail.com", - "homepage": "https://github.com/gmponos" - }, - { - "name": "Tobias Nyholm", - "email": "tobias.nyholm@gmail.com", - "homepage": "https://github.com/Nyholm" - }, - { - "name": "Márk Sági-Kazár", - "email": "mark.sagikazar@gmail.com", - "homepage": "https://github.com/sagikazarmark" - }, - { - "name": "Tobias Schultze", - "email": "webmaster@tubo-world.de", - "homepage": "https://github.com/Tobion" - }, - { - "name": "Márk Sági-Kazár", - "email": "mark.sagikazar@gmail.com", - "homepage": "https://sagikazarmark.hu" - } - ], - "description": "PSR-7 message implementation that also provides common utility methods", - "keywords": [ - "http", - "message", - "psr-7", - "request", - "response", - "stream", - "uri", - "url" - ], - "support": { - "issues": "https://github.com/guzzle/psr7/issues", - "source": "https://github.com/guzzle/psr7/tree/2.7.0" - }, - "funding": [ - { - "url": "https://github.com/GrahamCampbell", - "type": "github" - }, - { - "url": "https://github.com/Nyholm", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/psr7", - "type": "tidelift" - } - ], - "time": "2024-07-18T11:15:46+00:00" - }, - { - "name": "monolog/monolog", - "version": "3.9.0", - "source": { - "type": "git", - "url": "https://github.com/Seldaek/monolog.git", - "reference": "10d85740180ecba7896c87e06a166e0c95a0e3b6" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/Seldaek/monolog/zipball/10d85740180ecba7896c87e06a166e0c95a0e3b6", - "reference": "10d85740180ecba7896c87e06a166e0c95a0e3b6", - "shasum": "" - }, - "require": { - "php": ">=8.1", - "psr/log": "^2.0 || ^3.0" - }, - "provide": { - "psr/log-implementation": "3.0.0" - }, - "require-dev": { - "aws/aws-sdk-php": "^3.0", - "doctrine/couchdb": "~1.0@dev", - "elasticsearch/elasticsearch": "^7 || ^8", - "ext-json": "*", - "graylog2/gelf-php": "^1.4.2 || ^2.0", - "guzzlehttp/guzzle": "^7.4.5", - "guzzlehttp/psr7": "^2.2", - "mongodb/mongodb": "^1.8", - "php-amqplib/php-amqplib": "~2.4 || ^3", - "php-console/php-console": "^3.1.8", - "phpstan/phpstan": "^2", - "phpstan/phpstan-deprecation-rules": "^2", - "phpstan/phpstan-strict-rules": "^2", - "phpunit/phpunit": "^10.5.17 || ^11.0.7", - "predis/predis": "^1.1 || ^2", - "rollbar/rollbar": "^4.0", - "ruflin/elastica": "^7 || ^8", - "symfony/mailer": "^5.4 || ^6", - "symfony/mime": "^5.4 || ^6" - }, - "suggest": { - "aws/aws-sdk-php": "Allow sending log messages to AWS services like DynamoDB", - "doctrine/couchdb": "Allow sending log messages to a CouchDB server", - "elasticsearch/elasticsearch": "Allow sending log messages to an Elasticsearch server via official client", - "ext-amqp": "Allow sending log messages to an AMQP server (1.0+ required)", - "ext-curl": "Required to send log messages using the IFTTTHandler, the LogglyHandler, the SendGridHandler, the SlackWebhookHandler or the TelegramBotHandler", - "ext-mbstring": "Allow to work properly with unicode symbols", - "ext-mongodb": "Allow sending log messages to a MongoDB server (via driver)", - "ext-openssl": "Required to send log messages using SSL", - "ext-sockets": "Allow sending log messages to a Syslog server (via UDP driver)", - "graylog2/gelf-php": "Allow sending log messages to a GrayLog2 server", - "mongodb/mongodb": "Allow sending log messages to a MongoDB server (via library)", - "php-amqplib/php-amqplib": "Allow sending log messages to an AMQP server using php-amqplib", - "rollbar/rollbar": "Allow sending log messages to Rollbar", - "ruflin/elastica": "Allow sending log messages to an Elastic Search server" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "3.x-dev" - } - }, - "autoload": { - "psr-4": { - "Monolog\\": "src/Monolog" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jordi Boggiano", - "email": "j.boggiano@seld.be", - "homepage": "https://seld.be" - } - ], - "description": "Sends your logs to files, sockets, inboxes, databases and various web services", - "homepage": "https://github.com/Seldaek/monolog", - "keywords": [ - "log", - "logging", - "psr-3" - ], - "support": { - "issues": "https://github.com/Seldaek/monolog/issues", - "source": "https://github.com/Seldaek/monolog/tree/3.9.0" - }, - "funding": [ - { - "url": "https://github.com/Seldaek", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/monolog/monolog", - "type": "tidelift" - } - ], - "time": "2025-03-24T10:02:05+00:00" - }, - { - "name": "phpoption/phpoption", - "version": "1.9.3", - "source": { - "type": "git", - "url": "https://github.com/schmittjoh/php-option.git", - "reference": "e3fac8b24f56113f7cb96af14958c0dd16330f54" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/schmittjoh/php-option/zipball/e3fac8b24f56113f7cb96af14958c0dd16330f54", - "reference": "e3fac8b24f56113f7cb96af14958c0dd16330f54", - "shasum": "" - }, - "require": { - "php": "^7.2.5 || ^8.0" - }, - "require-dev": { - "bamarni/composer-bin-plugin": "^1.8.2", - "phpunit/phpunit": "^8.5.39 || ^9.6.20 || ^10.5.28" - }, - "type": "library", - "extra": { - "bamarni-bin": { - "bin-links": true, - "forward-command": false - }, - "branch-alias": { - "dev-master": "1.9-dev" - } - }, - "autoload": { - "psr-4": { - "PhpOption\\": "src/PhpOption/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "Apache-2.0" - ], - "authors": [ - { - "name": "Johannes M. Schmitt", - "email": "schmittjoh@gmail.com", - "homepage": "https://github.com/schmittjoh" - }, - { - "name": "Graham Campbell", - "email": "hello@gjcampbell.co.uk", - "homepage": "https://github.com/GrahamCampbell" - } - ], - "description": "Option Type for PHP", - "keywords": [ - "language", - "option", - "php", - "type" - ], - "support": { - "issues": "https://github.com/schmittjoh/php-option/issues", - "source": "https://github.com/schmittjoh/php-option/tree/1.9.3" - }, - "funding": [ - { - "url": "https://github.com/GrahamCampbell", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/phpoption/phpoption", - "type": "tidelift" - } - ], - "time": "2024-07-20T21:41:07+00:00" - }, - { - "name": "psr/http-client", - "version": "1.0.3", - "source": { - "type": "git", - "url": "https://github.com/php-fig/http-client.git", - "reference": "bb5906edc1c324c9a05aa0873d40117941e5fa90" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/http-client/zipball/bb5906edc1c324c9a05aa0873d40117941e5fa90", - "reference": "bb5906edc1c324c9a05aa0873d40117941e5fa90", - "shasum": "" - }, - "require": { - "php": "^7.0 || ^8.0", - "psr/http-message": "^1.0 || ^2.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Http\\Client\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "https://www.php-fig.org/" - } - ], - "description": "Common interface for HTTP clients", - "homepage": "https://github.com/php-fig/http-client", - "keywords": [ - "http", - "http-client", - "psr", - "psr-18" - ], - "support": { - "source": "https://github.com/php-fig/http-client" - }, - "time": "2023-09-23T14:17:50+00:00" - }, - { - "name": "psr/http-factory", - "version": "1.1.0", - "source": { - "type": "git", - "url": "https://github.com/php-fig/http-factory.git", - "reference": "2b4765fddfe3b508ac62f829e852b1501d3f6e8a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/http-factory/zipball/2b4765fddfe3b508ac62f829e852b1501d3f6e8a", - "reference": "2b4765fddfe3b508ac62f829e852b1501d3f6e8a", - "shasum": "" - }, - "require": { - "php": ">=7.1", - "psr/http-message": "^1.0 || ^2.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Http\\Message\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "https://www.php-fig.org/" - } - ], - "description": "PSR-17: Common interfaces for PSR-7 HTTP message factories", - "keywords": [ - "factory", - "http", - "message", - "psr", - "psr-17", - "psr-7", - "request", - "response" - ], - "support": { - "source": "https://github.com/php-fig/http-factory" - }, - "time": "2024-04-15T12:06:14+00:00" - }, - { - "name": "psr/http-message", - "version": "2.0", - "source": { - "type": "git", - "url": "https://github.com/php-fig/http-message.git", - "reference": "402d35bcb92c70c026d1a6a9883f06b2ead23d71" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/http-message/zipball/402d35bcb92c70c026d1a6a9883f06b2ead23d71", - "reference": "402d35bcb92c70c026d1a6a9883f06b2ead23d71", - "shasum": "" - }, - "require": { - "php": "^7.2 || ^8.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Http\\Message\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "https://www.php-fig.org/" - } - ], - "description": "Common interface for HTTP messages", - "homepage": "https://github.com/php-fig/http-message", - "keywords": [ - "http", - "http-message", - "psr", - "psr-7", - "request", - "response" - ], - "support": { - "source": "https://github.com/php-fig/http-message/tree/2.0" - }, - "time": "2023-04-04T09:54:51+00:00" - }, - { - "name": "psr/log", - "version": "3.0.2", - "source": { - "type": "git", - "url": "https://github.com/php-fig/log.git", - "reference": "f16e1d5863e37f8d8c2a01719f5b34baa2b714d3" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/f16e1d5863e37f8d8c2a01719f5b34baa2b714d3", - "reference": "f16e1d5863e37f8d8c2a01719f5b34baa2b714d3", - "shasum": "" - }, - "require": { - "php": ">=8.0.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Log\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "https://www.php-fig.org/" - } - ], - "description": "Common interface for logging libraries", - "homepage": "https://github.com/php-fig/log", - "keywords": [ - "log", - "psr", - "psr-3" - ], - "support": { - "source": "https://github.com/php-fig/log/tree/3.0.2" - }, - "time": "2024-09-11T13:17:53+00:00" - }, - { - "name": "ralouphie/getallheaders", - "version": "3.0.3", - "source": { - "type": "git", - "url": "https://github.com/ralouphie/getallheaders.git", - "reference": "120b605dfeb996808c31b6477290a714d356e822" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822", - "reference": "120b605dfeb996808c31b6477290a714d356e822", - "shasum": "" - }, - "require": { - "php": ">=5.6" - }, - "require-dev": { - "php-coveralls/php-coveralls": "^2.1", - "phpunit/phpunit": "^5 || ^6.5" - }, - "type": "library", - "autoload": { - "files": [ - "src/getallheaders.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Ralph Khattar", - "email": "ralph.khattar@gmail.com" - } - ], - "description": "A polyfill for getallheaders.", - "support": { - "issues": "https://github.com/ralouphie/getallheaders/issues", - "source": "https://github.com/ralouphie/getallheaders/tree/develop" - }, - "time": "2019-03-08T08:55:37+00:00" - }, - { - "name": "symfony/deprecation-contracts", - "version": "v3.5.1", - "source": { - "type": "git", - "url": "https://github.com/symfony/deprecation-contracts.git", - "reference": "74c71c939a79f7d5bf3c1ce9f5ea37ba0114c6f6" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/74c71c939a79f7d5bf3c1ce9f5ea37ba0114c6f6", - "reference": "74c71c939a79f7d5bf3c1ce9f5ea37ba0114c6f6", - "shasum": "" - }, - "require": { - "php": ">=8.1" - }, - "type": "library", - "extra": { - "thanks": { - "url": "https://github.com/symfony/contracts", - "name": "symfony/contracts" - }, - "branch-alias": { - "dev-main": "3.5-dev" - } - }, - "autoload": { - "files": [ - "function.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "A generic function and convention to trigger deprecation notices", - "homepage": "https://symfony.com", - "support": { - "source": "https://github.com/symfony/deprecation-contracts/tree/v3.5.1" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2024-09-25T14:20:29+00:00" - }, - { - "name": "symfony/polyfill-ctype", - "version": "v1.31.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "a3cc8b044a6ea513310cbd48ef7333b384945638" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/a3cc8b044a6ea513310cbd48ef7333b384945638", - "reference": "a3cc8b044a6ea513310cbd48ef7333b384945638", - "shasum": "" - }, - "require": { - "php": ">=7.2" - }, - "provide": { - "ext-ctype": "*" - }, - "suggest": { - "ext-ctype": "For best performance" - }, - "type": "library", - "extra": { - "thanks": { - "url": "https://github.com/symfony/polyfill", - "name": "symfony/polyfill" - } - }, - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Ctype\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Gert de Pagter", - "email": "BackEndTea@gmail.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for ctype functions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "ctype", - "polyfill", - "portable" - ], - "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.31.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2024-09-09T11:45:10+00:00" - }, - { - "name": "symfony/polyfill-mbstring", - "version": "v1.31.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "85181ba99b2345b0ef10ce42ecac37612d9fd341" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/85181ba99b2345b0ef10ce42ecac37612d9fd341", - "reference": "85181ba99b2345b0ef10ce42ecac37612d9fd341", - "shasum": "" - }, - "require": { - "php": ">=7.2" - }, - "provide": { - "ext-mbstring": "*" - }, - "suggest": { - "ext-mbstring": "For best performance" - }, - "type": "library", - "extra": { - "thanks": { - "url": "https://github.com/symfony/polyfill", - "name": "symfony/polyfill" - } - }, - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Mbstring\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for the Mbstring extension", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "mbstring", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.31.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2024-09-09T11:45:10+00:00" - }, - { - "name": "symfony/polyfill-php80", - "version": "v1.31.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "60328e362d4c2c802a54fcbf04f9d3fb892b4cf8" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/60328e362d4c2c802a54fcbf04f9d3fb892b4cf8", - "reference": "60328e362d4c2c802a54fcbf04f9d3fb892b4cf8", - "shasum": "" - }, - "require": { - "php": ">=7.2" - }, - "type": "library", - "extra": { - "thanks": { - "url": "https://github.com/symfony/polyfill", - "name": "symfony/polyfill" - } - }, - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Php80\\": "" - }, - "classmap": [ - "Resources/stubs" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Ion Bazan", - "email": "ion.bazan@gmail.com" - }, - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.31.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2024-09-09T11:45:10+00:00" - }, - { - "name": "vlucas/phpdotenv", - "version": "v5.6.1", - "source": { - "type": "git", - "url": "https://github.com/vlucas/phpdotenv.git", - "reference": "a59a13791077fe3d44f90e7133eb68e7d22eaff2" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/a59a13791077fe3d44f90e7133eb68e7d22eaff2", - "reference": "a59a13791077fe3d44f90e7133eb68e7d22eaff2", - "shasum": "" - }, - "require": { - "ext-pcre": "*", - "graham-campbell/result-type": "^1.1.3", - "php": "^7.2.5 || ^8.0", - "phpoption/phpoption": "^1.9.3", - "symfony/polyfill-ctype": "^1.24", - "symfony/polyfill-mbstring": "^1.24", - "symfony/polyfill-php80": "^1.24" - }, - "require-dev": { - "bamarni/composer-bin-plugin": "^1.8.2", - "ext-filter": "*", - "phpunit/phpunit": "^8.5.34 || ^9.6.13 || ^10.4.2" - }, - "suggest": { - "ext-filter": "Required to use the boolean validator." - }, - "type": "library", - "extra": { - "bamarni-bin": { - "bin-links": true, - "forward-command": false - }, - "branch-alias": { - "dev-master": "5.6-dev" - } - }, - "autoload": { - "psr-4": { - "Dotenv\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Graham Campbell", - "email": "hello@gjcampbell.co.uk", - "homepage": "https://github.com/GrahamCampbell" - }, - { - "name": "Vance Lucas", - "email": "vance@vancelucas.com", - "homepage": "https://github.com/vlucas" - } - ], - "description": "Loads environment variables from `.env` to `getenv()`, `$_ENV` and `$_SERVER` automagically.", - "keywords": [ - "dotenv", - "env", - "environment" - ], - "support": { - "issues": "https://github.com/vlucas/phpdotenv/issues", - "source": "https://github.com/vlucas/phpdotenv/tree/v5.6.1" - }, - "funding": [ - { - "url": "https://github.com/GrahamCampbell", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/vlucas/phpdotenv", - "type": "tidelift" - } - ], - "time": "2024-07-20T21:52:34+00:00" - } - ], - "packages-dev": [], - "aliases": [], - "minimum-stability": "stable", - "stability-flags": [], - "prefer-stable": false, - "prefer-lowest": false, - "platform": [], - "platform-dev": [], - "plugin-api-version": "2.2.0" -} diff --git a/docker/statistics/crontab b/docker/statistics/crontab deleted file mode 100644 index ee4a5668..00000000 --- a/docker/statistics/crontab +++ /dev/null @@ -1 +0,0 @@ -0 * * * * /usr/local/bin/php /app/sync.php >> /var/log/cron.log 2>&1 diff --git a/docker/statistics/supervisord.conf b/docker/statistics/supervisord.conf deleted file mode 100644 index 69811898..00000000 --- a/docker/statistics/supervisord.conf +++ /dev/null @@ -1,32 +0,0 @@ -[supervisord] -nodaemon=true -loglevel=info -logfile=/dev/stdout -logfile_maxbytes=0 - -[program:cron] -command=cron -f -autorestart=true -stdout_logfile=/dev/stdout -stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr -stderr_logfile_maxbytes=0 -priority=10 - -[program:sync-log] -command=tail -f /app/sync.log -autorestart=true -stdout_logfile=/dev/stdout -stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr -stderr_logfile_maxbytes=0 -priority=20 - -[program:cron-log] -command=tail -f /var/log/cron.log -autorestart=true -stdout_logfile=/dev/stdout -stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr -stderr_logfile_maxbytes=0 -priority=30 diff --git a/docker/statistics/sync.php b/docker/statistics/sync.php deleted file mode 100644 index a37512af..00000000 --- a/docker/statistics/sync.php +++ /dev/null @@ -1,422 +0,0 @@ -load(); - -class sync{ - - protected $db_host; - protected $db_name; - protected $db_user; - protected $db_password; - protected $server; - - protected $redis; - protected $redis_port; - protected $redis_host; - protected $redis_ttl; - protected $redis_timeout = 5; - - protected $db; - protected $http; - - protected $endpoint; - - protected $logger; - protected $log_file = __DIR__."/sync.log"; - - private $payload; - protected $server_status_url; - - function __construct(){ - # log service - $this->logger = new Logger("data-sync"); - - $stream_handler = new StreamHandler($this->log_file); - $this->logger->pushHandler($stream_handler); - - $this->logger->info("initializing sync."); - - # database setup - $this->db_name = $_ENV['DB_DATABASE']; - $this->db_host = $_ENV['DB_HOST']; - $this->db_user = $_ENV['DB_USERNAME']; - $this->db_password = $_ENV['DB_PASSWORD']; - - $this->db = new PDO("mysql:host=". $this->db_host .";dbname=". $this->db_name, $this->db_user, $this->db_password); - $this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); - - if(!$this->db) $this->logger->error("failed to connect to database."); - - $this->logger->debug("Connected to database."); - - # redis - $this->redis_host = $_ENV["REDIS_HOST"]; - $this->redis_port = $_ENV["REDIS_PORT"]; - $this->redis_ttl = $_ENV["REDIS_TTL"]; - - $this->redis = new Redis(); - $this->redis->connect($this->redis_host, $this->redis_port, $this->redis_timeout); - if(!$this->redis) $this->logger->error('Failed to connect to redis server.'); - - $this->logger->debug("Connected to redis server."); - - # remote server/endpoint - $this->server = $_ENV["SERVER"]; - $this->server_status_url = $_ENV["SERVER_STATUS_URL"]; - $this->endpoint = $_ENV['SERVER_ENDPOINT']; - - $this->http = new Client([ - 'base_uri' => $this->server, - 'timeout' => 3.0, - ]); - - # fetch data - $db_data = $this->fetchData(); - } - - function startSync(){ - - try{ - if(!$this->endpoint) throw new Exception("No remote server-endpoint specified. sync terminated."); - - $this->logger->info("Checking internet connection.", ["url"=> $this->endpoint ]); - - $response = $this->http->get($this->server_status_url, [ - 'timeout'=> 10, - 'http_errors'=> true, - 'headers' => [ - 'Accept' => 'application/json', - 'X-Requested-With' => 'XMLHttpRequest' - ], - 'verify'=> true, - 'allow_redirects'=> false - ]); - - $status_code = $response->getStatusCode(); - $response_body = $response->getBody()->getContents(); - - if($status_code != 200) throw new Exception("Internet connection unavailable, saving to cache."); - - $this->logger->debug("Internet connection available.", ["status_code"=> $status_code, "response"=> $response_body]); - - $upload_cache = $this->uploadCache(); - if(!$upload_cache) throw new Exception("Upload failed. [". $upload_cache."]"); - - $this->logger->info("Internet connection available. uploading data.", ["upload"=> $upload_cache ]); - - return true; - }catch(Exception $ex){ - $this->logger->error($ex->getMessage()); - - return false; - } - } - - public function fetchData(){ - $this->logger->info("Querying database. ", ["db"=> $this->db_name]); - - try{ - $previous = $this->db->query("SELECT * FROM signalytic_data")->fetch(PDO::FETCH_ASSOC)['last_fetch_date']; - - if(!$previous) $this->logger->error("last fetch date not found. "); - - $hospitalInformation = $this->db->query("SELECT * FROM hospital_information")->fetch(PDO::FETCH_ASSOC); - - $episodes = $this->db->query("SELECT triage_id, consultation_id, gender, clinic_id, name, slug FROM patient_episodes - JOIN patients ON patient_episodes.patient_id = patients.id - LEFT JOIN clinics ON patient_episodes.clinic_id = clinics.id - WHERE patient_episodes.created_at > '{$previous}'"); - - $episodes_created_male = 0; - $episodes_created_female = 0; - $episodes_completed_with_outcome = []; - $episodes_per_clinic = []; - $episodes_triaged = 0; - - while ($row = $episodes->fetch(PDO::FETCH_ASSOC)) { - if ($row['gender'] == 1) { - $episodes_created_male++; - } else if ($row['gender'] == 2) { - $episodes_created_female++; - } - - if (!is_null($row['triage_id'])) { - $episodes_triaged++; - } - - if (!is_null($row['clinic_id'])) { - $episodes_per_clinic[$row['clinic_id']] = [ - 'clinic_name' => $row['name'], - 'clinic_type' => $row['slug'], - 'clinic_count' => ($episodes_per_clinic[$row['clinic_id']]['clinic_count'] ?? 0) + 1, - ]; - } - - if (!is_null($row['consultation_id'])) { - $cons = $this->db->query("SELECT consultations.outcome_id, outcomes.name FROM consultations - JOIN outcomes ON consultations.outcome_id = outcomes.id - WHERE consultations.id = '{$row['consultation_id']}'")->fetch(PDO::FETCH_ASSOC); - $episodes_completed_with_outcome[$cons['outcome_id']] = [ - 'outcome_name' => $cons['name'], - 'outcome_count' => ($episodes_completed_with_outcome[$cons['outcome_id']]['outcome_count'] ?? 0) + 1, - ]; - } - } - - $users_seen = $this->db->query("SELECT * FROM users WHERE last_seen > '{$previous}'")->rowCount(); - $male_patients = $this->db->query("SELECT * FROM patients WHERE created_at > '{$previous}' AND gender = '1'")->rowCount(); - $female_patients = $this->db->query("SELECT * FROM patients WHERE created_at > '{$previous}' AND gender = '2'")->rowCount(); - $receipts = $this->db->query("SELECT * FROM track_receipts WHERE created_at > '{$previous}'")->rowCount(); - $pharmacyRec = $this->db->query("SELECT * FROM pharmacy_stock_reconciliations WHERE created_at > '{$previous}' AND completion_status = 1")->rowCount(); - $storeRec = $this->db->query("SELECT * FROM store_stock_reconciliations WHERE created_at > '{$previous}' AND completion_status = 1")->rowCount(); - $quotations = $this->db->query("SELECT * FROM quotations WHERE created_at > '{$previous}' AND receive_date IS NOT NULL")->rowCount(); - - $inpatients = $this->db->query("SELECT inpatient_info.discharged, inpatient_info.died_on, patients.gender FROM inpatient_info JOIN patients ON inpatient_info.patient_id = patients.id WHERE inpatient_info.created_at > '{$previous}'"); - - $patients_admitted_male = 0; - $patients_admitted_female = 0; - $patients_discharged_male = 0; - $patients_discharged_female = 0; - - while ($row = $inpatients->fetch(PDO::FETCH_ASSOC)) { - if ($row['gender'] == 1) { - $patients_admitted_male++; - } else if ($row['gender'] == 2) { - $patients_admitted_female++; - } - - if ($row['discharged'] === 1 || !is_null($row['died_on'])) { - if ($row['gender'] == 1) { - $patients_discharged_male++; - } else if ($row['gender'] == 2) { - $patients_discharged_female++; - } - } - } - - $investigations = $this->db->query("SELECT * FROM ordered_investigations WHERE created_at > '{$previous}'"); - - $investigation_requests = 0; - $investigation_results = 0; - - while ($row = $investigations->fetch(PDO::FETCH_ASSOC)) { - $investigation_requests++; - - // top_investigations - if ($row['investigation_status'] === 1) { - $investigation_results++; - } - } - - $treatments = $this->db->query("SELECT * FROM treatments WHERE created_at > '{$previous}'"); - - $prescriptions = 0; - $prescriptions_dispensed = 0; - - while ($row = $treatments->fetch(PDO::FETCH_ASSOC)) { - $prescriptions++; - - if ($row['dispense_status'] === 1) { - $prescriptions_dispensed++; - } - } - - $top_diagnosis = $this->db->query("SELECT primary_diagnosis, COUNT(*) AS freq, name FROM consultations JOIN diagnoses ON consultations.primary_diagnosis = diagnoses.id WHERE consultations.created_at > '{$previous}' GROUP BY primary_diagnosis ORDER BY freq DESC LIMIT 5")->fetchAll(); - - $data = json_encode([ - 'facility_name' => $hospitalInformation['name'], - 'facility_email' => $hospitalInformation['email'], - 'facility_address' => $hospitalInformation['address'], - 'facility_unique_identifier' => $hospitalInformation['unique_hospital_identifier'] ?? '', - 'time_period' => "{$previous} to " . date("Y-m-d H:i:s"), - 'episodes_created_male' => $episodes_created_male, - 'episodes_created_female' => $episodes_created_female, - 'episodes_completed_with_outcome' => $episodes_completed_with_outcome, - 'episodes_triaged' => $episodes_triaged, - 'patients_admitted_male' => $patients_admitted_male, - 'patients_admitted_female' => $patients_admitted_female, - 'patients_discharged_male' => $patients_discharged_male, - 'patients_discharged_female' => $patients_discharged_female, - 'number_of_prescriptions' => $prescriptions, - 'number_of_prescriptions_dispensed' => $prescriptions_dispensed, - 'payment_receipts_generated' => $receipts, - 'active_users' => $users_seen, - 'male_patients_registered' => $male_patients, - 'female_patients_registered' => $female_patients, - 'investigation_requests' => $investigation_requests, - 'investigation_requests_with_results' => $investigation_results, - 'times_inventory_stock_received' => $quotations, - 'times_stock_reconciled_pharmacy' => $pharmacyRec, - 'times_stock_reconciled_store' => $storeRec, - 'top_diagnosis' => $top_diagnosis, - 'top_investigations' => [], - 'top_prescribed_drugs_opd' => [], - 'top_prescribed_drugs_ipd' => [], - 'top_dispensed_drugs_opd' => [], - 'top_dispensed_drugs_ipd' => [], - 'episodes_per_clinic' => $episodes_per_clinic]); - - $this->logger->debug("Fetched: ". $data); - $this->logger->info("Queries executed successfully. data saved.", ['size'=> strlen($data)]); - - return $this->saveToCache($data); - }catch(Exception $ex){ - $this->logger->error($ex->getMessage()); - return false; - } - } - - public function uploadData($endpoint = null, $data = null) - { - $this->logger->info("Uploading payload.", ["url"=> $this->server. $this->endpoint ]); - - try{ - if(!$endpoint) throw new Exception("No endpoint specified."); - - if(empty($data)) throw new Exception("Payload is empty."); - - $options = [ - 'json' => json_decode($data), - 'allow_redirects' => false, - 'timeout' => 5, - 'headers' => [ - 'Accept' => 'application/json', - 'X-Requested-With' => 'XMLHttpRequest' - ] - ]; - - $response = $this->http->post($endpoint, $options); - - $statusCode = $response->getStatusCode(); - $response_body = $response->getBody()->getContents(); - - if($statusCode != 200) throw new Exception("Unexpected http-response: ". $response_body); - - $this->logger->info("Data uploaded.", ["remote"=> $this->server. $endpoint, "status_code"=> $statusCode, "response"=> $response_body ]); - - $this->updateLastFetchDate(); - - return true; - }catch(Exception $ex){ - $this->logger->error($ex->getMessage()); - - return false; - } - } - - function updateLastFetchDate(){ - try { - $update_date = $this->db->prepare("UPDATE signalytic_data SET last_fetch_date = ? WHERE id = ?"); - $update_date->execute([date("Y-m-d H:i:s"), 1]); - - $this->logger->info("Last fetch updated."); - return true; - }catch(Exception $ex){ - $this->logger->error("Last fetch failed. ", [ 'error_msg'=> $ex->getMessage()]); - return false; - } - } - - function saveToCache($data = null){ - try{ - if(!$data) throw new Exception("No data fetched."); - - $cache_key = "data:". date("d_m_Y_H"); - - $result = $this->redis->setex($cache_key, $this->redis_ttl, $data); - if (!$result) $this->logger->error("cache: $cache_key failed", ["error"=> $result]); - - $this->logger->info("Cached: $cache_key"); - return true; - }catch(Exception $ex){ - $this->logger->error($ex->getMessage()); - return false; - } - } - - function uploadCache(){ - $this->logger->info("Checking cache."); - try{ - $cache_keys = $this->getCacheKeys(); - if(empty($cache_keys)) throw new Exception("Cache is empty. "); - - foreach($cache_keys as $cache_key) - { - $cached_data = $this->redis->get($cache_key); - $this->logger->debug("[key] $cache_key found.", ["key"=>$cache_key, "data"=> $cached_data]); - - $result = $this->uploadData($this->endpoint, $cached_data); - $this->logger->debug("[key] $cache_key uploaded", ["upload"=> $result]); - - if($result) $this->clearCache($cache_key); # clear cache - } - - }catch(Exception $ex){ - $this->logger->warning($ex->getMessage()); - return false; - } - } - - private function getCacheKeys(){ - $keys = []; - $iterator = null; - - do { - //get all keys - $result = $this->redis->scan($iterator, 'data:*'); - - if ($result !== false) $keys = array_merge($keys, $result); - - } while ($iterator > 0); - - return $keys; - } - - function clearCache($cache_key = null){ - if(!$cache_key){ - $this->logger->error("No cache key provided. exiting ..."); - return false; - } - - try{ - $clear = $this->redis->del($cache_key); - - if($clear === 0) throw new Exception("Invalid cache key. [ $cache_key ]"); - - $this->logger->info("Cache cleared", ["key"=> $cache_key, "result"=> $clear ]); - - return true; - }catch(Exception $ex){ - $this->logger->error($ex->getMessage()); - return false; - } - } - - function resetCache(){ - try{ - $this->logger->warning("Flushing cache"); - $clear = $this->redis->flushDB(); - - if(!$clear) throw new Exception("Clearing cache failed. ($clear) "); - - $this->logger->info("Cache cleared", ["result"=> $clear]); - - return true; - }catch(Exception $ex){ - $this->logger->error($ex->getMessage()); - return false; - } - } -} - -$sync = new Sync(); -$sync->startSync(); diff --git a/hosted-app-utils b/hosted-app-utils index 3785af30..6af4c4ae 160000 --- a/hosted-app-utils +++ b/hosted-app-utils @@ -1 +1 @@ -Subproject commit 3785af3094b2b92f6daceb670e7bbb7a5d83d369 +Subproject commit 6af4c4ae8520e499c53a6bd80567454061e89103 diff --git a/src/docker-compose.yml b/src/docker-compose.yml index f8996487..1df897a6 100755 --- a/src/docker-compose.yml +++ b/src/docker-compose.yml @@ -1,7 +1,7 @@ services: streamline-emr: - image: ${APP_IMAGE:-streamline-emr:latest} - container_name: ${APP_CONTAINER:-streamline-emr} + image: registry.gitlab.com/signalytic/client-external/streamline/streamline-emr/streamline-emr/arm64:2.3 + container_name: streamline-emr restart: unless-stopped volumes: - "${DATA_DIR:-./data}:/var/lib/mysql" @@ -20,8 +20,8 @@ services: - streamline statistics: - image: ${STATISTICS_IMAGE:-streamline-emr-statistics:latest} - container_name: ${STATISTICS_CONTAINER:-streamline-emr-statistics} + image: registry.gitlab.com/signalytic/client-external/streamline/streamline-emr/statistics/arm64:2.3 + container_name: streamline-emr-statistics restart: unless-stopped volumes: - "${STATISTICS_ENV:-./resources/statistics.env}:/app/statistics.env" @@ -33,8 +33,8 @@ services: - streamline redis: - image: ${REDIS_IMAGE:-streamline-emr-redis:latest} - container_name: ${REDIS_CONTAINER:-streamline-emr-redis} + image: registry.gitlab.com/signalytic/client-external/streamline/streamline-emr/redis/arm64:2.3 + container_name: streamline-emr-redis restart: unless-stopped ports: - "${REDIS_PORT:-6379}:6379"