diff --git a/netforce_clinic/layouts/clinic_matching_hdcase.xml b/netforce_clinic/layouts/clinic_matching_hdcase.xml index 14ac1f7..2cdf845 100644 --- a/netforce_clinic/layouts/clinic_matching_hdcase.xml +++ b/netforce_clinic/layouts/clinic_matching_hdcase.xml @@ -3,17 +3,18 @@ - + + - - - - - - - - - + + + + + diff --git a/netforce_clinic/layouts/clinic_report_labor_cost.xml b/netforce_clinic/layouts/clinic_report_labor_cost.xml index 0c2dc49..6d636e7 100644 --- a/netforce_clinic/layouts/clinic_report_labor_cost.xml +++ b/netforce_clinic/layouts/clinic_report_labor_cost.xml @@ -1,6 +1,6 @@
- + diff --git a/netforce_clinic/models/matching_hdcase.py b/netforce_clinic/models/matching_hdcase.py index 1244b18..7aa8c4f 100644 --- a/netforce_clinic/models/matching_hdcase.py +++ b/netforce_clinic/models/matching_hdcase.py @@ -15,6 +15,7 @@ class MatchingHDCase(Model): 'skip_lines': fields.One2Many("clinic.matching.hdcase.line","matching_hdcase_id","Skip Lines"), 'file_lines': fields.One2Many("clinic.matching.hdcase.file","matching_hdcase_id","File Lines"), 'msg': fields.Text("Message"), + 'branch_id': fields.Many2One("clinic.branch","Branch"), } def _get_skip_lines(self,context={}): @@ -68,10 +69,10 @@ class MatchingHDCase(Model): return rows def get_report_data(self,ids,context={}): - hdcases={} defaults=self.default_get(context=context) date_from=defaults.get("date_from") date_to=defaults.get("date_to") + branch_id=defaults.get("branch_id") lines=[] state="all" if ids: @@ -79,15 +80,16 @@ class MatchingHDCase(Model): state=obj.state date_from=obj.date_from date_to=obj.date_to + branch_id=obj.branch_id.id skip_lines=[skip.type_id.name for skip in obj.skip_lines] - print('skip_lines ', skip_lines) if not obj.file: return {} - #raise Exception("File Not found") fpath=get_file_path(obj.file) rows=self.get_rows(fpath) if not rows: - raise Exception("No Data") + return { + 'message': 'No Data', + } #{0: ' A 01', #1: ' 6', #2: ' 11686', @@ -132,7 +134,9 @@ class MatchingHDCase(Model): dom.append(['date',">=",date_from]) dom.append(['date',"<=",date_to]) dom.append(['state','!=','cancelled']) - hdcases={} + if branch_id: + dom.append(['branch_id','=',branch_id]) + hdcases1={} hdcases2={} hdcases3={} def get_account_patient_hn(patient_id): @@ -140,11 +144,10 @@ class MatchingHDCase(Model): if res: return res[0] return res - + print('hdcase get key ....') for hdcase in get_model("clinic.hd.case").search_browse(dom): date=hdcase.date hn=hdcase.patient_id.hn_no or "" - #hn=hn[0:7] #XXX K.Ekk explain on 03/04/2015 : 0-7 is main of hn fee_amt=0 hct=hdcase.hct or "0" hct=round(float(hct),2) @@ -164,7 +167,7 @@ class MatchingHDCase(Model): if prod_line: prod_name='-'.join(prod_line) key1='%s-%s-%s-%s'%(date,hn,prod_name,fee_amt) - hdcases[key1]={ + hdcases1[key1]={ 'id': hdcase.id, 'number': hdcase.number or '', 'note': '', @@ -188,9 +191,12 @@ class MatchingHDCase(Model): 'patient_name': patient.name, 'patient_type': patient.type_id.name, } + ddate=set() + print('match hdcase ....') for row in rows: vals=list(row.values()) date,_time=(vals[5] or "").split() + ddate.update({date}) if len(date)<3: raise Exception("Wrong format date") d,m,y=date.split("/") @@ -214,7 +220,7 @@ class MatchingHDCase(Model): prod_name=prod_name.replace(" ", "") prod_id=products.get(prod_name.upper(),None) key1='%s-%s-%s-%s'%(date,hn,prod_name.upper(),fee_amt) - hdcase=hdcases.get(key1) + hdcase=hdcases1.get(key1) unit_amt=float(vals[11]) line_vals={ 'hn': hn, @@ -271,6 +277,7 @@ class MatchingHDCase(Model): total_match=0 total_unmatch=0 mdate=[] + print('sorted line ...') for line in sorted(lines,key=lambda x: x['hn']): ldate=line.get('date') or "" if ldate not in mdate: @@ -320,14 +327,15 @@ class MatchingHDCase(Model): 'total': total, 'total_match': total_match, 'total_unmatch': total_unmatch, + 'message': '', } if no <=1 and ids: - raise Exception("File match only %s"%', '.join(sorted(mdate))) + data['message']="%s"%', '.join(sorted(ddate)) return data def onchange_date(self,context={}): data=context['data'] - #data['date_to']=data['date_from'] + data['date_to']=data['date_from'] return data MatchingHDCase.register() diff --git a/netforce_clinic/models/report_labor_cost.py b/netforce_clinic/models/report_labor_cost.py index fadc007..e7b0c7d 100644 --- a/netforce_clinic/models/report_labor_cost.py +++ b/netforce_clinic/models/report_labor_cost.py @@ -338,4 +338,9 @@ class ReportLaborCost(Model): data['department_id']=None return data + def onchange_from(self,context={}): + data=context['data'] + data['date_to']=data['date_from'] + return data + ReportLaborCost.register() diff --git a/netforce_clinic/templates/matching_hdcase.hbs b/netforce_clinic/templates/matching_hdcase.hbs index 5a017f4..64686cd 100644 --- a/netforce_clinic/templates/matching_hdcase.hbs +++ b/netforce_clinic/templates/matching_hdcase.hbs @@ -74,4 +74,10 @@ - +{{#if message}} + + File Math Only: + + {{message}} + +{{/if}}