Beispiel #1
0
def show(request, id, pid=None, complete=False):
    patient = get_object_or_404(Patient, pk=id)

    if patient.state == "k":
        insurance = patient.get_insurance()

    if pid:
        prescription = Prescription.objects.get(pk=pid)

        form = PrescriptionForm.from_prescription(prescription)
    else:
        form = PrescriptionForm()

    doc = DoctorForm()

    return render_to_response("patient/view.html",
                              locals(),
                              context_instance=RequestContext(request))
Beispiel #2
0
def edit(request, id, pid):
    prescription = get_object_or_404(Prescription, pk=pid)
    patient = get_object_or_404(Patient, pk=id)

    if request.method == "POST":
        form = PrescriptionForm(request.POST)
        doc = DoctorForm(request.POST)

        if form.is_valid() and (form.get("new_doc").value() == "0" or doc.is_valid()):
            prescription = Prescription.from_form(form, patient=patient, prescription=prescription, doctor=doc)

            prescription.save()

            return redirect("%s#%s" % (reverse("show_patient", args=(id,)), request.GET.get("forward", "")))
    else:
        form = PrescriptionForm.from_prescription(prescription, True)
        doc = DoctorForm()

    url_attachment = request.GET.get("forward", None)

    return render_to_response("prescription/edit.html",
                              locals(),
                              context_instance=RequestContext(request))