From 10b2578088427fb99b5a0e0060d46e70c10d866e Mon Sep 17 00:00:00 2001 From: "watcha.h" Date: Tue, 10 Feb 2015 12:22:04 +0700 Subject: [PATCH] improve dialyzer --- .../layouts/clinic_hd_case_form.xml | 4 +-- netforce_clinic/layouts/clinic_menu.xml | 3 ++ netforce_clinic/models/dialyzer.py | 2 +- netforce_clinic/models/hd_case.py | 35 ++++++++++--------- netforce_clinic/models/hd_case_dialyzer.py | 2 +- netforce_clinic/models/visit.py | 7 ++-- 6 files changed, 30 insertions(+), 23 deletions(-) diff --git a/netforce_clinic/layouts/clinic_hd_case_form.xml b/netforce_clinic/layouts/clinic_hd_case_form.xml index e2f3447..742f0a4 100644 --- a/netforce_clinic/layouts/clinic_hd_case_form.xml +++ b/netforce_clinic/layouts/clinic_hd_case_form.xml @@ -3,7 +3,7 @@ @@ -49,7 +49,7 @@ - + diff --git a/netforce_clinic/layouts/clinic_menu.xml b/netforce_clinic/layouts/clinic_menu.xml index 74acb7e..e3b28d5 100644 --- a/netforce_clinic/layouts/clinic_menu.xml +++ b/netforce_clinic/layouts/clinic_menu.xml @@ -46,6 +46,9 @@ + +
+ diff --git a/netforce_clinic/models/dialyzer.py b/netforce_clinic/models/dialyzer.py index a355b49..f1103b6 100644 --- a/netforce_clinic/models/dialyzer.py +++ b/netforce_clinic/models/dialyzer.py @@ -215,7 +215,7 @@ class Dialyzer(Model): obj=self.browse(ids[0]) # XXX if obj.use_time > obj.max_use_time: - raise Exception("No long to use it (use time > max use time") + raise Exception("Dialyzer %s is expired. (use time > max use time)"%obj.number or '') obj.cancel() obj.write({"state": "new"}) diff --git a/netforce_clinic/models/hd_case.py b/netforce_clinic/models/hd_case.py index 6e13167..0be8d2b 100644 --- a/netforce_clinic/models/hd_case.py +++ b/netforce_clinic/models/hd_case.py @@ -153,15 +153,8 @@ class HDCase(Model): "time_stop": lambda *a: time.strftime("%Y-%m-%d %H:%M:%S"), 'number': '/', "company_id": lambda *a: get_active_company(), - #'wt_start': 0.0, - #'wt_stop': 0.0, - #'bp_start': '0/0', - #'bp_stop': '0/0', - #"bid_flow_rate": 0.0, - #"ultrafittration": 0.0, 'hd_acc': 'o', 'hd_mode': 'chronic', - #'hct': 0, 'hct_msg': "สามารถเบิกค่ายาสูงสุดไม่เกิน 1,125บาท ต่อ สัปดาห์", 'invoice_option': 'fee', 'invoice_policy': 'fee', @@ -686,23 +679,32 @@ class HDCase(Model): for obj in self.browse(ids): is_decrease=context.get('is_decrease') for dlz_line in obj.dialyzers: - dlz=dlz_line.dialyzer_id + membrane_type=dlz_line.membrane_type or '' + dialyzer_type=dlz_line.dialyzer_type or '' use_time=dlz_line.use_time or 0 + max_use_time=dlz_line.max_use_time or 0 + desc=dlz_line.description or '' if is_decrease: use_time-=1 print("decrease ok") - print("use_time ", use_time) - if dlz_line.use_time < dlz.max_use_time: - dlz.write({ - 'use_time': use_time, - }) - elif dlz_line.use_time==dlz.max_use_time: - dlz.write({ + vals={ + 'membrane_type': membrane_type, + 'dialyzer_type': dialyzer_type, + 'use_time': use_time, + 'max_use_time': max_use_time, + 'note': desc, + } + if use_time==max_use_time: + vals.update({ 'use_time': use_time, 'state': 'expire', }) - else: + elif use_time > max_use_time: raise Exception("Dialyzer is expired!") + else: + pass + dlz=dlz_line.dialyzer_id + dlz.write(vals) return True def create_cycle_item(self,ids,context={}): @@ -993,6 +995,7 @@ class HDCase(Model): 'use_time': 1, 'max_use_time': dialyzer.max_use_time, 'dialyzer_type': dialyzer.dialyzer_type, + 'membrane_type': dialyzer.membrane_type, })) obj.write(vals) if context.get('called'): diff --git a/netforce_clinic/models/hd_case_dialyzer.py b/netforce_clinic/models/hd_case_dialyzer.py index 9aa2290..3895f12 100644 --- a/netforce_clinic/models/hd_case_dialyzer.py +++ b/netforce_clinic/models/hd_case_dialyzer.py @@ -19,7 +19,7 @@ class HDCaseDialyzerLine(Model): "description": fields.Char("Description",search=True), "use_time":fields.Integer("Use time"), "max_use_time":fields.Integer("Max use time"), - "membrane_type": fields.Selection([("unsub","Unsub cellul"),("sub","Sub cellul"),("synthetic","Synthetic")],"Membrane Type",function="_get_all",function_multi=True), + "membrane_type": fields.Selection([("unsub","Unsub cellul"),("sub","Sub cellul"),("synthetic","Synthetic")],"Membrane Type"), } HDCaseDialyzerLine.register() diff --git a/netforce_clinic/models/visit.py b/netforce_clinic/models/visit.py index 6617262..60ce7e8 100644 --- a/netforce_clinic/models/visit.py +++ b/netforce_clinic/models/visit.py @@ -136,11 +136,12 @@ class Visit(Model): dialyzer=get_model("clinic.dialyzer").browse(dlz_id) use_time+=1 vals={ - "description": dialyzer.name or dialyzer.product_id.name or "", + 'dialyzer_id': dialyzer.id, + 'membrane_type': dialyzer.membrane_type or '', + "dialyzer_type": dialyzer.dialyzer_type, "use_time": use_time, "max_use_time": dialyzer.max_use_time, - "dialyzer_type": dialyzer.dialyzer_type, - 'dialyzer_id': dialyzer.id, + "description": dialyzer.name or dialyzer.product_id.name or "", } return vals