2014-08-19 11:36:46 +00:00
|
|
|
from netforce.model import Model, fields, get_model
|
|
|
|
from netforce.utils import get_data_path
|
|
|
|
import time
|
|
|
|
from netforce.access import get_active_user
|
|
|
|
from netforce.access import get_active_company
|
|
|
|
|
|
|
|
class Doctor(Model):
|
|
|
|
_name="clinic.doctor"
|
|
|
|
_string="Doctor"
|
|
|
|
_audit_log=True
|
|
|
|
_name_field="name"
|
|
|
|
_multi_company=True
|
|
|
|
_fields={
|
2014-10-01 07:50:42 +00:00
|
|
|
"number": fields.Char("Doctor No.",required=True,search=True),
|
|
|
|
"name": fields.Char("First name",required=True,search=True),
|
|
|
|
"last_name" : fields.Char("Last name",required=False),
|
2014-08-19 11:36:46 +00:00
|
|
|
"date": fields.Date("Create Date",required=True,search=True),
|
2014-10-01 07:50:42 +00:00
|
|
|
"card_id" : fields.Char("Identity ID"),
|
|
|
|
"card_expire" : fields.Date("Expire Date"),
|
|
|
|
"birthday": fields.Date("Date of birth",required=False,search=True),
|
|
|
|
"telephone": fields.Char("Telephone",required=False,search=True),
|
|
|
|
"department": fields.Selection([("temporary","Temporary"),("permanent","Permanent")], "Dapartment"),
|
|
|
|
"mobile": fields.Char("Mobile",required=False,search=True),
|
|
|
|
#"licen" : fields.char("licens medicine No."),
|
|
|
|
"number2" : fields.Char("Licen medical No."),
|
|
|
|
"licen_issued" : fields.Date("Issued on"),
|
2014-08-19 11:36:46 +00:00
|
|
|
"state": fields.Selection([("draft","Draft"),("active","Active"),("deactive","Deactive")],"Status",required=True),
|
2014-10-01 07:50:42 +00:00
|
|
|
"addresses" : fields.One2Many("address","related_id","Addresses"),
|
|
|
|
"comments" : fields.One2Many("message","related_id","Comments"),
|
|
|
|
"patients" : fields.Many2Many("clinic.patient","Patients"),
|
|
|
|
"visits" : fields.One2Many("clinic.visit","doctor_id","Visits"),
|
|
|
|
"hd_cases" : fields.One2Many("clinic.hd.case","doctor_id","HD Cases"),
|
|
|
|
"company_id" : fields.Many2One("company","Company"),
|
2014-08-19 11:36:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
def _get_number(self,context={}):
|
|
|
|
while 1:
|
|
|
|
num=get_model("sequence").get_number("sale_order")
|
|
|
|
if not num:
|
|
|
|
return None
|
|
|
|
res=self.search([["number","=",num]])
|
|
|
|
if not res:
|
|
|
|
return num
|
2014-10-01 07:50:42 +00:00
|
|
|
get_model("sequence") .increment("sale_order")
|
2014-08-19 11:36:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
_defaults={
|
|
|
|
"state": "draft",
|
|
|
|
"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 07:50:42 +00:00
|
|
|
obj.write({"state":"voided "})
|
2014-08-19 11:36:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
Doctor.register()
|