AFG-Polio-Data / APMIS-Project

APMIS (Afghanistan Polio Management Information System) is an supplemental Immunization Activities management system to manage the vaccination activities in the country.
https://test.afghanistan-apmis.com
GNU General Public License v3.0
4 stars 8 forks source link

Provide for server-side integration of R Shiny support for advanced visualizations (e.g., temporal campaign-level data) #32

Closed apmis-org closed 1 year ago

apmis-org commented 3 years ago

Situation Description

apmis-stats-shinyapp apmis-stats-shinyapp is a web app based on R Shiny framework. It contains modules to analyze data generated by APMIS or any other electronic tool used for SIAs

Feature Description

Based on https://github.com/hzi-braunschweig/SORMAS-Stats-next-gen/blob/development/sormas-stats-shinyapp/sormas-stats-app/Documentation/documents_en.md

Possible Alternatives

Download documents needed from https://github.com/hzi-braunschweig/SORMAS-Stats-next-gen/tree/development/sormas-stats-shinyapp/sormas-stats-app

Demo apps [Connect to demo SORMAS-Stats app version] (https://sormas.helmholtz-hzi.de/sormas-stats-shinyapp/) Username: stats Password: aeJahpho3shi [Connect to demo SORMAS app version] (https://release-international.sormas.netzlink.com/sormas-ui/) Username: stats Password: rHbaN8y3BMAG

Additional Information

SORMAS-Stats-next-gen

SORMAS-Stats contain functions to analyze and visualize surveillance data collected by SORMAS.

Run docker container

Prerequisites

(1) You should begin this tutorial after installing and configuring the SORMAS app on your system, and create some data in the database. Information on how to install SORMAS can be found on the SORMAS-Docker repository https://github.com/hzi-braunschweig/SORMAS-Docker.

(2) You need to install a container engine (e.g. Docker)

Run container

(3) Pull the latests version from hub.docker.com

docker pull hzibraunschweig/sormas-stats:latest

If you like to pull an image built from development branch, you need to pull the tag 'developemnt'.

(4) Run the image

docker run -p 0.0.0.0:3838:3838 hzibraunschweig/sormas-stats:latest

The app will listen on port 3838. You can map this port to any port on the server.

docker run -p 0.0.0.0:3838:3838 -v /local_path_to_app/shiny-server.conf:/etc/shiny-server/shiny-server.conf hzibraunschweig/sormas-stats:latest

If you like to provide a custom shiny-server.conf you can map this as a volume. For example shiny-server.conf:

 # Instruct Shiny Server to run applications as the user "shiny"
run_as shiny;

# Define a server that listens on port 3838
server {
  listen 3838 0.0.0.0;

  # Define a location at the base URL
  location / {

    # Host the directory of Shiny Apps stored in this directory
    site_dir /srv/shiny-server;

    # Log all Shiny output to files in this directory
    log_dir /var/log/shiny-server;

    # When a user visits the base URL rather than a particular application,
    # an index of the applications available in this directory will be shown.
    directory_index on;
  }
}

Please refer to the documentation of R shiny https://docs.rstudio.com/shiny-server/#default-configuration

Environment parameters

After starting the container, the application tries to connect to a SORMAS database. The container uses these environment parameters for configuration:

Parameter default accepted values
SHINY_LOG_STDERR 0 or 1 to log output of the app to stderr (needed to display via docker-logs)
DB_USER "sormas_user" username for sormas databse
DB_PASS "password" password of database user
DB_HOST 127.0.0.1 IP-Adress of SORMAS database to connect to
DB_PORT 5432 SORMAS database port
DB_NAME "sormas" name of sormas database

Docker compose

You can use a docker-compose file to start the application:

version: "3"
services: 
  sormas-stats:
    ports: 
      - "0.0.0.0:3838:3838"
    image: hzibraunschweig/sormas-stats:latest      
    environment: 
      - SHINY_LOG_STDERR=1
      - DB_USER="sormas_user"
      - DB_PASS="{{ sormas.postgres.password }}"
      - DB_HOST="{{ ansible_default_ipv4.address }}"
      - DB_PORT="5432"
      - DB_NAME="sormas"
    volumes: 
      - /path_to_shiny_app/shiny-server.conf:/etc/shiny-server/shiny-server.conf
    restart: always

Run locally

(1) Set the R PATH to where the example-app.Rproj is saved on your sytem. You can also double click on example-app.Rproj to launch R and this would automatically set the PATH.

setwd("SORMAS-Stats/shinyapp")

(2) Run app using the command shiny::runApp()

bnygren commented 1 year ago

@xlg8 This issue is the oldest, almost 2 years old with no comments and no developer or project manager assigned. Yet, it is classified as 'in development' with an associated milestone of June 2023. Since we now have #419 which is a duplicate, I suggest closing/deleting this issue. FYi @RaziaMahmodi

bnygren commented 1 year ago

dulpicate