Guest User

Untitled

a guest
Sep 22nd, 2016
65
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class Appointment(ModelSQL, ModelView):
  2. 'Patient Appointments'
  3. __name__ = 'gnuhealth.appointment'
  4.  
  5.  
  6. insurance = fields.Function(fields.Char('Insurance'), 'get_insurance')
  7.  
  8. insurancecode = fields.Function(fields.Char('Insurance'), 'get_insurancecode')
  9.  
  10. insurancenumber = fields.Function(fields.Char('Insurance'), 'get_insurancenumber')
  11.  
  12. codenomenclador = fields.Function(fields.Char('Nomenclador'), 'get_nomenclador')
  13.  
  14. tipo = fields.Function(fields.Char('Nomenclador'), 'get_tipo')
  15.  
  16. def get_insurance(self, name):
  17. res = ''
  18. if self.patient.current_insurance:
  19. res = self.patient.current_insurance.company.name
  20. return res
  21.  
  22. def get_insurancenumber(self, name):
  23. res = ''
  24. if self.patient.current_insurance:
  25. res = self.patient.current_insurance.number
  26. return res
  27.  
  28. def get_insurancecode(self, name):
  29. res = ''
  30. if self.patient.current_insurance:
  31. res = self.patient.current_insurance.company.ref
  32. return res
  33.  
  34. def get_nomenclador(self, name):
  35. res = ''
  36. pool = Pool()
  37. if (self.healthprof and self.healthprof.main_specialty):
  38. hp_main_specialty = self.healthprof.main_specialty.specialty.id
  39. hprof_id = self.healthprof.id
  40.  
  41. hp_specialty_obj = Pool().get('gnuhealth.hp_specialty')
  42. hp_spec = hp_specialty_obj.search(
  43. [('name', '=', hprof_id)], limit=1)[0]
  44. if hp_spec.nomenclador:
  45. hp_nomenclador = hp_spec.nomenclador.codigo
  46. res = hp_nomenclador
  47.  
  48. return res
  49.  
  50.  
  51. def get_tipo(self, name):
  52. res = ''
  53. pool = Pool()
  54. if (self.healthprof and self.healthprof.main_specialty):
  55. hp_main_specialty = self.healthprof.main_specialty.specialty.id
  56. hprof_id = self.healthprof.id
  57.  
  58. hp_specialty_obj = Pool().get('gnuhealth.hp_specialty')
  59. hp_spec = hp_specialty_obj.search(
  60. [('name', '=', hprof_id)], limit=1)[0]
  61. if hp_spec.nomenclador:
  62. tipo_nomenclador = hp_spec.nomenclador.tipo
  63. res = tipo_nomenclador
  64.  
  65. return res
RAW Paste Data