コード例 #1
0
ファイル: admin.py プロジェクト: boyombo/WBNigeria
 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 プロジェクト: boyombo/WBNigeria
 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 = patients.PatientDataPayload.objects.all()[0]
     self.assertEqual(payload.status, "success")
     self.assertEqual(payload.patients.count(), 3)
コード例 #3
0
 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 = patients.PatientDataPayload.objects.all()[0]
     self.assertEqual(payload.status, 'success')
     self.assertEqual(payload.patients.count(), 3)
コード例 #4
0
ファイル: views.py プロジェクト: dimagi/aremind
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 http.HttpResponseServerError("No XML data appears to be attached.")
    payload = patients.PatientDataPayload.objects.create(raw_data=content)
    try:
        parse_payload(payload)
    except Exception as e:
        mail_admins(subject="Patient Import Failed", message=unicode(e))
        return http.HttpResponseServerError(unicode(e))
    return http.HttpResponse("Data submitted succesfully.")
コード例 #5
0
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 http.HttpResponseServerError(
            "No XML data appears to be attached.")
    payload = patients.PatientDataPayload.objects.create(raw_data=content)
    try:
        parse_payload(payload)
    except Exception as e:
        mail_admins(subject="Patient Import Failed", message=unicode(e))
        return http.HttpResponseServerError(unicode(e))
    return http.HttpResponse("Data submitted succesfully.")