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.
-
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
nullnumeric values before writing to the database and removes them from thevalsdictionary to avoid Odoo writing incorrect0values and then callscreate.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_observationid.Return type: int
-
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
spelland gets its current location.Parameters: activity_id (int) – activityidReturns: locationidReturn 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
-
get_field_value_label(field_name, field_value)[source]¶ Lookup the label for the passed field value and return it.
Parameters: Returns: Field label.
Return type:
-
get_first_obs_created_after_datetime(*args, **kwargs)[source]¶ Gets the first observation created after the passed datetime.
Parameters: 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) – patientidReturns: 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: Falseorobservation
-
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: Falseoractivity
-
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_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
-
get_submission_message()[source]¶ Provides a message to be displayed when the observation is submitted. :return: :rtype str
-
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
Charbut 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
Charbut 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
-
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_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
Trueto 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.
-
read(*args, **kwargs)[source]¶ Calls
readand then looks for potential numeric values that might be actuallynullinstead of0(as Odoo interprets every numeric value as0when it findsnullin 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:
-
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
nullnumeric values before writing to the database and removes them from thevalsdictionary to avoid Odoo writing incorrect0values and then callswrite.If the
frequencyis updated, the observation will be rescheduled accordingly.Returns: TrueReturn type: bool
-