diff --git a/netforce_clinic/actions/clinic_hd_case.xml b/netforce_clinic/actions/clinic_hd_case.xml
index 2d908e7..7c2fab9 100644
--- a/netforce_clinic/actions/clinic_hd_case.xml
+++ b/netforce_clinic/actions/clinic_hd_case.xml
@@ -2,7 +2,7 @@
Treatments
multi_view
clinic.hd.case
- [["All",[]],["Draft",[["state","=","draft"]]],["Confirmed",[["state","=","confirmed"]]],["Approved",[["state","=","approved"]]],["Paid",[["state","=","paid"]]],["Cancelled",[["state","=","cancelled"]]]]
- list,form
+ [["All",[]],["Draft",[["state","=","draft"]]],["In Progress",[["state","=","in_progress"]]],["Completed",[["state","=","completed"]]],["Incomplete",[["state","=","fail"]]],["Cancelled",[["state","=","cancelled"]]]]
+ list,form
clinic_menu
diff --git a/netforce_clinic/layouts/clinic_hd_case_form.xml b/netforce_clinic/layouts/clinic_hd_case_form.xml
index bd95f6c..73c8ba2 100644
--- a/netforce_clinic/layouts/clinic_hd_case_form.xml
+++ b/netforce_clinic/layouts/clinic_hd_case_form.xml
@@ -22,17 +22,19 @@
-
+
+
+
-
+
@@ -41,6 +43,10 @@
+
+
+
+
@@ -65,10 +71,9 @@
-
-
-
-
+
+
+
diff --git a/netforce_clinic/layouts/clinic_import_payment_form.xml b/netforce_clinic/layouts/clinic_import_payment_form.xml
index 811d58c..b6ba015 100644
--- a/netforce_clinic/layouts/clinic_import_payment_form.xml
+++ b/netforce_clinic/layouts/clinic_import_payment_form.xml
@@ -8,18 +8,21 @@
+
+
+
diff --git a/netforce_clinic/layouts/clinic_visit_form.xml b/netforce_clinic/layouts/clinic_visit_form.xml
index a066ef3..9b9b6a9 100644
--- a/netforce_clinic/layouts/clinic_visit_form.xml
+++ b/netforce_clinic/layouts/clinic_visit_form.xml
@@ -15,13 +15,29 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/netforce_clinic/models/__init__.py b/netforce_clinic/models/__init__.py
index 9a93e92..a99af87 100644
--- a/netforce_clinic/models/__init__.py
+++ b/netforce_clinic/models/__init__.py
@@ -8,9 +8,10 @@ from . import doctor
from . import nurse
from . import visit
from . import hd_case
-from . import hd_case_dialyzer
+#from . import hd_case_dialyzer
from . import hd_case_line
from . import dialyzer
+from . import dialyzer_line
from . import department
from . import education
from . import setting
diff --git a/netforce_clinic/models/dialyzer.py b/netforce_clinic/models/dialyzer.py
index 177f497..766bb5d 100644
--- a/netforce_clinic/models/dialyzer.py
+++ b/netforce_clinic/models/dialyzer.py
@@ -16,7 +16,6 @@ class Dialyzer(Model):
"use_time": fields.Integer("Use Time"),
"max_use_time": fields.Integer("Max Use Time"),
"exp_date": fields.Date("Expiry Date",search=True),
- "patient_id": fields.Many2One("clinic.patient","Patient"),
"member_type": fields.Selection([("unsub","Unsub cellul"),("sub","Sub cellul"),("synthetic","Synthetic")],"Membrane Type"),
"dialyzer_type": fields.Selection([("low","low flux"),("high","high flux"),("dbl","dbl hifulx")],"Dialyzer Type"),
"bid_flow_rate": fields.Integer("Bid Flow Rate (ml/min)",search=True),
@@ -26,6 +25,9 @@ class Dialyzer(Model):
"company_id": fields.Many2One("company","Company"),
'product_id': fields.Many2One("product", "Product",required=True),
"pickings": fields.One2Many("stock.picking","related_id","Pickings"),
+ "patient_id": fields.Many2One("clinic.patient","Patient"),
+ "visit_id": fields.Many2One("clinic.visit","Visit"),
+ "hd_case_id": fields.Many2One("clinic.hd.case","HD Case"),
}
def _get_number(self,context={}):
diff --git a/netforce_clinic/models/dialyzer_line.py b/netforce_clinic/models/dialyzer_line.py
new file mode 100644
index 0000000..63c4c5a
--- /dev/null
+++ b/netforce_clinic/models/dialyzer_line.py
@@ -0,0 +1,20 @@
+from netforce.model import Model, fields
+
+class DialyzerLine(Model):
+ _name="clinic.dialyzer.line"
+ _fields={
+ "hd_case_id": fields.Many2One("clinic.hd.case","HdCase",on_delete="cascade"),
+ "visit_id": fields.Many2One("clinic.visit","Visit",on_delete="cascade"),
+ "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"),
+ }
+
+DialyzerLine.register()
+
diff --git a/netforce_clinic/models/hd_case.py b/netforce_clinic/models/hd_case.py
index f8e6427..51ac74c 100644
--- a/netforce_clinic/models/hd_case.py
+++ b/netforce_clinic/models/hd_case.py
@@ -37,8 +37,8 @@ class HDcase(Model):
"bp_stop": fields.Integer("BP mmHG stop"),
"per_bp_stop": fields.Integer("/Per stop"),
"hct": fields.Integer("HCT %"),
- "state": fields.Selection([("draft","Draft"),("confirmed","Confirmed"),("approved","Approved"),("cancelled","Cancelled"),("paid","Paid")],"Status",required=True),
- "dialyzers": fields.One2Many("clinic.hd.case.dialyzer","hd_case_id","Dializers"),
+ "state": fields.Selection([("draft","Draft"),("in_progress","In Progress"),("completed","Completed"),("cancelled","Cancelled"),("incomplete","Incomplete")],"Status",required=True),
+ "dialyzers": fields.One2Many("clinic.dialyzer.line","hd_case_id","Dializers"),
"lines": fields.One2Many("clinic.hd.case.line","hd_case_id","Lines"),
"comments": fields.One2Many("message","related_id","Comments"),
"company_id": fields.Many2One("company","Company"),
@@ -53,6 +53,7 @@ class HDcase(Model):
'total_time': fields.Integer("Total Time(Hrs)",function="get_hrs"),
"fee_type": fields.Selection([("mg","Medical Government"),("sc","Social Security"),("nhso","NHSO (30฿)"),("personal","Personal"),("others","Others")],"Fee Type"),
'fee_partner_id': fields.Many2One("partner","Fee Contact"),
+ 'paid': fields.Boolean("Paid"),
}
def _get_number(self,context={}):
@@ -92,11 +93,11 @@ class HDcase(Model):
data=context["data"]
path=context["path"]
line=get_data_path(data,path,parent=True)
- dialyzer_id=line.get("dialzer_id")
+ dialyzer_id=line.get("dialyzer_id")
if not dialyzer_id:
return {}
dialyzer=get_model("clinic.dialyzer").browse(dialyzer_id)
- line["detail"]=dialyzer.detail
+ line["description"]=dialyzer.description or ""
line["use_time"]=dialyzer.use_time
line["max_use_time"]=dialyzer.max_use_time
line["member_type"]=dialyzer.member_type
@@ -167,7 +168,7 @@ class HDcase(Model):
# XXX
context['type']='out'
context['inv_type']='invoice'
- if obj.lines:
+ if obj.lines and obj.total:
# XXX need to split function prepare invoice
vals={
"type": "out",
@@ -293,112 +294,29 @@ class HDcase(Model):
def confirm(self,ids,context={}):
obj=self.browse(ids)[0]
- obj.write({"state":"confirmed"})
+ obj.write({"state":"in_progress"})
- def paid(self,ids,context={}):
+ def reject(self,ids,context={}):
obj=self.browse(ids)[0]
- obj.write({"state":"paid"})
+ obj.write({"state":"cancelled"})
- def approve(self,ids,context={}):
+ def complete(self,ids,context={}):
obj=self.browse(ids)[0]
obj.make_invoices()
obj.post_invoices()
- obj.write({"state":"approved"})
+ obj.write({
+ "state":"completed",
+ 'paid': True,
+ })
return {
'next': {
'name': 'clinic_hd_case',
'mode': 'form',
'active_id': obj.id,
},
- 'flash': '%s has been approved'%obj.number,
+ 'flash': '%s is completed'%obj.number,
}
- def approved(self,ids,context={}):
- for obj in self.browse(ids):
- user_id=get_active_user()
- try:
- set_active_user(1)
- settings=get_model("clinic.setting").browse(1)
- reconcile_id=get_model("account.reconcile").create({})
- if obj.patient_id.type == 'mg':
- vals={
- "narration": obj.number,
- "lines": [
- ("create",{
- "description": obj.number,
- "account_id": settings.ar_mg_id.id,
- "debit": obj.amount,
- "credit": 0,
- "partner_id": settings.mg_partner_id.id,
- "due_date": obj.date,
- "reconcile_id":reconcile_id,
- }),
- ("create",{
- "description": obj.number,
- "account_id": settings.ap_mg_id.id,
- "debit": 0,
- "credit": obj.amount,
- }),
- ],
- "state": "posted",
- "date_posted": obj.date,
- "date": obj.date,
- }
- get_model("account.move").create(vals)
- elif obj.patient_id.type == 'sc':
- vals={
- "narration": obj.number,
- "lines": [
- ("create",{
- "description": obj.number,
- "account_id": settings.ar_sc_id.id,
- "debit": obj.amount,
- "credit": 0,
- "partner_id": settings.sc_partner_id.id,
- "due_date": obj.date,
- "reconcile_id":reconcile_id,
- }),
- ("create",{
- "description": obj.number,
- "account_id": settings.ap_sc_id.id,
- "debit": 0,
- "credit": obj.amount,
- }),
- ],
- "state": "posted",
- "date_posted": obj.date,
- "date": obj.date,
- }
- get_model("account.move").create(vals)
- elif obj.patient_id.type == 'nhso':
- vals={
- "narration": obj.number,
- "lines": [
- ("create",{
- "description": obj.number,
- "account_id": settings.ar_nhso_id.id,
- "debit": obj.amount,
- "credit": 0,
- "partner_id": settings.nhso_partner_id.id,
- "due_date": obj.date,
- "reconcile_id":reconcile_id,
- }),
- ("create",{
- "description": obj.number,
- "account_id": settings.ap_nhso_id.id,
- "debit": 0,
- "credit": obj.amount,
- }),
- ],
- "state": "posted",
- "date_posted": obj.date,
- "date": obj.date,
- }
- get_model("account.move").create(vals)
- finally:
- set_active_user(user_id)
- obj.write({"state":"approved","reconcile_id":reconcile_id})
-
def journal_report(self,ids,context={}):
obj=self.browse(ids[0])
move_id = get_model("account.move").search([["narration","=",obj.number]])
diff --git a/netforce_clinic/models/visit.py b/netforce_clinic/models/visit.py
index d8b50b4..6c364a3 100644
--- a/netforce_clinic/models/visit.py
+++ b/netforce_clinic/models/visit.py
@@ -3,6 +3,7 @@ import datetime
from netforce.model import Model, fields, get_model
from netforce.access import get_active_company, get_active_user, set_active_user
+from netforce.utils import get_data_path
class Visit(Model):
_name="clinic.visit"
@@ -13,6 +14,8 @@ class Visit(Model):
def _get_visit_late(self,ids,context={}):
res={}
+ #oneday=datetime.timedelta(days=1)
+ #yesterday=datetime.datetime.now()-oneday
datenow=time.strftime("%Y-%m-%d")
for obj in self.browse(ids):
late=0
@@ -34,6 +37,7 @@ class Visit(Model):
"company_id": fields.Many2One("company","Company"),
'time_use': fields.Integer("Time Use(hrs)"),
'late_visit': fields.Integer("Late Vist",function="_get_visit_late"),
+ "dialyzers": fields.One2Many("clinic.dialyzer.line","visit_id","Dialyzers"),
}
def _get_number(self,context={}):
@@ -93,6 +97,8 @@ class Visit(Model):
# cannot treatment if current date is not same visit date
if obj.visit_date!=datenow:
raise Exception("Today is not treament date!")
+ if not obj.dialyzers:
+ raise Exception("Please select dialyzer!")
fmt_date="%Y-%m-%d %H:%M:%S"
date_from=dt.strptime("%s %s"%(obj.visit_date,timenow),fmt_date)
@@ -113,6 +119,7 @@ class Visit(Model):
'fee_type': obj.patient_id.type,
'lines':[],
'dialyzers': [],
+ 'state': 'in_progress',
}
patient_type={
@@ -136,31 +143,15 @@ class Visit(Model):
break
# find dialyser
- for dlz in get_model("clinic.dialyzer").search_browse([['patient_id','=',obj.patient_id.id],['state','=','active']],order="id desc"):
- use_time=dlz.use_time or 0
- use_time+=1
- # XXX update dialyzer
- dlz.write({
- 'use_time': use_time,
- })
- if use_time > dlz.max_use_time:
- dlz.write({
- "state": "expire",
- })
- continue
- vals['dialyzers'].append(('create',{
- "dialyzer_id": dlz.id,
- "description": dlz.description,
- "use_time": use_time,
- "max_use_time": dlz.max_use_time,
- "member_type": dlz.member_type,
- "dialyzer_type": dlz.dialyzer_type,
- "bid_flow_rate": dlz.bid_flow_rate,
- "ultrafittration": dlz.ultrafittration,
- }))
- if not vals['dialyzers']:
+ if not obj.dialyzers:
raise Exception("%s don't have dialyzer for treatment yet" % obj.patient_id.name)
hd_case_id=hd_case_obj.create(vals)
+ for dlz in obj.dialyzers:
+ # TODO check max time and expire day also
+ dlz.dialyzer_id.write({'use_time': dlz.use_time}) # count use time
+ dlz.write({
+ 'hd_case_id': hd_case_id,
+ })
obj.write({"state":"treatment"})
return {
'next': {
@@ -250,4 +241,24 @@ class Visit(Model):
}
return data
+ def onchange_dialyzer(self,context={}):
+ data=context["data"]
+ path=context["path"]
+ line=get_data_path(data,path,parent=True)
+ dialyzer_id=line.get("dialyzer_id")
+ if not dialyzer_id:
+ return {}
+ dialyzer=get_model("clinic.dialyzer").browse(dialyzer_id)
+ use_time=dialyzer.use_time or 0
+ use_time+=1
+ line["description"]=dialyzer.description 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
+ return data
+
Visit.register()
diff --git a/netforce_clinic/todo.txt b/netforce_clinic/todo.txt
index 9c61ced..e12edf4 100644
--- a/netforce_clinic/todo.txt
+++ b/netforce_clinic/todo.txt
@@ -14,19 +14,17 @@
-> state
- draft
- confirmed
- - should dialyzer before treament
- - buttons
+ - should select dialyzer before treament
+ - buttons -> ok
- confirm
- state : draft -> waiting treatment
- do treatment
- state : waiting treatment ->
- - cancel visit
- - print visit
- - plaining visit
- - day [monday, tueday, wedsday, thursday, friday]
- - time
+ - cancel visit -> ok
+ - print visit -> ok
- treament
+ - print invoice
- time start/stop
- only time
- date treament
@@ -36,12 +34,24 @@
- make next appointment
- make payment
- state
- - draft
- - confirm
+ - ready to treatment
+ - paid -> no because not realte to accounting
- many2one for dializer
+ - list show percent of progress bar
+ - plaining visit !!!
+ - select next day to visit
+ - copy data to visit
+ - after click complete
+ - day [monday, tueday, wedsday, thursday, friday]
+ - time
- dialyzer
-
+ - import payment
+ - import
+ - create payment with invoice that found
+ - post
+ - undo
=======
+
sequence (support multi company) -> ok
- visit
- hd case