keep old patient name, report hdcase summary get data from patient move
parent
939c3e6f4d
commit
2d1b3e0bba
|
@ -0,0 +1,6 @@
|
||||||
|
<action>
|
||||||
|
<field name="string">Patient Movement</field>
|
||||||
|
<field name="view_cls">multi_view</field>
|
||||||
|
<field name="model">clinic.patient.move</field>
|
||||||
|
<field name="menu">clinic_menu</field>
|
||||||
|
</action>
|
|
@ -0,0 +1,9 @@
|
||||||
|
<action>
|
||||||
|
<field name="string">HDCase Summary(v2)</field>
|
||||||
|
<field name="view_cls">report</field>
|
||||||
|
<field name="model">report.hdcase.summary</field>
|
||||||
|
<field name="report_template">report_hdcase_summary</field>
|
||||||
|
<field name="report_template_xls">report_hdcase_summary</field>
|
||||||
|
<field name="export_pdf">1</field>
|
||||||
|
<field name="menu">clinic_menu</field>
|
||||||
|
</action>
|
|
@ -23,6 +23,7 @@
|
||||||
<field name="branch_id" span="2"/>
|
<field name="branch_id" span="2"/>
|
||||||
<field name="department_id" domain='[["branch_id","=",branch_id]]' span="2"/>
|
<field name="department_id" domain='[["branch_id","=",branch_id]]' span="2"/>
|
||||||
<field name="doctor_id" string="Personal Doctor" span="3"/>
|
<field name="doctor_id" string="Personal Doctor" span="3"/>
|
||||||
|
<field name="patient_name" span="3"/>
|
||||||
<field name="req_fee" span="2" invisible="1"/>
|
<field name="req_fee" span="2" invisible="1"/>
|
||||||
<field name="company_id" span="2" invisible="1"/> <!-- to show company name, don't remove -->
|
<field name="company_id" span="2" invisible="1"/> <!-- to show company name, don't remove -->
|
||||||
<field name="hct_include" span="2" invisible="1"/>
|
<field name="hct_include" span="2" invisible="1"/>
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<field name="number"/>
|
<field name="number"/>
|
||||||
<field name="date"/>
|
<field name="date"/>
|
||||||
<field name="cycle_id"/>
|
<field name="cycle_id"/>
|
||||||
<field name="patient_id"/>
|
<field name="patient_name"/>
|
||||||
<field name="patient_type_id"/>
|
<field name="patient_type_id"/>
|
||||||
<field name="epo"/>
|
<field name="epo"/>
|
||||||
<field name="department_id"/>
|
<field name="department_id"/>
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
<field name="date"/>
|
<field name="date"/>
|
||||||
<field name="cycle_id"/>
|
<field name="cycle_id"/>
|
||||||
<field name="patient_id"/>
|
<field name="patient_id"/>
|
||||||
|
<field name="patient_name"/>
|
||||||
<field name="patient_type_id"/>
|
<field name="patient_type_id"/>
|
||||||
<field name="department_id"/>
|
<field name="department_id"/>
|
||||||
<field name="branch_id"/>
|
<field name="branch_id"/>
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
</item>
|
</item>
|
||||||
<item string="Patients" perm="clinic_patient">
|
<item string="Patients" perm="clinic_patient">
|
||||||
<item string="Patients" action="clinic_patient"/>
|
<item string="Patients" action="clinic_patient"/>
|
||||||
|
<item string="Patient Movement" action="clinic_patient_move"/>
|
||||||
<item string="Dialyzers" action="clinic_dialyzer"/>
|
<item string="Dialyzers" action="clinic_dialyzer"/>
|
||||||
<divider/>
|
<divider/>
|
||||||
<header string="SETTINGS"/>
|
<header string="SETTINGS"/>
|
||||||
|
@ -45,6 +46,7 @@
|
||||||
<item string="Report Cycle Setting" action="clinic_report_cycle_setting"/>
|
<item string="Report Cycle Setting" action="clinic_report_cycle_setting"/>
|
||||||
<item string="Cycle Item Summary" action="clinic_report_cycle_item"/>
|
<item string="Cycle Item Summary" action="clinic_report_cycle_item"/>
|
||||||
<item string="HD Case Summary" action="clinic_report_hd_case_summary"/>
|
<item string="HD Case Summary" action="clinic_report_hd_case_summary"/>
|
||||||
|
<item string="HD Case Summary(v2)" action="report_hdcase_summary"/>
|
||||||
<item string="HD Case Expense" action="clinic_report_claim"/>
|
<item string="HD Case Expense" action="clinic_report_claim"/>
|
||||||
<item string="RD Shop Expense" action="clinic_report_shop"/>
|
<item string="RD Shop Expense" action="clinic_report_shop"/>
|
||||||
<divider/>
|
<divider/>
|
||||||
|
|
|
@ -4,9 +4,8 @@
|
||||||
</head>
|
</head>
|
||||||
<field name="number"/>
|
<field name="number"/>
|
||||||
<field name="date"/>
|
<field name="date"/>
|
||||||
<field name="contact_id"/>
|
<!--<field name="contact_id"/>-->
|
||||||
<!--<field name="ref"/>-->
|
<field name="patient_name"/>
|
||||||
<!--<field name="branch_id"/>-->
|
|
||||||
<field name="department_id"/>
|
<field name="department_id"/>
|
||||||
<field name="pay_type"/>
|
<field name="pay_type"/>
|
||||||
<field name="user_id"/>
|
<field name="user_id"/>
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
<field name="time_stop"/>
|
<field name="time_stop"/>
|
||||||
<field name="doctor_id"/>
|
<field name="doctor_id"/>
|
||||||
<field name="visit_date" onchange="onchange_date"/>
|
<field name="visit_date" onchange="onchange_date"/>
|
||||||
|
<field name="patient_name"/>
|
||||||
<field name="company_id" invisible="1"/>
|
<field name="company_id" invisible="1"/>
|
||||||
</group>
|
</group>
|
||||||
</tab>
|
</tab>
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<field name="number"/>
|
<field name="number"/>
|
||||||
<field name="visit_date"/>
|
<field name="visit_date"/>
|
||||||
<field name="cycle_id"/>
|
<field name="cycle_id"/>
|
||||||
<field name="patient_id"/>
|
<field name="patient_name"/>
|
||||||
<field name="doctor_id"/>
|
<field name="doctor_id"/>
|
||||||
<field name="department_id"/>
|
<field name="department_id"/>
|
||||||
<field name="branch_id"/>
|
<field name="branch_id"/>
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
<field name="visit_date"/>
|
<field name="visit_date"/>
|
||||||
<field name="number"/>
|
<field name="number"/>
|
||||||
<field name="patient_id"/>
|
<field name="patient_id"/>
|
||||||
|
<field name="patient_name"/>
|
||||||
<field name="doctor_id"/>
|
<field name="doctor_id"/>
|
||||||
<field name="cycle_id"/>
|
<field name="cycle_id"/>
|
||||||
<field name="department_id"/>
|
<field name="department_id"/>
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
<form model="clinic.patient.move">
|
||||||
|
<field name="patient_id"/>
|
||||||
|
<field name="date"/>
|
||||||
|
<field name="location_from_id"/>
|
||||||
|
<field name="location_to_id"/>
|
||||||
|
<field name="note"/>
|
||||||
|
<field name="state"/>
|
||||||
|
</form>
|
|
@ -0,0 +1,8 @@
|
||||||
|
<list model="clinic.patient.move">
|
||||||
|
<field name="date" span="2"/>
|
||||||
|
<field name="patient_id" span="2"/>
|
||||||
|
<field name="location_from_id" span="2"/>
|
||||||
|
<field name="location_to_id" span="2"/>
|
||||||
|
<field name="note" span="2"/>
|
||||||
|
<field name="state" span="2"/>
|
||||||
|
</list>
|
|
@ -0,0 +1,5 @@
|
||||||
|
<form model="report.hdcase.summary">
|
||||||
|
<field name="month" mode="month" span="2"/>
|
||||||
|
<!--<field name="branch_id" span="2"/>-->
|
||||||
|
<field name="department_id" span="2"/>
|
||||||
|
</form>
|
|
@ -15,4 +15,6 @@ from . import clinic_setting
|
||||||
#from . import reimport10to15
|
#from . import reimport10to15
|
||||||
#from . import add_missing_dlz # pending
|
#from . import add_missing_dlz # pending
|
||||||
#from . import validate_cycle_item
|
#from . import validate_cycle_item
|
||||||
from . import update_line_amount
|
#from . import update_line_amount
|
||||||
|
#from . import store_patient_name
|
||||||
|
from . import patient_move
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
import time
|
||||||
|
import csv
|
||||||
|
import xlrd
|
||||||
|
|
||||||
|
from netforce.model import get_model
|
||||||
|
from netforce import migration
|
||||||
|
from netforce.access import set_active_user, set_active_company
|
||||||
|
from netforce.database import get_connection
|
||||||
|
|
||||||
|
class PatientMove(migration.Migration):
|
||||||
|
_name="clinic.patient.move"
|
||||||
|
_version="2.12.6"
|
||||||
|
|
||||||
|
def migrate(self):
|
||||||
|
set_active_company(1)
|
||||||
|
set_active_user(1)
|
||||||
|
datenow=time.strftime("%Y-%m-%d")
|
||||||
|
datenow='2017-05-01'
|
||||||
|
get_model('clinic.patient.move').auto_get_data(context={'date': datenow})
|
||||||
|
#for patient in get_model("clinic.patient").search_browse([],order="department_id"):
|
||||||
|
#print(patient.name, patient.location, patient.department_id.name)
|
||||||
|
|
||||||
|
PatientMove.register()
|
|
@ -0,0 +1,26 @@
|
||||||
|
import csv
|
||||||
|
import xlrd
|
||||||
|
|
||||||
|
from netforce.model import get_model
|
||||||
|
from netforce import migration
|
||||||
|
from netforce.access import set_active_user, set_active_company
|
||||||
|
from netforce.database import get_connection
|
||||||
|
|
||||||
|
class Migration(migration.Migration):
|
||||||
|
_name="clinic.store.patient.name"
|
||||||
|
_version="2.12.6"
|
||||||
|
|
||||||
|
def migrate(self):
|
||||||
|
set_active_company(1)
|
||||||
|
set_active_user(1)
|
||||||
|
|
||||||
|
#ids=get_model("clinic.hd.case").search([])
|
||||||
|
#get_model("clinic.hd.case").function_store(ids)
|
||||||
|
|
||||||
|
ids=get_model("clinic.visit").search([])
|
||||||
|
get_model("clinic.visit").function_store(ids)
|
||||||
|
|
||||||
|
ids=get_model("clinic.shop").search([])
|
||||||
|
get_model("clinic.shop").function_store(ids)
|
||||||
|
|
||||||
|
Migration.register()
|
|
@ -148,3 +148,4 @@ from . import payment_matching
|
||||||
from . import create_invoice_payment
|
from . import create_invoice_payment
|
||||||
from . import report_stock_card
|
from . import report_stock_card
|
||||||
from . import report_receipt_summary
|
from . import report_receipt_summary
|
||||||
|
from . import report_hdcase_summary
|
||||||
|
|
|
@ -31,8 +31,16 @@ class AccountInvoice(Model):
|
||||||
'patient_id': fields.Many2One("clinic.patient","Patient",function="_get_patient", function_multi=True,store=True,search=True),
|
'patient_id': fields.Many2One("clinic.patient","Patient",function="_get_patient", function_multi=True,store=True,search=True),
|
||||||
'patient_type_id': fields.Many2One("clinic.patient.type","Patient Type",function="_get_patient", function_multi=True,store=True,search=True),
|
'patient_type_id': fields.Many2One("clinic.patient.type","Patient Type",function="_get_patient", function_multi=True,store=True,search=True),
|
||||||
'create_invoice_id': fields.Many2One("create.invoice.payment","Create Invoice Payment"),
|
'create_invoice_id': fields.Many2One("create.invoice.payment","Create Invoice Payment"),
|
||||||
|
'patient_name': fields.Char("Patient Name", function="_get_patient_name", store=True),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def _get_patient_name(self, ids, context={}):
|
||||||
|
res={}
|
||||||
|
for obj in self.browse(ids):
|
||||||
|
patient=obj.patient_id
|
||||||
|
res[obj.id]=patient.name
|
||||||
|
return res
|
||||||
|
|
||||||
def _get_number(self,context={}):
|
def _get_number(self,context={}):
|
||||||
defaults=context.get("defaults")
|
defaults=context.get("defaults")
|
||||||
if defaults: # XXX
|
if defaults: # XXX
|
||||||
|
|
|
@ -298,8 +298,16 @@ class HDCase(Model):
|
||||||
'company_id': fields.Many2One("company","Company"),
|
'company_id': fields.Many2One("company","Company"),
|
||||||
'branch_id': fields.Many2One("clinic.branch","Branch"),
|
'branch_id': fields.Many2One("clinic.branch","Branch"),
|
||||||
'check_dlz': fields.Boolean("Check Dialyzer"),
|
'check_dlz': fields.Boolean("Check Dialyzer"),
|
||||||
|
'patient_name': fields.Char("Patient Name", function="_get_patient_name", store=True, search=True),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def _get_patient_name(self, ids, context={}):
|
||||||
|
res={}
|
||||||
|
for obj in self.browse(ids):
|
||||||
|
patient=obj.patient_id
|
||||||
|
res[obj.id]=patient.name
|
||||||
|
return res
|
||||||
|
|
||||||
def _get_number(self,context={}):
|
def _get_number(self,context={}):
|
||||||
while 1:
|
while 1:
|
||||||
seq_id=get_model("sequence").find_sequence(type="clinic_hdcase",context=context)
|
seq_id=get_model("sequence").find_sequence(type="clinic_hdcase",context=context)
|
||||||
|
|
|
@ -1,17 +1,179 @@
|
||||||
import time
|
import time
|
||||||
|
from datetime import datetime
|
||||||
|
from calendar import monthrange
|
||||||
|
|
||||||
from netforce.model import Model, fields
|
from netforce.model import Model, fields, get_model
|
||||||
|
from netforce.access import get_active_user, set_active_user
|
||||||
|
|
||||||
|
from . import utils
|
||||||
|
|
||||||
class PatientMove(Model):
|
class PatientMove(Model):
|
||||||
_name="clinic.patient.move"
|
_name="clinic.patient.move"
|
||||||
|
|
||||||
|
def get_all(self, ids, context={}):
|
||||||
|
res={}
|
||||||
|
for obj in self.browse(ids):
|
||||||
|
res[obj.id]={
|
||||||
|
'date_move': obj.date.split(" ")[0],
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
|
||||||
|
|
||||||
_fields={
|
_fields={
|
||||||
'patient_id': fields.Many2One('clinic.patient','Patient'),
|
'patient_id': fields.Many2One('clinic.patient','Patient',search=True),
|
||||||
'date': fields.DateTime("Date"),
|
'date': fields.DateTime("Date", required=True,search=True),
|
||||||
'location_id': fields.Many2One("clinic.department","Department"),
|
'date_move': fields.Date("Date Move", function="get_all", function_multi=True, store=True),
|
||||||
|
'location_from_id': fields.Many2One("clinic.department","Location From",search=True),
|
||||||
|
'location_to_id': fields.Many2One("clinic.department","Location To",search=True),
|
||||||
|
"state": fields.Selection([['normal','Normal'],['new','New'],['dispose','Dispose']], "State"),
|
||||||
|
'note': fields.Text("Note",search=True),
|
||||||
}
|
}
|
||||||
|
|
||||||
_defaults={
|
_defaults={
|
||||||
'date': lambda *a: time.strftime("%Y-%m-%d %H:%M:%S"),
|
'date': lambda *a: time.strftime("%Y-%m-%d %H:%M:%S"),
|
||||||
|
'state': 'normal',
|
||||||
}
|
}
|
||||||
|
|
||||||
PatientMove()
|
def get_data(self, date, department_id, context={}):
|
||||||
|
if not date:
|
||||||
|
raise Exception("Missing date!")
|
||||||
|
y,m,d=date.split("-")
|
||||||
|
y=int(y)
|
||||||
|
m=int(m)
|
||||||
|
weekday, day_month=monthrange(y, m)
|
||||||
|
|
||||||
|
cond1=[
|
||||||
|
['date','>=','%s-%s-01 00:00:00'%(y,str(m).zfill(2))],
|
||||||
|
['date','<=','%s-%s-%s 23:59:59'%(y,str(m).zfill(2),day_month)],
|
||||||
|
['location_to_id','=', department_id],
|
||||||
|
]
|
||||||
|
cond=cond1+[['state','=','normal']]
|
||||||
|
ids=self.search(cond)
|
||||||
|
prev_month=len(ids)
|
||||||
|
|
||||||
|
cond=cond1+[['state','=','new']]
|
||||||
|
ids=self.search(cond)
|
||||||
|
current_month=len(ids)
|
||||||
|
current_items=[]
|
||||||
|
for index, val in enumerate(self.read(ids)):
|
||||||
|
val['no']=index+1
|
||||||
|
current_items.append(val)
|
||||||
|
|
||||||
|
|
||||||
|
cond=cond1+[['state','=','dispose']]
|
||||||
|
ids=self.search(cond)
|
||||||
|
dispose_month=len(ids)
|
||||||
|
dispose_items=[]
|
||||||
|
for index, val in enumerate(self.read(ids)):
|
||||||
|
val['no']=index+1
|
||||||
|
dispose_items.append(val)
|
||||||
|
|
||||||
|
next_month=prev_month+current_month-dispose_month
|
||||||
|
|
||||||
|
prev_m=m-1
|
||||||
|
if prev_m <= 0:
|
||||||
|
prev_m=1
|
||||||
|
next_m=m+1
|
||||||
|
if next_m > 12:
|
||||||
|
next_m=1
|
||||||
|
|
||||||
|
prev_month_thai=utils.MONTHS['th_TH'][prev_m]
|
||||||
|
current_month_thai=utils.MONTHS['th_TH'][m]
|
||||||
|
dispose_month_thai=utils.MONTHS['th_TH'][m]
|
||||||
|
next_month_thai=utils.MONTHS['th_TH'][next_m]
|
||||||
|
|
||||||
|
res={
|
||||||
|
'prev_month': prev_month,
|
||||||
|
'prev_month_thai': prev_month_thai,
|
||||||
|
|
||||||
|
'current_month': current_month,
|
||||||
|
'current_month_thai': current_month_thai,
|
||||||
|
'current_items': current_items,
|
||||||
|
|
||||||
|
'dispose_month': dispose_month,
|
||||||
|
'dispose_month_thai': dispose_month_thai,
|
||||||
|
'dispose_items': dispose_items,
|
||||||
|
|
||||||
|
'next_month': next_month,
|
||||||
|
'next_month_thai': next_month_thai,
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
|
||||||
|
def auto_get_data(self, context={}):
|
||||||
|
user_id=get_active_user()
|
||||||
|
set_active_user(1)
|
||||||
|
|
||||||
|
date=context.get("date")
|
||||||
|
if not date:
|
||||||
|
raise Exception("Missing date!")
|
||||||
|
y,m,d=date.split("-")
|
||||||
|
weekday, day_month=monthrange(int(y), int(m))
|
||||||
|
cond=[
|
||||||
|
['date','>=','%s-%s-01 00:00:00'%(y,m)],
|
||||||
|
['date','<=','%s-%s-%s 23:59:59'%(y,m,day_month)],
|
||||||
|
]
|
||||||
|
res=self.search(cond)
|
||||||
|
|
||||||
|
# copy data from previous month
|
||||||
|
if not res:
|
||||||
|
y=int(y)
|
||||||
|
m=int(m)-1
|
||||||
|
if m<=0:
|
||||||
|
m=1
|
||||||
|
y-=1
|
||||||
|
|
||||||
|
weekday, day_month=monthrange(int(y), int(m))
|
||||||
|
cond=[
|
||||||
|
['date','>=','%s-%s-01 00:00:00'%(y,m)],
|
||||||
|
['date','<=','%s-%s-%s 23:59:59'%(y,m,day_month)],
|
||||||
|
]
|
||||||
|
res=self.search_browse(cond)
|
||||||
|
for obj in res:
|
||||||
|
if obj.state=='dispose':
|
||||||
|
continue
|
||||||
|
vals={
|
||||||
|
'location_from_id': obj.location_from_id.id,
|
||||||
|
'location_to_id': obj.location_to_id.id,
|
||||||
|
'patient_id': obj.patient_id.id,
|
||||||
|
'date': date,
|
||||||
|
}
|
||||||
|
self.create(vals)
|
||||||
|
# copy from patient
|
||||||
|
if not res:
|
||||||
|
cond=[
|
||||||
|
['walkin','=','no'],
|
||||||
|
['dispose','=',False],
|
||||||
|
]
|
||||||
|
locations={
|
||||||
|
'LS-FL1': 1,
|
||||||
|
'LS-FL2': 2,
|
||||||
|
'LS-FL3': 3,
|
||||||
|
'SS-FL3': 4,
|
||||||
|
'SS-FL4': 5,
|
||||||
|
}
|
||||||
|
for obj in get_model("clinic.patient").search_browse(cond):
|
||||||
|
if not obj.location:
|
||||||
|
continue
|
||||||
|
locs=obj.location.split(",")
|
||||||
|
vals={
|
||||||
|
'location_from_id': locations[locs[0]], #first
|
||||||
|
'location_to_id': locations[locs[-1]], #last
|
||||||
|
'patient_id': obj.id,
|
||||||
|
'note': obj.note,
|
||||||
|
'date': date,
|
||||||
|
}
|
||||||
|
self.create(vals)
|
||||||
|
|
||||||
|
set_active_user(user_id)
|
||||||
|
|
||||||
|
def create(self, vals, **kw):
|
||||||
|
new_id=super().create(vals,**kw)
|
||||||
|
self.function_store([new_id])
|
||||||
|
return new_id
|
||||||
|
|
||||||
|
def write(self, ids, vals, **kw):
|
||||||
|
super().write(ids, vals, **kw)
|
||||||
|
self.function_store(ids)
|
||||||
|
|
||||||
|
|
||||||
|
PatientMove.register()
|
||||||
|
|
|
@ -0,0 +1,95 @@
|
||||||
|
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 ReportHDCaseSummaryV2(Model):
|
||||||
|
_name="report.hdcase.summary"
|
||||||
|
_trasient=True
|
||||||
|
|
||||||
|
_fields={
|
||||||
|
"month": fields.Date("Month"),
|
||||||
|
"branch_id": fields.Many2One("clinic.branch","Branch"),
|
||||||
|
"department_id": fields.Many2One("clinic.department","Department"),
|
||||||
|
}
|
||||||
|
|
||||||
|
def default_get(self,field_names=None,context={},**kw):
|
||||||
|
vals={
|
||||||
|
"month": time.strftime("%Y-%m-%d"),
|
||||||
|
}
|
||||||
|
select_dpt=get_model('select.company').get_select()
|
||||||
|
if select_dpt:
|
||||||
|
vals.update({
|
||||||
|
"branch_id": select_dpt['branch_id'],
|
||||||
|
"department_id": select_dpt['department_id'],
|
||||||
|
})
|
||||||
|
return vals
|
||||||
|
|
||||||
|
def get_report_data(self, ids, context={}):
|
||||||
|
defaults=self.default_get(context=context)
|
||||||
|
|
||||||
|
month=defaults.get("month")
|
||||||
|
|
||||||
|
|
||||||
|
y,m,d=month.split("-")
|
||||||
|
|
||||||
|
branch_id=defaults.get("branch_id")
|
||||||
|
department_id=defaults.get("department_id")
|
||||||
|
|
||||||
|
if ids:
|
||||||
|
obj=self.browse(ids)[0]
|
||||||
|
branch_id=obj.branch_id.id
|
||||||
|
department_id=obj.department_id.id
|
||||||
|
month=obj.month
|
||||||
|
y,m,d=month.split("-")
|
||||||
|
|
||||||
|
#auto gen at the fist time of that month
|
||||||
|
get_model("clinic.patient.move").auto_get_data(context={'date': month})
|
||||||
|
|
||||||
|
crr_month=m
|
||||||
|
weekday, total_day=monthrange(int(y), int(m))
|
||||||
|
date_from="-".join([y,m,"01"])
|
||||||
|
date_to="-".join([y,m,str(total_day)])
|
||||||
|
|
||||||
|
cond=[
|
||||||
|
['date','>=',date_from],
|
||||||
|
['date','<=',date_to],
|
||||||
|
['state','in',["waiting_payment","paid"]],
|
||||||
|
|
||||||
|
]
|
||||||
|
#if branch_id:
|
||||||
|
#cond.append([
|
||||||
|
#'branch_id','=',branch_id,
|
||||||
|
#])
|
||||||
|
if department_id:
|
||||||
|
cond.append([
|
||||||
|
'department_id','=',department_id,
|
||||||
|
])
|
||||||
|
|
||||||
|
hdcase_ids=get_model("clinic.hd.case").search(cond)
|
||||||
|
|
||||||
|
company_id=get_active_company()
|
||||||
|
company=get_model("company").browse(company_id)
|
||||||
|
department=get_model("clinic.department").browse(department_id)
|
||||||
|
|
||||||
|
year_thai=utils.date2thai(month, lang='th_TH').split("-")[0]
|
||||||
|
month_thai=utils.MONTHS['th_TH'][int(crr_month)]
|
||||||
|
|
||||||
|
data={
|
||||||
|
'company_name': company.name,
|
||||||
|
'department_name': department.name,
|
||||||
|
'month_thai': month_thai,
|
||||||
|
'year_thai': year_thai,
|
||||||
|
'total_hdcase': len(hdcase_ids),
|
||||||
|
}
|
||||||
|
data2=get_model("clinic.patient.move").get_data(date=month, department_id=department_id)
|
||||||
|
data.update(data2)
|
||||||
|
|
||||||
|
from pprint import pprint
|
||||||
|
pprint(data)
|
||||||
|
return data
|
||||||
|
|
||||||
|
ReportHDCaseSummaryV2.register()
|
|
@ -62,10 +62,18 @@ class Shop(Model):
|
||||||
'hd_case_call': fields.Boolean("HD Case Call"),
|
'hd_case_call': fields.Boolean("HD Case Call"),
|
||||||
'note': fields.Text("Note"),
|
'note': fields.Text("Note"),
|
||||||
"payment_lines": fields.One2Many("clinic.shop.payment","shop_id","Payment Lines"),
|
"payment_lines": fields.One2Many("clinic.shop.payment","shop_id","Payment Lines"),
|
||||||
|
'patient_name': fields.Char("Patient Name", function="_get_patient_name", store=True, search=True),
|
||||||
}
|
}
|
||||||
|
|
||||||
_order="date desc"
|
_order="date desc"
|
||||||
|
|
||||||
|
def _get_patient_name(self, ids, context={}):
|
||||||
|
res={}
|
||||||
|
for obj in self.browse(ids):
|
||||||
|
patient=obj.patient_id
|
||||||
|
res[obj.id]=patient.name
|
||||||
|
return res
|
||||||
|
|
||||||
def _get_related(self,context={}):
|
def _get_related(self,context={}):
|
||||||
related_id=None
|
related_id=None
|
||||||
if context.get('refer_id'):
|
if context.get('refer_id'):
|
||||||
|
|
|
@ -54,8 +54,16 @@ class Visit(Model):
|
||||||
'note': fields.Text('Note'),
|
'note': fields.Text('Note'),
|
||||||
'branch_id': fields.Many2One("clinic.branch","Branch"),
|
'branch_id': fields.Many2One("clinic.branch","Branch"),
|
||||||
'manual': fields.Boolean("Manual Tempolary Visit"),
|
'manual': fields.Boolean("Manual Tempolary Visit"),
|
||||||
|
'patient_name': fields.Char("Patient Name", function="_get_patient_name", store=True, search=True),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def _get_patient_name(self, ids, context={}):
|
||||||
|
res={}
|
||||||
|
for obj in self.browse(ids):
|
||||||
|
patient=obj.patient_id
|
||||||
|
res[obj.id]=patient.name
|
||||||
|
return res
|
||||||
|
|
||||||
def _get_number(self,context={}):
|
def _get_number(self,context={}):
|
||||||
while 1:
|
while 1:
|
||||||
seq_type='clinic_visit'
|
seq_type='clinic_visit'
|
||||||
|
|
Binary file not shown.
|
@ -0,0 +1,86 @@
|
||||||
|
<style>
|
||||||
|
.text-right{
|
||||||
|
text-align: right,
|
||||||
|
}
|
||||||
|
.text-center{
|
||||||
|
text-align: center,
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
||||||
|
<center>
|
||||||
|
<h2>
|
||||||
|
HDCase Summary (V2)
|
||||||
|
</h2>
|
||||||
|
<h3>
|
||||||
|
{{company_name}}
|
||||||
|
<span> {{department_name}} </span>
|
||||||
|
</h3>
|
||||||
|
<h4>
|
||||||
|
ประจำเดือน {{month_thai}} {{year_thai}}
|
||||||
|
</h4>
|
||||||
|
</center>
|
||||||
|
|
||||||
|
<table class="table table-hover">
|
||||||
|
<thead>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>จำนวนครั้งการทำ Hemodialysis</td><td>{{month_thai}}</td><td>เท่ากับ</td><td class="text-right">{{total_hdcase}}</td><td class="text-center">ครั้ง</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>จำนวนผู้ป่วยยกมาจากเดือน</td><td>{{prev_month_thai}}</td><td>เท่ากับ</td><td class="text-right">{{prev_month}}</td><td class="text-center">ครั้ง</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>จำนวนผู้ป่วยรับใหม่เดือน</td><td>{{current_month_thai}}</td><td>เท่ากับ</td><td class="text-right">{{current_month}}</td><td class="text-center">ครั้ง</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>จำนวนผู้ป่วยจำหน่ายเดือน</td><td>{{dispose_month_thai}}</td><td>เท่ากับ</td><td class="text-right">{{dispose_month}}</td><td class="text-center">ครั้ง</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>จำนวนผู้ป่วยยกไปเดือน</td><td>{{next_month_thai}}</td><td>เท่ากับ</td><td class="text-right">{{next_month}}</td><td class="text-center">ครั้ง</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
<tfoot>
|
||||||
|
</tfoot>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<h4 style="text-align:center;text-decoration: underline">รายชื่อผู้ป่วยรับใหม่</h4>
|
||||||
|
<table class="table table-hover">
|
||||||
|
<thead>
|
||||||
|
<th>No.</th>
|
||||||
|
<th>วันที่</th>
|
||||||
|
<th>ชื่อ</th>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{{#each current_items}}
|
||||||
|
<tr>
|
||||||
|
<td>{{no}}</td>
|
||||||
|
<td>{{date_move}}</td>
|
||||||
|
<td>{{patient_id.1.}}</td>
|
||||||
|
</tr>
|
||||||
|
{{/each}}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<h4 style="text-align:center;text-decoration: underline">รายชื่อผู้ป่วยจำหน่าย</h4>
|
||||||
|
<table class="table table-hover">
|
||||||
|
<thead>
|
||||||
|
<th>No.</th>
|
||||||
|
<th>วันที่</th>
|
||||||
|
<th>ชื่อ</th>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{{#each dispose_items}}
|
||||||
|
<tr>
|
||||||
|
<td>{{no}}</td>
|
||||||
|
<td>{{date_move}}</td>
|
||||||
|
<td>{{patient_id.1.}}</td>
|
||||||
|
</tr>
|
||||||
|
{{/each}}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
Loading…
Reference in New Issue