diff --git a/netforce_clinic/layouts/clinic_patient_form.xml b/netforce_clinic/layouts/clinic_patient_form.xml
index 0c77b46..416342e 100644
--- a/netforce_clinic/layouts/clinic_patient_form.xml
+++ b/netforce_clinic/layouts/clinic_patient_form.xml
@@ -13,7 +13,8 @@
-
+
+
@@ -79,6 +80,7 @@
+
@@ -106,15 +109,23 @@
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/netforce_clinic/models/patient.py b/netforce_clinic/models/patient.py
index 6f92c8b..5e3e654 100644
--- a/netforce_clinic/models/patient.py
+++ b/netforce_clinic/models/patient.py
@@ -2,6 +2,7 @@ import time
from netforce.model import Model, fields, get_model
from netforce.access import get_active_company, get_active_user, set_active_user
+from netforce.database import get_connection
from . import utils
@@ -91,7 +92,24 @@ class Patient(Model):
set_active_user(user_id)
return res
+ def _get_log(self,ids,context={}):
+ res={}
+ db=get_connection()
+ for obj in self.browse(ids):
+ for r in db.query("select create_time,create_uid,write_time,write_uid from clinic_patient where id = %s",obj.id):
+ res[obj.id]={
+ 'c_time': r['create_time'],
+ 'c_uid': r['create_uid'],
+ 'w_uid': r['write_uid'],
+ 'w_time': r['write_time'],
+ }
+ return res
+
_fields={
+ 'c_time': fields.DateTime("Created",function="_get_log", function_multi=True),
+ 'c_uid': fields.Many2One("base.user","Create By",function="_get_log", function_multi=True),
+ 'w_time': fields.DateTime("Edited",function="_get_log", function_multi=True),
+ 'w_uid': fields.Many2One("base.user","Lasted Edit",function="_get_log", function_multi=True),
"number": fields.Char("HN Number",required=True,search=True),
"trt_no": fields.Char("TRT",search=True),
"hn_no": fields.Char("HN",function="_get_hn_no",store=True),
diff --git a/netforce_clinic/models/report_labor_cost.py b/netforce_clinic/models/report_labor_cost.py
index 3c257d2..53eda76 100644
--- a/netforce_clinic/models/report_labor_cost.py
+++ b/netforce_clinic/models/report_labor_cost.py
@@ -295,11 +295,11 @@ class ReportLaborCost(Model):
'option_qty2': 'mode=list&search_domain=%s&tab_no=0'%replace_quote('%s'%(dom5)),
})
for dline in dlines[1:-1]:
- dlines[-1]['qty']+=float(dline['qty']) or 0
- dlines[-1]['qty2']+=float(dline['qty2']) or 0
+ dlines[-1]['qty']+=float((dline['qty'] or "").replace(",","")) or 0
+ dlines[-1]['qty2']+=float((dline['qty2'] or "").replace(",","")) or 0
dlines[-1]['total_qty']+=dline['total_qty'] or 0
dlines[-1]['cost']+=dline['cost'] or 0
- dlines[-1]['walkin_qty']+=float(dline['qty2']) or 0
+ dlines[-1]['walkin_qty']+=float((dline['qty2'] or "").replace(",","")) or 0
dlines[-1]['qty']="{0:,.2f}".format(round(dlines[-1]['qty'],2)) #total
dlines[-1]['qty2']="{0:,.2f}".format(round(dlines[-1]['qty2'],2)) #total
diff --git a/netforce_clinic/models/visit_board.py b/netforce_clinic/models/visit_board.py
index 5c2de28..84779e8 100644
--- a/netforce_clinic/models/visit_board.py
+++ b/netforce_clinic/models/visit_board.py
@@ -3,7 +3,7 @@ from calendar import monthrange
from datetime import datetime, timedelta
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
from . import utils
@@ -19,6 +19,16 @@ HD_STATE={
"cancelled":"Cancelled"
}
+DAYS={
+ 'mon': 0,
+ 'tue': 1,
+ 'wed': 2,
+ 'thu': 3,
+ 'fri': 4,
+ 'sat': 5,
+ 'sun': 6,
+}
+
class VisitBoard(Model):
_name="clinic.visit.board"
_string="Visit Board"
@@ -84,6 +94,51 @@ class VisitBoard(Model):
doctor_id=obj.doctor_id.id
department_id=obj.department_id.id
branch_id=obj.branch_id.id
+ def auto_gen_visit(dom=[]):
+ def daterange(start_date, end_date):
+ for n in range(int ((end_date - start_date).days)):
+ yield start_date + timedelta(n)
+ def convert_date(date_txt):
+ try:
+ if not date_txt:
+ raise Exception("Date Empty")
+ return datetime.strptime(date_txt,"%Y-%m-%d")
+ except:
+ raise Exception("Wrong Format Date")
+ # IMPROVE
+ # check day of week of this day
+ for date in daterange(convert_date(date_from),convert_date(date_to)+timedelta(days=1)):
+ weekday=date.weekday()
+ date_txt=date.strftime("%Y-%m-%d")
+ for pt in get_model("clinic.patient").search_browse(dom):
+ for pc in pt.cycles:
+ w=DAYS.get(pc.day,0) #default monday
+ cycle=pc.cycle_id
+ department=pc.department_id
+ if weekday==w:
+ dom2=[
+ ['visit_date','>=',date_txt],
+ ['visit_date','<=',date_txt],
+ ['patient_id','=',pt.id],
+ ['cycle_id','=',cycle.id],
+ ['department_id','=',department.id],
+ ]
+ res=get_model("clinic.visit").search(dom2)
+ # create visit auto
+ if not res:
+ vals={
+ 'patient_id': pt.id,
+ 'department_id': department.id,
+ 'cycle_id': cycle.id,
+ 'doctor_id': pt.doctor_id.id,
+ 'branch_id': department.branch_id.id,
+ 'time_start': '%s %s:00'%(date_txt,cycle.time_start),
+ 'time_stop': '%s %s:00'%(date_txt,cycle.time_stop),
+ 'visit_date': date_txt,
+ 'state': 'pending',
+ }
+ visit_id=get_model("clinic.visit").create(vals)
+ print('create new visit %s for %s'%(visit_id,pt.name))
time_start='%s 00:00:00'%(date_from)
time_stop='%s 23:59:59'%(date_to)
dom=[]
@@ -99,6 +154,11 @@ class VisitBoard(Model):
dom.append(['department_id','=',department_id])
if branch_id:
dom.append(['branch_id','=',branch_id])
+ #gen visit
+ if department_id:
+ auto_gen_visit(dom=[['department_id','=',department_id]])
+ elif branch_id:
+ auto_gen_visit(dom=[['branch_id','=',branch_id]])
lines=[]
empty_line={
'no': '',