Skip to content

Commit

Permalink
[IMP] dental: implemented various views, controller and portal
Browse files Browse the repository at this point in the history
After this commit
- added controller so that dental will be visible in my account
- implemented invoice in dental
  • Loading branch information
niku-odoo committed Sep 5, 2024
1 parent 19ec879 commit c386bd1
Show file tree
Hide file tree
Showing 23 changed files with 472 additions and 32 deletions.
13 changes: 8 additions & 5 deletions dental/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions dental/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
from . import dental_allergies
from . import dental_habits
from . import dental_configuration
from . import dental_medical_history
3 changes: 2 additions & 1 deletion dental/models/dental_allergies.py
Original file line number Diff line number Diff line change
@@ -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')
3 changes: 2 additions & 1 deletion dental/models/dental_chronic_conditions.py
Original file line number Diff line number Diff line change
@@ -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')
Expand Down
3 changes: 2 additions & 1 deletion dental/models/dental_configuration.py
Original file line number Diff line number Diff line change
@@ -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')
3 changes: 2 additions & 1 deletion dental/models/dental_habits.py
Original file line number Diff line number Diff line change
@@ -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')
3 changes: 2 additions & 1 deletion dental/models/dental_medical_aids.py
Original file line number Diff line number Diff line change
@@ -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')
Expand Down
98 changes: 98 additions & 0 deletions dental/models/dental_medical_history.py
Original file line number Diff line number Diff line change
@@ -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")
3 changes: 2 additions & 1 deletion dental/models/dental_medical_symptoms.py
Original file line number Diff line number Diff line change
@@ -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')
3 changes: 2 additions & 1 deletion dental/models/dental_medication.py
Original file line number Diff line number Diff line change
@@ -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')
78 changes: 69 additions & 9 deletions dental/models/dental_patient.py
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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)
1 change: 1 addition & 0 deletions dental/security/ir.model.access.csv
Original file line number Diff line number Diff line change
Expand Up @@ -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



Expand Down
Binary file added dental/static/tooth.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions dental/views/dental_allergies_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
</group>
</group>
</sheet>
<div class="oe_chatter">
<field name="message_follower_ids"/>
<field name="message_ids"/>
<field name="activity_ids"/>
</div>
</form>
</field>
</record>
Expand Down
5 changes: 5 additions & 0 deletions dental/views/dental_chronic_conditions_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@
<field name="parent_id" />
</div>
</sheet>
<div class="oe_chatter">
<field name="message_follower_ids"/>
<field name="message_ids"/>
<field name="activity_ids"/>
</div>
</form>
</field>
</record>
Expand Down
5 changes: 5 additions & 0 deletions dental/views/dental_configuration_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
</group>
</group>
</sheet>
<div class="oe_chatter">
<field name="message_follower_ids"/>
<field name="message_ids"/>
<field name="activity_ids"/>
</div>
</form>
</field>
</record>
Expand Down
5 changes: 5 additions & 0 deletions dental/views/dental_habits_view.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="message_follower_ids"/>
<field name="message_ids"/>
<field name="activity_ids"/>
</div>
</form>
</field>
</record>
Expand Down
5 changes: 5 additions & 0 deletions dental/views/dental_medical_aids_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@
<field name="notes" placeholder="Type down your notes here" />
</div>
</sheet>
<div class="oe_chatter">
<field name="message_follower_ids"/>
<field name="message_ids"/>
<field name="activity_ids"/>
</div>
</form>
</field>
</record>
Expand Down
Loading

0 comments on commit c386bd1

Please sign in to comment.