clinic management
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import controllers
|
||||
from . import models
|
||||
@@ -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,
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import controllers
|
||||
@@ -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/<model("clinic_management.clinic_management"):obj>', auth='public')
|
||||
# def object(self, obj, **kw):
|
||||
# return http.request.render('clinic_management.object', {
|
||||
# 'object': obj
|
||||
# })
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
<odoo>
|
||||
<data>
|
||||
<!--
|
||||
<record id="object0" model="clinic_management.clinic_management">
|
||||
<field name="name">Object 0</field>
|
||||
<field name="value">0</field>
|
||||
</record>
|
||||
|
||||
<record id="object1" model="clinic_management.clinic_management">
|
||||
<field name="name">Object 1</field>
|
||||
<field name="value">10</field>
|
||||
</record>
|
||||
|
||||
<record id="object2" model="clinic_management.clinic_management">
|
||||
<field name="name">Object 2</field>
|
||||
<field name="value">20</field>
|
||||
</record>
|
||||
|
||||
<record id="object3" model="clinic_management.clinic_management">
|
||||
<field name="name">Object 3</field>
|
||||
<field name="value">30</field>
|
||||
</record>
|
||||
|
||||
<record id="object4" model="clinic_management.clinic_management">
|
||||
<field name="name">Object 4</field>
|
||||
<field name="value">40</field>
|
||||
</record>
|
||||
-->
|
||||
</data>
|
||||
</odoo>
|
||||
@@ -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
|
||||
@@ -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'))
|
||||
@@ -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')
|
||||
@@ -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')
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
@@ -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ụ')
|
||||
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
|
||||
<data noupdate="1">
|
||||
<!-- nhóm admin -->
|
||||
<record id="group_clinic_admin" model="res.groups">
|
||||
<field name="name">Admin</field>
|
||||
</record>
|
||||
|
||||
<!-- nhóm bác sĩ -->
|
||||
<record id="group_clinic_doctor" model="res.groups">
|
||||
<field name="name">Doctor</field>
|
||||
</record>
|
||||
|
||||
<!-- nhóm lễ tân -->
|
||||
<record id="group_clinic_receptionist" model="res.groups">
|
||||
<field name="name">Receptionist</field>
|
||||
</record>
|
||||
|
||||
<!-- nhóm bệnh nhân -->
|
||||
<record id="group_clinic_patient" model="res.groups">
|
||||
<field name="name">Patient</field>
|
||||
</record>
|
||||
</data>
|
||||
|
||||
</odoo>
|
||||
@@ -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
|
||||
|
@@ -0,0 +1,54 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
|
||||
<!-- form view -->
|
||||
<record id="view_clinic_appointment_form" model="ir.ui.view">
|
||||
<field name="name">clinic.appointment.view.form</field>
|
||||
<field name="model">clinic.appointment</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="">
|
||||
<header>
|
||||
<button name="action_done" type="object" string="Hoàn thành"
|
||||
invisible="state == 'done' or state == 'cancel'" />
|
||||
<button name="action_cancel" type="object" string="Đã hủy"
|
||||
invisible="state == 'done' or state == 'cancel'" />
|
||||
<button name="action_scheduled" type="object" string="Đã lên lịch"
|
||||
invisible="state != 'cancel'" />
|
||||
<field name="state" widget="statusbar" statusbar_visible="scheduled,done,cancel" />
|
||||
</header>
|
||||
<sheet>
|
||||
<group>
|
||||
<field name="patient_id" />
|
||||
<field name="doctor_id" />
|
||||
<field name="date" />
|
||||
<field name="services_ids" widget="many2many_tags" />
|
||||
<field name="total_price" />
|
||||
</group>
|
||||
</sheet>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- list view -->
|
||||
<record id="view_clinic_appointment_tree" model="ir.ui.view">
|
||||
<field name="name">clinic.appointment.view.form</field>
|
||||
<field name="model">clinic.appointment</field>
|
||||
<field name="arch" type="xml">
|
||||
<list string="">
|
||||
<field name="patient_id" />
|
||||
<field name="doctor_id" />
|
||||
<field name="date" />
|
||||
<field name="services_ids" widget="many2many_tags" />
|
||||
<field name="total_price" />
|
||||
</list>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- action -->
|
||||
<record id="action_clinic_appointment" model="ir.actions.act_window">
|
||||
<field name="name">Lịch hẹn</field>
|
||||
<field name="res_model">clinic.appointment</field>
|
||||
<field name="view_mode">list,form</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
@@ -0,0 +1,43 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
|
||||
<!-- form view -->
|
||||
<record id="view_clinic_medicine_form" model="ir.ui.view">
|
||||
<field name="name">clinic.medicine.view.form</field>
|
||||
<field name="model">clinic.medicine</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="">
|
||||
<sheet>
|
||||
<group>
|
||||
<field name="name" />
|
||||
<field name="category" />
|
||||
<field name="price" />
|
||||
<field name="stock" />
|
||||
</group>
|
||||
</sheet>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- list view -->
|
||||
<record id="view_clinic_medicine_tree" model="ir.ui.view">
|
||||
<field name="name">clinic.medicine.view.tree</field>
|
||||
<field name="model">clinic.medicine</field>
|
||||
<field name="arch" type="xml">
|
||||
<list string="">
|
||||
<field name="name" optional="show" />
|
||||
<field name="category" optional="show" />
|
||||
<field name="price" optional="show" />
|
||||
<field name="stock" optional="show" />
|
||||
</list>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- action -->
|
||||
<record id="action_clinic_medicine" model="ir.actions.act_window">
|
||||
<field name="name">Thuốc</field>
|
||||
<field name="res_model">clinic.medicine</field>
|
||||
<field name="view_mode">list,form</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
@@ -0,0 +1,58 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
|
||||
<!-- main menu -->
|
||||
<menuitem
|
||||
id="menu_clinic_management"
|
||||
name="Quản lý phòng khám"
|
||||
sequence="10"/>
|
||||
|
||||
<menuitem
|
||||
id="menu_action_patient"
|
||||
name="Bệnh nhân"
|
||||
action="action_clinic_patient"
|
||||
parent="menu_clinic_management"
|
||||
sequence="10"/>
|
||||
|
||||
<menuitem
|
||||
id="menu_action_medicine"
|
||||
name="Thuốc"
|
||||
action="action_clinic_medicine"
|
||||
parent="menu_clinic_management"
|
||||
sequence="20"/>
|
||||
|
||||
<menuitem
|
||||
id="menu_action_appointment"
|
||||
name="Lịch hẹn"
|
||||
action="action_clinic_appointment"
|
||||
parent="menu_clinic_management"
|
||||
sequence="30"/>
|
||||
|
||||
<menuitem
|
||||
id="menu_action_prescription_root"
|
||||
name="Đơn thuốc"
|
||||
parent="menu_clinic_management"
|
||||
sequence="40"/>
|
||||
|
||||
<menuitem
|
||||
id="menu_action_prescription"
|
||||
name="Đơn thuốc"
|
||||
action="action_action_prescription"
|
||||
parent="menu_action_prescription_root"
|
||||
sequence="10"/>
|
||||
|
||||
<menuitem
|
||||
id="menu_action_prescription_line"
|
||||
name="Chi tiết đơn thuốc"
|
||||
action="action_action_prescription_line"
|
||||
parent="menu_action_prescription_root"
|
||||
sequence="20"/>
|
||||
|
||||
<menuitem
|
||||
id="menu_action_clinic_service"
|
||||
name="Dịch vụ"
|
||||
action="action_clinic_service"
|
||||
parent="menu_clinic_management"
|
||||
sequence="50"/>
|
||||
|
||||
</odoo>
|
||||
@@ -0,0 +1,51 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
|
||||
<!-- form view -->
|
||||
<record id="view_clinic_patient_form" model="ir.ui.view">
|
||||
<field name="name">clinic.patient.view.form</field>
|
||||
<field name="model">clinic.patient</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="">
|
||||
<sheet>
|
||||
<group>
|
||||
<group>
|
||||
<field name="name" />
|
||||
<field name="phone" />
|
||||
</group>
|
||||
<group>
|
||||
<field name="dob" />
|
||||
<field name="gender" />
|
||||
</group>
|
||||
<group>
|
||||
<field name="medical_history" />
|
||||
</group>
|
||||
</group>
|
||||
</sheet>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- list view -->
|
||||
<record id="view_clinic_patient_tree" model="ir.ui.view">
|
||||
<field name="name">clinic.patient.view.tree</field>
|
||||
<field name="model">clinic.patient</field>
|
||||
<field name="arch" type="xml">
|
||||
<list string="">
|
||||
<field name="name" optional='show' />
|
||||
<field name="phone" optional='show' />
|
||||
<field name="dob" optional='show' />
|
||||
<field name="gender" optional='show' />
|
||||
<field name="medical_history" optional='show' />
|
||||
</list>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- action -->
|
||||
<record id="action_clinic_patient" model="ir.actions.act_window">
|
||||
<field name="name">Bệnh nhân</field>
|
||||
<field name="res_model">clinic.patient</field>
|
||||
<field name="view_mode">list,form</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
@@ -0,0 +1,41 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
|
||||
<!-- form view -->
|
||||
<record id="view_clinic_prescription_line_form" model="ir.ui.view">
|
||||
<field name="name">clinic.prescription.line.view.form</field>
|
||||
<field name="model">clinic.prescription.line</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="">
|
||||
<sheet>
|
||||
<group>
|
||||
<field name="prescription_id" />
|
||||
<field name="medicine_id" />
|
||||
<field name="quantity" />
|
||||
</group>
|
||||
</sheet>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- list view -->
|
||||
<record id="view_clinic_prescription_line_tree" model="ir.ui.view">
|
||||
<field name="name">clinic.prescription.line.view.tree</field>
|
||||
<field name="model">clinic.prescription.line</field>
|
||||
<field name="arch" type="xml">
|
||||
<list string="">
|
||||
<field name="prescription_id" optional="show" />
|
||||
<field name="medicine_id" optional="show" />
|
||||
<field name="quantity" optional="show" />
|
||||
</list>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- action -->
|
||||
<record id="action_action_prescription_line" model="ir.actions.act_window">
|
||||
<field name="name">Chi tiết đơn thuốc</field>
|
||||
<field name="res_model">clinic.prescription.line</field>
|
||||
<field name="view_mode">list,form</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
@@ -0,0 +1,52 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
|
||||
<!-- form view -->
|
||||
<record id="view_clinic_prescription_form" model="ir.ui.view">
|
||||
<field name="name">clinic.prescription.view.form</field>
|
||||
<field name="model">clinic.prescription</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="">
|
||||
<header>
|
||||
<button name="action_prescribe" type="object"
|
||||
string="Xác nhận đơn thuốc" class="btn-primary" />
|
||||
</header>
|
||||
<sheet>
|
||||
<group>
|
||||
<field name="patient_id" />
|
||||
<field name="doctor_id" />
|
||||
<field name="date" />
|
||||
<field name="prescription_line_ids">
|
||||
<list editable="bottom">
|
||||
<field name="medicine_id" />
|
||||
<field name="quantity" />
|
||||
</list>
|
||||
</field>
|
||||
</group>
|
||||
</sheet>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- list view -->
|
||||
<record id="view_clinic_prescription_tree" model="ir.ui.view">
|
||||
<field name="name">clinic.prescription.view.tree</field>
|
||||
<field name="model">clinic.prescription</field>
|
||||
<field name="arch" type="xml">
|
||||
<list string="">
|
||||
<field name="patient_id" optional="show" />
|
||||
<field name="doctor_id" optional="show" />
|
||||
<field name="date" optional="show" />
|
||||
<field name="prescription_line_ids" widget="many2many_tags" options="{'color_field': 'color'}" optional="show" />
|
||||
</list>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- action -->
|
||||
<record id="action_action_prescription" model="ir.actions.act_window">
|
||||
<field name="name">Đơn thuốc</field>
|
||||
<field name="res_model">clinic.prescription</field>
|
||||
<field name="view_mode">list,form</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
@@ -0,0 +1,39 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<odoo>
|
||||
|
||||
<!-- form view -->
|
||||
<record id="view_clinic_service_form" model="ir.ui.view">
|
||||
<field name="name">clinic.service.view.form</field>
|
||||
<field name="model">clinic.service</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="">
|
||||
<sheet>
|
||||
<group>
|
||||
<field name="name" />
|
||||
<field name="price" />
|
||||
</group>
|
||||
</sheet>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- list view -->
|
||||
<record id="view_clinic_service_tree" model="ir.ui.view">
|
||||
<field name="name">clinic.service.view.tree</field>
|
||||
<field name="model">clinic.service</field>
|
||||
<field name="arch" type="xml">
|
||||
<list string="">
|
||||
<field name="name" />
|
||||
<field name="price" />
|
||||
</list>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- action -->
|
||||
<record id="action_clinic_service" model="ir.actions.act_window">
|
||||
<field name="name">Dịch vụ</field>
|
||||
<field name="res_model">clinic.service</field>
|
||||
<field name="view_mode">list,form</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user