Ejemplo n.º 1
0
def start_tree_for_patient(tree, patient):
    """Trigger tree for a given patient.
    Will result in our sending them the first question in the tree."""

    connection = patient.contact.default_connection

    # if one is in progress, end it
    Router().get_app('decisiontree').end_sessions(connection)

    # fake an incoming message from our patient that triggers the tree

    backend_name = connection.backend.name
    address = connection.identity
    incoming(backend_name, address, tree.trigger)
Ejemplo n.º 2
0
def start_tree_for_patient(tree, patient):
    """Trigger tree for a given patient.
    Will result in our sending them the first question in the tree."""

    connection = patient.contact.default_connection

    # if one is in progress, end it
    Router().get_app("decisiontree").end_sessions(connection)

    # fake an incoming message from our patient that triggers the tree

    backend_name = connection.backend.name
    address = connection.identity
    incoming(backend_name, address, tree.trigger)
Ejemplo n.º 3
0
 def form_valid(self, form):
     self.debug('form is valid')
     incoming(self.backend_name, **form.get_incoming_data())
     return HttpResponse('OK')
Ejemplo n.º 4
0
 def form_valid(self, form):
     self.debug('form is valid')
     incoming(self.backend_name, **form.get_incoming_data())
     return HttpResponse('OK')
Ejemplo n.º 5
0
def store_and_queue(backend_name, identity, text):
    store_message('in', identity, text)
    incoming(backend_name, identity, text)
Ejemplo n.º 6
0
                    return HttpResponse(j)
                except Exception, e:
                    logger.exception(e)
                    return HttpResponseServerError()

        # Must have received a message
        logger.debug("@@Got a text message")
        try:
            from_address = s['from']['id']
            text = s['initialText']

            logger.debug("@@Received message from %s: %s" %
                         (from_address, text))

            # pass the message to RapidSMS
            incoming(backend_name, from_address, text)

            # Respond nicely to Tropo
            t = Tropo()
            t.hangup()
            logger.debug("@@responding to tropo with hangup")
            return HttpResponse(t.RenderJson())
        except Exception, e:
            logger.exception(e)
            logger.debug("@@responding to tropo with error")
            return HttpResponseServerError()
    else:
        # What?  We don't expect any GET to our URL because
        # our Tropo app should be a Web API app.
        logger.error("@@Unexpected GET to tropo URL")
        return HttpResponseServerError()
Ejemplo n.º 7
0
                    logger.debug("@@%s" % j)
                    return HttpResponse(j)
                except Exception, e:
                    logger.exception(e)
                    return HttpResponseServerError()

        # Must have received a message
        logger.debug("@@Got a text message")
        try:
            from_address = s['from']['id']
            text = s['initialText']

            logger.debug("@@Received message from %s: %s" % (from_address, text))

            # pass the message to RapidSMS
            incoming(backend_name, from_address, text)

            # Respond nicely to Tropo
            t = Tropo()
            t.hangup()
            logger.debug("@@responding to tropo with hangup")
            return HttpResponse(t.RenderJson())
        except Exception, e:
            logger.exception(e)
            logger.debug("@@responding to tropo with error")
            return HttpResponseServerError()
    else:
        # What?  We don't expect any GET to our URL because
        # our Tropo app should be a Web API app.
        logger.error("@@Unexpected GET to tropo URL")
        return HttpResponseServerError()