Skip to content

Commit

Permalink
[IMP] dental: enhance patient module and portal views
Browse files Browse the repository at this point in the history
- Added DentalPortal controller for managing dental records via the portal.
- Implemented routes for patient details, medical history, medical aid, and
  dental history.
- Updated `portal_my_home` with a dedicated Dental section for easy access.
- Enhanced templates for a user-friendly experience in managing and viewing
  dental records.
  • Loading branch information
pkgu-odoo committed Sep 10, 2024
1 parent e060de9 commit f533795
Show file tree
Hide file tree
Showing 44 changed files with 603 additions and 942 deletions.
Binary file removed Dental.zip
Binary file not shown.
6 changes: 4 additions & 2 deletions Dental/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,26 @@
'version': '1.0',
'summary': 'Manage patient billing and treatment notes',
'description': """
This module helps in managing patient billing, including treatment notes,
This module helps in managing patient billing, including treatment notes,
consultation types, and other related information.
""",
'category': 'Sales',
'author': 'odoo',
'depends': ['base','website','mail','account'],
'depends': ['base', 'website', 'mail', 'account'],
'data': [
'security/ir.model.access.csv',
'views/dental_medical_symptoms_allergies_view.xml',
'views/dental_medical_symptoms_chronic_conditions_view.xml',
'views/dental_medical_symptoms_habit_view.xml',
'views/patients_view.xml',
'views/templates.xml',
'views/dental_medical_history_view.xml',
'views/dental_medication_view.xml',
'views/dental_medical_aids.xml',
'views/dental_menu_view.xml'
],
'installable': True,
'application': True,
'auto_install': False,
'license': 'LGPL-3',
}
50 changes: 45 additions & 5 deletions Dental/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,51 @@
class DentalPortal(CustomerPortal):
@http.route('/my/dental', type='http', auth='user', website=True)
def portal_my_dental(self, **kw):
users = request.env.user.search([])
patients = request.env['dental.patient'].search([('guarantor_name', '=', request.env.user.id)])
return request.render('Dental.portal_my_dental', {
'users': users
'users': patients
})

@http.route('/my/dental/<int:user_id>', type='http', auth='user', website=True)
def portal_my_dental_user(self, user_id, **kw):
return request.render('Dental.portal_my_dental_user')
@http.route('/my/dental/<int:patient_id>', type='http', auth='user', website=True)
def portal_my_dental_user(self, patient_id, **kw):
patient = request.env['dental.patient'].browse(patient_id)
return request.render('Dental.portal_my_dental_user', {
'patient': patient
})

@http.route('/my/dental/<int:patient_id>/personal', type='http', auth='user', website=True)
def portal_my_dental_personal(self, patient_id, **kw):
patient = request.env['dental.patient'].browse(patient_id)
return request.render('Dental.portal_my_dental_personal', {
'patient': patient
})

@http.route('/my/dental/medical_history/<int:history_id>', type='http', auth='user', website=True)
def portal_dental_medical_history_detail(self, history_id, **kw):
medical_history = request.env['dental.medical.history'].browse(history_id)
if not medical_history.exists():
return request.not_found()
return request.render('Dental.portal_my_dental_medical_history_detail', {
'record': medical_history
})

@http.route('/my/dental/<int:patient_id>/medical_history', type='http', auth='user', website=True)
def portal_my_dental_medical_history_list(self, patient_id, **kw):
history = request.env['dental.medical.history'].search([('patient_id', '=', patient_id)])
return request.render('Dental.portal_my_dental_medical_history_list', {
'history': history
})

@http.route('/my/dental/<int:patient_id>/medical_aid', type='http', auth='user', website=True)
def portal_my_dental_medical_aid(self, patient_id, **kw):
medical_aid = request.env['dental.patient'].browse(patient_id).medical_aids
return request.render('Dental.portal_my_dental_medical_aid', {
'medical_aid': medical_aid
})

@http.route('/my/dental/<int:patient_id>/dental_history', type='http', auth='user', website=True)
def portal_my_dental_dental_history(self, patient_id, **kw):
dental_patient_history = request.env['dental.medical.history'].search([('patient_id', '=', patient_id)])
return request.render('Dental.portal_my_dental_dental_history', {
'dental_patient_history': dental_patient_history
})
3 changes: 2 additions & 1 deletion Dental/models/dental_medical_aids.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
class DentalMedicalAids(models.Model):
_name = 'dental.medical.aids'
_description = 'Medical Aids'
_inherit = ['mail.thread', 'mail.activity.mixin']

name = fields.Char('Name', required=True)
contact = fields.Integer('Contact')
contact = fields.Many2one('res.partner', 'Contact')
phone = fields.Char('Phone')
email = fields.Text('Email')
company_id = fields.Many2one('res.company')
Expand Down
96 changes: 66 additions & 30 deletions Dental/models/dental_medical_history.py
Original file line number Diff line number Diff line change
@@ -1,51 +1,87 @@
from odoo import models, fields,api
from odoo import models, fields
from datetime import date

class DentalMedicalHistory(models.Model):

class DentalPatientHistory(models.Model):
_name = 'dental.medical.history'
_description = 'Dental Medical History'
_description = 'Dental Patient History'

history_id = fields.Many2one('dental.patient', string="History")
name = fields.Char(string="Name", store=True)
patient_id = fields.Many2one('dental.patient', string="Patient", required=True)
responsible_id = fields.Many2one('res.users', string="Responsible", default=lambda self: self.env.user)
date = fields.Date(string="Date", default=date.today())
name = fields.Char(string="Title", required=True)
description = fields.Text(string="Description")
did_not_attend = fields.Boolean(string="Did not attend", required=True)
company_id = fields.Many2one('res.company', string="Company", default=lambda self: self.env.company)
patient_id = fields.Many2one('dental.patient', string="Patient", required=True)
date = fields.Date(string="Date", default=date.today(), required=True)
main_complaint = fields.Text(string="Main Complaint")
teeth_history = fields.Text(string="History")
history = fields.Text(string="History")
company_id = fields.Many2one('res.company', string='Company')
did_not_attend = fields.Boolean(string="Did Not Attend")
tags = fields.Char(string="Tags")

xray_file_1 = fields.Binary(string="X-ray File 1")
xray_file_2 = fields.Binary(string="X-ray File 2")
clear_aligner_file_1 = fields.Binary(string="Clear Aligner File 1")
clear_aligner_file_2 = fields.Binary(string="Clear Aligner File 2")

habits = fields.Text(string="Habits")
extra_oral_observation = fields.Text(string="Extra-Oral Observation")
xray_file_1 = fields.Image(string="X-ray file 1")
xray_file_2 = fields.Image(string="X-ray file 2")
clear_align_file_1 = fields.Binary(string="Clear Aligner File 1")
clear_align_file_2 = fields.Binary(string="Clear Aligner File 2")


# Billing Fileds

teeth_chart = fields.Char(string="Teeth Chart")

treatment_notes = fields.Text(string="Treatment Notes")

consultation_type = fields.Selection([
('full', 'Full consultation with bite-wings and scan'),
('basic', 'Basic consultation'),
('none', 'No consultation')
('full_consultation', 'Full Consultation with Bitewings and Scan'),
('basic_consultation', 'Basic Consultation'),
('no_consultation', 'No Consultation')
], string="Consultation Type")

call_out = fields.Boolean(string="Call Out")
scale_and_polish = fields.Boolean(string="Scale and Polish")
fluoride = fields.Boolean(string="Fluoride")

filling_description = fields.Text(string="Filling Description")

aligner_delivery = fields.Boolean(string="Aligner delivery and attachment placed")
aligner_delivery = fields.Boolean(
string="Aligner Delivery and Attachment Placed")
whitening = fields.Boolean(string="Whitening")
fissure_sealant_qty = fields.Float(string="Fissure Sealant - Quantity", digits=(6, 2))

fissure_sealant_qty = fields.Float(
string="Fissure Sealant Quantity", digits=(6, 2))

attachments_removed = fields.Boolean(string="Attachments Removed")
aligner_follow_up_scan = fields.Boolean(string="Aligner Follow-up Scan")
aligner_followup_scan = fields.Boolean(string="Aligner Follow-up Scan")

other_description = fields.Text(string="Other")
notes = fields.Text(string="Notes")
other_notes = fields.Text(string="Other Notes")
upper_18_staining = fields.Boolean(string='18 Staining')
upper_17_staining = fields.Boolean(string='17 Staining')
upper_16_staining = fields.Boolean(string='16 Staining')
upper_15_staining = fields.Boolean(string='15 Staining')
upper_14_staining = fields.Boolean(string='14 Staining')
upper_13_staining = fields.Boolean(string='13 Staining')
upper_12_staining = fields.Boolean(string='12 Staining')
upper_11_staining = fields.Boolean(string='11 Staining')
upper_28_staining = fields.Boolean(string='28 Staining')
upper_27_staining = fields.Boolean(string='27 Staining')
upper_26_staining = fields.Boolean(string='26 Staining')
upper_25_staining = fields.Boolean(string='25 Staining')
upper_24_staining = fields.Boolean(string='24 Staining')
upper_23_staining = fields.Boolean(string='23 Staining')
upper_22_staining = fields.Boolean(string='22 Staining')
upper_21_staining = fields.Boolean(string='21 Staining')
lower_31_staining = fields.Boolean(string='31 Staining')
lower_32_staining = fields.Boolean(string='32 Staining')
lower_33_staining = fields.Boolean(string='33 Staining')
lower_34_staining = fields.Boolean(string='34 Staining')
lower_35_staining = fields.Boolean(string='35 Staining')
lower_36_staining = fields.Boolean(string='36 Staining')
lower_37_staining = fields.Boolean(string='37 Staining')
lower_38_staining = fields.Boolean(string='38 Staining')
lower_41_staining = fields.Boolean(string='41 Staining')
lower_42_staining = fields.Boolean(string='42 Staining')
lower_43_staining = fields.Boolean(string='43 Staining')
lower_44_staining = fields.Boolean(string='44 Staining')
lower_45_staining = fields.Boolean(string='45 Staining')
lower_46_staining = fields.Boolean(string='46 Staining')
lower_47_staining = fields.Boolean(string='47 Staining')
lower_48_staining = fields.Boolean(string='48 Staining')

@api.depends('patient_id', 'date')
def _compute_name(self):
for record in self:
record.name = f"{record.patient_id.name} - {record.date}" if record.patient_id and record.date else "New History"
notes = fields.Text(string="Additional Notes")
3 changes: 3 additions & 0 deletions Dental/models/dental_medical_symptoms_allergies.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,8 @@
class Allergies(models.Model):
_name = 'dental.allergies'
_description = 'Allergies'
_inherit = ['mail.thread', 'mail.activity.mixin']
_order = 'sequence, name'

sequence = fields.Integer(string="Sequence")
name = fields.Char(string="Name")
4 changes: 3 additions & 1 deletion Dental/models/dental_medical_symptoms_chronic_conditions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
class ChronicConditions(models.Model):
_name = 'dental.chronic.conditions'
_description = 'Chronic Conditions'
_inherit = ['mail.thread', 'mail.activity.mixin']
_order = 'sequence, name'

sequence = fields.Integer(string="Sequence")
name = fields.Char(string="Name")

4 changes: 4 additions & 0 deletions Dental/models/dental_medical_symptoms_habit.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
from odoo import models, fields


class Habits(models.Model):
_name = 'dental.habit.substance.abuse'
_description = 'Habits'
_inherit = ['mail.thread', 'mail.activity.mixin']
_order = 'sequence, name'

sequence = fields.Integer(string="Sequence")
name = fields.Char(string="Name")
1 change: 1 addition & 0 deletions Dental/models/dental_medication.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class DentalMedication(models.Model):
_name = 'dental.medication'
_description = 'Dental Medication'
_order = 'sequence, name'
_inherit = ['mail.thread', 'mail.activity.mixin']

name = fields.Char('Name', required=True)
sequence = fields.Integer('Sequence')
39 changes: 12 additions & 27 deletions Dental/models/dental_patients.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
from odoo import models, fields, api, Command
from odoo import models, fields, Command


class DentalPatient(models.Model):
_name = 'dental.patient'
_description = 'Patient'
_inherit = ['mail.thread', 'mail.activity.mixin']


name = fields.Char(string='Name')
name = fields.Char(string='Name', required=True)
state = fields.Selection([
('new', 'New'),
('todotoday', 'To Do Today'),
('done', 'Done'),
('new', 'New'),
('todotoday', 'To Do Today'),
('done', 'Done'),
('toinvoice', 'To Invoice')
], default='new', tracking=True)

Expand All @@ -37,60 +36,46 @@ class DentalPatient(models.Model):
main_member_code = fields.Integer(string="Main Member Code")
depandant_code = fields.Integer(string="Dependant Code")
medical_aids_note = fields.Text(string="Medical Aids Notes")

# Emergency Contact Section

emergency_contact_id = fields.Many2one('res.partner', string="Emergency Contact")
emergency_contact_mobile = fields.Char(related='emergency_contact_id.phone', string="Mobile", readonly=True)

# Patient Details Section
company_or_school_id = fields.Many2one('res.users', string="Company or School")
company_or_school_id = fields.Many2one('res.users', string="Company")
occupation_or_grade = fields.Char(string="Occupation or Grade")
identity_number = fields.Char(string="Identity Number")
date_of_birth = fields.Date(string="Date of Birth")

gender = fields.Selection([
('female', 'Female'),
('male', 'Male'),
('neither', 'Neither')
], string="Gender", default='female')

marital_status = fields.Selection([
('single', 'Single'),
('married', 'Married'),
('divorced', 'Divorced'),
('widowed', 'Widowed')
], string="Marital Status", default='single')

# Consent Form Section
consent_signature = fields.Binary(string="Consent Signature")
consent_date = fields.Date(string="Consent Date")

patient_image = fields.Binary()
guarantor_name = fields.Many2one('res.partner',string="Guarantor Name")
guarantor_name = fields.Many2one('res.users', string="Guarantor Name", required=True)
guarantor_mobile = fields.Char(related='guarantor_name.phone', string="Mobile", readonly=True)
guarantor_email = fields.Char(related='guarantor_name.email', string="Email", readonly=True)
guarantor_phone = fields.Char(string="Phone")
tags = fields.Char(string="Tags")
company_id = fields.Many2one('res.company', string="Company")

patient_history_id = fields.One2many('dental.medical.history', 'patient_id', nolabel=True)

treatment_notes = fields.Text(string="Treatment Notes")

patient_history_id = fields.One2many('dental.medical.history', 'patient_id', string="History")

def action_book_appointment(self):
self.state='toinvoice'
self.state = 'toinvoice'
move_vals = {
'partner_id': self.guarantor_name.id,
'move_type': 'out_invoice',
'invoice_date': fields.Date.today(),
"invoice_line_ids": [
Command.create({
"name": "consultant fees",
"name": "Doctor Appointment fees",
"quantity": 1,
"price_unit": 500
"price_unit": 2000
}),
],

}
self.env['account.move'].create(move_vals)
2 changes: 1 addition & 1 deletion Dental/security/ir.model.access.csv
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ access_dental_chronic_conditions,access_dental_chronic_conditions,model_dental_c
access_dental_allergies,access_dental_allergies,model_dental_allergies,base.group_user,1,1,1,1
access_dental_habit_substance_abuse,access_dental_habit_substance_abuse,model_dental_habit_substance_abuse,base.group_user,1,1,1,1
access_dental_medication,access_dental_medication,model_dental_medication,base.group_user,1,1,1,1
Dental.access_dental_medical_history,access_dental_medical_history,Dental.model_dental_medical_history,base.group_user,1,1,1,1
Dental.access_dental_medical_history,access_dental_medical_history,Dental.model_dental_medical_history,base.group_user,1,1,1,1
Binary file added Dental/static/description/floss.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Dental/static/description/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 7 additions & 3 deletions Dental/views/dental_medical_aids.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
</group>
</group>
</sheet>
<div class="oe_chatter">
<field name="activity_ids" widget="chatter" />
<field name="message_ids" widget="mail_thread" />
<field name="message_follower_ids" widget="mail_followers" />
</div>
</form>
</field>
</record>
Expand All @@ -43,6 +48,5 @@
<field name="email"/>
</tree>
</field>
</record>

</odoo>
</record>
</odoo>
Loading

0 comments on commit f533795

Please sign in to comment.