2015-01-15 07:37:36 +00:00
|
|
|
from netforce.model import Model, fields
|
|
|
|
|
|
|
|
class PatientCycle(Model):
|
|
|
|
_name="clinic.patient.cycle"
|
|
|
|
_string="Patient Cycle"
|
|
|
|
|
|
|
|
_fields={
|
2015-03-02 04:03:07 +00:00
|
|
|
"patient_id": fields.Many2One('clinic.patient',"Patient",required=True,on_delete="cascade",search=True,domain=[['state','=','admit']]),
|
2015-01-15 07:37:36 +00:00
|
|
|
"cycle_id": fields.Many2One('clinic.cycle',"Cycle",search=True),
|
2015-01-15 08:45:11 +00:00
|
|
|
"department_id": fields.Many2One('clinic.department',"Department",search=True),
|
2015-01-16 04:47:11 +00:00
|
|
|
'day': fields.Selection([('mon', 'Monday'), ('tue','Tuesday'), ('wed','Wednesday'),('thu','Thursday'),('fri','Friday'),('sat','Saturday'),('sun','Sunday')], 'Day',search=True),
|
2015-01-15 07:37:36 +00:00
|
|
|
}
|
2015-05-07 05:08:51 +00:00
|
|
|
|
|
|
|
def _get_department(self,context={}):
|
|
|
|
data=context.get('data')
|
|
|
|
if data and data.get('department_id'):
|
|
|
|
return data['department_id']
|
|
|
|
|
|
|
|
_defaults={
|
|
|
|
'department_id': _get_department,
|
|
|
|
}
|
|
|
|
|
2015-02-02 06:48:25 +00:00
|
|
|
_sql_constraints=("pcycle_uniq","unique(patient_id,cycle_id,day,department_id)","patient_id,cycle_id,day,department_id should be unique"),
|
2015-05-07 05:08:51 +00:00
|
|
|
_order="department_id,cycle_id"
|
2015-01-15 07:37:36 +00:00
|
|
|
|
|
|
|
PatientCycle.register()
|