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