diff --git a/clinic_management/__init__.py b/clinic_management/__init__.py new file mode 100644 index 0000000..aa4d0fd --- /dev/null +++ b/clinic_management/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- + +from . import controllers +from . import models diff --git a/clinic_management/__manifest__.py b/clinic_management/__manifest__.py new file mode 100644 index 0000000..d06416b --- /dev/null +++ b/clinic_management/__manifest__.py @@ -0,0 +1,35 @@ +# -*- coding: utf-8 -*- +{ + 'name': "Clinic Management", + + 'summary': "Phần mềm quản lý phòng khám", + + 'description': """ + Phần mềm quản lý phòng khám + """, + + 'author': "NXHuyen", + 'website': "https://www.nxhuyen.com", + + 'category': 'Management', + 'version': '0.1', + + 'depends': ['base'], + + 'data': [ + 'security/ir.model.access.csv', + # 'security/clinic_security.xml', + 'views/clinic_patient_views.xml', + 'views/clinic_appointment_views.xml', + 'views/clinic_medicine_views.xml', + 'views/clinic_prescription_views.xml', + 'views/clinic_prescription_line_views.xml', + 'views/clinic_service_views.xml', + 'views/clinic_menus.xml', + ], + + 'application': True, + 'installable': True, + 'auto_install': False, +} + diff --git a/clinic_management/controllers/__init__.py b/clinic_management/controllers/__init__.py new file mode 100644 index 0000000..b0f26a9 --- /dev/null +++ b/clinic_management/controllers/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +from . import controllers diff --git a/clinic_management/controllers/controllers.py b/clinic_management/controllers/controllers.py new file mode 100644 index 0000000..d031842 --- /dev/null +++ b/clinic_management/controllers/controllers.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +# from odoo import http + + +# class ClinicManagement(http.Controller): +# @http.route('/clinic_management/clinic_management', auth='public') +# def index(self, **kw): +# return "Hello, world" + +# @http.route('/clinic_management/clinic_management/objects', auth='public') +# def list(self, **kw): +# return http.request.render('clinic_management.listing', { +# 'root': '/clinic_management/clinic_management', +# 'objects': http.request.env['clinic_management.clinic_management'].search([]), +# }) + +# @http.route('/clinic_management/clinic_management/objects/', auth='public') +# def object(self, obj, **kw): +# return http.request.render('clinic_management.object', { +# 'object': obj +# }) + diff --git a/clinic_management/demo/demo.xml b/clinic_management/demo/demo.xml new file mode 100644 index 0000000..2ae2c42 --- /dev/null +++ b/clinic_management/demo/demo.xml @@ -0,0 +1,30 @@ + + + + + diff --git a/clinic_management/models/__init__.py b/clinic_management/models/__init__.py new file mode 100644 index 0000000..f515cf5 --- /dev/null +++ b/clinic_management/models/__init__.py @@ -0,0 +1,8 @@ +# -*- coding: utf-8 -*- + +from . import clinic_medicine +from . import clinic_patient +from . import clinic_appointment +from . import clinic_prescription +from . import clinic_prescription_line +from . import clinic_service diff --git a/clinic_management/models/clinic_appointment.py b/clinic_management/models/clinic_appointment.py new file mode 100644 index 0000000..310fa1f --- /dev/null +++ b/clinic_management/models/clinic_appointment.py @@ -0,0 +1,30 @@ +from odoo import models, fields, api + +class ClinicAppointment(models.Model): + _name = 'clinic.appointment' + _description = 'Lịch hẹn' + _rec_name = 'patient_id' + + patient_id = fields.Many2one('clinic.patient', string='Bệnh nhân', required=True) + doctor_id = fields.Many2one('res.partner', string='Bác sĩ', required=True) + date = fields.Date(string='Ngày kê đơn', default=fields.Date.today) + state = fields.Selection([ + ('scheduled', 'Đã lên lịch'), + ('done', 'Hoàn thành'), + ('cancel', 'Hủy') + ], string='Trạng thái', default='scheduled') + + services_ids = fields.Many2many('clinic.service', string='Dịch vụ khám') + total_price = fields.Float(string='Tổng tiền', compute='_compute_total_price') + + def action_scheduled(self): + self.state = 'scheduled' + def action_done(self): + self.state = 'done' + def action_cancel(self): + self.state = 'cancel' + + @api.depends('services_ids') + def _compute_total_price(self): + for rec in self: + rec.total_price = sum(rec.services_ids.mapped('price')) \ No newline at end of file diff --git a/clinic_management/models/clinic_medicine.py b/clinic_management/models/clinic_medicine.py new file mode 100644 index 0000000..58afa2f --- /dev/null +++ b/clinic_management/models/clinic_medicine.py @@ -0,0 +1,15 @@ +from odoo import models, fields, api + +class ClinicMedicine(models.Model): + _name = 'clinic.medicine' + _description = 'Thuốc' + + name = fields.Char(string='Tên thuốc', required=True) + category = fields.Selection([ + ('antibiotics', 'Kháng sinh'), + ('painkiller', 'Giảm đau'), + ('vitamins', 'Vitamins'), + ('others', 'Khác') + ], string='Phân loại thuốc') + price = fields.Float(string='Giá') + stock = fields.Integer(string='Số lượng') diff --git a/clinic_management/models/clinic_patient.py b/clinic_management/models/clinic_patient.py new file mode 100644 index 0000000..21a1a6a --- /dev/null +++ b/clinic_management/models/clinic_patient.py @@ -0,0 +1,14 @@ +from odoo import models, fields, api + +class ClinicPatient(models.Model): + _name = 'clinic.patient' + _description = 'Bệnh nhân' + + name = fields.Char(string='Tên bệnh nhân', required=True) + dob = fields.Date(string='Ngày sinh') + gender = fields.Selection([ + ('male', 'Male'), + ('female', 'Female') + ], string='Giới tính') + phone = fields.Char(string='Số điện thoại') + medical_history = fields.Text(string='Lịch sử bệnh án') \ No newline at end of file diff --git a/clinic_management/models/clinic_prescription.py b/clinic_management/models/clinic_prescription.py new file mode 100644 index 0000000..a307768 --- /dev/null +++ b/clinic_management/models/clinic_prescription.py @@ -0,0 +1,24 @@ +from odoo import models, fields, api +from odoo.exceptions import UserError + +class ClinicPrescription(models.Model): + _name = 'clinic.prescription' + _description = 'Đơn thuốc' + _rec_name = 'patient_id' + + patient_id = fields.Many2one('clinic.patient', string='Bệnh nhân', required=True) + doctor_id = fields.Many2one('res.partner', string='Bác sĩ', required=True) + date = fields.Date(string='Ngày kê đơn', default=fields.Date.today) + prescription_line_ids = fields.One2many('clinic.prescription.line', 'prescription_id', string='Chi tiết đơn thuốc') + + # khi kê đơn thì trừ số lượng thuốc trong kho + def action_prescribe(self): + for line in self.prescription_line_ids: + if line.quantity <= 0: + raise UserError(f"Số lượng thuốc {line.medicine_id.name} phải lớn hơn 0!") + else: + if line.medicine_id.stock < line.quantity: + raise UserError(f"Số lượng thuốc {line.medicine_id.name} không đủ trong kho!") + else: + line.medicine_id.stock -= line.quantity + \ No newline at end of file diff --git a/clinic_management/models/clinic_prescription_line.py b/clinic_management/models/clinic_prescription_line.py new file mode 100644 index 0000000..b92756d --- /dev/null +++ b/clinic_management/models/clinic_prescription_line.py @@ -0,0 +1,23 @@ +from odoo import models, fields, api + +class ClinicPrescriptionLine(models.Model): + _name = 'clinic.prescription.line' + _description = 'Chi tiết đơn thuốc' + _rec_name = 'prescription_id' + + prescription_id = fields.Many2one('clinic.prescription', string='Đơn thuốc', required=True) + medicine_id = fields.Many2one('clinic.medicine', string='Thuốc', required=True) + quantity = fields.Integer(string='Số lượng', required=True) + color = fields.Integer(string="Màu sắc", compute="_compute_line_color", store=True) + + @api.depends('medicine_id.category') + def _compute_line_color(self): + for line in self: + if line.medicine_id.category == 'antibiotics': + line.color = 1 + elif line.medicine_id.category == 'painkiller': + line.color = 2 + elif line.medicine_id.category == 'vitamins': + line.color = 3 + else: + line.color = 4 \ No newline at end of file diff --git a/clinic_management/models/clinic_service.py b/clinic_management/models/clinic_service.py new file mode 100644 index 0000000..a4f236d --- /dev/null +++ b/clinic_management/models/clinic_service.py @@ -0,0 +1,8 @@ +from odoo import models, fields, api + +class ClinicService(models.Model): + _name = 'clinic.service' + _description = 'Dịch vụ' + + name = fields.Char(string='Tên dịch vụ', required=True) + price = fields.Float(string='Giá dịch vụ') \ No newline at end of file diff --git a/clinic_management/security/clinic_security.xml b/clinic_management/security/clinic_security.xml new file mode 100644 index 0000000..319f60c --- /dev/null +++ b/clinic_management/security/clinic_security.xml @@ -0,0 +1,26 @@ + + + + + + + Admin + + + + + Doctor + + + + + Receptionist + + + + + Patient + + + + \ No newline at end of file diff --git a/clinic_management/security/ir.model.access.csv b/clinic_management/security/ir.model.access.csv new file mode 100644 index 0000000..96b0cbd --- /dev/null +++ b/clinic_management/security/ir.model.access.csv @@ -0,0 +1,7 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_clinic_appointment,clinic.appointment,model_clinic_appointment,base.group_user,1,1,1,1 +access_clinic_medicine,clinic.medicine,model_clinic_medicine,base.group_user,1,1,1,1 +access_clinic_patient,clinic.patient,model_clinic_patient,base.group_user,1,1,1,1 +access_clinic_prescription,clinic.prescription,model_clinic_prescription,base.group_user,1,1,1,1 +access_clinic_prescription_line,clinic.prescription.line,model_clinic_prescription_line,base.group_user,1,1,1,1 +access_clinic_service,clinic.service,model_clinic_service,base.group_user,1,1,1,1 \ No newline at end of file diff --git a/clinic_management/views/clinic_appointment_views.xml b/clinic_management/views/clinic_appointment_views.xml new file mode 100644 index 0000000..3621d6e --- /dev/null +++ b/clinic_management/views/clinic_appointment_views.xml @@ -0,0 +1,54 @@ + + + + + + clinic.appointment.view.form + clinic.appointment + +
+
+
+ + + + + + + + + +
+
+
+ + + + clinic.appointment.view.form + clinic.appointment + + + + + + + + + + + + + + Lịch hẹn + clinic.appointment + list,form + + +
\ No newline at end of file diff --git a/clinic_management/views/clinic_medicine_views.xml b/clinic_management/views/clinic_medicine_views.xml new file mode 100644 index 0000000..5629e61 --- /dev/null +++ b/clinic_management/views/clinic_medicine_views.xml @@ -0,0 +1,43 @@ + + + + + + clinic.medicine.view.form + clinic.medicine + +
+ + + + + + + + +
+
+
+ + + + clinic.medicine.view.tree + clinic.medicine + + + + + + + + + + + + + Thuốc + clinic.medicine + list,form + + +
\ No newline at end of file diff --git a/clinic_management/views/clinic_menus.xml b/clinic_management/views/clinic_menus.xml new file mode 100644 index 0000000..e159eac --- /dev/null +++ b/clinic_management/views/clinic_menus.xml @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/clinic_management/views/clinic_patient_views.xml b/clinic_management/views/clinic_patient_views.xml new file mode 100644 index 0000000..8ccd570 --- /dev/null +++ b/clinic_management/views/clinic_patient_views.xml @@ -0,0 +1,51 @@ + + + + + + clinic.patient.view.form + clinic.patient + +
+ + + + + + + + + + + + + + + +
+
+
+ + + + clinic.patient.view.tree + clinic.patient + + + + + + + + + + + + + + Bệnh nhân + clinic.patient + list,form + + +
\ No newline at end of file diff --git a/clinic_management/views/clinic_prescription_line_views.xml b/clinic_management/views/clinic_prescription_line_views.xml new file mode 100644 index 0000000..508eae7 --- /dev/null +++ b/clinic_management/views/clinic_prescription_line_views.xml @@ -0,0 +1,41 @@ + + + + + + clinic.prescription.line.view.form + clinic.prescription.line + +
+ + + + + + + +
+
+
+ + + + clinic.prescription.line.view.tree + clinic.prescription.line + + + + + + + + + + + + Chi tiết đơn thuốc + clinic.prescription.line + list,form + + +
\ No newline at end of file diff --git a/clinic_management/views/clinic_prescription_views.xml b/clinic_management/views/clinic_prescription_views.xml new file mode 100644 index 0000000..2e593fa --- /dev/null +++ b/clinic_management/views/clinic_prescription_views.xml @@ -0,0 +1,52 @@ + + + + + + clinic.prescription.view.form + clinic.prescription + +
+
+
+ + + + + + + + + + + + + +
+
+
+ + + + clinic.prescription.view.tree + clinic.prescription + + + + + + + + + + + + + Đơn thuốc + clinic.prescription + list,form + + +
\ No newline at end of file diff --git a/clinic_management/views/clinic_service_views.xml b/clinic_management/views/clinic_service_views.xml new file mode 100644 index 0000000..79e6e47 --- /dev/null +++ b/clinic_management/views/clinic_service_views.xml @@ -0,0 +1,39 @@ + + + + + + clinic.service.view.form + clinic.service + +
+ + + + + + +
+
+
+ + + + clinic.service.view.tree + clinic.service + + + + + + + + + + + Dịch vụ + clinic.service + list,form + + +
\ No newline at end of file