From fd63be1777fea42f2ff6814067dee81efdcc5e40 Mon Sep 17 00:00:00 2001 From: "watcha.h" Date: Tue, 17 Mar 2015 11:59:23 +0700 Subject: [PATCH] patient --- netforce_clinic/layouts/clinic_nation_form.xml | 1 + netforce_clinic/layouts/clinic_nation_list.xml | 1 + netforce_clinic/models/nation.py | 11 +++++++++++ netforce_clinic/models/patient.py | 14 ++++++++++++-- 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/netforce_clinic/layouts/clinic_nation_form.xml b/netforce_clinic/layouts/clinic_nation_form.xml index ad0417f..73aae5f 100644 --- a/netforce_clinic/layouts/clinic_nation_form.xml +++ b/netforce_clinic/layouts/clinic_nation_form.xml @@ -1,4 +1,5 @@
+ diff --git a/netforce_clinic/layouts/clinic_nation_list.xml b/netforce_clinic/layouts/clinic_nation_list.xml index 91a7974..3ed877f 100644 --- a/netforce_clinic/layouts/clinic_nation_list.xml +++ b/netforce_clinic/layouts/clinic_nation_list.xml @@ -1,4 +1,5 @@ + diff --git a/netforce_clinic/models/nation.py b/netforce_clinic/models/nation.py index 78b0770..7614b85 100644 --- a/netforce_clinic/models/nation.py +++ b/netforce_clinic/models/nation.py @@ -8,6 +8,17 @@ class Nation(Model): _fields={ "name": fields.Char("Name",required=True,search=True), "code": fields.Char("Code",search=True), + 'default': fields.Boolean("Default"), } + def write(self,ids,vals,**kw): + default=vals.get('default') + if default: + for obj in self.search_browse([]): + if obj.id not in ids: + obj.write({ + 'default': False, + }) + super().write(ids,vals,**kw) + Nation.register() diff --git a/netforce_clinic/models/patient.py b/netforce_clinic/models/patient.py index 513b392..aee295a 100644 --- a/netforce_clinic/models/patient.py +++ b/netforce_clinic/models/patient.py @@ -227,6 +227,12 @@ class Patient(Model): code=','.join([dpt.code for dpt in dpts]) return code + def _get_nation(self,context={}): + nid=None + for nt in get_model("clinic.nation").search_browse([['default','=',True]]): + nid=nt.id + return nid + _defaults={ #"number": _get_number, "number": "", @@ -241,6 +247,7 @@ class Patient(Model): 'walkin': 'no', 'departments': _get_departments, 'location': _get_default_location, + 'nation_id': _get_nation, } _sql_constraints=("clinic_patient_key_uniq","unique(name_check,branch_id)","name should be unique"), @@ -248,12 +255,15 @@ class Patient(Model): def check_idcard(self,card_type,idcard=''): res=True - print(card_type , idcard) + if not idcard: + return False if card_type!='identification': return False if idcard=='/': return True - if idcard.isalpha(): + if not idcard: + res=False + elif idcard.isalpha(): res=False elif len(idcard)!=13: res=False