diff --git a/netforce_clinic/layouts/clinic_report_wizard_labor_cost.xml b/netforce_clinic/layouts/clinic_report_wizard_labor_cost.xml
index 11d4d88..70b2313 100644
--- a/netforce_clinic/layouts/clinic_report_wizard_labor_cost.xml
+++ b/netforce_clinic/layouts/clinic_report_wizard_labor_cost.xml
@@ -11,7 +11,7 @@
-
+
diff --git a/netforce_clinic/layouts/report_hdcase_expense_summary.xml b/netforce_clinic/layouts/report_hdcase_expense_summary.xml
index 347d27b..9df558c 100644
--- a/netforce_clinic/layouts/report_hdcase_expense_summary.xml
+++ b/netforce_clinic/layouts/report_hdcase_expense_summary.xml
@@ -10,4 +10,7 @@
+
+
+
diff --git a/netforce_clinic/migrations/__init__.py b/netforce_clinic/migrations/__init__.py
index 97b9faf..b6fee1a 100644
--- a/netforce_clinic/migrations/__init__.py
+++ b/netforce_clinic/migrations/__init__.py
@@ -17,4 +17,5 @@ from . import clinic_setting
#from . import validate_cycle_item
#from . import update_line_amount
#from . import revise
-from . import add_patient_moves
+#from . import add_patient_moves #XXX do not run it again!!!
+from . import check_patient
diff --git a/netforce_clinic/migrations/check_patient.py b/netforce_clinic/migrations/check_patient.py
new file mode 100644
index 0000000..a03a382
--- /dev/null
+++ b/netforce_clinic/migrations/check_patient.py
@@ -0,0 +1,70 @@
+from netforce.model import get_model
+from netforce import migration
+from netforce.access import set_active_user, get_active_user, set_active_company, get_active_company
+import collections
+
+class Migration(migration.Migration):
+ _name="check.patient"
+ _version="2.12.8"
+
+ def migrate(salf):
+ set_active_company(1)
+ set_active_user(1)
+ totals={}
+ context={
+ 'active_test': False,
+ }
+ for pt in get_model('clinic.patient').search_browse([], context=context):
+ key=(pt.number, pt.card_no, pt.walkin)
+ #key=(pt.hn_no)
+ totals.setdefault(key,{
+ 'count': 0,
+ 'pid': pt.id,
+ 'pname': pt.name,
+ })
+ totals[key]['count']+=1
+
+ for k in sorted(totals.keys()):
+ hn_no, card_no, walkin = k
+ pt=totals[k]
+ if pt['count'] > 1:
+ #hn_no, card_no, walkin = k
+ print(k, pt)
+ return
+
+ user_id=get_active_user()
+ company_id=get_active_company()
+ count=0
+ lines_hn=[]
+ lines_pid=[]
+ lines_h=[]
+ lines_p=[]
+ print('start check patients.')
+ for pat in get_model('clinic.patient').search_browse([]):
+ lines_hn.append(pat.hn_no)
+ lines_pid.append(pat.card_no)
+ count+=1
+ print('count : %d'%(count))
+ total_hn = [item for item, count in collections.Counter(lines_hn).items() if count > 1]
+ total_pid = [item for item, count in collections.Counter(lines_pid).items() if count > 1]
+ count=0
+ for total in total_hn:
+ for line in get_model('clinic.patient').search_browse(['hn_no','=',total]):
+ data = '%d : %s'%(line.id,line.hn_no)
+ lines_h.append(data)
+ count+=1
+ print('#%d : id=%d, name=%s %s, hn_no=%s'%(count,line.id,line.first_name,line.last_name,line.hn_no))
+ print("")
+ print("*"*100)
+ print("")
+ count=0
+ for total in total_pid:
+ for line in get_model('clinic.patient').search_browse(['card_no','=',total]):
+ data = '%d : %s'%(line.id,line.card_no)
+ lines_p.append(data)
+ count+=1
+ print('#%d : id=%d, name=%s %s, pid=%s'%(count,line.id,line.first_name,line.last_name,line.card_no))
+ print('check patients : Done!')
+ return True
+
+Migration.register()
diff --git a/netforce_clinic/models/account_payment.py b/netforce_clinic/models/account_payment.py
index 329f0a2..8cf3399 100644
--- a/netforce_clinic/models/account_payment.py
+++ b/netforce_clinic/models/account_payment.py
@@ -46,7 +46,7 @@ class AccountPayment(Model):
'next': {
'name': 'report_clinic_payment_form',
'refer_id': hd_case_id,
- 'payment_id': obj.id,
+ 'payment_ids': ids,
'convert': 'pdf',
},
}
diff --git a/netforce_clinic/models/hd_case.py b/netforce_clinic/models/hd_case.py
index 914fc82..a086b87 100644
--- a/netforce_clinic/models/hd_case.py
+++ b/netforce_clinic/models/hd_case.py
@@ -1321,7 +1321,10 @@ class HDCase(Model):
for obj in self.browse(ids):
if not obj.payments:
raise Exception("Receipt not found!")
- for payment in obj.payments:
+ payment_ids=[]
+ if context.get('payment_ids'):
+ payment_ids=eval(context['payment_ids'])
+ for payment in get_model('account.payment').browse(payment_ids):
context['payment_id']=payment.id
data=self.get_report_payment_data(context=context)
limit_item=9
diff --git a/netforce_clinic/models/patient.py b/netforce_clinic/models/patient.py
index f83c6dc..5d9da9c 100644
--- a/netforce_clinic/models/patient.py
+++ b/netforce_clinic/models/patient.py
@@ -272,7 +272,7 @@ class Patient(Model):
'dispose': False,
}
- _sql_constraints=("clinic_patient_key_uniq","unique(name_check)","name should be unique"),
+ _sql_constraints=("clinic_patient_key_uniq","unique(number,card_no,walkin)","HN, Card and Walkin should be unique"),
def check_idcard(self,card_type,idcard=''):
res=True
diff --git a/netforce_clinic/models/report_hdcase_expense_summary.py b/netforce_clinic/models/report_hdcase_expense_summary.py
index c984a20..85b3e46 100644
--- a/netforce_clinic/models/report_hdcase_expense_summary.py
+++ b/netforce_clinic/models/report_hdcase_expense_summary.py
@@ -60,7 +60,20 @@ class ReportHDCaseExpenseSummary(Model):
'product_id': product_id,
}
return res
-
+
+ def get_report_data_pdf(self,ids,context={}):
+ obj=self.browse(ids)[0]
+ return {
+ "next": {
+ "type": "report_odt2",
+ "model": self._name,
+ "template": "report_hdcase_expense_summary_pdf",
+ "refer_id": obj.id,
+ "method": "get_report_data",
+ "convert": "pdf",
+ }
+ }
+
def get_report_data(self,ids,context={}):
company_id=get_active_company()
company=get_model("company").browse(company_id)
diff --git a/netforce_clinic/models/report_wizard_labor_cost.py b/netforce_clinic/models/report_wizard_labor_cost.py
index 06ffc46..2816e6a 100644
--- a/netforce_clinic/models/report_wizard_labor_cost.py
+++ b/netforce_clinic/models/report_wizard_labor_cost.py
@@ -56,15 +56,15 @@ class ReportLaborCost(Model):
}
return res
- def wizard_report_summany(self,ids,context={}):
+ def wizard_report_summary(self,ids,context={}):
obj=self.browse(ids)[0]
return {
"next": {
"type": "report_odt2",
"model": self._name,
- "template": "report_wizard_labor_cost_summany",
+ "template": "report_wizard_labor_cost_summary",
"refer_id": obj.id,
- "method": "get_report_wizard_summany",
+ "method": "get_report_wizard_summary",
"convert": "pdf",
}
}
@@ -85,7 +85,7 @@ class ReportLaborCost(Model):
def get_report_data(self,ids,context={}):
return
- def get_report_wizard_summany(self,ids,context={}):
+ def get_report_wizard_summary(self,ids,context={}):
obj=[]
if ids:
obj=self.browse(ids)[0]
@@ -100,13 +100,14 @@ class ReportLaborCost(Model):
lc_vals={
'date': obj.date_form,
'period_id': obj.period_id.id,
- 'date_from': obj.date_form,
+ 'date_from': obj.date_from,
'date_to': obj.date_to,
'cycle_id': obj.cycle_id.id or None,
'branch_id': obj.branch_id.id or None,
'report_type': 'cross',
'department_id': obj.department_id.id or None,
}
+ print(lc_vals)
lc_id=get_model('clinic.report.labor.cost').create(lc_vals)
lc_data=get_model('clinic.report.labor.cost').get_report_data([lc_id])
#data['lc_data'].append(lc_data) # END STEP 1
@@ -120,6 +121,7 @@ class ReportLaborCost(Model):
}
pages1.append(data)
t2=datetime.now()
+ #import pdb; pdb.set_trace()
print('step 1 : ',t2-t1)
#STEP 2
diff --git a/netforce_clinic/models/visit.py b/netforce_clinic/models/visit.py
index 7b1b866..5d68db6 100644
--- a/netforce_clinic/models/visit.py
+++ b/netforce_clinic/models/visit.py
@@ -30,8 +30,8 @@ class Visit(Model):
res[obj.id]={
'cycle_color': color,
'sequence': '%s-%s'%(obj.time_start[0:10],cycle.sequence), #date-sequence
- 'patient_name': patient_id.name,
- 'patient_type_id': patient_id.type_id.id,
+ 'patient_name': patient.name,
+ 'patient_type_id': patient.type_id.id,
}
return res
@@ -57,8 +57,8 @@ class Visit(Model):
'note': fields.Text('Note'),
'branch_id': fields.Many2One("clinic.branch","Branch"),
'manual': fields.Boolean("Manual Tempolary Visit"),
- "patient_name": fields.Char("Patient Name", function="_get_all", store=True, search=True),
- "patient_type_id": fields.Char("Patient Type", function="_get_all", store=True, search=True),
+ "patient_name": fields.Char("Patient Name", function="_get_all", function_multi=True, store=True, search=True),
+ "patient_type_id": fields.Char("Patient Type", function="_get_all", function_multi=True, store=True, search=True),
}
def _get_number(self,context={}):
diff --git a/netforce_clinic/reports/cust_payment.odt b/netforce_clinic/reports/cust_payment.odt
index 49cf102..120487d 100644
Binary files a/netforce_clinic/reports/cust_payment.odt and b/netforce_clinic/reports/cust_payment.odt differ
diff --git a/netforce_clinic/reports/report_hdcase_expense_summary_pdf.odt b/netforce_clinic/reports/report_hdcase_expense_summary_pdf.odt
new file mode 100644
index 0000000..4bf0a2d
Binary files /dev/null and b/netforce_clinic/reports/report_hdcase_expense_summary_pdf.odt differ
diff --git a/netforce_clinic/reports/report_wizard_labor_cost_summany.odt b/netforce_clinic/reports/report_wizard_labor_cost_summary.odt
similarity index 100%
rename from netforce_clinic/reports/report_wizard_labor_cost_summany.odt
rename to netforce_clinic/reports/report_wizard_labor_cost_summary.odt