diff --git a/netforce_clinic/actions/clinic_report_hd_detail.xml b/netforce_clinic/actions/clinic_report_hd_detail.xml new file mode 100644 index 0000000..523c839 --- /dev/null +++ b/netforce_clinic/actions/clinic_report_hd_detail.xml @@ -0,0 +1,8 @@ + --> + HD Report Detail + report + clinic.report.hd.detail + report_hd_detail + report_hd_detail + clinic_menu + diff --git a/netforce_clinic/actions/clinic_report_hd_madical.xml b/netforce_clinic/actions/clinic_report_hd_madical.xml new file mode 100644 index 0000000..4101bef --- /dev/null +++ b/netforce_clinic/actions/clinic_report_hd_madical.xml @@ -0,0 +1,8 @@ + + Medical Report Summary + report + clinic.report.hd.madical + report_hd_madical + report_hd_madical + clinic_menu + diff --git a/netforce_clinic/actions/clinic_report_hd_summary.xml b/netforce_clinic/actions/clinic_report_hd_summary.xml new file mode 100644 index 0000000..354018e --- /dev/null +++ b/netforce_clinic/actions/clinic_report_hd_summary.xml @@ -0,0 +1,8 @@ + + HD Report Summary + report + clinic.report.hd.summary + report_hd_summary + report_hd_summary + clinic_menu + diff --git a/netforce_clinic/actions/clinic_translate.xml b/netforce_clinic/actions/clinic_translate.xml new file mode 100644 index 0000000..4c174f1 --- /dev/null +++ b/netforce_clinic/actions/clinic_translate.xml @@ -0,0 +1,7 @@ + + Translation + multi_view + clinic.translate + list,form + clinic_menu + diff --git a/netforce_clinic/layouts/clinic_hd_case_form.xml b/netforce_clinic/layouts/clinic_hd_case_form.xml index 0190878..0ce05b7 100644 --- a/netforce_clinic/layouts/clinic_hd_case_form.xml +++ b/netforce_clinic/layouts/clinic_hd_case_form.xml @@ -26,8 +26,10 @@ - + + + diff --git a/netforce_clinic/layouts/clinic_menu.xml b/netforce_clinic/layouts/clinic_menu.xml index 904d368..74810d1 100644 --- a/netforce_clinic/layouts/clinic_menu.xml +++ b/netforce_clinic/layouts/clinic_menu.xml @@ -20,12 +20,15 @@
- - + + +
+ + diff --git a/netforce_clinic/layouts/clinic_report_hd_detail.xml b/netforce_clinic/layouts/clinic_report_hd_detail.xml new file mode 100644 index 0000000..b07f88c --- /dev/null +++ b/netforce_clinic/layouts/clinic_report_hd_detail.xml @@ -0,0 +1,10 @@ +
+ + + + + + + + +
diff --git a/netforce_clinic/layouts/clinic_report_hd_madical.xml b/netforce_clinic/layouts/clinic_report_hd_madical.xml new file mode 100644 index 0000000..fcd40ac --- /dev/null +++ b/netforce_clinic/layouts/clinic_report_hd_madical.xml @@ -0,0 +1,3 @@ +
+ + diff --git a/netforce_clinic/layouts/clinic_report_hd_summary.xml b/netforce_clinic/layouts/clinic_report_hd_summary.xml new file mode 100644 index 0000000..decc455 --- /dev/null +++ b/netforce_clinic/layouts/clinic_report_hd_summary.xml @@ -0,0 +1,3 @@ +
+ + diff --git a/netforce_clinic/layouts/clinic_translate_form.xml b/netforce_clinic/layouts/clinic_translate_form.xml new file mode 100644 index 0000000..27c8779 --- /dev/null +++ b/netforce_clinic/layouts/clinic_translate_form.xml @@ -0,0 +1,4 @@ +
+ + + diff --git a/netforce_clinic/layouts/clinic_translate_list.xml b/netforce_clinic/layouts/clinic_translate_list.xml new file mode 100644 index 0000000..38a44f2 --- /dev/null +++ b/netforce_clinic/layouts/clinic_translate_list.xml @@ -0,0 +1,4 @@ + + + + diff --git a/netforce_clinic/models/__init__.py b/netforce_clinic/models/__init__.py index 20a9074..fa56528 100644 --- a/netforce_clinic/models/__init__.py +++ b/netforce_clinic/models/__init__.py @@ -29,7 +29,9 @@ from . import file_sheet from . import cycle from . import gen_visit from . import gen_visit_line -from . import report_hd_dialy -from . import report_hd_monthly +from . import report_hd_detail +from . import report_hd_summary from . import payment from . import input_data +from . import report_hd_madical +from . import translate diff --git a/netforce_clinic/models/hd_case.py b/netforce_clinic/models/hd_case.py index 6ea3e4f..c3caa7f 100644 --- a/netforce_clinic/models/hd_case.py +++ b/netforce_clinic/models/hd_case.py @@ -1,6 +1,6 @@ import time -from datetime import datetime +from datetime import datetime from netforce.model import Model, fields, get_model from netforce.utils import get_data_path from netforce.access import get_active_user,set_active_user @@ -22,6 +22,7 @@ class HDcase(Model): res[obj.id]=total_time return res + _fields={ "number": fields.Char("Number",required=True,search=True), "time_start": fields.DateTime("Time start",required=True,search=True), @@ -41,9 +42,9 @@ class HDcase(Model): "epo_tn" : fields.Char("EpoTn (Drug name)"), "epo_unit" : fields.Integer("EpoUnit (Unit of Used drug)"), "hct": fields.Integer("HCT %", required=True), + "hct_alert" : fields.Char("",readonly=True,function_multi=True), "check_goverment_pay" : fields.Boolean("The Government Pay"), "check_personal_pay" : fields.Boolean("Pay yourself"), - "hct": fields.Integer("HCT %(>39)"), "state": fields.Selection([("draft","Draft"),("in_progress","In Progress"),("completed","Completed"),("discountinued","Discountinued"),("in_completed","In completed")],"Status",required=True), "dialyzers": fields.One2Many("clinic.dialyzer.line","hd_case_id","Dialyzers"), "lines": fields.One2Many("clinic.hd.case.line","hd_case_id","Lines"), @@ -534,6 +535,21 @@ class HDcase(Model): else: data['fee']=0.0 return data + + + def onchange_hct(self,context={}): + print(">"*50) + data=context['data'] + hct_alert=data.get("hct","") + if(hct_alert<=36): + data['hct_alert']="Reimbursement of medicines : 1,125/Week" + elif(36<=hct_alert<=39): + data['hct_alert']="Reimbursement of medicines : 750/Week" + elif(hct_alert>39): + data['hct_alert']="Can not be drawn" + else: + data['hct_alert']="" + return data def undo(self,ids,context={}): obj=self.browse(ids)[0] @@ -559,6 +575,5 @@ class HDcase(Model): }, 'flash': '%s has been undo'%obj.number, } - HDcase.register() diff --git a/netforce_clinic/models/report_hd_detail.py b/netforce_clinic/models/report_hd_detail.py new file mode 100644 index 0000000..cf7e506 --- /dev/null +++ b/netforce_clinic/models/report_hd_detail.py @@ -0,0 +1,156 @@ +import time +import pprint + +from netforce.model import Model, fields, get_model + +class ReportHDDetail(Model): + _name="clinic.report.hd.detail" + _string="Hemodialysis Report Detail" + _transient=True + + _fields={ + "patient_id" : fields.Many2One("clinic.patient","Patient"), + "doctor_id" : fields.Many2One("clinic.doctor","Doctor"), + "nurse_id" : fields.Many2One("clinic.nurse","Nurse"), + "date_from": fields.Date("From"), + "date_to": fields.Date("To"), + "cycle_id": fields.Many2One("clinic.cycle","Cycle"), + } + + _defaults={ + 'date_from': lambda *a: time.strftime("%Y-%m-%d"), + 'date_to': lambda *a: time.strftime("%Y-%m-%d"), + } + + _order="cycle_id desc" + + + def get_report_data(self,ids,context={}): + # context=> dict + # inside context => keys => defaults => type => dict + # dict => key: value => '', 1, [], {} + # context['default'] => defaults(dict) => key => inside key => value => '2014-10-22' + date_from=time.strftime("%Y-%m-%d") + date_to=time.strftime("%Y-%m-%d") + # print('date_from ',date_from) + defaults=context.get("defaults") + if defaults: + if defaults.get("date_from"): + date_from=defaults['date_from'] + if defaults.get("date_to"): + date_to=defaults['date_to'] + # date_to=context['date_to'] + # default => key => dataults + # date_from=context['date_from'] + # print(context['date_from']) + #'2014-10-13' + # print('date_from ',date_from) + # print('date_to ',date_to) + PATIENT_TYPE={ + "mg":"Medical Government", + "sc":"Social Security", + "nhso":"NHSO (30฿)", + "personal": "Personal", + "others": "Others", + } + + dom=[] + dom.append(['state','=','completed']) + if ids: + obj=self.browse(ids)[0] + if obj.date_from: + date_from=obj.date_from + if obj.date_to: + date_to=obj.date_to + if obj.cycle_id: + dom.append([ + 'cycle_id','=',obj.cycle_id.id, + ]) + if obj.patient_id: + dom.append([ + 'patient_id','=',obj.patient_id.id, + ]) + if obj.nurse_id: + dom.append([ + 'nurse_id','=',obj.nurse_id.id, + ]) + if obj.doctor_id: + dom.append([ + 'doctor_id','=',obj.doctor_id.id, + ]) + + dom.append(['time_start', ">=", date_from+" 00:00:00"]) + dom.append(['time_stop',"<=", date_to+" 23:59:59"]) + lines=[] + cycles=[] + index=0 + no_patient=0 + for hd_case in get_model("clinic.hd.case").search_browse(dom,order="cycle_id.sequence"): + patient_type=hd_case.patient_id.type + patient_type=PATIENT_TYPE.get(patient_type) + #dialyzer_name=hd_case.dialyzers.id + #dialyzer_name=DIALYZER_NAME.get(dialyzer_name) + cycle_name=hd_case.cycle_id.name or "" + show_cycle=False + if not cycle_name in cycles: + cycles.append(cycle_name) + show_cycle=True + vals={ + 'color': 'success', + 'show_cycle': False, + 'cycle' : "", + 'patient': "", + 'no_patient': no_patient, + 'patient_type' : "", + 'doctor' : "", + 'total' : "", + 'rc_no' : "", + 'dialyzer_name' : "", + 'nurse' : "", + } + lines.append(vals) + no_patient=1 + else: + no_patient+=1 + index+=1 + vals={ + 'show_cycle': show_cycle, + 'cycle' : cycle_name, + 'patient': hd_case.patient_id.name, + 'patient_type' : patient_type, + 'no_patient': 0, + 'doctor' : hd_case.doctor_id.name, + 'total' : hd_case.total, + 'rc_no' : hd_case.number, + 'dialyzer_name' : 'DZ-xxx', + 'nurse' : hd_case.nurse_id.name, + } + lines.append(vals) + + # XXX + if lines: + vals={ + 'color': 'success', + 'show_cycle': False, + 'cycle' : "", + 'patient': "", + 'no_patient': no_patient, + 'patient_type' : "", + 'doctor' : "", + 'total' : "", + 'rc_no' : "", + 'dialyzer_name' : "", + 'nurse' : "", + } + lines.append(vals) + #XXX + del lines[0] + data={ + 'lines': lines, + 'same_date': date_from==date_to, + 'date_from': date_from, + 'date_to': date_to, + } + return data + +ReportHDDetail.register() diff --git a/netforce_clinic/models/report_hd_madical.py b/netforce_clinic/models/report_hd_madical.py new file mode 100644 index 0000000..b316a13 --- /dev/null +++ b/netforce_clinic/models/report_hd_madical.py @@ -0,0 +1,153 @@ +import time + +from datetime import datetime +from calendar import monthrange +from netforce.model import Model,fields + +class ReportHDMadical(Model): + _name="clinic.report.hd.madical" + _string="Hemodialysis Report Madical Summary" + _transient=True + + _fields={ + "date": fields.Date("Month", required=True), + } + + _defaults={ + 'date': lambda *a: time.strftime("%Y-%m-%d"), + } + + def get_report_data(self,ids,context={}): + date=datetime.now().strftime("%Y-%m-%d") + #datemonth=datetime.now().strftime("%m") + if ids: + obj=self.browse(ids)[0] + date=obj.date + year=int(date[0:4]) + month=int(date[5:7]) + month_str=datetime.strptime(date,'%Y-%m-%d').strftime("%B") + + next_month = str(month + 1) + if next_month == 13: + next_month = 12 + #next_month_str=datetime.strptime(next_month,'%m').strftime("%B") + previous_month = str(month - 1) + if previous_month == 0: + previous_month = 12 + #previous_month_str=datetime.strptime(previous_month,'%m').strftime("%B") + + #madical=get_model("clinic.hd.case.gm.line").search_browse() + #patients_mg=get_model("clinic.patient").search_browse(['type','=','mg']) + + weekday, total_day=monthrange(year, month) + time_start='2014-%s-01 00:00:00'%(month) + time_stop='2014-%s-%s 23:59:59'%(month,total_day) + + dom=[] + dom.append(['state','=','completed']) + dom.append(['time_start','>=',time_start]) + dom.append(['time_stop','<=',time_stop]) + #hd_cases=get_model("clinic.hd.case.gm.line").search_browse(dom) + + lines=[ + { + 'madical' : 'H4', + 'sc': '437', + 'uc': '', + 'buy' : '4', + 'total' : '441', + }, + { + 'madical' : 'H2', + 'sc': '', + 'uc': '', + 'buy' : '', + 'total' : '', + }, + { + 'madical' : 'Epr4', + 'sc': '216', + 'uc': '', + 'buy' : '', + 'total' : '216', + }, + { + 'madical' : 'Epr2', + 'sc': '', + 'uc': '', + 'buy' : '', + 'total' : '', + }, + { + 'madical' : 'Epk4', + 'sc': '70', + 'uc': '', + 'buy' : '', + 'total' : '70', + }, + { + 'madical' : 'Epk2', + 'sc': '', + 'uc': '', + 'buy' : '', + 'total' : '', + }, + { + 'madical' : 'Epg4', + 'sc': '98', + 'uc': '', + 'buy' : '', + 'total' : '98', + }, + { + 'madical' : 'Epg2', + 'sc': '', + 'uc': '', + 'buy' : '', + 'total' : '', + }, + { + 'madical' : 'Rng4', + 'sc': '34', + 'uc': '', + 'buy' : '9', + 'total' : '43', + }, + { + 'madical' : 'Rng2', + 'sc': '', + 'uc': '', + 'buy' : '', + 'total' : '', + }, + { + 'madical' : 'Epi4', + 'sc': '264', + 'uc': '', + 'buy' : '9', + 'total' : '43', + }, + { + 'madical' : 'Epi2', + 'sc': '', + 'uc': '', + 'buy' : '', + 'total' : '', + }, + { + 'madical' : 'Vnf', + 'sc': '', + 'uc': '', + 'buy' : '', + 'total' : '', + }, + ] + + data={ + 'month': month_str, + 'year': year, + 'lines': lines, + } + return data + +ReportHDMadical.register() diff --git a/netforce_clinic/models/report_hd_summary.py b/netforce_clinic/models/report_hd_summary.py new file mode 100644 index 0000000..ca0412e --- /dev/null +++ b/netforce_clinic/models/report_hd_summary.py @@ -0,0 +1,149 @@ +import time + +from datetime import datetime +from calendar import monthrange +from netforce.model import Model, fields, get_model + +class ReportHDSummary(Model): + _name="clinic.report.hd.summary" + _string="Hemodialysis Report Summary" + _transient=True + + _fields={ + "date": fields.Date("Month", required=True), + } + + _defaults={ + 'date': lambda *a: time.strftime("%Y-%m-%d"), + } + + def get_report_data(self,ids,context={}): + date=datetime.now().strftime("%Y-%m-%d") + dom=[] + if ids: + obj=self.browse(ids)[0] + date=obj.date + + month=int(date[5:7]) + year=int(date[0:4]) + weekday, total_day=monthrange(year, month) + #date_from="%s-%s-01"%(year,month) + #date_to="%s-%s-%s"%(year,month,total_day) + month_str=datetime.strptime(date,'%Y-%m-%d').strftime("%B") + next_month = str(month + 1) + if next_month == 13: + next_month = 12 + next_month_str=datetime.strptime(next_month,'%m').strftime("%B") + + previous_month = month-1 + if previous_month == 0: + previous_month = 12 + #tip previous_month=str(month-1 == 0 and 12 or month) + previous_month_str=datetime.strptime('%s'%previous_month,'%m').strftime("%B") + + + time_start='2014-%s-01'%(month) # 2014-10-20 + time_stop='2014-%s-%s'%(month,total_day) + + dom=[] + dom.append(['time_start','>=',time_start]) + dom.append(['time_stop','<=',time_stop]) + + patients=get_model("clinic.patient").search_browse(['type','=','All']) + new_patients=len(patients) + patients_mg=get_model("clinic.patient").search_browse(['type','=','mg']) + patients_sc=get_model("clinic.patient").search_browse(['type','=','sc']) + patients_nhso=get_model("clinic.patient").search_browse(['type','=','nhso']) + patients_pn=get_model("clinic.patient").search_browse(['type','=','personal']) + + dom=[] + dom.append(['state','=','completed']) + dom.append(['time_start','>=',time_start]) + dom.append(['time_stop','<=',time_stop]) + cur_total_case=len(get_model("clinic.hd.case").search(dom)) + + weekday, prev_total_day=monthrange(year, previous_month) + time_start_pre='2014-%s-01'%(previous_month) # 2014-10-20 + time_stop_pre='2014-%s-%s'%(previous_month,prev_total_day) + + dom=[] + dom.append(['state','=','completed']) + dom.append(['time_start','>=',time_start_pre]) + dom.append(['time_stop','<=',time_stop_pre]) + prev_total_case=len(get_model("clinic.hd.case").search(dom)) + + lines=[ + { + 'topic': 'The number of times the Hemodialysis', + 'month': month_str, + 'amount': cur_total_case, + 'date_from': time_start, + 'date_to': time_stop, + }, + { + 'topic':'The number of cases brought', + 'month': previous_month_str, + 'amount': prev_total_case, + 'date_from': time_start_pre, + 'date_to': time_stop_pre, + }, + { + 'topic':'Number of new patients', + 'month': month_str, + 'amount': new_patients, + 'date_from': time_start, + 'date_to': time_stop, + }, + { + 'topic':'Number of patients discharged', + 'month': month_str, + 'amount': 'N/A', + 'date_from': time_start, + 'date_to': time_stop, + }, + { + 'topic':'The number of cases brought', + 'month': next_month_str, + 'amount': 'N/A', + 'date_from': time_start, + 'date_to': time_stop, + }, + { + 'topic':'Number of patients withdrawn Social Security', + 'month': '', + 'amount': len(patients_sc), + 'date_from': "", + 'date_to': "", + }, + { + 'topic':'Number of patients withdrawn Medical Government', + 'month':'', + 'amount': len(patients_mg), + 'date_from': "", + 'date_to': "", + }, + { + 'topic':'Number of patients withdrawn NHSO(30B)', + 'month':'', + 'amount': len(patients_nhso), + 'date_from': "", + 'date_to': "", + }, + { + 'topic':'Many patients pay themselves', + 'month': '', + 'amount': len(patients_pn), + 'date_from': "", + 'date_to': "", + }, + ] + + data={ + 'month': month_str, + 'year': year, + 'lines': lines, + } + #print("data", data) + return data + +ReportHDSummary.register() diff --git a/netforce_clinic/models/setting.py b/netforce_clinic/models/setting.py index 4c9d05c..4dd86c3 100644 --- a/netforce_clinic/models/setting.py +++ b/netforce_clinic/models/setting.py @@ -17,6 +17,9 @@ class ClinicSetting(Model): "sc_partner_id": fields.Many2One("partner","Partner Social Security"), "ar_sc_id": fields.Many2One("account.account","Account Receiveble Social Security"), "ap_sc_id": fields.Many2One("account.account","Account Payment Social Security"), + #"ori_str": fields.Char("ori_str","Original String"), + #"translate": fields.Char("translate","Translation"), + } ClinicSetting.register() diff --git a/netforce_clinic/models/translate.py b/netforce_clinic/models/translate.py new file mode 100644 index 0000000..9ad41b1 --- /dev/null +++ b/netforce_clinic/models/translate.py @@ -0,0 +1,13 @@ +from netforce.model import Model, fields + +class Translate(Model): + _name="clinic.translate" + _string="Translate" + + _fields={ + "original_string": fields.Char("original_string","Original String",required=True,search=True), + "translate": fields.Char("translate","Translate"), + } + + +Translate.register() diff --git a/netforce_clinic/models/visit.py b/netforce_clinic/models/visit.py index af14153..962f045 100644 --- a/netforce_clinic/models/visit.py +++ b/netforce_clinic/models/visit.py @@ -13,7 +13,7 @@ class Visit(Model): _name_field="number" _multi_company=True - def _get_visit_date(self,ids,context): + def _get_visit_date(self,ids,context={}): res={} for obj in self.browse(ids): res[obj.id]=obj.time_start[0:10] diff --git a/netforce_clinic/reports/report_hd_detail.xlsx b/netforce_clinic/reports/report_hd_detail.xlsx new file mode 100644 index 0000000..f8cb902 Binary files /dev/null and b/netforce_clinic/reports/report_hd_detail.xlsx differ diff --git a/netforce_clinic/reports/report_hd_madical.xlsx b/netforce_clinic/reports/report_hd_madical.xlsx new file mode 100644 index 0000000..a802b45 Binary files /dev/null and b/netforce_clinic/reports/report_hd_madical.xlsx differ diff --git a/netforce_clinic/reports/report_hd_summary.xlsx b/netforce_clinic/reports/report_hd_summary.xlsx new file mode 100644 index 0000000..2e63974 Binary files /dev/null and b/netforce_clinic/reports/report_hd_summary.xlsx differ diff --git a/netforce_clinic/templates/report_hd_detail.hbs b/netforce_clinic/templates/report_hd_detail.hbs new file mode 100644 index 0000000..f1907a5 --- /dev/null +++ b/netforce_clinic/templates/report_hd_detail.hbs @@ -0,0 +1,84 @@ +
+

Detail of the Hemodialysis

+

Clinic [Ratchawat]

+

+ {{#if same_date}} + As at {{fmt_date date_from}} + {{else}} + From {{fmt_date date_from}} to {{fmt_date date_to}} + {{/if}} +

+
+ + + + + + + + + + + + + + + {{#each lines context=context}} + {{#if show_cycle}} + + + + {{/if}} + + {{#if no_patient}} + + + {{else}} + + + {{/if}} + + + + + + + + {{/each}} + + + + + + +
+ Cycle + + Patient + + Doctor + + Patient Type + + HD Fee + + RC.No + + Dialyzer + + Nurse +
+ {{cycle}} +
TOTAL{{no_patient}}{{patient}} + {{doctor}} + + {{patient_type}} + + {{total}} + + {{rc_no}} + + {{dialyzer_name}} + + {{nurse}} +
diff --git a/netforce_clinic/templates/report_hd_madical.hbs b/netforce_clinic/templates/report_hd_madical.hbs new file mode 100644 index 0000000..dabd546 --- /dev/null +++ b/netforce_clinic/templates/report_hd_madical.hbs @@ -0,0 +1,29 @@ +
+

+ Summary of the Madical +

+

+ [Ratchawat : Saamsan4]
+ As at {{month}} {{year}} +

+
+ + + + + + + + + + {{#each lines}} + + + + + + + + {{/each}} + +
MadicalSocial SecurityucBuyTotal
{{madical}}{{sc}}{{uc}}{{buy}}{{total}}
diff --git a/netforce_clinic/templates/report_hd_summary.hbs b/netforce_clinic/templates/report_hd_summary.hbs new file mode 100644 index 0000000..665c8b1 --- /dev/null +++ b/netforce_clinic/templates/report_hd_summary.hbs @@ -0,0 +1,25 @@ +
+

+ Summary of the Hemodialysis +

+

+ [Ratchawat : Saamsan4]
+ As at {{month}} {{year}} +

+
+ + + + + + + + {{#each lines}} + + + + + + {{/each}} + +
TopicMonthAmount
{{topic}}{{month}}{{amount}}