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 specifiedlocation
.Parameters: Returns: True
Return type:
-
admit_update
(cr, uid, patient_id, data, context=None)[source]¶ Wraps
admit_update()
, updating thespell
information of apatient
.Parameters: Returns: True
Return type:
-
assign
(cr, uid, activity_id, data, context=None)[source]¶ Assigns an
activity
to auser
. Raises an exception if the user is not permitted to assign the activity or if the user being assigned cannot be located.Parameters: Raises: osv.except_osv
Returns: True
Return type:
-
cancel
(cr, uid, activity_id, data, context=None)[source]¶ Cancel an
activity
, updating it with submitteddata
.Parameters: Returns: True
Return type:
-
cancel_admit
(cr, uid, hospital_number, context=None)[source]¶ Extends
cancel_admit()
, cancelling the openspell
of apatient
.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 apatient
.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 apatient
.Parameters: hospital_number (str location
) – hospital number of the patientReturns: True
Return type: bool
-
check_patient_responsibility
(cr, uid, hospital_number, context=None)[source]¶ Verifies that a
user
is responsible for apatient
.Parameters: Returns: True
if user is responsible. OtherwiseFalse
Return type:
-
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 activityReturn 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 theuser
is not permitted to complete the activity.Parameters: Raises: osv.except_osv
Returns: True
Return type:
-
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 apatient
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: Raises: osv.except_osv
Returns: id of activity
Return type:
-
discharge
(cr, uid, hospital_number, data, context=None)[source]¶ Extends
discharge()
, closing thespell
of apatient
.Parameters: Returns: True
Return type:
-
follow_invite
(cr, uid, patient_ids, to_user_id, context=None)[source]¶ Creates a
follow activity
for theuser
to follow thepatients
. 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:
-
get_active_observations
(cr, uid, patient_id, context=None)[source]¶ Returns all active observation types supported by eObs, if the
patient
has an activespell
.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 apatient
in a dictionary (containing every field from the table).Parameters: 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 patientspell
.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: Returns: observation score. Otherwise
False
Return type:
-
get_assigned_activities
(cr, uid, activity_type=None, context=None)[source]¶ Gets
users
open assignedactivities
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 cancelledactivity
.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 byuser
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
idReturns: 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, includingactivities
.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
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
andpatients
for each userReturn 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
orFalse
Return type: bool
-
merge
(cr, uid, hospital_number, data, context=None)[source]¶ Wraps
merge()
of apatient
.Parameters: Returns: True
Return type:
-
register
(cr, uid, hospital_number, data, context=None)[source]¶ Wraps
register()
, register apatient
in the system.Parameters: Returns: True
Return type:
-
remove_followers
(cr, uid, patient_ids, context=None)[source]¶ Removes followers (
users
) frompatients
. 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: Returns: True
Return type:
-
transfer
(cr, uid, hospital_number, data, context=None)[source]¶ Extends
transfer()
, transferring apatient
to alocation
.Parameters: - hospital_number (str) – hospital number of the patient
- data – dictionary parameter that may contain the key
location
Returns: True
Return type:
-
unassign
(cr, uid, activity_id, context=None)[source]¶ Unassign the
activity
from theuser
.Parameters: Returns: True
Return type:
-