Beispiel #1
0
def prescriptions(request):
    """
    Lists either all patients in the hospital with links to their prescription lists, or the prescriptions applied to a
    single defined patient. 
    :param request: The request sent in, not used here
    :return: List page rendering
    """

    context = {}

    if is_doctor(request.user) or is_nurse(request.user):

        context["Labels"] = ["Name", "Prescriptions"]

        patients = Patient.objects.all()
        prescription_nums = []
        for pat in patients.iterator():
            prescription_nums.append(
                Prescription.objects.filter(patient=pat).count())
        context["Patients"] = zip(patients, prescription_nums)

    elif is_patient(request.user):
        cpatient = Patient.objects.get(user=request.user)
        context = get_prescription_list_for(cpatient)
        context["is_doctor"] = is_doctor(request.user)

    context["is_doctor"] = is_doctor(request.user)

    return render(request, 'prescriptions/list.html', context)
Beispiel #2
0
def is_doctor_or_admin(user):
    """
    Helper function that tells if a user is of type Doctor or Admin
    :param user: user being checked for type
    :return: True if either Doctor or Admin, False otherwise
    """
    return is_doctor(user) or is_admin(user)
Beispiel #3
0
def is_doctor_or_patient(user):
    """
    Checks if user logged in is of type doctor or patient
    :param user: user logged in
    :return: True if user is a doctor or patient
    """
    return is_doctor(user) or is_patient(user)
Beispiel #4
0
def is_doc_or_patient(user):
    """
    Helper function that checks if a user is a doctor or a patient
    :param user: The user to be checked
    :return: True if user is a doctor or a patient
    """
    return is_doctor(user) or is_patient(user)
Beispiel #5
0
def prescriptions_list(request, patient_id):
    """
    Page that doctors and nurses are sent to when accessing a single patient's prescription list.
    :param request: The request sent in, not used here
    :param patient_id: ID of the patient who's being listed
    :return: List page rendering
    """
    cpatient = Patient.objects.get(pk=patient_id)
    context = get_prescription_list_for(cpatient)
    context["is_doctor"] = is_doctor(request.user)

    return render(request, 'prescriptions/list.html', context)
Beispiel #6
0
def is_doctor_or_nurse(user):
    """
    :param user: The User in question
    :return: True if the user is a Doctor or Nurse
    """
    return is_doctor(user) or is_nurse(user)
Beispiel #7
0
 def test_func(self):
     return is_doctor(self.request.user)