diff --git a/netforce_clinic/actions/clinic_gen_visit_form.xml b/netforce_clinic/actions/clinic_gen_visit_form.xml
new file mode 100644
index 0000000..6137987
--- /dev/null
+++ b/netforce_clinic/actions/clinic_gen_visit_form.xml
@@ -0,0 +1,6 @@
+
+ Generate Visit
+ form_view
+ clinic.gen.visit
+ clinic_menu
+
diff --git a/netforce_clinic/actions/clinic_hd_case.xml b/netforce_clinic/actions/clinic_hd_case.xml
index 43c34eb..d0caf61 100644
--- a/netforce_clinic/actions/clinic_hd_case.xml
+++ b/netforce_clinic/actions/clinic_hd_case.xml
@@ -1,5 +1,5 @@
- Treatments
+ HD Cases
multi_view
clinic.hd.case
[["All",[]],["Draft",[["state","=","draft"]]],["In Progress",[["state","=","in_progress"]]],["Waiting Payment",[["state","=","waiting_payment"]]],["Completed",[["state","=","completed"]]],["In Completed",[["state","=","in_completed"]]]]
diff --git a/netforce_clinic/layouts/clinic_gen_visit_form.xml b/netforce_clinic/layouts/clinic_gen_visit_form.xml
index e5fc08b..ef455c7 100644
--- a/netforce_clinic/layouts/clinic_gen_visit_form.xml
+++ b/netforce_clinic/layouts/clinic_gen_visit_form.xml
@@ -1,28 +1,46 @@
diff --git a/netforce_clinic/layouts/clinic_hd_case_form.xml b/netforce_clinic/layouts/clinic_hd_case_form.xml
index 393afc5..9faddee 100644
--- a/netforce_clinic/layouts/clinic_hd_case_form.xml
+++ b/netforce_clinic/layouts/clinic_hd_case_form.xml
@@ -56,11 +56,6 @@
-
-
-
-
-
@@ -83,8 +78,20 @@
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/netforce_clinic/layouts/clinic_hd_case_list.xml b/netforce_clinic/layouts/clinic_hd_case_list.xml
index fd09d59..8a61ee5 100644
--- a/netforce_clinic/layouts/clinic_hd_case_list.xml
+++ b/netforce_clinic/layouts/clinic_hd_case_list.xml
@@ -5,15 +5,11 @@
-
-
-
-
diff --git a/netforce_clinic/layouts/clinic_menu.xml b/netforce_clinic/layouts/clinic_menu.xml
index a6534cc..3c06500 100644
--- a/netforce_clinic/layouts/clinic_menu.xml
+++ b/netforce_clinic/layouts/clinic_menu.xml
@@ -20,13 +20,13 @@
-
-
+
-
+
-
@@ -39,6 +39,7 @@
-
+
diff --git a/netforce_clinic/models/__init__.py b/netforce_clinic/models/__init__.py
index 2ebc8af..6c35c87 100644
--- a/netforce_clinic/models/__init__.py
+++ b/netforce_clinic/models/__init__.py
@@ -19,6 +19,7 @@ from . import visit_line
from . import visit_plan
from . import hd_case
from . import hd_case_line
+from . import hd_case_personal
from . import hd_case_gmline
from . import hd_case_discont
from . import hd_case_payment
diff --git a/netforce_clinic/models/gen_visit.py b/netforce_clinic/models/gen_visit.py
index 5011478..a1edf8e 100644
--- a/netforce_clinic/models/gen_visit.py
+++ b/netforce_clinic/models/gen_visit.py
@@ -23,7 +23,8 @@ class GenVisit(Model):
'date_from': fields.DateTime("From", required=True),
'date_to': fields.DateTime("To", required=True),
'cycle_id': fields.Many2One("clinic.cycle","Cycle", required=True),
- 'lines': fields.One2Many("clinic.gen.visit.line","gen_id","Lines"),
+ 'patient_lines': fields.One2Many("clinic.gen.visit.line","gen_id","Patient Lines"),
+ 'nurse_lines': fields.One2Many("clinic.gen.visit.line","gen_id","Nurse Lines"),
'monday': fields.Boolean("Monday"),
'tuesday': fields.Boolean("Tuesdays"),
'wednesday': fields.Boolean("Wednesdays"),
@@ -35,14 +36,19 @@ class GenVisit(Model):
'nurse_id': fields.Many2One("clinic.nurse","Nurse"),
'department_id': fields.Many2One("clinic.department","Department"),
'duration': fields.Integer("Duration (hrs)", function="_get_duration"),
+ "patient_type": fields.Selection([("mg","Medical Government"),("sc","Social Security"),("nhso","NHSO (30฿)"),("personal","Personal"),("others","Others")],"Patient Type"),
+ 'nurse_categ_id': fields.Many2One("clinic.personal.categ", "Nurse Category", domain=[['type','=','nurse']]),
}
- def _get_lines(self,context={}):
+ def _get_patient_lines(self,context={}):
ids=context.get("ids")
if not ids:
ids=[context.get("refer_id")]
- lines=[{'patient_id': id} for id in ids]
+ lines=[]
+ # XXX [None]
+ if any(ids):
+ lines=[{'patient_id': id} for id in ids]
return lines
def _get_nurse(self,context={}):
@@ -60,9 +66,9 @@ class GenVisit(Model):
return cycle_id or None
_defaults={
- 'lines': _get_lines,
+ 'patient_lines': _get_patient_lines,
'date_from': lambda *a: datetime.now().strftime(FMT_DATETIME),
- 'date_to': lambda *a: datetime.now().strftime(FMT_DATETIME),
+ 'date_to': lambda *a: (datetime.now()+timedelta(days=7)).strftime(FMT_DATETIME),
'nurse_id': _get_nurse,
'duration': 1,
'cycle_id': _get_cycle,
@@ -107,7 +113,13 @@ class GenVisit(Model):
visit_vals=[]
date_from=datetime.strptime(obj.date_from,FMT_DATETIME)
date_to=datetime.strptime(obj.date_to,FMT_DATETIME)
- for line in obj.lines:
+ patients=[p.patient_id.id for p in obj.patient_lines]
+ if not patients and obj.patient_type:
+ patients=get_model("clinic.patient").search([['type','=',obj.patient_type]])
+ else:
+ raise Exception("Please select some patient or patient type")
+
+ for patient_id in patients:
ntoday=1
day_total=(date_to-date_from).days+ntoday
for weekday in days:
@@ -124,7 +136,7 @@ class GenVisit(Model):
while count < day_total:
tmp=start_date+timedelta(days=count)
vals={
- 'patient_id': line.patient_id.id,
+ 'patient_id': patient_id,
'doctor_id': obj.doctor_id.id,
'nurse_id': obj.nurse_id.id,
'department_id': obj.department_id.id,
@@ -139,7 +151,7 @@ class GenVisit(Model):
dom=[]
dom.append(['time_start','>=','%s %s'%(tmp.strftime(FMT_DATE)[0:10],' 00:00:00')])
dom.append(['time_stop','<=','%s %s'%(tmp.strftime(FMT_DATE)[0:10],' 23:59:59')])
- dom.append(['patient_id', '=', line.patient_id.id])
+ dom.append(['patient_id', '=', patient_id])
dom.append(['cycle_id', '=', obj.cycle_id.id]) #XXX
dom.append(['state','=','draft'])
vids=visit_obj.search(dom)
@@ -151,7 +163,7 @@ class GenVisit(Model):
return {
'next': {
- 'name': 'clinic_patient',
+ 'name': 'clinic_visit',
'mode': 'list',
},
'flash': 'Generate OK',
@@ -171,8 +183,13 @@ class GenVisit(Model):
date_from=datetime.strptime(obj.date_from,FMT_DATETIME)
date_to=datetime.strptime(obj.date_to,FMT_DATETIME)
visit_obj=get_model("clinic.visit")
+ patients=[p.patient_id.id for p in obj.patient_lines]
+ if not patients and obj.patient_type:
+ patients=get_model("clinic.patient").search([['type','=',obj.patient_type]])
+ else:
+ raise Exception("Please select some patient or patient type")
if days:
- for line in obj.lines:
+ for patient_id in patients:
# loop days in weekend
ntoday=1
day_total=(date_to-date_from).days+ntoday
@@ -191,7 +208,6 @@ class GenVisit(Model):
tmp=start_date+timedelta(days=count)
time_start="%s 00:00:00" % (tmp.strftime(FMT_DATE))
time_stop="%s 23:59:59" % (tmp.strftime(FMT_DATE))
- patient_id=line.patient_id.id
dom=[]
dom.append(['time_start','>=','%s'%time_start])
dom.append(['time_stop','<=','%s'%time_stop])
@@ -206,8 +222,7 @@ class GenVisit(Model):
else:
time_start=obj.date_from
time_stop=obj.date_to
- for line in obj.lines:
- patient_id=line.patient_id.id
+ for patient_id in patients:
dom=[]
dom.append(['time_start','>=','%s'%time_start])
dom.append(['time_stop','<=','%s'%time_stop])
@@ -221,31 +236,12 @@ class GenVisit(Model):
get_model("clinic.visit").delete(visit_ids)
return {
'next': {
- 'name': 'clinic_patient',
+ 'name': 'clinic_visit',
'mode': 'list',
},
'flash': 'Clear OK',
}
- def _clear_visit(self,ids,context):
- obj=self.browse(ids)[0]
- visit_obj=get_model("clinic.visit")
- for line in obj.lines:
- patient_id=line.patient_id
- dom=[]
- dom.append(['patient_id','=',patient_id.id])
- dom.append(['state','=','draft'])
- # clear
- # only from to and day
- visit_ids=visit_obj.search(dom)
- visit_obj.delete(visit_ids)
- return {
- 'next': {
- 'name': 'clinic_patient',
- 'mode': 'list',
- },
- 'flash': 'Clear OK',
- }
GenVisit.register()
diff --git a/netforce_clinic/models/gen_visit_line.py b/netforce_clinic/models/gen_visit_line.py
index e9bfd01..4a37ebc 100644
--- a/netforce_clinic/models/gen_visit_line.py
+++ b/netforce_clinic/models/gen_visit_line.py
@@ -7,7 +7,9 @@ class GenVisitLine(Model):
_fields={
'gen_id': fields.Many2One("clinic.gen.visit","gen_id","Gen Visit"),
'patient_id': fields.Many2One("clinic.patient","Patient"),
+ 'nurse_id': fields.Many2One("clinic.personal","Nurse", domain=[['type','=','nurse']]),
}
+
GenVisitLine.register()
diff --git a/netforce_clinic/models/hd_case.py b/netforce_clinic/models/hd_case.py
index c9e134a..d5e225c 100644
--- a/netforce_clinic/models/hd_case.py
+++ b/netforce_clinic/models/hd_case.py
@@ -8,7 +8,7 @@ from netforce.access import get_active_company
class HDCase(Model):
_name="clinic.hd.case"
- _string="Treatment"
+ _string="HD Case"
_audit_log=True
_name_field="number"
_multi_company=True
@@ -35,7 +35,6 @@ class HDCase(Model):
"date": fields.Date("Time stop",required=True,search=True),
"patient_id": fields.Many2One("clinic.patient","Patient",required=True,search=True),
"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),
"wh_start": fields.Float("Wt.Kg start"),
"wh_stop": fields.Float("Wt.Kg stop"),
@@ -52,6 +51,7 @@ class HDCase(Model):
"state": fields.Selection([("draft","Draft"),("in_progress","In Progress"),("completed","Completed"),("waiting_payment","Waiting Payment"),("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"),
+ "personals": fields.One2Many("clinic.hd.case.personal","hd_case_id","Personals"),
"comments": fields.One2Many("message","related_id","Comments"), "company_id": fields.Many2One("company","Company"),
"amount": fields.Float("Due Amount",function="get_total",readonly=True,function_multi=True),
"total": fields.Float("Total",function="get_total",readonly=True,function_multi=True),
@@ -73,6 +73,8 @@ class HDCase(Model):
'pay_account_id': fields.Many2One("account.account","Account"),
'payment_id': fields.Many2One("account.payment","Payment"), # for print
'dlz_id': fields.Many2One("clinic.dialyzer","Dialyzer"), # for link
+ "total_doctor": fields.Integer("Total Doctor",function="get_personal",function_multi=True),
+ "total_nurse": fields.Integer("Total Nurse",function="get_personal",function_multi=True),
}
def _get_number(self,context={}):
@@ -89,20 +91,11 @@ class HDCase(Model):
return num
get_model("sequence").increment_number(seq_id,context=context)
- def _get_nurse(self,context={}):
- user_id=get_active_user()
- print("user_id ",user_id)
- nurse_ids=get_model("clinic.nurse").search([['user_id','=',user_id]])
- if nurse_ids:
- return nurse_ids[0]
- return None
-
_defaults={
"state": "draft",
"date": lambda *a: time.strftime("%Y-%m-%d"),
"time_start": lambda *a: time.strftime("%Y-%m-%d %H:%M:%S"),
"time_stop": lambda *a: time.strftime("%Y-%m-%d %H:%M:%S"),
- 'nurse_id': _get_nurse,
"number": _get_number,
"company_id": lambda *a: get_active_company(),
'hct': 0,
@@ -142,14 +135,13 @@ class HDCase(Model):
data=context['data']
patient_id=data['patient_id']
hd_cases=self.search_browse([['patient_id','=',patient_id]])
- # TODO reset dialyzer
if hd_cases:
hd_case=hd_cases[-1]
- data['doctor_id']=hd_case.doctor_id.id
data['department_id']=hd_case.department_id.id
else:
- data['doctor_id']=None
data['department_id']=None
+ #XXX
+ data['dialyzers']=[]
return data
@@ -687,5 +679,22 @@ class HDCase(Model):
obj=self.browse(ids)[0]
context['state']='draft'
obj.undo(context=context)
+
+ def get_personal(self,ids,context={}):
+ res={}
+ for obj in self.browse(ids):
+ doctor=0
+ nurse=0
+ for personal in obj.personals:
+ if personal.type=="doctor":
+ doctor+= 1
+ else:
+ nurse+=1
+ res[obj.id]={
+ 'total_doctor': doctor,
+ 'total_nurse': nurse,
+ }
+ return res
+
HDCase.register()
diff --git a/netforce_clinic/models/hd_case_personal.py b/netforce_clinic/models/hd_case_personal.py
new file mode 100644
index 0000000..0dc39a1
--- /dev/null
+++ b/netforce_clinic/models/hd_case_personal.py
@@ -0,0 +1,19 @@
+from netforce.model import Model, fields
+
+class HdCasePersonal(Model):
+ _name="clinic.hd.case.personal"
+ _fields={
+ "hd_case_id": fields.Many2One("clinic.hd.case","HdCase",required=True,on_delete="cascade"),
+ "personal_id": fields.Many2One("clinic.personal","Personal",search=True),
+ "type": fields.Selection([("doctor","Doctor"),('nurse','Nurse'),("other","Other")],"Type",required=True),
+ "priop": fields.Selection([("owner","Owner"),('other','Other')],"Priority"),
+ 'note': fields.Char("Note"),
+ }
+
+ _defaults={
+ 'type': 'nurse',
+ 'priop': 'other',
+ }
+
+HdCasePersonal.register()
+
diff --git a/netforce_clinic/models/patient.py b/netforce_clinic/models/patient.py
index 0b040d7..e8e6aa7 100644
--- a/netforce_clinic/models/patient.py
+++ b/netforce_clinic/models/patient.py
@@ -31,7 +31,7 @@ class Patient(Model):
_fields={
"type": fields.Selection([("mg","Medical Government"),("sc","Social Security"),("nhso","NHSO (30฿)"),("personal","Personal"),("others","Others")],"Patient Type",required=True),
"number": fields.Char("Patient No.",required=True,search=True),
- "hn": fields.Char("HN",search=True),
+ "hn": fields.Char("REF/HN",search=True),
"name": fields.Char("Name",required=True,search=True),
"reg_date": fields.Date("Register Date",required=False,search=True),
"birthday": fields.Date("Birthday",required=False,search=True),
diff --git a/netforce_clinic/models/personal.py b/netforce_clinic/models/personal.py
index 8dbfda9..414bc3a 100644
--- a/netforce_clinic/models/personal.py
+++ b/netforce_clinic/models/personal.py
@@ -27,7 +27,7 @@ class Personal(Model):
"expiry_card" : fields.Date("Card Expiry"),
"birthday": fields.Date("Birthday",search=True),
"age": fields.Integer("Age", function="_get_age"),
- "state": fields.Selection([["temporary","Temporary"],["permanent","Permanent"]],"Status"),
+ "state": fields.Selection([["temporary","Temporary"],["permanent","Permanent"]],"Status",search=True),
"type": fields.Selection([["doctor","Doctor"],["nurse","Nurse"],["other","Other"]],"Type"),
"mobile": fields.Char("Mobile",required=False,search=True),
"phone": fields.Char("Phone",search=True),
diff --git a/netforce_clinic/models/visit.py b/netforce_clinic/models/visit.py
index c6c47d1..6070379 100644
--- a/netforce_clinic/models/visit.py
+++ b/netforce_clinic/models/visit.py
@@ -24,6 +24,12 @@ class Visit(Model):
for obj in self.browse(ids):
res[obj.id]=datetime.now().strftime("%Y-%m-%d %H:%M:%S")
return res
+
+ def _get_color(self,ids,context={}):
+ res={}
+ for obj in self.browse(ids):
+ res[obj.id]='red'
+ return res
_fields={
"number": fields.Char("Number",required=True,search=True),
@@ -41,6 +47,7 @@ class Visit(Model):
"comments": fields.One2Many("message","related_id","Comments"),
'visit_date': fields.Date('Visit Date',function="_get_visit_date"),
'print_date': fields.Date('Print Date',function="_get_print_date"),
+ 'cycle_color': fields.Char("Cycle Color", function="_get_color"), # FIXME
}
def _get_number(self,context={}):
@@ -104,8 +111,6 @@ class Visit(Model):
obj=self.browse(ids)[0]
vals={
'patient_id': obj.patient_id.id,
- 'doctor_id': obj.doctor_id.id,
- 'nurse_id': obj.nurse_id.id,
'department_id': obj.department_id.id,
'time_start': obj.time_start,
'time_stop': obj.time_stop,
@@ -114,11 +119,10 @@ class Visit(Model):
'cycle_id': obj.cycle_id.id,
'lines':[],
'dialyzers': [],
+ 'personals': [],
'state': 'draft',
}
- # search dialyzer and count automatically
- # search Nurse with category
products=get_model("product").search_browse([['code','=','FEE']])
for product in products:
vals['lines'].append(('create',{
diff --git a/netforce_clinic/todo.txt b/netforce_clinic/todo.txt
index ba2924d..ee8c9e9 100644
--- a/netforce_clinic/todo.txt
+++ b/netforce_clinic/todo.txt
@@ -1,3 +1,6 @@
+after finish hd case -> show popup to check nurse and doctor after finish
+
formalar
tick:
find all -> replace -> multiple x
+