コード例 #1
0
ファイル: admin.py プロジェクト: afrims/afrims
 def save_model(self, request, obj, form, change):
     if not obj.submit_date:
         obj.submit_date = datetime.datetime.now()
     obj.save()
     try:
         parse_payload(obj)
     except Exception as e:
         messages.error(request, u"Error parsing patient data: %s" % unicode(e))
コード例 #2
0
ファイル: tests.py プロジェクト: afrims/afrims
 def test_multi_patient_creation(self):
     """ Test that multiple patients are inserted properly """
     node1 = self.create_xml_patient()
     node2 = self.create_xml_patient()
     node3 = self.create_xml_patient()
     payload = self.create_payload([node1, node2, node3])
     parse_payload(payload)
     payload = reminders.PatientDataPayload.objects.all()[0]
     self.assertEqual(payload.status, 'success')
     self.assertEqual(payload.patients.count(), 3)
コード例 #3
0
ファイル: views.py プロジェクト: afrims/afrims
def receive_patient_record(request):
    ''' Accept data submissions from the the site via POST. '''
    if request.META['CONTENT_TYPE'] != 'text/xml':
        logger.warn('incoming post does not have text/xml content type')
        logger.debug(request)
    content = request.raw_post_data
    if not content:
        logger.error("No XML data appears to be attached.")
        return HttpResponseServerError("No XML data appears to be attached.")
    payload = reminders.PatientDataPayload.objects.create(raw_data=content)
    try:
        parse_payload(payload)
    except Exception as e:
        if getattr(settings, 'NOTIFY_ON_PATIENT_IMPORT_ERROR', True):
            mail_admins(subject="Patient Import Failed", message=unicode(e))
        return HttpResponseServerError(unicode(e))
    return HttpResponse("Data submitted succesfully.")