bemade_sports_clinic: added form view for injuries. Fixed record rule for injuries.

This commit is contained in:
Marc Durepos 2023-10-16 16:23:18 -04:00
parent 0cc8f07763
commit 5113c065ab
4 changed files with 40 additions and 7 deletions

View file

@ -25,13 +25,13 @@
professionals. The core purpose of this module is to keep track of the treatment
history of players and to make it appropriately accessible to the various
involved parties (medical practitioners, clinic staff, team staff, and patients).
Internal users get access to patient data as appropriate, i.e.
treatment professionals get full access to their own patients' data, clinic
staff users get access to basic patient data needed for contacting patients, etc.
External users (portal users) can be added to give coaches and other team
personnel access to limited player data such as estimated return-to-play dates.
personnel access to limited player data such as estimated return-to-play dates.
""",
'category': 'Services/Medical',
'author': 'Bemade Inc.',

View file

@ -11,6 +11,7 @@ class Patient(models.Model):
first_name = fields.Char(required=True)
last_name = fields.Char(required=True)
name = fields.Char(compute="_compute_name")
date_of_birth = fields.Date(
groups="bemade_sports_clinic.group_sports_clinic_treatment_professional")
age = fields.Integer(compute='_compute_age',
@ -62,9 +63,14 @@ class Patient(models.Model):
lambda r: r.predicted_return_date > date.today()).sorted(
'predicted_return_date')
if ongoing_injuries:
rec.predicted_return_date = ongoing_injuries[-1]
rec.predicted_return_date = ongoing_injuries[-1].\
predicted_return_date
else:
rec.predicted_return_date = False
def _compute_name(self):
for rec in self:
rec.name = ((rec.first_name or "") + " " + (rec.last_name or
"")).strip()
class PatientContact(models.Model):
@ -87,7 +93,10 @@ class PatientInjury(models.Model):
_description = "A patient's injury."
_inherit = ['mail.thread', 'mail.activity.mixin']
patient_id = fields.Many2one(comodel_name='sports.patient', string="Patient")
patient_id = fields.Many2one(comodel_name='sports.patient',
string="Patient",
readonly=True)
patient_name = fields.Char(related="patient_id.name")
diagnosis = fields.Char(tracking=True)
injury_date_time = fields.Datetime(string='Date and Time of Injury')
internal_notes = fields.Html(tracking=True)

View file

@ -16,8 +16,9 @@
<field name="model_id" ref="model_sports_patient_injury"/>
<field name="groups" eval="[(6, 0, [ref('group_sports_clinic_user'), ref('group_sports_clinic_treatment_professional')])]"/>
<field name="domain_force">
[('message_follower_ids', 'in', user.partner_id.ids)]
[('message_partner_ids', 'in', user.partner_id.ids)]
</field>
<field name="perm_create" eval="False"/>
</record>
</data>
</odoo>

View file

@ -63,5 +63,28 @@
</form>
</field>
</record>
<record id="sports_patient_injury_view_form" model="ir.ui.view">
<field name="name">sports.patient.injury.view.form</field>
<field name="model">sports.patient.injury</field>
<field name="arch" type="xml">
<form>
<header></header>
<sheet>
<div class="oe_title">
<h1>
<field name="patient_name"/>
</h1>
</div>
<group>
<field name="injury_date_time"/>
<field name="diagnosis"/>
<field name="treatment_professional_ids"/>
<field name="internal_notes"/>
<field name="predicted_return_date"/>
</group>
</sheet>
</form>
</field>
</record>
</data>
</odoo>
</odoo>