|
@@ -0,0 +1,293 @@
|
|
|
+# -*- coding: utf-8 -*-
|
|
|
+# License, author and contributors information in:
|
|
|
+# __openerp__.py file at the root folder of this module.
|
|
|
+
|
|
|
+from openerp import api, models, fields
|
|
|
+from openerp.exceptions import ValidationError, except_orm, Warning, RedirectWarning
|
|
|
+import logging
|
|
|
+
|
|
|
+_log = logging.getLogger(__name__)
|
|
|
+
|
|
|
+
|
|
|
+class MedicClinic(models.Model):
|
|
|
+ _name = 'clinic.history'
|
|
|
+ _description = 'Historial clínica médica'
|
|
|
+ _inherit = ['mail.thread', 'ir.needaction_mixin']
|
|
|
+
|
|
|
+ def _get_user(self):
|
|
|
+ return self.env.uid
|
|
|
+
|
|
|
+ def _get_number(self):
|
|
|
+ return self.env['ir.sequence'].get('clinic.history') or '*'
|
|
|
+
|
|
|
+ name = fields.Char(
|
|
|
+ string=u'Codigo',
|
|
|
+ readonly=True,
|
|
|
+ default=_get_number
|
|
|
+ )
|
|
|
+ user_id = fields.Many2one(
|
|
|
+ comodel_name='res.users',
|
|
|
+ string='Médico',
|
|
|
+ default=_get_user
|
|
|
+ )
|
|
|
+ partner_id = fields.Many2one(
|
|
|
+ comodel_name='res.partner',
|
|
|
+ string='Cliente'
|
|
|
+ )
|
|
|
+ paciente_id = fields.Many2one(
|
|
|
+ comodel_name='res.partner',
|
|
|
+ string='Paciente'
|
|
|
+ )
|
|
|
+ lugar_visita = fields.Selection([('domicilio','A domicilio'),('via','Vía pública'),('comercio','Comercio'),('sanatorio','Sanatorio')],'Lugar atendido')
|
|
|
+ tipo_paciente = fields.Selection([('directivo','Directivo'),('externo','Cliente externo'),('Trabajador','Trabajador'),('otro','Otros')],'Tipo de paciente')
|
|
|
+ line_ids = fields.One2many(
|
|
|
+ comodel_name='clinic.history.line',
|
|
|
+ inverse_name='clinichistory_id',
|
|
|
+ string='Trabajos hechos'
|
|
|
+ )
|
|
|
+ # consumed_ids = fields.One2many(
|
|
|
+ # comodel_name='clinic.history.consumed',
|
|
|
+ # inverse_name='clinichistory_id ',
|
|
|
+ # string='Productos y Servicios consumidos'
|
|
|
+ # )
|
|
|
+ order_date = fields.Datetime(
|
|
|
+ string='Fecha de Carga',
|
|
|
+ default=fields.Datetime.now
|
|
|
+ )
|
|
|
+ planned_start_date = fields.Datetime(
|
|
|
+ string='Fecha y hora de Recepción'
|
|
|
+ )
|
|
|
+ planned_end_date = fields.Datetime(
|
|
|
+ string='Fecha y hora de Atención'
|
|
|
+ )
|
|
|
+ name_movil = fields.Char(
|
|
|
+ string='Móvil'
|
|
|
+ )
|
|
|
+ nro_salida = fields.Char(
|
|
|
+ string='N° de Salida'
|
|
|
+ )
|
|
|
+ seguro = fields.Char(
|
|
|
+ string='Seguro'
|
|
|
+ )
|
|
|
+ nro_socio = fields.Char(
|
|
|
+ string='N° de Socio'
|
|
|
+ )
|
|
|
+ alergico = fields.Selection([('si','Sí'),('no','No')],'Alérgico?')
|
|
|
+ embarazada = fields.Selection([('si','Sí'),('no','No')],'Embarazada?')
|
|
|
+ pa = fields.Char(
|
|
|
+ string='P.A.'
|
|
|
+ )
|
|
|
+ fc = fields.Char(
|
|
|
+ string='F.C.'
|
|
|
+ )
|
|
|
+ fr = fields.Char(
|
|
|
+ string='F.R.'
|
|
|
+ )
|
|
|
+ temp = fields.Char(
|
|
|
+ string='T.'
|
|
|
+ )
|
|
|
+ so = fields.Char(
|
|
|
+ string='SO.'
|
|
|
+ )
|
|
|
+ hgt = fields.Char(
|
|
|
+ string='HGT'
|
|
|
+ )
|
|
|
+ motivo = fields.Text(
|
|
|
+ string='Motivo de la consulta'
|
|
|
+ )
|
|
|
+ diagnostic = fields.Text(
|
|
|
+ string='Hallazgo Positivo'
|
|
|
+ )
|
|
|
+ indicacion = fields.Text(
|
|
|
+ string='Indicación Médica'
|
|
|
+ )
|
|
|
+ actions = fields.Text(
|
|
|
+ string='Acciones'
|
|
|
+ )
|
|
|
+ recommendations = fields.Text(
|
|
|
+ string="Tratamiento Administrado"
|
|
|
+ )
|
|
|
+ epicrisis = fields.Char(
|
|
|
+ string='Epicrisis'
|
|
|
+ )
|
|
|
+ presuntivo = fields.Char(
|
|
|
+ string='Diagnóstico Presuntivo'
|
|
|
+ )
|
|
|
+ clasificacion = fields.Selection([('emergencia','Emergencia'),('urgencia','Urgencia'),('consulta','Consulta'),('suministro','Suministro'),('tar','T.A.R'),('tbr','T.B.R')],'Clasificación de la Atención')
|
|
|
+ state = fields.Selection([
|
|
|
+ ('draft', 'Pendiente'),
|
|
|
+ ('in_progress', 'En progreso'),
|
|
|
+ ('done', 'Hecho'),
|
|
|
+ ('canceled', 'Cancelado')],
|
|
|
+ string='Estado',
|
|
|
+ default='draft'
|
|
|
+ )
|
|
|
+ # invoicehistory_ids = fields.One2many('account.invoice', 'clinichistory_invoice_id')
|
|
|
+ # invoicehistory_count = fields.Integer(
|
|
|
+ # string='Facturas',
|
|
|
+ # compute='_get_invoice_count',
|
|
|
+ # )
|
|
|
+
|
|
|
+ # @api.multi
|
|
|
+ # def button_draft(self):
|
|
|
+ # if self.invoicehistory_count > 0:
|
|
|
+ # raise Warning('Este trabajo tiene una factura asociada')
|
|
|
+ # if self.invoicehistory_count == 0:
|
|
|
+ # for history in self:
|
|
|
+ # history.write({'state': 'draft'})
|
|
|
+ # return True
|
|
|
+ #
|
|
|
+ # @api.one
|
|
|
+ # @api.depends('invoicehistory_ids')
|
|
|
+ # def _get_invoice_count(self):
|
|
|
+ # self.invoice_counthistory = len(self.invoicehistory_ids)
|
|
|
+
|
|
|
+ @api.one
|
|
|
+ def onchange_partner_id(self, partner_id):
|
|
|
+ _log.info('-'*100)
|
|
|
+ _log.info(partner_id)
|
|
|
+
|
|
|
+ @api.one
|
|
|
+ def button_in_progress(self):
|
|
|
+ self.state = 'in_progress'
|
|
|
+
|
|
|
+ @api.one
|
|
|
+ def button_in_progress_back(self):
|
|
|
+ self.state = 'draft'
|
|
|
+
|
|
|
+ @api.one
|
|
|
+ def button_done(self):
|
|
|
+ # product = self.line_ids
|
|
|
+ works = self.consumed_ids
|
|
|
+ if not product or not works:
|
|
|
+ raise Warning('El trabajo debe tener productos y trabajos asociados')
|
|
|
+ else:
|
|
|
+ self.state = 'done'
|
|
|
+
|
|
|
+ @api.one
|
|
|
+ def button_done_back(self):
|
|
|
+ self.state = 'in_progress'
|
|
|
+
|
|
|
+ @api.one
|
|
|
+ def button_cancel(self):
|
|
|
+ self.state = 'canceled'
|
|
|
+
|
|
|
+ # @api.multi
|
|
|
+ # def Facturado(self):
|
|
|
+ # inv_obj = self.env['account.invoice']
|
|
|
+ # inv_line_obj = self.env['account.invoice.line']
|
|
|
+ # customer = self.partner_id
|
|
|
+ # if not customer.name:
|
|
|
+ # raise osv.except_osv(_('UserError!'), _('Por favor seleccione el cliente.'))
|
|
|
+ # company_id = self.env['res.users'].browse(1).company_id
|
|
|
+ # self.ensure_one()
|
|
|
+ # ir_values = self.env['ir.values']
|
|
|
+ # inv_data = {
|
|
|
+ # 'name': customer.name,
|
|
|
+ # 'reference': customer.name,
|
|
|
+ # 'account_id': customer.property_account_receivable.id,
|
|
|
+ # 'partner_id': customer.id,
|
|
|
+ # 'origin': self.name,
|
|
|
+ # 'clinichistory_invoice_id ': self.id
|
|
|
+ # }
|
|
|
+ # inv_id = inv_obj.create(inv_data)
|
|
|
+ # for records in self.consumed_ids:
|
|
|
+ # if records.product_id.id:
|
|
|
+ # income_account = records.product_id.categ_id.property_account_income_categ.id
|
|
|
+ # if not income_account:
|
|
|
+ # raise osv.except_osv(_('UserError!'), _('No hay cuenta definida '
|
|
|
+ # 'para este producto: "%s".') % (records.product_id.name,))
|
|
|
+ # inv_line_data = {
|
|
|
+ # 'name': records.product_id.name,
|
|
|
+ # 'account_id': income_account,
|
|
|
+ # 'price_unit': records.price_unit,
|
|
|
+ # 'quantity': records.quantity,
|
|
|
+ # 'product_id': records.product_id.id,
|
|
|
+ # 'invoice_id': inv_id.id,
|
|
|
+ # 'invoice_line_tax_id': [(6, 0, [x.id for x in records.product_id.taxes_id])],
|
|
|
+ # }
|
|
|
+ # inv_line_obj.create(inv_line_data)
|
|
|
+ # self.state = 'invoiced'
|
|
|
+ # imd = self.env['ir.model.data']
|
|
|
+ # action = imd.xmlid_to_object('account.action_invoice_tree1')
|
|
|
+ # list_view_id = imd.xmlid_to_res_id('account.invoice_tree')
|
|
|
+ # form_view_id = imd.xmlid_to_res_id('account.invoice_form')
|
|
|
+ # result = {
|
|
|
+ # 'name': action.name,
|
|
|
+ # 'help': action.help,
|
|
|
+ # 'type': 'ir.actions.act_window',
|
|
|
+ # 'views': [[list_view_id, 'tree'], [form_view_id, 'form'], [False, 'graph'], [False, 'kanban'],
|
|
|
+ # [False, 'calendar'], [False, 'pivot']],
|
|
|
+ # 'target': action.target,
|
|
|
+ # 'context': action.context,
|
|
|
+ # 'res_model': 'account.invoice',
|
|
|
+ # }
|
|
|
+ # if len(inv_id) > 1:
|
|
|
+ # result['domain'] = "[('id','in',%s)]" % inv_id.ids
|
|
|
+ # elif len(inv_id) == 1:
|
|
|
+ # result['views'] = [(form_view_id, 'form')]
|
|
|
+ # result['res_id'] = inv_id.ids[0]
|
|
|
+ # else:
|
|
|
+ # result = {'type': 'ir.actions.act_window_close'}
|
|
|
+ # invoiced_records = self.env['clinic.history']
|
|
|
+ # total = 0
|
|
|
+ # self.stage_id = 3
|
|
|
+ # for rows in invoiced_records:
|
|
|
+ # invoiced_date = rows.date
|
|
|
+ # invoiced_date = invoiced_date[0:10]
|
|
|
+ # if invoiced_date == str(date.today()):
|
|
|
+ # total = total + rows.price_subtotal
|
|
|
+ # inv_id.signal_workflow('invoice_open')
|
|
|
+ # return result
|
|
|
+
|
|
|
+
|
|
|
+class ClinicHistoryLine(models.Model):
|
|
|
+ _name = 'clinic.history.line'
|
|
|
+ _description = 'Trabajos realizados'
|
|
|
+ _inherit = ['mail.thread', 'ir.needaction_mixin']
|
|
|
+
|
|
|
+ clinichistory_id = fields.Many2one(
|
|
|
+ comodel_name='clinic.history',
|
|
|
+ string='Clinic History')
|
|
|
+
|
|
|
+ description = fields.Char(string='Descripción')
|
|
|
+ quantity = fields.Float(string='Cantidad', default=1.0)
|
|
|
+ brand = fields.Char(string='Marca')
|
|
|
+ number = fields.Char(string="Numero de serie")
|
|
|
+
|
|
|
+
|
|
|
+# class ClinicHistoryConsumed(models.Model):
|
|
|
+# _name = 'clinic.history.consumed'
|
|
|
+# _description = 'Servicios consumidos'
|
|
|
+# _inherit = ['mail.thread', 'ir.needaction_mixin']
|
|
|
+#
|
|
|
+# clinichistory_id = fields.Many2one(
|
|
|
+# comodel_name='clinic.history',
|
|
|
+# string='Orden de visita'
|
|
|
+# )
|
|
|
+# product_id = fields.Many2one(
|
|
|
+# comodel_name='product.product',
|
|
|
+# string='Product'
|
|
|
+# )
|
|
|
+# type = fields.Selection([
|
|
|
+# ('service', 'Service'),
|
|
|
+# ('product', 'Product')],
|
|
|
+# string='Type',
|
|
|
+# required=True,
|
|
|
+# default='service'
|
|
|
+# )
|
|
|
+# description = fields.Char(
|
|
|
+# string='Descripción',
|
|
|
+# required=True
|
|
|
+# )
|
|
|
+# quantity = fields.Float(
|
|
|
+# string='Cantidad',
|
|
|
+# default=1
|
|
|
+# )
|
|
|
+# price_unit = fields.Float(
|
|
|
+# string='Precio Unit.'
|
|
|
+# )
|
|
|
+# subtotal = fields.Float(
|
|
|
+# string='Subtotal',
|
|
|
+# compute='compute_subtotal'
|
|
|
+# )
|