2014-08-19 11:36:46 +00:00
|
|
|
import time
|
2014-10-01 08:48:58 +00:00
|
|
|
|
|
|
|
from netforce.model import Model, fields, get_model
|
2014-10-02 01:12:46 +00:00
|
|
|
from netforce.access import get_active_company, get_active_user, set_active_user
|
2014-08-19 11:36:46 +00:00
|
|
|
|
|
|
|
class Doctor(Model):
|
|
|
|
_name="clinic.doctor"
|
|
|
|
_string="Doctor"
|
|
|
|
_audit_log=True
|
|
|
|
_multi_company=True
|
2014-10-01 16:14:52 +00:00
|
|
|
|
|
|
|
def _get_age(self,ids,context):
|
|
|
|
res={}
|
|
|
|
year_now=int(time.strftime("%Y"))
|
|
|
|
for obj in self.browse(ids):
|
|
|
|
age=0
|
|
|
|
if obj.birthday:
|
|
|
|
year_bd=int(obj.birthday[0:4])
|
|
|
|
age=year_now-year_bd
|
|
|
|
res[obj.id]=age
|
|
|
|
return res
|
|
|
|
|
2014-08-19 11:36:46 +00:00
|
|
|
_fields={
|
2014-10-01 07:50:42 +00:00
|
|
|
"number": fields.Char("Doctor No.",required=True,search=True),
|
2014-10-01 10:52:21 +00:00
|
|
|
"name": fields.Char("Name",required=True,search=True),
|
2014-10-01 16:14:52 +00:00
|
|
|
"identification" : fields.Char("Identification"),
|
2014-10-02 01:12:46 +00:00
|
|
|
"expiry_card" : fields.Date("Card Expiry"),
|
2014-10-01 16:14:52 +00:00
|
|
|
"birthday": fields.Date("Birthday",search=True),
|
|
|
|
"age": fields.Integer("Age", function="_get_age"),
|
|
|
|
"type": fields.Selection([["temporary","Temporary"],["permanent","Permanent"]],"Type"),
|
2014-10-01 07:50:42 +00:00
|
|
|
"mobile": fields.Char("Mobile",required=False,search=True),
|
2014-10-01 16:14:52 +00:00
|
|
|
"phone": fields.Char("Phone",search=True),
|
|
|
|
'email': fields.Char("Email"),
|
2014-10-04 15:51:54 +00:00
|
|
|
"prof_license" : fields.Char("License."),
|
|
|
|
"prof_license_date" : fields.Date("License Date"),
|
2014-10-01 09:30:37 +00:00
|
|
|
"birthday": fields.Date("BirthDay",search=True),
|
|
|
|
"department_id": fields.Many2One("clinic.department", "Department",search=True),
|
2014-10-01 16:14:52 +00:00
|
|
|
"patients": fields.Many2Many("clinic.patient","Patients"),
|
2014-10-01 10:52:21 +00:00
|
|
|
"addresses": fields.One2Many("address","related_id","Addresses"),
|
|
|
|
"comments": fields.One2Many("message","related_id","Comments"),
|
|
|
|
"visits": fields.One2Many("clinic.visit","nurse_id","Visits"),
|
2014-10-01 16:14:52 +00:00
|
|
|
"hd_cases": fields.One2Many("clinic.hd.case","nurse_id","HD Cases"),
|
2014-10-01 10:52:21 +00:00
|
|
|
"company_id": fields.Many2One("company","Company"),
|
2014-10-01 16:14:52 +00:00
|
|
|
"user_id": fields.Many2One("base.user","User"),
|
|
|
|
'picture': fields.File("Picture"),
|
2014-10-04 15:51:54 +00:00
|
|
|
'note': fields.Text("Note"),
|
2014-10-26 15:17:56 +00:00
|
|
|
'categ_id': fields.Many2One("clinic.personal.categ", "Doctor Category", domain=[['type','=','doctor']]),
|
2014-08-19 11:36:46 +00:00
|
|
|
}
|
|
|
|
|
2014-10-02 01:12:46 +00:00
|
|
|
|
2014-08-19 11:36:46 +00:00
|
|
|
def _get_number(self,context={}):
|
|
|
|
while 1:
|
2014-10-02 01:12:46 +00:00
|
|
|
seq_id=get_model("sequence").find_sequence(name="Clinic Doctor")
|
|
|
|
num=get_model("sequence").get_next_number(seq_id,context=context)
|
2014-08-19 11:36:46 +00:00
|
|
|
if not num:
|
|
|
|
return None
|
2014-10-02 01:12:46 +00:00
|
|
|
user_id=get_active_user()
|
|
|
|
set_active_user(1)
|
2014-08-19 11:36:46 +00:00
|
|
|
res=self.search([["number","=",num]])
|
2014-10-02 01:12:46 +00:00
|
|
|
set_active_user(user_id)
|
2014-08-19 11:36:46 +00:00
|
|
|
if not res:
|
|
|
|
return num
|
2014-10-02 01:12:46 +00:00
|
|
|
get_model("sequence").increment_number(seq_id,context=context)
|
2014-08-19 11:36:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
_defaults={
|
2014-10-01 10:52:21 +00:00
|
|
|
"type": "temporary",
|
2014-08-19 11:36:46 +00:00
|
|
|
"date": lambda *a: time.strftime("%Y-%m-%d"),
|
|
|
|
"number": _get_number,
|
|
|
|
"company_id": lambda *a: get_active_company(),
|
|
|
|
}
|
|
|
|
_order="date desc,number desc"
|
|
|
|
|
|
|
|
|
|
|
|
def void(self,ids,context={}):
|
|
|
|
obj=self.browse(ids)[0]
|
2014-10-01 10:52:21 +00:00
|
|
|
obj.write({"state":"voided"})
|
|
|
|
|
2014-08-19 11:36:46 +00:00
|
|
|
Doctor.register()
|