Skip to content

Commit

Permalink
[IMP] dental: added history and guarantors
Browse files Browse the repository at this point in the history
After this commit:
-added medical and tooth history
-added guarantors
  • Loading branch information
smee-odoo committed Sep 6, 2024
1 parent e9361ec commit 0333ec0
Show file tree
Hide file tree
Showing 16 changed files with 560 additions and 97 deletions.
10 changes: 7 additions & 3 deletions dental/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@
'version': '1.2',
'description': "",
'depends': [
'base_setup', 'website'
'base_setup', 'website',
'mail'
],
'data': [
'security/ir.model.access.csv',


'views/portal_template.xml',
'views/tag_views.xml',
'views/medical_history_views.xml',
'views/dental_views.xml',
'views/medical_aids_views.xml',
'views/medical_symptoms_views.xml',
Expand All @@ -20,4 +24,4 @@
'installable': True,
'application': True,
'license': 'LGPL-3'
}
}
1 change: 1 addition & 0 deletions dental/controller/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import portal
32 changes: 32 additions & 0 deletions dental/controller/portal.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from odoo import http
from odoo.http import request
from odoo.addons.portal.controllers.portal import CustomerPortal

class DentalPortal(CustomerPortal):

@http.route(['/my/dental'], type='http', auth='public', website=True)
def portal_my_dental(self, **kwargs):

patients = request.env['dental.patient'].sudo().search([])

values = {
'patients': patients,
'page_name': 'dental'
}
for patient in patients:
print("Patient:", patient.guarantor_id.id)
return request.render("dental.portal_my_dental", values)

@http.route(['/my/dental/<int:patient_id>'], type='http', auth='public', website=True)
def portal_my_dental_patient(self, patient_id, **kwargs):

patient = request.env['dental.patient'].sudo().search(['guaranter_id', '=' , patient_id])

values = {
'patient': patient,
'page_name': 'dental'
}

print("Values:", values)

return request.render("dental.portal_my_dental_patient", values)
2 changes: 2 additions & 0 deletions dental/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
from . import medical_aids
from . import medical_symptoms
from . import medication
from . import medical_history
from . import dental_tags
59 changes: 56 additions & 3 deletions dental/models/dental_patients.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from odoo import models, fields
from odoo import models, fields, Command
from datetime import date
from dateutil.relativedelta import relativedelta


class DentalPatients(models.Model):
_name = "dental.patient"
_description = "patients"
_inherit = ["mail.thread", "mail.activity.mixin"]

name = fields.Char(string='Name', required=True)
stage = fields.Selection(
Expand All @@ -24,12 +25,17 @@ class DentalPatients(models.Model):
string="Company",
copy=False
)
phone_number = fields.Char(string="GP's Phone", related="doctor_id.phone")
patient_guarantor_id = fields.Many2one(
'dental.guarantor',
string="Guranator"
)
image = fields.Image()
doc_phone_number = fields.Char(string="GP's Phone", related="doctor_id.phone")
chronic_conditions_ids = fields.Many2many('chronic.conditions', string="Chronic Condtions")
allergies_ids = fields.Many2many('dental.allergies', string="Allergies")
habits_substance_ids = fields.Many2many('habits.substance', string="Habits and substance abuse")
medication_ids = fields.Many2many('dental.medication', string="Medication")
hospitialized = fields.Char(string="Hospitalized this year")
hospitalized = fields.Char(string="Hospitalized this year")
specialized_care = fields.Char(string="Under Specialist Care")
psychiatric_history = fields.Char(string="Psychiatric history")
gender = fields.Selection(
Expand All @@ -52,3 +58,50 @@ class DentalPatients(models.Model):
selection=[('single', 'Single'), ('married', 'Married'), ('divorced', 'Divorced'), ('widowed', 'Widowed')],
required=True,
default='single')
emergency_contact_id = fields.Many2one(
'res.users',
string="Emergency Contact",
copy=False
)
emergency_contact_phone = fields.Char(string="Mobile", related="emergency_contact_id.phone")
consent_date = fields.Date(string="Consent Date")
consent_signature = fields.Binary(string="Consent Signature")
notes = fields.Text()
insurance_id = fields.Many2one('medical.aids')
medical_aids_plan = fields.Char(string="Medical Aid Plan")
medical_aids_number = fields.Char(string="Medical Aid Number")
main_member_code = fields.Char(string="Main Member Code")
depedent_code = fields.Char(string="Dependent Code")
medical_history_ids = fields.One2many('medical.history', 'patient_id', string="Medical History")

def book_appointment_button(self):
self.stage = 'to invoice'
move_vals = {
'partner_id': self.patient_guarantor_id.guarantor_id.id,
'move_type': 'out_invoice',
'invoice_line_ids': [
Command.create({
"name": "consultation fees",
"quantity": 1,
"price_unit": 500
})
]
}
self.env['account.move'].check_access_rights('create')
self.env['account.move'].check_access_rule('create')
self.env['account.move'].sudo().create(move_vals)

class Guarantor(models.Model):
_name = "dental.guarantor"
_description = "Gurantor of the patient"

guarantor_id = fields.Many2one(
'res.users',
string="Guarantor",
copy=False
)
patient_ids = fields.One2many('dental.patient', 'patient_guarantor_id')
guarantor_phone = fields.Char(string="Guarantor Mobile Phone", related="guarantor_id.phone")
phone = fields.Char(string="Phone")
guarantor_email = fields.Char(string="Email", related="guarantor_id.email")
notes = fields.Text()
12 changes: 12 additions & 0 deletions dental/models/dental_tags.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from odoo import models, fields


class DentalTags(models.Model):
_name = "dental.tags"

name = fields.Char(string='Name', required=True)

_sql_constraints = [
('name_uniq', 'unique(name)',
'A tag with the same name already exists')
]
7 changes: 7 additions & 0 deletions dental/models/medical_aids.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,10 @@ class MedicalAids(models.Model):
)
note = fields.Text(string="")
image = fields.Image(string="")

class MedicalAidsDetails(models.Model):
_name = "medicalaids.details"
_inherits = {'medical.aids':'medical_aids_id'}

medical_aids_id = fields.Many2one('medical.aids')

95 changes: 95 additions & 0 deletions dental/models/medical_history.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
from odoo import models, fields, api
from datetime import date


class MedicalHistory(models.Model):
_name = "medical.history"
_description = "Medical History"
_inherit = ["mail.thread", "mail.activity.mixin"]

name = fields.Char(string="Name", compute="_computed_name")
patient_id = fields.Many2one('dental.patient', string="Patient", required=True)
date = fields.Date(string="Date", default=fields.Date.today())
did_not_attend = fields.Boolean(string="Did not attend", required=True)
company_id = fields.Many2one(
'res.company',
string="Company")
tag_ids = fields.Many2one(
'dental.tags',
string="Tags")
responsible = fields.Char(string="Responsible")
main_complaint = fields.Text(string="Main Complaint")
history = fields.Text(string="History")
habits = fields.Text(string="Habits")
extra_observation = fields.Text(string="Extra-Oral observation")
xray_file1 = fields.Image(string="X-Ray File 1")
xray_file2 = fields.Image(string="X-Ray File 2")
aligner_file1 = fields.Binary(string="Clear Aligner File 1")
aligner_file2 = fields.Binary(string="Clear Aligner File 2")
teeth_chart = fields.Char(string="Teeth Chart")
treatment_notes = fields.Text(string="Treatment Notes")
consultation_type = fields.Selection([
('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")
whitening = fields.Boolean(string="Whitening")

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

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

other_notes = fields.Text(string="Other Notes")

# General notes field at the end
notes = fields.Text(string="Additional Notes")

upper_18 = fields.Boolean(string="18 Staining")
upper_17 = fields.Boolean(string="17 Staining")
upper_16 = fields.Boolean(string="16 Staining")
upper_15 = fields.Boolean(string="15 Staining")
upper_14 = fields.Boolean(string="14 Staining")
upper_13 = fields.Boolean(string="13 Staining")
upper_12 = fields.Boolean(string="12 Staining")
upper_11 = fields.Boolean(string="11 Staining")
upper_28 = fields.Boolean(string="28 Staining")
upper_27 = fields.Boolean(string="27 Staining")
upper_26 = fields.Boolean(string="26 Staining")
upper_25 = fields.Boolean(string="25 Staining")
upper_24 = fields.Boolean(string="24 Staining")
upper_23 = fields.Boolean(string="23 Staining")
upper_22 = fields.Boolean(string="22 Staining")
upper_21 = fields.Boolean(string="21 Staining")

lower_38 = fields.Boolean(string="38 Staining")
lower_37 = fields.Boolean(string="37 Staining")
lower_36 = fields.Boolean(string="36 Staining")
lower_35 = fields.Boolean(string="35 Staining")
lower_34 = fields.Boolean(string="34 Staining")
lower_33 = fields.Boolean(string="33 Staining")
lower_32 = fields.Boolean(string="32 Staining")
lower_31 = fields.Boolean(string="31 Staining")
lower_41 = fields.Boolean(string="41 Staining")
lower_42 = fields.Boolean(string="42 Staining")
lower_43 = fields.Boolean(string="43 Staining")
lower_44 = fields.Boolean(string="44 Staining")
lower_45 = fields.Boolean(string="45 Staining")
lower_46 = fields.Boolean(string="46 Staining")
lower_47 = fields.Boolean(string="47 Staining")
lower_48 = fields.Boolean(string="48 Staining")

@api.depends("patient_id")
def _computed_name(self):
for record in self:
record.name = f"{record.patient_id.name}-{date.today()}"
6 changes: 5 additions & 1 deletion dental/security/ir.model.access.csv
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@ dental.access_medical_symptoms,access_medical_symptoms,dental.model_medical_symp
dental.access_chronic_conditions,access_chronic_conditions,dental.model_chronic_conditions,base.group_user,1,1,1,1
dental.access_dental_allergies,access_dental_allergies,dental.model_dental_allergies,base.group_user,1,1,1,1
dental.access_habits_substance,access_habits_substance,dental.model_habits_substance,base.group_user,1,1,1,1
dental.access_dental_medication,access_dental_medication,dental.model_dental_medication,base.group_user,1,1,1,1
dental.access_dental_medication,access_dental_medication,dental.model_dental_medication,base.group_user,1,1,1,1
dental.access_dental_guarantor,access_dental_guarantor,dental.model_dental_guarantor,base.group_user,1,1,1,1
dental.access_medicalaids_details,access_medicalaids_details,dental.model_medicalaids_details,base.group_user,1,1,1,1
dental.access_medical_history,access_medical_history,dental.model_medical_history,base.group_user,1,1,1,1
dental.access_dental_tags,access_dental_tags,dental.model_dental_tags,base.group_user,1,1,1,1
Binary file added dental/static/Description/dental-checkup.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/dental.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions dental/views/dental_menu.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<odoo>
<menuitem id="dental_menu_root" name="Dental" />
<menuitem id="dental_menu_root" name="Dental" web_icon="dental,static/Description/dental-checkup.png"/>

<menuitem id="dental_first_menu" name="Patients" parent="dental_menu_root"
action="dental_patient_action" />
Expand All @@ -15,5 +15,5 @@

<menuitem id="dental_fourth_menu" name="Medication" parent="dental_menu_root" action="dental_medication_menu_action" />

<menuitem id="dental_fifth_menu" name="Configuration" parent="dental_menu_root" />
<menuitem id="dental_fifth_menu" name="Configuration" parent="dental_menu_root" action="action_dental_tags"/>
</odoo>
Loading

0 comments on commit 0333ec0

Please sign in to comment.