Skip to main content

The Thalamus project provides a RESTful API hub to all the GNU Health Federation nodes. The main functions are:

  1. Message server: A concentrator and message relay from and to the participating nodes in the GNU Health Federation and the GNU Health Information System (PgSQL). Some of the participating nodes include the GNU Health HMIS, MyGNUHealth mobile PHR application, laboratories, research institutions and civil offices.

  2. Authentication Server: Thalamus also serves as an authentication and authorization server to interact with the GNUHealth Information System

Thalamus is part of the GNU Health project, but it is a self contained, independent server that can be used in different health related scenarios.

Installation

Thalamus is pip-installable:

$ pip install thalamus

Technology

RESTful API: Thalamus uses a REST (Representional State Transfer) architectural style, powered by Flask technology

Thalamus will perform CRUD (Create, Read, Update, Delete) operations. They will be achived via the following methods upon resources and their instances.

  • GET : Read

  • POST : Create

  • PATCH : Update

  • DELETE : Delete.

The DELETE operations will be minimal.

JSON: The information will be encoded in JSON format.

Resources

Some resources and end-points are:

  • People (/people)

  • Pages of Life (/pols)

  • DomiciliaryUnits (/domiciliary-units)

  • PersonalDocs (/personal_docs)

Running Thalamus from a WSGI Container

In production settings, for performance reasons you should use a HTTP server. We have chosen gunicorn .

For example, you can run the Thalamus application from uWSGI as follows. The default configuration file uses secure (SSL) connections:

$ gunicorn --daemon -c etc/gunicorn.cfg thalamus:app

For development, if you want to run it directly from the Flask Werkzeug server,:

$ python3 ./thalamus.py

Examples

Command-line, using httpie

Retrieve the demographic information of person:

$ http --verify no --auth ARGBUE111FAV:freedom https://federation.gnuhealth.org:8443/people/ESPGNU777ORG

Yields to:

HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Connection: close
Content-Length: 547
Content-Type: application/json
Date: Thu, 30 Jul 2020 12:01:37 GMT
Server: gunicorn/20.0.0

{
    "_id": "ESPGNU777ORG",
    "active": true,
    "dob": "1990-10-04",
    "education": "tertiary",
    "ethnicity": "latino",
    "gender": "f",
    "id": "ESPGNU777ORG",
    "lastname": "Betz",
    "marital_status": "married",
    "modification_info": {
        "node": "SPAIN-LASPALMAS-GNUSOLIDARIO-GRAL_HOSPITAL",
        "timestamp": "2018-11-06 19:24:43.662846",
        "user": "ITAPYT999HON"
    },
    "name": "Ana",
    "password": "$2b$12$cjrKVGYEKUwCmVDCtEnwcegcrmECTmeBz526AAD/ZqMGPWFpHJ4FW",
    "profession": "teacher",
    "roles": [
        "end_user"
    ]
}

Retrieve the demographics information globally:

$ http --verify no --auth ARGBUE111FAV:freedom https://federation.gnuhealth.org:8443/people

Yields to:

HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Connection: close
Content-Length: 2715
Content-Type: application/json
Date: Mon, 20 Jul 2020 18:03:24 GMT
Server: gunicorn/20.0.0

[
[
    {
        "active": true,
        "dob": "1984-10-05",
        "education": "tertiary",
        "ethnicity": "latino",
        "gender": "f",
        "id": "ITAPYT999HON",
        "lastname": "Cordara",
        "marital_status": "married",
        "name": "Cameron",
        "password": "$2b$12$Y9rX7PoTHRXhTO1H78Tan.8mVmyayGAUIveiYxu2Qeo0ZDRvJQ8/2",
        "profession": "teacher",
        "roles": [
            "end_user",
            "health_professional"
        ]
    }
],
[
    {
        "creation_info": {
            "node": "SPAIN-LASPALMAS-GNUSOLIDARIO-GRAL_HOSPITAL",
            "timestamp": "2019-11-20 10:39:21.162731",
            "user": "ITAPYT999HON"
        },
        "dob": "1999-10-12",
        "gender": "m",
        "id": "DEUMOP095IDI",
        "lastname": "Dillinger",
        "name": "John Doe",
        "roles": [
            "end_user"
        ]
    }
],


[
    {
        "active": true,
        "dob": "2008-10-12",
        "education": "tertiary",
        "ethnicity": "latino",
        "gender": "f",
        "id": "ARGBUE111FAV",
        "lastname": "Root",
        "marital_status": "married",
        "name": "Admin",
        "password": "$2b$12$McKDNgArdHKbUssD1fj64ecpdbJGMIt29ns7DGvqzqIT26W0dtJzi",
        "profession": "System Administrator",
        "roles": [
            "root"
        ]
    }
],
[
    {
        "_id": "ESPGNU777ORG",
        "active": true,
        "dob": "1990-10-04",
        "education": "tertiary",
        "ethnicity": "latino",
        "gender": "f",
        "id": "ESPGNU777ORG",
        "lastname": "Betz",
        "marital_status": "married",
        "modification_info": {
            "node": "SPAIN-LASPALMAS-GNUSOLIDARIO-GRAL_HOSPITAL",
            "timestamp": "2018-11-06 19:24:43.662846",
            "user": "ITAPYT999HON"
        },
        "name": "Ana",
        "password": "$2b$12$cjrKVGYEKUwCmVDCtEnwcegcrmECTmeBz526AAD/ZqMGPWFpHJ4FW",
        "profession": "teacher",
        "roles": [
            "end_user"
        ]
    }
],
]

Using Python requests:

>>> import requests
>>> person = requests.get('https://localhost:8443/people/ESPGNU777ORG', auth=('ITAPYT999HON', 'gnusolidario'), verify=False)
>>> person.json()
  {'_id': 'ESPGNU777ORG', 'active': True, 'biological_sex': 'female','dob': 'Fri, 04 Oct 1985 13:05:00 GMT',
  'education': 'tertiary', 'ethnicity': 'latino', 'gender': 'female', 'lastname': 'Betz', 'marital_status': 'married',
  'name': 'Ana', 'password': '$2b$12$cjrKVGYEKUwCmVDCtEnwcegcrmECTmeBz526AAD/ZqMGPWFpHJ4FW', 'profession': 'teacher',
  'roles': ['end_user']}

Note on roles The demo user “ITAPYT999HON” is a health professional (health_professional role), so she has global access to demographic information.

The user “ARGBUE111FAV”, password “freedom”. This is the “root” user for the demo database.

Check the roles.cfg file for examples information about roles and ACLs.

Development

Thalamus is part of the GNU Health project.

The development will be done on GNU Savannah, using the Mercurial repository.

Tasks, bugs and mailing lists will be on health-dev@gnu.org , for development.

General questions can be done on health@gnu.org mailing list.

Homepage

https://www.gnuhealth.org

Release Cycle

Thalamus, as other GNU Health components, will follow its own release process.

Documentation

The Thalamus documentation will be at the corresponding chapter in the GNU Health documentation portal:

https://docs.gnuhealth.org

Author:

Luis Falcon <falcon@gnuhealth.org>

Metadata

Release files for thalamus 0.9.18

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for thalamus 0.9.18
File Size Uploaded
thalamus-0.9.18.tar.gz 132.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for thalamus 0.9.18
File Interpreter ABI Platform
thalamus-0.9.18-py3-none-any.whl Python 3 none any Details

Total release size: 266.7 kB

Release files / thalamus-0.9.18.tar.gz

Download URL thalamus-0.9.18.tar.gz
Size 132.3 kB
Tags Source
SHA-256 checksum
How to use checksums
82c458b7478b3265d6815083f2e5f2906b501b69dbf79263a3d89b9401dd6c0b
BLAKE2b-256 checksum
How to use checksums
176503f84de490c797d7e8fed0d63e4b51c48d8495a8aebced53582401cedbc1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.2.1 CPython/3.14.3 Linux/6.12.77_1

Release files / thalamus-0.9.18-py3-none-any.whl

Download URL thalamus-0.9.18-py3-none-any.whl
Size 134.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e8e700c5a7f5cac919081d183162a575aff2b2c0644e0bc77da5c4cddec91b0c
BLAKE2b-256 checksum
How to use checksums
2ae5b9d6da347979a7a79f90307d0a85bb8928faa4704e4771180c93331e9ef5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.2.1 CPython/3.14.3 Linux/6.12.77_1

Release history Release notifications | RSS feed

This release

0.9.18 This release

2 release files

0.9.16

2 release files

0.9.15

2 release files

0.9.14

1 release file

0.9.13

1 release file

0.9.12

1 release file

0.9.11

1 release file

0.9.10

1 release file

0.9.9

1 release file

0.9.8

2 release files

0.9.7

2 release files

0.9.6

1 release file

0.9.5

1 release file

0.9.4

1 release file

0.9.3

1 release file

0.9.2

1 release file

0.9.1

1 release file

0.9.0

1 release file

0.0.9

2 release files

0.0.8

2 release files

0.0.7

1 release file

0.0.6

1 release file

0.0.5

1 release file

0.0.4

1 release file

0.0.3

1 release file

0.0.2

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page