diff --git a/netforce_clinic/layouts/clinic_report_discontinue_patient.xml b/netforce_clinic/layouts/clinic_report_discontinue_patient.xml
index 27869f8..b006ac8 100644
--- a/netforce_clinic/layouts/clinic_report_discontinue_patient.xml
+++ b/netforce_clinic/layouts/clinic_report_discontinue_patient.xml
@@ -1,3 +1,5 @@
diff --git a/netforce_clinic/layouts/clinic_report_new_patient.xml b/netforce_clinic/layouts/clinic_report_new_patient.xml
index bcfd736..ba06bb1 100644
--- a/netforce_clinic/layouts/clinic_report_new_patient.xml
+++ b/netforce_clinic/layouts/clinic_report_new_patient.xml
@@ -1,3 +1,5 @@
diff --git a/netforce_clinic/models/personal_move.py b/netforce_clinic/models/personal_move.py
index ec92188..a436b55 100644
--- a/netforce_clinic/models/personal_move.py
+++ b/netforce_clinic/models/personal_move.py
@@ -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()
diff --git a/netforce_clinic/models/report_discontinue_patient.py b/netforce_clinic/models/report_discontinue_patient.py
index 5f521c7..fed64e0 100644
--- a/netforce_clinic/models/report_discontinue_patient.py
+++ b/netforce_clinic/models/report_discontinue_patient.py
@@ -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()
diff --git a/netforce_clinic/models/report_medical_summary.py b/netforce_clinic/models/report_medical_summary.py
index 2c5ba99..7d9f257 100644
--- a/netforce_clinic/models/report_medical_summary.py
+++ b/netforce_clinic/models/report_medical_summary.py
@@ -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()
diff --git a/netforce_clinic/models/report_new_patient.py b/netforce_clinic/models/report_new_patient.py
index 3f4bd34..d7f140b 100644
--- a/netforce_clinic/models/report_new_patient.py
+++ b/netforce_clinic/models/report_new_patient.py
@@ -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()
diff --git a/netforce_clinic/templates/report_discontinue_patient.hbs b/netforce_clinic/templates/report_discontinue_patient.hbs
index b6d56a5..0aec8f1 100644
--- a/netforce_clinic/templates/report_discontinue_patient.hbs
+++ b/netforce_clinic/templates/report_discontinue_patient.hbs
@@ -4,13 +4,18 @@
{{parent_company_name}} {{company_name}}
- ประจำเดือน {{month}} {{year}}
+ {{#if is_duration}}
+ ระหว่างวันที่ {{from}} ถึง {{to}}
+ {{else}}
+ ประจำเดือน {{month}} {{year}}
+ {{/if}}
{{#if lines}}
# |
+ วันที่ |
ชื่อ |
หมายเหตุ |
@@ -18,6 +23,7 @@
{{#each lines}}
{{no}} |
+ {{resign_date}} |
{{view "link" string=name action="clinic_patient" action_options="mode=form" active_id=pid}}
|
diff --git a/netforce_clinic/templates/report_hd_case_summary.hbs b/netforce_clinic/templates/report_hd_case_summary.hbs
index ad96124..b8f5519 100644
--- a/netforce_clinic/templates/report_hd_case_summary.hbs
+++ b/netforce_clinic/templates/report_hd_case_summary.hbs
@@ -60,6 +60,7 @@
# |
+ วันที่ |
ชื่อ |
หมายเหตุ |
@@ -68,6 +69,7 @@
{{#each new_patients}}
{{no}} |
+ {{reg_date}} |
{{view "link" string=name action="clinic_patient" action_options="mode=form" active_id=pid}}
|
@@ -90,6 +92,7 @@
# |
+ วันที่ |
ชื่อ |
หมายเหตุ |
@@ -98,6 +101,7 @@
{{#each resign_patients}}
{{no}} |
+ {{resign_date}} |
{{view "link" string=name action="clinic_patient" action_options="mode=form" active_id=pid}}
|
@@ -134,6 +138,7 @@
{{sc}} |
{{nhso}} |
{{personal}} |
+ รวม |
{{#each medicals}}
@@ -144,6 +149,7 @@
{{sc}} |
{{nhso}} |
{{personal}} |
+ {{total}} |
{{/each}}
diff --git a/netforce_clinic/templates/report_medical_summary.hbs b/netforce_clinic/templates/report_medical_summary.hbs
index 50c4584..c06baae 100644
--- a/netforce_clinic/templates/report_medical_summary.hbs
+++ b/netforce_clinic/templates/report_medical_summary.hbs
@@ -1,5 +1,5 @@
- รวมจำนวนยาที่ใช้ประจำเดือน
+ จำนวนยาที่ใช้
{{parent_company_name}} {{company_name}}
@@ -13,6 +13,7 @@
{{sc}} |
{{nhso}} |
{{personal}} |
+ รวม |
{{#each lines}}
@@ -23,6 +24,7 @@
{{sc}} |
{{nhso}} |
{{personal}} |
+ {{total}} |
{{/each}}
diff --git a/netforce_clinic/templates/report_new_patient.hbs b/netforce_clinic/templates/report_new_patient.hbs
index 9d8384a..c432564 100644
--- a/netforce_clinic/templates/report_new_patient.hbs
+++ b/netforce_clinic/templates/report_new_patient.hbs
@@ -4,13 +4,18 @@
{{parent_company_name}} {{company_name}}
- ประจำเดือน {{month}} {{year}}
+ {{#if is_duration}}
+ ระหว่างวันที่ {{from}} ถึง {{to}}
+ {{else}}
+ ประจำเดือน {{month}} {{year}}
+ {{/if}}
{{#if lines}}
# |
+ วันที่ |
ชื่อ |
หมายเหตุ |
@@ -18,6 +23,7 @@
{{#each lines}}
{{no}} |
+ {{reg_date}} |
{{view "link" string=name action="clinic_patient" action_options="mode=form" active_id=pid}}
|