def createUser(enduser): if enduser.telephone is None: raise MchCriticalError("National ID should not be null if you need to be RapidSMS Rwanda User") if enduser.national_id is None: raise MchCriticalError("Telephone should not be null if you need to be RapidSMS Rwanda User") if enduser.email is None: raise MchCriticalError("Email should not be null if you need to be RapidSMS Rwanda User") if enduser.passwd is None: raise MchCriticalError("Password should not be null if you need to be RapidSMS Rwanda User") if enduser.role is None: raise MchCriticalError("Role should not be null if you need to be RapidSMS Rwanda User") """print { 'telephone' : enduser.telephone, 'national_id' : enduser.national_id, 'role_pk': enduser.role_pk, 'email' : enduser.email, 'salt' : salt, 'passwd': passwd } orm.ORM.store('enduser', { } )""" return True
def save(self, orm, obj): """ Save a childhealth object and return indexcol """ try: ref = orm.ORM.store(self.table, obj.FIELDS) return ref except Exception, e: raise MchCriticalError(Exception('Childhealth cannot be saved'))
def get(self, filters): """ Retrieve a risk object and return risk record """ try: red = fetch_risk(self.national_id, filters) return red except: raise MchCriticalError(Exception('Risk cannot be fetched')) return False
def get(self, filters): """ Retrieve a childhealth object and return childhealth record """ try: chi = fetch_chi(self.national_id, filters) return chi except Exception, e: print e raise MchCriticalError(Exception('Childhealth cannot be fetched'))
def get(self): """ Retrieve a pncvisit object and return pncvisit record """ try: pnc = fetch_pncvisit(self.national_id, self.delivery_date, self.pnc_visit) return pnc except Exception, e: print e raise MchCriticalError(Exception('Pncvisit cannot be fetched'))
def save(self, orm, obj): """ Save a risk object and return indexcol """ try: ref = orm.ORM.store(self.table, obj.FIELDS) return ref except: raise MchCriticalError(Exception('Risk cannot be saved')) return False
def get(self): """ Retrieve a refusal object and return refusal record """ try: ref = fetch_refusal(self.national_id, self.created_at) return ref except: raise MchCriticalError(Exception('Refusal cannot be fetched')) return False
def get(self, filters): """ Retrieve a CCM object and return CCM record """ try: ccm = fetch_ccm(self.national_id, filters) return ccm except Exception, e: print e raise MchCriticalError(Exception('CCM cannot be fetched'))
def get_cmr(self, filters): """ Retrieve a CMR object and return CMR record """ try: cmr = fetch_cmr(self.national_id, filters) return cmr except Exception, e: print e raise MchCriticalError(Exception('CMR cannot be fetched'))
def save(self, orm, obj): """ Save a CCM object and return indexcol """ try: ref = orm.ORM.store(self.table1, obj.FIELDS) return ref except Exception, e: #print e raise MchCriticalError(Exception('CCM cannot be saved'))
def get(self, risk_pk, filters): """ Retrieve a riskresult object and return riskresult record """ try: res = fetch_riskresult(self.national_id, risk_pk, filters) return res except: raise MchCriticalError(Exception('Riskresult cannot be fetched')) return False
def get(self): """ Retrieve a mother object and return mother record """ try: mth = fetch_mother(self.national_id) return mth except: raise MchCriticalError(Exception('Mother cannot be fetched')) return False
def get(self): """ Retrieve a download object and return download record """ try: err = fetch_download(self.user_pk, self.filename) return err except: raise MchCriticalError(Exception('Download cannot be fetched')) return None
def get(self, filters): """ Retrieve a nutrition object and return nutrition record """ try: cbn = fetch_cbn(self.national_id, filters) return cbn except Exception, e: print e raise MchCriticalError(Exception('Nutrition cannot be fetched'))
def get(self): """ Retrieve a ancvisit object and return ancvisit record """ try: anc = fetch_ancvisit(self.national_id, self.pregnancy_pk, self.anc_visit) return anc except: raise MchCriticalError(Exception('Ancvisit cannot be fetched')) return False
def get(self): """ Retrieve a child object and return child record """ try: chi = fetch_birth(self.national_id, self.birth_date, self.child_number) return chi except: raise MchCriticalError(Exception('Child cannot be fetched')) return False
def get(self): """ Retrieve a pregnancy object and return pregnancy record """ try: preg = fetch_pregnancy(self.national_id, self.lmp) return preg except Exception, e: print e raise MchCriticalError( Exception('Pregnancy Report cannot be fetched'))
def get(self): """ Retrieve a enderror object and return enderror record """ try: err = fetch_enderror(self.user_phone, self.error_code, self.created_at) return err except: raise MchCriticalError(Exception('Enderror cannot be fetched')) return False
def save(self, orm, obj): """ Save a pregnancy object and return indexcol """ try: ref = orm.ORM.store(self.table, obj.FIELDS) return ref except Exception, e: print e raise MchCriticalError( Exception('Pregnancy Report cannot be saved'))
def get(self): """ Retrieve a nbcvisit object and return nbcvisit record """ try: nbc = fetch_nbcvisit(self.national_id, self.birth_date, self.child_number, self.nbc_visit) return nbc except Exception, e: print e raise MchCriticalError(Exception('Nbvisit cannot be fetched'))
def get_or_create(self, orm, obj): """ Retrieve a nutrition object and return nutrition record """ try: cbn = fetch_cbn(self.national_id, obj.UNIQUE_QUERY) if cbn: obj.FIELDS.update({'indexcol': cbn.indexcol}) self.save(orm, obj) return self.get(obj.UNIQUE_QUERY) except Exception, e: raise MchCriticalError( Exception('Nutrition cannot be saved and fetched'))
def get_or_create(self, orm, obj): """ Retrieve a riskresult object and return riskresult record """ try: res = fetch_riskresult(self.national_id, obj.risk_pk, obj.UNIQUE_QUERY) if res: obj.FIELDS.update({'indexcol': res.indexcol}) self.save(orm, obj) return self.get(obj.risk_pk, obj.UNIQUE_QUERY) except: raise MchCriticalError(Exception('Riskresult cannot be saved and fetched')) return False
def get_or_create(self, orm, obj): """ Retrieve a ancvisit object and return ancvisit record """ try: anc = fetch_ancvisit(self.national_id, self.pregnancy_pk, self.anc_visit) if anc: obj.FIELDS.update({'indexcol': anc.indexcol}) self.save(orm, obj) return self.get() except: raise MchCriticalError(Exception('Ancvisit cannot be saved and fetched')) return False
def get_or_create(self, orm, obj, pnc1): """ Retrieve a pncvisit object and return pncvisit record """ try: pnc = fetch_pncvisit(self.national_id, self.delivery_date, self.pnc_visit) if pnc: obj.FIELDS.update({'indexcol': pnc.indexcol}) self.save(orm, obj, pnc1) return self.get() except Exception, e: print e raise MchCriticalError(Exception('Pncvisit cannot be saved and fetched'))
def get_or_create(self, orm, obj): """ Retrieve a CCM object and return CCM record """ try: ccm = fetch_ccm(self.national_id, obj.UNIQUE_QUERY) if ccm: obj.FIELDS.update({'indexcol': ccm.indexcol}) self.save(orm, obj) return self.get(obj.UNIQUE_QUERY) except Exception, e: raise MchCriticalError( Exception('CCM cannot be saved and fetched'))
def get_or_create(self, orm, obj): """ Retrieve a mother object and return mother record """ try: mth = fetch_mother(self.national_id) if mth: obj.FIELDS.update({'indexcol': mth.indexcol}) self.save(orm, obj) return self.get() except: raise MchCriticalError(Exception('Mother cannot be fetched')) return False
def get_or_create(self, orm, obj): """ Retrieve a refusal object and return refusal record """ try: ref = self.get() if ref: obj.FIELDS.update({'indexcol': ref.indexcol}) self.save(orm, obj) return self.get() except: raise MchCriticalError( Exception('Refusal cannot be saved and fetched')) return False
def get_or_create(self, orm, obj): """ Retrieve a Pregnancy object and return mother record """ try: preg = fetch_pregnancy(self.national_id, self.lmp) if preg: obj.FIELDS.update({'indexcol': preg.indexcol}) self.save(orm, obj) return self.get() except Exception, e: print e raise MchCriticalError( Exception('Pregnancy cannot be retrieved or saved'))
def get_or_create_cmr(self, orm, obj): """ Retrieve a CMR object and return CMR record """ try: cmr = fetch_cmr(self.national_id, obj.UNIQUE_QUERY) if cmr: obj.FIELDS.update({'indexcol': cmr.indexcol}) self.save_cmr(orm, obj) #print obj.UNIQUE_QUERY return self.get_cmr(obj.UNIQUE_QUERY) except Exception, e: raise MchCriticalError( Exception('CMR cannot be saved and fetched'))
def get_or_create(self, orm, obj): """ Retrieve a child object and return child record """ try: chi = fetch_birth(self.national_id, self.birth_date, self.child_number) if chi: obj.FIELDS.update({'indexcol': chi.indexcol}) self.save(orm, obj) return self.get() except: raise MchCriticalError(Exception('Child cannot be fetched')) return False