Esempio n. 1
0
def contactleftLaterPages(canvas):
	textobject = canvas.beginText()
	textobject.setTextOrigin(51.2,57)
	textobject.setFont('Akkurat-Light',9)
	textobject.textLines('''
	510 Victoria Ave
	Venice CA 90291
	www.leftfieldlabs.com
	''')
	canvas.drawText(textobject)
Esempio n. 2
0
def lfleft(canvas):
	textobject = canvas.beginText()
	textobject.setTextOrigin(51.2,749)
	textobject.setFont('Gridnik',27)
	textobject.textLines('''
	LEFT 
	FIELD 
	LABS
	''')
	canvas.drawText(textobject)
Esempio n. 3
0
def drawlines(canvas):
	canvas.setStrokeColorRGB(0.2,0.5,0.3)
	canvas.line(0,0,70,70)
	textobject = canvas.beginText()
	textobject.setTextOrigin(51.2,749)
	textobject.textLines('''
	LEFT 
	FIELD 
	LABS
	''')
	canvas.drawText(textobject)
def to_pdf(request, id):
    history = None
    try:
        history = History.objects.get(dentist=request.user, id=id)
    except:
        messages.error(request,
                       "Error: You are not authorized to view this history")
        return HttpResponseRedirect('/prescription/history/')
    response = HttpResponse(content_type='application/pdf')
    response[
        'Content-Disposition'] = 'attachment;filename="prescription_%d_%s.pdf"' % (
            history.patient.id, str(datetime.datetime.now()))
    buffer = BytesIO()
    p = canvas.Canvas(buffer)
    p.drawCentredString(300, 800, "Confident Dental Care")

    patient = history.patient
    prescription = history.prescription
    dentist = history.dentist

    patientString = '''Name: %s
Age:%s 
Gender: %s
Contact Number: %s
%s
''' % (patient.name, patient.age, patient.gender, patient.contact_number,
       str(datetime.datetime.now()))

    textobject = p.beginText()
    textobject.setTextOrigin(inch, inch * 10.5)
    textobject.textLines(patientString)

    dentistString = '''Dentist: %s
    %s
    Contact: %s
    Email: %s
''' % (dentist.name, dentist.about, dentist.contact_number, dentist.email)

    textobject.moveCursor(inch * 4.5, inch * -1)
    textobject.textLines(dentistString)
    textobject.moveCursor(inch * -4.5, inch * .5)
    textobject.textLine("Rx,")

    count = 1
    for medicine in prescription.recommended_medicines.all():
        textobject.moveCursor(inch * 1, inch * .1)
        medString = "%d. %s : %s %s" % (count, medicine.medicine.medicine_name,
                                        medicine.get_dosage_str(),
                                        medicine.comments)
        textobject.textLine(medString)
        count += 1

    if prescription.recommended_tests.count() > 0:
        textobject.moveCursor(inch * 1, inch * .15)
        textobject.textLine("Recommended Tests")
        count = 1
        for test in prescription.recommended_tests.all():
            textobject.moveCursor(inch * 1, inch * .1)
            testString = "%d. %s" % (count, test.test_name)
            textobject.textLine(testString)
            count += 1
    p.drawText(textobject)

    p.showPage()
    p.save()
    pdf = buffer.getvalue()
    buffer.close()
    response.write(pdf)
    send_prescription(pdf, patient, prescription.created_at)

    return response