def dispatch(cls, router, msg):

        # spawn an instance of this handler, and stash
        # the low(er)-level router and message object
        inst = cls(router, msg)

        ### GET REPORTER
        try:
            cls.reporter = Enduser.get_active_user(msg.connection.identity)
            #print cls.reporter.__dict__
            cls.language = cls.reporter.language_code.lower()
        except Exception, e:
            #print "ERROR OF CHW REG: ", e
            msg.respond(
                get_appropriate_response(
                    msg=msg,
                    DEFAULT_LANGUAGE_ISO='rw',
                    message_type='sender_not_registered')[1])
            return True
Пример #2
0
 def save(self, user=None):
     """ Save a enderror object and return indexcol """
     try:
         FIELDS = self.__dict__
         if not user: user = Enduser.get_active_user(self.user_phone)
         if user:
             FIELDS.update({
                 "user_pk": user.indexcol,
                 "nation_pk": user.nation_pk,
                 "province_pk": user.province_pk,
                 "district_pk": user.district_pk,
                 "referral_facility_pk": user.referral_facility_pk,
                 "facility_pk": user.facility_pk,
                 "sector_pk": user.facility_pk,
                 "cell_pk": user.facility_pk,
                 "village_pk": user.facility_pk,
             })
         err = migrate(Enderror._table, FIELDS)
         return err
     except Exception, e:
         print e
         raise MchCriticalError(Exception('Enderror cannot be saved'))
Пример #3
0
##
## @author UWANTWALI ZIGAMA Didier
## [email protected]/[email protected]
##

from sms.api.messaging.smsparser import *
from sms.api.messaging.smsprocessor import *
from model.enduser import Enduser
from sms.api.messagelog.models import Message
from rapidsms.models import Connection
from sms.api.messaging.persister import Persister

#identity = '+250782904295' #ASM
#identity = '+250782923741' #BINOME
identity = '+250788660270'
chw = Enduser.get_active_user(identity)
REPORTS = [
    ('PRE',
     'pre 1199270180887099 09.12.2017 10.09.2018 5 1 GS rm yg ol ma vo oe ns HC wt80.6 ht180 to hw muac14.5 0788660270'
     ),
    ('DEP', 'DEP 1234007890123457'),
    ('DEP_CHILD', 'DEP 1234567890123457 01 09.01.2015'),
    ('REF', 'REF 0234567890123457'),
    ('ANC',
     'ANC 0788660270010918 05.07.2018 anc4 VO PC OE NS MA JA FP FE DS DI SA RB HY CH AF hc wt65.5 muac12.5'
     ),
    ('RISK',
     'RISK 1234567890123090 VO PC OE NS MA JA FP FE DS DI SA RB HY CH AF or wt70'
     ),
    ('RES',
     'RES 1234567890123090 VO PC OE NS MA JA FP FE DS DI SA RB HY CH AF hp AA MW'