Skip to content

Commit

Permalink
[IMP] dental: added web controller
Browse files Browse the repository at this point in the history
After this commit:
-added added data
-added basic appointment booking
  • Loading branch information
smee-odoo committed Sep 9, 2024
1 parent 0333ec0 commit d5316f9
Show file tree
Hide file tree
Showing 12 changed files with 451 additions and 104 deletions.
9 changes: 6 additions & 3 deletions dental/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@
'version': '1.2',
'description': "",
'depends': [
'base_setup', 'website',
'mail'
'base', 'website',
'mail', 'account'
],
'data': [
'security/ir.model.access.csv',


'data/dental_data.xml',
'data/dental_tags.xml',

'views/portal_template.xml',
'views/tag_views.xml',
'views/medical_history_views.xml',
Expand Down
69 changes: 42 additions & 27 deletions dental/controller/portal.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,46 @@
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)
class DentalPortal(CustomerPortal):
@http.route('/my/dental', type='http', auth='user', website=True)
def portal_my_dental(self, **kw):
current = request.env.user.id
users = request.env['dental.patient'].search([('guarantor_id', '=', current)])
return request.render('dental.portal_my_dental', {
'users': users
})

@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/<int:patient_id>/medical_history', type='http', auth='user', website=True)
def portal_my_dental_medical_history(self, patient_id, **kw):
medical_historys = request.env['medical.history'].search([('patient_id', '=', patient_id)])
return request.render('dental.portal_my_dental_medical_history', {
'medical_historys': medical_historys
})

@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'].search([]).insurance_id
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):

return request.render('dental.portal_my_dental_dental_history', {
})
35 changes: 35 additions & 0 deletions dental/data/dental_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0"?>
<odoo noupdate="1">
<!-- Medical SYmptoms DATA -->

<record model="chronic.conditions" id="chronic_type1">
<field name="name">Diabetes- Type 2</field>
</record>
<record model="chronic.conditions" id="chronic_type2">
<field name="name">Heart Conditions</field>
</record>
<record model="dental.allergies" id="allergies_type1">
<field name="name">Latex</field>
</record>
<record model="dental.allergies" id="allergies_type2">
<field name="name">Mercury</field>
</record>
<record model="habits.substance" id="habits_type1">
<field name="name">Alcohol</field>
</record>

<!-- Medication DATA -->

<record model="dental.medication" id="habits_type1">
<field name="name">Acetaminophen</field>
</record>
<record model="dental.medication" id="habits_type2">
<field name="name">Corticosteroids</field>
</record>
<record model="dental.medication" id="habits_type3">
<field name="name">Ibuprofen</field>
</record>
<record model="dental.medication" id="habits_type4">
<field name="name">Pilocarpine</field>
</record>
</odoo>
108 changes: 108 additions & 0 deletions dental/data/dental_tags.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<data noupdate="1">
<!-- Incisors -->
<record id="dental_tag_incisor_upper_left_1" model="dental.tags">
<field name="name">Upper Left Central Incisor</field>
</record>
<record id="dental_tag_incisor_upper_left_2" model="dental.tags">
<field name="name">Upper Left Lateral Incisor</field>
</record>
<record id="dental_tag_incisor_upper_right_1" model="dental.tags">
<field name="name">Upper Right Central Incisor</field>
</record>
<record id="dental_tag_incisor_upper_right_2" model="dental.tags">
<field name="name">Upper Right Lateral Incisor</field>
</record>
<record id="dental_tag_incisor_lower_left_1" model="dental.tags">
<field name="name">Lower Left Central Incisor</field>
</record>
<record id="dental_tag_incisor_lower_left_2" model="dental.tags">
<field name="name">Lower Left Lateral Incisor</field>
</record>
<record id="dental_tag_incisor_lower_right_1" model="dental.tags">
<field name="name">Lower Right Central Incisor</field>
</record>
<record id="dental_tag_incisor_lower_right_2" model="dental.tags">
<field name="name">Lower Right Lateral Incisor</field>
</record>

<!-- Canines -->
<record id="dental_tag_canine_upper_left" model="dental.tags">
<field name="name">Upper Left Canine</field>
</record>
<record id="dental_tag_canine_upper_right" model="dental.tags">
<field name="name">Upper Right Canine</field>
</record>
<record id="dental_tag_canine_lower_left" model="dental.tags">
<field name="name">Lower Left Canine</field>
</record>
<record id="dental_tag_canine_lower_right" model="dental.tags">
<field name="name">Lower Right Canine</field>
</record>

<!-- Premolars -->
<record id="dental_tag_premolar_upper_left_1" model="dental.tags">
<field name="name">Upper Left First Premolar</field>
</record>
<record id="dental_tag_premolar_upper_left_2" model="dental.tags">
<field name="name">Upper Left Second Premolar</field>
</record>
<record id="dental_tag_premolar_upper_right_1" model="dental.tags">
<field name="name">Upper Right First Premolar</field>
</record>
<record id="dental_tag_premolar_upper_right_2" model="dental.tags">
<field name="name">Upper Right Second Premolar</field>
</record>
<record id="dental_tag_premolar_lower_left_1" model="dental.tags">
<field name="name">Lower Left First Premolar</field>
</record>
<record id="dental_tag_premolar_lower_left_2" model="dental.tags">
<field name="name">Lower Left Second Premolar</field>
</record>
<record id="dental_tag_premolar_lower_right_1" model="dental.tags">
<field name="name">Lower Right First Premolar</field>
</record>
<record id="dental_tag_premolar_lower_right_2" model="dental.tags">
<field name="name">Lower Right Second Premolar</field>
</record>

<!-- Molars -->
<record id="dental_tag_molar_upper_left_1" model="dental.tags">
<field name="name">Upper Left First Molar</field>
</record>
<record id="dental_tag_molar_upper_left_2" model="dental.tags">
<field name="name">Upper Left Second Molar</field>
</record>
<record id="dental_tag_molar_upper_left_3" model="dental.tags">
<field name="name">Upper Left Third Molar (Wisdom Tooth)</field>
</record>
<record id="dental_tag_molar_upper_right_1" model="dental.tags">
<field name="name">Upper Right First Molar</field>
</record>
<record id="dental_tag_molar_upper_right_2" model="dental.tags">
<field name="name">Upper Right Second Molar</field>
</record>
<record id="dental_tag_molar_upper_right_3" model="dental.tags">
<field name="name">Upper Right Third Molar (Wisdom Tooth)</field>
</record>
<record id="dental_tag_molar_lower_left_1" model="dental.tags">
<field name="name">Lower Left First Molar</field>
</record>
<record id="dental_tag_molar_lower_left_2" model="dental.tags">
<field name="name">Lower Left Second Molar</field>
</record>
<record id="dental_tag_molar_lower_left_3" model="dental.tags">
<field name="name">Lower Left Third Molar (Wisdom Tooth)</field>
</record>
<record id="dental_tag_molar_lower_right_1" model="dental.tags">
<field name="name">Lower Right First Molar</field>
</record>
<record id="dental_tag_molar_lower_right_2" model="dental.tags">
<field name="name">Lower Right Second Molar</field>
</record>
<record id="dental_tag_molar_lower_right_3" model="dental.tags">
<field name="name">Lower Right Third Molar (Wisdom Tooth)</field>
</record>
</data>
</odoo>
1 change: 1 addition & 0 deletions dental/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
from . import medication
from . import medical_history
from . import dental_tags
# from . import account_move
7 changes: 7 additions & 0 deletions dental/models/account_move.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# from odoo import models, fields


# class AccountMove(models.Model):
# _inherit = "account.move"

# patient_id = fields.Many2one('dental.patient', string="Patient name")
46 changes: 25 additions & 21 deletions dental/models/dental_patients.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
from odoo import models, fields, Command
from datetime import date
from dateutil.relativedelta import relativedelta


class DentalPatients(models.Model):
Expand All @@ -25,10 +23,17 @@ class DentalPatients(models.Model):
string="Company",
copy=False
)
patient_guarantor_id = fields.Many2one(
'dental.guarantor',
string="Guranator"
guarantor_id = fields.Many2one(
'res.users',
string="Guarantor",
copy=False
)
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")
guarantor_company = fields.Many2one('res.company')
tag_ids = fields.Many2many('dental.tags', string="Tags")

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")
Expand Down Expand Up @@ -74,10 +79,11 @@ class DentalPatients(models.Model):
depedent_code = fields.Char(string="Dependent Code")
medical_history_ids = fields.One2many('medical.history', 'patient_id', string="Medical History")

def book_appointment_button(self):
def book_invoice_button(self):
self.stage = 'to invoice'
self.guarantor_id = self.env.user.id
move_vals = {
'partner_id': self.patient_guarantor_id.guarantor_id.id,
'partner_id': self.guarantor_id.id,
'move_type': 'out_invoice',
'invoice_line_ids': [
Command.create({
Expand All @@ -91,17 +97,15 @@ def book_appointment_button(self):
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()
def book_appointment_button(self):
move_vals = {
'appointment_duration': 1,
'appointment_tz': self.env.user.tz,
'assign_method': 'resource_time',
'max_schedule_days': 1,
'min_cancellation_hours': 24,
'min_schedule_hours': 48,
'name': 'Appointment',
'schedule_based_on': 'users',
}
self.env['appointment.type'].sudo().create(move_vals)
7 changes: 0 additions & 7 deletions dental/models/medical_aids.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,3 @@ 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')

10 changes: 7 additions & 3 deletions dental/models/medical_symptoms.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,26 @@ class MedicalSymptoms(models.Model):
sequence = fields.Integer('Sequence', default=1, help="Used to order types. Lower is better.")
parent_id = fields.Many2one('medical.symptoms')


class ChronicConditions(models.Model):
_name = "chronic.conditions"
_description = "Chronic medical symptoms"
_inherits = {'medical.symptoms':'medical_symptoms_id'}
_inherits = {'medical.symptoms': 'medical_symptoms_id'}

medical_symptoms_id = fields.Many2one('medical.symptoms')


class Allergies(models.Model):
_name = "dental.allergies"
_description = "Allergies"
_inherits = {'medical.symptoms':'medical_symptoms_id'}
_inherits = {'medical.symptoms': 'medical_symptoms_id'}

medical_symptoms_id = fields.Many2one('medical.symptoms')


class HabitsSubstance(models.Model):
_name = "habits.substance"
_description = "Habits and substance abuse info"
_inherits = {'medical.symptoms':'medical_symptoms_id'}
_inherits = {'medical.symptoms': 'medical_symptoms_id'}

medical_symptoms_id = fields.Many2one('medical.symptoms')
2 changes: 0 additions & 2 deletions dental/security/ir.model.access.csv
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,5 @@ dental.access_chronic_conditions,access_chronic_conditions,dental.model_chronic_
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_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
Loading

0 comments on commit d5316f9

Please sign in to comment.