Early Warning Score Observation

Defines the Early Warning Score observation class and its standard behaviour and policy triggers based on the UK NEWS standard.

class ews.nh_clinical_patient_observation_ews(pool, cr)[source]

Represents an Early Warning Score observation which stores a group of physiological parameters measured from the patient that together determine a score that serves as an indicator of the illness current acuity.

The basis of the scoring system are the following six parameters: respiratory rate, oxygen saturations, temperature, systolic blood pressure, pulse rate and level of consciousness.

avpu_text
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.

blood_pressure_diastolic
blood_pressure_systolic
body_temperature

The precision digits are given by the attribute

Parameters:digits – a pair (total, decimal), or a function taking a database cursor and returning a pair (total, decimal)
bp_display

Basic string field, can be length-limited, usually displayed as a single-line string in clients

Parameters:
  • size (int) – the maximum size of values stored for that field
  • translate (bool) – whether the values of this field can be translated
calculate_score(*args, **kwargs)[source]

Computes the score and clinical risk values based on the NEWS parameters provided.

It will return as extra information the presence of any Red Score parameter within the data. (any parameter that scores 3)

Parameters:ews_data (dict) – The NEWS parameters: respiration_rate, indirect_oxymetry_spo2, body_temperature, blood_pressure_systolic, pulse_rate, oxygen_administration_flag and avpu_text
Returns:score, clinical_risk and three_in_one
Return type:dict
can_decrease_obs_frequency(*args, **kwargs)[source]

Determines whether or not the frequency of the patients observations can be reduced to a lower value. There are certain situations where this is allowed depending on the ward’s policy.

Parameters:
  • cr
  • uid
  • patient_id
  • threshold_value
  • context
Returns:

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

Convenience that allows you to pass a ‘case’ instead of a ‘frequency’ and the method will do the lookup for you.

See nh_observations.nh_clinical_extension .nh_clinical_api_extension.change_activity_frequency.

Parameters:
  • cr
  • uid
  • patient_id
  • name
  • case
  • context
Returns:

clinical_risk

Basic string field, can be length-limited, usually displayed as a single-line string in clients

Parameters:
  • size (int) – the maximum size of values stored for that field
  • translate (bool) – whether the values of this field can be translated
complete(*args, **kwargs)[source]

It determines which acuity case the current observation is in with the stored data and responds to the different policy triggers accordingly defined on the _POLICY dictionary.

After the policy triggers take place the activity is completed and a new NEWS activity is created. Then the case based frequency is applied, effectively scheduling it.

In the case of having a partial observation we won’t have a new frequency so the new activity is scheduled to the same time the one just completed was, as the need for a complete observation is still there.

Returns:True
Return type:bool
concentration
convert_case_to_risk(case)[source]
cpap_peep
create_activity(*args, **kwargs)[source]

When creating a new activity of this type every other not completed or cancelled instance related to the same patient will be automatically cancelled.

Returns:activity id.
Return type:int
create_next_obs(*args, **kwargs)[source]

Creates a new observation and activity based on a given closed observation activity.

If the previous observation is partial, the new observation is scheduled for the same time as the old one, in other words, there is a good chance it will be due right away. If the previous observation is not a partial then it will be scheduled based on the frequency implied by the clinical risk of the previous observation.

It only makes sense to create the next observation activity based on an activity for an observation of the same type as this one. An exception will be raised if the same type of activity is not passed.

If the observation is neither completed or cancelled then it is still open and a new observation activity should not be created, thus an exception will be raised.

Parameters:previous_obs_activity
Returns:
device_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.

flow_rate

The precision digits are given by the attribute

Parameters:digits – a pair (total, decimal), or a function taking a database cursor and returning a pair (total, decimal)
get_case(observation)[source]

Return an integer based on the clinical risk of the observation to be used as an index when accessing elements of _POLICY.

Parameters:observation – EWS observation
Returns:case
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
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_last_case(*args, **kwargs)[source]

Checks for the last completed NEWS for the provided patient and returns the acuity case:

0 - No Risk
1 - Low Risk
2 - Medium Risk
3 - High Risk
Returns:False or the acuity case
Return type:int
get_last_full_obs_activity(*args, **kwargs)[source]

Gets the most recent full observation.

Parameters:spell_activity_id (int) –
Returns:observation activity
Return type:nh.activity
get_notifications(*args, **kwargs)[source]

Get notifications that should be triggered upon completion of the passed activity for an EWS observation.

Parameters:activity – activity referencing an EWS observation
Returns:a list of dictionaries representing notifications
Return type:list
get_submission_message(*args, **kwargs)[source]

Override of nh.clincal.patient.observation method.

Returns:
handle_o2_devices(*args, **kwargs)[source]

Checks the current state of supplemental oxygen device sessions on the related spell.

It completes the sessions if the current NEWS does not have the oxygen administration flag up.

It completes any session with an oxygen administration device type that does not match the NEWS device.

It starts a new session if the NEWS device provided does not have already an open one related to the spell.

Parameters:activity_id (int) – activity id.
indirect_oxymetry_spo2
is_partial
mews_score
niv_backup
niv_epap
niv_ipap
o2_display

Basic string field, can be length-limited, usually displayed as a single-line string in clients

Parameters:
  • size (int) – the maximum size of values stored for that field
  • translate (bool) – whether the values of this field can be translated
order_by
oxygen_administration_flag
patient_has_spell(*args, **kwargs)[source]
pulse_rate
respiration_rate
score
score_display

Basic string field, can be length-limited, usually displayed as a single-line string in clients

Parameters:
  • size (int) – the maximum size of values stored for that field
  • translate (bool) – whether the values of this field can be translated
submit(*args, **kwargs)[source]
three_in_one
update_next_obs_after_partial(*args, **kwargs)[source]

Updates the frequency and date scheduled of the newly created next_obs_activity from their default values to their correct values based on previous observations and the refusal status.

Parameters:
  • partial_obs_activity ('nh.activity' record) – Observation activity expected to be a partial and the most recently completed observation for the spell.
  • next_obs_activity ('nh.activity' record) – Observation activity expected to be the most recently created one triggered by the passed partial.
Returns: