Location

class location.nh_clinical_location(pool, cr)[source]

Represents a location where a patient may be located or an activity may take place.

There are different types of locations. The most common usage is to have a hospital as a parent location to a group of wards where each ward is a parent to several beds. The bed location is where the patient can be placed.

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

Check that the context can be applied to the model

Parameters:context_ids
Returns:
create(*args, **kwargs)[source]

Extends Odoo’s create() method. Updates nh_clinical_location to write context_ids field.

Parameters:vals (dict) – values to update the records with
Returns:True
Return type:bool
get_available_location_ids(*args, **kwargs)[source]

Gets a list of available locations, only returning beds unless specified otherwise.

Parameters:usages – location type (ward, bed, etc.) of available locations
Returns:location ids of available locations (default usage is bed)i
Return type:list
get_by_code(*args, **kwargs)[source]

Gets the location’s id by the location’s code. Creates a location if auto_create is True and the location doesn’t exist.

Parameters:
  • code (str) – location’s code
  • auto_create (bool) – False [default].
Returns:

location id of the location. False if auto_create is True and location doesn’t exist, the location id of new ward location created. Otherwise False

Return type:

int or bool

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

Gets a location’s closest ancestor (parent) location id of a particular usage. Returns False if no such location exists.

Parameters:
Returns:

location id of the ancestor. Otherwise False

Return type:

int or bool

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

Checks if a location is a child of another location.

Parameters:
  • location_id (int) – location id
  • code (str) – location code
Returns:

the dictionary location_id (key) and a string containing location name and parent location name (value) Otherwise False is returned.

Return type:

dict or bool

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

Hospital locations can not have a parent location

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

Hospital locations can only be Point of Service type

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

Hospital locations don’t have parent locations and they are always Point of Service type.

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

Activates the location if inactive and deactivates it if active.

Parameters:location_id (int) – location id of location to be switched
Returns:True
Return type:bool
write(*args, **kwargs)[source]

Extends Odoo’s write() method. Updates nh_clinical_location to write context_ids field.

Parameters:
  • ids (list) – ids of the records to update
  • vals (dict) – values to update the records with
Returns:

True

Return type:

bool