Example #1
0
  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
Example #2
0
 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'))
Example #3
0
 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
Example #4
0
 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'))
Example #5
0
 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'))
Example #6
0
 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
Example #7
0
 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
Example #8
0
 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'))
Example #9
0
 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'))
Example #10
0
 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'))
Example #11
0
 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
Example #12
0
 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
Example #13
0
 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
Example #14
0
 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'))
Example #15
0
 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
Example #16
0
 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
Example #17
0
 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'))
Example #18
0
 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
Example #19
0
 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'))
Example #20
0
 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'))
Example #21
0
 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'))
Example #22
0
 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
Example #23
0
 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
Example #24
0
 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'))
Example #25
0
 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'))
Example #26
0
 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
Example #27
0
 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
Example #28
0
 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'))
Example #29
0
 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'))
Example #30
0
 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