Welcome to MOST Web-Demographics’s documentation!¶
Contents:
Getting started¶
Installation¶
Demographics is a Django application, indipendent from any Django project.
To use Demographics in your project, add it to INSTALLED_APPS in your settings.py file.
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
# ...
# your apps go here
# ...
'demographics',The following **HowTo** makes use of `requests` and `json` module.
The sample blocks of code illustrate how to use them making use of the **[helper shown in this module](http://localhost:8888/notebooks/DemographicsHelper.ipynb)**
)
API Docs¶
REST API reference¶
API Methods¶
Identifier¶
- POST /demographics/identifier/new/¶
Create new identifier.
Query params: data (json) – identifier data: {
‘type’: String or None, ‘domain’: String or None, ‘identifier’: String}
Responseheader Content-Type: application/json :parameter boolean success: True if the identifier is successfully created. False otherwise :parameter str message: a feedback string that would be displayed to the user :parameter str errors: an error string that explains the raised problems :parameter json data: if success is True, it contains the created identifier data in json format
- GET /demographics/identifier/get/¶
Get the information of an identifier
Query params: query_string (str) – the query string to search. Responseheader Content-Type: application/json :parameter boolean success: True if identifiers are successfully found. False otherwise :parameter str message: a feedback string that would be displayed to the user :parameter str errors: an error string that explains the raised problems :parameter json data: if success is True, it contains the found identifiers data in json format
- POST /demographics/identifier/(identifier_id)/edit/¶
Edit the information of an identifier identified by identifier_id
Query params: data (json) – identifier data: {
‘id’: String, ‘type’: String or None, ‘domain’: String or None, ‘identifier’: String}
Responseheader Content-Type: application/json :parameter boolean success: True if identifier is successfully edited. False otherwise :parameter str message: a feedback string that would be displayed to the user :parameter str errors: an error string that explains the raised problems :parameter json data: if success is True, it contains the edited identifier data in json format
City¶
- POST /demographics/city/new/¶
Create new city.
Query params: data (json) – city data: {
‘name’: String, ‘province’: String or None, ‘state’: String, ‘code’: String or None}
Responseheader Content-Type: application/json :parameter boolean success: True if the city is successfully created. False otherwise :parameter str message: a feedback string that would be displayed to the user :parameter str errors: an error string that explains the raised problems :parameter json data: if success is True, it contains the created city data in json format
- GET /demographics/city/get/¶
Get the information of a city
Query params: query_string (str) – the query string to search. Responseheader Content-Type: application/json :parameter boolean success: True if cities are successfully found. False otherwise :parameter str message: a feedback string that would be displayed to the user :parameter str errors: an error string that explains the raised problems :parameter json data: if success is True, it contains the found cities data in json format
- POST /demographics/city/(city_id)/edit/¶
Edit the information of a city identified by city_id
Query params: data (json) – city data: {
‘id’: String, ‘name’: String, ‘province’: String or None, ‘state’: String, ‘code’: String or None}
Responseheader Content-Type: application/json :parameter boolean success: True if city is successfully edited. False otherwise :parameter str message: a feedback string that would be displayed to the user :parameter str errors: an error string that explains the raised problems :parameter json data: if success is True, it contains the edited city data in json format
Patient module¶
- POST /demographics/patient/new/¶
Create new patient.
Query params: data (json) – patient data: {
‘account_number’: String or None, ‘first_name’: String, ‘last_name’: String, ‘other_ids’: Array of Int or None, ‘gender’: ‘M’ | ‘F’, ‘birth_date’: Date, ‘birth_place’: Int, ‘address’: String or None, ‘city’: Int or None, ‘phone’: String or None, ‘mobile’: String or None, ‘email’: String or None, ‘certified_email’: String or None, ‘active’: True | False}
Responseheader Content-Type: application/json :parameter boolean success: True if the patient is successfully created. False otherwise :parameter str message: a feedback string that would be displayed to the user :parameter str errors: an error string that explains the raised problems :parameter json data: if success is True, it contains the created patient data in json format
- GET /demographics/patient/get/¶
Get the information of a patient
Query params: query_string (str) – the query string to search. Responseheader Content-Type: application/json :parameter boolean success: True if patients are successfully found. False otherwise :parameter str message: a feedback string that would be displayed to the user :parameter str errors: an error string that explains the raised problems :parameter json data: if success is True, it contains the found patients data in json format
- POST /demographics/patient/(patient_id)/edit/¶
Edit the information of a patient identified by patient_id
Query params: data (json) – patient data: {
‘id’: String, ‘account_number’: String or None, ‘first_name’: String, ‘last_name’: String, ‘other_ids’: Array of Int or None, ‘gender’: ‘M’ | ‘F’, ‘birth_date’: Date, ‘birth_place’: Int, ‘address’: String or None, ‘city’: Int or None, ‘phone’: String or None, ‘mobile’: String or None, ‘email’: String or None, ‘certified_email’: String or None, ‘active’: True | False}
Responseheader Content-Type: application/json :parameter boolean success: True if patient is successfully edited. False otherwise :parameter str message: a feedback string that would be displayed to the user :parameter str errors: an error string that explains the raised problems :parameter json data: if success is True, it contains the edited patient data in json format
- POST /demographics/patient/(patient_id)/deactivate/¶
Deactivate a patient identified by patient_id
Responseheader Content-Type: application/json :parameter boolean success: True if patient is successfully deactivated. False otherwise :parameter str message: a feedback string that would be displayed to the user :parameter str errors: an error string that explains the raised problems :parameter json data: if success is True, it contains the deactivated patient data in json format
- POST /demographics/patient/(patient_id)/activate/¶
Activate a patient identified by patient_id
Responseheader Content-Type: application/json :parameter boolean success: True if patient is successfully activated. False otherwise :parameter str message: a feedback string that would be displayed to the user :parameter str errors: an error string that explains the raised problems :parameter json data: if success is True, it contains the activated patient data in json format
Examples¶
REST APIs¶
The following HowTo makes use of requests and json module.
The sample blocks of code illustrate how to use them making use of the `helper shown in this module <http://localhost:8888/notebooks/DemographicsHelper.ipynb>`__.
Identifier module¶
Identifier module provides the following web API:
- /demographics/identifier/new/
- /demographics/identifier/get/
- /demographics/identifier/edit/
# -*- coding: utf-8 -*-
from helper import *
HOST_ADDRESS = 'http://127.0.0.1:8000'
IDENTIFIER_DATA = {
'type': 'business',
'domain': 'hospital_1',
'identifier': '0123456789'
}
identifier = compose_post_request(HOST_ADDRESS, '/demographics/identifier/new/', IDENTIFIER_DATA)
print_response_data('identifier', identifier)
# -*- coding: utf-8 -*-
from helper import *
HOST_ADDRESS = 'http://127.0.0.1:8000'
identifier = compose_get_request(HOST_ADDRESS, '/demographics/identifier/get/', '01234')
print_response_data('identifier', identifier)
# -*- coding: utf-8 -*-
from helper import *
HOST_ADDRESS = 'http://127.0.0.1:8000'
IDENTIFIER_DATA = {
'type': 'business',
'domain': 'hospital_X',
'identifier': 'ZZZZZZZZZZ'
}
identifier = compose_get_request(HOST_ADDRESS, '/demographics/identifier/get/', '01234')
print_response_data('identifier', identifier)
identifier_id = identifier['data'][0]['id']
edited_identifier = compose_post_request(HOST_ADDRESS, '/demographics/identifier/%s/edit/' % identifier_id, IDENTIFIER_DATA)
print_response_data('identifier', edited_identifier)
City module¶
City module provides the following web API:
- /demographics/city/new/
- /demographics/city/get/
- /demographics/city/edit/
# -*- coding: utf-8 -*-
from helper import *
HOST_ADDRESS = 'http://127.0.0.1:8000'
CITY_DATA = {
'name': 'Milano',
'province': 'MI',
'state': 'Italia',
'code': '20100'
}
city = compose_post_request(HOST_ADDRESS, '/demographics/city/new/', CITY_DATA)
print_response_data('city', city)
# -*- coding: utf-8 -*-
from helper import *
HOST_ADDRESS = 'http://127.0.0.1:8000'
city = compose_get_request(HOST_ADDRESS, '/demographics/city/get/', 'Mi')
print_response_data('city', city)
# -*- coding: utf-8 -*-
from helper import *
HOST_ADDRESS = 'http://127.0.0.1:8000'
CITY_DATA = {
'name': 'Milano',
'province': 'MI',
'state': 'Italia',
'code': '20128'
}
city = compose_get_request(HOST_ADDRESS, '/demographics/city/get/', 'Milano 20100')
print_response_data('city', city)
city_id = city['data'][0]['id']
edited_city = compose_post_request(HOST_ADDRESS, '/demographics/city/%s/edit/' % city_id, CITY_DATA)
print_response_data('city', edited_city)
Patient module¶
Patient module provides the following web API:
- /demographics/patient/new/
- /demographics/patient/get/
- /demographics/patient/edit/
- /demographics/patient/deactivate/
- /demographics/patient/activate/
- # /demographics/patient/add_id/
- # /demographics/patient/remove_id/
- # /demographics/patient/edit/
- # /demographics/patient/set_birth_place/
- # /demographics/patient/set_city/
# -*- coding: utf-8 -*-
from helper import *
HOST_ADDRESS = 'http://127.0.0.1:8000'
PATIENT_DATA = {
'account_number': 'RSSMRA80H51B354M',
'first_name': 'Maria',
'last_name': 'Rossi',
'other_ids': [1],
'gender': 'F',
'birth_date': '1980-06-11',
'birth_place': 1,
'address': 'Via Cagliari 4',
'city': 4,
'active': True
}
patient = compose_post_request(HOST_ADDRESS, '/demographics/patient/new/', PATIENT_DATA)
print_response_data('patient', patient)
# -*- coding: utf-8 -*-
from helper import *
HOST_ADDRESS = 'http://127.0.0.1:8000'
patient = compose_get_request(HOST_ADDRESS, '/demographics/patient/get/', 'RSS')
print_response_data('patient', patient)
# -*- coding: utf-8 -*-
from helper import *
HOST_ADDRESS = 'http://127.0.0.1:8000'
PATIENT_DATA = {
'account_number': 'RSSMRA80H51B354M',
'first_name': 'Marianna',
'last_name': 'Rossi',
'other_ids': [1],
'gender': 'F',
'birth_date': '1980-06-11',
'birth_place': 1,
'address': 'Via Cagliari 4',
'city': 4,
'active': True
}
patient = compose_get_request(HOST_ADDRESS, '/demographics/patient/get/', 'RSS')
print_response_data('patient', patient)
patient_id = patient['data'][0]['id']
edited_patient = compose_post_request(HOST_ADDRESS, '/demographics/patient/%s/edit/' % patient_id, PATIENT_DATA)
print_response_data('patient', edited_patient)
License¶
/*!
* Project MOST - Moving Outcomes to Standard Telemedicine Practice
* http://most.crs4.it/
*
* Copyright 2014, CRS4 srl. (http://www.crs4.it/)
* Dual licensed under the MIT or GPL Version 2 licenses.
* See license-GPLv2.txt or license-MIT.txt
*/
Authors¶
Code author: Francesco Cabras <paneb@crs4.it>
Code author: Valeria Lecca <valeria.lecca@crs4.it>
Code author: Stefano Leone Monni <stefano.monni@crs4.it>