Beispiel #1
0
def insert_to_young(name,age,address):
    data=[name,age,address]
    try:
        cur.execute("""INSERT INTO YOUNG(ID,NAME,AGE,ADDRESS) VALUES(NULL,?,?,?);""",data)
        conn.commit()
    except:
        print("can not insert please try again later")
Beispiel #2
0
def insert_care(oid,yid):
    dat=[oid,yid]
    try:
        cur.execute("""INSERT INTO CARE(OID<YID) VALUES(?,?);""",data)
        conn.commit()
    except:
        print("can not insert please try again later")
Beispiel #3
0
def approve_request(oname,yname):
    try:
        yid=get_young_id_by_name(yname)
        oid=get_olie_id_by_name(oname)
        query="UPDATE REQUEST_APPROVE SET REQUEST=1 WHERE OID="+oid+"&& YID="+yid
        cur.execute(query)
        conn.commit()
    except:
        print("can not insert please try again later")
Beispiel #4
0
    def put(self,id):
        """Update the appointment details by the appointment id"""

        appointment = request.get_json(force=True)
        pat_id = appointment['pat_id']
        doc_id = appointment['doc_id']
        conn.execute("UPDATE appointment SET pat_id=?,doc_id=? WHERE app_id=?",
                     (pat_id, doc_id, id))
        conn.commit()
        return appointment
Beispiel #5
0
    def post(self):
        """Create the appoitment by assiciating patient and docter with appointment date"""

        appointment = request.get_json(force=True)
        pat_id = appointment['pat_id']
        doc_id = appointment['doc_id']
        appointment_date = appointment['appointment_date']
        appointment['app_id'] = conn.execute('''INSERT INTO appointment(pat_id,doc_id,appointment_date)
            VALUES(?,?,?)''', (pat_id, doc_id,appointment_date)).lastrowid
        conn.commit()
        return appointment
Beispiel #6
0
def make_request(yname,oname):
        yid=get_young_id_by_name(yname)
        oid=get_olie_id_by_name(oname)
        query="SELECT COUNT(YID) FROM CARE WHERE YID="+str(yid[0])
        data=[oid[0],yid[0]]
        
        if(next(cur.execute(query))[0]<4):
            cur.execute("""INSERT INTO REQUEST_APPROVE(OID,YID,REQUEST) VALUES(?,?,0);""",data)
            conn.commit()
        else:
            print("YOU CANNOT TAKE CARE OF MORE THAN 4 PEOPLE")
Beispiel #7
0
    def put(self, id):
        """Update the medicine by its id"""

        medicineInput = request.get_json(force=True)
        medicine_name = medicineInput['medicine_name']
        desease = medicineInput['desease']
        pat_name = medicineInput['pat_name']
        conn.execute(
            "UPDATE medicine SET medicine_name=?,desease=?,pat_name=? WHERE med_id=?",
            (medicine_name, desease, pat_name, id))
        conn.commit()
        return medicineInput
Beispiel #8
0
    def post(self):
        """Add the new doctor"""

        doctorInput = request.get_json(force=True)
        doc_first_name=doctorInput['doc_first_name']
        doc_last_name = doctorInput['doc_last_name']
        doc_ph_no = doctorInput['doc_ph_no']
        doc_address = doctorInput['doc_address']
        doctorInput['doc_id']=conn.execute('''INSERT INTO doctor(doc_first_name,doc_last_name,doc_ph_no,doc_address)
            VALUES(?,?,?,?)''', (doc_first_name, doc_last_name,doc_ph_no,doc_address)).lastrowid
        conn.commit()
        return doctorInput
    def post(self):
        """api to add the bill in the database"""

        billInput = request.get_json(force=True)
        pat_name = billInput['pat_name']
        amount = billInput['amount']
        bill_date = billInput['bill_date']
        billInput['bill_id'] = conn.execute(
            '''INSERT INTO bill(pat_name,amount)
            VALUES(?,?)''', (pat_name, amount)).lastrowid
        conn.commit()
        return billInput
Beispiel #10
0
    def post(self):
        """Add the new medicine"""

        medicineInput = request.get_json(force=True)
        #med_id=medicineInput['med_id']
        medicine_name = medicineInput['medicine_name']
        desease = medicineInput['desease']
        pat_name = medicineInput['pat_name']
        medicineInput['med_id'] = conn.execute(
            '''INSERT INTO medicine(medicine_name,desease,pat_name)
            VALUES(?,?,?)''', (medicine_name, desease, pat_name)).lastrowid
        conn.commit()
        return medicineInput
Beispiel #11
0
    def put(self, id):
        """api to update the bill by it id"""

        billInput = request.get_json(force=True)
        pat_name = billInput['pat_name']
        amount = billInput['amount']
        bill_date = billInput['bill_date']
        #bill_id = billInput['bill_id']
        #pat_address = billInput['pat_address']
        conn.execute("UPDATE bill SET pat_name=?,amount=? WHERE bill_id=?",
                     (pat_name, amount, id))
        conn.commit()
        return billInput
Beispiel #12
0
    def put(self, id):
        """Update the staff by its id"""

        staffInput = request.get_json(force=True)
        stf_first_name = staffInput['stf_first_name']
        stf_last_name = staffInput['stf_last_name']
        stf_ph_no = staffInput['stf_ph_no']
        stf_address = staffInput['stf_address']
        conn.execute(
            "UPDATE staff SET stf_first_name=?,stf_last_name=?,stf_ph_no=?,stf_address=? WHERE stf_id=?",
            (stf_first_name, stf_last_name, stf_ph_no, stf_address, id))
        conn.commit()
        return staffInput
Beispiel #13
0
    def put(self,id):
        """Update the doctor by its id"""

        doctorInput = request.get_json(force=True)
        doc_first_name=doctorInput['doc_first_name']
        doc_last_name = doctorInput['doc_last_name']
        doc_ph_no = doctorInput['doc_ph_no']
        doc_address = doctorInput['doc_address']
        conn.execute(
            "UPDATE doctor SET doc_first_name=?,doc_last_name=?,doc_ph_no=?,doc_address=? WHERE doc_id=?",
            (doc_first_name, doc_last_name, doc_ph_no, doc_address, id))
        conn.commit()
        return doctorInput
Beispiel #14
0
    def post(self):
        """Add the new staff"""

        staffInput = request.get_json(force=True)
        stf_first_name = staffInput['stf_first_name']
        stf_last_name = staffInput['stf_last_name']
        stf_ph_no = staffInput['stf_ph_no']
        stf_address = staffInput['stf_address']
        staffInput['stf_id'] = conn.execute(
            '''INSERT INTO staff(stf_first_name,stf_last_name,stf_ph_no,stf_address)
            VALUES(?,?,?,?)''',
            (stf_first_name, stf_last_name, stf_ph_no, stf_address)).lastrowid
        conn.commit()
        return staffInput
Beispiel #15
0
    def put(self, id):
        """api to update the patient by it id"""

        patientInput = request.get_json(force=True)
        pat_first_name = patientInput['pat_first_name']
        pat_last_name = patientInput['pat_last_name']
        pat_insurance_no = patientInput['pat_insurance_no']
        pat_ph_no = patientInput['pat_ph_no']
        pat_address = patientInput['pat_address']
        conn.execute(
            "UPDATE patient SET pat_first_name=?,pat_last_name=?,pat_insurance_no=?,pat_ph_no=?,pat_address=? WHERE pat_id=?",
            (pat_first_name, pat_last_name, pat_insurance_no, pat_ph_no,
             pat_address, id))
        conn.commit()
        return patientInput
Beispiel #16
0
    def post(self):
        """api to add the patient in the database"""

        patientInput = request.get_json(force=True)
        pat_first_name = patientInput['pat_first_name']
        pat_last_name = patientInput['pat_last_name']
        pat_insurance_no = patientInput['pat_insurance_no']
        pat_ph_no = patientInput['pat_ph_no']
        pat_address = patientInput['pat_address']
        patientInput['pat_id'] = conn.execute(
            '''INSERT INTO patient(pat_first_name,pat_last_name,pat_insurance_no,pat_ph_no,pat_address)
            VALUES(?,?,?,?,?)''',
            (pat_first_name, pat_last_name, pat_insurance_no, pat_ph_no,
             pat_address)).lastrowid
        conn.commit()
        return patientInput
Beispiel #17
0
    def delete(self,id):
        """Delete teh appointment by its id"""

        conn.execute("DELETE FROM appointment WHERE app_id=?",(id,))
        conn.commit()
        return {'msg': 'sucessfully deleted'}
Beispiel #18
0
    def delete(self, id):
        """Delete the staff by its id"""

        conn.execute("DELETE FROM staff WHERE stf_id=?", (id, ))
        conn.commit()
        return {'msg': 'sucessfully deleted'}
from flask_restful import Resource, Api, request
from model import conn

#billInput = request.get_json(force=True)
pat_name = 'pat'
#bill_date = bill['bill_date']
amount = 25000
conn.execute('''INSERT INTO bill(pat_name,amount)
    VALUES(?,?)''', (pat_name, amount)).lastrowid
conn.commit()
Beispiel #20
0
    def delete(self, id):
        """Delete the doctor by its id"""

        conn.execute("DELETE FROM doctor WHERE doc_id=?", (id,))
        conn.commit()
        return {'msg': 'sucessfully deleted'}
Beispiel #21
0
def insert_to_old(data):
    try:
        cur.execute("""INSERT INTO OLD(ID,NAME,AGE,ADDRESS,FUND) VALUES(NULL,?,?,?,?);""",data)
        conn.commit()
    except:
        print("can not insert please try again later")
Beispiel #22
0
    def delete(self, id):
        """api to delete the patiend by its id"""

        conn.execute("DELETE FROM patient WHERE pat_id=?", (id, ))
        conn.commit()
        return {'msg': 'sucessfully deleted'}
Beispiel #23
0
    def delete(self, id):
        """Delete the medicine by its id"""

        conn.execute("DELETE FROM medicine WHERE med_id=?", (id, ))
        conn.commit()
        return {'msg': 'sucessfully deleted'}