xxxx
parent
c933fb1280
commit
27bf15311f
|
@ -1,5 +1,3 @@
|
|||
<form model="clinic.report.discontinue.patient">
|
||||
<group>
|
||||
<field name="date" span="3"/>
|
||||
</group>
|
||||
<field name="date" span="3" mode="month"/>
|
||||
</form>
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
<form model="clinic.report.new.patient">
|
||||
<group>
|
||||
<field name="date" span="3"/>
|
||||
</group>
|
||||
<field name="date" span="3" mode="month"/>
|
||||
</form>
|
||||
|
|
|
@ -105,7 +105,7 @@ class Patient(Model):
|
|||
|
||||
|
||||
_defaults={
|
||||
"type": "mg",
|
||||
"type": "sc",
|
||||
"reg_date": lambda *a: time.strftime("%Y-%m-%d"),
|
||||
"number": _get_number,
|
||||
"company_id": lambda *a: get_active_company(),
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
from netforce.model import Model, fields
|
||||
from netforce.access import get_active_company
|
||||
|
||||
class PersonalCategory(Model):
|
||||
_name="clinic.personal.categ"
|
||||
|
@ -8,6 +9,11 @@ class PersonalCategory(Model):
|
|||
"name": fields.Char("Name",required=True,search=True),
|
||||
"type": fields.Selection([("doctor","Doctor"),("nurse","Nurse"),('other','Other')],"Type"),
|
||||
'parent_id': fields.Many2One("clinic.personal.categ","Parent"),
|
||||
'company_id': fields.Many2One("company","Company"),
|
||||
}
|
||||
|
||||
_defaults={
|
||||
"company_id": lambda *a: get_active_company(),
|
||||
}
|
||||
|
||||
PersonalCategory.register()
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
import time
|
||||
from calendar import monthrange
|
||||
|
||||
from netforce.model import Model,fields,get_model
|
||||
from netforce.access import get_active_company
|
||||
|
||||
from . import utils
|
||||
|
||||
class ReportDiscontinuePatient(Model):
|
||||
_name="clinic.report.discontinue.patient"
|
||||
_string="Report Discontinue Patient"
|
||||
|
@ -19,10 +22,42 @@ class ReportDiscontinuePatient(Model):
|
|||
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("-")
|
||||
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_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])
|
||||
records=get_model('clinic.patient').search_browse(dom)
|
||||
lines=[]
|
||||
no=1
|
||||
for record in records:
|
||||
lines.append({
|
||||
'no': no,
|
||||
'pid': record.id,
|
||||
'name': record.name or '',
|
||||
'note': record.note or '',
|
||||
})
|
||||
no+=1
|
||||
|
||||
month_str=utils.MONTHS['th_TH'][month]
|
||||
data={
|
||||
'company_name': company.name or "",
|
||||
'parent_company_name': company.parent_id.name or "",
|
||||
'lines': lines,
|
||||
'month': month_str,
|
||||
'year': year,
|
||||
}
|
||||
|
||||
return data
|
||||
|
||||
ReportDiscontinuePatient.register()
|
||||
|
|
|
@ -4,7 +4,6 @@ import urllib.parse as urllib
|
|||
from datetime import datetime
|
||||
from calendar import monthrange
|
||||
from netforce.model import Model, fields, get_model
|
||||
from netforce.database import get_connection
|
||||
from netforce.access import get_active_company
|
||||
|
||||
from . import utils
|
||||
|
@ -23,7 +22,6 @@ class ReportHDCaseSummary(Model):
|
|||
}
|
||||
|
||||
def get_report_data(self,ids,context={}):
|
||||
db=get_connection()
|
||||
company_id=get_active_company()
|
||||
company=get_model("company").browse(company_id)
|
||||
|
||||
|
@ -218,8 +216,8 @@ class ReportHDCaseSummary(Model):
|
|||
'month': month_str,
|
||||
'year': year,
|
||||
'lines': lines,
|
||||
'new_patient_lines': new_patient_lines,
|
||||
'resign_patient_lines': resign_patient_lines,
|
||||
#'new_patient_lines': new_patient_lines,
|
||||
#'resign_patient_lines': resign_patient_lines,
|
||||
'company_name': company.name or "",
|
||||
'parent_company_name': company.parent_id.name or "",
|
||||
}
|
||||
|
|
|
@ -31,24 +31,58 @@ class ReportMedicalSummary(Model):
|
|||
dom.append([['state','=','completed']])
|
||||
dom.append([['time_start','>=','%s-%s-01 00:00:00'%(year,month)]])
|
||||
dom.append([['time_stop','<=','%s-%s-%s 23:59:59'%(year,month,total_day)]])
|
||||
print("dom ", dom)
|
||||
|
||||
products=[]
|
||||
products={}
|
||||
for prod in get_model("product").search_browse([['type','=','stock']]):
|
||||
products[prod.code]={}
|
||||
for patient_type in ('sc','nhso','personal'):
|
||||
products[prod.code][patient_type]={
|
||||
'qty': 0,
|
||||
'name': prod.name,
|
||||
'code': prod.code,
|
||||
}
|
||||
|
||||
for hd_case in get_model('clinic.hd.case').search_browse(dom):
|
||||
print("="*30)
|
||||
patient_type=hd_case.patient_id.type
|
||||
for line in hd_case.lines:
|
||||
prod=line.product_id
|
||||
if line.type=='fee':
|
||||
continue
|
||||
if prod.type=='service':
|
||||
if line.type=='fee' or prod.type=='service':
|
||||
continue
|
||||
products[prod.code][patient_type]['qty']+=line.qty
|
||||
|
||||
lines=[]
|
||||
|
||||
for prod, records in products.items():
|
||||
line={
|
||||
'prod_name': records['sc']['name'], # XXX
|
||||
}
|
||||
for patient_type in ('sc','nhso','personal'):
|
||||
line.update({
|
||||
patient_type: records[patient_type]['qty'],
|
||||
})
|
||||
lines.append(line)
|
||||
|
||||
company_id=get_active_company()
|
||||
company=get_model('company').browse(company_id)
|
||||
month_str=utils.MONTHS['th_TH'][month]
|
||||
|
||||
lines=sorted(lines, key=lambda x: x['prod_name'])
|
||||
titles={
|
||||
'prod_name': 'ชื่อยา',
|
||||
'sc': utils.PATIENT_TYPE['sc'],
|
||||
'nhso': utils.PATIENT_TYPE['nhso'],
|
||||
'personal': utils.PATIENT_TYPE['personal'],
|
||||
}
|
||||
data={
|
||||
'company_name': company.name or "",
|
||||
'parent_company_name': company.parent_id.name or "",
|
||||
'titles': titles,
|
||||
'lines': lines,
|
||||
'month': month_str,
|
||||
'year': year,
|
||||
}
|
||||
data.update(titles)
|
||||
|
||||
return data
|
||||
|
||||
ReportMedicalSummary.register()
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
import time
|
||||
from calendar import monthrange
|
||||
|
||||
from netforce.model import Model,fields,get_model
|
||||
from netforce.access import get_active_company
|
||||
|
||||
from . import utils
|
||||
|
||||
class ReportNewPatient(Model):
|
||||
_name="clinic.report.new.patient"
|
||||
_string="Report New Patient"
|
||||
|
@ -19,9 +22,38 @@ class ReportNewPatient(Model):
|
|||
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("-")
|
||||
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_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)
|
||||
lines=[]
|
||||
no=1
|
||||
for record in records:
|
||||
lines.append({
|
||||
'no': no,
|
||||
'name': record.name or '',
|
||||
'pid': record.id,
|
||||
'note': record.note or '',
|
||||
})
|
||||
no+=1
|
||||
|
||||
month_str=utils.MONTHS['th_TH'][month]
|
||||
data={
|
||||
'company_name': company.name or "",
|
||||
'parent_company_name': company.parent_id.name or "",
|
||||
'lines': lines,
|
||||
'month': month_str,
|
||||
'year': year,
|
||||
}
|
||||
return data
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
ประจำเดือน {{month}} {{year}}
|
||||
</h4>
|
||||
</center>
|
||||
{{#if lines}}
|
||||
<table class="table">
|
||||
<thead>
|
||||
<th>#</th>
|
||||
|
@ -16,12 +17,17 @@
|
|||
<tbody>
|
||||
{{#each lines}}
|
||||
<tr>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td>{{no}}</td>
|
||||
<td>
|
||||
{{view "link" string=name action="clinic_patient" action_options="mode=form" active_id=pid}}
|
||||
</td>
|
||||
<td>{{note}}</td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
</tbody>
|
||||
<tfoot>
|
||||
</tfoot>
|
||||
</table>
|
||||
{{else}}
|
||||
No items to display.
|
||||
{{/if}}
|
||||
|
|
|
@ -9,20 +9,18 @@
|
|||
</center>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<th>ยา</th>
|
||||
<th>ประเภทการรักษา</th>
|
||||
<th>uc</th>
|
||||
<th>ซื้อ</th>
|
||||
<th>รวม</th>
|
||||
<th>{{prod_name}}</th>
|
||||
<th>{{sc}}</th>
|
||||
<th>{{nhso}}</th>
|
||||
<th>{{personal}}</th>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{#each lines}}
|
||||
<tr>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td>{{prod_name}}</td>
|
||||
<td>{{sc}}</td>
|
||||
<td>{{nhso}}</td>
|
||||
<td>{{personal}}</td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
</tbody>
|
||||
|
|
|
@ -7,7 +7,8 @@
|
|||
ประจำเดือน {{month}} {{year}}
|
||||
</h4>
|
||||
</center>
|
||||
<table class="table">
|
||||
{{#if lines}}
|
||||
<table class="table">
|
||||
<thead>
|
||||
<th>#</th>
|
||||
<th>ชื่อ</th>
|
||||
|
@ -17,11 +18,16 @@
|
|||
{{#each lines}}
|
||||
<tr>
|
||||
<td>{{no}}</td>
|
||||
<td>{{name}}</td>
|
||||
<td>
|
||||
{{view "link" string=name action="clinic_patient" action_options="mode=form" active_id=pid}}
|
||||
</td>
|
||||
<td>{{note}}</td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
</tbody>
|
||||
<tfoot>
|
||||
</tfoot>
|
||||
</table>
|
||||
</table>
|
||||
{{else}}
|
||||
No items to display.
|
||||
{{/if}}
|
||||
|
|
Loading…
Reference in New Issue