diff --git a/netforce_clinic/actions/clinic_invoice_payment.xml b/netforce_clinic/actions/clinic_invoice_payment.xml
index 394af3b..29ec4ca 100644
--- a/netforce_clinic/actions/clinic_invoice_payment.xml
+++ b/netforce_clinic/actions/clinic_invoice_payment.xml
@@ -6,6 +6,7 @@
[
["All",[]],
["Draft",[["state","=","draft"]]],
- ["Approved",[["state","=","approved"]]]
+ ["Approved",[["state","=","approved"]]],
+ ["Completed",[["state","=","done"]]]
]
diff --git a/netforce_clinic/layouts/clinic_invoice_payment_form.xml b/netforce_clinic/layouts/clinic_invoice_payment_form.xml
index 7acf0fb..434787e 100644
--- a/netforce_clinic/layouts/clinic_invoice_payment_form.xml
+++ b/netforce_clinic/layouts/clinic_invoice_payment_form.xml
@@ -30,5 +30,6 @@
+
diff --git a/netforce_clinic/layouts/clinic_name_title_form.xml b/netforce_clinic/layouts/clinic_name_title_form.xml
index a8ee766..2a3ea85 100644
--- a/netforce_clinic/layouts/clinic_name_title_form.xml
+++ b/netforce_clinic/layouts/clinic_name_title_form.xml
@@ -1,3 +1,4 @@
diff --git a/netforce_clinic/layouts/clinic_name_title_list.xml b/netforce_clinic/layouts/clinic_name_title_list.xml
index 73080ad..3980147 100644
--- a/netforce_clinic/layouts/clinic_name_title_list.xml
+++ b/netforce_clinic/layouts/clinic_name_title_list.xml
@@ -1,3 +1,4 @@
+
diff --git a/netforce_clinic/layouts/clinic_patient_form.xml b/netforce_clinic/layouts/clinic_patient_form.xml
index 224e390..d303815 100644
--- a/netforce_clinic/layouts/clinic_patient_form.xml
+++ b/netforce_clinic/layouts/clinic_patient_form.xml
@@ -13,9 +13,12 @@
-
-
+
+
+
+
+
diff --git a/netforce_clinic/layouts/clinic_report_discontinue_patient.xml b/netforce_clinic/layouts/clinic_report_discontinue_patient.xml
index b006ac8..d5a88f9 100644
--- a/netforce_clinic/layouts/clinic_report_discontinue_patient.xml
+++ b/netforce_clinic/layouts/clinic_report_discontinue_patient.xml
@@ -1,5 +1,7 @@
diff --git a/netforce_clinic/layouts/clinic_report_hd_case_summary.xml b/netforce_clinic/layouts/clinic_report_hd_case_summary.xml
index 3b1db4a..70faa49 100644
--- a/netforce_clinic/layouts/clinic_report_hd_case_summary.xml
+++ b/netforce_clinic/layouts/clinic_report_hd_case_summary.xml
@@ -1,5 +1,5 @@
diff --git a/netforce_clinic/layouts/clinic_report_medical_summary.xml b/netforce_clinic/layouts/clinic_report_medical_summary.xml
index a1a40ca..bfd0bf0 100644
--- a/netforce_clinic/layouts/clinic_report_medical_summary.xml
+++ b/netforce_clinic/layouts/clinic_report_medical_summary.xml
@@ -4,5 +4,5 @@
-
+
diff --git a/netforce_clinic/layouts/clinic_report_recent_patient.xml b/netforce_clinic/layouts/clinic_report_recent_patient.xml
index 253fadc..c67db5c 100644
--- a/netforce_clinic/layouts/clinic_report_recent_patient.xml
+++ b/netforce_clinic/layouts/clinic_report_recent_patient.xml
@@ -1,5 +1,7 @@
diff --git a/netforce_clinic/layouts/clinic_staff_form.xml b/netforce_clinic/layouts/clinic_staff_form.xml
index f233ece..1d107fc 100644
--- a/netforce_clinic/layouts/clinic_staff_form.xml
+++ b/netforce_clinic/layouts/clinic_staff_form.xml
@@ -7,11 +7,12 @@
-
-
+
-
+
+
+
@@ -34,6 +35,11 @@
+
+
+
+
+
diff --git a/netforce_clinic/migrations/import_acc.py b/netforce_clinic/migrations/import_acc.py
index ef7c716..793a9f4 100644
--- a/netforce_clinic/migrations/import_acc.py
+++ b/netforce_clinic/migrations/import_acc.py
@@ -26,7 +26,6 @@ class Migration(migration.Migration):
'file': 'ap.csv',
})
get_model("conv.bal").import_purch([cbv.id],context={})
-
print("create invoice from setep 1 to 3 is running...")
print("create_open_entry...")
cbv.create_open_entry()
diff --git a/netforce_clinic/models/invoice_payment.py b/netforce_clinic/models/invoice_payment.py
index 4e9508e..824c9fb 100644
--- a/netforce_clinic/models/invoice_payment.py
+++ b/netforce_clinic/models/invoice_payment.py
@@ -27,7 +27,7 @@ class InvoicePayment(Model):
'name': fields.Char("Name",required=True),
'lines': fields.One2Many("clinic.invoice.payment.line","invoice_payment_id", "Lines"),
'total': fields.Float("Total",function="_get_all",function_multi=True),
- 'state': fields.Selection([['draft','Draft'],['waiting_approve','Waiting Approve'],['approved','Approved']],'State'),
+ 'state': fields.Selection([['draft','Draft'],['waiting_approve','Waiting Approve'],['approved','Approved'],['done','Done']],'State'),
'date': fields.Date("Date"),
}
@@ -118,5 +118,23 @@ class InvoicePayment(Model):
obj.write({
'state': 'waiting_approve',
})
+
+ def post(self,ids,context={}):
+ obj=self.browse(ids)[0]
+ obj.write({
+ 'state': 'done',
+ })
+ print("Post")
+ return {
+ 'next': {
+ 'name': 'clinic_invoice_payment',
+ 'mode': 'form',
+ 'active_id': obj.id,
+ },
+ 'flash': 'Posted.An message will send to you after finish',
+ }
+
+ def post_invoice(self,ids,context={}):
+ print("post_invoice")
InvoicePayment.register()
diff --git a/netforce_clinic/models/name_title.py b/netforce_clinic/models/name_title.py
index fe3874d..1fa92f4 100644
--- a/netforce_clinic/models/name_title.py
+++ b/netforce_clinic/models/name_title.py
@@ -3,11 +3,25 @@ from netforce.model import Model, fields
class NameTitle(Model):
_name="clinic.name.title"
_string="Title"
+ _key=["name"]
_fields={
"name": fields.Char("Name",required=True,search=True),
+ 'description': fields.Text("Description"),
}
_order="name"
+ def name_search(self,name,domain=None,condition=[],context={},**kw):
+ dom=[["name","ilike","%"+name+"%"]]
+ if domain:
+ dom=[dom,domain]
+ ids1=self.search(dom)
+ dom=[["description","ilike","%"+name+"%"]]
+ if domain:
+ dom=[dom,domain]
+ ids2=self.search(dom)
+ ids=list(set(ids1+ids2))
+ return self.name_get(ids,context=context)
+
NameTitle.register()
diff --git a/netforce_clinic/models/patient.py b/netforce_clinic/models/patient.py
index e539076..1188daf 100644
--- a/netforce_clinic/models/patient.py
+++ b/netforce_clinic/models/patient.py
@@ -46,17 +46,22 @@ class Patient(Model):
name=(obj.name or "").replace(" ","")
if not obj.active:
name+='not_use'
+ elif context.get('active'):
+ name+='not_use'
res[obj.id]=name
return res
_fields={
- 'type_id': fields.Many2One("clinic.patient.type","Type",search=True,required=True),
"number": fields.Char("HN Number",required=True,search=True),
"trt_no": fields.Char("TRT",search=True),
"hn_no": fields.Char("HN",function="_get_hn_no",store=True),
"hn": fields.Char("REF/HN",search=False),
- "name": fields.Char("Name",required=True,search=True),
+ 'title_id': fields.Many2One("clinic.name.title","Title"),
+ "first_name": fields.Char("First Name"),
+ "last_name": fields.Char("Last Name"),
+ "name": fields.Char("Name",search=True),
"name_check": fields.Char("Name",function="_get_name_check",store=True), # prevent duplicate
+ 'type_id': fields.Many2One("clinic.patient.type","Type",search=True,required=True),
"reg_date": fields.Date("Reg. Date",required=False,search=True),
"birthday": fields.Date("Birthday",required=False,search=True),
"phone": fields.Char("Phone",required=False,search=True),
@@ -210,34 +215,35 @@ class Patient(Model):
def write(self,ids,vals,**kw):
#TODO change department of patient after change department
+ ctx={}
if 'active' in vals.keys():
if not vals['active']:
vals['resign_date']=time.strftime("%Y-%m-%d")
vals['rm_remain_visit']=True
+ ctx['active']=False
else:
vals['rm_remain_visit']=False
+ def update_visit_pending(obj,department_id, branch_id, doctor_id):
+ vids=get_model("clinic.visit").search([['patient_id','=',obj.id],['state','in',['draft','pending']]])
+ for visit in get_model('clinic.visit').browse(vids):
+ visit.write(vals)
for obj in self.browse(ids):
if 'department_id' in vals.keys():
- vids=get_model("clinic.visit").search([['patient_id','=',obj.id],['state','in',['draft','pending']]])
- for visit in get_model('clinic.visit').browse(vids):
- visit.write({
- 'department_id': vals['department_id']
- })
- print("update visit set department = %s"%(visit.department_id.name))
+ visit_vals={
+ 'department_id': vals['department_id'],
+ }
+ update_visit_pending(obj,visit_vals)
if 'branch_id' in vals.keys():
- vids=get_model("clinic.visit").search([['patient_id','=',obj.id],['state','in',['draft','pending']]])
- for visit in get_model('clinic.visit').browse(vids):
- visit.write({
- 'branch_id': vals['branch_id']
- })
- print("update visit set branch_id = %s"%(visit.department_id.name))
+ visit_vals={
+ 'branch_id': vals['branch_id'],
+ }
+ update_visit_pending(obj,visit_vals)
if 'doctor_id' in vals.keys():
- for vs in get_model("clinic.visit").search_browse([['state','in',['draft','pending']],['patient_id','=',obj.id]]):
- vs.write({
- 'doctor_id': vals['doctor_id'],
- })
- print("update doctor %s to patient %s"%(vals['doctor_id'], obj.name))
+ visit_vals={
+ 'doctor_id': vals['doctor_id'],
+ }
+ update_visit_pending(obj,visit_vals)
partner_id=obj.partner_id
if not partner_id:
for partner in get_model("partner").search_browse([['name', '=', obj.name]]):
@@ -274,7 +280,7 @@ class Patient(Model):
visit_ids=get_model('clinic.visit').search([['patient_id','=',obj.id],['state','in',('draft','pending')]])
get_model('clinic.visit').delete(visit_ids)
print('remove visit auto %s'%visit_ids)
- self.function_store(ids)
+ self.function_store(ids,context=ctx)
super().write(ids,vals,**kw)
def name_get(self,ids,context={}):
diff --git a/netforce_clinic/models/report_discontinue_patient.py b/netforce_clinic/models/report_discontinue_patient.py
index a2788b3..51a44d6 100644
--- a/netforce_clinic/models/report_discontinue_patient.py
+++ b/netforce_clinic/models/report_discontinue_patient.py
@@ -2,7 +2,7 @@ import time
from calendar import monthrange
from netforce.model import Model,fields,get_model
-from netforce.access import get_active_company
+from netforce.access import get_active_company, get_active_user
from . import utils
@@ -15,47 +15,72 @@ class ReportDiscontinuePatient(Model):
"date": fields.Date("Month"),
"date_from": fields.Date("From", required=True),
"date_to": fields.Date("To", required=True),
+ "branch_id": fields.Many2One("clinic.branch","Branch"),
+ "department_id": fields.Many2One("clinic.department","Department"),
}
- def _get_date_from(self,context={}):
+ def default_get(self,field_names=None,context={},**kw):
+ user_id=get_active_user()
+ defaults=context.get("defaults",{})
+ date=defaults.get('date',time.strftime("%Y-%m-%d"))
year,month=time.strftime("%Y-%m").split("-")
- return '%s-%s-01'%(year,month)
-
- def _get_date_to(self,context={}):
- year,month,day=time.strftime("%Y-%m-%d").split("-")
weekday, total_day=monthrange(int(year), int(month))
- return "%s-%s-%s"%(year,month,total_day)
+ date_from=defaults.get('date_from','%s-%s-01'%(year,month))
+ date_to=defaults.get('date_to',"%s-%s-%s"%(year,month,total_day))
+ branch_id=defaults.get('branch_id',None)
+ if not branch_id:
+ staff=get_model("clinic.staff").search_browse([['user_id','=',user_id]])
+ if staff:
+ branch_id=staff[0].branch_id.id
+ else:
+ branch_id=int(branch_id or "0")
+ department_id=defaults.get('department_id',None)
+ if not department_id:
+ dom=[]
+ dom.append(['user_id','=',user_id])
+ if branch_id:
+ dom.append(['branch_id','=',branch_id])
+ staff=get_model("clinic.staff").search_browse(dom)
+ if staff:
+ department_id=staff[0].department_id.id
+ else:
+ department_id=int(department_id or "0")
+ res={
+ 'date': date,
+ 'date_from': date_from,
+ 'date_to': date_to,
+ 'branch_id': branch_id,
+ 'department_id': department_id,
+ }
+ return res
- _defaults={
- 'date': lambda *a: time.strftime("%Y-%m-%d"),
- 'date_from': _get_date_from,
- 'date_to': _get_date_to,
- }
-
def get_report_data(self,ids,context={}):
company_id=get_active_company()
company=get_model('company').browse(company_id)
year, month=time.strftime("%Y-%m").split("-")
weekday, total_day=monthrange(int(year), int(month))
- time_start='%s-%s-01'%(year,str(month).zfill(2))
- time_stop='%s-%s-%s'%(year,str(month).zfill(2),total_day)
-
- defaults=context.get('defaults')
- if defaults:
- year,month,day=defaults['date'].split("-")
- weekday, total_day=monthrange(int(year), int(month))
- time_start='%s-%s-01'%(year,str(month).zfill(2))
- time_stop='%s-%s-%s'%(year,str(month).zfill(2),total_day)
+ defaults=self.default_get(context=context)
+ time_start=defaults.get("date_from")
+ time_stop=defaults.get("date_to")
+ branch_id=defaults.get("branch_id")
+ department_id=defaults.get("department_id")
if ids:
obj=self.browse(ids)[0]
month=obj.date_from.split("-")[1]
time_start=obj.date_from
time_stop=obj.date_to
+ branch_id=obj.branch_id.id
+ department_id=obj.department_id.id
# new patient of this month
dom=[]
dom.append(['resign_date','>=',time_start])
dom.append(['resign_date','<=',time_stop])
dom.append(['active','=',False])
+ if branch_id:
+ dom.append(['branch_id','=',branch_id])
+ if department_id:
+ dom.append(['department_id','=',department_id])
+ print("dom ", dom)
records=get_model('clinic.patient').search_browse(dom)
lines=[]
no=1
@@ -94,4 +119,9 @@ class ReportDiscontinuePatient(Model):
data['date_to']="%s-%s-%s"%(year,month,total_day)
return data
+ def onchange_branch(self,context={}):
+ data=context['data']
+ data['department_id']=None
+ return data
+
ReportDiscontinuePatient.register()
diff --git a/netforce_clinic/models/report_hd_case_summary.py b/netforce_clinic/models/report_hd_case_summary.py
index ee536f7..2e671de 100644
--- a/netforce_clinic/models/report_hd_case_summary.py
+++ b/netforce_clinic/models/report_hd_case_summary.py
@@ -17,6 +17,8 @@ class ReportHDCaseSummary(Model):
"date": fields.Date("Month", required=True),
"date_from": fields.Date("From", required=True),
"date_to": fields.Date("To", required=True),
+ 'branch_id': fields.Many2One("clinic.branch","Branch"),
+ 'department_id': fields.Many2One("clinic.department","Departments"),
}
def _get_date_from(self,context={}):
@@ -42,11 +44,14 @@ class ReportHDCaseSummary(Model):
year=int(date[0:4])
crr_month=int(date[5:7])
weekday, crr_total_day=monthrange(year, crr_month)
-
+ branch_id=None
+ department_id=None
time_start='%s-%s-01 00:00:00'%(year,str(crr_month).zfill(2))
time_stop='%s-%s-%s 23:59:59'%(year,str(crr_month).zfill(2),crr_total_day)
if ids:
obj=self.browse(ids)[0]
+ branch_id=obj.branch_id.id
+ department_id=obj.department_id.id
date=obj.date
time_start='%s 00:00:00'%obj.date_from
time_stop='%s 23:59:59'%obj.date_to
@@ -81,6 +86,10 @@ class ReportHDCaseSummary(Model):
dom.append(["time_start",">=",time_start])
dom.append(["time_stop","<=",time_stop])
dom.append(["state","in",["completed","waiting_payment","paid"]])
+ if branch_id:
+ dom.append(['branch_id','=',branch_id])
+ if department_id:
+ dom.append(['department_id','=',department_id])
crr_total=len(get_model("clinic.hd.case").search(dom))
items={}
items['topic%s'%count]={
@@ -96,6 +105,10 @@ class ReportHDCaseSummary(Model):
weekday, prev_total_day=monthrange(prev_year, prev_month)
time_stop='%s-%s-%s'%(prev_year,str(prev_month).zfill(2),prev_total_day)
dom.append(['reg_date','<=',time_stop])
+ if branch_id:
+ dom.append(['branch_id','=',branch_id])
+ if department_id:
+ dom.append(['department_id','=',department_id])
npatient=len(get_model("clinic.patient").search(dom))
dom=replace_quote('%s'%dom)
items['topic%s'%count]={
@@ -113,6 +126,10 @@ class ReportHDCaseSummary(Model):
time_stop='%s-%s-%s'%(year,str(crr_month).zfill(2),crr_total_day)
dom.append(['reg_date','>=',time_start])
dom.append(['reg_date','<=',time_stop])
+ if branch_id:
+ dom.append(['branch_id','=',branch_id])
+ if department_id:
+ dom.append(['department_id','=',department_id])
new_patients=get_model('clinic.patient').search_browse(dom)
dom=replace_quote('%s'%dom)
items['topic%s'%count]={
@@ -130,6 +147,10 @@ class ReportHDCaseSummary(Model):
dom.append(['resign_date','>=',time_start])
dom.append(['resign_date','<=',time_stop])
dom.append(['active','=',False])
+ if branch_id:
+ dom.append(['branch_id','=',branch_id])
+ if department_id:
+ dom.append(['department_id','=',department_id])
resign_patients=get_model('clinic.patient').search_browse(dom)
del dom[-1]
dom=replace_quote('%s'%dom)
@@ -146,6 +167,10 @@ class ReportHDCaseSummary(Model):
weekday, crr_total_day=monthrange(year, crr_month)
time_stop='%s-%s-%s'%(year,str(crr_month).zfill(2),crr_total_day)
dom.append(['reg_date','<=',time_stop])
+ if branch_id:
+ dom.append(['branch_id','=',branch_id])
+ if department_id:
+ dom.append(['department_id','=',department_id])
total_patient=get_model('clinic.patient').search_browse(dom)
dom=replace_quote('%s'%dom)
items['topic%s'%count]={
@@ -197,7 +222,11 @@ class ReportHDCaseSummary(Model):
medicals=get_model("clinic.report.medical.summary").get_report_data(ids=[],context=context)
year=year+543
+ print('branch_id ', branch_id)
+ print('department_id ', department_id)
data={
+ 'branch_id': branch_id,
+ 'department_id': department_id,
'date': date,
'month': month_str,
'year': year,
diff --git a/netforce_clinic/models/report_labor_cost_daily.py b/netforce_clinic/models/report_labor_cost_daily.py
index 06ace9e..320877d 100644
--- a/netforce_clinic/models/report_labor_cost_daily.py
+++ b/netforce_clinic/models/report_labor_cost_daily.py
@@ -1,5 +1,4 @@
import time
-from calendar import monthrange
from netforce.model import Model,fields,get_model
from netforce.access import get_active_company
@@ -18,9 +17,7 @@ class ReportLaborCostDaily(Model):
def default_get(self,field_names=None,context={},**kw):
defaults=context.get("defaults",{})
- date=defaults.get("date")
- if not date:
- date=time.strftime("%Y-%m-%d")
+ date=defaults.get('date',time.strftime("%Y-%m-%d"))
staff_type=defaults.get("staff_type","doctor")
staff_id=int(defaults.get('staff_id', "0"))
department_id=int(defaults.get('department_id', "0"))
@@ -46,7 +43,7 @@ class ReportLaborCostDaily(Model):
obj=self.browse(ids)[0]
date=obj.date
staff_id=obj.staff_id.id
- staff_type=obj.type
+ staff_type=obj.staff_type
dpt_id=obj.department_id.id
dom.append(['date','>=',date])
dom.append(['date','<=',date])
diff --git a/netforce_clinic/models/report_medical_summary.py b/netforce_clinic/models/report_medical_summary.py
index 8026e9d..6a80e8d 100644
--- a/netforce_clinic/models/report_medical_summary.py
+++ b/netforce_clinic/models/report_medical_summary.py
@@ -18,68 +18,58 @@ class ReportMedicalSummary(Model):
"branch_id": fields.Many2One("clinic.branch","Branch"),
"department_id": fields.Many2One("clinic.department","Department"),
}
-
- def _get_date_from(self,context={}):
+
+ # in case link from another report
+ def default_get(self,field_names=None,context={},**kw):
+ user_id=get_active_user()
+ defaults=context.get("defaults",{})
+ date=defaults.get('date',time.strftime("%Y-%m-%d"))
year,month=time.strftime("%Y-%m").split("-")
- return '%s-%s-01'%(year,month)
-
- def _get_date_to(self,context={}):
- year,month,day=time.strftime("%Y-%m-%d").split("-")
weekday, total_day=monthrange(int(year), int(month))
- return "%s-%s-%s"%(year,month,total_day)
-
- def _get_prod_categ(self,context={}):
- categ_id=None
- ids=get_model("product.categ").search([['code','=','EPO']])
- if ids:
- categ_id=ids[0]
- return categ_id
+ date_from=defaults.get('date_from','%s-%s-01'%(year,month))
+ date_to=defaults.get('date_to',"%s-%s-%s"%(year,month,total_day))
+ categ_id=defaults.get('categ_id',None)
+ if not categ_id:
+ categ_ids=get_model("product.categ").search([['code','=','EPO']])
+ if categ_ids:
+ categ_id=categ_ids[0]
+ branch_id=defaults.get('branch_id',None)
+ if not branch_id:
+ staff=get_model("clinic.staff").search_browse([['user_id','=',user_id]])
+ if staff:
+ branch_id=staff[0].branch_id.id
+ else:
+ branch_id=int(branch_id or "0")
+ department_id=defaults.get('department_id',None)
+ if not department_id:
+ dom=[]
+ dom.append(['user_id','=',user_id])
+ if branch_id:
+ dom.append(['branch_id','=',branch_id])
+ staff=get_model("clinic.staff").search_browse(dom)
+ if staff:
+ department_id=staff[0].department_id.id
+ else:
+ department_id=int(department_id or "0")
+ res={
+ 'date': date,
+ 'date_from': date_from,
+ 'date_to': date_to,
+ 'prod_categ_id': categ_id,
+ 'branch_id': branch_id,
+ 'department_id': department_id,
+ }
+ return res
- def _get_branch(self,context={}):
- user_id=get_active_user()
- staff=get_model("clinic.staff").search_browse([['user_id','=',user_id]])
- if staff:
- return staff[0].branch_id.id
-
- def _get_department(self,context={}):
- user_id=get_active_user()
- staff=get_model("clinic.staff").search_browse([['user_id','=',user_id]])
- if staff:
- return staff[0].department_id.id
-
- _defaults={
- 'date': lambda *a: time.strftime("%Y-%m-%d"),
- 'date_from': _get_date_from,
- 'date_to': _get_date_to,
- 'prod_categ_id': _get_prod_categ,
- 'branch_id':_get_branch,
- 'department_id': _get_department,
- }
-
def get_report_data(self,ids,context={}):
year, month=time.strftime("%Y-%m").split("-")
weekday, total_day=monthrange(int(year), int(month))
- time_start='%s-%s-01'%(year,str(month).zfill(2))
- time_stop='%s-%s-%s'%(year,str(month).zfill(2),total_day)
-
- defaults=context.get('defaults')
- if defaults:
- year,month,total_day=defaults['date'].split("-")
- weekday, total_day=monthrange(int(year), int(month))
- time_start='%s-%s-01'%(year,str(month).zfill(2))
- time_stop='%s-%s-%s'%(year,str(month).zfill(2),total_day)
-
- prod_categ_id=None
- branch_id=None
- department_id=None
- res=get_model("clinic.report.medical.summary").default_get(context=context)
- if res:
- if res.get("prod_categ_id"):
- prod_categ_id=res.get("prod_categ_id")[0]
- if res.get("branch_id"):
- branch_id=res.get("branch_id")[0]
- if res.get("department_id"):
- department_id=res.get("department_id")[0]
+ defaults=self.default_get(context=context)
+ time_start=defaults.get("date_from")
+ time_stop=defaults.get("date_to")
+ prod_categ_id=defaults.get("prod_categ_id")
+ branch_id=defaults.get("branch_id")
+ department_id=defaults.get("department_id")
if ids:
obj=self.browse(ids)[0]
prod_categ_id=obj.prod_categ_id.id
@@ -199,4 +189,9 @@ class ReportMedicalSummary(Model):
data['date_to']="%s-%s-%s"%(year,month,total_day)
return data
+ def onchange_branch(self,context={}):
+ data=context['data']
+ data['department_id']=None
+ return data
+
ReportMedicalSummary.register()
diff --git a/netforce_clinic/models/report_recent_patient.py b/netforce_clinic/models/report_recent_patient.py
index a6a93a6..f1c089f 100644
--- a/netforce_clinic/models/report_recent_patient.py
+++ b/netforce_clinic/models/report_recent_patient.py
@@ -2,7 +2,7 @@ import time
from calendar import monthrange
from netforce.model import Model,fields,get_model
-from netforce.access import get_active_company
+from netforce.access import get_active_company, get_active_user
from . import utils
@@ -15,47 +15,70 @@ class ReportRecentPatient(Model):
"date": fields.Date("Month"),
"date_from": fields.Date("From", required=True),
"date_to": fields.Date("To", required=True),
+ "branch_id": fields.Many2One("clinic.branch","Branch"),
+ "department_id": fields.Many2One("clinic.department","Department"),
}
- def _get_date_from(self,context={}):
+ def default_get(self,field_names=None,context={},**kw):
+ user_id=get_active_user()
+ defaults=context.get("defaults",{})
+ date=defaults.get('date',time.strftime("%Y-%m-%d"))
year,month=time.strftime("%Y-%m").split("-")
- return '%s-%s-01'%(year,month)
-
- def _get_date_to(self,context={}):
- year,month,day=time.strftime("%Y-%m-%d").split("-")
weekday, total_day=monthrange(int(year), int(month))
- return "%s-%s-%s"%(year,month,total_day)
-
- _defaults={
- 'date': lambda *a: time.strftime("%Y-%m-%d"),
- 'date_from': _get_date_from,
- 'date_to': _get_date_to,
- }
+ date_from=defaults.get('date_from','%s-%s-01'%(year,month))
+ date_to=defaults.get('date_to',"%s-%s-%s"%(year,month,total_day))
+ branch_id=defaults.get('branch_id',None)
+ if not branch_id:
+ staff=get_model("clinic.staff").search_browse([['user_id','=',user_id]])
+ if staff:
+ branch_id=staff[0].branch_id.id
+ else:
+ branch_id=int(branch_id or "0")
+ department_id=defaults.get('department_id',None)
+ if not department_id:
+ dom=[]
+ dom.append(['user_id','=',user_id])
+ if branch_id:
+ dom.append(['branch_id','=',branch_id])
+ staff=get_model("clinic.staff").search_browse(dom)
+ if staff:
+ department_id=staff[0].department_id.id
+ else:
+ department_id=int(department_id or "0")
+ res={
+ 'date': date,
+ 'date_from': date_from,
+ 'date_to': date_to,
+ 'branch_id': branch_id,
+ 'department_id': department_id,
+ }
+ return res
def get_report_data(self,ids,context={}):
company_id=get_active_company()
company=get_model('company').browse(company_id)
year, month=time.strftime("%Y-%m").split("-")
weekday, total_day=monthrange(int(year), int(month))
- time_start='%s-%s-01'%(year,str(month).zfill(2))
- time_stop='%s-%s-%s'%(year,str(month).zfill(2),total_day)
-
- defaults=context.get('defaults')
- if defaults:
- year,month,day=defaults['date'].split("-")
- # XXX
- weekday, total_day=monthrange(int(year), int(month))
- time_start='%s-%s-01'%(year,str(month).zfill(2))
- time_stop='%s-%s-%s'%(year,str(month).zfill(2),total_day)
+ defaults=self.default_get(context=context)
+ time_start=defaults.get("date_from")
+ time_stop=defaults.get("date_to")
+ branch_id=defaults.get("branch_id")
+ department_id=defaults.get("department_id")
if ids:
obj=self.browse(ids)[0]
month=obj.date_from.split("-")[1]
time_start=obj.date_from
time_stop=obj.date_to
+ branch_id=obj.branch_id.id
+ department_id=obj.department_id.id
# new patient of this month
dom=[]
dom.append(['reg_date','>=',time_start])
dom.append(['reg_date','<=',time_stop])
+ if branch_id:
+ dom.append(['branch_id','=',branch_id])
+ if department_id:
+ dom.append(['department_id','=',department_id])
records=get_model('clinic.patient').search_browse(dom)
lines=[]
no=1
@@ -94,4 +117,9 @@ class ReportRecentPatient(Model):
data['date_to']="%s-%s-%s"%(year,month,total_day)
return data
+ def onchange_branch(self,context={}):
+ data=context['data']
+ data['department_id']=None
+ return data
+
ReportRecentPatient.register()
diff --git a/netforce_clinic/models/setting.py b/netforce_clinic/models/setting.py
index d2d884f..7f9119e 100644
--- a/netforce_clinic/models/setting.py
+++ b/netforce_clinic/models/setting.py
@@ -110,21 +110,6 @@ class ClinicSetting(Model):
if user_id !=1:
print("Only admin!!")
return
-
- #for exp in get_model('clinic.hd.case.expense').search_browse([]):
- #exp.write({
- #'note': ' ',
- #})
- # try to create contact
- for pt in get_model("clinic.patient").search_browse([]):
- pt.write({
- 'note': ' ',
- })
-
- #for staff in get_model("clinic.staff").search_browse([]):
- #staff.write({
- #'note': ' ',
- #})
print("Done!")
def reset_last_import(self,ids,context={}):
diff --git a/netforce_clinic/models/staff.py b/netforce_clinic/models/staff.py
index 424dc56..bd0f22d 100644
--- a/netforce_clinic/models/staff.py
+++ b/netforce_clinic/models/staff.py
@@ -81,6 +81,9 @@ class Staff(Model):
_fields={
'employee_id': fields.Many2One("hr.employee","Employee"),
"number": fields.Char("Number",required=True,search=True),
+ "title_id": fields.Many2One("clinic.name.title","Title"),
+ "first_name": fields.Char("First Name"),
+ "last_name": fields.Char("Last Name"),
"name": fields.Char("Name",required=True,search=True),
"name_check": fields.Char("Name",function="_get_name_check",store=True),
"name_eng": fields.Char("Eng Name",search=True),
@@ -129,6 +132,8 @@ class Staff(Model):
"cycle_item_nurses": fields.One2Many("clinic.cycle.item.line","nurse_id","Cycle Items"),
'branch_id': fields.Many2One("clinic.branch","Branch", search=True),
"partner_id": fields.Many2One("partner","Contact"),
+ 'departments': fields.Many2Many("clinic.department","Departments"),
+ 'test': fields.Boolean("Test",search=True),
}
def _get_number(self,context={}):
diff --git a/netforce_clinic/models/visit.py b/netforce_clinic/models/visit.py
index 58becc6..d61c2f5 100644
--- a/netforce_clinic/models/visit.py
+++ b/netforce_clinic/models/visit.py
@@ -147,6 +147,9 @@ class Visit(Model):
def confirm(self,ids,context={}):
obj=self.browse(ids)[0]
+ datenow=time.strftime("%Y-%m-%d")
+ if obj.visit_date > datenow:
+ raise Exception("Can not confirm visit %s: datenow is %s"%(obj.number or "", datenow))
number=obj.number
if number=="/" or not number:
number=self._get_number(context)
diff --git a/netforce_clinic/reports/report_labor_cost_daily.xlsx b/netforce_clinic/reports/report_labor_cost_daily.xlsx
index c5d0fc0..87e827a 100644
Binary files a/netforce_clinic/reports/report_labor_cost_daily.xlsx and b/netforce_clinic/reports/report_labor_cost_daily.xlsx differ
diff --git a/netforce_clinic/templates/report_hd_case_summary.hbs b/netforce_clinic/templates/report_hd_case_summary.hbs
index 66b2a4b..75f2764 100644
--- a/netforce_clinic/templates/report_hd_case_summary.hbs
+++ b/netforce_clinic/templates/report_hd_case_summary.hbs
@@ -128,7 +128,7 @@
- รวมจำนวนยาที่ใช้ประจำเดือน
+ รวมจำนวนยาที่ใช้ประจำเดือน
diff --git a/netforce_clinic/todo.txt b/netforce_clinic/todo.txt
index 436ce5f..2d48bb7 100644
--- a/netforce_clinic/todo.txt
+++ b/netforce_clinic/todo.txt
@@ -1,5 +1,12 @@
todo:
- show epo in list of hd case
+ convbal -> not yet (wait yui)
+ post 10,000 invoices per one time -> ask david
+ patient & staff
+ - split name -> not yet
+ staff have multi department -> added but set have to set permission
+ - many2many
+
+ show epo(yes) in list of hd case ->ok
matching payment > ok
create contact from staff -> ok
- script to clear invoice -
+ script to clear invoice -> ok