medal-hub
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
medal-hub [2021/12/15 15:11] – arnaud_poletto | medal-hub [2022/01/14 16:27] (current) – Alan Vonlanthen | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== medAL-hub Documentation ====== | ====== medAL-hub Documentation ====== | ||
- | ==== About medAL-hub | + | The purpose of medAL-//hub// is 3-fold: |
- | + | ||
- | The purpose of medAL-hub is 3-fold: | + | |
- Relay between the tablets, thus allowing to start a consultation on a tablet and finish it on another one (client-server). | - Relay between the tablets, thus allowing to start a consultation on a tablet and finish it on another one (client-server). | ||
- Local database for the clinical data. | - Local database for the clinical data. | ||
- | - Hub for the data synchronisation with the National server (medAL-data) . | + | - Hub for the data synchronisation with the National server (medAL-// |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | ==== medAL-hub Installation ==== | + | |
- | + | ||
- | === Prerequisite === | + | |
- | + | ||
- | Follow the procedure given in [[internet|Internet setup]]. At this point, you should be able to connect to the following Wi-Fi network: \\ | + | |
- | ssid: //health_facility_dynamic// | + | |
- | password: // | + | |
- | If your setup does not allow you to have direct access to the internet using the above network, you should still be able to connect to the following mobile network regularly: \\ | + | |
- | ssid: // | + | |
- | password: // | + | |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | === Material === | + | |
- | + | ||
- | You will need the following material: | + | |
- | * Raspberry PI 4 (For convenience and ease, it will be shortened to RasPi [[https:// | + | |
- | * A MicroSD card [[https:// | + | |
- | * An SD card reader for the PC [[https:// | + | |
- | * An HDMI to micro-HDMI cable (NOT mini) [[https:// | + | |
- | * A PowerBank (5Vx3A (15W) output) [[https:// | + | |
- | * A Power Adapter (USB + Power) [[https:// | + | |
- | * An internet connection (either cable or Wi-Fi) | + | |
- | * A PC connected to internet, with admin rights | + | |
- | * A screen with HDMI connection | + | |
- | * A USB keyboard | + | |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | === SD Card Setup === | + | |
- | + | ||
- | - Download and open BalenaEtcher from: https:// | + | |
- | - Download the HypriotOS image: https:// | + | |
- | - Plug in your SD card inside the SD card reader. | + | |
- | - In BalenaEtcher, | + | |
- | - Click on //Select target// and select your SD card. | + | |
- | - Click on //Flash!//, and wait until the flash is complete. | + | |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | === RasPI Setup === | + | |
- | + | ||
- | - Put the SD card back in the RasPI. | + | |
- | - Connect the RasPI to the following: | + | |
- | * HDMI (0) \\ {{:: | + | |
- | * Ethernet (if present) | + | |
- | * A Keyboard | + | |
- | * A Screen | + | |
- | * The PowerBank | + | |
- | - Wait until you see “login” and a blinking underscore (after about 4 minutes). That means you are ready to start. If no login then repeat steps above. | + | |
- | + | ||
- | === Wi-Fi Setup === | + | |
- | + | ||
- | Enter the credentials (press //Enter// between each and be careful: **the keyboard is UK by default**): \\ | + | |
- | Username: //pirate// \\ | + | |
- | Password: // | + | |
- | + | ||
- | The next step is to create the '' | + | |
- | + | ||
- | < | + | |
- | + | ||
- | If you are configuring the hub for an offline facility, also add the following line: | + | |
- | < | + | |
- | + | ||
- | After that, we have to give a name to each of the network configurations. In order to do that, open ''/ | + | |
- | < | + | |
- | + | ||
- | And add the two '' | + | |
- | < | + | |
- | ssid=”health_facility_dynamic” | + | |
- | # | + | |
- | psk=… | + | |
- | id_str=”hf” | + | |
- | } | + | |
- | network={ | + | |
- | ssid=”mobile_dynamic” | + | |
- | # | + | |
- | psk=… | + | |
- | id_str=”mobile” | + | |
- | } | + | |
- | </ | + | |
- | + | ||
- | Save file using 1. //Ctrl-X// 2. Confirm //Y// 3. Press //Enter// | + | |
- | After that, we have to link the '' | + | |
- | < | + | |
- | + | ||
- | And edit the file to make it exactly as below: | + | |
- | < | + | |
- | #source / | + | |
- | + | ||
- | allow-hotplug wlan0 | + | |
- | iface wlan0 inet manual | + | |
- | wpa-roam / | + | |
- | + | ||
- | iface hf inet dhcp | + | |
- | iface mobile inet dhcp | + | |
- | </ | + | |
- | + | ||
- | Save file using 1. //Ctrl-X// 2. Confirm //Y// 3. Press //Enter// | + | |
- | + | ||
- | After that, we can activate the wlan0 interface: | + | |
- | < | + | |
- | + | ||
- | Make sure to save the changes and reboot: | + | |
- | < | + | |
- | + | ||
- | The device should now be connected to the internet. | + | |
- | < | + | |
- | + | ||
- | in order to verify this. (//Ctrl-C// to exit '' | + | |
- | Now that the connection is established, | + | |
- | < | + | |
- | + | ||
- | and take note of the following values (under wlan0 interface) | + | |
- | * inet | + | |
- | * netmask | + | |
- | * broadcast | + | |
- | These values will be useful later. Run: | + | |
- | < | + | |
- | + | ||
- | And take note of the nameserver address (the first address that appears). | + | |
- | Run: | + | |
- | < | + | |
- | + | ||
- | Make the necessary changes (under hf interface): | + | |
- | < | + | |
- | + | ||
- | allow-hotplug wlan0 | + | |
- | iface wlan0 inet manual | + | |
- | wpa-roam / | + | |
- | + | ||
- | iface hf inet static | + | |
- | address 178.17.54.136 | + | |
- | netmask 255.255.255.0 | + | |
- | network 178.17.54.0 | + | |
- | broadcast 178.17.54.255 | + | |
- | gateway 178.17.54.1 | + | |
- | dns-nameservers 178.17.54.1 | + | |
- | iface mobile inet dhcp | + | |
- | </ | + | |
- | + | ||
- | Replace the relevant values with the ones from the previous step. The '' | + | |
- | + | ||
- | Make sure to save the changes and reboot: | + | |
- | < | + | |
- | + | ||
- | The connection should now be established (again). | + | |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | === Application Setup === | + | |
- | + | ||
- | Clone the repository and checkout the '' | + | |
- | < | + | |
- | cd liwi-local-data | + | |
- | git checkout master | + | |
- | </ | + | |
- | + | ||
- | Create the environment file: | + | |
- | < | + | |
- | nano .env | + | |
- | </ | + | |
- | + | ||
- | And set the health facility ID to the desired value by updating the '' | + | |
- | < | + | |
- | sudo nano .env | + | |
- | </ | + | |
- | Save file using 1. //Ctrl-X// 2. Confirm //Y// 3. Press //Enter// | + | |
- | + | ||
- | Install //nginx//, //php// and other requirements: | + | |
- | < | + | |
- | sudo apt update | + | |
- | sudo apt upgrade | + | |
- | sudo apt install nginx php composer php-zip php-xml php-fpm php-pgsql | + | |
- | </ | + | |
- | + | ||
- | Restart: | + | |
- | < | + | |
- | + | ||
- | Start the docker container, install pendencies and prepare the database: | + | |
- | < | + | |
- | composer install | + | |
- | php artisan key: | + | |
- | php artisan migrate | + | |
- | </ | + | |
- | + | ||
- | Open the nginx configuration file: | + | |
- | < | + | |
- | + | ||
- | And insert the following server block (right after the //# Virtual Host Configs//): \\ | + | |
- | The two ''# | + | |
- | < | + | |
- | #include / | + | |
- | #include / | + | |
- | server { | + | |
- | listen 80; | + | |
- | listen 443 ssl; | + | |
- | ssl_certificate / | + | |
- | ssl_certificate_key / | + | |
- | # | + | |
- | root / | + | |
- | add_header X-Frame-Options " | + | |
- | add_header X-Content-Type-Options " | + | |
- | index index.php; | + | |
- | charset utf-8; | + | |
- | location / { | + | |
- | try_files $uri $uri/ / | + | |
- | } | + | |
- | location = / | + | |
- | location = / | + | |
- | error_page 404 / | + | |
- | client_max_body_size 0; | + | |
- | location ~ \.php$ { | + | |
- | fastcgi_pass unix:/ | + | |
- | fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; | + | |
- | include fastcgi_params; | + | |
- | } | + | |
- | location ~ / | + | |
- | deny all; | + | |
- | } | + | |
- | } | + | |
- | </ | + | |
- | + | ||
- | We can verify that the nginx configuration is valid using the following command: | + | |
- | < | + | |
- | + | ||
- | After that, we have to change the permissions of the project folder so that each component of the application (the web server and the database) can access the required files: | + | |
- | < | + | |
- | sudo chown -R root:root / | + | |
- | sudo usermod -a -G www-data pirate | + | |
- | </ | + | |
- | + | ||
- | Restart the docker container: | + | |
- | < | + | |
- | docker-compose up -d | + | |
- | </ | + | |
- | + | ||
- | Restart nginx: | + | |
- | < | + | |
- | + | ||
- | Go to [[http://< | + | |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | ==== medAL-hub Maintenance Setup ==== | + | |
- | + | ||
- | === Update Script === | + | |
- | + | ||
- | We are now going to create a script to update the application from the git repository: | + | |
- | < | + | |
- | touch ~/ | + | |
- | chmod +x ~/ | + | |
- | nano ~/ | + | |
- | </ | + | |
- | + | ||
- | The content of the script should look like this: | + | |
- | < | + | |
- | #!/bin/sh | + | |
- | cd / | + | |
- | docker-compose down | + | |
- | git pull | + | |
- | docker-compose up -d | + | |
- | composer install | + | |
- | php artisan key: | + | |
- | php artisan migrate | + | |
- | </ | + | |
- | === Crontab Setup === | ||
- | We need to configure cron jobs so that Laravel can run synchronization jobs and that the update script gets executed everyday. | + | ===== medAL-hub Setup and Management ===== |
- | Open crontab: | + | |
- | < | + | |
- | And add the following jobs: | + | * [[medal-hub:setup|medAL-hub setup]] |
- | < | + | * [[medal-hub:step-ca-setup|medAL-hub self-signed certificates setup]] |
- | * * * * * php / | + | |
- | 30 16 * * * / | + | |
- | </ | + | |
- | The exact time of the update can be adjusted based on the health facility requirements (in this example it is set to update at 16:30 everyday). | ||
+ | ===== medAL-hub User Guide and Troubleshooting ===== | ||
- | === Sync Configuration === | + | * [[medal-hub: |
+ | * [[medal-hub: | ||
- | Open the configuration file for synchronization: | ||
- | < | ||
- | And choose | + | ===== medAL-hub Data Sync Schedule ===== |
+ | There are 2 scripts on the hub for syncing: | ||
+ | - script #1 runs everyday at 4PM and sends all the cases closed but unsynced to the server | ||
+ | - script #2 runs every minute and sends all the cases closed for more than 25 hours that have not yet been sent to the server | ||
+ | * huge caveat :!:: the raspberry pi does not have a physical clock. Meaning, everytime it loses power, it does not know what time it is until it gets the time from the internet | ||
- | * '' | ||
- | * Choose '' | ||
- | * Choose '' | ||
- | * '' | ||
- | * These values are used to reach the main data server. | ||
- | * '' | ||
- | * This value is the number of hours after which the cases are considered out-of-sync (starting from creation time). Synchronization will be triggered as soon as any closed case is out-of-sync and connection is available. The value for online mode should to be much higher than the one for offline mode because a reliable connection is expected to be available in online mode. For this reason, cases in online mode only become out-of-sync when the daily scheduled synchronization cannot take place for some reason. | ||
- | === Synchronization Using a Mobile Hotspot (Offline facilities) === | ||
- | In the case where no connection is available at the health facility, it is possible to perform a synchronization with the help of a mobile phone with a mobile internet connection that can act as a hotspot. The procedure is the following: | ||
- | - Check that the hotspot is already configured with the ssid and the password specified in '' | ||
- | - As soon as the connection is established, | ||
- | - In order to make sure that the transaction completed successfully, | ||
medal-hub.1639577463.txt.gz · Last modified: 2021/12/15 15:11 by arnaud_poletto