diff --git a/dental/__manifest__.py b/dental/__manifest__.py index 8799610e79..aae01407ae 100644 --- a/dental/__manifest__.py +++ b/dental/__manifest__.py @@ -3,19 +3,22 @@ 'version': '17.0', 'summary': 'Manage Dental Patients , Appointments and Medical Record', 'author': 'Your Name', - 'depends': ['base'], + 'depends': ['base', 'mail', 'account'], 'license': 'LGPL-3', 'data': [ - 'security/ir.model.access.csv', - 'views/dental_patient_views.xml', + 'security/ir.model.access.csv', 'views/dental_medical_aids_view.xml', + 'views/dental_patient_views.xml', 'views/dental_medical_symptoms_view.xml', 'views/dental_medication_views.xml', 'views/dental_chronic_conditions_views.xml', 'views/dental_allergies_view.xml', 'views/dental_habits_view.xml', - 'views/dental_configuration_views.xml', - 'views/dental_patient_menus.xml', + 'views/dental_configuration_views.xml', + 'views/dental_medical_history_view.xml', + 'views/dental_patient_menus.xml' + + ], 'installable': True, 'application': True, diff --git a/dental/models/__init__.py b/dental/models/__init__.py index f028651c2e..dc4013f18f 100644 --- a/dental/models/__init__.py +++ b/dental/models/__init__.py @@ -6,3 +6,4 @@ from . import dental_allergies from . import dental_habits from . import dental_configuration +from . import dental_medical_history \ No newline at end of file diff --git a/dental/models/dental_allergies.py b/dental/models/dental_allergies.py index 64889c12a2..de83c95b7f 100644 --- a/dental/models/dental_allergies.py +++ b/dental/models/dental_allergies.py @@ -1,9 +1,10 @@ -from odoo import api, models, fields +from odoo import models, fields class DentalAllergies(models.Model): _name = "dental.allergies" _description = "Dental Allergies" + _inherit = ['mail.thread', 'mail.activity.mixin'] name = fields.Char(string='Name') diff --git a/dental/models/dental_chronic_conditions.py b/dental/models/dental_chronic_conditions.py index d542062dab..797ad1fb55 100644 --- a/dental/models/dental_chronic_conditions.py +++ b/dental/models/dental_chronic_conditions.py @@ -1,10 +1,11 @@ -from odoo import api, models, fields +from odoo import models, fields class DentalChronicConditions(models.Model): _name = "dental.chronic.conditions" _description = "Dental Chronic Conditions" + _inherit = ['mail.thread', 'mail.activity.mixin'] name = fields.Char(string='Name') sequence = fields.Integer('Sequence') diff --git a/dental/models/dental_configuration.py b/dental/models/dental_configuration.py index 5ec1bbf0a2..665ac28418 100644 --- a/dental/models/dental_configuration.py +++ b/dental/models/dental_configuration.py @@ -1,9 +1,10 @@ -from odoo import api, models, fields +from odoo import models, fields class DentalConfiguration(models.Model): _name = "dental.configuration" _description = "Dental Configuration" + _inherit = ['mail.thread', 'mail.activity.mixin'] name = fields.Char(string='Name') diff --git a/dental/models/dental_habits.py b/dental/models/dental_habits.py index ce44fcb94e..8807bc1766 100644 --- a/dental/models/dental_habits.py +++ b/dental/models/dental_habits.py @@ -1,9 +1,10 @@ -from odoo import api, models, fields +from odoo import models, fields class DentalHabits(models.Model): _name = "dental.habits" _description = "Dental Habits" + _inherit = ['mail.thread', 'mail.activity.mixin'] name = fields.Char(string='Name') diff --git a/dental/models/dental_medical_aids.py b/dental/models/dental_medical_aids.py index 018d4efff4..d278b8c47d 100644 --- a/dental/models/dental_medical_aids.py +++ b/dental/models/dental_medical_aids.py @@ -1,10 +1,11 @@ -from odoo import api, models, fields +from odoo import models, fields class DentalMedicalAids(models.Model): _name = "dental.medical.aids" _description = "Medical Aids" + _inherit = ['mail.thread', 'mail.activity.mixin'] name = fields.Char(string='Name') contact_id = fields.Many2one('res.partner', string='Contact') diff --git a/dental/models/dental_medical_history.py b/dental/models/dental_medical_history.py new file mode 100644 index 0000000000..0186cbca4d --- /dev/null +++ b/dental/models/dental_medical_history.py @@ -0,0 +1,98 @@ +from odoo import models, fields, api +from datetime import date + + +class DentalMedicalHistory(models.Model): + _name = 'dental.medical.history' + _description = 'Dental Mdeical History' + _inherit = ['mail.thread', 'mail.activity.mixin'] + + + name = fields.Char(string="Consultation Name", compute="_compute_name") + date = fields.Date( + string="Date", default=fields.Date.context_today, required=True) + patient_id = fields.Many2one( + 'dental.patient', string="Patient", required=True) + main_complaint = fields.Text(string="Main Complaint") + history = fields.Text(string="History") + tags = fields.Char(string="Tags") + company_id = fields.Many2one('res.company', string='Company') + did_not_attend = fields.Boolean(required=True) + + 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") + + 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") + + notes = fields.Text(string="Additional Notes") + + @api.depends("patient_id") + def _compute_name(self): + for record in self: + record.name = f"{record.patient_id.name}-{date.today()}" + + tooth_18_staining = fields.Boolean(string="18 Staining") + tooth_17_staining = fields.Boolean(string="17 Staining") + tooth_16_staining = fields.Boolean(string="16 Staining") + tooth_15_staining = fields.Boolean(string="15 Staining") + tooth_14_staining = fields.Boolean(string="14 Staining") + tooth_13_staining = fields.Boolean(string="13 Staining") + tooth_12_staining = fields.Boolean(string="12 Staining") + tooth_11_staining = fields.Boolean(string="11 Staining") + tooth_28_staining = fields.Boolean(string="28 Staining") + tooth_27_staining = fields.Boolean(string="27 Staining") + tooth_26_staining = fields.Boolean(string="26 Staining") + tooth_25_staining = fields.Boolean(string="25 Staining") + tooth_24_staining = fields.Boolean(string="24 Staining") + tooth_23_staining = fields.Boolean(string="23 Staining") + tooth_22_staining = fields.Boolean(string="22 Staining") + tooth_21_staining = fields.Boolean(string="21 Staining") + tooth_38_staining = fields.Boolean(string="38 Staining") + tooth_37_staining = fields.Boolean(string="37 Staining") + tooth_36_staining = fields.Boolean(string="36 Staining") + tooth_35_staining = fields.Boolean(string="35 Staining") + tooth_34_staining = fields.Boolean(string="34 Staining") + tooth_33_staining = fields.Boolean(string="33 Staining") + tooth_32_staining = fields.Boolean(string="32 Staining") + tooth_31_staining = fields.Boolean(string="31 Staining") + tooth_41_staining = fields.Boolean(string="41 Staining") + tooth_42_staining = fields.Boolean(string="42 Staining") + tooth_43_staining = fields.Boolean(string="43 Staining") + tooth_44_staining = fields.Boolean(string="44 Staining") + tooth_45_staining = fields.Boolean(string="45 Staining") + tooth_46_staining = fields.Boolean(string="46 Staining") + tooth_47_staining = fields.Boolean(string="47 Staining") + tooth_48_staining = fields.Boolean(string="48 Staining") \ No newline at end of file diff --git a/dental/models/dental_medical_symptoms.py b/dental/models/dental_medical_symptoms.py index 5ba4c6da90..e1c9a7bd70 100644 --- a/dental/models/dental_medical_symptoms.py +++ b/dental/models/dental_medical_symptoms.py @@ -1,9 +1,10 @@ -from odoo import api, models, fields +from odoo import models, fields class DentalMedicalSymptoms(models.Model): _name = "dental.medical.symptoms" _description = "Dental Medical Symptoms" + _inherit = ['mail.thread', 'mail.activity.mixin'] name = fields.Char(string='Name') diff --git a/dental/models/dental_medication.py b/dental/models/dental_medication.py index ba2992d05d..d447738b60 100644 --- a/dental/models/dental_medication.py +++ b/dental/models/dental_medication.py @@ -1,10 +1,11 @@ -from odoo import api, models, fields +from odoo import models, fields class DentalMedication(models.Model): _name = "dental.medication" _description = "Dental Medication" + _inherit = ['mail.thread', 'mail.activity.mixin'] name = fields.Char(string='Name') sequence = fields.Integer('Sequence') diff --git a/dental/models/dental_patient.py b/dental/models/dental_patient.py index 5ad5dd8d81..cb7d69b196 100644 --- a/dental/models/dental_patient.py +++ b/dental/models/dental_patient.py @@ -1,24 +1,27 @@ -from odoo import api, models, fields +from odoo import models, fields , Command class DentalPatient(models.Model): _name = "dental.patient" _description = "Dental Patient" + _inherit = ['mail.thread', 'mail.activity.mixin'] - name = fields.Char(string="Name") + name = fields.Char(string="Name", required=True) + image = fields.Image('Image') gp_id = fields.Many2one('res.partner', string="GP's Name") gp_phone = fields.Char(related='gp_id.phone', string="GP's Phone", readonly=True) - chronic_conditions = fields.Many2many( - 'dental.chronic.condition', string="Chronic Conditions") - medication = fields.Many2many('dental.medication', string="Medication") - hospitalized_this_year = fields.Boolean(string="Hospitalised this Year") - allergies = fields.Char(string="Allergies") + chronic_conditions_ids = fields.Many2many( + 'dental.chronic.conditions', string="Chronic Conditions") + medication_ids = fields.Many2many('dental.medication', string="Medication") + hospitalized_this_year = fields.Text(string="Hospitalised this Year") + allergies_ids = fields.Many2many('dental.allergies', string="Allergies") notes = fields.Text(string='Notes') - habits_substance_abuse = fields.Char(string="Habits/Substance Abuse") + habits_substance_abuse_ids = fields.Many2many('dental.habits', string="Habits/Substance Abuse") under_specialist_care = fields.Char(string="Under Specialist Care") psychiatric_history = fields.Char(string="Psychiatric History") + female = fields.Boolean(string="Female") is_pregnant = fields.Boolean(string="Are you pregnant?", default=False) is_nursing = fields.Boolean(string="Are you nursing?", default=False) @@ -27,8 +30,65 @@ class DentalPatient(models.Model): ('birth_control', 'Birth control'), ('neither', 'Neither') ], string="Are you on...?", default='neither') - medical_aid = fields.Many2one('dental.medical.aids', string="Medical Aid") + + medical_aid_id = fields.Many2one( + 'dental.medical.aids', string="Medical Aid") medical_aid_plan = fields.Char(string='Medical Aid Plan') medical_aid_number = fields.Integer(string='Medical Aid Number') main_member_code = fields.Integer(string='Medical Member Code') dependent_code = fields.Integer(string='Dependent Code') + + emergency_contact_id = fields.Many2one( + 'res.partner', string="Emergency Contact") + mobile = fields.Char(related='emergency_contact_id.phone', string='Mobile') + + company_school_id = fields.Many2one('res.partner', string="Company or School") + occupation_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") + marital_status = fields.Selection([ + ('single', 'Single'), + ('married', 'Married'), + ('divorced', 'Divorced'), + ('widowed', 'Widowed') + ], string="Marital Status") + + consent_signature = fields.Binary(string="Consent Signature") + consent_date = fields.Date(string="Consent Date") + + + guarantor_id = fields.Many2one( + 'res.partner', string="Guarantor") + guarantor_mobile = fields.Char( + related='guarantor_id.mobile', string="Guarantor Mobile Phone", readonly=True) + guarantor_phone = fields.Char(related='guarantor_id.phone', string="Phone") + guarantor_email = fields.Char(related='guarantor_id.email', string="Email") + + tags = fields.Char(string="Tags") + company_id = fields.Many2one( + 'res.company', string="Company", default=lambda self: self.env.company) + + + history_ids = fields.One2many('dental.medical.history', 'patient_id') + state = fields.Selection(string='Status', default='new', + selection=[('new', 'New'), ('to do today', 'To Do Today'), ('done', 'Done'), ('to invoice', 'To Invoice')]) + + def book_an_appointment(self): + move_values = { + "partner_id": self.guarantor_id.id, + "move_type": "out_invoice", + 'invoice_date': fields.Date.today(), + "invoice_line_ids": [ + Command.create({ + "name": "consultant fee", + "quantity": 1, + "price_unit": 500 + }) + ], + } + self.env['account.move'].sudo().create(move_values) diff --git a/dental/security/ir.model.access.csv b/dental/security/ir.model.access.csv index d34a07464e..77a63bac11 100644 --- a/dental/security/ir.model.access.csv +++ b/dental/security/ir.model.access.csv @@ -7,6 +7,7 @@ access_dental_configuration,access_dental_configuration,model_dental_configurati access_dental_chronic_conditions,access_dental_chronic_conditions,model_dental_chronic_conditions,base.group_user,1,1,1,1 access_dental_allergies,access_dental_allergies,model_dental_allergies,base.group_user,1,1,1,1 access_dental_habits,access_dental_habits,model_dental_habits,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 diff --git a/dental/static/tooth.png b/dental/static/tooth.png new file mode 100644 index 0000000000..5d6ab6fb3a Binary files /dev/null and b/dental/static/tooth.png differ diff --git a/dental/views/dental_allergies_view.xml b/dental/views/dental_allergies_view.xml index 5d25032f8e..fffa6825eb 100644 --- a/dental/views/dental_allergies_view.xml +++ b/dental/views/dental_allergies_view.xml @@ -27,6 +27,11 @@ +