Patient

class patient.NhClinicalPatient(pool, cr)[source]

Represents a patient.

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

Extends Odoo’s create() to write name, other_identifier and patient_identifier upon creation.

Returns:True if created
Return type:bool
current_location_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.

display_name

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
dob
ethnicity
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.

family_name

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
follower_ids

Many2many field; the value of such a field is the recordset.

Parameters:comodel_name – name of the target model (string)

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

Parameters:
  • relation – optional name of the table that stores the relation in the database (string)
  • column1 – optional name of the column referring to “these” records in the table relation (string)
  • column2 – optional name of the column referring to “those” records in the table relation (string)

The attributes relation, column1 and column2 are optional. If not given, names are automatically generated from model names, provided model_name and comodel_name are different!

Parameters:
  • 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)
  • limit – optional limit to use upon read (integer)
format_data(fields, data, context=None)[source]
full_name

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

Returns patients ids for patients with no open spell.

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

Get patient record with either of the supplied identifier or raise error

Parameters:
  • hospital_number – Other identifier for the patient record
  • nhs_number – Patient identifier for the patient record
Returns:

patient ID for patient with either of the identifiers

get_patients_on_ward(*args, **kwargs)[source]
Parameters:
  • ward_id (int) –
  • patient_ids (int or list of nh.clinical.patient records) –
Returns:

All the patients on the given ward

Return type:

list of nh.clinical.patient records

given_name

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

Attempts to load the data matrix, and returns a list of ids (or False if there was an error and no id could be generated) and a list of messages.

The ids are those of the records created and saved (in database), in the same order they were extracted from the file. They can be passed directly to read()

Parameters:
  • fields (list(str)) – list of fields to import, at the same index as the corresponding data
  • data (list(list(str))) – row-major matrix of data to import
  • context (dict) –
Returns:

{ids: list(int)|False, messages: [Message]}

middle_names

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

Override name_get method so we return the patient’s fullname instead of the default name field

not_admitted
other_identifier

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

patient_identifier

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

Convert the current patient record to a dictionary. Commonly used to be sent to the front-end. The self argument must be a single nh.clinical.patient record.

Returns:Patient dictionary.
Return type:dict
sex
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.

“Deletes” a patient from the system without deleting the record from the database. This allows the retrieval of patient data if necessary.

Parameters:ids (list) – ids of patients to unlink
Returns:True
Return type:bool
update(*args, **kwargs)[source]

Updates patient data by provided hospital number or nhs number, instead of patient_id as per usual.

Parameters:
  • identifier (str) – identifier of patient
  • data (dict) – data to write to the patient record
  • selection (str) – type of identifier used to lookup patient. Default is other_identifier, which is hospital number. patient_identifier will do it through the nhs number.
Returns:

True

Return type:

bool

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

Extends Odoo’s write().

Returns:True if created
Return type:bool