clinic/netforce_clinic/models/clinic_patient.py

101 lines
4.9 KiB
Python

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 Patient(Model):
_name="clinic.patient"
_string="Patient"
_audit_log=True
_name_field="name"
_multi_company=True
_fields={
"number": fields.Char("Number",required=True,search=True),
"name": fields.Char("Name Surname",required=True,search=True),
"date": fields.Date("Create Date",required=True,search=True),
"birthday": fields.Date("BirthDay",required=True,search=True),
"telephone": fields.Char("Telephone",required=True,search=True),
"mobile": fields.Char("Mobile",required=True,search=True),
"job": fields.Char("Job"),
"age": fields.Integer("Age"),
"weight": fields.Integer("Weight (cm)"),
"height": fields.Integer("Height (Kg)"),
"type": fields.Selection([("mg","Medical Govement"),("sc","Social Security"),("nhso","NHSO (30฿)"),("personal","Personal"),("other","Other")],"Type",required=True),
"card_type": fields.Selection([("iden_id","Identity Card"),("passport","Passport")],"ID From",required=True),
'iden_id' : fields.Char("Identity ID"),
"app_no": fields.Char("Application No."),
"salary": fields.Float("Salary"),
'exp_id' : fields.Date("Expiry Date"),
"state": fields.Selection([("draft","Draft"),("active","Active"),("deactive","Deactive")],"Status",required=True),
"addresses": fields.One2Many("address","related_id","Addresses"),
"gender": fields.Selection([("male","Male"),("female","Female")],"Gendel",required=True),
"marital_status": fields.Selection([("single","Single"),("marry","Marry"),("divorce","Divorce"),("separated","Saparated"),("widowed","Widowed")],"Marital Status",required=True),
"nationality": fields.Char("Nationality",search=True),
"race": fields.Char("Race",search=True),
"smoke": fields.Boolean("Smoke ?"),
"first_hemodialysis": fields.Date("First time Hemodialysis",required=True),
"hemodialysis": fields.Char("First Hemodialysis",required=True),
"clinic_after": fields.Selection([("small","Small"),("medium","Medium"),("large","Large")],"Clinic Lastime",required=True),
"clinic_after_name": fields.Char("Clinic after name",required=True),
"first_permanent_vascular_access": fields.Date("First time Permanent Vascular",required=True),
"first_tenckhoff_catheters": fields.Date("First time Tenckhoff Catheters",required=True),
"start_date_clinic": fields.Date("Start Date Clinic",required=True),
"waiting_transplantation": fields.Boolean("Kidney Transplantation Waiting ?"),
"who_transplantation": fields.Char("Who is Transplantation?"),
"reason_of_chronic_renal_failure": fields.Char("Reason chronic renal failure ?"),
"ac_mi": fields.Boolean("Acute MI"),
"co_an": fields.Boolean("Coronary Angioplasty"),
"ce_ac": fields.Boolean("Cerebrovascular Accident"),
"pvd": fields.Boolean("PVD or Amputation"),
"co_he": fields.Boolean("Congestive heart failure"),
"hypertnsion": fields.Boolean("Hypertension"),
"dia": fields.Boolean("Diabetes"),
"copd": fields.Boolean("Copd"),
"asthma": fields.Boolean("Asthma"),
"pul_tub": fields.Boolean("Pulmonary tuberculosis"),
"cancer": fields.Boolean("Cancer"),
"cirrhosis": fields.Boolean("Cirrhosis"),
"dyslip": fields.Boolean("Dyslipidemia"),
"prca": fields.Boolean("PRCA"),
"hyperucemia": fields.Boolean("Hyperurinencemia"),
"cga": fields.Boolean("Chronic gouty arthitis"),
"parathy": fields.Boolean("Parathyroidectomy"),
"comarbid": fields.Char("Co-morbid 1"),
"comarbid2": fields.Char("Co-morbid 2"),
"comments": fields.One2Many("message","related_id","Comments"),
"company_id": fields.Many2One("company","Company"),
"doctorsss": fields.Many2Many("clinic.doctor","Doctors"),
"nurses": fields.Many2Many("clinic.nurse","Nurses"),
"visits": fields.One2Many("clinic.visit","patient_id","Visits"),
"hd_cases": fields.One2Many("clinic.hd.case","patient_id","HD Cases"),
}
def _get_number(self,context={}):
while 1:
num=get_model("sequence").get_number("clinic_patient")
if not num:
return None
res=self.search([["number","=",num]])
if not res:
return num
get_model("sequence").increment("clinic_patient")
_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]
obj.write({"state":"voided"})
Patient.register()