コード例 #1
0
 def test_patient_gps(self):
     try:
         patient = Patient()
         patient.gps_coordinates = '101010'
         patient.save()
     except IntegrityError:
         return HttpResponseServerError()
     self.assertEqual(patient.gps_coordinates, '101010')
コード例 #2
0
 def test_patient_gender(self):
     try:
         patient = Patient()
         patient.gender = 'Male'
         patient.save()
     except IntegrityError:
         return HttpResponseServerError()
     self.assertEqual(patient.gender, 'Male')
コード例 #3
0
 def test_patient_last_name(self):
     try:
         patient = Patient()
         patient.last_name = 'ho'
         patient.save()
     except IntegrityError:
         return HttpResponseServerError()
     self.assertEqual(patient.last_name, 'ho')
コード例 #4
0
 def test_patient_last_name(self):
     try:
         patient = Patient()
         patient.last_name = 'ho'
         patient.save()
     except IntegrityError:
         return HttpResponseServerError()
     self.assertEqual(patient.last_name, 'ho')
コード例 #5
0
 def test_patient_email(self):
     try:
         patient = Patient()
         patient.email = '*****@*****.**'
         patient.save()
     except IntegrityError:
         return HttpResponseServerError()
     self.assertEqual(patient.email, '*****@*****.**')
コード例 #6
0
 def test_patient_health_id(self):
     try:
         patient = Patient()
         patient.health_id = '12345'
         patient.save()
     except IntegrityError:
         return HttpResponseServerError()
     self.assertEqual(patient.health_id, '12345')
コード例 #7
0
 def test_patient_dob(self):
     try:
         patient = Patient()
         patient.date_of_birth = '1999-10-10'
         patient.save()
     except IntegrityError:
         return HttpResponseServerError()
     self.assertEqual(patient.date_of_birth, '1999-10-10')
コード例 #8
0
 def test_patient_gender(self):
     try:
         patient = Patient()
         patient.gender = 'Male'
         patient.save()
     except IntegrityError:
         return HttpResponseServerError()
     self.assertEqual(patient.gender, 'Male')
コード例 #9
0
 def test_patient_email(self):
     try:
         patient = Patient()
         patient.email = '*****@*****.**'
         patient.save()
     except IntegrityError:
         return HttpResponseServerError()
     self.assertEqual(patient.email, '*****@*****.**')
コード例 #10
0
 def test_patient_phone(self):
     try:
         patient = Patient()
         patient.phone = '416'
         patient.save()
     except IntegrityError:
         return HttpResponseServerError()
     self.assertEqual(patient.phone, '416')
コード例 #11
0
 def test_patient_health_id(self):
     try:
         patient = Patient()
         patient.health_id = '12345'
         patient.save()
     except IntegrityError:
         return HttpResponseServerError()
     self.assertEqual(patient.health_id, '12345')
コード例 #12
0
 def test_patient_dob(self):
     try:
         patient = Patient()
         patient.date_of_birth = '1999-10-10'
         patient.save()
     except IntegrityError:
         return HttpResponseServerError()
     self.assertEqual(patient.date_of_birth, '1999-10-10')
コード例 #13
0
 def test_patient_address(self):
     try:
         patient = Patient()
         patient.address = '420 street'
         patient.save()
     except IntegrityError:
         return HttpResponseServerError()
     self.assertEqual(patient.address, '420 street')
コード例 #14
0
 def test_patient_gps(self):
     try:
         patient = Patient()
         patient.gps_coordinates = '101010'
         patient.save()
     except IntegrityError:
         return HttpResponseServerError()
     self.assertEqual(patient.gps_coordinates, '101010')
コード例 #15
0
 def test_patient_address(self):
     try:
         patient = Patient()
         patient.address = '420 street'
         patient.save()
     except IntegrityError:
         return HttpResponseServerError()
     self.assertEqual(patient.address, '420 street')
コード例 #16
0
 def test_patient_phone(self):
     try:
         patient = Patient()
         patient.phone = '416'
         patient.save()
     except IntegrityError:
         return HttpResponseServerError()
     self.assertEqual(patient.phone, '416')
コード例 #17
0
    def test_create_new_patient(self):
        user = createUser('doctor2', '*****@*****.**', 'doctorf')
        user.save()
        try:
            doctor1 = Doctor(user=user)
            doctor1.user.first_name = 'F'
            doctor1.registration_time = timezone.now()
            user.save()
            doctor1.save()
        except IntegrityError:
            return HttpResponseServerError()

        try:
            patient = Patient(
                first_name = "John",
                last_name = "Smith",
                gps_coordinates = "101010",
                address = "Yonge street",
                date_of_birth = "1999-06-10",
                phone = "646646646464",
                health_id = "324324234",
                gender = "Male",
                email = "*****@*****.**"
            )
            patient.save()
        except IntegrityError:
            return HttpResponseServerError()

        self.assertEqual(patient.first_name, "John")
        self.assertEqual(patient.last_name, "Smith")
        self.assertEqual(patient.gps_coordinates, "101010")
        self.assertEqual(patient.address, "Yonge street")
        self.assertEqual(patient.date_of_birth, "1999-06-10")
        self.assertEqual(patient.phone, "646646646464")
        self.assertEqual(patient.health_id, "324324234")
        self.assertEqual(patient.gender, "Male")
        self.assertEqual(patient.email, "*****@*****.**")

        self.client.login(username="******", password='******')
        url2 = reverse('display_patient', args=[patient.id])
        response = self.client.get(url2)
        self.assertEqual(response.status_code, 200)
        self.assertEqual(response.context['firstName'], "John")
        self.assertEqual(response.context['viewer'], user)
        self.assertEqual(response.context['user'], user)
        self.assertEqual(response.context['lastName'], "Smith")
        self.assertEqual(response.context['gender'], "Male")
        self.assertEqual(response.context['date_of_birth'], datetime.date(1999, 06,10))
        self.assertEqual(response.context['gps_coordinates'], "101010")
        self.assertEqual(response.context['health_id'], "324324234")
        self.assertEqual(response.context['address'], "Yonge street")
        self.assertEqual(response.context['phone'], "646646646464")
        self.assertEqual(response.context['email'], "*****@*****.**")
コード例 #18
0
ファイル: patient.py プロジェクト: c0chenji/Utra-R-M
def display_new_patient(request):
    ''' Display the new patient page and process submitted new-patient
        forms. '''

    user = request.user

    # Only workers may add new patients.
    if not hasattr(user, "worker"):
        return HttpResponseServerError()

    if request.method == 'POST':

        form = NewPatientForm(request.POST, request.FILES)
        if form.is_valid():
            first_name = form.cleaned_data['first_name']
            last_name = form.cleaned_data['last_name']
            gps_coordinates = form.cleaned_data['gps_coordinates']
            address = form.cleaned_data['address']
            date_of_birth = form.cleaned_data['date_of_birth']
            phone_number = form.cleaned_data['phone_number']
            health_id = form.cleaned_data['health_id']
            sex = form.cleaned_data['sex']
            email = form.cleaned_data['email']
            patient_pic = form.cleaned_data['patient_pic']

            try:
                patient = Patient(first_name=first_name,
                                  last_name=last_name,
                                  gps_coordinates=gps_coordinates,
                                  address=address,
                                  date_of_birth=date_of_birth,
                                  phone=phone_number,
                                  health_id=health_id,
                                  gender=sex,
                                  email=email,
                                  patient_pic=patient_pic)
                patient.save()
            except IntegrityError:
                return HttpResponseServerError()

            return HttpResponseRedirect("/patient/" + str(patient.id))
    else:

        # The page has just been entered and so the form hasn't
        # been submitted yet.
        form = NewPatientForm()

    return render_to_response('newPatient.html', {
        'form': form,
        'viewer': request.user
    },
                              context_instance=RequestContext(request))
コード例 #19
0
def display_new_patient(request):
    ''' Display the new patient page and process submitted new-patient
        forms. '''

    user = request.user

    # Only workers may add new patients.
    if not hasattr(user, "worker"):
        return HttpResponseServerError()

    if request.method == 'POST':

        form = NewPatientForm(request.POST, request.FILES)
        if form.is_valid():
            first_name = form.cleaned_data['first_name']
            last_name = form.cleaned_data['last_name']
            gps_coordinates = form.cleaned_data['gps_coordinates']
            address = form.cleaned_data['address']
            date_of_birth = form.cleaned_data['date_of_birth']
            phone_number = form.cleaned_data['phone_number']
            health_id = form.cleaned_data['health_id']
            sex = form.cleaned_data['sex']
            email = form.cleaned_data['email']
            patient_pic = form.cleaned_data['patient_pic']

            try:
                patient = Patient(
                    first_name=first_name,
                    last_name=last_name,
                    gps_coordinates=gps_coordinates,
                    address=address,
                    date_of_birth=date_of_birth,
                    phone=phone_number,
                    health_id=health_id,
                    gender=sex,
                    email=email,
                    patient_pic=patient_pic)
                patient.save()
            except IntegrityError:
                return HttpResponseServerError()

            return HttpResponseRedirect("/patient/" + str(patient.id))
    else:

        # The page has just been entered and so the form hasn't
        # been submitted yet.
        form = NewPatientForm()

    return render_to_response('newPatient.html',
                              {'form': form,
                               'viewer': request.user},
                              context_instance=RequestContext(request))
コード例 #20
0
    def test_create_new_patient(self):
        user = createUser('doctor2', '*****@*****.**', 'doctorf')
        user.save()
        try:
            doctor1 = Doctor(user=user)
            doctor1.user.first_name = 'F'
            doctor1.registration_time = timezone.now()
            user.save()
            doctor1.save()
        except IntegrityError:
            return HttpResponseServerError()

        try:
            patient = Patient(first_name="John",
                              last_name="Smith",
                              gps_coordinates="101010",
                              address="Yonge street",
                              date_of_birth="1999-06-10",
                              phone="646646646464",
                              health_id="324324234",
                              gender="Male",
                              email="*****@*****.**")
            patient.save()
        except IntegrityError:
            return HttpResponseServerError()

        self.assertEqual(patient.first_name, "John")
        self.assertEqual(patient.last_name, "Smith")
        self.assertEqual(patient.gps_coordinates, "101010")
        self.assertEqual(patient.address, "Yonge street")
        self.assertEqual(patient.date_of_birth, "1999-06-10")
        self.assertEqual(patient.phone, "646646646464")
        self.assertEqual(patient.health_id, "324324234")
        self.assertEqual(patient.gender, "Male")
        self.assertEqual(patient.email, "*****@*****.**")

        self.client.login(username="******", password='******')
        url2 = reverse('display_patient', args=[patient.id])
        response = self.client.get(url2)
        self.assertEqual(response.status_code, 200)
        self.assertEqual(response.context['firstName'], "John")
        self.assertEqual(response.context['viewer'], user)
        self.assertEqual(response.context['user'], user)
        self.assertEqual(response.context['lastName'], "Smith")
        self.assertEqual(response.context['gender'], "Male")
        self.assertEqual(response.context['date_of_birth'],
                         datetime.date(1999, 06, 10))
        self.assertEqual(response.context['gps_coordinates'], "101010")
        self.assertEqual(response.context['health_id'], "324324234")
        self.assertEqual(response.context['address'], "Yonge street")
        self.assertEqual(response.context['phone'], "646646646464")
        self.assertEqual(response.context['email'], "*****@*****.**")
コード例 #21
0
def create_new_patient_m(request):

    data = is_worker(request)
    if not data:
        json_response = json.dumps({"success": "false",
                                    "type": "notWorker"})
        return HttpResponse(json_response, mimetype='application/json')

    form = NewPatientForm(data)
    if form.is_valid():
        first_name = form.cleaned_data['first_name']
        last_name = form.cleaned_data['last_name']
        gps_coordinates = form.cleaned_data['gps_coordinates']
        address = form.cleaned_data['address']
        date_of_birth = form.cleaned_data['date_of_birth']
        phone_number = form.cleaned_data['phone_number']
        health_id = form.cleaned_data['health_id']
        photo_link = form.cleaned_data['photo_link']
        sex = form.cleaned_data['sex']
        email = form.cleaned_data['email']

        try:
            patient = Patient(
                first_name=first_name,
                last_name=last_name,
                gps_coordinates=gps_coordinates,
                address=address,
                date_of_birth=date_of_birth,
                phone=phone_number,
                health_id=health_id,
                gender=sex,
                email=email,
                photo_link=photo_link)
            patient.save()
        except IntegrityError:
            json_response = json.dumps({"success": "false",
                                        "type": "IntegrityError"})
            return HttpResponse(json_response, mimetype='application/json')

        json_response = json.dumps({"success": "true",
                                    "type": "newPatient", "patient_id":
                                    str(patient.id)})
        return HttpResponse(json_response, mimetype='application/json')
    else:
        json_response = json.dumps({"success": "false",
                                    "type": "invalidForm"})
        return HttpResponse(json_response, mimetype='application/json')
コード例 #22
0
def populate_default_test_data():
    ''' Populates the database with default test data. '''

    try:
        worker_user = createUser('theworker', '*****@*****.**', 'password')
        worker_user.save()
        worker = Worker(user=worker_user)
        worker.registration_time = timezone.now()
        worker.save()

    except IntegrityError:
        print 'Failed to create a default worker user'
        return HttpResponseServerError()

    try:
        doctor_user = createUser('thedoctor', '*****@*****.**', 'thepassword')
        doctor_user.save()
        doctor = Doctor(user=doctor_user)
        doctor.user_id = doctor_user.id
        doctor.registration_time = timezone.now()
        doctor.save()
    except IntegrityError:
        print 'Failed to create a default doctor'
        return HttpResponseServerError()

    try:
        doctor2_user = createUser('doctor2', '*****@*****.**', 'd2password')
        doctor2_user.save()
        doctor2 = Doctor(user=doctor2_user)
        doctor2.user_id = doctor2_user.id
        doctor2.registration_time = timezone.now()
        doctor2.save()
    except IntegrityError:
        print 'Failed to create a default doctor'
        return HttpResponseServerError()

    try:
        sample_patient = Patient(
                first_name="Alexis",
                last_name="Advantageous",
                gps_coordinates="101010",
                address="Yonge street",
                date_of_birth="1999-06-10",
                phone="646646646464",
                health_id="324324234",
                gender="Male",
                email="*****@*****.**"
            )

        sample_patient.save()
    except IntegrityError:
        print 'Failed to create a default patient'
        return HttpResponseServerError()

    try:
        comment = Comment(author=worker_user,
                          text="Trololololol.",
                          time_posted=timezone.now())
        comment.save()
    except IntegrityError:
        print 'Failed to create a default comment'
        return HttpResponseServerError()

    try:
        comment_group = CommentGroup()
        comment_group.save()
        comment_group.comments.add(comment)
    except IntegrityError:
        print 'Failed to create a default comment group'
        return HttpResponseServerError()

    try:
        sample_case = Case(
                patient=sample_patient,
                submitter=worker,
                lock_holder=None,
                status=1,
                priority=10,
                submitter_comments=comment_group,
                date_opened="2012-12-12"
            )
        sample_case.save()
    except IntegrityError:
        print 'Failed to create a default worker user'
        return HttpResponseServerError()

    return [worker_user, worker, doctor_user, doctor, sample_patient, comment,
            comment_group, sample_case, doctor2_user, doctor2]
コード例 #23
0
def populate_default_test_data():
    ''' Populates the database with default test data. '''

    try:
        worker_user = createUser('theworker', '*****@*****.**', 'password')
        worker_user.save()
        worker = Worker(user=worker_user)
        worker.registration_time = timezone.now()
        worker.save()

    except IntegrityError:
        print 'Failed to create a default worker user'
        return HttpResponseServerError()

    try:
        doctor_user = createUser('thedoctor', '*****@*****.**', 'thepassword')
        doctor_user.save()
        doctor = Doctor(user=doctor_user)
        doctor.user_id = doctor_user.id
        doctor.registration_time = timezone.now()
        doctor.save()
    except IntegrityError:
        print 'Failed to create a default doctor'
        return HttpResponseServerError()

    try:
        doctor2_user = createUser('doctor2', '*****@*****.**', 'd2password')
        doctor2_user.save()
        doctor2 = Doctor(user=doctor2_user)
        doctor2.user_id = doctor2_user.id
        doctor2.registration_time = timezone.now()
        doctor2.save()
    except IntegrityError:
        print 'Failed to create a default doctor'
        return HttpResponseServerError()

    try:
        sample_patient = Patient(first_name="Alexis",
                                 last_name="Advantageous",
                                 gps_coordinates="101010",
                                 address="Yonge street",
                                 date_of_birth="1999-06-10",
                                 phone="646646646464",
                                 health_id="324324234",
                                 gender="Male",
                                 email="*****@*****.**")

        sample_patient.save()
    except IntegrityError:
        print 'Failed to create a default patient'
        return HttpResponseServerError()

    try:
        comment = Comment(author=worker_user,
                          text="Trololololol.",
                          time_posted=timezone.now())
        comment.save()
    except IntegrityError:
        print 'Failed to create a default comment'
        return HttpResponseServerError()

    try:
        comment_group = CommentGroup()
        comment_group.save()
        comment_group.comments.add(comment)
    except IntegrityError:
        print 'Failed to create a default comment group'
        return HttpResponseServerError()

    try:
        sample_case = Case(patient=sample_patient,
                           submitter=worker,
                           lock_holder=None,
                           status=1,
                           priority=10,
                           submitter_comments=comment_group,
                           date_opened="2012-12-12")
        sample_case.save()
    except IntegrityError:
        print 'Failed to create a default worker user'
        return HttpResponseServerError()

    return [
        worker_user, worker, doctor_user, doctor, sample_patient, comment,
        comment_group, sample_case, doctor2_user, doctor2
    ]