def create(self, request):
        # Form validated so we don't have to check any arguments.
        notification_type  = request.POST.get('type')
        patient_id = request.POST.get('patient_id')
        case_identifier = request.POST.get('case_identifier')
        message = request.POST.get('message')
        destination = request.POST.get('destinations')

        n = models.Notification(patient_id=patient_id,
                                client=destination,
                                procedure_id=case_identifier,
                                message=message,
                                delivered=False)


        if notification_type == 'SMS':
            sms.send_sms_notification(n)
        elif notification_type == 'EMAIL':
            subject = request.POST.get('email_subject')
            try:
                send_mail(subject, n.message, '*****@*****.**',
                          destination, fail_silently=False)
                n.delivered = True
            except Exception, e:
                logging.error("Could not send email: %s." % e)
def notification_submit(request):
    phoneId = request.REQUEST.get("phoneIdentifier", None)
    text = request.REQUEST.get("notificationText", None)
    caseIdentifier = request.REQUEST.get("caseIdentifier", None)
    patientIdentifier = request.REQUEST.get("patientIdentifier", None)
    delivered = False

    logging.info("Notification submit received")

    for key,value in request.REQUEST.items():
        logging.info("Notification submit %s:%s" % (key,value))

    response = json_fail('Failed to register notification.')
    if phoneId and text and caseIdentifier and patientIdentifier:
        n = Notification(client=phoneId,
                         patient_id=patientIdentifier,
                         message=text,
                         procedure_id=caseIdentifier,
                         delivered=delivered)
        n.save()
        response = json_succeed('Successfully registered notification.')
        try:
            sms.send_sms_notification(n)
        except Exception, e:
            logging.error("Got error while trying to send notification: %s" % e)
示例#3
0
    def create(self, request):
        # Form validated so we don't have to check any arguments.
        notification_type = request.POST.get('type')
        patient_id = request.POST.get('patient_id')
        case_identifier = request.POST.get('case_identifier')
        message = request.POST.get('message')
        destination = request.POST.get('destinations')

        n = models.Notification(patient_id=patient_id,
                                client=destination,
                                procedure_id=case_identifier,
                                message=message,
                                delivered=False)

        if notification_type == 'SMS':
            sms.send_sms_notification(n)
        elif notification_type == 'EMAIL':
            subject = request.POST.get('email_subject')
            try:
                send_mail(subject,
                          n.message,
                          '*****@*****.**',
                          destination,
                          fail_silently=False)
                n.delivered = True
            except Exception, e:
                logging.error("Could not send email: %s." % e)
def notification_submit(request):
    phoneId = request.REQUEST.get("phoneIdentifier", None)
    text = request.REQUEST.get("notificationText", None)
    caseIdentifier = request.REQUEST.get("caseIdentifier", None)
    patientIdentifier = request.REQUEST.get("patientIdentifier", None)
    delivered = False

    logging.info("Notification submit received")

    for key, value in request.REQUEST.items():
        logging.info("Notification submit %s:%s" % (key, value))

    response = json_fail('Failed to register notification.')
    if phoneId and text and caseIdentifier and patientIdentifier:
        n = Notification(client=phoneId,
                         patient_id=patientIdentifier,
                         message=text,
                         procedure_id=caseIdentifier,
                         delivered=delivered)
        n.save()
        response = json_succeed('Successfully registered notification.')
        try:
            sms.send_sms_notification(n)
        except Exception, e:
            logging.error("Got error while trying to send notification: %s" %
                          e)