Activity Data

class activity_extension.nh_activity_data(pool, cr)[source]

Extends class nh_activity_data.

_audit_shift_coordinator(*args, **kwargs)[source]

Writes shift_coordinator_id for ward manager responsible for the activity’s location. If location doesn’t exist or it’s not within the ward or there’s no ward assigned, then no audit happens.

Parameters:activity_id (int) – activity id
Returns:True if the shift_coordinator_id is stored. Otherwise False
Return type:bool
_get_policy_create_data(case=None)[source]

Get the create_data dictionary for the policy

Parameters:case (int) – Case that controls the logic used when getting policy
Returns:Dictionary of values to use when creating a new activity
Return type:dict
cancel(*args, **kwargs)[source]

Extends cancel() method to audit the ward manager responsible for activity location.

Parameters:activity_id (int) – activity id
Returns:True
Return type:bool
check_policy_activity_context(*args, **kwargs)[source]

Check that the policy activity can be triggered based on the location’s context (Normally eobs)

Parameters:
  • activity_dict (dict) – Policy activity definition
  • location_id (int) – ID of location to check policy for
Returns:

True if can create activity for location

Return type:

bool

check_trigger_domains(*args, **kwargs)[source]

Check if any records are returned for the supplied domains. If so then return False

Parameters:
  • activity – nh.clinical.activity instance
  • search_definitions

    list of dicts with object (model to query) and domain (search query to carry out on model)

    for example: [

    {
    ‘object’: ‘nh.clinical.patient’, ‘domain’: [[‘patient_id’, ‘=’, XXX]]

    }

    ]

Type:

list(dict)

Returns:

True if no records found, False is records found

Return type:

bool

complete(*args, **kwargs)[source]

Extends complete() method to audit the ward manager responsible for activity location.

Parameters:activity_id (int) – activity id
Returns:True
Return type:bool
get_activity_location_id(*args, **kwargs)[source]

Gets the activity’s location id.

Parameters:activity_id (int) – activity id
Returns:location_id. See class nh_clinical_location
Return type:int
get_activity_patient_id(*args, **kwargs)[source]

Gets the activity’s patient id.

Parameters:activity_id (int) – activity id
Returns:patient_id. See class nh_clinical_patient
Return type:int
get_activity_pos_id(*args, **kwargs)[source]

Gets activity point of service (POST) id.

Parameters:activity_id (int) – activity id of updated activity
Returns:POS id
Return type:int
get_activity_user_ids(*args, **kwargs)[source]

Gets the activity’s user ids.

Parameters:activity_id (int) – activity id
Returns:patient_id. See class res_users
Return type:list
get_child_activity(activity_model, activity, data_model, context=None)[source]

Generator to return the child activity of the specified data model. The inputs use the Odoo v8 API record sets

Parameters:
  • activity_model – Instance of nh.activity environment
  • activity – Activity instance to get child of
  • data_model – data_model child activity should be
  • context – Odoo context
Returns:

Record of child activity

static get_recurring_activity_date_scheduled(activity)[source]

Recurring activities are ones that automatically create a new one when they are completed. It is common for EWS to be set as a recurring activity in a trust’s policy.

This method is called when an existing recurring activity has been completed and a new one has just been created. It returns the datetime which the newly created activity should be due by adding a ‘frequency’ to the current datetime.

Parameters:activity – Activity to get recurring date scheduled for
Returns:The datetime the newly triggered recurring activity should be due.
Return type:str
get_schedule_date(*args, **kwargs)[source]

Get the time to schedule the activity at

Parameters:
  • activity – Activity to get schedule date for
  • recurring – If the schedule date needs to take into consideration recurrance for the activities
Returns:

Date to schedule the activity for

Return type:

datetime

trigger_policy(*args, **kwargs)[source]

Triggers the list of activities in the _POLICY['activities'] list.

Parameters:
  • activity_id (int) – ID of the activity associated with the record
  • location_id (int) – location id [optional]. Required for checking context
  • case (bool or int) – default False. Otherwise integer related to risk of patient
Returns:

False if no spell activity otherwise True

Return type:

bool

trigger_policy_activity(*args, **kwargs)[source]

Trigger the activity as defined in the policy dictionary

Parameters:
  • source_activity (nh.activity record) – Record of the activity that’s going to be used as the base for the new activities
  • activity_dict (dict) – Activity dictionary contains: - model - type - cancel_others (optional)
  • case (int) – Case to use when triggering policy
trigger_policy_cancel_others(*args, **kwargs)[source]

Cancel all open activities when triggering the policy

Parameters:spell_activity_id – ID of the spell’s activity record. This is used by the cancel_
trigger_policy_change_state(activity_id, policy_dict)[source]

Change the state of the supplied activity in accordance with the supplied policy dict

Parameters:
  • activity_id – ID of the activity record
  • policy_dict – Dictionary representing the policy to enact on the activity
static trigger_policy_create_activity(source_activity, model, case=None)[source]

Create a new activity using the data defined in the policy with the source activity as it’s creator

Parameters:
  • source_activity (nh.activity record) – Activity to use to get activity info from
  • model (openerp.models.Model) – Model to create activity on
  • case – Case to use when getting the data to create the new activity with
update_activity(*args, **kwargs)[source]

Extends update_activity() method.

Parameters:activity_id (int) – activity id of updated activity
Returns:True
Return type:bool