Commit 475c6cca authored by Ángel Ramírez Isea's avatar Ángel Ramírez Isea
Browse files

refactor: Cambiar health_page_of_life por commed_pol.

parent d7223ba1
# Copyright 2011-2020 GNU Solidario
# Copyright 2020 LabViv.
# License GPL-3.0 or later (
from . import models
# Copyright 2011-2020 GNU Solidario
# Copyright 2020 LabViv.
# License GPL-3.0 or later (
'name': 'Community Medical - Page of Live',
'description': """Page of Life, ported from GNU Health. Records relevant
events for a person:
- Demographical.
- Biographical.
- Medical.
- Social.""",
'version': '',
'category': 'Medical',
'depends': [
'author': 'LabViv',
'website': "",
'license': 'GPL-3',
'data': [
'installable': True,
'maintainer': 'Kaylenis Mardach <>'
# Copyright 2011-2020 GNU Solidario
# Copyright 2020 LabViv
# License GPL-3.0 or later (
from . import page_of_life
\ No newline at end of file
# Copyright 2011-2020 GNU Solidario
# Copyright 2020 LabViv
# License GPL-3.0 or later (
from datetime import datetime
from odoo import models, fields, api
from odoo.addons.commed_evaluation.models.commed_evaluation import \
class CommedPol(models.Model):
_name = 'commed.pol'
_descripcion = 'Page of Life'
_sql_constraints = [(
'page_uniq', 'unique(page)', 'The page must be unique!'
def age_at_page(self):
if (self.person.dob and self.page_date):
return CommedPatientEvaluation.compute_age_from_dates(
self.person.dob, None, None, None, 'age',
person = fields.Many2one(
domain=[('is_company', '=', False)]
# TODO: Secuencia para números de página
page = fields.Char('Page', help="Page of Life")
page_date = fields.Datetime(
help='Date of this page/event. By default it takes the current \
date/time when creating the event, but it can be a past date and it \
can also be empty, or used in combination with the person age at that \
age = fields.Char(
string="Age (computed)",
help="Age at the moment of this page of life"
page_type = fields.Selection(
('biographical', 'Biographical'),
('demographical', 'Demographical'),
('medical', 'Medical'),
('social', 'Social')
string='Page type',
medical_context = fields.Selection(
('health_condition', 'Medical condition'),
('encounter', 'Encounter'),
('procedure', 'Procedure'),
('immunization', 'Immunization'),
('prescription', 'Prescription'),
('surgery', 'Surgery'),
('hospitalization', 'Hospitalization'),
('lab', 'Lab'),
('dx_imaging', 'Dx imaging'),
('genetics', 'Genetics'),
('family', 'Family history'),
('birth', 'Birth'),
('death', 'Death'),
string='Medical Context',
social_context = fields.Selection(
('social_gradient', 'Social Gradient/Equity'),
('stress', 'Stress'),
('early_life_development', 'Early life development'),
('social_exclusion', 'Social exclusion'),
('working_conditions', 'Working conditions'),
('education', 'Education'),
('physical_environment', 'Physical environment'),
('unemployment', 'Unemployment'),
('social_support', 'Social support'),
('addiction', 'Addiction'),
('food', 'Food'),
('transport', 'Transport'),
('health_services', 'Health services'),
('uninsured', 'Uninsured'),
('family_functionality', 'Family functionality'),
('family_violence', 'Family violence'),
('bullying', 'Bullying'),
('war', 'War'),
string='Social Context',
relevance = fields.Selection(
('informational', 'Informational'),
('important', 'Important'),
('critical', 'Critical'),
health_condition = fields.Many2one('commed.pathology', 'Health Condition')
health_condition_code = fields.Char(string="Code")
health_condition_text = fields.Char(string="Health Condition")
procedure = fields.Many2one('commed.procedure', 'Procedure')
procedure_text = fields.Char(string="Procedure")
procedure_code = fields.Char(string="Procedure Code")
gene = fields.Char("Gene", help="Gene/protein")
natural_variant = fields.Char(string="Natural variant")
phenotype = fields.Char(string="Phenotype")
summary = fields.Char(string="Summary")
info = fields.Text(string="Extended Information")
institution = fields.Many2one('', 'Institution')
node = fields.Char(string="Node")
author = fields.Char(string="Author")
author_acct = fields.Char(string="Author account")
# Get the text representation of the health condition
def on_change_health_condition(self):
if (self.health_condition):
self.health_conditionn_code = self.health_condition.code
self.health_condition_text =
# Get the text representation of the procedure
def on_change_procedure(self):
if (self.procedure):
self.procedure_code =
self.procedure_text = self.procedure.description
@api.onchange('person', 'page_date')
def on_change_with_age(self):
if (self.person and self.page_date):
self.age = self.age_at_page()
# def create_genetics_pol(self,genetic_info):
# """ Adds an entry in the person PoL related to genetic finding"""
# Pol = self.env('commed.pol')
# pol = []
# vals = {
# 'page': str(uuid4()),
# 'person':,
# 'age': genetic_info.onset and str(genetic_info.onset) + 'y' or '',
# 'page_type':'medical',
# 'medical_context':'genetics',
# 'relevance':'important',
# 'gene':genetic_info.disease_gene.rec_name,
# 'natural_variant':genetic_info.natural_variant and \
# genetic_info.natural_variant.aa_change,
# 'summary': genetic_info.notes,
# 'author': genetic_info.healthprof and,
# }
# if (genetic_info.variant_phenotype):
# vals['health_condition_text'] = vals['health_condition_text'] = \
# genetic_info.variant_phenotype.phenotype.rec_name
# pol.append(vals)
# Pol.create(pol)
# def create(self, vals):
# # Execute first the creation of PoL
# genetic_info = super(CommedPatientGeneticRisk, self).create(vals)
# self.create_genetics_pol(genetic_info[0])
# return genetic_info
<?xml version="1.0" encoding="utf-8"?>
Copyright 2011-2020 GNU Solidario
Copyright 2020 LabViv
License GPL-3.0 or later (
<record model="ir.ui.view" id="commed_pol_form">
<field name="name">commed.pol.form</field>
<field name="model">commed.pol</field>
<field name="type">form</field>
<field name="arch" type="xml">
<group id="pol_header" colspan="4" col="8">
<label for="person"/>
<field name="person"/>
<label for="page_type"/>
<field name="page_type"/>
<label for="page_date"/>
<field name="page_date"/>
<label for="relevance"/>
<field name="relevance"/>
<label for="age"/>
<field name="age"/>
<label for="institution"/>
<field name="institution"/>
<label for="summary"/>
<field name="summary" colspan="4"/>
<separator string="Context" id="separator_context" colspan="4"/>
<group id="pol_body" colspan="4" col="6">
<label for="medical_context"/>
<field name="medical_context"/>
<label for="social_context"/>
<field name="social_context"/>
<group id="pol_medical" colspan="4" col="6">
<label for="health_condition"/>
<field name="health_condition"/>
<field name="health_condition_text"/>
<label for="health_condition_code"/>
<field name="health_condition_code"/>
<label for="procedure"/>
<field name="procedure"/>
<field name="procedure_text"/>
<label for="procedure_code"/>
<field name="procedure_code"/>
<label for="gene"/>
<field name="gene"/>
<label for="natural_variant"/>
<field name="natural_variant"/>
<label for="phenotype"/>
<field name="phenotype"/>
<separator string="Extended Information" id="separator_extra_info" colspan="4"/>
<field name="info" colspan="4"/>
<group id="pol_footer" colspan="4" col="10">
<label for="page"/>
<field name="page"/>
<label for="author"/>
<field name="author"/>
<label for="author_acct"/>
<field name="author_acct"/>
<label for="node"/>
<field name="node"/>
<record model="ir.ui.view" id="commed_pol_tree">
<field name="name">commed.pol.tree</field>
<field name="model">commed.pol</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<field name="page"/>
<field name="person"/>
<field name="relevance"/>
<field name="page_date" widget="date"/>
<field name="age"/>
<field name="page_type"/>
<field name="medical_context"/>
<field name="social_context"/>
<field name="summary"/>
<field name="node"/>
<record model="ir.actions.act_window" id="commed_action_pol">
<field name="name">Pages of life</field>
<field name="res_model">commed.pol</field>
<field name="view_mode">tree,form</field>
<record model="ir.ui.view" id="act_pol_tree_view">
<field name="sequence" eval="10"/>
<field name="view" ref="commed_pol_tree"/>
<field name="act_window" ref="commed_action_pol"/>
<record model="ir.ui.view" id="act_pol_form_view">
<field name="sequence" eval="20"/>
<field name="view" ref="commed_pol_form"/>
<field name="act_window" ref="commed_action_pol"/>
name="Books of Life"
name="Page of Life"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment