Report

class nh_eobs.report.report_nh_clinical_observation_report.ObservationReport(pool, cr)[source]
add_exclude_placement_cancel_reason_parameter_to_domain(domain)[source]
add_triggered_action_keys_to_obs_dicts(*args, **kwargs)[source]
add_user_key(activity_data_list)[source]
classmethod build_monitoring_exception_domain(spell_activity_id, start_date=None, end_date=None)[source]

Contained in the domain is all the business logic for deciding whether an activity may need to be included on the report in some way.

The domain uses Polish Notation. You can learn how to read it on Wikipedia.

Parameters:
  • spell_activity_id
  • start_date
  • end_date
Returns:

static convert_bristol_stools_booleans(model_data)[source]
convert_partial_reasons_to_labels(*args, **kwargs)[source]
static convert_pbp_booleans(model_data)[source]
create_patient_monitoring_exception_dictionary(data, spell_activity_id)[source]

Creates a dictionary containing data for patient monitoring exceptions that can be used to populate the observation report.

Parameters:
  • data
  • spell_activity_id (int) –
Returns:

Return type:

dict

create_report_data(data)[source]
get_activity_data(*args, **kwargs)[source]

Returns a list of dictionaries, each one representing the values of one :class:<nh_activity.activity.nh_activity> record.

Parameters:
  • spell_activity_id
  • model (str) – The name of the model matching the type of activity data to retrieve activities for.
  • start_time
  • end_time
Returns:

Return type:

dict

get_activity_data_from_dict(dict, spell_id, data)[source]
get_and_process_report_data(data)[source]

Calls get_report_data as well as some additional methods that massage the data.

Parameters:data
Returns:
Return type:dict
get_ews_observations(*args, **kwargs)[source]

Gets all completed or cancelled EWS observations associated with the passed spell activity id and returns them as a list of dictionaries.

Parameters:
  • data
  • spell_activity_id (int) –
Returns:

Return type:

dict

get_model_data(spell_activity_id, model, start, end)[source]

Get activities associated with the passed model and spell id and return them as a dictionary.

Parameters:
  • spell_activity_id (int) –
  • model (str) –
  • start (str) –
  • end (str) –
Returns:

Activities for the passed spell id and model within the date range.

Return type:

dict

get_model_values(model, activity_data)[source]

Adds a values key to the passed activity dictionary which is associated with another dictionary of values representing the record which is the data ref of the passed activity.

Parameters:
  • model (str) –
  • activity_data (str) –
Returns:

Return type:

dict

get_monitoring_exception_report_data_from_activities(pme_activity_ids)[source]

Calls :method:<get_monitoring_exception_report_data_from_activity> recursively.

Parameters:pme_activity_ids (list) –
Returns:
Return type:dict
get_monitoring_exception_report_data_from_activity(pme_activity_id)[source]

Gets data from the activities with the passed ids and returns a dictionary containing just the values needed for the observation report.

Parameters:pme_activity_id (int) –
Returns:
Return type:dict
get_multi_model_data(spell_id, model_one, model_two, start, end)[source]
get_patient_monitoring_exception_activity_ids(spell_activity_id, start_date=None, end_date=None)[source]

Returns a list of ids for all activities whose information should be included in the report. Exactly what entries should be created for these activities on the report is decided later.

Parameters:
  • spell_activity_id (int) –
  • start_date (str) –
  • end_date (str) –
Returns:

get_patient_monitoring_exception_report_data(spell_activity_id, start_date=None, end_date=None)[source]

Returns a dictionary with a ‘patient_monitoring_exception_history’ key which contains a list of dictionaries containing data for ‘new style’ patient monitoring exceptions. These are patient monitoring exceptions which are records of the :class:<nh_eobs.models.PatientMonitoringException> model.

The data returned is meant for use on the observation report, it is not a full representation of the record, just a few fields that are ready to be mapped directly onto the report.

The ‘patient_monitoring_exception_history’ list is sorted chronologically.

Parameters:
  • spell_activity_id (int) –
  • start_date (str) –
  • end_date (str) –
Returns:

Return type:

dict

get_report_data(data, ews_only=False)[source]

Returns a dictionary that will be used to populate the report. Most of the values are themselves dictionaries returned by activity.read(). However they also have an additional key named ‘values’ that contains the activities data_ref record as dictionaries returned by model.read().

Parameters:
  • data
  • ews_only
Returns:

Return type:

dict

get_report_entry_dictionary(pme_activity_id, pme_started=True)[source]

Creates a dictionary that contains the data that will be used to populate the report for a single entry concerning a patient monitoring exception activity.

Contains various bits of logic to return different values depending on whether the PME has been started, stopped, or cancelled.

Parameters:
  • pme_activity_id (int) –
  • pme_started (bool) –
Returns:

Return type:

dict

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

Recursively get the triggered actions of the activity passed to it and then it’s children and so on.

Parameters:
  • activity_id (int) – The current activity under inspection
  • activity_list – the list to use
Returns:

list of activity ids

Return type:

list

get_triggered_actions(*args, **kwargs)[source]
is_activity_date_terminated_within_date_range(activity, start_date=None, end_date=None)[source]

Returns a boolean indicating whether a particular activity’s date_terminated field falls within the specified date range.

Parameters:
  • activity (dict) – dictionary as returned by :method:<read>
  • start_date (str) –
  • end_date (str) –
Returns:

Return type:

bool

static is_date_range_within_active_pme(activity, start_date, end_date)[source]

Checks to see if supplied start and end dates are within a PME event

Parameters:
  • activity – PME activity
  • start_date – report start date
  • end_date – report end date
Returns:

True if date range within activities date range, False if not

Return type:

bool

classmethod is_datetime_within_range(date_time, start_date=None, end_date=None)[source]

Returns a boolean indicating whether the passed datetime falls within the specified date range.

Parameters:
  • date_time (str or datetime) –
  • start_date (str or datetime) –
  • end_date (str or datetime) –
Returns:

Return type:

bool

monitoring_dict = {'critical_care_history': 'nh.clinical.patient.critical_care', 'diabetes_history': 'nh.clinical.patient.diabetes', 'mrsa_history': 'nh.clinical.patient.mrsa', 'palliative_care_history': 'nh.clinical.patient.palliative_care', 'post_surgery_history': 'nh.clinical.patient.post_surgery', 'targeto2': 'nh.clinical.patient.o2target'}
patient_id = None
static process_patient_height(patient, height)[source]
static process_report_dates(data, spell, base_report)[source]
process_transfer_history(model_data)[source]
render_html(*args, **kwargs)[source]

” This is a special method that the Odoo report module executes instead of it’s built-in render_html method when generating a report.

spell_activity_id = None