From 156310367f7b73e4ab17db4aff1798aba90a2482 Mon Sep 17 00:00:00 2001 From: "watcha.h" Date: Wed, 29 Oct 2014 16:10:19 +0700 Subject: [PATCH] personal --- netforce_clinic/actions/clinic_patient.xml | 2 +- netforce_clinic/actions/clinic_personal.xml | 8 ++ .../layouts/clinic_hd_case_form.xml | 12 +-- netforce_clinic/layouts/clinic_menu.xml | 13 +-- .../layouts/clinic_patient_form.xml | 3 + .../layouts/clinic_personal_form.xml | 46 +++++++++++ .../layouts/clinic_personal_list.xml | 6 ++ netforce_clinic/migrations/clinic_setting.py | 2 + netforce_clinic/models/__init__.py | 1 + netforce_clinic/models/patient.py | 1 + netforce_clinic/models/personal.py | 80 +++++++++++++++++++ netforce_clinic/models/personal_categ.py | 4 +- netforce_clinic/models/report_clinic.py | 4 +- 13 files changed, 166 insertions(+), 16 deletions(-) create mode 100644 netforce_clinic/actions/clinic_personal.xml create mode 100644 netforce_clinic/layouts/clinic_personal_form.xml create mode 100644 netforce_clinic/layouts/clinic_personal_list.xml create mode 100644 netforce_clinic/models/personal.py diff --git a/netforce_clinic/actions/clinic_patient.xml b/netforce_clinic/actions/clinic_patient.xml index 9ee98a8..a422e6b 100644 --- a/netforce_clinic/actions/clinic_patient.xml +++ b/netforce_clinic/actions/clinic_patient.xml @@ -2,6 +2,6 @@ Patients multi_view clinic.patient - [["All",[]],["Medical Goverment",[["type","=","mg"]]],["Social Security",[["type","=","sc"]]],["NHSO(30฿)",[["type","=","nhso"]]],["Personal",[["type","=","personal"]]],["Others",[["type","=","others"]]],["Archived",[["active","=","False"]]]] + [["All",[]],["Archived",[["active","=","False"]]],["Medical Goverment",[["type","=","mg"]]],["Social Security",[["type","=","sc"]]],["NHSO(30฿)",[["type","=","nhso"]]],["Personal",[["type","=","personal"]]],["Others",[["type","=","others"]]]] clinic_menu diff --git a/netforce_clinic/actions/clinic_personal.xml b/netforce_clinic/actions/clinic_personal.xml new file mode 100644 index 0000000..a8c385b --- /dev/null +++ b/netforce_clinic/actions/clinic_personal.xml @@ -0,0 +1,8 @@ + + Personals + multi_view + clinic.personal + [["All",[]],["Archived",[["active","=",false]]],["Doctor",[["type","=","doctor"]]],["Nurse",[["type","=","nurse"]]]] + list,page,form + clinic_menu + diff --git a/netforce_clinic/layouts/clinic_hd_case_form.xml b/netforce_clinic/layouts/clinic_hd_case_form.xml index b9ccf73..393afc5 100644 --- a/netforce_clinic/layouts/clinic_hd_case_form.xml +++ b/netforce_clinic/layouts/clinic_hd_case_form.xml @@ -11,14 +11,12 @@ - - - + @@ -84,14 +82,16 @@ + + + + - - - + diff --git a/netforce_clinic/layouts/clinic_menu.xml b/netforce_clinic/layouts/clinic_menu.xml index 810b8e4..a6534cc 100644 --- a/netforce_clinic/layouts/clinic_menu.xml +++ b/netforce_clinic/layouts/clinic_menu.xml @@ -1,8 +1,9 @@ - - + + +
@@ -11,13 +12,13 @@ -
- - - +
+ + + diff --git a/netforce_clinic/layouts/clinic_patient_form.xml b/netforce_clinic/layouts/clinic_patient_form.xml index 5faa609..e9c32bc 100644 --- a/netforce_clinic/layouts/clinic_patient_form.xml +++ b/netforce_clinic/layouts/clinic_patient_form.xml @@ -85,6 +85,9 @@ + + + diff --git a/netforce_clinic/layouts/clinic_personal_form.xml b/netforce_clinic/layouts/clinic_personal_form.xml new file mode 100644 index 0000000..0dcca0c --- /dev/null +++ b/netforce_clinic/layouts/clinic_personal_form.xml @@ -0,0 +1,46 @@ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/netforce_clinic/layouts/clinic_personal_list.xml b/netforce_clinic/layouts/clinic_personal_list.xml new file mode 100644 index 0000000..6daf35d --- /dev/null +++ b/netforce_clinic/layouts/clinic_personal_list.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/netforce_clinic/migrations/clinic_setting.py b/netforce_clinic/migrations/clinic_setting.py index e388b72..503d128 100644 --- a/netforce_clinic/migrations/clinic_setting.py +++ b/netforce_clinic/migrations/clinic_setting.py @@ -13,6 +13,7 @@ class Migration(migration.Migration): seq_names=[ ('HDC-','Clinic HD Case'), ('VS-', 'Clinic Visit'), + ('PS-', 'Clinic Personal'), ('PT-', 'Clinic Patient'), ('DT-', 'Clinic Doctor'), ('NS-', 'Clinic Nurse'), @@ -26,6 +27,7 @@ class Migration(migration.Migration): 'type': 'other', }) print("create seq %s successfully " % seq_name) + # insert into clinic_personal(number,name,type, state,picture, active) select number, name,'doctor','temporary', picture, true from clinic_doctor; return Migration.register() diff --git a/netforce_clinic/models/__init__.py b/netforce_clinic/models/__init__.py index b7d838e..2ebc8af 100644 --- a/netforce_clinic/models/__init__.py +++ b/netforce_clinic/models/__init__.py @@ -44,4 +44,5 @@ from . import payment from . import account_payment from . import account_invoice from . import personal_categ +from . import personal from . import schedule diff --git a/netforce_clinic/models/patient.py b/netforce_clinic/models/patient.py index 10132f6..0b040d7 100644 --- a/netforce_clinic/models/patient.py +++ b/netforce_clinic/models/patient.py @@ -77,6 +77,7 @@ class Patient(Model): "partner_id": fields.Many2One("partner","Contact"), "dialyzers": fields.One2Many("clinic.dialyzer","patient_id","Dialyzers"), "active":fields.Boolean("Active"), + 'note': fields.Text("Note"), } diff --git a/netforce_clinic/models/personal.py b/netforce_clinic/models/personal.py new file mode 100644 index 0000000..8dbfda9 --- /dev/null +++ b/netforce_clinic/models/personal.py @@ -0,0 +1,80 @@ +import time + +from netforce.model import Model, fields, get_model +from netforce.access import get_active_company, get_active_user, set_active_user + +class Personal(Model): + _name="clinic.personal" + _string="Personal" + _audit_log=True + _multi_company=True + + def _get_age(self,ids,context): + res={} + year_now=int(time.strftime("%Y")) + for obj in self.browse(ids): + age=0 + if obj.birthday: + year_bd=int(obj.birthday[0:4]) + age=year_now-year_bd + res[obj.id]=age + return res + + _fields={ + "number": fields.Char("Ref.",required=True,search=True), + "name": fields.Char("Name",required=True,search=True), + "identification" : fields.Char("Identification"), + "expiry_card" : fields.Date("Card Expiry"), + "birthday": fields.Date("Birthday",search=True), + "age": fields.Integer("Age", function="_get_age"), + "state": fields.Selection([["temporary","Temporary"],["permanent","Permanent"]],"Status"), + "type": fields.Selection([["doctor","Doctor"],["nurse","Nurse"],["other","Other"]],"Type"), + "mobile": fields.Char("Mobile",required=False,search=True), + "phone": fields.Char("Phone",search=True), + 'email': fields.Char("Email"), + "prof_license" : fields.Char("License."), + "prof_license_date" : fields.Date("License Date"), + "birthday": fields.Date("BirthDay",search=True), + "department_id": fields.Many2One("clinic.department", "Department",search=True), + "patients": fields.Many2Many("clinic.patient","Patients"), + "addresses": fields.One2Many("address","related_id","Addresses"), + "comments": fields.One2Many("message","related_id","Comments"), + "visits": fields.One2Many("clinic.visit","nurse_id","Visits"), + "hd_cases": fields.One2Many("clinic.hd.case","nurse_id","HD Cases"), + "company_id": fields.Many2One("company","Company"), + "user_id": fields.Many2One("base.user","User"), + 'picture': fields.File("Picture"), + 'note': fields.Text("Note"), + 'categ_id': fields.Many2One("clinic.personal.categ", "Category"), + 'active': fields.Boolean("Active"), + 'date': fields.Date("Register Date"), + } + + def _get_number(self,context={}): + while 1: + seq_id=get_model("sequence").find_sequence(name="Clinic Personal") + if not seq_id: + return "/" + num=get_model("sequence").get_next_number(seq_id,context=context) + if not num: + return None + user_id=get_active_user() + set_active_user(1) + res=self.search([["number","=",num]]) + set_active_user(user_id) + if not res: + return num + get_model("sequence").increment_number(seq_id,context=context) + + _defaults={ + 'active': True, + "state": "temporary", + 'type': 'nurse', + "personal_type": "temporary", + "date": lambda *a: time.strftime("%Y-%m-%d"), + "number": _get_number, + "company_id": lambda *a: get_active_company(), + } + _order="date desc,number desc" + +Personal.register() diff --git a/netforce_clinic/models/personal_categ.py b/netforce_clinic/models/personal_categ.py index faccd24..98ba862 100644 --- a/netforce_clinic/models/personal_categ.py +++ b/netforce_clinic/models/personal_categ.py @@ -1,7 +1,7 @@ from netforce.model import Model, fields from netforce.access import get_active_company -class NurseCateg(Model): +class PersonalCateg(Model): _name="clinic.personal.categ" _string="Personal Category" @@ -41,4 +41,4 @@ class NurseCateg(Model): ids=list(set(ids1+ids2)) return self.name_get(ids,context=context) -NurseCateg.register() +PersonalCateg.register() diff --git a/netforce_clinic/models/report_clinic.py b/netforce_clinic/models/report_clinic.py index 79e1a78..b8ccd11 100644 --- a/netforce_clinic/models/report_clinic.py +++ b/netforce_clinic/models/report_clinic.py @@ -1,5 +1,6 @@ from netforce.model import Model from netforce.database import get_connection +from netforce.access import get_active_company class Report(Model): _name="clinic.report" @@ -7,7 +8,8 @@ class Report(Model): def cycle_recent_widget(self,context={}): db=get_connection() - res=db.query("select count(cycle_id) as count, c.name from clinic_hd_case as hd inner join clinic_cycle as c on c.id=hd.cycle_id group by c.name;") + company_id=get_active_company() + res=db.query("select count(cycle_id) as count, c.name from clinic_hd_case as hd inner join clinic_cycle as c on c.id=hd.cycle_id where hd.company_id=%s group by c.name",company_id) data=[] for r in res: data.append((r.name,r.count))