From 4c783eccd8cc4ae4df17c471a323e2f94f260eb0 Mon Sep 17 00:00:00 2001 From: "watcha.h@almacom.co.th" Date: Tue, 13 Jan 2015 14:56:30 +0700 Subject: [PATCH] hn & hct --- .../layouts/clinic_hd_case_form.xml | 5 +++-- .../layouts/clinic_patient_form.xml | 4 ++-- .../layouts/clinic_patient_list.xml | 2 +- .../layouts/clinic_patient_type_form.xml | 17 ++++++++++++----- netforce_clinic/models/hd_case.py | 12 ++++++++++++ netforce_clinic/models/patient.py | 18 ++++++++++++------ netforce_clinic/models/patient_type.py | 1 + 7 files changed, 43 insertions(+), 16 deletions(-) diff --git a/netforce_clinic/layouts/clinic_hd_case_form.xml b/netforce_clinic/layouts/clinic_hd_case_form.xml index a9c81ed..209faf0 100644 --- a/netforce_clinic/layouts/clinic_hd_case_form.xml +++ b/netforce_clinic/layouts/clinic_hd_case_form.xml @@ -19,6 +19,7 @@ + @@ -32,8 +33,8 @@ - - + + diff --git a/netforce_clinic/layouts/clinic_patient_form.xml b/netforce_clinic/layouts/clinic_patient_form.xml index d436d41..55a2c07 100644 --- a/netforce_clinic/layouts/clinic_patient_form.xml +++ b/netforce_clinic/layouts/clinic_patient_form.xml @@ -4,14 +4,14 @@ - + diff --git a/netforce_clinic/layouts/clinic_patient_list.xml b/netforce_clinic/layouts/clinic_patient_list.xml index 1729196..740b596 100644 --- a/netforce_clinic/layouts/clinic_patient_list.xml +++ b/netforce_clinic/layouts/clinic_patient_list.xml @@ -4,7 +4,7 @@ - + diff --git a/netforce_clinic/layouts/clinic_patient_type_form.xml b/netforce_clinic/layouts/clinic_patient_type_form.xml index d1473fb..6696343 100644 --- a/netforce_clinic/layouts/clinic_patient_type_form.xml +++ b/netforce_clinic/layouts/clinic_patient_type_form.xml @@ -4,9 +4,16 @@ - - - - - + + + + + + + + + + + + diff --git a/netforce_clinic/models/hd_case.py b/netforce_clinic/models/hd_case.py index 59b7097..b4f9119 100644 --- a/netforce_clinic/models/hd_case.py +++ b/netforce_clinic/models/hd_case.py @@ -57,6 +57,15 @@ class HDCase(Model): patient=obj.patient_id res[obj.id]=patient.type_id.id return res + + def _get_hct_include(self,ids,context={}): + res={} + for obj in self.browse(ids): + include=False + if obj.patient_id.type_id.hct_include: + include=True + res[obj.id]=include + return res _fields={ "number": fields.Char("Number",required=True,search=True), @@ -81,6 +90,7 @@ class HDCase(Model): "ultrafittration": fields.Float("Ultrafittration (kg.)"), "hct": fields.Integer("Hct",required=True), "hct_msg" : fields.Char(""), + 'hct_include': fields.Boolean("HCT Include", function="_get_hct_include",store=True), "state": fields.Selection([("draft","Draft"),('waiting_treatment','Waiting Treatment'),("in_progress","In Progress"),("completed","Finish Treatment"),('paid','Paid'),("waiting_payment","Waiting Payment"),("discountinued","Discountinued"),("cancelled","Cancelled")],"Status",required=True), "staffs": fields.One2Many("clinic.hd.case.staff","hd_case_id","Staffs"), "comments": fields.One2Many("message","related_id","Comments"), "company_id": fields.Many2One("company","Company"), @@ -977,6 +987,7 @@ class HDCase(Model): patient=get_model("clinic.patient").browse(patient_id) vals['branch_id']=patient.branch_id.id new_id=super().create(vals,**kw) + self.function_store([new_id]) return new_id def write(self,ids,vals,**kw): @@ -1045,6 +1056,7 @@ class HDCase(Model): sb.write({ 'state': 'not_available', }) + self.function_store(ids) super().write(ids,vals,**kw) def approve(self,ids,context={}): diff --git a/netforce_clinic/models/patient.py b/netforce_clinic/models/patient.py index 8d64d4f..2cdff37 100644 --- a/netforce_clinic/models/patient.py +++ b/netforce_clinic/models/patient.py @@ -3,13 +3,15 @@ import time from netforce.model import Model, fields, get_model from netforce.access import get_active_company, get_active_user, set_active_user +from . import utils + class Patient(Model): _name="clinic.patient" _string="Patient" _audit_log=True _multi_company=True - _key=['name'] + _key=['number'] def _get_age(self,ids,context): res={} @@ -35,15 +37,15 @@ class Patient(Model): def _get_hn_no(self,ids,context={}): res={} for obj in self.browse(ids): - hn=''.join(x for x in (obj.hn or "") if x.isdigit()) + hn=''.join(x for x in (obj.number or "") if x.isdigit()) res[obj.id]=hn return res _fields={ 'type_id': fields.Many2One("clinic.patient.type","Type",search=True,required=True), - "number": fields.Char("Number",required=True,search=True), + "number": fields.Char("HN",required=True,search=True), "trt_no": fields.Char("TRT. No",search=True), - "hn_no": fields.Char("HN",function="_get_hn_no"), + "hn_no": fields.Char("HN Number",function="_get_hn_no"), "hn": fields.Char("REF/HN",search=True), "name": fields.Char("Name",required=True,search=True), "reg_date": fields.Date("Register Date",required=False,search=True), @@ -109,6 +111,11 @@ class Patient(Model): return None user_id=get_active_user() set_active_user(1) + # reformat number: month-running num-year thai(2 digit) + monthnow=int(time.strftime("%m")) + yearnow=utils.date2thai(time.strftime("%Y-%m-%d"),"%(By)s") + num="%s-%s-%s"%(monthnow,num,yearnow) + res=self.search([["number","=",num]]) set_active_user(user_id) if not res: @@ -226,7 +233,6 @@ class Patient(Model): def name_get(self,ids,context={}): vals=[] for obj in self.browse(ids): - #name="%s [%s]"%(obj.name, obj.hn_no) name=obj.name or '' if obj.hn_no: name+=" (HN: %s)"%obj.hn_no @@ -238,7 +244,7 @@ class Patient(Model): if domain: dom=[dom,domain] ids1=self.search(dom) - dom=[["hn","ilike","%"+name+"%"]] + dom=[["number","ilike","%"+name+"%"]] if domain: dom=[dom,domain] ids2=self.search(dom) diff --git a/netforce_clinic/models/patient_type.py b/netforce_clinic/models/patient_type.py index 123c602..47910ad 100644 --- a/netforce_clinic/models/patient_type.py +++ b/netforce_clinic/models/patient_type.py @@ -11,6 +11,7 @@ class PatientType(Model): "code": fields.Char("Code",required=True,search=True), 'contact_id': fields.Many2One("partner","Contact",domain=[['type','=','org']],search=True), 'default': fields.Boolean("Default"), + 'hct_include': fields.Boolean("HCT Include"), 'company_id': fields.Many2One("company","Company"), }