reports
parent
136067e422
commit
3faeca4977
|
@ -1,3 +1,5 @@
|
||||||
<form model="clinic.report.discontinue.patient">
|
<form model="clinic.report.discontinue.patient">
|
||||||
<field name="date" span="3" mode="month"/>
|
<field name="date" span="3" mode="month" onchange="onchange_date"/>
|
||||||
|
<field name="date_from" span="3"/>
|
||||||
|
<field name="date_to" span="3"/>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
<form model="clinic.report.new.patient">
|
<form model="clinic.report.new.patient">
|
||||||
<field name="date" span="3" mode="month"/>
|
<field name="date" span="3" mode="month" onchange="onchange_date"/>
|
||||||
|
<field name="date_from" span="3"/>
|
||||||
|
<field name="date_to" span="3"/>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -1,18 +1,23 @@
|
||||||
from netforce.model import Model, fields
|
from netforce.model import Model, fields
|
||||||
|
from netforce.access import get_active_company
|
||||||
|
|
||||||
class PersonalMove(Model):
|
class PersonalMove(Model):
|
||||||
_name="clinic.personal.move"
|
_name="clinic.personal.move"
|
||||||
_string="Personal Move"
|
_string="Personal Move"
|
||||||
|
|
||||||
_fields={
|
_fields={
|
||||||
"personal_id": fields.Many2One("clinic.personal","Personal (Doctor/Nurse)"),
|
"personal_id": fields.Many2One("clinic.personal","Personal (Doctor/Nurse)", search=True),
|
||||||
"level_id": fields.Many2One("clinic.personal.level","Personal Level"),
|
"level_id": fields.Many2One("clinic.personal.level","Personal Level", search=True),
|
||||||
"from_company_id": fields.Many2One("company", "From"),
|
"from_company_id": fields.Many2One("company", "From", search=True),
|
||||||
"to_company_id": fields.Many2One("company", "To"),
|
"to_company_id": fields.Many2One("company", "To", search=True),
|
||||||
"hire_date": fields.Date("Hire Date"),
|
"hire_date": fields.Date("Hire Date", search=True),
|
||||||
"resign_date": fields.Date("Resign Date"),
|
"resign_date": fields.Date("Resign Date", search=True),
|
||||||
"wage": fields.Float("Wage"),
|
"wage": fields.Float("Wage"),
|
||||||
"note": fields.Text("Note"),
|
"note": fields.Text("Note"),
|
||||||
|
'company_id': fields.Many2One("company","Company"),
|
||||||
|
}
|
||||||
|
_defaults={
|
||||||
|
"company_id": lambda *a: get_active_company(),
|
||||||
}
|
}
|
||||||
|
|
||||||
PersonalMove.register()
|
PersonalMove.register()
|
||||||
|
|
|
@ -12,31 +12,46 @@ class ReportDiscontinuePatient(Model):
|
||||||
_transient=True
|
_transient=True
|
||||||
|
|
||||||
_fields={
|
_fields={
|
||||||
"date": fields.Date("Month", required=True),
|
"date": fields.Date("Month"),
|
||||||
|
"date_from": fields.Date("From", required=True),
|
||||||
|
"date_to": fields.Date("To", required=True),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def _get_date_from(self,context={}):
|
||||||
|
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={
|
_defaults={
|
||||||
'date': lambda *a: time.strftime("%Y-%m-%d"),
|
'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={}):
|
def get_report_data(self,ids,context={}):
|
||||||
company_id=get_active_company()
|
company_id=get_active_company()
|
||||||
company=get_model('company').browse(company_id)
|
company=get_model('company').browse(company_id)
|
||||||
year, month=time.strftime("%Y-%m").split("-")
|
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')
|
defaults=context.get('defaults')
|
||||||
if defaults:
|
if defaults:
|
||||||
year,month,day=defaults['date'].split("-")
|
year,month,day=defaults['date'].split("-")
|
||||||
if ids:
|
|
||||||
obj=self.browse(ids)[0]
|
|
||||||
year,month,day=obj.date.split("-")
|
|
||||||
# new patient of this month
|
|
||||||
year=int(year)
|
|
||||||
month=int(month)
|
|
||||||
dom=[]
|
|
||||||
weekday, total_day=monthrange(year, month)
|
|
||||||
dom=[]
|
|
||||||
time_start='%s-%s-01'%(year,str(month).zfill(2))
|
time_start='%s-%s-01'%(year,str(month).zfill(2))
|
||||||
time_stop='%s-%s-%s'%(year,str(month).zfill(2),total_day)
|
time_stop='%s-%s-%s'%(year,str(month).zfill(2),total_day)
|
||||||
|
if ids:
|
||||||
|
obj=self.browse(ids)[0]
|
||||||
|
month=obj.date_from.split("-")[1]
|
||||||
|
time_start=obj.date_from
|
||||||
|
time_stop=obj.date_to
|
||||||
|
# new patient of this month
|
||||||
|
dom=[]
|
||||||
dom.append(['resign_date','>=',time_start])
|
dom.append(['resign_date','>=',time_start])
|
||||||
dom.append(['resign_date','<=',time_stop])
|
dom.append(['resign_date','<=',time_stop])
|
||||||
dom.append(['active','=',False])
|
dom.append(['active','=',False])
|
||||||
|
@ -46,21 +61,36 @@ class ReportDiscontinuePatient(Model):
|
||||||
for record in records:
|
for record in records:
|
||||||
lines.append({
|
lines.append({
|
||||||
'no': no,
|
'no': no,
|
||||||
'pid': record.id,
|
|
||||||
'name': record.name or '',
|
'name': record.name or '',
|
||||||
|
'pid': record.id,
|
||||||
'note': record.note or '',
|
'note': record.note or '',
|
||||||
|
'resign_date': record.resign_date or '',
|
||||||
})
|
})
|
||||||
no+=1
|
no+=1
|
||||||
|
|
||||||
month_str=utils.MONTHS['th_TH'][month]
|
month_str=utils.MONTHS['th_TH'][int(month)]
|
||||||
|
start=int(time_start[8:10])
|
||||||
|
stop=int(time_stop[8:10])
|
||||||
|
diff=stop-start
|
||||||
data={
|
data={
|
||||||
'company_name': company.name or "",
|
'company_name': company.name or "",
|
||||||
'parent_company_name': company.parent_id.name or "",
|
'parent_company_name': company.parent_id.name or "",
|
||||||
'lines': lines,
|
'lines': lines,
|
||||||
'month': month_str,
|
'month': month_str,
|
||||||
|
'from': time_start,
|
||||||
|
'to': time_stop,
|
||||||
|
'is_duration': diff+1 < total_day,
|
||||||
'year': year,
|
'year': year,
|
||||||
}
|
}
|
||||||
|
return data
|
||||||
|
|
||||||
|
def onchange_date(self,context={}):
|
||||||
|
data=context['data']
|
||||||
|
date=data['date']
|
||||||
|
year,month,day=date.split("-")
|
||||||
|
weekday, total_day=monthrange(int(year), int(month))
|
||||||
|
data['date_from']="%s-%s-01"%(year,month)
|
||||||
|
data['date_to']="%s-%s-%s"%(year,month,total_day)
|
||||||
return data
|
return data
|
||||||
|
|
||||||
ReportDiscontinuePatient.register()
|
ReportDiscontinuePatient.register()
|
||||||
|
|
|
@ -53,15 +53,20 @@ class ReportMedicalSummary(Model):
|
||||||
|
|
||||||
lines=[]
|
lines=[]
|
||||||
|
|
||||||
|
limit=25
|
||||||
for prod, records in products.items():
|
for prod, records in products.items():
|
||||||
|
prod_name=records['sc']['name'] or ""
|
||||||
|
prod_name=len(prod_name) > limit and '%s...' %prod_name[0:limit] or prod_name
|
||||||
line={
|
line={
|
||||||
'prod_name': records['sc']['name'], # XXX
|
'prod_name': prod_name,
|
||||||
'prod_id': records[patient_type]['prod_id'],
|
'prod_id': records[patient_type]['prod_id'],
|
||||||
|
'total': 0,
|
||||||
}
|
}
|
||||||
for patient_type in ('sc','nhso','personal'):
|
for patient_type in ('sc','nhso','personal'):
|
||||||
line.update({
|
line.update({
|
||||||
patient_type: records[patient_type]['qty'],
|
patient_type: records[patient_type]['qty'] or 0,
|
||||||
})
|
})
|
||||||
|
line['total']+=line[patient_type]
|
||||||
lines.append(line)
|
lines.append(line)
|
||||||
|
|
||||||
company_id=get_active_company()
|
company_id=get_active_company()
|
||||||
|
|
|
@ -12,31 +12,46 @@ class ReportNewPatient(Model):
|
||||||
_transient=True
|
_transient=True
|
||||||
|
|
||||||
_fields={
|
_fields={
|
||||||
"date": fields.Date("Month", required=True),
|
"date": fields.Date("Month"),
|
||||||
|
"date_from": fields.Date("From", required=True),
|
||||||
|
"date_to": fields.Date("To", required=True),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def _get_date_from(self,context={}):
|
||||||
|
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={
|
_defaults={
|
||||||
'date': lambda *a: time.strftime("%Y-%m-%d"),
|
'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={}):
|
def get_report_data(self,ids,context={}):
|
||||||
company_id=get_active_company()
|
company_id=get_active_company()
|
||||||
company=get_model('company').browse(company_id)
|
company=get_model('company').browse(company_id)
|
||||||
year, month=time.strftime("%Y-%m").split("-")
|
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')
|
defaults=context.get('defaults')
|
||||||
if defaults:
|
if defaults:
|
||||||
year,month,day=defaults['date'].split("-")
|
year,month,day=defaults['date'].split("-")
|
||||||
if ids:
|
|
||||||
obj=self.browse(ids)[0]
|
|
||||||
year,month,day=obj.date.split("-")
|
|
||||||
# new patient of this month
|
|
||||||
year=int(year)
|
|
||||||
month=int(month)
|
|
||||||
dom=[]
|
|
||||||
weekday, total_day=monthrange(year, month)
|
|
||||||
time_start='%s-%s-01'%(year,str(month).zfill(2))
|
time_start='%s-%s-01'%(year,str(month).zfill(2))
|
||||||
time_stop='%s-%s-%s'%(year,str(month).zfill(2),total_day)
|
time_stop='%s-%s-%s'%(year,str(month).zfill(2),total_day)
|
||||||
|
if ids:
|
||||||
|
obj=self.browse(ids)[0]
|
||||||
|
month=obj.date_from.split("-")[1]
|
||||||
|
time_start=obj.date_from
|
||||||
|
time_stop=obj.date_to
|
||||||
|
# new patient of this month
|
||||||
|
dom=[]
|
||||||
dom.append(['reg_date','>=',time_start])
|
dom.append(['reg_date','>=',time_start])
|
||||||
dom.append(['reg_date','<=',time_stop])
|
dom.append(['reg_date','<=',time_stop])
|
||||||
records=get_model('clinic.patient').search_browse(dom)
|
records=get_model('clinic.patient').search_browse(dom)
|
||||||
|
@ -48,17 +63,33 @@ class ReportNewPatient(Model):
|
||||||
'name': record.name or '',
|
'name': record.name or '',
|
||||||
'pid': record.id,
|
'pid': record.id,
|
||||||
'note': record.note or '',
|
'note': record.note or '',
|
||||||
|
'reg_date': record.reg_date,
|
||||||
})
|
})
|
||||||
no+=1
|
no+=1
|
||||||
|
|
||||||
month_str=utils.MONTHS['th_TH'][month]
|
month_str=utils.MONTHS['th_TH'][int(month)]
|
||||||
|
start=int(time_start[8:10])
|
||||||
|
stop=int(time_stop[8:10])
|
||||||
|
diff=stop-start
|
||||||
data={
|
data={
|
||||||
'company_name': company.name or "",
|
'company_name': company.name or "",
|
||||||
'parent_company_name': company.parent_id.name or "",
|
'parent_company_name': company.parent_id.name or "",
|
||||||
'lines': lines,
|
'lines': lines,
|
||||||
'month': month_str,
|
'month': month_str,
|
||||||
|
'from': time_start,
|
||||||
|
'to': time_stop,
|
||||||
|
'is_duration': diff+1 < total_day,
|
||||||
'year': year,
|
'year': year,
|
||||||
}
|
}
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
def onchange_date(self,context={}):
|
||||||
|
data=context['data']
|
||||||
|
date=data['date']
|
||||||
|
year,month,day=date.split("-")
|
||||||
|
weekday, total_day=monthrange(int(year), int(month))
|
||||||
|
data['date_from']="%s-%s-01"%(year,month)
|
||||||
|
data['date_to']="%s-%s-%s"%(year,month,total_day)
|
||||||
|
return data
|
||||||
|
|
||||||
ReportNewPatient.register()
|
ReportNewPatient.register()
|
||||||
|
|
|
@ -4,13 +4,18 @@
|
||||||
{{parent_company_name}} {{company_name}}<br/>
|
{{parent_company_name}} {{company_name}}<br/>
|
||||||
</h3>
|
</h3>
|
||||||
<h4>
|
<h4>
|
||||||
|
{{#if is_duration}}
|
||||||
|
ระหว่างวันที่ {{from}} ถึง {{to}}
|
||||||
|
{{else}}
|
||||||
ประจำเดือน {{month}} {{year}}
|
ประจำเดือน {{month}} {{year}}
|
||||||
|
{{/if}}
|
||||||
</h4>
|
</h4>
|
||||||
</center>
|
</center>
|
||||||
{{#if lines}}
|
{{#if lines}}
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<thead>
|
<thead>
|
||||||
<th>#</th>
|
<th>#</th>
|
||||||
|
<th>วันที่</th>
|
||||||
<th>ชื่อ</th>
|
<th>ชื่อ</th>
|
||||||
<th>หมายเหตุ</th>
|
<th>หมายเหตุ</th>
|
||||||
</thead>
|
</thead>
|
||||||
|
@ -18,6 +23,7 @@
|
||||||
{{#each lines}}
|
{{#each lines}}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{no}}</td>
|
<td>{{no}}</td>
|
||||||
|
<td>{{resign_date}}</td>
|
||||||
<td>
|
<td>
|
||||||
{{view "link" string=name action="clinic_patient" action_options="mode=form" active_id=pid}}
|
{{view "link" string=name action="clinic_patient" action_options="mode=form" active_id=pid}}
|
||||||
</td>
|
</td>
|
||||||
|
|
|
@ -60,6 +60,7 @@
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<thead>
|
<thead>
|
||||||
<th>#</th>
|
<th>#</th>
|
||||||
|
<th>วันที่</th>
|
||||||
<th>ชื่อ</th>
|
<th>ชื่อ</th>
|
||||||
<th>หมายเหตุ</th>
|
<th>หมายเหตุ</th>
|
||||||
</thead>
|
</thead>
|
||||||
|
@ -68,6 +69,7 @@
|
||||||
{{#each new_patients}}
|
{{#each new_patients}}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{no}}</td>
|
<td>{{no}}</td>
|
||||||
|
<td>{{reg_date}}</td>
|
||||||
<td>
|
<td>
|
||||||
{{view "link" string=name action="clinic_patient" action_options="mode=form" active_id=pid}}
|
{{view "link" string=name action="clinic_patient" action_options="mode=form" active_id=pid}}
|
||||||
</td>
|
</td>
|
||||||
|
@ -90,6 +92,7 @@
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<thead>
|
<thead>
|
||||||
<th>#</th>
|
<th>#</th>
|
||||||
|
<th>วันที่</th>
|
||||||
<th>ชื่อ</th>
|
<th>ชื่อ</th>
|
||||||
<th>หมายเหตุ</th>
|
<th>หมายเหตุ</th>
|
||||||
</thead>
|
</thead>
|
||||||
|
@ -98,6 +101,7 @@
|
||||||
{{#each resign_patients}}
|
{{#each resign_patients}}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{no}}</td>
|
<td>{{no}}</td>
|
||||||
|
<td>{{resign_date}}</td>
|
||||||
<td>
|
<td>
|
||||||
{{view "link" string=name action="clinic_patient" action_options="mode=form" active_id=pid}}
|
{{view "link" string=name action="clinic_patient" action_options="mode=form" active_id=pid}}
|
||||||
</td>
|
</td>
|
||||||
|
@ -134,6 +138,7 @@
|
||||||
<th>{{sc}}</th>
|
<th>{{sc}}</th>
|
||||||
<th>{{nhso}}</th>
|
<th>{{nhso}}</th>
|
||||||
<th>{{personal}}</th>
|
<th>{{personal}}</th>
|
||||||
|
<th>รวม</th>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{{#each medicals}}
|
{{#each medicals}}
|
||||||
|
@ -144,6 +149,7 @@
|
||||||
<td>{{sc}}</td>
|
<td>{{sc}}</td>
|
||||||
<td>{{nhso}}</td>
|
<td>{{nhso}}</td>
|
||||||
<td>{{personal}}</td>
|
<td>{{personal}}</td>
|
||||||
|
<td>{{total}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<center>
|
<center>
|
||||||
<h2>รวมจำนวนยาที่ใช้ประจำเดือน</h2>
|
<h2>จำนวนยาที่ใช้</h2>
|
||||||
<h3>
|
<h3>
|
||||||
{{parent_company_name}} {{company_name}}<br/>
|
{{parent_company_name}} {{company_name}}<br/>
|
||||||
</h3>
|
</h3>
|
||||||
|
@ -13,6 +13,7 @@
|
||||||
<th>{{sc}}</th>
|
<th>{{sc}}</th>
|
||||||
<th>{{nhso}}</th>
|
<th>{{nhso}}</th>
|
||||||
<th>{{personal}}</th>
|
<th>{{personal}}</th>
|
||||||
|
<th>รวม</th>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{{#each lines}}
|
{{#each lines}}
|
||||||
|
@ -23,6 +24,7 @@
|
||||||
<td>{{sc}}</td>
|
<td>{{sc}}</td>
|
||||||
<td>{{nhso}}</td>
|
<td>{{nhso}}</td>
|
||||||
<td>{{personal}}</td>
|
<td>{{personal}}</td>
|
||||||
|
<td>{{total}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
|
@ -4,13 +4,18 @@
|
||||||
{{parent_company_name}} {{company_name}}<br/>
|
{{parent_company_name}} {{company_name}}<br/>
|
||||||
</h3>
|
</h3>
|
||||||
<h4>
|
<h4>
|
||||||
|
{{#if is_duration}}
|
||||||
|
ระหว่างวันที่ {{from}} ถึง {{to}}
|
||||||
|
{{else}}
|
||||||
ประจำเดือน {{month}} {{year}}
|
ประจำเดือน {{month}} {{year}}
|
||||||
|
{{/if}}
|
||||||
</h4>
|
</h4>
|
||||||
</center>
|
</center>
|
||||||
{{#if lines}}
|
{{#if lines}}
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<thead>
|
<thead>
|
||||||
<th>#</th>
|
<th>#</th>
|
||||||
|
<th>วันที่</th>
|
||||||
<th>ชื่อ</th>
|
<th>ชื่อ</th>
|
||||||
<th>หมายเหตุ</th>
|
<th>หมายเหตุ</th>
|
||||||
</thead>
|
</thead>
|
||||||
|
@ -18,6 +23,7 @@
|
||||||
{{#each lines}}
|
{{#each lines}}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{no}}</td>
|
<td>{{no}}</td>
|
||||||
|
<td>{{reg_date}}</td>
|
||||||
<td>
|
<td>
|
||||||
{{view "link" string=name action="clinic_patient" action_options="mode=form" active_id=pid}}
|
{{view "link" string=name action="clinic_patient" action_options="mode=form" active_id=pid}}
|
||||||
</td>
|
</td>
|
||||||
|
|
Loading…
Reference in New Issue