conv_bal
watcha.h 2014-11-25 17:26:10 +07:00
parent 4440a5a312
commit c1e2142629
33 changed files with 301 additions and 245 deletions

View File

@ -2,6 +2,6 @@
<field name="string">Patients</field> <field name="string">Patients</field>
<field name="view_cls">multi_view</field> <field name="view_cls">multi_view</field>
<field name="model">clinic.patient</field> <field name="model">clinic.patient</field>
<field name="tabs">[["All",[]],["Archived",[["active","=","False"]]],["Social Security",[["type","=","sc"]]],["NHSO(30฿)",[["type","=","nhso"]]],["Personal",[["type","=","personal"]]],["Others",[["type","=","others"]]]]</field> <field name="tabs">[["All",[]],["Archived",[["active","=","False"]]],["Social Security",[["type","=","sc"]]],["UC",[["type","=","uc"]]],["Others",[["type","=","others"]]]]</field>
<field name="menu">clinic_menu</field> <field name="menu">clinic_menu</field>
</action> </action>

View File

@ -1,8 +1,8 @@
<action> <action>
<field name="string">Visit Dialy</field> <field name="string">Visit Board</field>
<field name="view_cls">report</field> <field name="view_cls">report</field>
<field name="model">clinic.visit.dialy</field> <field name="model">clinic.visit.board</field>
<field name="report_template">visit_dialy</field> <field name="report_template">visit_board</field>
<field name="report_template_xls">visit_dialy</field> <field name="report_template_xls">visit_board</field>
<field name="menu">clinic_menu</field> <field name="menu">clinic_menu</field>
</action> </action>

View File

@ -1,6 +1,6 @@
<action> <action>
<field name="view_cls">form_view</field> <field name="view_cls">form_view</field>
<field name="model">clinic.import.payment</field> <field name="model">clinic.import.payment</field>
<field name="view_xml">import_clinic_nhso</field> <field name="view_xml">import_clinic_uc</field>
<field name="menu">account_menu</field> <field name="menu">account_menu</field>
</action> </action>

View File

@ -1,4 +1,4 @@
<form model="clinic.data.nhso"> <form model="clinic.data.uc">
<field name="name"/> <field name="name"/>
<field name="epostat"/> <field name="epostat"/>
<field name="hdrate"/> <field name="hdrate"/>

View File

@ -1,5 +1,4 @@
<!--<list model="clinic.data.nhso" colors='{"#9f9":[["type","=","success"]],"red":[["type","=","fail"]]}'>--> <list model="clinic.data.uc">
<list model="clinic.data.nhso">
<field name="name"/> <field name="name"/>
<field name="epostat"/> <field name="epostat"/>
<field name="hdrate"/> <field name="hdrate"/>

View File

@ -34,7 +34,7 @@
<item string="Schedules" action="clinic_schedule"/> <item string="Schedules" action="clinic_schedule"/>
<item string="Visits"> <item string="Visits">
<item string="Visits" action="clinic_visit"/> <item string="Visits" action="clinic_visit"/>
<item string="Visit Dialy" action="clinic_visit_dialy"/> <item string="Visit Board" action="clinic_visit_board"/>
<item string="Generate Visit" action="clinic_gen_visit_form"/> <item string="Generate Visit" action="clinic_gen_visit_form"/>
</item> </item>
<item string="HD Cases"> <item string="HD Cases">

View File

@ -4,12 +4,12 @@
<header string="IMPORT PAYMENT"/> <header string="IMPORT PAYMENT"/>
<!--<item string="Medical Government" action="import_clinic_mg"/>--> <!--<item string="Medical Government" action="import_clinic_mg"/>-->
<item string="Social Security" action="import_clinic_sc"/> <item string="Social Security" action="import_clinic_sc"/>
<item string="NHSO 30฿" action="import_clinic_nhso"/> <item string="UC" action="import_clinic_uc"/>
<divider/> <divider/>
<header string="IMPORT DATA"/> <header string="IMPORT DATA"/>
<!--<item string="Medical Government" action="clinic_import_payment"/>--> <!--<item string="Medical Government" action="clinic_import_payment"/>-->
<item string="Social Security" action="clinic_data_sc"/> <item string="Social Security" action="clinic_data_sc"/>
<item string="NHSO 30฿" action="clinic_data_nhso"/> <item string="UC" action="clinic_data_uc"/>
</item> </item>
</item> </item>
</inherit> </inherit>

View File

@ -1,6 +1,7 @@
<list model="clinic.personal"> <list model="clinic.personal">
<field name="number"/> <field name="number"/>
<field name="name"/> <field name="name"/>
<field name="level_id"/>
<field name="categ_id"/> <field name="categ_id"/>
<field name="type"/> <field name="type"/>
<field name="state"/> <field name="state"/>

View File

@ -1,4 +1,5 @@
<form model="clinic.visit.dialy"> <form model="clinic.visit.board">
<field name="date_from" span="2"/> <field name="date_from" span="2"/>
<field name="date_to" span="2"/> <field name="date_to" span="2"/>
<field name="patient_id" span="2"/>
</form> </form>

View File

@ -1,12 +1,10 @@
<inherit model="settings" inherit="fin_settings"> <inherit model="settings" inherit="fin_settings">
<field name="retained_earnings_account_id" position="after"> <field name="retained_earnings_account_id" position="after">
<separator string="Clinic"/> <separator string="Clinic"/>
<field name="ar_mg_id"/>
<field name="ap_mg_id"/>
<field name="ar_sc_id"/> <field name="ar_sc_id"/>
<field name="ap_sc_id"/> <field name="ap_sc_id"/>
<field name="ar_nhso_id"/> <field name="ar_uc_id"/>
<field name="ap_nhso_id"/> <field name="ap_uc_id"/>
<field name="ap_nurse_id"/> <field name="ap_nurse_id"/>
<field name="ap_doctor_id"/> <field name="ap_doctor_id"/>
<field name="hospital_code"/> <field name="hospital_code"/>

View File

@ -1,12 +0,0 @@
<form title="Import Medical Government">
<group span="6" columns="1">
<field name="file"/>
</group>
<group span="6" columns="1">
<separator string="Result"/>
<field name="result" nolabel="1" height="240" width="540"/>
</group>
<foot replace="1">
<button string="Import Data" method="import_nhso" type="primary" icon="arrow-right"/>
</foot>
</form>

View File

@ -1,13 +0,0 @@
<form title="Import NHSO">
<group span="6" columns="1">
<field name="file"/>
</group>
<group span="6" columns="1">
<!--<separator string="Result"/>-->
<!--<field name="result" nolabel="1" height="240" width="540"/>-->
</group>
<foot replace="1">
<button string="Import Data" method="import_nhso" type="primary" icon="arrow-right"/>
<!--<button string="Post" method="post" type="success"/>-->
</foot>
</form>

View File

@ -0,0 +1,10 @@
<form title="Import UC">
<group span="6" columns="1">
<field name="file"/>
</group>
<group span="6" columns="1">
</group>
<foot replace="1">
<button string="Import Data" method="import_uc" type="primary" icon="arrow-right"/>
</foot>
</form>

View File

@ -16,7 +16,7 @@ from . import patient_comorbidity
from . import patient_morbidity from . import patient_morbidity
from . import race from . import race
from . import visit from . import visit
from . import visit_dialy from . import visit_board
from . import hd_case from . import hd_case
from . import hd_case_line from . import hd_case_line
from . import hd_case_personal from . import hd_case_personal
@ -37,8 +37,7 @@ from . import cycle_dialy_line
from . import gen_visit from . import gen_visit
from . import gen_visit_line from . import gen_visit_line
from . import fin_setting from . import fin_setting
from . import import_data_mg from . import import_data_uc
from . import import_data_nhso
from . import import_data_sc from . import import_data_sc
from . import payment from . import payment
from . import account_payment from . import account_payment

View File

@ -3,11 +3,9 @@ from netforce.model import Model, fields
class Settings(Model): class Settings(Model):
_inherit="settings" _inherit="settings"
_fields={ _fields={
"ap_mg_id": fields.Many2One("account.account","Account Payment Medical Government"), "ap_uc_id": fields.Many2One("account.account","Account Payment UC"),
"ap_nhso_id": fields.Many2One("account.account","Account Payment NHSO 30B"),
"ap_sc_id": fields.Many2One("account.account","Account Payment Social Security"), "ap_sc_id": fields.Many2One("account.account","Account Payment Social Security"),
"ar_mg_id": fields.Many2One("account.account","Account Recieve Medical Government"), "ar_uc_id": fields.Many2One("account.account","Account Recieve UC"),
"ar_nhso_id": fields.Many2One("account.account","Account Recieve NHSO 30B"),
"ar_sc_id": fields.Many2One("account.account","Account Recieve Social Security"), "ar_sc_id": fields.Many2One("account.account","Account Recieve Social Security"),
"ap_nurse_id": fields.Many2One("account.account","Account Payment Nurse"), "ap_nurse_id": fields.Many2One("account.account","Account Payment Nurse"),
"ap_doctor_id": fields.Many2One("account.account","Account Payment Doctor"), "ap_doctor_id": fields.Many2One("account.account","Account Payment Doctor"),

View File

@ -34,7 +34,7 @@ class GenVisit(Model):
'doctor_id': fields.Many2One("clinic.personal","Doctor",domain=[['type','=','doctor']]), 'doctor_id': fields.Many2One("clinic.personal","Doctor",domain=[['type','=','doctor']]),
'department_id': fields.Many2One("clinic.department","Department"), 'department_id': fields.Many2One("clinic.department","Department"),
'duration': fields.Integer("Duration (hrs)", function="_get_duration"), 'duration': fields.Integer("Duration (hrs)", function="_get_duration"),
"patient_type": fields.Selection([("mg","Medical Government"),("sc","Social Security"),("nhso","NHSO (30฿)"),("personal","Personal"),("others","Others")],"Patient Type"), "patient_type": fields.Selection([("sc","Social Security"),("uc","UC."),("personal","Personal"),("others","Others")],"Patient Type"),
'patient_categ_id': fields.Many2One("clinic.patient.categ", "Patient Category"), 'patient_categ_id': fields.Many2One("clinic.patient.categ", "Patient Category"),
'nurse_categ_id': fields.Many2One("clinic.personal.categ", "Nurse Category", domain=[['type','=','nurse']]), 'nurse_categ_id': fields.Many2One("clinic.personal.categ", "Nurse Category", domain=[['type','=','nurse']]),
} }

View File

@ -358,8 +358,8 @@ class HDCase(Model):
account_id=setting.ar_mg_id.id account_id=setting.ar_mg_id.id
elif patient_type=='sc': elif patient_type=='sc':
account_id=setting.ar_sc_id.id account_id=setting.ar_sc_id.id
elif patient_type=='nhso': elif patient_type=='uc':
account_id=setting.ar_nhso_id.id account_id=setting.ar_uc.id
for fee_line in fee_lines: for fee_line in fee_lines:
fee_line['account_id']=account_id fee_line['account_id']=account_id

View File

@ -1,11 +0,0 @@
from netforce.model import Model, fields
class ImportDataMG(Model):
_name="clinic.data.mg"
_transient=True
_fields={
'name': fields.Char("Name"),
}
ImportDataMG.register()

View File

@ -1,7 +1,7 @@
from netforce.model import Model, fields from netforce.model import Model, fields
class ImportDataNHSO(Model): class ImportDataUC(Model):
_name="clinic.data.nhso" _name="clinic.data.uc"
_transient=True _transient=True
_fields={ _fields={
'name': fields.Char("Name"), 'name': fields.Char("Name"),
@ -23,4 +23,4 @@ class ImportDataNHSO(Model):
} }
ImportDataNHSO.register() ImportDataUC.register()

View File

@ -85,7 +85,7 @@ class ImportPayment(Model):
#titles=[title for title, value in lines[0].items()] #titles=[title for title, value in lines[0].items()]
return lines return lines
def import_nhso(self,ids,context={}): def import_uc(self,ids,context={}):
obj=self.browse(ids)[0] obj=self.browse(ids)[0]
fname=obj.file fname=obj.file
fpath=get_file_path(fname) fpath=get_file_path(fname)
@ -94,16 +94,16 @@ class ImportPayment(Model):
lines=self.read_xml(fpath,node='HDBills') lines=self.read_xml(fpath,node='HDBills')
if not lines: if not lines:
raise Exception("Wrong file") raise Exception("Wrong file")
data_nhso=get_model("clinic.data.nhso") data_uc=get_model("clinic.data.uc")
nhso_ids=data_nhso.search([]) uc_ids=data_uc.search([])
data_nhso.delete(nhso_ids) data_uc.delete(uc_ids)
result="" result=""
result+="Match: %s"%(50) result+="Match: %s"%(50)
result+="\n" result+="\n"
result+="*"*50 result+="*"*50
for line in lines: for line in lines:
# TODO need to check match or not # TODO need to check match or not
data_nhso.create(line) data_uc.create(line)
line['type']='success' line['type']='success'
print(line) print(line)
result+="\n" result+="\n"

View File

@ -4,10 +4,8 @@ from netforce.model import Model, fields, get_model
from netforce.access import get_active_company, get_active_user, set_active_user from netforce.access import get_active_company, get_active_user, set_active_user
PATIENT_TYPE={ PATIENT_TYPE={
"mg":"Medical Government",
"sc":"Social Security", "sc":"Social Security",
"nhso":"NHSO (30฿)", "uc":"UC",
"personal": "Personal",
"others": "Others", "others": "Others",
} }
@ -29,7 +27,7 @@ class Patient(Model):
return res # -> {1: 30, 2: 45,.....} return res # -> {1: 30, 2: 45,.....}
_fields={ _fields={
"type": fields.Selection([("sc","Social Security"),("nhso","NHSO (30฿)"),("personal","Personal"),("others","Others")],"Patient Type",required=True), "type": fields.Selection([("sc","Social Security"),("uc","UC"),("others","Others")],"Patient Type",required=True),
"number": fields.Char("Patient No.",required=True,search=True), "number": fields.Char("Patient No.",required=True,search=True),
"hn": fields.Char("REF/HN",search=True), "hn": fields.Char("REF/HN",search=True),
"name": fields.Char("Name",required=True,search=True), "name": fields.Char("Name",required=True,search=True),
@ -126,7 +124,7 @@ class Patient(Model):
if not categ_ids: if not categ_ids:
raise Exception("Category: %s not found"%categ_name) raise Exception("Category: %s not found"%categ_name)
partner_id=None partner_id=None
if patient_type in ("mg","sc","nhso"): if patient_type in ("mg","sc","uc"):
partner_obj=get_model("partner") partner_obj=get_model("partner")
for partner in partner_obj.search_browse([]): for partner in partner_obj.search_browse([]):
if partner.categ_id.id in categ_ids: if partner.categ_id.id in categ_ids:

View File

@ -149,13 +149,13 @@ class ReportHDCaseSummary(Model):
'action_options': 'mode=list&search_domain=%s&tab_no=2'%dom, 'action_options': 'mode=list&search_domain=%s&tab_no=2'%dom,
} }
# all patient who are nhso in hospital on select month # all patient who are uc in hospital on select month
dom=[] dom=[]
time_start='%s-%s-01'%(year,str(crr_month).zfill(2)) time_start='%s-%s-01'%(year,str(crr_month).zfill(2))
time_stop='%s-%s-%s'%(year,str(crr_month).zfill(2),crr_total_day) time_stop='%s-%s-%s'%(year,str(crr_month).zfill(2),crr_total_day)
dom.append(['reg_date','>=',time_start]) dom.append(['reg_date','>=',time_start])
dom.append(['reg_date','<=',time_stop]) dom.append(['reg_date','<=',time_stop])
dom.append(['type','=','nhso']) dom.append(['type','=','uc'])
npatients=get_model("clinic.patient").search(dom) npatients=get_model("clinic.patient").search(dom)
dom=replace_quote('%s'%dom) dom=replace_quote('%s'%dom)
items['topic7']={ items['topic7']={
@ -171,7 +171,7 @@ class ReportHDCaseSummary(Model):
time_stop='%s-%s-%s'%(year,str(crr_month).zfill(2),crr_total_day) time_stop='%s-%s-%s'%(year,str(crr_month).zfill(2),crr_total_day)
dom.append(['reg_date','>=',time_start]) dom.append(['reg_date','>=',time_start])
dom.append(['reg_date','<=',time_stop]) dom.append(['reg_date','<=',time_stop])
dom.append(['type','=','personal']) dom.append(['type','=','others'])
npatients=get_model("clinic.patient").search(dom) npatients=get_model("clinic.patient").search(dom)
dom=replace_quote('%s'%dom) dom=replace_quote('%s'%dom)
items['topic8']={ items['topic8']={
@ -197,8 +197,8 @@ class ReportHDCaseSummary(Model):
titles={ titles={
'prod_name': 'ชื่อยา', 'prod_name': 'ชื่อยา',
'sc': utils.PATIENT_TYPE['sc'], 'sc': utils.PATIENT_TYPE['sc'],
'nhso': utils.PATIENT_TYPE['nhso'], 'uc': utils.PATIENT_TYPE['uc'],
'personal': utils.PATIENT_TYPE['personal'], 'others': utils.PATIENT_TYPE['others'],
} }
medicals=get_model("clinic.report.medical.summary").get_report_data(ids=[],context=context)['lines'] medicals=get_model("clinic.report.medical.summary").get_report_data(ids=[],context=context)['lines']

View File

@ -57,7 +57,7 @@ class ReportMedicalSummary(Model):
products={} products={}
for prod in get_model("product").search_browse([['type','=','stock']]): for prod in get_model("product").search_browse([['type','=','stock']]):
products[prod.code]={} products[prod.code]={}
for patient_type in ('sc','nhso','personal'): for patient_type in ('sc','uc','others'):
products[prod.code][patient_type]={ products[prod.code][patient_type]={
'qty': 0, 'qty': 0,
'name': prod.name, 'name': prod.name,
@ -86,7 +86,7 @@ class ReportMedicalSummary(Model):
'prod_id': records[patient_type]['prod_id'], 'prod_id': records[patient_type]['prod_id'],
'total': 0, 'total': 0,
} }
for patient_type in ('sc','nhso','personal'): for patient_type in ('sc','uc','others'):
line.update({ line.update({
patient_type: records[patient_type]['qty'] or 0, patient_type: records[patient_type]['qty'] or 0,
}) })
@ -101,8 +101,8 @@ class ReportMedicalSummary(Model):
titles={ titles={
'prod_name': 'ชื่อยา', 'prod_name': 'ชื่อยา',
'sc': utils.PATIENT_TYPE['sc'], 'sc': utils.PATIENT_TYPE['sc'],
'nhso': utils.PATIENT_TYPE['nhso'], 'uc': utils.PATIENT_TYPE['uc'],
'personal': utils.PATIENT_TYPE['personal'], 'others': utils.PATIENT_TYPE['others'],
} }
year=int(year)+543 year=int(year)+543
data={ data={

View File

@ -1,17 +1,22 @@
DAYS={ 'th_TH': ['จันทร์', 'อังคาร', 'พุธ', 'พฤหัสบดี', 'ศุกร์', 'เสาร์', 'อาทิตย์'] from datetime import datetime
, 'en_US': ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
DAYS={
'th_TH': ['จันทร์', 'อังคาร', 'พุธ', 'พฤหัสบดี', 'ศุกร์', 'เสาร์', 'อาทิตย์'],
'th_TH2': ['จันทร์', 'อังคาร', 'พุธ', 'พฤหัสบดี', 'ศุกร์', 'เสาร์', 'อาทิตย์'],
'en_US': ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
} }
MONTHS={ 'th_TH': [None, 'มกราคม', 'กุมภาพันธ์', 'มีนาคม', 'เมษายน', 'พฤษภาคม', 'มิถุนายน', 'กรกฎาคม', 'สิงหาคม', 'กันยายน', 'ตุลาคม', 'พฤศจิกายน', 'ธันวาคม'] MONTHS={
, 'en_US': [None, 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'] 'th_TH': [None, 'มกราคม', 'กุมภาพันธ์', 'มีนาคม', 'เมษายน', 'พฤษภาคม', 'มิถุนายน', 'กรกฎาคม', 'สิงหาคม', 'กันยายน', 'ตุลาคม', 'พฤศจิกายน', 'ธันวาคม'],
'th_TH2': [None, 'ม.ค.', 'ก.พ.', 'มี.ค.', 'เม.ย.', 'พ.ค.', 'มิ.ย.', 'ก.ค.', 'ส.ค.', 'ก.ย.', 'ต.ค.', 'พ.ย.', 'ธ.ค.'],
'en_US': [None, 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
} }
PATIENT_TYPE={ PATIENT_TYPE={
"mg":"Medical Government",
"sc":"ปกส.", "sc":"ปกส.",
"nhso":"สปกส.", "uc":"uc.",
"personal": "จ่ายเอง", "others": "จ่ายเอง",
"others": "อื่นๆ",
} }
PERSONAL_TYPE={ PERSONAL_TYPE={
@ -30,3 +35,35 @@ TOPICS={
'topic7': {'name': 'จำนวนผู้ป่วยเบิก สปกส.', 'unit': 'คน'}, 'topic7': {'name': 'จำนวนผู้ป่วยเบิก สปกส.', 'unit': 'คน'},
'topic8': {'name': 'จำนวนผู้ป่วยจ่ายเอง', 'unit': 'คน'}, 'topic8': {'name': 'จำนวนผู้ป่วยจ่ายเอง', 'unit': 'คน'},
} }
def date2thai(date, format='%(BY)s-%(m)s-%(d)s', lang='th_TH'):
'''
>>> date2thai('2011-12-31', lang='th_TH')
'2554-12-31'
>>> date2thai('2011-12-31', format='%(Td)s %(d)s %(Tm)s, %(By)s', lang='en_US')
'Saturday 31 December, 54'
>>> print date2thai('2011-12-31', format='%(Td)s %(d)s %(Tm)s, %(By)s', lang='th_TH')
เสาร 31 นวาคม, 54
>>> date2thai('2000-06-08', lang='th_TH')
'2543-06-08'
>>> date2thai('2000-06-08', format='%(Td)s %(d)s %(Tm)s, %(By)s', lang='en_US')
'Thursday 08 June, 43'
>>> print date2thai('2000-06-08', format='%(Td)s %(d)s %(Tm)s, %(By)s', lang='th_TH')
พฤหสบด 08 นายน, 43
'''
if not date or not date.count('-') == 2:
return ''
year, month, day = date.split('-')
#dow = DateTime.Date(int(year), int(month), int(day)).day_of_week
dow = datetime(int(year),int(month),int(day)).weekday()
return format % { 'BY': int(year) + 543
, 'By': int(year[2:]) + 43
, 'Tm': MONTHS[lang][int(month)]
, 'Td': DAYS[lang][dow]
, 'm': month
, 'd': int(day) # XXX remove zero
}

View File

@ -155,9 +155,8 @@ class Visit(Model):
patient_type={ patient_type={
"mg":"Medical Government",
"sc":"Social Security", "sc":"Social Security",
"nhso":"NHSO (30฿)", "uc":"UC",
"personal": "Personal", "personal": "Personal",
"others": "Others", "others": "Others",
} }
@ -166,7 +165,7 @@ class Visit(Model):
if not categ_ids: if not categ_ids:
raise Exception("Partner Category: %s not found"%categ_name) raise Exception("Partner Category: %s not found"%categ_name)
partner_id=None partner_id=None
if obj.patient_id.type in ("mg","sc","nhso"): if obj.patient_id.type in ("mg","sc","uc"):
partner_obj=get_model("partner") partner_obj=get_model("partner")
for partner in partner_obj.search_browse([]): for partner in partner_obj.search_browse([]):
if partner.categ_id.id in categ_ids: if partner.categ_id.id in categ_ids:

View File

@ -0,0 +1,142 @@
import time
from datetime import datetime, timedelta
#from calendar import monthrange
from netforce.model import Model, fields, get_model
from netforce.access import get_active_company
from . import utils
DRT=5
class VisitBoard(Model):
_name="clinic.visit.board"
_string="Visit Board"
_transient=True
_fields={
"date_from": fields.Date("From", required=True),
"date_to": fields.Date("To", required=True),
'patient_id': fields.Many2One("clinic.patient","Patient"),
}
_defaults={
'date_from': lambda *a: time.strftime("%Y-%m-%d"),
'date_to': lambda *a: (datetime.now()+timedelta(days=DRT)).strftime("%Y-%m-%d"),
}
def get_report_data(self,ids,context={}):
company_id=get_active_company()
company=get_model("company").browse(company_id)
date_from=datetime.now().strftime("%Y-%m-%d")
date_to=(datetime.now()+timedelta(days=DRT)).strftime("%Y-%m-%d")
patient_id=None
if ids:
obj=self.browse(ids)[0]
date_from=obj.date_from
date_to=obj.date_to
patient_id=obj.patient_id.id
time_start='%s 00:00:00'%(date_from)
time_stop='%s 23:59:59'%(date_to)
dom=[]
dom.append(['time_start','>=','%s'%time_start])
dom.append(['time_stop','<=','%s'%time_stop])
if patient_id:
dom.append(['patient_id','=',patient_id])
lines=[]
empty_line={
'no': '',
'number': '',
'visit_id': None,
'cycle_name': '',
'cycle_color': '',
'patient_name': '',
'patient_type': '',
'doctor_name': '',
'hd_case_number': '',
'hd_case_id': None,
'success_color': '',
'date':'',
'title': True,
'details':'',
}
types={}
no=1
for visit in get_model("clinic.visit").search_browse(dom):
hd_case_id=None
hd_case_number=''
if visit.hd_cases:
hd_case=visit.hd_cases[0]
hd_case_id=hd_case.id,
hd_case_number=hd_case.number,
number=visit.number
if number=='/':
number='รอการรรักษา'
cycle=visit.cycle_id
patient=visit.patient_id
visit_date=visit.visit_date
visit_color=''
if visit.state=='confirmed':
visit_color='#99ff99'
elif visit.state=='cancelled':
visit_color='#D84B4B',
line={
'number': number,
'visit_id': visit.id,
'cycle_name': cycle.name,
'cycle_color': cycle.color,
'patient_name': patient.name,
'patient_type': utils.PATIENT_TYPE.get(patient.type,''),
'doctor_name': visit.doctor_id.name,
'hd_case_number': hd_case_number,
'hd_case_id': hd_case_id,
'visit_color': visit_color,
'date': visit_date,
'title': False,
'details':'',
'no': no,
}
lines.append(line)
no+=1
if not types.get(visit_date):
ptype={}
[ptype.setdefault(t,0) for t in utils.PATIENT_TYPE.keys()]
types[visit_date]=ptype
types[visit_date][patient.type]+=1
dates=[]
index=0
for line in lines:
date=line['date']
if date not in dates:
line=empty_line.copy()
total_qty=0
for qty in types[date].values():
total_qty+=qty
line['cycle_name']=utils.date2thai(date,format='%(Td)s %(d)s %(Tm)s',lang="th_TH2"),
line['details']='รวม %s: %s'%(total_qty,', '.join('%s %s'%(utils.PATIENT_TYPE[k],v) for k,v in types[date].items()))
lines.insert(index,line)
dates.append(date)
index+=1
has_duration=False
if date_from != date_to:
has_duration=True
data={
'lines': lines,
'date': utils.date2thai(date_from,format='ประจำวัน%(Td)s ที่ %(d)s %(Tm)s %(BY)s'),
'company_name': company.name,
'company_parent_name': company.parent_id.name,
'has_duration': has_duration,
'date_from': utils.date2thai(date_from,format='%(d)s %(Tm)s %(By)s',lang="th_TH2"),
'date_to': utils.date2thai(date_to,format='%(d)s %(Tm)s %(By)s',lang="th_TH2"),
}
return data
VisitBoard.register()

View File

@ -1,102 +0,0 @@
import time
from datetime import datetime, timedelta
from calendar import monthrange
from netforce.model import Model, fields, get_model
from netforce.access import get_active_company
from . import utils
class VisitDialy(Model):
_name="clinic.visit.dialy"
_string="Visit Dialy"
_transient=True
_fields={
"date_from": fields.Date("From", required=True),
"date_to": fields.Date("To", required=True),
}
_defaults={
'date_from': lambda *a: time.strftime("%Y-%m-%d"),
'date_to': lambda *a: (datetime.now()+timedelta(days=7)).strftime("%Y-%m-%d"),
}
def get_report_data(self,ids,context={}):
company_id=get_active_company()
company=get_model("company").browse(company_id)
date_from=datetime.now().strftime("%Y-%m-%d")
date_to=(datetime.now()+timedelta(days=7)).strftime("%Y-%m-%d")
if ids:
obj=self.browse(ids)[0]
date_from=obj.date_from
date_to=obj.date_to
time_start='%s 00:00:00'%(date_from)
time_stop='%s 23:59:59'%(date_to)
month=int(date_from[5:7])
year=date_from[0:4]
day=date_from[8:10]
month_str=utils.MONTHS['th_TH'][month]
dom=[]
dom.append(['time_start','>=','%s'%time_start])
dom.append(['time_stop','<=','%s'%time_stop])
lines=[]
empty_line={
'number': '',
'visit_id': None,
'cycle_name': '',
'cycle_color': '',
'patient_name': '',
'doctor_name': '',
'hd_case_number': '',
'hd_case_id': None,
'success_color': '',
}
for obj in get_model("clinic.visit").search_browse(dom):
hd_case_id=None
hd_case_number=''
if obj.hd_cases:
hd_case=obj.hd_cases[0]
hd_case_id=hd_case.id,
hd_case_number=hd_case.number,
number=obj.number
if number=='/':
number='รอการรรักษา'
cycle=obj.cycle_id
line={
'number': number,
'visit_id': obj.id,
'cycle_name': cycle.name,
'cycle_color': cycle.color,
'patient_name': obj.patient_id.name,
'doctor_name': obj.doctor_id.name,
'hd_case_number': hd_case_number,
'hd_case_id': hd_case_id,
'success_color': obj.state=='confirmed' and '#99ff99' or ''
}
lines.append(line)
year=int(year)+543
date_str='%s %s %s'%(day,month_str,year)
has_duration=False
if date_from != date_to:
has_duration=True
data={
'lines': lines,
'date': date_str,
'company_name': company.name,
'company_parent_name': company.parent_id.name,
'has_duration': has_duration,
'date_from': date_from,
'date_to': date_to,
}
return data
VisitDialy.register()

View File

@ -136,8 +136,8 @@
<thead> <thead>
<th>{{prod_name}}</th> <th>{{prod_name}}</th>
<th>{{sc}}</th> <th>{{sc}}</th>
<th>{{nhso}}</th> <th>{{uc}}</th>
<th>{{personal}}</th> <th>{{others}}</th>
<th>รวม</th> <th>รวม</th>
</thead> </thead>
<tbody> <tbody>
@ -147,8 +147,8 @@
<a href="/ui#name=product&active_id={{prod_id}}&mode=form"> {{prod_name}} </a> <a href="/ui#name=product&active_id={{prod_id}}&mode=form"> {{prod_name}} </a>
</td> </td>
<td>{{sc}}</td> <td>{{sc}}</td>
<td>{{nhso}}</td> <td>{{uc}}</td>
<td>{{personal}}</td> <td>{{others}}</td>
<td>{{total}}</td> <td>{{total}}</td>
</tr> </tr>
{{/each}} {{/each}}

View File

@ -11,8 +11,8 @@
<thead> <thead>
<th>{{prod_name}}</th> <th>{{prod_name}}</th>
<th>{{sc}}</th> <th>{{sc}}</th>
<th>{{nhso}}</th> <th>{{uc}}</th>
<th>{{personal}}</th> <th>{{others}}</th>
<th>รวม</th> <th>รวม</th>
</thead> </thead>
<tbody> <tbody>
@ -22,8 +22,8 @@
<a href="/ui#name=product&active_id={{prod_id}}&mode=form"> {{prod_name}} </a> <a href="/ui#name=product&active_id={{prod_id}}&mode=form"> {{prod_name}} </a>
</td> </td>
<td>{{sc}}</td> <td>{{sc}}</td>
<td>{{nhso}}</td> <td>{{uc}}</td>
<td>{{personal}}</td> <td>{{others}}</td>
<td>{{total}}</td> <td>{{total}}</td>
</tr> </tr>
{{/each}} {{/each}}

View File

@ -0,0 +1,46 @@
<center>
<h2>ตารางนัดผู้ป่วย</h2>
<h3>
{{parent_company_name}}&nbsp;{{company_name}}<br/>
</h3>
<h4>
{{#if has_duration}}
ระหว่างวันที่ {{date_from}} ถึง {{date_to}}
{{else}}
{{date}}
{{/if}}
</h4>
</center>
<table class="table table-condensed table-striped">
<thead>
<th>รอบ</th>
<th>#</th>
<th>เลขที่อ้างอิง</th>
<th>ผู้ป่วย</th>
<th>สิทธ์</th>
<th>แพทย์</th>
<th>HD Case</th>
<th>หมายเหตุ</th>
</thead>
<tbody>
{{#each lines }}
<tr style="background-color:{{visit_color}}">
{{#if title}}
<td style="background-color:{{cycle_color}}"><b>{{cycle_name}}</b></td>
<td colspan="7" style="text-align:right;"><b>{{details}}</b></td>
{{else}}
<td style="background-color:{{cycle_color}}">{{cycle_name}}</td>
<td style="background-color:{{visit_color}}">{{no}}</td>
<td style="background-color:{{visit_color}}"><a href="/ui#name=clinic_visit&active_id={{visit_id}}&mode=form">{{number}}</a></td>
<td style="background-color:{{visit_color}}">{{patient_name}}</td>
<td style="background-color:{{visit_color}}">{{patient_type}}</td>
<td style="background-color:{{visit_color}}">{{doctor_name}}</td>
<td style="background-color:{{visit_color}}"><a href="/ui#name=clinic_hd_case&active_id={{hd_case_id}}&mode=form">{{hd_case_number}}</a></td>
<td style="background-color:{{visit_color}}">{{note}}</td>
{{/if}}
</tr>
{{/each}}
</tbody>
<tfoot>
</tfoot>
</table>

View File

@ -1,37 +0,0 @@
<center>
<h2>ตารางนัดผู้ป่วย</h2>
<h3>
{{parent_company_name}}&nbsp;{{company_name}}<br/>
</h3>
<h4>
{{#if has_duration}}
ระหว่างวันที่ {{date_from}} ถึง {{date_to}}
{{else}}
ประจำวันที่ {{date}}
{{/if}}
</h4>
</center>
<table class="table table-hover">
<thead>
<th>รอบ</th>
<th>Ref.</th>
<th>ผู้ป่วย</th>
<th>แพทย์</th>
<th>HD Case</th>
<th>หมายเหตุ</th>
</thead>
<tbody>
{{#each lines }}
<tr style="background-color: {{success_color}}">
<td style="background-color: {{cycle_color}}">{{cycle_name}}</td>
<td><a href="/ui#name=clinic_visit&active_id={{visit_id}}&mode=form">{{number}}</a></td>
<td>{{patient_name}}</td>
<td>{{doctor_name}}</td>
<td><a href="/ui#name=clinic_hd_case&active_id={{hd_case_id}}&mode=form">{{hd_case_number}}</a></td>
<td>{{note}}</td>
</tr>
{{/each}}
</tbody>
<tfoot>
</tfoot>
</table>

View File

@ -1,4 +1,7 @@
======= =======
- change personal -> stuff -> link to employee
- add level to the list of the stuff
- design - design
- auto complete hd after time out - auto complete hd after time out
- create payment for each type of patient - create payment for each type of patient