diff --git a/netforce_clinic/actions/clinic_sickbed.xml b/netforce_clinic/actions/clinic_sickbed.xml new file mode 100644 index 0000000..a8a34d0 --- /dev/null +++ b/netforce_clinic/actions/clinic_sickbed.xml @@ -0,0 +1,6 @@ + + Sickbed + multi_view + clinic.sickbed + clinic_menu + diff --git a/netforce_clinic/layouts/clinic_cycle_item_form.xml b/netforce_clinic/layouts/clinic_cycle_item_form.xml index f9ef707..fc740aa 100644 --- a/netforce_clinic/layouts/clinic_cycle_item_form.xml +++ b/netforce_clinic/layouts/clinic_cycle_item_form.xml @@ -11,6 +11,25 @@ + + + + + + + + + + + + + + + + + + + @@ -22,15 +41,14 @@ - - + + + + + + diff --git a/netforce_clinic/layouts/clinic_sickbed_list.xml b/netforce_clinic/layouts/clinic_sickbed_list.xml new file mode 100644 index 0000000..6622ea5 --- /dev/null +++ b/netforce_clinic/layouts/clinic_sickbed_list.xml @@ -0,0 +1,4 @@ + + + + diff --git a/netforce_clinic/models/__init__.py b/netforce_clinic/models/__init__.py index b7ab062..95564c1 100644 --- a/netforce_clinic/models/__init__.py +++ b/netforce_clinic/models/__init__.py @@ -80,3 +80,4 @@ from . import labor_cost_line from . import labor_cost_staff from . import labor_cost_entry from . import labor_cost_entry_line +from . import sickbed diff --git a/netforce_clinic/models/cycle_item.py b/netforce_clinic/models/cycle_item.py index eec93ef..c0ad9c3 100644 --- a/netforce_clinic/models/cycle_item.py +++ b/netforce_clinic/models/cycle_item.py @@ -19,20 +19,20 @@ class CycleItem(Model): name="%s-%s"%(cycle_name,obj.date) res[obj.id]={ 'name': name, + 'sequence':'%s-%s'%(obj.date,cycle.sequence), } return res _fields={ - 'name': fields.Char("Name", function="_get_all",function_multi=True), + 'name': fields.Char("Name",function="_get_all",function_multi=True,store=True), 'date': fields.Date("Date",search=True), 'cycle_id': fields.Many2One("clinic.cycle", "Cycle",search=True), - 'cycle_daily_id': fields.Many2One("clinic.cycle.daily", "Cycle Daily",search=True), 'lines': fields.One2Many("clinic.cycle.item.line","item_id", "Lines"), 'visits': fields.One2Many("clinic.visit","cycle_item_id", "Visits"), 'hd_cases': fields.One2Many("clinic.hd.case","cycle_item_id", "HD Cases"), 'nurses': fields.One2Many("clinic.cycle.item.nurse",'cycle_item_id','Nurses'), - 'nurse_id': fields.Many2One("clinic.staff","Nurse",domain=[['type','=','nurse']]), #XXX - 'sequence': fields.Char("Sequence"), # for sort item + 'nurse_id': fields.Many2One("clinic.staff","Nurse",domain=[['type','=','nurse']]), + 'sequence': fields.Char("Sequence",function="_get_all",function_multi=True,store=True), 'company_id': fields.Many2One("company", "Company"), "state": fields.Selection([("draft","Draft"),("validated","Validated")],"Status",required=True), 'user_id': fields.Many2One("base.user","Validator"), @@ -72,18 +72,13 @@ class CycleItem(Model): def create(self, vals,**kw): - date=vals['date'] - cycle_id=vals['cycle_id'] - cycle=get_model("clinic.cycle").browse(cycle_id) - vals['sequence']='%s-%s'%(date,cycle.sequence) #date-sequence - obj_id=super().create(vals,**kw) - return obj_id + new_id=super().create(vals,**kw) + self.function_store([new_id]) + return new_id def write(self,ids,vals,**kw): - obj=self.browse(ids)[0] - cycle=obj.cycle_id - vals['sequence']='%s-%s'%(obj.date,cycle.sequence) #date-sequence super().write(ids,vals,**kw) + self.function_store(ids) def validate(self,ids,context={}): obj=self.browse(ids)[0] diff --git a/netforce_clinic/models/hd_case.py b/netforce_clinic/models/hd_case.py index 729e663..6d08590 100644 --- a/netforce_clinic/models/hd_case.py +++ b/netforce_clinic/models/hd_case.py @@ -66,23 +66,30 @@ class HDCase(Model): res={} for obj in self.browse(ids): patient=obj.patient_id - res[obj.id]=patient.type_id.name + res[obj.id]=patient.type_id.id return res _fields={ "number": fields.Char("Number",required=True,search=True), + 'sickbed_id': fields.Many2One("clinic.sickbed",'Sickbed'), "ref": fields.Char("Ref",search=True), "time_start": fields.DateTime("Start Time",required=True,search=True), "time_stop": fields.DateTime("Finish Time",required=True,search=True), "date": fields.Date("Date",required=True,search=True), "patient_id": fields.Many2One("clinic.patient","Patient",required=True,search=True), - "patient_type": fields.Char("Service Type",function="_get_patient_type"), - "vascular_acc": fields.Many2One("clinic.vascular.access","Vascular Ac."), + "patient_type_id": fields.Many2One("clinic.patient.type", "Type",function="_get_patient_type"), "nurse_id": fields.Many2One("clinic.staff","Approve By", domain=[['type','=','nurse']]), "department_id": fields.Many2One("clinic.department", "Department",search=True), - "wt_kg": fields.Float("Wt.kg."), - "bp": fields.Integer("BP"), - "mm_hg": fields.Integer("mmHG"), + "wt_start": fields.Float("Wt Start(kg)"), + "wt_stop": fields.Float("Wt Stop(kg)"), + "bp_start": fields.Char("BP Start"), + "bp_stop": fields.Char("BP Stop"), + "membrane_type": fields.Selection([("unsub","Unsub cellul"),("sub","Sub cellul"),("synthetic","Synthetic")],"Member Type"), + "hd_acc": fields.Selection([("o","O"),("i","I")],"HD Acc"), + "hd_mode": fields.Selection([("chronic","Chronic"),("acute","Acute")],"HD Moode"), + "vascular_acc": fields.Many2One("clinic.vascular.access","Vascular Ac."), + "bid_flow_rate": fields.Integer("Bid Flow Rate (ml/min)"), + "ultrafittration": fields.Float("Ultrafittration Kg."), "hct": fields.Integer("Hct",required=True), "hct_msg" : fields.Char(""), "state": fields.Selection([("draft","Draft"),('waiting_treatment','Waiting Treatment'),("in_progress","In Progress"),("completed","Finish Treatment"),('paid','Paid'),("waiting_payment","Waiting Payment"),("discountinued","Discountinued"),("cancelled","Cancelled")],"Status",required=True), @@ -96,7 +103,7 @@ class HDCase(Model): "payment_lines": fields.One2Many("clinic.payment","hd_case_id","Payment Lines"), "expenes": fields.One2Many("clinic.hd.case.expense","hd_case_id","Expenses"), 'visit_id': fields.Many2One("clinic.visit", "Visit"), - 'duration': fields.Integer("Duration(Hours)",function="_get_duration"), + 'duration': fields.Integer("Duration (Hours)",function="_get_duration"), "total": fields.Float("Total",function="_get_total",readonly=True,function_multi=True), "fee_amount": fields.Float("Fee",function="_get_total",readonly=True,function_multi=True), "mdc_amount": fields.Float("Medicine",function="_get_total",readonly=True,function_multi=True), @@ -107,7 +114,7 @@ class HDCase(Model): 'note': fields.Text("Note"), 'complication': fields.Text("Complication"), "cycle_id": fields.Many2One("clinic.cycle","Cycle"), - 'cycle_item_id': fields.Many2One("clinic.cycle.item","Cycle Item"), # on_delete="cascade" -> will rm visit from cycle item + 'cycle_item_id': fields.Many2One("clinic.cycle.item","Cycle Item (Team)"), # on_delete="cascade" -> will rm visit from cycle item 'pay_amount': fields.Float("Amount",function="_get_pay_amount"), 'pay_date': fields.Date("Pay Date"), 'pay_account_id': fields.Many2One("account.account","Account"), @@ -143,9 +150,14 @@ class HDCase(Model): "time_stop": lambda *a: time.strftime("%Y-%m-%d %H:%M:%S"), "number": _get_number, "company_id": lambda *a: get_active_company(), - 'wt_kg': 0.0, - 'bp': 0, - 'mm_hg': 0, + '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บาท ต่อ สัปดาห์", 'fee_paid': False, @@ -174,11 +186,7 @@ class HDCase(Model): 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 line["dialyzer_type"]=dialyzer.dialyzer_type - line["bid_flow_rate"]=dialyzer.bid_flow_rate - line["ultrafittration"]=dialyzer.ultrafittration - line["state"]=dialyzer.state data['dlz_id']=dialyzer.id return data @@ -206,11 +214,11 @@ class HDCase(Model): partner=patient.type_id.contact_id data['department_id']=department.id data['cycle_id']=cycle.id + data['patient_type_id']=patient.type_id.id if partner: data['fee_partner_id']=partner.id else: data['fee_partner_id']=None - data['patient_type']=patient.type_id.name or "" data['dialyzers']=[] doctor=patient.doctor_id data['staffs']=[] # XXX @@ -827,11 +835,7 @@ class HDCase(Model): 'description': dialyzer.description or product_name, '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) if context.get('called'): @@ -887,7 +891,7 @@ class HDCase(Model): })) # fee st=get_model("clinic.setting").browse(1) - if not st.auto_gen: + if st.auto_gen: return if not vals.get('lines'): @@ -917,15 +921,16 @@ class HDCase(Model): raise Exception("Not found contact %s at menu: Patiens -> Type"%patient.type_id.name) return vals - def get_invoice_policy(self,vals,patient_id=None): + def get_invoice_policy(self,vals={},patient_id=None): + print('vals ', vals) if patient_id: patient=get_model("clinic.patient").browse(patient_id) st=get_model("clinic.setting").browse(1) for pl in st.invoice_policies: policy=pl.invoice_policy - patient_type_id=pl.patient_type_id.id + patient_type=pl.patient_type_id opt=pl.invoice_option - if patient.type_id.id==patient_type_id: + if patient.type_id.id==patient_type.id: vals['invoice_policy']=policy vals['invoice_option']=opt break diff --git a/netforce_clinic/models/hd_case_dialyzer.py b/netforce_clinic/models/hd_case_dialyzer.py index 2ca5186..b582487 100644 --- a/netforce_clinic/models/hd_case_dialyzer.py +++ b/netforce_clinic/models/hd_case_dialyzer.py @@ -4,16 +4,11 @@ class HDCaseDialyzerLine(Model): _name="clinic.hd.case.dialyzer" _fields={ "hd_case_id": fields.Many2One("clinic.hd.case","HdCase",on_delete="cascade"), - "visit_id": fields.Many2One("clinic.visit","Visit",on_delete="cascade"), + "dialyzer_type": fields.Selection([("low","low flux"),("high","high flux"),("dbl","dbl hifulx")],"Dialyzer Type"), "dialyzer_id": fields.Many2One("clinic.dialyzer","Dialzer",search=True), "description": fields.Char("Description",search=True), "use_time":fields.Integer("Use time"), "max_use_time":fields.Integer("Max use time"), - "member_type": fields.Selection([("unsub","Unsub cellul"),("sub","Sub cellul"),("synthetic","Synthetic")],"Member Type"), - "dialyzer_type": fields.Selection([("low","low flux"),("high","high flux"),("dbl","dbl hifulx")],"Member Type"), - "bid_flow_rate": fields.Integer("Bid Flow Rate (ml/min)"), - "ultrafittration": fields.Float("Ultrafittration Kg."), - "state":fields.Selection([("draft","New"),("active","Active"),("drop","Drop")],"Status"), } HDCaseDialyzerLine.register() diff --git a/netforce_clinic/models/sickbed.py b/netforce_clinic/models/sickbed.py new file mode 100644 index 0000000..9022b63 --- /dev/null +++ b/netforce_clinic/models/sickbed.py @@ -0,0 +1,31 @@ +from netforce.model import Model, fields, get_model + +class SickBed(Model): + _name="clinic.sickbed" + _string="Sickbed" + + _fields={ + "name": fields.Char("Name",required=True,search=True), + "available": fields.Boolean("Available"), + 'hd_cases': fields.One2Many("clinic.hd.case",'sickbed_id','HDCases'), + } + + _defaults={ + 'available': True, + } + + def copy(self,ids,context={}): + obj=self.browse(ids)[0] + new_id=get_model("clinic.sickbed").create({ + 'name': '%s(copy)' % obj.name, + }) + return { + 'next': { + 'name': 'clinic_sickbed', + 'mode': 'form', + 'active_id': new_id, + }, + 'flash': 'Copy succesfully', + } + +SickBed.register() diff --git a/netforce_clinic/todo.txt b/netforce_clinic/todo.txt index 7720d8c..0a205a5 100644 --- a/netforce_clinic/todo.txt +++ b/netforce_clinic/todo.txt @@ -1,4 +1,20 @@ -== +===== +cycle item + - list's nurse + - list hd case + U + +===== + - design + 1. create cycle item + +===== + + +==== after midnight, create payment + + + +==== if patient not do visit before treatment , how to do? == import payment