Exemple #1
0
def tests():
    if current_user.designation == "diagnostic":
        form = Patient_Retr()
        p_li = []
        m_li = []
        if request.method == 'POST':
            p_id = form.patient_id.data
            exists = Patient.query.filter_by(patient_id=p_id).scalar()
            if exists:
                session['p_id'] = int(p_id)
            else:
                flash("Patient does not exists", "danger")
                return redirect('/retrieve')
        elif session['p_id'] is None:
            flash("Enter a id", "danger")
            return redirect('/retrieve')
        details = Patient.query.filter_by(patient_id=session['p_id']).first()
        dia_mas = Diagnosis.query.filter_by(patient_id=session['p_id']).all()
        p_li.append(details)
        m_li.append(dia_mas)
        return render_template("tests.html",
                               retrieve=True,
                               patientdets=p_li,
                               dia_mas=m_li,
                               p_id=session['p_id'],
                               form=form)
    else:
        flash("Not authorised", "danger")
        return redirect('/index')
Exemple #2
0
def bills():
    form = Patient_Retr()
    #if form.validate_on_submit():
    p_li = []
    m_li = []
    d_li = []

    p_id = form.patient_id.data
    exists = Patient.query.filter_by(patient_id=p_id).scalar()
    if exists:
        details = Patient.query.filter_by(patient_id=int(p_id)).first()
        if details.status == "discharged":
            flash("Patient already discharged", "danger")
            return redirect('/index')
        else:
            med_is = Issued_Medicines.query.filter_by(
                patient_id=int(p_id)).all()
            dia_mas = Diagnosis.query.filter_by(patient_id=int(p_id)).all()
            p_li.append(details)
            d_li.append(dia_mas)
            m_li.append(med_is)
            mcosts = 0
            bcosts = 0
            bed = []
            b = 0
            for data in p_li:
                d = (datetime.today() - data.doa).days
                beds = Bed.query.filter_by(bed_type=data.beds).first()
                print(beds)
                bed.append(beds)
                for data in bed:
                    b = data.bed_cost
                    bcosts = d * b

            for rows in m_li:
                for data in rows:
                    mcosts += data.medicine_rate * data.quantity_issued
            dcosts = 0
            for rows in d_li:
                for data in rows:
                    dcosts += data.price
            total = dcosts + mcosts + bcosts
            #print(m_li)
            #return redirect('/index')
            return render_template("bills.html",
                                   billing=True,
                                   patientdets=p_li,
                                   d=d,
                                   b=b,
                                   bedtot=bcosts,
                                   total=total,
                                   totdia=dcosts,
                                   totmed=mcosts,
                                   dia_mas=d_li,
                                   iss_med=m_li,
                                   p_id=p_id,
                                   form=form)
    else:
        flash("Patient does not exists", "danger")
        return redirect('/billing')
Exemple #3
0
def medicine():

    if current_user.designation == "pharmacist":
        form = Patient_Retr()
        #if form.validate_on_submit():
        p_li = []
        m_li = []
        mas_li = []

        p_id = form.patient_id.data
        exists = Patient.query.filter_by(patient_id=p_id).scalar()
        if exists:
            details = Patient.query.filter_by(patient_id=int(p_id)).first()
            med_is = Issued_Medicines.query.filter_by(
                patient_id=int(p_id)).all()
            med_mas = Medicine_MasterFile.query.filter_by().all()
            p_li.append(details)
            m_li.append(med_is)
            mas_li.append(med_mas)
            #print(m_li)
            #return redirect('/index')
            return render_template("medicine.html",
                                   medicine=True,
                                   patientdets=p_li,
                                   iss_med=m_li,
                                   med_mas=mas_li,
                                   p_id=p_id,
                                   form=form)
        else:
            flash("Patient does not exists", "danger")
            return redirect('/pharmacy')
    else:
        flash("Not authorised", "danger")
        return redirect('/index')
Exemple #4
0
def retrieve():
    if current_user.designation == "diagnostic":
        form = Patient_Retr()
        session.pop('p_id', None)
        return render_template("retrieve.html", retrieve=True, form=form)
    else:
        flash("Not authorised", "danger")
        return redirect('/index')
Exemple #5
0
def viewing():
    if current_user.designation == "Desk_executive":
        #return render_template("pharmacy.html",pharamcy=True, patientdets=details, form=form)
        #print("this works")
        form = Patient_Retr()
        return render_template("view.html", viewing=True, form=form)
    else:
        flash("Not authorised", "danger")
        return redirect('/index')
Exemple #6
0
def newview():
    if current_user.designation == "Desk_exective":
        p_li=[]
        form = Patient_Retr()
        p_id = form.patient_id.data
        exists = Patient.query.filter_by(patient_id=p_id).scalar()
        if exists:
            patient=Patient.query.filter_by(patient_id=p_id).first()
            p_li.append(patient)
            return render_template("viewing.html",viewing=True,form=form,p_li=p_li)
        else:
            flash("Patient does not exists","danger")
            return redirect('/viewing')
    else:
        flash("Not authorised","danger")
        return redirect('/index')
Exemple #7
0
def billing():
    form = Patient_Retr()
    return render_template("billing.html", billing=True, form=form)