GNU Health/Installation
Contents
- 1 Requirements
- 2 Installing GNU Health on GNU/Linux and FreeBSD
- 3 Booting up the Tryton Server
- 4 Creating a Systemd service for the GNU Health server
- 5 Installation of the GNU Health Client
- 6 Initializing the GNU Health database
- 7 Logging into the Application
- 8 Installing the Default Modules
- 9 Creating a Company
- 10 Disabling demo users in Production environments
- 11 Customizing the GNU Health Client
Requirements[edit]
The latest stable GNU Health has the following requirements:
- Operating System: Supported on most Free/Libre OS (such as GNU/Linux or FreeBSD) for the server.
- Database: PostgreSQL
- Python: >= 3.4 ( Recommended >= 3.6 )
- Tryton: = 4.2
- BASH Shell
- PIP version for Python 3, verify through:
pip --version
You should see the python3 part, as in:
pip x.x.x from /usr/local/lib/python3.6/site-packages (python 3.6)
If you see python2.x then stop and get the pip for python 3.
Installing GNU Health on GNU/Linux and FreeBSD[edit]
Operating System requirements[edit]
The following table contains the instructions to setup your operating system for a standard GNU Health installation. The operating systems and their version shown in the list have been tested using the instructions for each OS.
The installation instructions for the different Operating Systems and distributions have been done on fresh installation. When possible and for simplicity sake, only the server environment was installed, without desktop. No firewall was configured (we will cover this on the security section), and the SSH server was installed.
The instructions - written here - have been applied and verified with the following OS as shown below.
|
|
Please verify that you are using the Operating System version documented on the following table |
| Operating System | Version | Link | Notes |
|---|---|---|---|
| Arch Linux | 2017.07.01 | Arch Linux setup | |
| Debian | 9 | Debian setup | |
| FreeBSD | 11.1 | FreeBSD setup | |
| OpenSUSE | Leap / Tumbleweed | OpenSUSE setup | |
| Ubuntu | 16.04 LTS | Ubuntu setup |
Setting up Network Time Protocol (NTP)[edit]
In order to properly run GNU Health, you need to make sure that the time in both the server (database and central instance) and the clients are properly set and in sync . The best way to do this is to keep your clock synchronized with a NTP Server .
This is a critical step, not only for the smooth functioning of GNU Health, but also because many documents will have a timestamp associated that can have legal value.
Creating the Operating System User[edit]
|
|
Do this step only if you did NOT create the user during the installation of the operating system. |
The following steps will create the GNU Health operating system user. Please note that many operating systems give you the option to create a regular user at installation time. If you already created the "gnuhealth" operating system user, you can skip this section, otherwise, create it now.
Run the following command as root:
adduser gnuhealth
Note: If your Operating System does NOT include the adduser command, you can use the useradd command
useradd -m gnuhealth
Verify PostgreSQL authentication method[edit]
Note : You can skip this section if you made a standard installation on FreeBSD or Arch Linux
PostgreSQL uses different authentication methods (MD5, ident, trust ... ). Depending the Operating System, the postgreSQL server authentication method will vary.
The standard GNU Health installation uses the trust authentication method, so you need to check the postgreSQL authentication file configuration.
Locate the pg_hba.conf file and verify that the trust method is set. The location of this configuration file varies across operating systems; under UNIX/Linux, the full pathname of the file can be obtained with the following command, to be executed as root:
su - postgres -c "psql -t -P format=unaligned -c 'show hba_file'"
You may need to start the postgres server at least one time as this file may be created during first startup. Usually this file is located at
/etc/postgresql/9.x/main
or
/var/lib/pgsql/data
An example configuration file entry specifying use of the trust method is given in the following line:
local all all trust
The following example in particular may address issues with establishing a working database connection as reported in the context of the creation of the GNU Health database upon first use of the Tryton client (see further down; Symptom: the "Create" button is not displayed):
host all all 127.0.0.1/32 trust
Make sure you edit the file as user 'postgres', otherwise - as root - postgres may have trouble reading the changed file. After any changes to the file, the postgreSQL server needs to be restarted.
Many authentication errors (e.g., database connection errors) arise because of not having correctly configured this file. Of course, you can use other authentication methods, and you can adapt the tryton / GNU Health configuration file to each of them. For the sake of simplicity, we based the documentation and sample files on this book on one (trust) specific method.
Make sure you restart your postgresql server: sudo service postgresql restart
Creating the Database User[edit]
The following command switches to the postgres administration user and gives permissions to your newly created gnuhealth administrator:
Execute, as root:
su - postgres -c "createuser --createdb --no-createrole --no-superuser gnuhealth"
Downloading and Installing GNU Health[edit]
|
|
Do the following steps with your newly created gnuhealth user, DO NOT use root. |
Running the GNU Health Installer[edit]
Become user gnuhealth:
su - gnuhealth
cd $HOME
Download GNU Health from GNU.org[edit]
wget https://ftp.gnu.org/gnu/health/gnuhealth-latest.tar.gz
For version >= 3.0 < 3.2, download the following to get the latest gnuhealth-setup installation program
wget https://ftp.gnu.org/gnu/health/gnuhealth-setup-latest.tar.gz
Verify the package signature[edit]
First get the signing key if you haven't done so:
gpg --recv-key 0xC015E1AE00989199
The key is issued by Luis Falcon (meanmicio at GNU) <falcon@gnu.org> and its fingerprint is ACBF C80F C891 631C 68AA 8DC8 C015 E1AE 0098 9199. This information can be seen issuing:
gpg --with-fingerprint --list-keys 0xC015E1AE00989199
Then, verify the signature, using the matching version number for the latest. For instance, if latest GNU Health version is 3.2.9, then
Download the detached signature:
wget ftp://ftp.gnu.org/gnu/health/gnuhealth-3.2.9.tar.gz.sig
Verify the package using the detached signature :
gpg --verify gnuhealth-3.2.9.tar.gz.sig gnuhealth-latest.tar.gz
If the file is correctly validated, the output should be something like:
gpg: Signature made Sat 01 Jul 2017 11:06:25 PM WEST gpg: using RSA key ACBFC80FC891631C68AA8DC8C015E1AE00989199 gpg: Good signature from "Luis Falcon (GNU) <falcon@gnu.org>" [ultimate] gpg: aka "Luis Falcon (GNU Health) <lfalcon@gnusolidario.org>" [ultimate]
The important part is the Good signature from "Luis Falcon ....". The WARNING means that, even if the file and signature are OK and validated correctly, you aren't trusting that key; and it's OK. You can read more about this in The GNU Privacy Handbook, Chapter 3. Key Management.
Uncompress the file:
tar xzf gnuhealth-latest.tar.gz
Change to the GNU Health installation directory matching your version :
cd gnuhealth-3.2.1
Run the gnuhealth_setup installation program
./gnuhealth-setup install
Finally, enable the BASH environment for the gnuhealth user.
source "$HOME"/.gnuhealthrc
Activate Network Devices for the JSON-RPC Protocol[edit]
The Tryton GNU Health server listens to localhost at port 8000, not allowing direct connections from other workstations.
editconf
You can edit the parameter listen in the [web] section , to activate the network device so workstations in your net can connect. For example, the following block
[web] listen = *:8000
will allow to connect to the server in the different devices of your system.
Setting up a Local Directory for Attachments[edit]
By default, Tryton uses a system-wide directory to store the attachments. In GNU Health is advisable to keep the attachments in the gnuhealth user space.
Edit the server configuration file trytond.conf and enter the attach directory under the [database] section, for instance:
editconf
[database] path = /home/gnuhealth/attach
Configuring the Log File (optional)[edit]
Since GNU Health 2.8, the way the server logs and tracks events is based on a log configuration file, that resides in the config directory "${GNUHEALTH_DIR}"/tryton/server/config/.
A default version is shipped, called gnuhealth_log.conf.
It looks something like this:
[formatters]
keys: simple
[handlers]
keys: rotate, console
[loggers]
keys: root
[formatter_simple]
format: [%(asctime)s] %(levelname)s:%(name)s:%(message)s
datefmt: %a %b %d %H:%M:%S %Y
[handler_rotate]
class: handlers.TimedRotatingFileHandler
args: ('/home/gnuhealth/gnuhealth/logs/gnuhealth.log', 'D', 1, 30)
formatter: simple
[handler_console]
class: StreamHandler
formatter: simple
args: (sys.stdout,)
[logger_root]
level: WARNING
handlers: rotate, console
In this example (and in the standard file) the log file is written in the default logs directory. You can change it to fit your specific installation.
In order to use logging, you need to provide the --logconf option, along with the path to the log configuration file gnuhealth_log.conf as argument, when invoking the Tryton server, in the next section (e.g., trytond --logconf "${GNUHEALTH_DIR}"/tryton/server/config/gnuhealth_log.conf ...).
For more information, check the following resources:
- Python logging facility logging tutorial: https://docs.python.org/2/howto/logging.html#logging-basic-tutorial
- Tryton Server logging documentation: http://trytond.readthedocs.org/en/latest/topics/logs.html
Booting up the Tryton Server[edit]
Change to your newly installed system (use the alias cdexe )
cdexe
and boot the server.
nohup ./trytond &
This command executes the GNU Health server in the background. You can check the output on the file nohup.out
| Helpful Hint! | |
|---|---|
| use the --logconf option to write the log file |
If you use the --verbose argument, it will print more events, including starting and stopping the server
You should see something like this. Pay attention at the last line INFO:server:starting JSON-RPC protocol on *:8000
Note : the "--verbose" argument is optional. It is used in this case so you can see the main configuration parameters.
[Wed Jan 14 11:01:20 2015] INFO:server:using /home/gnuhealth/gnuhealth/tryton/server/config/log.conf as logging configuration file [Wed Jan 14 11:01:20 2015] INFO:trytond.server:using /home/gnuhealth/gnuhealth/tryton/server/config/trytond.conf as configuration file [Wed Jan 14 11:01:20 2015] INFO:trytond.server:initialising distributed objects services [Wed Jan 14 11:01:20 2015] INFO:trytond.server:starting JSON-RPC protocol on *:8000
You may see a UserWarning : warnings.warn("Unable to load plugin '%s'" % name). Try installing the following package.
pip install relatorio.templates.chart
Creating a Systemd service for the GNU Health server[edit]
If you use the standard installation method, you can use the following scripts to automate the startup / stop of the GNU Health instance using systemd services.
GNU Health startup script[edit]
Create the GNU Health startup script under /home/gnuhealth/start_gnuhealth.sh and make the file executable.
#!/bin/bash
source $HOME/.gnuhealthrc
cd ${GNUHEALTH_DIR}/tryton/server/${TRYTOND}/bin
python3 ./trytond
GNU Health service unit file[edit]
Create the GNU Health Unit file under /usr/lib/systemd/system/gnuhealth.service
[Unit]
Description=GNU Health Server
After=network.target
[Service]
Type=simple
User=gnuhealth
WorkingDirectory=/home/gnuhealth
ExecStart=/home/gnuhealth/start_gnuhealth.sh
Restart=on-abort
[Install]
WantedBy=multi-user.target
Starting and Stopping the GNU Health service[edit]
You can issue the commands
systemctl start gnuhealth
or
systemctl stop gnuhealth
Enable the service to start at boot time[edit]
If you want to automatically start the GNU Health server whenever you start the operating system, you can enable the service with the following command
systemctl enable gnuhealth
Installation of the GNU Health Client[edit]
Since GNU Health 3.2, there is a native GNU Health GTK client, that
Installation from Source (GNU/Linux, FreeBSD and other *NIX)[edit]
1) Download the latest GNU Health client from GNU.org
https://ftp.gnu.org/gnu/health/gnuhealth-client-latest.tar.gz
2) Install python dependencies :
pip2 install --user python-dateutil
3) Untar the client tarball:
tar -xzvf gnuhealth-client-latest.tar.gz
4) Launch the client
cd gnuhealth-client-3.2.5/bin
./gnuhealth-client
Using PIP[edit]
Alternatively, you can install the GNU Health client from the Python Package Index (pypi)
Following are the instructions on how to install the client system-wide (without the --user option).
pip install gnuhealth-client
If you have an older GNU Health client (installed with PIP), you can upgrade it to the latest version with the following command:'
pip install --upgrade gnuhealth-client
The following command will boot your GNU Health client
gnuhealth-client
Alternative Method (System Packages)[edit]
Instead from source as described above, you can install the GNU Health Client from pre-build packages as well. Debian and openSUSE offer packages that you can install with your systems package manager.
Microsoft Windows and Mac[edit]
|
|
You should always use Free/Libre Software in GNU Health. We highly recommend you use GNU/Linux or other Libre Operating System for the client. The development of all GNU Health components (Server, client, plugins, Thalamus, GNU Health Federation, ... ) is done and focused on Free Operating Systems. |
If you use MS Windows or Mac, currently you could use the Tryton 4.2 client, which is compatible with GNU Health 3.2 (except the plugins like GNU Health GNUPG crypto or GNU Health Camera)
Download the Tryton client [1].
Follow the instructions.
Initializing the GNU Health database[edit]
The first step is to create a database that will hold all the information for your GNU Health system.
The GNU Health HMIS information is stored in a PostgreSQL database, and processed by the Tryton kernel.
You create the database at operating system level, with the gnuhealth user. For example, if you want to initialize a database with the name "health320", you will issue the following commands:
createdb health320 --encoding=unicode --locale=C --template=template0
cdexe
./trytond-admin --all --database=health320
if the command above does not work, try this:
cd ~/gnuhealth/tryton/server # (where "pwd" shows "/home/gnuhealth/gnuhealth/tryton/server")
python3 trytond-4.2.5/bin/trytond-admin -c config/trytond.conf -d health320 --all -v -p
-c congfig
-d database_name
-all update all the modules
-p ask password for admin in an interactive way
-v show the server log
Check in the server log (or console) if any error occurs. If so, try to fix the problem (ie. any Python module missing or some unmet dependencies), drop the database just created and repeat the procedure.
After the database is created, click OK. You're now ready to log in!
Logging into the Application[edit]
Now that you're back at the login screen, you'll notice that the selected profile is the one you've just created. Fill in the login form:
- User name: the one you used previously usually, admin
- Password: the one entered twice in the previous section
Installing the Default Modules[edit]
From this point on, you will use the client for almost every process. Start with the installation of the basic functionality:
- After you've created the database, the system will ask you to create some new users. You can skip this step for now.
- You are then presented with a list of modules that will provide the functionality you desire. If you don't see the Modules window, navigate to it on the left side: Administration → Modules → Modules.
- Select the health_profile module, and click on Mark for installation:
- Click on the Action icon (a blue rotated square) and select Perform Pending Installation/Upgrade:
- Tryton will automatically select all the dependent modules required for the installation:
- Click on Start Upgrade. This process will take a while, depending on the computer where GNU Health is being installed on. Once it's done, the following message appears:
Creating a Company[edit]
The next thing you need to do is to create the initial company, that will be your health center. You will be presented with a wizard to create it.
Press F3 to create the new company.
Note: At the party form, please make sure you set the institution attribute . You will link this company to your main health institution later on. Please refer to the screenshot provided in this section for details.
Disabling demo users in Production environments[edit]
|
|
For security reasons, deactivate demo users in production environments |
GNU Health comes with a set of pre-defined users for demo purposes. They all have the suffix "demo_" ( demo_doctor, demo_front_desk, demo_nurse... ).
Please deactivate them in production environments.
To deactivate the users, follow the following path : Administration -> Users -> Users
In filters, you can choose : login name : demo_
Unset the "active" flag of each of them. The demo users are now de-activated in your environment.
Look at the provided screenshot for further details.
Congratulations! You have completed the initial installation of GNU Health. In the next chapter we will discuss how to add functionality by installing additional modules.
Customizing the GNU Health Client[edit]
For GNU/Linux and other Free operating systems, the GNU Health GTK client configuration file is
$HOME/.config/gnuhealth/<version>/gnuhealth-client.conf
For example
$HOME/.config/gnuhealth/3.2/gnuhealth-client.conf
Using a custom greeter / banner[edit]
You can customize the login greeter banner to fit your institution.
In the section [client] include the banner parameter with the absolute path of the png file.
Something like
[client]
banner = /home/yourlogin/myhospitalbanner.png
The default resolution of the banner is 500 x 128 pixels. Adjust yours to approximately this size.