API

Defines the core methods for Open eObs in the taking of patient observations.

API

class api.nh_eobs_api[source]

Defines attributes and methods used by Open eObs in the making of patient observations.

_active_observations are the observation types supported by eObs.

admit(cr, uid, hospital_number, data, context=None)[source]

Extends admit(), admitting a patient into a specified location.

Parameters:
  • hospital_number (str) – hospital number of the patient
  • data (dict) – dictionary parameter that must contain a location key
Returns:

True

Return type:

bool

admit_update(cr, uid, patient_id, data, context=None)[source]

Wraps admit_update(), updating the spell information of a patient.

Parameters:
  • patient_id (str) – hospital number of the patient
  • data (dict) – dictionary parameter that must contain a location key
Returns:

True

Return type:

bool

assign(cr, uid, activity_id, data, context=None)[source]

Assigns an activity to a user. Raises an exception if the user is not permitted to assign the activity or if the user being assigned cannot be located.

Parameters:
  • activity_id (int) – id of activity
  • data (dict) – may contain user_id. The activity will be assigned to this user
Raises:

osv.except_osv

Returns:

True

Return type:

bool

cancel(cr, uid, activity_id, data, context=None)[source]

Cancel an activity, updating it with submitted data.

Parameters:
  • activity_id (int) – id of activity to cancel
  • data (dict) – data to update the activity
Returns:

True

Return type:

bool

cancel_admit(cr, uid, hospital_number, context=None)[source]

Extends cancel_admit(), cancelling the open spell of a patient.

Parameters:hospital_number (str) – hospital number of the patient
Returns:True
Return type:bool
cancel_discharge(cr, uid, hospital_number, context=None)[source]

Extends cancel_discharge() of a patient.

Parameters:hospital_number (str) – hospital number of the patient
Returns:True
Return type:bool
cancel_transfer(cr, uid, hospital_number, context=None)[source]

Extends cancel_transfer(), cancelling the transfer of a patient.

Parameters:hospital_number (str location) – hospital number of the patient
Returns:True
Return type:bool
check_patient_responsibility(cr, uid, hospital_number, context=None)[source]

Verifies that a user is responsible for a patient.

Parameters:
  • uid (int) – id of the user
  • hospital_number (str) – hospital number of the patient
Returns:

True if user is responsible. Otherwise False

Return type:

bool

collect_activities(cr, uid, domain, context=None)[source]

Get activities from the database for a given domain :param cr: odoo cursor :param uid: user to perform search as :param domain: domain to look for :param context: odoo context :returns: list of dictionaries containing activities. See source

for specific attributes returned for each activity
Return type:list
collect_patients(cr, uid, domain, context=None)[source]

Collect patients for a given domain and return SQL output.

Parameters:
  • cr – Odoo cursor
  • uid – user ID for user doing operation
  • domain – search domain to use
  • context – Odoo context
Returns:

list of dicts

complete(cr, uid, activity_id, data, context=None)[source]

Completes an activity. Raises an exception if the user is not permitted to complete the activity.

Parameters:
  • activity_id (int) – id of activity
  • data (dict) – data to submit
Raises:

osv.except_osv

Returns:

True

Return type:

bool

create_activity_for_patient(cr, uid, patient_id, activity_type, vals_activity=None, vals_data=None, context=None)[source]

Creates an activity of specified type for a patient if there is no open activity of that type for that patient. Raises exception if the activity type is invalid, if there’s no open spell for the patient or if there are no access rules for the activity type.

Parameters:
  • patient_id (int) – id of the patient
  • activity_type (str) – type of activity
Raises:

osv.except_osv

Returns:

id of activity

Return type:

int

discharge(cr, uid, hospital_number, data, context=None)[source]

Extends discharge(), closing the spell of a patient.

Parameters:
  • hospital_number (str) – hospital number of the patient
  • data (dict) – may contain the key discharge_date
Returns:

True

Return type:

bool

follow_invite(cr, uid, patient_ids, to_user_id, context=None)[source]

Creates a follow activity for the user to follow the patients. Raises an exception if the user is not responsible for a patient.

Parameters:
  • patient_ids (list) – ids of the patients to follow
  • to_user_id (int) – id of the user to invite
Raises:

osv.except_osv

Returns:

id of the follow activity

Return type:

int

get_active_observations(cr, uid, patient_id, context=None)[source]

Returns all active observation types supported by eObs, if the patient has an active spell.

Parameters:patient_id (int) – id of patient
Returns:list of all observation types
Return type:list
get_activities(cr, uid, ids, context=None)[source]

Gets a list of activities.

Parameters:ids (list) – ids of the activities. An empty list returns all activities
Returns:list of dictionaries containing activities. See source for specific attributes returned for each activity
Return type:list
get_activities_for_patient(cr, uid, patient_id, activity_type, start_date=None, end_date=None, context=None)[source]

Returns a list of activities for a patient in a dictionary (containing every field from the table).

Parameters:
  • patient_id (int) – id of the patient
  • activity_type (str) – type of activity
  • start_date (str) – start date to filter. A month from now by default
  • end_date (str) – end date to filter. Now by default
Returns:

list of activity dictionaries for patient

Return type:

list

get_activities_for_spell(cr, uid, spell_id, activity_type, start_date=None, end_date=None, context=None)[source]

Gets all activities for a patient spell.

Parameters:
  • spell_id (int) – id for the patient spell
  • activity_type (str) – The part of the model name after ‘observation.’
  • start_date (str) – retrieve activities only on or after this date. Must be provided if activity_type has also been given
  • end_date (str) – retrieve activities only on or before this date. Must be provided if activity_type has also been given
Returns:

list of dictionaries of activities, including all fields and values

Return type:

list

get_activity_score(cr, uid, data_model, data, context=None)[source]

Gets the activity score for a observation.

Parameters:
  • data_model (str) – name of the data model
  • data (dict) – observation data
Returns:

observation score. Otherwise False

Return type:

dict

get_assigned_activities(cr, uid, activity_type=None, context=None)[source]

Gets users open assigned activities of the specified type (any by default).

Parameters:activity_type (str [default is None]) – type of activity [optional]
Returns:list of dictionaries containing activities
Return type:list
get_cancel_reasons(cr, uid, context=None)[source]

Gets the reason for each cancelled activity.

Returns:list of dictionaries of reasons
Return type:list
get_data_visualisation_resources()[source]

Get data visualisation resources for all installed observations that have data visualisation JS files defined

Returns:list of JS file URLs used for drawing graphs
get_followed_patients(cr, uid, context=None)[source]

Returns a list of patients followed by user in a dictionary (containing every field from the table).

Parameters:uid (int) – id of the user
Returns:list of patient dictionaries
Return type:list
get_form_description(cr, uid, patient_id, data_model, context=None)[source]

Returns a description in dictionary format of the input fields that would be required in the user gui to submit the observation.

Parameters:patient_id (int) – patient id
Returns:a list of dictionaries
Return type:list
get_invited_users(cr, uid, patients, context=None)[source]

Expects the return value from get_patients or get_followed_patients and adds the users that have an open follow invitation for each patient.

get_patient_followers(cr, uid, patients, context=None)[source]

Expects the return value from get_patients or get_followed_patients and adds the followers for each patient.

get_patient_info(cr, uid, hospital_number, context=None)[source]

Gets patient information for a patient, including activities.

Parameters:hospital_number (str) – hospital number of patient
Returns:dictionary containing the patient fields.
Return type:dict
get_patients(cr, uid, ids, context=None)[source]

Return containing every field from patient for each patients.

Parameters:ids (list) – ids of the patients. If empty, then all patients are returned
Returns:list of patient dictionaries
Return type:list
get_share_users(cr, uid, context=None)[source]

Gets user information name, id and number of patients responsible for) of each user who is responsible for any location located in any of the wards the user calling the method is responsible for.

Parameters:uid (int) – id of user calling method
Returns:list of dictionaries containing values name, id and patients for each user
Return type:list
get_spell_activity_id(hospital_number)[source]

Return the spell activity ID for the patient with the given hospital number. Raises an exception if more than one spell is found. :param hospital_number: :type hospital_number: str :return:

is_cancellable(cr, uid, data_model, context=None)[source]

Checks if instances belonging to data model can be cancelled. Only data models which are notifications (i.e. either is or have inherited from notification.

Parameters:data_model (str) – data model
Returns:True or False
Return type:bool
merge(cr, uid, hospital_number, data, context=None)[source]

Wraps merge() of a patient.

Parameters:
  • hospital_number (str) – hospital number of the patient to merge INTO
  • data (dict) – dictionary parameter that may contain the following keys from_identifier, the hospital number of the patient merged FROM
Returns:

True

Return type:

bool

register(cr, uid, hospital_number, data, context=None)[source]

Wraps register(), register a patient in the system.

Parameters:
  • hospital_number (str) – hospital number of the patient
  • data (dict) – dictionary parameter that may contain the following about the patient: patient_identifier, family_name, given_name, middle_names, dob, gender, sex.
Returns:

True

Return type:

bool

remove_followers(cr, uid, patient_ids, context=None)[source]

Removes followers (users) from patients. Raises an exception if the user is not responsible for a patient.

Parameters:patient_ids (list) – ids of the patients to unfollow
Raises:osv.except_osv
Returns:True
Return type:bool
submit(cr, uid, activity_id, data, context=None)[source]

Updates submitted activity data.

Parameters:
  • activity_id (int) – id of activity to update
  • data (dict) – data to update activity
Returns:

True

Return type:

bool

transfer(cr, uid, hospital_number, data, context=None)[source]

Extends transfer(), transferring a patient to a location.

Parameters:
  • hospital_number (str) – hospital number of the patient
  • data – dictionary parameter that may contain the key location
Returns:

True

Return type:

bool

unassign(cr, uid, activity_id, context=None)[source]

Unassign the activity from the user.

Parameters:
  • uid (int) – id of the user
  • activity_id (int) – id of activity
Returns:

True

Return type:

bool

unassign_my_activities(cr, uid, context=None)[source]

Unassigns every activity the user is assigned to.

Not included are activities that are always belong to a specific user.

Parameters:uid (int) – id user of user
Returns:True
Return type:bool
update(cr, uid, patient_id, data, context=None)[source]

Wraps update(), updating a patient record.

Parameters:patient_id (str) – hospital number of the patient
Returns:True
Return type:bool