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 (http://www.gnu.org/licenses/gpl.html).
from . import models
# Copyright 2011-2020 GNU Solidario
# Copyright 2020 LabViv.
# License GPL-3.0 or later (http://www.gnu.org/licenses/gpl.html).
{
'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': '13.0.0.0.1',
'category': 'Medical',
'depends': [
'base',
'commed_base',
'commed_procedure',
'commed_disease',
'commed_genetics',
'commed_lab',
'commed_prescription',
'commed_evaluation'
],
'author': 'LabViv',
'website': "https://git.labviv.org.ve/",
'license': 'GPL-3',
'data': [
'security/ir.model.access.csv',
'views/page_of_life.xml',
],
'installable': True,
'maintainer': 'Kaylenis Mardach <kaykmm@yandex.com>'
}
# Copyright 2011-2020 GNU Solidario
# Copyright 2020 LabViv
# License GPL-3.0 or later (http://www.gnu.org/licenses/gpl.html).
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 (http://www.gnu.org/licenses/gpl.html).
from datetime import datetime
from odoo import models, fields, api
from odoo.addons.commed_evaluation.models.commed_evaluation import \
CommedPatientEvaluation
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', self.page_date.date()
)
person = fields.Many2one(
comodel_name='commed.patient',
string='Person',
required=True,
domain=[('is_company', '=', False)]
)
# TODO: Secuencia para números de página
page = fields.Char('Page', help="Page of Life")
page_date = fields.Datetime(
string='Date',
default=datetime.now(),
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 \
moment'
)
age = fields.Char(
string="Age (computed)",
default=age_at_page,
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',
required=True
)
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',
sort=False
)
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',
sort=False
)
relevance = fields.Selection(
[
('informational', 'Informational'),
('important', 'Important'),
('critical', 'Critical'),
],
string='Relevance',
sort=False,
required=True
)
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('commed.center', '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
@api.onchange('health_condition')
def on_change_health_condition(self):
if (self.health_condition):
self.health_conditionn_code = self.health_condition.code
self.health_condition_text = self.health_condition.name
# Get the text representation of the procedure
@api.onchange('procedure')
def on_change_procedure(self):
if (self.procedure):
self.procedure_code = self.procedure.name
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': genetic_info.patient.name.id,
# '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 genetic_info.healthprof.name.rec_name,
# }
# 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
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_commed_pol,access_commed_pol,model_commed_pol,commed_base.group_commed_user,1,1,1,0
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2011-2020 GNU Solidario
Copyright 2020 LabViv
License GPL-3.0 or later (http://www.gnu.org/licenses/gpl.html).
-->
<odoo>
<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">
<form>
<notebook>
<page>
<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"/>
<newline/>
<label for="age"/>
<field name="age"/>
<label for="institution"/>
<field name="institution"/>
<newline/>
<label for="summary"/>
<field name="summary" colspan="4"/>
</group>
</page>
<newline/>
<separator string="Context" id="separator_context" colspan="4"/>
<newline/>
<page>
<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>
</page>
<newline/>
<page>
<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"/>
<newline/>
<label for="procedure"/>
<field name="procedure"/>
<field name="procedure_text"/>
<label for="procedure_code"/>
<field name="procedure_code"/>
<newline/>
<label for="gene"/>
<field name="gene"/>
<label for="natural_variant"/>
<field name="natural_variant"/>
<label for="phenotype"/>
<field name="phenotype"/>
</group>
</page>
<newline/>
<separator string="Extended Information" id="separator_extra_info" colspan="4"/>
<newline/>
<page>
<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"/>
</group>
</page>
</notebook>
</form>
</field>
</record>
<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">
<tree>
<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"/>
</tree>
</field>
</record>
<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>
<!--
<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>
<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"/>
</record>
-->
<menuitem
id="commed_bol"
name="Books of Life"
parent="commed_base.commed_root"
web_icon="health_page_of_life,static/description/icon.png"
groups="commed_base.group_commed_user"
/>
<menuitem
id="commed_pol"
name="Page of Life"
parent="commed_bol"
action="commed_action_pol"
groups="commed_base.group_commed_user"
/>
</odoo>
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