<commit_before># -*- coding: utf-8 -*-
# Copyright 2008 <NAME> <<EMAIL>>
# Copyright 2016 LasLabs Inc.
# License GPL-3.0 or later (http://www.gnu.org/licenses/gpl.html).

from datetime import date, datetime
from dateutil.relativedelta import relativedelta

from odoo import _, api, fields, models
from odoo.modules import get_module_resource
# from odoo.exceptions import ValidationError, UserError
from odoo.exceptions import UserError


class Patient(models.Model):

    _name = 'clv.patient'
    _description = 'Patient'
    _inherit = 'clv.abstract.entity'

    code = fields.Char(string='Person Code', required=False)

    # age = fields.Char(
    #     compute='_compute_age',
    # )
    # age_years = fields.Integer(
    #     string="Age (years old)",
    #     compute='_compute_age',
    #     search='_search_age',
    # )
    # identification_code = fields.Char(
    #     string='Internal Identification',
    #     help='Patient Identifier provided by the Health Center.'
    #          '(different from the Social Security Number)',
    # )
    # general_info = fields.Text(
    #     string='General Information',
    # )
    # is_deceased = fields.Boolean(
    #     compute='_compute_is_deceased',
    # )
    # marital_status = fields.Selection([
    #     ('s', 'Single'),
    #     ('m', 'Married'),
    #     ('w', 'Widowed'),
    #     ('d', 'Divorced'),
    #     ('x', 'Separated'),
    #     ('z', 'law marriage'),
    # ], )
    # # is_pregnant = fields.Boolean(
    #     help='Check this if the patient if pregnant',
    # )
    # date_death = fields.Datetime(
    #     string='Deceased Date',
    # )

    # @api.multi
    # def _compute_age(self):
    #     """ Age computed depending based on the birth date in the
    #      membership request.
    #     """
    #     now = datetime.now()
    #     for record in self:
    #         if record.birthdate_date:
    #             birthdate_date = fields.Datetime.from_string(
    #                 record.birthdate_date,
    #             )
    #             if record.is_deceased:
    #                 date_death = fields.Datetime.from_string(record.date_death)
    #                 delta = relativedelta(date_death, birthdate_date)
    #                 is_deceased = _(' (deceased)')
    #             else:
    #                 delta = relativedelta(now, birthdate_date)
    #                 is_deceased = ''
    #             years_months_days = '%d%s %d%s %d%s%s' % (
    #                 delta.years, _('y'), delta.months, _('m'),
    #                 delta.days, _('d'), is_deceased
    #             )
    #             years = delta.years
    #         else:
    #             years_months_days = _('No DoB')
    #             years = False
    #         record.age = years_months_days
    #         if years:
    #             record.age_years = years

    # @api.multi
    # def _compute_is_deceased(self):
    #     for record in self:
    #         record.is_deceased = bool(record.date_death)

    # @api.multi
    # @api.constrains('is_pregnant', 'gender')
    # def _check_is_pregnant(self):
    #     for record in self:
    #         if record.is_pregnant and record.gender != 'female':
    #             raise ValidationError(_(
    #                 'Invalid selection - Only a `Female` may be pregnant.',
    #             ))

    @api.model
    def _create_vals(self, vals):
        vals = super(Patient, self)._create_vals(vals)
        if not vals.get('identification_code'):
            Seq = self.env['ir.sequence']
            vals['identification_code'] = Seq.sudo().next_by_code(
                self._name,
            )<commit_msg>[IMP] clv_patient (IMP models/patient.py)<commit_after># -*- coding: utf-8 -*-
# Copyright 2008 <NAME> <<EMAIL>>
# Copyright 2016 LasLabs Inc.
# License GPL-3.0 or later (http://www.gnu.org/licenses/gpl.html).

from datetime import date, datetime
from dateutil.relativedelta import relativedelta

from odoo import _, api, fields, models
from odoo.modules import get_module_resource
# from odoo.exceptions import ValidationError, UserError
from odoo.exceptions import UserError


class Patient(models.Model):

    _name = 'clv.patient'
    _description = 'Patient'
    _inherit = 'clv.abstract.entity'

    code = fields.Char(string='Person Code', required=False)

    # age = fields.Char(
    #     compute='_compute_age',
    # )
    # age_years = fields.Integer(
    #     string="Age (years old)",
    #     compute='_compute_age',
    #     search='_search_age',
    # )
    # identification_code = fields.Char(
    #     string='Internal Identification',
    #     help='Patient Identifier provided by the Health Center.'
    #          '(different from the Social Security Number)',
    # )
    # general_info = fields.Text(
    #     string='General Information',
    # )
    # is_deceased = fields.Boolean(
    #     compute='_compute_is_deceased',
    # )
    # marital_status = fields.Selection([
    #     ('s', 'Single'),
    #     ('m', 'Married'),
    #     ('w', 'Widowed'),
    #     ('d', 'Divorced'),
    #     ('x', 'Separated'),
    #     ('z', 'law marriage'),
    # ], )
    # # is_pregnant = fields.Boolean(
    #     help='Check this if the patient if pregnant',
    # )
    # date_death = fields.Datetime(
    #     string='Deceased Date',
    # )

    # @api.multi
    # def _compute_age(self):
    #     """ Age computed depending based on the birth date in the
    #      membership request.
    #     """
    #     now = datetime.now()
    #     for record in self:
    #         if record.birthdate_date:
    #             birthdate_date = fields.Datetime.from_string(
    #                 record.birthdate_date,
    #             )
    #             if record.is_deceased:
    #                 date_death = fields.Datetime.from_string(record.date_death)
    #                 delta = relativedelta(date_death, birthdate_date)
    #                 is_deceased = _(' (deceased)')
    #             else:
    #                 delta = relativedelta(now, birthdate_date)
    #                 is_deceased = ''
    #             years_months_days = '%d%s %d%s %d%s%s' % (
    #                 delta.years, _('y'), delta.months, _('m'),
    #                 delta.days, _('d'), is_deceased
    #             )
    #             years = delta.years
    #         else:
    #             years_months_days = _('No DoB')
    #             years = False
    #         record.age = years_months_days
    #         if years:
    #             record.age_years = years

    # @api.multi
    # def _compute_is_deceased(self):
    #     for record in self:
    #         record.is_deceased = bool(record.date_death)

    # @api.multi
    # @api.constrains('is_pregnant', 'gender')
    # def _check_is_pregnant(self):
    #     for record in self:
    #         if record.is_pregnant and record.gender != 'female':
    #             raise ValidationError(_(
    #                 'Invalid selection - Only a `Female` may be pregnant.',
    #             ))

    @api.model
    def _create_vals(self, vals):
        vals = super(Patient, self)._create_vals(vals)
        # if not vals.get('identification_code'):
        #     Seq = self.env['ir.sequence']
        #     vals['identification_code'] = Seq.sudo().next_by_code(
        #         self._name,
        #     )
{'fraction_non_alphanumeric': 0.12653228003268865, 'fraction_numerical': 0.0029964587305911197, 'mean_word_length': 1.8852652259332023, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6586395', 'n_tokens_mistral': 2361, 'n_tokens_neox': 2252, 'n_words': 465}