123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325 |
- # -*- 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
- )
- paramedico_id = fields.Many2one(
- comodel_name='res.users',
- string='Paramédico',
- )
- partner_id = fields.Many2one(
- comodel_name='res.partner',
- string='Seguro'
- )
- paciente_id = fields.Many2one(
- comodel_name='res.partner',
- string='Paciente'
- )
- lugar_visita = fields.Selection([('A domicilio','A domicilio'),('Vía pública','Vía pública'),('Comercio','Comercio'),('Sanatorio','Sanatorio')],'Lugar atendido')
- tipo_paciente = fields.Selection([('directivo','Directivo'),('Cliente externo','Cliente externo'),('Trabajador','Trabajador'),('Particular','Particular'),('Otros','Otros')],'Tipo de paciente')
- line_ids = fields.One2many(
- comodel_name='clinic.history.line',
- inverse_name='clinichistory_id',
- string='Trabajos hechos'
- )
- uso_gel = fields.Selection([('si','Sí'),('no','No')],'Uso alcohol en gel?')
- 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'
- )
- programado = fields.Selection([('Programado','Programado')],'Programado')
- name_movil = fields.Char(
- string='Móvil'
- )
- edad_paciente = fields.Char(
- string='Edad'
- )
- antig_trabajo = fields.Char(
- string='Antiguedad'
- )
- at_base = fields.Char(
- string='At. Base'
- )
- nro_salida = fields.Char(
- string='N° de Salida'
- )
- seguro = fields.Char(
- string='Seguro'
- )
- seguro1 = fields.Char(
- string='Seguro'
- )
- nro_socio1 = fields.Char(
- string='N° de Socio'
- )
- nro_socio = fields.Char(
- string='N° de Socio'
- )
- alergico = fields.Selection([('Si','Sí'),('No','No')],'Alérgico?')
- respuesta_tratamiento = fields.Selection([('Mejora','Mejora'),('Sin cambios','Sin cambios'),('Desmejora','Desmejora')],'Respuesta al Tratamiento:')
- tipo_alergico = fields.Char(
- string='Alérgico a:'
- )
- embarazada = fields.Selection([('Si','Sí'),('No','No')],'Embarazada?')
- ost = fields.Boolean(string='OST' ,default = False)
- asm = fields.Boolean(string='ASM' ,default = False)
- card = fields.Boolean(string='CARD' ,default = False)
- acv = fields.Boolean(string='ACV' ,default = False)
- conv = fields.Boolean(string='CONV' ,default = False)
- hta = fields.Boolean(string='HTA' ,default = False)
- epoc = fields.Boolean(string='EPOC' ,default = False)
- otro = fields.Boolean(string='Otros' ,default = False)
- 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'
- )
- insumos_ids = fields.One2many(
- comodel_name='clinic.insumos.line',
- inverse_name='clinichistory_id',
- string='Insumos Utilizados'
- )
- 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'),('T.A.R','T.A.R'),('tbr','T.B.R')],'Clasificación de la Atención')
- informado = fields.Char(
- string='Informado a:'
- )
- entregado = fields.Char(
- string='Entrega de paciente a:'
- )
- signature_image_paramedico= fields.Binary(string='Firma Paramédico')
- signature_image_medico= fields.Binary(string='Firma Médico')
- signature_image_paciente = fields.Binary(string='Firma Paciente o Responsable')
- state = fields.Selection([
- ('draft', 'Programado'),
- ('redraft', 'Reprogramado'),
- ('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',
- # )
- # 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_redraft(self):
- self.state = 'redraft'
- @api.one
- def button_in_progress_back(self):
- self.state = 'draft'
- @api.one
- def button_done(self):
- # product = self.line_ids
- works = self.line_ids
- if 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 = 'redraft'
- @api.one
- def button_redraft_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')
- product_id = fields.Many2one(
- comodel_name='product.product',
- string='Servicio'
- )
- quantity = fields.Float(string='Cantidad', default=1.0)
- brand = fields.Char(string='Marca')
- number = fields.Char(string="Numero de serie")
- class ClinicInsumosLine(models.Model):
- _name = 'clinic.insumos.line'
- _description = 'Insumos Utilizados'
- _inherit = ['mail.thread', 'ir.needaction_mixin']
- clinichistory_id = fields.Many2one(
- comodel_name='clinic.history',
- string='Insumos Clinicos')
- product_id = fields.Many2one(
- comodel_name='product.product',
- string='Insumos'
- )
- quantity = fields.Float(string='Cantidad', default=1.0)
- brand = fields.Char(string='Marca')
- number = fields.Char(string="Numero de serie")
|