Commit 689894fc authored by Ángel Ramírez Isea's avatar Ángel Ramírez Isea
Browse files

refactor: PEP-8 a medical_inpatient_calendar y cambiar a commed_inpatient_calendar. _

parent daf25388
# Copyright (C) 2011 Cédric Krier
# Copyright (C) 2011-2020 Luis Falcon <falcon@gnuhealth.org>
# Copyright 2020 LabViv
# License GPL-3.0 or later (http://www.gnu.org/licenses/gpl.html).
from . import models
# Copyright (C) 2011 Cédric Krier
# Copyright (C) 2011-2020 Luis Falcon <falcon@gnuhealth.org>
# Copyright 2020 LabViv
# License GPL-3.0 or later (http://www.gnu.org/licenses/gpl.html).
{
'name': 'Community Medical - Inpatient calendar',
'description': '''Hospitalization calendar functionality ported from GNU
Health. Allows to:
* Link beds with calendars
* Create calendar events from inpatient registrations''',
'version': '13.0.0.0.1',
'category': 'Medical',
'depends': [
'base',
'commed_base',
'commed_lifestyle',
'commed_procedure',
'commed_medicament',
'commed_center',
'commed_disease',
'commed_practitioner',
'commed_medication',
'commed_evaluation',
'commed_inpatient',
'calendar'
],
'author': 'LabViv',
'website': 'https://labviv.org.ve/',
'license': 'GPL-3',
'data': [
'views/commed_inpatient_calendar_view.xml',
# 'security/ir.model.access.csv',
],
'installable': True,
'maintainer': 'Julio César Méndez <mendezjcx@tutanota.com>'
}
# Copyright (C) 2011 Cédric Krier
# Copyright (C) 2011-2020 Luis Falcon <falcon@gnuhealth.org>
# Copyright 2020 LabViv
# License GPL-3.0 or later (http://www.gnu.org/licenses/gpl.html).
from . import commed_inpatient_calendar
# Copyright (C) 2011 Cédric Krier
# Copyright (C) 2011-2020 Luis Falcon <falcon@gnuhealth.org>
# Copyright 2020 LabViv
# License GPL-3.0 or later (http://www.gnu.org/licenses/gpl.html).
from odoo import fields, models
class HospitalBed(models.Model):
'''Add Calendar to Hospital Bed'''
_inherit = "hospital.bed"
calendar = fields.Many2one('calendar.event', 'Calendar')
class CommedInpatientRegistration(models.Model):
'''Add Calendar to the Inpatient Registration'''
_inherit = 'commed.inpatient_registration'
event = fields.Many2one('calendar.event', 'Calendar Event')
def confirmed(self, registrations):
super(CommedInpatientRegistration, self).confirmed(registrations)
Event = self.env.get('calendar.event')
for inpatient_registration in registrations:
if inpatient_registration.bed.calendar:
if not inpatient_registration.event:
bed = inpatient_registration.bed.name.code + ": "
events = Event.create([{
'dtstart': inpatient_registration.hospitalization_date,
'dtend': inpatient_registration.discharge_date,
'calendar': inpatient_registration.bed.calendar.id,
'summary':
bed + inpatient_registration.patient.name.rec_name
}])
self.write(
[inpatient_registration], {'event': events[0].id}
)
def discharge(self, registrations):
super(CommedInpatientRegistration, self).discharge(registrations)
Event = self.env.get('calendar.event')
for inpatient_registration in registrations:
if inpatient_registration.event:
Event.delete([inpatient_registration.event])
def write(self, registrations, values):
Event = self.env.get('calendar.event')
Patient = self.env.get('commed.patient')
HospitalBed = self.env.get('hospital.bed')
for inpatient_registration in registrations:
if inpatient_registration.event:
if 'hospitalization_date' in values:
Event.write(
[inpatient_registration.event],
{'dtstart': values['hospitalization_date']}
)
if 'discharge_date' in values:
Event.write(
[inpatient_registration.event],
{'dtend': values['discharge_date']}
)
if 'bed' in values:
bed = HospitalBed(values['bed'])
Event.write(
[inpatient_registration.event],
{'calendar': bed.calendar.id}
)
if 'patient' in values:
patient = Patient(values['patient'])
bed = inpatient_registration.bed.name.code + ": "
Event.write(
[inpatient_registration.event],
{'summary': bed + patient.name.rec_name}
)
return super(CommedInpatientRegistration, self).\
write(registrations, values)
def delete(self, registrations):
Event = self.env.get('calendar.event')
for inpatient_registration in registrations:
if inpatient_registration.event:
Event.delete([inpatient_registration.event])
return super(CommedInpatientRegistration, self).delete(registrations)
# Copyright (C) 2011 Cédric Krier
# Copyright (C) 2011-2020 Luis Falcon <falcon@gnuhealth.org>
# Copyright 2020 LabViv
# License GPL-3.0 or later (http://www.gnu.org/licenses/gpl.html).
from test_commed_inpatient_calendar import suite
# Copyright (C) 2011 Cédric Krier
# Copyright (C) 2011-2020 Luis Falcon <falcon@gnuhealth.org>
# Copyright 2020 LabViv
# License GPL-3.0 or later (http://www.gnu.org/licenses/gpl.html).
from odoo.tests.common import TransactionCase
class CommedInpatientCalendarTestCase(TransactionCase):
def set_up(self):
super(CommedInpatientCalendarTestCase, self).setUp()
self.model_obj = self.env['commed.inpatient_calendar'].browse(1)
self.assertFalse(
self.model_obj.admitted(),
self.model_obj.icu_stay(),
)
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2011 Cédric Krier
Copyright (C) 2011-2020 Luis Falcon <falcon@gnuhealth.org>
Copyright 2020 LabViv
License GPL-3.0 or later (http://www.gnu.org/licenses/gpl.html).
-->
<odoo>
<!-- Health center Bed -->
<record id="commed_hospital_bed_form_view_inherit" model="ir.ui.view">
<field name="name">hospital.bed.form.view.inherit</field>
<field name="model">hospital.bed</field>
<field name="inherit_id" ref="commed_center.commed_hospital_bed_form"/>
<field name="arch" type="xml">
<xpath expr="/form/sheet/group" position="after">
<label for="calendar"/>
<field name="calendar"/>
</xpath>
</field>
</record>
<!-- Patient hospitalization and bed registration (in-patient registration) -->
<record id="commed_inpatient_registration_inherit" model="ir.ui.view">
<field name="name">commed.inpatient_registration.inherit</field>
<field name="model">commed.inpatient_registration</field>
<field name="inherit_id" ref="commed_inpatient.commed_inpatient_registration_form_view"/>
<field name="arch" type="xml">
<xpath expr="/form/sheet/notebook/page/group/group/field[@name='discharge_date']" position="after">
<field name="event"/>
</xpath>
</field>
</record>
</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