Welcome to NHClinical’s documentation!¶
NH Odoo Fixes¶
NH Odoo fixes wraps and amends Odoo functionality for use with NHClinical.
Cookie Fix¶
Override Odoo’s default 3 month cookie timeout with our own
Parameters: - httprequest – An instance of openerp.http.HttpRequest
- result – The result to return to the client from openerp.http.route
- explicit_session – optional openerp.http.Session
Returns: Returns the result response with a cookie that expires in x hours
fields.many2many Set Override¶
read_group Fill Results¶
-
fix_read_group_fill_results.
_append_all
(self, cr, uid, read_group_result, all_groups, all_group_tuples, groupby, result_template, domain, count_field)[source]¶
-
fix_read_group_fill_results.
_append_left
¶ staticmethod(function) -> method
Convert a function to be a static method.
A static method does not receive an implicit first argument. To declare a static method, use this idiom:
class C: def f(arg1, arg2, …): … f = staticmethod(f)It can be called either on the class (e.g. C.f()) or on an instance (e.g. C().f()). The instance is ignored except for its class.
Static methods in Python are similar to those found in Java or C++. For a more advanced concept, see the classmethod builtin.
-
fix_read_group_fill_results.
_append_right
¶ staticmethod(function) -> method
Convert a function to be a static method.
A static method does not receive an implicit first argument. To declare a static method, use this idiom:
class C: def f(arg1, arg2, …): … f = staticmethod(f)It can be called either on the class (e.g. C.f()) or on an instance (e.g. C().f()). The instance is ignored except for its class.
Static methods in Python are similar to those found in Java or C++. For a more advanced concept, see the classmethod builtin.
Fix Server Shutdown Issue¶
Fixes to osv.expression¶
-
fixes_expression.
parse
(self, cr, uid, context)[source]¶ Transform the leaves of the expression
The principle is to pop elements from a leaf stack one at a time. Each leaf is processed. The processing is a if/elif list of various cases that appear in the leafs (many2one, function fields, …). Two things can happen as a processing result: - the leaf has been modified and/or new leafs have to be introduced
in the expression; they are pushed into the leaf stack, to be processed right after- the leaf is added to the result
- Some internal var explanation:
var obj working_model: model object, model containing the field (the name provided in the left operand) var list field_path: left operand seen as a path (foo.bar -> [foo, bar]) var obj relational_model: relational model of a field (field._obj) ex: res_partner.bank_ids -> res.partner.bank
ORM timestamp fixes¶
-
orm_fixes.
utc_timestamp
¶ staticmethod(function) -> method
Convert a function to be a static method.
A static method does not receive an implicit first argument. To declare a static method, use this idiom:
class C: def f(arg1, arg2, …): … f = staticmethod(f)It can be called either on the class (e.g. C.f()) or on an instance (e.g. C().f()). The instance is ignored except for its class.
Static methods in Python are similar to those found in Java or C++. For a more advanced concept, see the classmethod builtin.
Remove the exception name from error dialogs¶
Validation helpers¶
A place for generic validation functions.
In some places the variable name date_time has been used to avoid conflict with the imported datetime class.
NH Activity¶
activity.py
defines the classes and methods to allow for an audit
event driven system to be built on top of it.
-
activity.
data_model_event
(callback=None)[source]¶ Decorator for activity methods. This will automatically call a method with the same name on the
data model
related to theactivity
instance after calling the activity method. The result returned is the one from the data_model method.
nh_activity
¶
-
class
activity.
nh_activity
(pool, cr)[source]¶ Class representing any event that needs to be recorded by the system.
Any user executed event that has a starting and ending point in time could be represented as an instance of this class.
Most of them will need extra information recorded within them and that is why this class is closely related to the
data model
classes, which could be also named activity type.-
assign
(**kwargs)[source]¶ Sets
user_id
to the specified user if allowed by access rights.See
data model assign
for full implementation.Parameters: Returns: True
Return type:
-
assign_locked
¶
-
cancel
(**kwargs)[source]¶ Sets activity
state
to cancelled and records the date and user ondate_terminated
andterminate_uid
respectively. Seedata model cancel
for full implementation.Parameters: activity_id (int) – activity
idReturns: True
Return type: bool
-
child_ids
¶ One2many field; the value of such a field is the recordset of all the records in comodel_name such that the field inverse_name is equal to the current record.
Parameters: - comodel_name – name of the target model (string)
- inverse_name – name of the inverse Many2one field in comodel_name (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)
- auto_join – whether JOINs are generated upon search through that
field (boolean, by default
False
) - limit – optional limit to use upon read (integer)
The attributes comodel_name and inverse_name are mandatory except in the case of related fields or field extensions.
-
complete
(**kwargs)[source]¶ Sets activity
state
to completed and records the date and user ondate_terminated
andterminate_uid
respectively. Seedata model complete
for full implementation.Parameters: activity_id (int) – activity
idReturns: True
Return type: bool
-
create
(*args, **kwargs)[source]¶ Creates an activity. Raises an exception if
data_model
isn’t in parametervals
or ifdata_model
doesn’t exist as a table in the database.Parameters: vals (dict) – must include data_model
key:value pairRaises: osv.except_osv Returns: id of created activity
Return type: int
-
create_date
¶
-
create_uid
¶ 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.
-
created_ids
¶ One2many field; the value of such a field is the recordset of all the records in comodel_name such that the field inverse_name is equal to the current record.
Parameters: - comodel_name – name of the target model (string)
- inverse_name – name of the inverse Many2one field in comodel_name (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)
- auto_join – whether JOINs are generated upon search through that
field (boolean, by default
False
) - limit – optional limit to use upon read (integer)
The attributes comodel_name and inverse_name are mandatory except in the case of related fields or field extensions.
-
creator_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.
-
data_model
¶ 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
-
data_ref
¶
-
date_deadline
¶
-
date_expiry
¶
-
date_planned
¶
-
date_scheduled
¶
-
date_started
¶
-
date_terminated
¶
-
get_recursive_created_ids
(*args, **kwargs)[source]¶ Recursively gets ids of all activities created by an activity or all activitie
Parameters: activity_id (int) – id of activity Returns: list of activity ids Return type: list
-
notes
¶ 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
-
parent_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.
-
schedule
(**kwargs)[source]¶ Sets
date_scheduled
to the specified date and changes the activity state to scheduled. Seedata model schedule
for full implementation.Parameters: Returns: True
Return type:
-
sequence
¶
-
start
(**kwargs)[source]¶ Sets activity
state
to started.See
data model start
for full implementation.Parameters: activity_id (int) – activity
idReturns: True
Return type: bool
-
state
¶ 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.
-
submit
(**kwargs)[source]¶ Updates activity data. See
data model submit
for full implementation.Parameters: Returns: True
Return type:
-
summary
¶ Basic string field, can be length-limited, usually displayed as a single-line string in clients
Parameters:
-
terminate_uid
¶ 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.
-
unassign
(**kwargs)[source]¶ Sets
user_id
to False. Only the current owner of the activity is allowed to do this action. Seedata model unassign
for full implementation.Parameters: activity_id (int) – activity
idReturns: True
Return type: bool
-
update_activity
(**kwargs)[source]¶ This method is meant to refresh any real time data that needs to be refreshed on the activity. Does nothing as default. Included for potential utility on some activity types.
Parameters: activity_id (int) – activity
idReturns: True
Return type: bool
-
user_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.
-
write
(*args, **kwargs)[source]¶ Writes to an activity.
sequence
will be updated if the the state of the activity is changed.Parameters: Returns: True
Return type:
-
write_date
¶
-
write_uid
¶ 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.
-
nh_activity_data
¶
-
class
activity.
nh_activity_data
(pool, cr)[source]¶ Abstract class that relates to activity from which every activity type will inherit from.
-
activity_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.
-
assign
(*args, **kwargs)[source]¶ Assigns activity to a user. Raises an exception if it is already assigned to another user. If it is already assigned to the same user, then the activity is locked.
Parameters: Returns: True
Return type:
-
cancel
(*args, **kwargs)[source]¶ Cancels an activity and sets its
date_terminated
.Parameters: activity_id (int) – activity
idReturns: True
Return type: bool
-
complete
(*args, **kwargs)[source]¶ Completes an activity and sets its
date_terminated
.Parameters: activity_id (int) – activity
idReturns: True
Return type: bool
-
convert_record_to_data_ref
(*args, **kwargs)[source]¶ Useful for getting the value for domains so you can search on data_ref.
Returns: Return type: str
-
create
(vals) → record[source]¶ Creates a new record for the model.
The new record is initialized using the values from
vals
and if necessary those fromdefault_get()
.Parameters: vals (dict) –
values for the model’s fields, as a dictionary:
{'field_name': field_value, ...}
see
write()
for detailsReturns: new record created
Raises: - AccessError –
- if user has no create rights on the requested object
- if user tries to bypass access rules for create on the requested object
- ValidateError – if user tries to enter invalid value for a field that is not in selection
- UserError – if a loop would be created in a hierarchy of objects a result of the operation (such as setting an object as its own parent)
- AccessError –
-
create_activity
(*args, **kwargs)[source]¶ Creates a new
activity
of the current data type.Parameters: Returns: activity
id.Return type:
-
date_started
¶
-
date_terminated
¶
-
get_latest_activity
(*args, **kwargs)[source]¶ Return the most recent activity for a given data model.
Parameters: - data_model –
- spell_activity_id –
Returns:
-
get_open_activities
(*args, **kwargs)[source]¶ Get open activity(s) for one spell or all spells. :return: list of activities :rtype: list
-
get_open_activity
(*args, **kwargs)[source]¶ Get the latest open activity for the given model. The method assumes that only one open activity at a time is possible for the given model. If more than one is found an exception is raised.
Parameters: spell_activity_id – Returns:
-
is_action_allowed
(state, action)[source]¶ Tells us if the specified action is allowed in the specified state.
Parameters: Returns: True
orFalse
Return type:
-
name
¶ Basic string field, can be length-limited, usually displayed as a single-line string in clients
Parameters:
-
schedule
(*args, **kwargs)[source]¶ Schedules an activity and sets its
date_scheduled
.Parameters: Returns: True
Return type:
-
start
(*args, **kwargs)[source]¶ Starts an activity and sets its
date_started
.Parameters: activity_id (int) – activity
idReturns: True
Return type: bool
-
state
¶ Basic string field, can be length-limited, usually displayed as a single-line string in clients
Parameters:
-
submit
(*args, **kwargs)[source]¶ Updates submitted data. It creates a new instance of the data model if it does not exist yet.
Parameters: Returns: True
Return type:
-
terminate_uid
¶ 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.
-
NH Clinical¶
Activity Extension¶
Extends module nh_activity
, introducing patients,
spells, users and locations. See also base
module for more
information on their representative classes.
-
activity_extension.
list2sqlstr
()¶
Activity¶
-
class
activity_extension.
nh_activity
(pool, cr)[source]¶ Extends class
nh_activity
.-
cancel_open_activities
(*args, **kwargs)[source]¶ Cancels all open activities of parent activity.
Parameters: Returns: True
if all open activities are cancelled or if there are no open activities. Otherwise,False
Return type:
-
cancel_with_reason
(*args, **kwargs)[source]¶ Cancel the activity add a cancel reason to it.
Parameters: - activity_id –
- cancel_reason_id –
Returns: True
Return type:
-
create
(*args, **kwargs)[source]¶ Extends Odoo’s create() method.
Writes
user_ids
for responsible users of the activities` location.Parameters: vals (doct) – values to create record Returns: nh_activity
idReturn type: int
-
update_spell_users
(*args, **kwargs)[source]¶ Updates spell activities with the user_ids of users responsible for parent locations of spell location.
Parameters: user_ids (list) – user ids. See class res_users
Returns: True
Return type: bool
-
update_users
(*args, **kwargs)[source]¶ Updates activities with the user_ids of users responsible for the activities’ locations.
Parameters: user_ids (list) – user ids. See class res_users
Returns: True
Return type: bool
-
write
(*args, **kwargs)[source]¶ Extends Odoo’s write() method.
Also writes
user_ids
for responsible users of the activities’ location. See classnh_clinical_location
.Parameters: - ids (list) –
nh_activity
record ids - vals (dict) – values to update records (may include
location_id
)
Returns: True
Return type: - ids (list) –
-
Activity Data¶
-
class
activity_extension.
nh_activity_data
(pool, cr)[source]¶ Extends class
nh_activity_data
.-
_audit_shift_coordinator
(*args, **kwargs)[source]¶ Writes shift_coordinator_id for ward manager responsible for the activity’s location. If location doesn’t exist or it’s not within the ward or there’s no ward assigned, then no audit happens.
Parameters: activity_id (int) – activity id Returns: True
if the shift_coordinator_id is stored. OtherwiseFalse
Return type: bool
-
cancel
(*args, **kwargs)[source]¶ Extends
cancel()
method to audit the ward manager responsible for activity location.Parameters: activity_id (int) – activity id Returns: True
Return type: bool
-
complete
(*args, **kwargs)[source]¶ Extends
complete()
method to audit the ward manager responsible for activity location.Parameters: activity_id (int) – activity id Returns: True
Return type: bool
-
get_activity_location_id
(*args, **kwargs)[source]¶ Gets the activity’s location id.
Parameters: activity_id (int) – activity id Returns: location_id. See class nh_clinical_location
Return type: int
-
get_activity_patient_id
(*args, **kwargs)[source]¶ Gets the activity’s patient id.
Parameters: activity_id (int) – activity id Returns: patient_id. See class nh_clinical_patient
Return type: int
-
get_activity_pos_id
(*args, **kwargs)[source]¶ Gets activity point of service (POST) id.
Parameters: activity_id (int) – activity id of updated activity Returns: POS id Return type: int
-
get_activity_user_ids
(*args, **kwargs)[source]¶ Gets the activity’s user ids.
Parameters: activity_id (int) – activity id Returns: patient_id. See class res_users
Return type: list
-
get_child_activity
(activity_model, activity, data_model, context=None)[source]¶ Generator to return the child activity of the specified data model. The inputs use the Odoo v8 API record sets
Parameters: - activity_model – Instance of nh.activity environment
- activity – Activity instance to get child of
- data_model – data_model child activity should be
- context – Odoo context
Returns: Record of child activity
-
trigger_policy
(*args, **kwargs)[source]¶ Triggers the list of activities in the
_POLICY['activities']
list.Parameters: Returns: True
Return type:
-
update_activity
(*args, **kwargs)[source]¶ Extends
update_activity()
method.Parameters: activity_id (int) – activity id of updated activity Returns: True
Return type: bool
-
Cancel Reason¶
Activity Access¶
-
class
activity_extension.
nh_clinical_activity_access
(pool, cr)[source]¶ Adds an additional permission type called
perm_responsibility
to an activity. This defines if a particular user group can or cannot perform an activity.-
_auto
= False¶
-
_columns
= {'location_activity_ids_text': <openerp.osv.fields.text object at 0x7fcc88e99890>, 'location_ids_text': <openerp.osv.fields.text object at 0x7fcc89228c90>, 'parent_location_activity_ids_text': <openerp.osv.fields.text object at 0x7fcc88e991d0>, 'parent_location_ids_text': <openerp.osv.fields.text object at 0x7fcc88e99910>, 'user_id': <openerp.osv.fields.many2one object at 0x7fcc88fb05d0>}¶
-
_module
= 'activity_extension'¶
-
_name
= 'nh.clinical.activity.access'¶
-
location_activity_ids_text
¶ 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
-
location_ids_text
¶ 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
-
parent_location_activity_ids_text
¶ 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
-
parent_location_ids_text
¶ 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
-
user_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.
-
ADT¶
adt.py
defines a set of activity types to deal with patient
management systems operations.
Admit¶
-
class
adt.
nh_clinical_adt_patient_admit
(pool, cr)[source]¶ Represents the patient admission operation in the patient management system. (A01 Message)
Consulting and referring doctors are expected in the submitted values in the following format:
[... { 'type': 'c' or 'r', 'code': 'code_string, 'title': 'Mr', 'given_name': 'John', 'family_name': 'Smith' }... ]
If doctor doesn’t exist, then a partner is created (but no user is created).
-
complete
(*args, **kwargs)[source]¶ Calls
complete
and then creates and completes a newadmission
to the provided location.Returns: True
Return type: bool
-
submit
(*args, **kwargs)[source]¶ Checks the submitted data and then calls
submit
.If a ward
location
with the provided code does not exist, it will create a new one.Due to this behaviour the user submitting the data must be related to a
point of service
linked to a validlocation
instance of pos type, as new Wards will need to be assigned to a point of service.Returns: True
Return type: bool
-
Cancel Admit¶
-
class
adt.
nh_clinical_adt_patient_cancel_admit
(pool, cr)[source]¶ Represents the cancel admission operation in the patient management system. (A11 Message)
Cancel Discharge¶
-
class
adt.
nh_clinical_adt_patient_cancel_discharge
(pool, cr)[source]¶ Represents the cancel discharge operation in the patient management system. (A13 Message)
Cancel Transfer¶
-
class
adt.
nh_clinical_adt_patient_cancel_transfer
(pool, cr)[source]¶ Represents the cancel transfer operation in the patient management system. (A12 Message)
Discharge¶
-
class
adt.
nh_clinical_adt_patient_discharge
(pool, cr)[source]¶ Represents the patient discharge operation in the patient management system. (A03 Message)
-
complete
(*args, **kwargs)[source]¶ Calls
complete
and then creates and completes a newdischarge
for the provided patient.Returns: True
Return type: bool
-
submit
(*args, **kwargs)[source]¶ Checks the submitted data and then calls
submit
.Creates a new
spell
for the provided patient if there is not an open instance related to it. Requires the user to be linked to apoint of service
due to similar behaviour as the admission in this particular scenario.Returns: True
Return type: bool
-
Patient Merge¶
-
class
adt.
nh_clinical_adt_patient_merge
(pool, cr)[source]¶ Represents the patient merge operation in the patient management system. (A40 Message) Merges a patient into another patient making the resulting patient own all activities.
-
complete
(*args, **kwargs)[source]¶ Calls
complete
and then adds every piece of information that the source patient has and the destination patient lacks into the destination patient.The destination patient ends up being linked to all the
activities
both patients were linked to.Returns: True
Return type: bool
-
Register¶
Admit¶
-
class
adt.
nh_clinical_adt_patient_transfer
(pool, cr)[source]¶ Represents the patient transfer operation in the patient management system. (A02 Message)
-
complete
(*args, **kwargs)[source]¶ Calls
complete
and then creates and completes a newtransfer
for the provided patient.Returns: True
Return type: bool
-
submit
(*args, **kwargs)[source]¶ Checks the submitted data and then calls
submit
.Creates a new
spell
for the provided patient if there is not an open instance related to it and an origin location for the transfer was provided. Requires the user to be linked to apoint of service
due to similar behaviour as the admission in this particular scenario.Returns: True
Return type: bool
-
Update¶
Spell Update¶
-
class
adt.
nh_clinical_adt_spell_update
(pool, cr)[source]¶ Represents the admission update operation in the patient management system. (A08 Message)
-
complete
(*args, **kwargs)[source]¶ Overwrites the target
spell
information and then callscomplete
.If location information needs to be updated a new instance of
movement
is created and completed.If the new location is located in a different Ward than the current spell location, a
policy trigger
will be kicked off. As that is technically a transfer movement.Returns: True
Return type: bool
-
submit
(*args, **kwargs)[source]¶ Checks the submitted data and then calls
submit
.If a
location
of ward usage with the provided code does not exist, it will create a new one.Due to this behaviour the user submitting the data must be related to a
point of service
linked to a validlocation
instance of pos type, as new Wards will need to be assigned to a point of service.Returns: True
Return type: bool
-
API¶
api.py
defines the core methods to interface with the
adt
module.
API¶
-
class
api.
nh_clinical_api
(pool, cr)[source]¶ Core API for nh_clinical
-
admit
(*args, **kwargs)[source]¶ Admits a patient into a specified location.
Parameters: Returns: True
Return type:
-
admit_update
(*args, **kwargs)[source]¶ Updates the spell information of a patient.
Parameters: Returns: True
Return type:
-
cancel_admit
(*args, **kwargs)[source]¶ Cancels the open admission of the patient.
Parameters: hospital_number (str) – hospital number of the patient Returns: True
Return type: bool
-
cancel_discharge
(*args, **kwargs)[source]¶ Cancels the last discharge of a patient.
Parameters: hospital_number (str) – hospital number of the patient Returns: True
Return type: bool
-
cancel_transfer
(*args, **kwargs)[source]¶ Cancels the last transfer of a patient.
Parameters: hospital_number (str) – hospital number of the patient Returns: True
Return type: bool
-
check_activity_access
(*args, **kwargs)[source]¶ Verifies if an
activity
is assigned to auser
.Parameters: Returns: True
if user is assigned. OtherwiseFalse
Return type:
-
merge
(*args, **kwargs)[source]¶ Merges a specified patient into a patient.
Parameters: Returns: True
Return type:
-
register
(*args, **kwargs)[source]¶ Registers a new patient in the system.
Parameters: - hospital_number (str) – hospital number of the patient
- data – may contain the following keys:
patient_identifier
,family_name
,given_name
,middle_names
,dob
,gender
andsex
Returns: True
Return type:
-
Auditing¶
auditing.py
defines some activity types to audit some specific
operations that are not represented by any other objects in the system
but still need to be audittable.
Activate Location¶
Deactivate Location¶
User Responsibility Allocation¶
-
class
auditing.
nh_clinical_user_responsibility_allocation
(pool, cr)[source]¶ This activity is meant to audit the allocation of responsibility of users to locations.
-
complete
(*args, **kwargs)[source]¶ Calls
complete
and then sets updates thelocation_ids
list for the user.If the user is in the HCA or Nurse user groups the method will automatically assign every location child of the ones provided on top of them. If the user is not within those user groups, that will also be done when the location is not of ward usage.
Returns: True
Return type: bool
-
get_allocation_locations
(*args, **kwargs)[source]¶ Get a list locations to allocate the user to :param cr: Cursor :param uid: User ID to perform operation with :param allocation_obj: The activity data ref from a user responsibility allocation :param context: Odoo context :return: list of location ids
-
Context¶
Defines context.
Context¶
Devices¶
devices.py
defines a set of objects and activity types to deal with
clinical devices management within the Hospital.
Device¶
-
class
devices.
nh_clinical_device
(pool, cr)[source]¶ Represents a physical instance of a device, which will have its own unique serial number.
-
category_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.
-
is_available
¶
-
name_get
() → [(id, name), ...][source]¶ Returns a textual representation for the records in
self
. By default this is the value of thedisplay_name
field.Returns: list of pairs (id, text_repr)
for each recordsReturn type: list(tuple)
-
serial_number
¶ Basic string field, can be length-limited, usually displayed as a single-line string in clients
Parameters:
-
type_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.
-
Category¶
-
class
devices.
nh_clinical_device_category
(pool, cr)[source]¶ Represents a group of
device types
that share the same category / specialty (i.e. surgical).
Connect¶
Disconnect¶
-
class
devices.
nh_clinical_device_disconnect
(pool, cr)[source]¶ Represents the action of disconnecting a device from a patient.
-
complete
(*args, **kwargs)[source]¶ Completes the related
device session
and then callscomplete
.Returns: True
Return type: bool
-
submit
(*args, **kwargs)[source]¶ Checks the submitted data is correct, finding the last started
device session
for the provided device or device type (if the specific device is not provided) and callssubmit
.Returns: True
Return type: bool
-
Session¶
-
class
devices.
nh_clinical_device_session
(pool, cr)[source]¶ Represents a period of time where an instance of
device
ordevice type
(the specific physical instance of the device is not required) is being used during aspell
-
complete
(*args, **kwargs)[source]¶ Sets the specified
device
as available and callscomplete
.Returns: True
Return type: bool
-
Groups¶
Extends Odoo’s res_groups
and ir_model_access
.
Location¶
Location¶
-
class
location.
nh_clinical_location
(pool, cr)[source]¶ Represents a location where a patient may be located or an activity may take place.
There are different types of locations. The most common usage is to have a hospital as a parent location to a group of wards where each ward is a parent to several beds. The bed location is where the patient can be placed.
-
create
(*args, **kwargs)[source]¶ Extends Odoo’s
create()
method. Updatesnh_clinical_location
to write context_ids field.Parameters: vals (dict) – values to update the records with Returns: True
Return type: bool
-
get_available_location_ids
(*args, **kwargs)[source]¶ Gets a list of available locations, only returning beds unless specified otherwise.
Parameters: usages – location type ( ward
,bed
, etc.) of available locationsReturns: location ids of available locations (default usage is bed
)iReturn type: list
-
get_by_code
(*args, **kwargs)[source]¶ Gets the location’s id by the location’s code. Creates a location if
auto_create
isTrue
and the location doesn’t exist.Parameters: Returns: location id of the location.
False
ifauto_create
isTrue
and location doesn’t exist, the location id of new ward location created. OtherwiseFalse
Return type:
-
get_closest_parent_id
(*args, **kwargs)[source]¶ Gets a location’s closest ancestor (parent) location id of a particular usage. Returns
False
if no such location exists.Parameters: - location_id (int) – location id
- usage – usage of location.
See
nh_clinical_location
Returns: location id of the ancestor. Otherwise
False
Return type:
-
is_child_of
(*args, **kwargs)[source]¶ Checks if a location is a child of another location.
Parameters: Returns: the dictionary
location_id
(key) and a string containing location name and parent location name (value) OtherwiseFalse
is returned.Return type:
-
onchange_usage
(*args, **kwargs)[source]¶ Hospital locations don’t have parent locations and they are always Point of Service type.
-
Operations¶
operations.py
defines a set of activity types to deal with
hospital administrative tasks like patient movements, admissions,
discharge, etc.
Admission¶
-
class
operations.
nh_clinical_patient_admission
(pool, cr)[source]¶ Represents the action of a patient visiting the Hospital and being admitted to one of the Wards.
-
cancel
(*args, **kwargs)[source]¶ Calls
cancel
and then cancels everyactivity
related to the admission, including the current patientspell
.Returns: True
Return type: bool
-
complete
(*args, **kwargs)[source]¶ Calls
complete
and then creates and starts a newspell
for the selected patient.It will also create and complete a
movement
to the admitted location.This operation kicks off a
policy trigger
as actions may need to take place after the patient is admitted into the Hospital.Returns: True
Return type: bool
-
Discharge¶
-
class
operations.
nh_clinical_patient_discharge
(pool, cr)[source]¶ Represents the action of a patient leaving the Hospital after completing his or her visit for any reason.
-
cancel
(*args, **kwargs)[source]¶ Calls
cancel
and then opens (changes state to started) the last completed patientspell
.It will also create and complete a
movement
to the bed location the patient was previously located if it is still available. If not, the patient will be moved to the corresponding ward location parent of that bed.This operation will kick off a
policy trigger
as this is technically equivalent to an admission back to the Hospital.Returns: True
Return type: bool
-
complete
(*args, **kwargs)[source]¶ Calls
complete
and then creates and completes a newmovement
to the discharge location, which is a virtual location representing the patient is no longer in the Hospital.It will also complete the current
spell
.Returns: True
Return type: bool
-
Follow¶
-
class
operations.
nh_clinical_patient_follow
(pool, cr)[source]¶ Represents the action to invite another user to follow a group of
patients
adding visibility for those patients even when the invited user does not have a responsibility towards them.-
complete
(*args, **kwargs)[source]¶ Calls
complete
and then updates thefollowing_ids
list for the assigneduser
.It will also call
update activity
for all notcompleted
orcancelled
activities related to the list of patients.Returns: True
Return type: bool
-
Move¶
-
class
operations.
nh_clinical_patient_move
(pool, cr)[source]¶ Represents any physical patient movement between different instances of
location
.It is meant to work as an audit mechanism to track any patient movements within the Hospital.
Placement¶
-
class
operations.
nh_clinical_patient_placement
(pool, cr)[source]¶ Represents the action of assigning a bed usage
location
to an admitted patient.-
complete
(*args, **kwargs)[source]¶ Calls
complete
and then creates and completes amovement
to the selected bed usage location.This operation will kick off a policy trigger as Hospitals usually start observations or measurements on patients after this action is taken.
Returns: True
Return type: bool
-
get_activity_location_id
(*args, **kwargs)[source]¶ Returns the
location
where the patient is waiting to be placed, usually of ward usage.Returns: location
idReturn type: int
-
get_form_description
(*args, **kwargs)[source]¶ - Returns a description in dictionary format of the input fields that would be required in the user gui when completing this action.
Parameters: patient_id (int) – patient
idReturns: a list of dictionaries Return type: list
-
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.
-
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.
-
pos_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.
-
reason
¶ 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
-
submit
(*args, **kwargs)[source]¶ Checks the submitted data is correct and then calls
submit
.Returns: True
Return type: bool
-
suggested_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.
-
Swap Beds¶
-
class
operations.
nh_clinical_patient_swap_beds
(pool, cr)[source]¶ Represents the simultaneous movement of two patients that are located in bed usage
location
instances. The patients will end placed in the location the other patient was in.It is meant to be used to move patients specially when there are no available beds to use as a buffer, although it can be used any time.
Transfer¶
-
class
operations.
nh_clinical_patient_transfer
(pool, cr)[source]¶ Represents the action of a patient being moved to a ward usage
location
within the Hospital.-
cancel
(*args, **kwargs)[source]¶ Calls
cancel
and then if the origin ward usage location is different from where the current patient location is located, a newmovement
is created and completed.If the origin location was of bed usage then the movement will assign that location back to the patient if it is still available.
This operation will kick off a
policy trigger
if the movement takes place as this is technically equivalent to an admission into the new Ward.Returns: True
Return type: bool
-
complete
(*args, **kwargs)[source]¶ Calls
complete
and then if the destination ward usage location is different from where the current patient location is located, a newmovement
is created and completed.This operation will kick off a
policy trigger
if the movement takes place as this is technically equivalent to an admission into the new Ward.Returns: True
Return type: bool
-
get_last
(*args, **kwargs)[source]¶ Checks if there is a completed transfer for the provided patient and returns the last one.
Parameters: exception (str) – ‘True’ will raise exception when found. ‘False’ when not. Returns: transfer
idReturn type: int
-
Partner¶
partner.py
extends Odoo classes for doctor and role
functionality.
Partner Extension¶
-
class
partner.
res_partner
(pool, cr)[source]¶ Extends Odoo’s res_partner which defines a business entity i.e. customer, supplier, employer.
Extension adds boolean field
doctor
andcode
for doctor type.Please note: must precede
res_company
(below) to ensure these fields are added to the model in the database.
Partner Category Extension¶
-
class
partner.
res_partner_category_extension
(pool, cr)[source]¶ Extends Odoo’s res_partner_category to add functionality for roles.
Creates many-to-many relationship between categories (roles) and groups, allowing a relation between each role and corresponding group(s).
An example would be the role ‘Registrar’ belonging to groups base, doctor, senior doctor and registrar groups.
-
get_child_of_ids
(*args, **kwargs)[source]¶ Gets all child category ids of parent, recursively.
Parameters: id (int) – parent id Returns: parent id follow by child ids Return type: list
-
group_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)
-
Partner Title Extension¶
-
class
partner.
res_partner_title_extension
(pool, cr)[source]¶ Extends Odoo’s res_partner_title to include method
get_title_by_name()
.-
get_title_by_name
(*args, **kwargs)[source]¶ Searches for the title by name. If the title does not exist, a new title is created by default.
Parameters: - title (string) – title of partner (‘Mr’, ‘Dr, ‘Miss’, etc.)
- create (
bool
[default isTrue
]) – whenTrue
, the title will be created if the title doesn’t exist
Returns: id of title
Return type:
-
Patient¶
Patient¶
-
class
patient.
nh_clinical_patient
(pool, cr)[source]¶ Represents a patient.
-
check_data
(*args, **kwargs)[source]¶ Default will check if patient exists. Either hospital number (
other_identifier
) or NHS number (patient_identifier
) is required.If
create
isTrue
, then bothother_identifier
andpatient_identifier
must be unique. Otherwise either or both identifiers will be accepted indata
parameter.If
title
is indata
parameter, then method changes title to res.partner.title id. Iftitle
is not included, a new title will be created.Parameters: Raises: except_orm
ifexception
arguments isTrue
and if patient doesn’t exists or if duplicate patients are foundReturns: True
if successful. OtherwiseFalse
Return type:
-
check_hospital_number
(*args, **kwargs)[source]¶ Checks for a patient by hospital number.
Parameters: - hospital_number (string) – patient’s hospital number
- exception (bool) –
True
orFalse
. Default isFalse
Returns: True
if patient exists. OtherwiseFalse
Return type: Raises: except_orm
ifexception
isTrue
and if the patient exists or if the patient does not
-
check_nhs_number
(*args, **kwargs)[source]¶ Checks for patient by provided NHS Number.
Parameters: - nhs_number (string) – patient’s nhs number
- exception (bool) –
True
orFalse
. Default isFalse
Returns: True
if patient exists. OtherwiseFalse
Return type: Raises: except_orm
ifexception
isTrue
and if the patient exists or if the patient does not
-
create
(*args, **kwargs)[source]¶ Extends Odoo’s
create()
to writename
,other_identifier
andpatient_identifier
upon creation.Returns: True
if createdReturn 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:
-
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)
-
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.
-
given_name
¶ Basic string field, can be length-limited, usually displayed as a single-line string in clients
Parameters:
-
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: 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:
-
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:
-
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:
-
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.
-
unlink
(*args, **kwargs)[source]¶ “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
-
POS¶
Defines POS class and extends Odoo’s res_company.
Spell¶
Defines the Spell class.
Spell¶
-
class
spell.
nh_clinical_spell
(pool, cr)[source]¶ A spell represents the time between a patient admission to the hospital and the patient discharge. It will be open as long as the patient remains in the hospital and will be connected to every activity related to that patient during this period of time.
-
code
¶ Basic string field, can be length-limited, usually displayed as a single-line string in clients
Parameters:
-
con_doctor_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)
-
create
(*args, **kwargs)[source]¶ Checks the patient does not have already an open spell and then calls
create
Returns: spell
idReturn type: int
-
get_activity_user_ids
(*args, **kwargs)[source]¶ Returns a list of user ids that would have visibility or responsibility over the specified spell activity
Returns: res.users ids Return type: list
-
get_by_patient_id
(*args, **kwargs)[source]¶ Checks if there is a started spell for the provided
patient
. Returns false if there are no spells found.If the patient has had a previous spell that has now ended, no spells will be found by this method and it will return False. This is because activity
state == completed
when a spell has ended and so is not picked up by the search used in this method which containsstate == started
.Parameters: Returns: spell
idReturn type:
-
get_spell_activity_by_patient_id
(*args, **kwargs)[source]¶ Get the nh.clinical.spell record for the given patient.
Parameters: patient_id ('nh.clinical.patient' record) – Returns: spell if it exists, otherwise None Return type: ‘nh.clinical.spell’ record
-
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.
-
move_date
¶
-
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.
-
pos_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.
-
ref_doctor_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)
-
start_date
¶
-
transferred_user_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)
-
User¶
Extends Odoo’s res_users.
Change Password¶
Doctor¶
-
class
user.
nh_clinical_doctor
(pool, cr)[source]¶ Represents a doctor.
-
create
(*args, **kwargs)[source]¶ Extends Odoo’s
create()
to updatedoctor_id
field inres_users
.Returns: True
if createdReturn type: bool
-
evaluate_doctors_dict
(*args, **kwargs)[source]¶ Evaluates doctors, checking for a doctor before creating a new doctor if it doesn’t exist.
Parameters: data (dict) – must contain doctors
key. Its value will be a list of dictionaries which must contain the keyscode
,gender
,gmc
andtype
. It many containtitle
.Returns: True
if either it finds a doctor or creates a new doctor. OtherwiseFalse
Return type: bool
-
Clinical Specialty¶
Users¶
-
class
user.
res_users
(pool, cr)[source]¶ Extends Odoo’s
res_users
to include point of service, parent locations of responsibility, following patients and the related doctor for the user.-
check_pos
(*args, **kwargs)[source]¶ Checks if user has an assigned point of service (POS).
Parameters: Returns: if exception parameter is
False
, then returnsTrue
if POS is defined. OtherwiseFalse
. If isTrue
, them returnsTrue
if POS is defined. If POS is undefined, thenosv.except_osv
is raised
-
create
(*args, **kwargs)[source]¶ Extends Odoo’s
create()
to update fieldsgroup_ids
anddoctor_id
.Parameters: vals (dict) – values to initialise the new record Returns: id of created record Return type: int
-
doctor_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.
-
following_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)
-
get_groups_string
(*args, **kwargs)[source]¶ Returns: list of NH Clinical user groups for UID in string format
-
location_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)
-
name_get
(*args, **kwargs)[source]¶ Gets the names of users.
Parameters: ids (list or int) – user ids Returns: user names Return type: list
-
pos_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.
-
pos_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)
-
update_doctor_status
(*args, **kwargs)[source]¶ Updates
doctor
field inres_partner
if user is a doctor.Parameters: ids (list) – user ids Returns: True
Return type: bool
-
NH Clinical LDAP Extension¶
auth.ldap Extension¶
-
class
auth_ldap_extension.
NHClinicalLDAPExtension
(pool, cr)[source]¶