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)
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)
def form_valid(self, form): self.debug('form is valid') incoming(self.backend_name, **form.get_incoming_data()) return HttpResponse('OK')
def store_and_queue(backend_name, identity, text): store_message('in', identity, text) incoming(backend_name, identity, text)
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()
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()