Observation Base Class

class nh_observations.observations.NhClinicalPatientObservation(pool, cr)[source]

Abstract representation of what a medical observation is. Contains common information that all observations will have but does not represent any entity itself, so it basically acts as a template for every other observation.

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

Convert the values in the passed dictionary to their corresponding labels.

Parameters:obs (list) –
create(*args, **kwargs)[source]

Checks for null numeric values before writing to the database and removes them from the vals dictionary to avoid Odoo writing incorrect 0 values and then calls create.

Passing a field key with a falsey value will cause that value to be excluded from the partial calculation due to the logic used, so don’t pass keys at all for fields that have not been submitted, even if they are using falsey values.

Returns:nh_clinical_patient_observation id.
Return type:int
create_activity(*args, **kwargs)[source]
frequency
Parameters:
  • selection – specifies the possible values for this field. It is given as either a list of pairs (value, string), or a model method, or a method name.
  • selection_add – provides an extension of the selection in the case of an overridden field. It is a list of pairs (value, string).

The attribute selection is mandatory except in the case of related fields or field extensions.

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

Looks for the related spell and gets its current location.

Parameters:activity_id (int) – activity id
Returns:location id
Return type:int
classmethod get_data_visualisation_resource()[source]

Returns URL of JS file to plot data visualisation so can be loaded on mobile and desktop

Returns:URL of JS file to plot graph
Return type:str
classmethod get_description(append_observation=True)[source]
get_field_value_label(field_name, field_value)[source]

Lookup the label for the passed field value and return it.

Parameters:
  • field_name (str) –
  • field_value (str) –
Returns:

Field label.

Return type:

str

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

Gets the first observation created after the passed datetime.

Parameters:
  • spell_activity_id (int) –
  • date_time (str) –
Returns:

get_form_description(*args, **kwargs)[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_formatted_obs(*args, **kwargs)[source]

Get a dictionary of observation data formatted for display.

Returns:
Return type:dict
get_last_obs(*args, **kwargs)[source]

Get the last observation made for the given patient_id.

Parameters:
  • cr
  • uid
  • patient_id (int) –
  • context
Returns:

False or observation

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

Get the activity for the last observation made for the given patient_id.

Parameters:
  • cr
  • uid
  • patient_id (int) –
  • context
Returns:

False or activity

get_necessary_fields()[source]
get_necessary_fields_dict()[source]
get_next_obs_activity(*args, **kwargs)[source]

When one observation activity is completed it triggers the creation of another one, this method returns the observation activity triggered by the given one.

Parameters:
  • obs_activity ('nh.activity' record) –
  • data_model (str) –
Returns:

Return type:

‘nh.activity’ record

get_obs_field_names()[source]
get_obs_field_order()[source]
get_obs_fields(*args, **kwargs)[source]
get_open_obs(*args, **kwargs)[source]
get_open_obs_activity(*args, **kwargs)[source]

Gets a list of all ‘open’ activities. ‘Open’ is anything that is not ‘completed’ or ‘cancelled’.

As far as I know there is not yet a situation where there should be more than one observation that is open but there may be in the future. It is up to the caller to check they are happy with the length of the returned list.

Returns:Search results for open EWS observations.
Return type:list
classmethod get_open_obs_search_domain(spell_activity_id)[source]
get_partial_reason_label(reason)[source]
get_previous_obs_activity(*args, **kwargs)[source]
get_submission_message()[source]

Provides a message to be displayed when the observation is submitted. :return: :rtype str

get_submission_response_data()[source]
get_triggered_tasks()[source]
get_view_description(*args, **kwargs)[source]

Transform the form description into view description that can be used by the mobile. This will return a list of dicts similar to:

[
    {
        'type': 'template',
        'template': 'nh_observation.custom_template'
    },
    {
        'type': 'form',
        'inputs': []
    }
]
Parameters:form_desc (list) – List of dicts representing the inputs for the form
Returns:list of dicts representing view description
is_last_obs_refused(*args, **kwargs)[source]

Check if the last completed observation was a partial with reason ‘refused’.

Parameters:patient_id
Returns:
is_partial
none_values

Very similar to Char but used for longer contents, does not have a size and usually displayed as a multiline text box.

Parameters:translate – whether the value of this field can be translated
null_values

Very similar to Char but used for longer contents, does not have a size and usually displayed as a multiline text box.

Parameters:translate – whether the value of this field can be translated
obs_stop_before_refusals(*args, **kwargs)[source]
partial_reason
Parameters:
  • selection – specifies the possible values for this field. It is given as either a list of pairs (value, string), or a model method, or a method name.
  • selection_add – provides an extension of the selection in the case of an overridden field. It is a list of pairs (value, string).

The attribute selection is mandatory except in the case of related fields or field extensions.

patient_has_spell(*args, **kwargs)[source]
patient_id

The value of such a field is a recordset of size 0 (no record) or 1 (a single record).

Parameters:
  • comodel_name – name of the target model (string)
  • domain – an optional domain to set on candidate values on the client side (domain or string)
  • context – an optional context to use on the client side when handling that field (dictionary)
  • ondelete – what to do when the referred record is deleted; possible values are: 'set null', 'restrict', 'cascade'
  • auto_join – whether JOINs are generated upon search through that field (boolean, by default False)
  • delegate – set it to True to make fields of the target model accessible from the current model (corresponds to _inherits)

The attribute comodel_name is mandatory except in the case of related fields or field extensions.

placement_before_refusals(*args, **kwargs)[source]
read(*args, **kwargs)[source]

Calls read and then looks for potential numeric values that might be actually null instead of 0 (as Odoo interprets every numeric value as 0 when it finds null in the database) and fixes the return value accordingly.

Rounds all floats to n decimal places, where n is the number specified in the digits tuple that is an attribute of the field definition on the model.

Returns:dictionary with the read values
Return type:dict
read_labels(*args, **kwargs)[source]

Return a ‘read-like’ dictionary with field labels instead of values.

Parameters:
  • fields
  • load
Returns:

Return type:

dict

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

Read all observations for the patient.

Parameters:patient_id (int) –
Returns:
Return type:dict
write(*args, **kwargs)[source]

Checks for null numeric values before writing to the database and removes them from the vals dictionary to avoid Odoo writing incorrect 0 values and then calls write.

If the frequency is updated, the observation will be rescheduled accordingly.

Returns:True
Return type:bool