diff --git a/netforce_clinic/actions/clinic_report_hd_dialy.xml b/netforce_clinic/actions/clinic_report_hd_dialy.xml
deleted file mode 100644
index 67e54ae..0000000
--- a/netforce_clinic/actions/clinic_report_hd_dialy.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
- Report HD Dialy
- report
- clinic.report.hd.dialy
- report_hd_dialy
- report_hd_dialy
- clinic_menu
-
diff --git a/netforce_clinic/actions/clinic_report_hd_monthly.xml b/netforce_clinic/actions/clinic_report_hd_monthly.xml
deleted file mode 100644
index c0ed924..0000000
--- a/netforce_clinic/actions/clinic_report_hd_monthly.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
- Report HD Monthly
- report
- clinic.report.hd.monthly
- report_hd_monthly
- report_hd_monthly
- clinic_menu
-
diff --git a/netforce_clinic/layouts/clinic_hd_case_form.xml b/netforce_clinic/layouts/clinic_hd_case_form.xml
index 0ce05b7..661b104 100644
--- a/netforce_clinic/layouts/clinic_hd_case_form.xml
+++ b/netforce_clinic/layouts/clinic_hd_case_form.xml
@@ -2,13 +2,13 @@
-
+
@@ -29,7 +29,7 @@
-
+
diff --git a/netforce_clinic/models/__init__.py b/netforce_clinic/models/__init__.py
index fa56528..05178af 100644
--- a/netforce_clinic/models/__init__.py
+++ b/netforce_clinic/models/__init__.py
@@ -31,7 +31,7 @@ from . import gen_visit
from . import gen_visit_line
from . import report_hd_detail
from . import report_hd_summary
+from . import report_hd_madical
from . import payment
from . import input_data
-from . import report_hd_madical
-from . import translate
+#from . import translate
diff --git a/netforce_clinic/models/hd_case.py b/netforce_clinic/models/hd_case.py
index c3caa7f..4e489b6 100644
--- a/netforce_clinic/models/hd_case.py
+++ b/netforce_clinic/models/hd_case.py
@@ -32,7 +32,6 @@ class HDcase(Model):
"doctor_id": fields.Many2One("clinic.doctor","Doctor", required=False,search=True),
"nurse_id": fields.Many2One("clinic.nurse","Nurse", required=True,search=True),
"department_id": fields.Many2One("clinic.department", "Department",search=True),
- "cycle_id" : fields.Many2One("clinic.cycle","Cycle", required=True),
"wh_start": fields.Float("Wt.Kg start"),
"wh_stop": fields.Float("Wt.Kg stop"),
"bp_start": fields.Integer("BP mmHG start"),
@@ -41,8 +40,8 @@ class HDcase(Model):
"per_bp_stop": fields.Integer("/Per stop"),
"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),
+ "hct": fields.Integer("HCT %"),
+ "hct_msg" : fields.Char("HCT message"),
"check_goverment_pay" : fields.Boolean("The Government Pay"),
"check_personal_pay" : fields.Boolean("Pay yourself"),
"state": fields.Selection([("draft","Draft"),("in_progress","In Progress"),("completed","Completed"),("discountinued","Discountinued"),("in_completed","In completed")],"Status",required=True),
@@ -101,10 +100,12 @@ class HDcase(Model):
'nurse_id': _get_nurse,
"number": _get_number,
"company_id": lambda *a: get_active_company(),
- "fee": 1500,
+ 'hct': 0,
+ 'hct_msg': "Reimbursement of medicines : 1,125/Week",
}
_order="date desc,number desc"
+
def onchange_dialyzer(self,context={}):
data=context["data"]
path=context["path"]
@@ -190,8 +191,8 @@ class HDcase(Model):
settings=get_model("settings").browse(1)
account_id=settings.account_receivable_id
data['pay_account_id']=account_id.id
- pay_amount=total
- data['pay_amount']=pay_amount
+ #pay_amount=total
+ #data['pay_amount']=pay_amount
return data
def onchange_pay(self,context={}):
@@ -234,7 +235,8 @@ class HDcase(Model):
payment_id=get_model("account.payment").create(vals,context={"type":"in"})
obj.write({
- 'pay_amount': remaining_amt-obj.pay_amount,
+ #'pay_amount': remaining_amt-obj.pay_amount,
+ 'pay_amount': 0, # reset
'payment_lines': [('create',{
'payment_id': payment_id,
'amount': obj.pay_amount,
@@ -249,13 +251,6 @@ class HDcase(Model):
'flash': 'Pay OK',
}
- def onchange_hct(self,context={}):
- data=context['data']
- hct=data['hct']
- if(hct<=39):
- pass
- return data
-
def cancelled(self,ids,context={}):
obj=self.browse(ids)[0]
obj.write({" state":"cancelled"})
@@ -538,17 +533,16 @@ class HDcase(Model):
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']=""
+ hct=data.get("hct",0)
+ msg=""
+ if(hct<=36):
+ msg="Reimbursement of medicines : 1,125/Week"
+ elif(hct>36 and hct<39):
+ msg="Reimbursement of medicines : 750/Week"
+ elif(hct>=39):
+ msg="Can not be drawn"
+ data['hct_msg']=msg
return data
def undo(self,ids,context={}):
@@ -563,6 +557,11 @@ class HDcase(Model):
'state': 'draft',
})
pick.delete()
+ for payment in obj.payments:
+ payment.to_draft()
+ payment.delete()
+ for pm_line in obj.payment_lines:
+ pm_line.delete()
obj.write({
'state': 'draft',
diff --git a/netforce_clinic/models/report_hd_detail.py b/netforce_clinic/models/report_hd_detail.py
index cf7e506..7d9c63c 100644
--- a/netforce_clinic/models/report_hd_detail.py
+++ b/netforce_clinic/models/report_hd_detail.py
@@ -1,5 +1,4 @@
import time
-import pprint
from netforce.model import Model, fields, get_model
diff --git a/netforce_clinic/models/report_hd_dialy.py b/netforce_clinic/models/report_hd_dialy.py
deleted file mode 100644
index f84792c..0000000
--- a/netforce_clinic/models/report_hd_dialy.py
+++ /dev/null
@@ -1,138 +0,0 @@
-import time
-
-from netforce.model import Model, fields, get_model
-
-class ReportHDDialy(Model):
- _name="clinic.report.hd.dialy"
- _string="Report HD Dialy"
- _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={}):
- PATIENT_TYPE={
- "mg":"Medical Government",
- "sc":"Social Security",
- "nhso":"NHSO (30฿)",
- "personal": "Personal",
- "others": "Others",
- }
-
- date_from=time.strftime("%Y-%m-%d")
- date_to=time.strftime("%Y-%m-%d")
-
- defaults=context.get("defaults")
- if defaults.get("date_from"):
- date_from=defaults.get("date_from")
- if defaults.get("date_to"):
- date_to=defaults.get("date_to")
-
- 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.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)
- 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.fee,
- '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
-
-ReportHDDialy.register()
diff --git a/netforce_clinic/models/report_hd_monthly.py b/netforce_clinic/models/report_hd_monthly.py
deleted file mode 100644
index abfd984..0000000
--- a/netforce_clinic/models/report_hd_monthly.py
+++ /dev/null
@@ -1,117 +0,0 @@
-import time
-
-from datetime import datetime
-from calendar import monthrange
-
-from netforce.model import Model, fields, get_model
-
-class ReportHDMonthly(Model):
- _name="clinic.report.hd.monthly"
- _string="Report HD Monthly"
- _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")
-
- patients=get_model("clinic.patient").search_browse(['type','=','All'])
- 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'])
-
- new_patients=0
- if datemonth==month:
- new_patients= len(patients)
-
- 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").search_browse(dom)
-
- lines=[
- {
- 'topic': 'The number of times the Hemodialysis',
- 'month': month_str,
- 'amount': len(hd_cases),
- },
-
- {
- 'topic':'The number of cases brought',
- 'month': previous_month_str,
- 'amount': 'N/A',
- },
- {
- 'topic':'Number of new patients',
- 'month': month_str,
- 'amount': new_patients,
- },
- {
- 'topic':'Number of patients discharged',
- 'month': month_str,
- 'amount': 'N/A',
- },
- {
- 'topic':'The number of cases brought',
- 'month': next_month_str,
- 'amount': 0,
- },
- {
- 'topic':'Number of patients withdrawn Social Security',
- 'month': '',
- 'amount': len(patients_sc),
- },
- {
- 'topic':'Number of patients withdrawn Medical Government',
- 'month':'',
- 'amount': len(patients_mg),
- },
- {
- 'topic':'Number of patients withdrawn NHSO(30B)',
- 'month':'',
- 'amount': len(patients_nhso),
- },
- {
- 'topic':'Many patients pay themselves',
- 'month': '',
- 'amount': len(patients_pn),
- },
- ]
-
- data={
- 'month': month_str,
- 'year': year,
- 'lines': lines,
- }
- return data
-
-ReportHDMonthly.register()