Merge remote-tracking branch 'origin/paully' into dev_sa

dev_sa
saharat.i@netforce.co.th 2017-11-23 11:30:23 +07:00
commit c4dc2071a2
13 changed files with 315 additions and 7 deletions

View File

@ -0,0 +1,11 @@
<action>
<field name="string">Patient Moves</field>
<field name="view_cls">multi_view</field>
<field name="model">clinic.patient.move</field>
<field name="tabs">[
["All",[[]]],
["In",[["type","=","in"]]],
["Out",[["type","=","out"]]]]
</field>
<field name="menu">clinic_menu</field>
</action>

View File

@ -0,0 +1,9 @@
<action>
<field name="string">HD Case Summary (Revise)</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>

View File

@ -42,6 +42,7 @@
<item string="Sickbed" action="clinic_sickbed"/>
</item>
<item string="Reports" perm="clinic_report">
<item string="HD Case Summary (Revise)" action="report_hdcase_summary"/>
<item string="Report Cycle Setting" action="clinic_report_cycle_setting"/>
<item string="Cycle Item Summary" action="clinic_report_cycle_item"/>
<item string="HD Case Summary" action="clinic_report_hd_case_summary"/>

View File

@ -133,6 +133,7 @@
</tabs>
<related>
<field name="addresses"/>
<field name="moves"/>
<field name="visits" readonly="1"/>
<field name="hd_cases" readonly="1"/>
<field name="dialyzers" readonly="1"/>

View File

@ -0,0 +1,7 @@
<form model="clinic.patient.move">
<field name="date"/>
<field name="patient_id"/>
<field name="type"/>
<field name="patient_name"/>
<field name="patient_type"/>
</form>

View File

@ -0,0 +1,7 @@
<list model="clinic.patient.move">
<field name="date"/>
<field name="patient_id"/>
<field name="type"/>
<field name="patient_name"/>
<field name="patient_type"/>
</list>

View File

@ -0,0 +1,8 @@
<form model="report.hdcase.summary">
<field name="date" span="2" mode="month" onchange="onchange_date"/>
<field name="date_from" span="2"/>
<field name="date_to" span="2"/>
<field name="hdcase_type" required="1" span="2"/>
<field name="branch_id" onchange="onchange_branch" span="2"/>
<field name="department_id" domain='[["branch_id","=",branch_id]]' span="2"/>
</form>

View File

@ -149,3 +149,7 @@ from . import create_invoice_payment
from . import report_stock_card
from . import report_receipt_summary
from . import report_wizard_labor_cost
#revise
from . import patient_move
from . import report_hdcase_summary

View File

@ -178,6 +178,7 @@ class Patient(Model):
'location': fields.Char("Share Department"), #to filter
'cw_time': fields.DateTime("Cycle Updated"),
'cw_uid': fields.Many2One("base.user"," Cycle Edit"),
"moves": fields.One2Many("clinic.patient.move","patient_id","Moves"),
}
def _get_number(self,context={}):
@ -327,6 +328,8 @@ class Patient(Model):
obj.write({
'partner_id': partner_id,
})
#TODO create patient.move
return obj_id
def delete(self,ids,context={}):

View File

@ -1,17 +1,21 @@
import time
from netforce.model import Model, fields
from netforce.model import Model, fields, get_model
class PatientMove(Model):
_name="clinic.patient.move"
_name='clinic.patient.move'
_fields={
'patient_id': fields.Many2One('clinic.patient','Patient'),
'date': fields.DateTime("Date"),
'location_id': fields.Many2One("clinic.department","Department"),
'patient_id': fields.Many2One("clinic.patient", "Patient", required=True, on_delete="cascade"),
"date": fields.DateTime("Date"),
"patient_name": fields.Char("Patient Name"),
"patient_type": fields.Char("Patient Type"), #ปกส. ....
"type": fields.Selection([['in','In'],['out','Out']], 'Type', required=True),
}
_defaults={
'date': lambda *a: time.strftime("%Y-%m-%d %H:%M:%S"),
}
PatientMove()
PatientMove.register()

View File

@ -0,0 +1,101 @@
import time
import urllib.parse as urllib
from datetime import datetime
from calendar import monthrange
from netforce.model import Model, fields, get_model
from netforce.access import get_active_company, get_active_user
from . import utils
class ReportHDCaseSummary(Model):
_name="report.hdcase.summary"
_string="Report HDCase Summary"
_transient=True
_fields={
"date": fields.Date("Month", required=True),
"date_from": fields.Date("From", required=True),
"date_to": fields.Date("To", required=True),
'branch_id': fields.Many2One("clinic.branch","Branch"),
'department_id': fields.Many2One("clinic.department","Departments"),
'hdcase_type': fields.Selection([['completed','Completed'],['not_completed','Not Completed']],"HDCase Type"),
}
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)
def _get_branch(self,context={}):
res=get_model('select.company').get_select()
if res:
return res['branch_id']
def _get_department(self,context={}):
res=get_model('select.company').get_select()
if res:
if res.get("department_ids"):
return res['department_ids'][0]
else:
return res['department_id']
_defaults={
'date': lambda *a: time.strftime("%Y-%m-%d"),
'date_from': _get_date_from,
'date_to': _get_date_to,
'branch_id': _get_branch,
'department_id': _get_department,
'hdcase_type': 'completed',
}
def get_report_data(self,ids,context={}):
company_id=get_active_company()
company=get_model("company").browse(company_id)
date=datetime.now().strftime("%Y-%m-%d")
year=int(date[0:4])
crr_month=int(date[5:7])
weekday, crr_total_day=monthrange(year, crr_month)
defaults=self.default_get(context=context)
date_from=defaults.get('date_from',date)
date_to=defaults.get('date_to',date)
branch_id=defaults.get("branch_id",None)
department_id=defaults.get("department_id",None)
hdcase_type=defaults.get('hdcase_type','completed')
#TODO get data from clinic.patient.move
#DO SOME STAFF
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
def onchange_branch(self,context={}):
data=context['data']
data['department_id']=None
return data
def run_report(self,ids,context={}):
return {
'next': {
'name': 'clinic_print_hd_case_summary',
'refer_id': ids[0],
'action_options': 'convert=pdf',
}
}
def export_pdf(self,ids,context={}):
raise Exception("TODO")
return
ReportHDCaseSummary.register()

View File

@ -0,0 +1,152 @@
<center>
<h2>
{{title}}
</h2>
<h3>
{{parent_company_name}}&nbsp;{{company_name}}<br/>
</h3>
<h4>
From {{date_from}} To {{date_to}}
</h4>
</center>
<table class="table">
<thead class="scroll-header">
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
</thead>
<tbody>
{{#each lines}}
<tr>
<td>{{topic}}</td>
<td>{{month}}</td>
<td>เท่ากับ</td>
{{#ifeq qty '0'}}
<td></td>
{{else}}
<td style="text-align:right;width:5%">
<a href='/ui#name={{link}}' target="_blank">{{qty}}</a>
</td>
{{/ifeq}}
<td style="text-align:center">{{unit}}</td>
</tr>
{{/each}}
</tbody>
</table>
<table class="table">
<thead>
<th>
<center>
<a href="/ui#name=clinic_report_recent_patient&defaults.date={{date}}&defaults.date_from={{date_from}}&defaults.date_to={{date_to}}&defaults.branch_id={{branch_id}}&defaults.department_id={{department_id}}">
รายชื่อผู้ป่วยรับใหม่
</a>
</center>
</th>
<th>
<center>
<a href="/ui#name=clinic_report_discontinue_patient&defaults.date={{date}}&defaults.date_from={{date_from}}&defaults.date_to={{date_to}}&defaults.branch_id={{branch_id}}&defaults.department_id={{department_id}}">
รายชื่อผู้ป่วยจำหน่าย
</a>
</center>
</th>
</thead>
<tr>
<td>
<table class="table">
<thead>
<th>#</th>
<th>วันที่</th>
<th>ชื่อ</th>
</thead>
<tbody>
{{#if recent_patients}}
{{#each recent_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>
</tr>
{{/each}}
{{else}}
<tr>
<td colspan="3">
No items to display.
</td>
</tr>
{{/if}}
</tbody>
<tfoot>
</tfoot>
</table>
</td>
<td style="width:50%">
<table class="table">
<thead>
<th>#</th>
<th>วันที่</th>
<th>ชื่อ</th>
</thead>
<tbody>
{{#if resign_patients}}
{{#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>
</tr>
{{/each}}
{{else}}
<tr>
<td colspan="3">
No items to display.
</td>
</tr>
{{/if}}
</tbody>
<tfoot>
</tfoot>
</table>
</td>
</tr>
<tr>
<td colspan="2">
<span>
<center>
<b>
<a href="/ui#name=clinic_report_medical_summary&defaults.date={{date}}&defaults.date_from={{date_from}}&defaults.date_to={{date_to}}&defaults.branch_id={{branch_id}}&defaults.department_id={{department_id}}&defaults.report_type={{report_type}}">รวมจำนวนยาที่ใช้ประจำเดือน</a>
</b>
</center>
</span>
<table class="table table-bordered">
<thead>
{{#each titles}}
<th>{{name}}</th>
{{/each}}
</thead>
<tbody>
{{#each medicals}}
<tr>
<td style="width:20%;">
<a href="/ui#name=product&active_id={{prod_id}}&mode=form"> {{prod_name}} </a>
</td>
{{#each sub_lines}}
<td style="text-align:center">
<a href="/ui#name=clinic_report_medical_detail&defaults.date_from={{time_start}}&defaults.date_to={{time_stop}}&defaults.types={{types}}&defaults.product_id={{product_id}}&defaults.product_categ_id={{product_categ_id}}&defaults.report_type={{../../report_type}}">{{qty}} </a>
</td>
{{/each}}
</tr>
{{/each}}
</tbody>
<tfoot>
</tfoot>
</table>
</td>
</tr>
</table>