From 616e17244746075be35031900c2f3977df3b8694 Mon Sep 17 00:00:00 2001 From: "watcha.h" Date: Fri, 24 Oct 2014 15:08:56 +0700 Subject: [PATCH 01/10] import --- netforce_clinic/actions/clinic_data_nhso.xml | 7 ++ netforce_clinic/actions/clinic_data_sc.xml | 7 ++ .../layouts/clinic_data_nhso_form.xml | 18 +++++ .../layouts/clinic_data_nhso_list.xml | 19 +++++ .../layouts/clinic_data_sc_form.xml | 12 +++ .../layouts/clinic_data_sc_list.xml | 12 +++ .../layouts/clinic_gen_visit_form.xml | 15 ++-- .../layouts/clinic_menu_inherit.xml | 8 +- netforce_clinic/layouts/import_clinic_mg.xml | 10 ++- .../layouts/import_clinic_nhso.xml | 13 ++-- netforce_clinic/layouts/import_clinic_sc.xml | 8 +- netforce_clinic/models/gen_visit.py | 2 + netforce_clinic/models/import_data_nhso.py | 3 +- netforce_clinic/models/import_data_sc.py | 12 ++- netforce_clinic/models/import_payment.py | 75 +++++++++++++++++-- netforce_clinic/models/patient.py | 22 ++++++ 16 files changed, 215 insertions(+), 28 deletions(-) create mode 100644 netforce_clinic/actions/clinic_data_nhso.xml create mode 100644 netforce_clinic/actions/clinic_data_sc.xml create mode 100644 netforce_clinic/layouts/clinic_data_nhso_form.xml create mode 100644 netforce_clinic/layouts/clinic_data_nhso_list.xml create mode 100644 netforce_clinic/layouts/clinic_data_sc_form.xml create mode 100644 netforce_clinic/layouts/clinic_data_sc_list.xml diff --git a/netforce_clinic/actions/clinic_data_nhso.xml b/netforce_clinic/actions/clinic_data_nhso.xml new file mode 100644 index 0000000..67e8bb2 --- /dev/null +++ b/netforce_clinic/actions/clinic_data_nhso.xml @@ -0,0 +1,7 @@ + + NHSO + multi_view + [["All",[]],["Success",[["type","=","success"]]],["Fail",[["type","=","fail"]]]] + clinic.data.nhso + account_menu + diff --git a/netforce_clinic/actions/clinic_data_sc.xml b/netforce_clinic/actions/clinic_data_sc.xml new file mode 100644 index 0000000..498dcb8 --- /dev/null +++ b/netforce_clinic/actions/clinic_data_sc.xml @@ -0,0 +1,7 @@ + + NHSO + multi_view + [["All",[]],["Success",[["type","=","success"]]],["Fail",[["type","=","fail"]]]] + clinic.data.sc + account_menu + diff --git a/netforce_clinic/layouts/clinic_data_nhso_form.xml b/netforce_clinic/layouts/clinic_data_nhso_form.xml new file mode 100644 index 0000000..974e91d --- /dev/null +++ b/netforce_clinic/layouts/clinic_data_nhso_form.xml @@ -0,0 +1,18 @@ +
+ + + + + + + + + + + + + + + + + diff --git a/netforce_clinic/layouts/clinic_data_nhso_list.xml b/netforce_clinic/layouts/clinic_data_nhso_list.xml new file mode 100644 index 0000000..4e88632 --- /dev/null +++ b/netforce_clinic/layouts/clinic_data_nhso_list.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/netforce_clinic/layouts/clinic_data_sc_form.xml b/netforce_clinic/layouts/clinic_data_sc_form.xml new file mode 100644 index 0000000..7ec0a89 --- /dev/null +++ b/netforce_clinic/layouts/clinic_data_sc_form.xml @@ -0,0 +1,12 @@ +
+ + + + + + + + + + + diff --git a/netforce_clinic/layouts/clinic_data_sc_list.xml b/netforce_clinic/layouts/clinic_data_sc_list.xml new file mode 100644 index 0000000..897a221 --- /dev/null +++ b/netforce_clinic/layouts/clinic_data_sc_list.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/netforce_clinic/layouts/clinic_gen_visit_form.xml b/netforce_clinic/layouts/clinic_gen_visit_form.xml index 37cf326..65e80f5 100644 --- a/netforce_clinic/layouts/clinic_gen_visit_form.xml +++ b/netforce_clinic/layouts/clinic_gen_visit_form.xml @@ -1,10 +1,13 @@
- - - - - - + + + + + + + + + diff --git a/netforce_clinic/layouts/clinic_menu_inherit.xml b/netforce_clinic/layouts/clinic_menu_inherit.xml index 1fbee64..5a7e502 100644 --- a/netforce_clinic/layouts/clinic_menu_inherit.xml +++ b/netforce_clinic/layouts/clinic_menu_inherit.xml @@ -2,14 +2,14 @@
- +
- - - + + + diff --git a/netforce_clinic/layouts/import_clinic_mg.xml b/netforce_clinic/layouts/import_clinic_mg.xml index 33fd255..b8b8982 100644 --- a/netforce_clinic/layouts/import_clinic_mg.xml +++ b/netforce_clinic/layouts/import_clinic_mg.xml @@ -1,6 +1,12 @@ - + + + + + + + - diff --git a/netforce_clinic/models/__init__.py b/netforce_clinic/models/__init__.py index 342b8d4..71a28cf 100644 --- a/netforce_clinic/models/__init__.py +++ b/netforce_clinic/models/__init__.py @@ -7,6 +7,7 @@ from . import graduation from . import morbidity from . import nation from . import nurse +from . import address from . import patient from . import patient_cause_line from . import patient_comorbidity_line diff --git a/netforce_clinic/models/address.py b/netforce_clinic/models/address.py new file mode 100644 index 0000000..304a456 --- /dev/null +++ b/netforce_clinic/models/address.py @@ -0,0 +1,10 @@ +from netforce.model import Model, fields + +class Address(Model): + _inherit="address" + + _fields={ + "patient_id": fields.Many2One("clinic.patient","Patient"), + } + +Address.register() diff --git a/netforce_clinic/models/dialyzer.py b/netforce_clinic/models/dialyzer.py index 9e405a1..7795d5f 100644 --- a/netforce_clinic/models/dialyzer.py +++ b/netforce_clinic/models/dialyzer.py @@ -66,12 +66,13 @@ class Dialyzer(Model): _defaults={ "state": "new", "date": lambda *a: time.strftime("%Y-%m-%d"), - #"number": _get_number, 'number': '/', "max_use_time": 10, "use_time": 0, "company_id": lambda *a: get_active_company(), 'product_id': _get_product, + 'dialyzer_type': 'low', + 'member_type': 'unsub', } _order="date desc,number desc" diff --git a/netforce_clinic/models/hd_case.py b/netforce_clinic/models/hd_case.py index cbddf46..48b8ea6 100644 --- a/netforce_clinic/models/hd_case.py +++ b/netforce_clinic/models/hd_case.py @@ -620,5 +620,37 @@ class HDCase(Model): data['amount_total']=payment.amount_total or 0.0 return data + + def new_dialyzer(self,ids,context={}): + obj=self.browse(ids)[0] + dlz_id=get_model('clinic.dialyzer').create({ + 'patient_id': obj.patient_id.id, + }) + dialyzer=get_model("clinic.dialyzer").browse(dlz_id) + dialyzer.confirm() + vals={ + 'dlz_id': dlz_id, + 'dialyzers': [], + } + vals['dialyzers'].append(('create',{ + 'dialyzer_id': dlz_id, + 'description': dialyzer.description or "", + 'use_time': 1, + 'max_use_time': dialyzer.max_use_time, + 'member_type': dialyzer.member_type, + 'dialyzer_type': dialyzer.dialyzer_type, + 'bid_flow_rate': dialyzer.bid_flow_rate, + 'ultrafittration': dialyzer.ultrafittration, + 'state': dialyzer.state, + })) + obj.write(vals) + return { + 'next': { + 'name': 'clinic_hd_case', + 'mode': 'form', + 'active_id': obj.id, + }, + 'flash': 'Create new dialyzer successfully', + } HDCase.register() diff --git a/netforce_clinic/models/patient.py b/netforce_clinic/models/patient.py index 1b5f1dd..fb7c1d4 100644 --- a/netforce_clinic/models/patient.py +++ b/netforce_clinic/models/patient.py @@ -48,7 +48,7 @@ class Patient(Model): 'card_exp' : fields.Date("Card Expiry"), "app_no": fields.Char("Application No."), "salary": fields.Selection([["20000","5,001-20,000"],["50000","20,001-50,000"],["100000","50,001-100,000"],["100001","100,000+"]], "Salary"), - "addresses": fields.One2Many("address","related_id","Addresses"), + "addresses": fields.One2Many("address","patient_id","Addresses"), "gender": fields.Selection([("male","Male"),("female","Female")],"Gender",required=False), "marital_status": fields.Selection([("single","Single"),("marry","Marry"),("divorce","Divorce"),("separated","Saparated"),("widowed","Widowed")],"Marital Status",required=False), "nation_id": fields.Many2One("clinic.nation","Nationality"), @@ -203,6 +203,26 @@ class Patient(Model): 'type': 'person', }) vals['partner_id']=partner_id + + # XXX + if not isinstance(partner_id,int): + partner_id=partner_id.id + if obj.addresses: + addr=obj.addresses[0] + get_model("address").browse(addr.id).write({ + 'partner_id': partner_id, + }) + else: + if vals.get("addresses"): + # in case no address in patient + addr_vals=vals.get("addresses")[0][1] + addr_id=get_model("address").create(addr_vals) + get_model("address").browse(addr_id).write({ + 'patient_id': obj.id, + 'partner_id': partner_id, + }) + del vals['addresses'] + print("create address for %s"%obj.name) super().write(ids,vals,**kw) def name_get(self,ids,context={}): diff --git a/netforce_clinic/todo.txt b/netforce_clinic/todo.txt index 881e19b..7bd8216 100644 --- a/netforce_clinic/todo.txt +++ b/netforce_clinic/todo.txt @@ -1,4 +1,6 @@ ==== + question: + - can filter field in related find dialyzer automatic after confirm visit ==== - import data From c6e7131b273cdedecdf331834dfb1108a79e29b7 Mon Sep 17 00:00:00 2001 From: "watcha.h" Date: Sun, 26 Oct 2014 09:23:27 +0700 Subject: [PATCH 06/10] dlz & hd case --- netforce_clinic/models/dialyzer.py | 6 +++--- netforce_clinic/models/hd_case.py | 14 +++++++++----- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/netforce_clinic/models/dialyzer.py b/netforce_clinic/models/dialyzer.py index 7795d5f..f804f56 100644 --- a/netforce_clinic/models/dialyzer.py +++ b/netforce_clinic/models/dialyzer.py @@ -52,14 +52,14 @@ class Dialyzer(Model): def _get_product(self,context={}): categ_ids=get_model("product.categ").search([['name','=','Dialyzer']]) product_id=None - stop=False + found=False for prod in get_model("product").search_browse([]): - if stop: + if found: break for categ in prod.categs: if categ.id in categ_ids: product_id=prod.id - stop=True + found=True break return product_id diff --git a/netforce_clinic/models/hd_case.py b/netforce_clinic/models/hd_case.py index 48b8ea6..118bf86 100644 --- a/netforce_clinic/models/hd_case.py +++ b/netforce_clinic/models/hd_case.py @@ -127,7 +127,7 @@ class HDCase(Model): }) raise Exception("%s is expired"%dialyzer.number) use_time+=1 - line["description"]=dialyzer.description or "" + line["description"]=dialyzer.description or dialyzer.product_id.name or "" line["use_time"]=use_time line["max_use_time"]=dialyzer.max_use_time line["member_type"]=dialyzer.member_type @@ -623,9 +623,13 @@ class HDCase(Model): def new_dialyzer(self,ids,context={}): obj=self.browse(ids)[0] - dlz_id=get_model('clinic.dialyzer').create({ - 'patient_id': obj.patient_id.id, - }) + dlz_vals=get_model("clinic.dialyzer").default_get() + dlz_vals['patient_id']=obj.patient_id.id + dlz_vals['company_id']=dlz_vals['company_id'][0] + product_name=dlz_vals['product_id'][1] + dlz_vals['product_id']=dlz_vals['product_id'][0] + + dlz_id=get_model('clinic.dialyzer').create(dlz_vals) dialyzer=get_model("clinic.dialyzer").browse(dlz_id) dialyzer.confirm() vals={ @@ -634,7 +638,7 @@ class HDCase(Model): } vals['dialyzers'].append(('create',{ 'dialyzer_id': dlz_id, - 'description': dialyzer.description or "", + 'description': dialyzer.description or product_name, 'use_time': 1, 'max_use_time': dialyzer.max_use_time, 'member_type': dialyzer.member_type, From 7d6240a247292efe1fced9dee1c2f9eaddd48dbd Mon Sep 17 00:00:00 2001 From: "watcha.h" Date: Sun, 26 Oct 2014 11:28:08 +0700 Subject: [PATCH 07/10] [hd case] to draft --- netforce_clinic/layouts/clinic_cycle_form.xml | 11 +++++++++++ netforce_clinic/layouts/clinic_hd_case_form.xml | 3 ++- netforce_clinic/layouts/clinic_menu.xml | 5 +++-- netforce_clinic/models/cycle.py | 8 ++++++-- netforce_clinic/models/department.py | 6 +++++- netforce_clinic/models/hd_case.py | 10 ++++++++-- 6 files changed, 35 insertions(+), 8 deletions(-) diff --git a/netforce_clinic/layouts/clinic_cycle_form.xml b/netforce_clinic/layouts/clinic_cycle_form.xml index fc4271c..f5ef225 100644 --- a/netforce_clinic/layouts/clinic_cycle_form.xml +++ b/netforce_clinic/layouts/clinic_cycle_form.xml @@ -1,5 +1,16 @@
+ + + + + + + + + + diff --git a/netforce_clinic/layouts/clinic_hd_case_form.xml b/netforce_clinic/layouts/clinic_hd_case_form.xml index c67ba1c..b9ccf73 100644 --- a/netforce_clinic/layouts/clinic_hd_case_form.xml +++ b/netforce_clinic/layouts/clinic_hd_case_form.xml @@ -2,7 +2,8 @@ diff --git a/netforce_clinic/layouts/clinic_menu.xml b/netforce_clinic/layouts/clinic_menu.xml index 74810d1..a7467fd 100644 --- a/netforce_clinic/layouts/clinic_menu.xml +++ b/netforce_clinic/layouts/clinic_menu.xml @@ -16,6 +16,7 @@ + @@ -24,11 +25,11 @@
+
+ - - diff --git a/netforce_clinic/models/cycle.py b/netforce_clinic/models/cycle.py index 68d1c4b..30cf40d 100644 --- a/netforce_clinic/models/cycle.py +++ b/netforce_clinic/models/cycle.py @@ -9,14 +9,18 @@ class Cycle(Model): "name": fields.Char("Name",required=True,search=True), 'duration': fields.Integer("Duration (hrs)"), 'sequence': fields.Integer("Sequence"), - 'comapany_id': fields.Many2One("company", "Company"), + 'company_id': fields.Many2One("company", "Company"), + 'hd_cases': fields.One2Many("clinic.hd.case","cycle_id", "HD Cases"), + 'visits': fields.One2Many("clinic.visit","cycle_id", "Visits"), + 'var_k': fields.Float("K"), + 'var_x': fields.Float("X"), } _defaults={ 'duration': 1, 'sequence': 1, - 'comapany_id': lambda *a: get_active_company(), + 'company_id': lambda *a: get_active_company(), } diff --git a/netforce_clinic/models/department.py b/netforce_clinic/models/department.py index 874816c..54475f8 100644 --- a/netforce_clinic/models/department.py +++ b/netforce_clinic/models/department.py @@ -1,9 +1,9 @@ from netforce.model import Model, fields +from netforce.access import get_active_company class Department(Model): _name="clinic.department" _string="Department" - #_name_field="name" _fields={ "name": fields.Char("Name",required=True,search=True), @@ -11,4 +11,8 @@ class Department(Model): "parent_id": fields.Many2One("clinic.department", "Parent"), } + _defaults={ + 'company_id': lambda *a: get_active_company(), + } + Department.register() diff --git a/netforce_clinic/models/hd_case.py b/netforce_clinic/models/hd_case.py index 118bf86..859394f 100644 --- a/netforce_clinic/models/hd_case.py +++ b/netforce_clinic/models/hd_case.py @@ -551,11 +551,12 @@ class HDCase(Model): payment.delete() for pm_line in obj.payment_lines: pm_line.delete() - + state=context.get("state","in_progress") #force state obj.write({ - 'state': 'in_progress', + 'state': state, 'fee_paid': False, }) + return { 'next': { 'name': 'clinic_hd_case', @@ -656,5 +657,10 @@ class HDCase(Model): }, 'flash': 'Create new dialyzer successfully', } + + def to_draft(self,ids,context={}): + obj=self.browse(ids)[0] + context['state']='draft' + obj.undo(context=context) HDCase.register() From 1ca2e625547c213acc66c834d72d082e6006cff1 Mon Sep 17 00:00:00 2001 From: "watcha.h" Date: Sun, 26 Oct 2014 15:48:51 +0700 Subject: [PATCH 08/10] nurse payment --- netforce_clinic/actions/clinic_cycle_item.xml | 7 ++ .../actions/clinic_nurse_categ.xml | 7 ++ netforce_clinic/layouts/clinic_cycle_form.xml | 4 +- .../layouts/clinic_cycle_item_form.xml | 34 +++++++ .../layouts/clinic_cycle_item_list.xml | 6 ++ netforce_clinic/layouts/clinic_menu.xml | 10 +- .../layouts/clinic_nurse_categ_form.xml | 6 ++ .../layouts/clinic_nurse_categ_list.xml | 6 ++ netforce_clinic/layouts/clinic_setting.xml | 2 + netforce_clinic/models/:w | 53 ++++++++++ netforce_clinic/models/__init__.py | 3 + netforce_clinic/models/cycle.py | 3 +- netforce_clinic/models/cycle_item.py | 96 +++++++++++++++++++ netforce_clinic/models/cycle_item_line.py | 31 ++++++ netforce_clinic/models/gen_visit.py | 1 + netforce_clinic/models/hd_case.py | 21 ++++ netforce_clinic/models/hd_case_payment.py | 2 + netforce_clinic/models/nurse.py | 2 +- netforce_clinic/models/nurse_categ.py | 22 +++++ netforce_clinic/models/setting.py | 17 +--- 20 files changed, 309 insertions(+), 24 deletions(-) create mode 100644 netforce_clinic/actions/clinic_cycle_item.xml create mode 100644 netforce_clinic/actions/clinic_nurse_categ.xml create mode 100644 netforce_clinic/layouts/clinic_cycle_item_form.xml create mode 100644 netforce_clinic/layouts/clinic_cycle_item_list.xml create mode 100644 netforce_clinic/layouts/clinic_nurse_categ_form.xml create mode 100644 netforce_clinic/layouts/clinic_nurse_categ_list.xml create mode 100644 netforce_clinic/models/:w create mode 100644 netforce_clinic/models/cycle_item.py create mode 100644 netforce_clinic/models/cycle_item_line.py create mode 100644 netforce_clinic/models/nurse_categ.py diff --git a/netforce_clinic/actions/clinic_cycle_item.xml b/netforce_clinic/actions/clinic_cycle_item.xml new file mode 100644 index 0000000..09c4581 --- /dev/null +++ b/netforce_clinic/actions/clinic_cycle_item.xml @@ -0,0 +1,7 @@ + + Cycle Items + multi_view + clinic.cycle.item + list,form + clinic_menu + diff --git a/netforce_clinic/actions/clinic_nurse_categ.xml b/netforce_clinic/actions/clinic_nurse_categ.xml new file mode 100644 index 0000000..4528b4c --- /dev/null +++ b/netforce_clinic/actions/clinic_nurse_categ.xml @@ -0,0 +1,7 @@ + + Nurse Categories + multi_view + clinic.nurse.categ + list,page,form + clinic_menu + diff --git a/netforce_clinic/layouts/clinic_cycle_form.xml b/netforce_clinic/layouts/clinic_cycle_form.xml index f5ef225..bf3fb2e 100644 --- a/netforce_clinic/layouts/clinic_cycle_form.xml +++ b/netforce_clinic/layouts/clinic_cycle_form.xml @@ -6,10 +6,8 @@ - - - + diff --git a/netforce_clinic/layouts/clinic_cycle_item_form.xml b/netforce_clinic/layouts/clinic_cycle_item_form.xml new file mode 100644 index 0000000..01aa6ed --- /dev/null +++ b/netforce_clinic/layouts/clinic_cycle_item_form.xml @@ -0,0 +1,34 @@ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + @@ -10,13 +12,12 @@ - - - - - + + + + @@ -24,6 +25,8 @@ + +