improve
parent
26441129be
commit
dee7b80640
|
@ -6,6 +6,7 @@
|
|||
<field name="tabs">[
|
||||
["All",[]],
|
||||
["Draft",[["state","=","draft"]]],
|
||||
["Approved",[["state","=","approved"]]]
|
||||
["Approved",[["state","=","approved"]]],
|
||||
["Completed",[["state","=","done"]]]
|
||||
]</field>
|
||||
</action>
|
||||
|
|
|
@ -30,5 +30,6 @@
|
|||
<foot>
|
||||
<button string="Submit To Approve" method="submit" states="draft" type="default" icon="arrow-right"/>
|
||||
<button string="Approve" method="approve" states="waiting_approve" type="success"/>
|
||||
<button string="Send To Payment" method="send_to_payment" states="approved" type="default" icon="arrow-right"/>
|
||||
</foot>
|
||||
</form>
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
<form model="clinic.name.title">
|
||||
<field name="name"/>
|
||||
<field name="description"/>
|
||||
</form>
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
<list model="clinic.name.title">
|
||||
<field name="name"/>
|
||||
<field name="description"/>
|
||||
</list>
|
||||
|
|
|
@ -13,9 +13,12 @@
|
|||
<field name="name"/>
|
||||
<field name="reg_date"/>
|
||||
<field name="doctor_id"/>
|
||||
<field name="branch_id"/>
|
||||
<field name="categ_id"/>
|
||||
<field name="department_id" domain='[["branch_id","=",branch_id]]'/>
|
||||
<field name="branch_id" required="1"/>
|
||||
<field name="title_id" required="1"/>
|
||||
<field name="department_id" required="1" domain='[["branch_id","=",branch_id]]'/>
|
||||
<field name="first_name" required="1"/>
|
||||
<field name="last_name" required="1"/>
|
||||
<tabs>
|
||||
<tab string="General Information">
|
||||
<group span="6" columns="1">
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
<form model="clinic.report.discontinue.patient">
|
||||
<field name="date" span="3" mode="month" onchange="onchange_date"/>
|
||||
<field name="date_from" span="3"/>
|
||||
<field name="date_to" span="3"/>
|
||||
<field name="date" span="2" mode="month" onchange="onchange_date"/>
|
||||
<field name="date_from" span="2"/>
|
||||
<field name="date_to" span="2"/>
|
||||
<field name="branch_id" onchange="onchange_branch" span="2"/>
|
||||
<field name="department_id" domain='[["branch_id","=",branch_id]]' span="2"/>
|
||||
</form>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<form model="clinic.report.hd.case.summary">
|
||||
<field name="date" span="3" mode="month" onchange="onchange_date"/>
|
||||
<!--<field name="date_from" span="3"/>-->
|
||||
<!--<field name="date_to" span="3"/>-->
|
||||
<field name="branch_id" onchange="onchange_branch" span="3"/>
|
||||
<field name="department_id" domain='[["branch_id","=",branch_id]]' span="3"/>
|
||||
</form>
|
||||
|
|
|
@ -4,5 +4,5 @@
|
|||
<field name="date_to" span="2"/>
|
||||
<field name="prod_categ_id" span="2"/>
|
||||
<field name="branch_id" span="2"/>
|
||||
<field name="department_id" span="2"/>
|
||||
<field name="department_id" domain='[["branch_id","=",branch_id]]' span="2"/>
|
||||
</form>
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
<form model="clinic.report.recent.patient">
|
||||
<field name="date" span="3" mode="month" onchange="onchange_date"/>
|
||||
<field name="date_from" span="3"/>
|
||||
<field name="date_to" span="3"/>
|
||||
<field name="date" span="2" mode="month" onchange="onchange_date"/>
|
||||
<field name="date_from" span="2"/>
|
||||
<field name="date_to" span="2"/>
|
||||
<field name="branch_id" onchange="onchange_branch" span="2"/>
|
||||
<field name="department_id" domain='[["branch_id","=",branch_id]]' span="2"/>
|
||||
</form>
|
||||
|
|
|
@ -7,11 +7,12 @@
|
|||
</head>
|
||||
<field name="number"/>
|
||||
<field name="type" required="1"/>
|
||||
<field name="name"/>
|
||||
<field name="branch_id" required="1"/>
|
||||
<field name="title_id" required="1"/>
|
||||
<field name="nick_name"/>
|
||||
<field name="department_id" domain='[["branch_id","=",branch_id]]' required="1"/>
|
||||
<field name="first_name" required="1"/>
|
||||
<field name="last_name" required="1"/>
|
||||
<field name="name_eng"/>
|
||||
<field name="name"/>
|
||||
<field name="company_id" invisible="1"/>
|
||||
<tabs>
|
||||
<tab string="General">
|
||||
|
@ -34,6 +35,11 @@
|
|||
<field name="active"/>
|
||||
</group>
|
||||
</tab>
|
||||
<tab string="Work Location">
|
||||
<field name="branch_id" required="1"/>
|
||||
<field name="department_id" domain='[["branch_id","=",branch_id]]' required="1"/>
|
||||
<field name="departments"/>
|
||||
</tab>
|
||||
<tab string="Professional Information">
|
||||
<field name="prof_license" attrs='{"invisible":[["type","in",["staff"]]]}'/>
|
||||
<field name="prof_license_date" attrs='{"invisible":[["type","in",["staff"]]]}'/>
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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={}):
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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])
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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={}):
|
||||
|
|
|
@ -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={}):
|
||||
|
|
|
@ -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)
|
||||
|
|
Binary file not shown.
|
@ -128,7 +128,7 @@
|
|||
<span>
|
||||
<center>
|
||||
<b>
|
||||
<a href="/ui#name=clinic_report_medical_summary&defaults.date={{date}}">รวมจำนวนยาที่ใช้ประจำเดือน</a>
|
||||
<a href="/ui#name=clinic_report_medical_summary&defaults.date={{date}}&defaults.branch_id={{branch_id}}&defaults.department_id={{department_id}}">รวมจำนวนยาที่ใช้ประจำเดือน</a>
|
||||
</b>
|
||||
</center>
|
||||
</span>
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue