Exemple #1
0
    def post(self):
        """api to add the patient in the database"""

        try:
            if session['role_id'] == Roles.ADMIN.val():
                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']
                pat_email = patientInput['pat_email']
                pat_password = patientInput['pat_password']
                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
                hashed_password = bcrypt.hashpw(pat_password.encode('utf-8'),
                                                SALT)
                pat_id = patientInput['pat_id']
                r = conn.execute(
                    "INSERT INTO user(id, email, password, role_id) VALUES(?,?,?,?)",
                    (pat_id, pat_email, hashed_password, Roles.PATIENT.val()))
                conn.commit()
                return patientInput
            else:
                return {'status': 401, 'msg': 'Not authorized'}
        except KeyError as no_key:
            return {'status': 403, 'msg': 'Forbidden'}
Exemple #2
0
    def get(self):
        """Retrive the patient, doctor, appointment, medication count for the dashboard page"""

        getPatientCount=conn.execute("SELECT COUNT(*) AS patient FROM patient").fetchone()
        getDoctorCount = conn.execute("SELECT COUNT(*) AS doctor FROM doctor").fetchone()
        getAppointmentCount = conn.execute("SELECT COUNT(*) AS appointment FROM appointment").fetchone()
        getMedicationCount = conn.execute("SELECT COUNT(*) AS medication from medication").fetchone()
        getDepartmentCount = conn.execute("SELECT COUNT(*) AS department FROM department").fetchone()
        getNurseCount = conn.execute("SELECT COUNT(*) AS nurse FROM nurse").fetchone()
        getRoomCount = conn.execute("SELECT COUNT(*) AS room FROM room").fetchone()
        getProcedureCount = conn.execute("SELECT COUNT(*) AS procedure FROM procedure").fetchone()
        getPrescribesCount = conn.execute("SELECT COUNT(*) AS prescribes FROM prescribes").fetchone()
        getUndergoesCount = conn.execute("SELECT COUNT(*) AS undergoes FROM undergoes").fetchone()

        getPatientCount.update(getDoctorCount)
        getPatientCount.update(getAppointmentCount)
        getPatientCount.update(getMedicationCount)
        getPatientCount.update(getDepartmentCount)
        getPatientCount.update(getNurseCount)
        getPatientCount.update(getRoomCount)
        getPatientCount.update(getProcedureCount)
        getPatientCount.update(getPrescribesCount)
        getPatientCount.update(getUndergoesCount)

        return getPatientCount
    def put(self, id):
        """api to update the patient by its id"""

        patientInputPafh = request.get_json(force=True)
        pat_first_name = patientInputPafh['pat_first_name']
        #pat_last_name = patientInput['pat_last_name']
        #pat_insurance_no = patientInput['pat_insurance_no']
        pat_ph_no = patientInputPafh['pat_ph_no']
        #pat_address = patientInput['pat_address']
        pat_age = patientInputPafh['pat_age']
        pat_bp = patientInputPafh['pat_bp']
        pat_cancer = patientInputPafh['pat_cancer']
        pat_diabetes = patientInputPafh['pat_diabetes']
        pat_father = patientInputPafh['pat_father']
        pat_mother = patientInputPafh['pat_mother']
        pat_father_age = patientInputPafh['pat_father_age']
        pat_mother_age = patientInputPafh['pat_mother_age']
        pat_father_bp = patientInputPafh['pat_father_bp']
        pat_father_cancer = patientInputPafh['pat_father_cancer']
        pat_father_diabetes = patientInputPafh['pat_father_diabetes']
        pat_mother_bp = patientInputPafh['pat_mother_bp']
        pat_mother_cancer = patientInputPafh['pat_mother_cancer']
        pat_mother_diabetes = patientInputPafh['pat_mother_diabetes']

        conn.execute(
            "UPDATE patient_history SET pat_first_name=?,pat_ph_no=?,pat_age=?,pat_bp=?,pat_cancer=?,pat_diabetes=?,pat_father=?,pat_mother=?,pat_father_age=?,pat_mother_age=?,pat_father_bp=?,pat_father_cancer=?,pat_father_diabetes=?,pat_mother_bp=?,pat_mother_cancer=?,pat_mother_diabetes=? WHERE pat_id=?",
            (pat_first_name, pat_ph_no, pat_age, pat_bp, pat_cancer,
             pat_diabetes, pat_father, pat_mother, pat_father_age,
             pat_mother_age, pat_father_bp, pat_father_cancer,
             pat_father_diabetes, pat_mother_bp, pat_mother_cancer,
             pat_mother_diabetes, id))
        conn.commit()
        return patientInputPafh
Exemple #4
0
    def put(self, id):

        bed = request.get_json(force=True)
        pat_id = appointment['pat_id']
        conn.execute("UPDATE bed SET pat_id=? WHERE bed_id=?", (pat_id, id))
        conn.commit()
        return bed
Exemple #5
0
 def post(self):
     """Add the new doctor"""
     try:
         if session['role_id'] == Roles.ADMIN.val():
             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']
             doc_password = doctorInput['doc_password']
             doc_email = doctorInput['doc_email']
             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
             hashed_password = bcrypt.hashpw(doc_password.encode('utf-8'),
                                             SALT)
             doc_id = doctorInput['doc_id']
             r = conn.execute(
                 "INSERT INTO user(id, email, password, role_id) VALUES(?,?,?,?)",
                 (doc_id, doc_email, hashed_password, Roles.DOCTOR.val()))
             conn.commit()
             return doctorInput
         else:
             return {'status': 401, 'msg': 'Not authorized'}
     except KeyError as no_key:
         return {'status': 403, 'msg': 'Forbidden'}
    def get(self):
        """Retrive the patient,doctor and appointment count for the dashboard page"""

        getPatientCount=conn.execute("SELECT COUNT(*) AS patient FROM patient").fetchone()
        getDoctorCount = conn.execute("SELECT COUNT(*) AS doctor FROM doctor").fetchone()
        getAppointmentCount = conn.execute("SELECT COUNT(*) AS appointment FROM appointment").fetchone()
        getPatientCount.update(getDoctorCount)
        getPatientCount.update(getAppointmentCount)
        return getPatientCount
Exemple #7
0
    def get(self):
        """Retrive the patient,doctor and appointment count for the dashboard page"""

        getPatientCount=conn.execute("SELECT COUNT(*) AS patient FROM patient").fetchone()
        getDoctorCount = conn.execute("SELECT COUNT(*) AS doctor FROM doctor").fetchone()
        getAppointmentCount = conn.execute("SELECT COUNT(*) AS appointment FROM appointment").fetchone()
        getPatientCount.update(getDoctorCount)
        getPatientCount.update(getAppointmentCount)
        return getPatientCount
Exemple #8
0
    def put(self,department_id):
        """Update the department details by the department id"""

        department = request.get_json(force=True)
        name = department['name']
        head_id = department['head_id']
        conn.execute("UPDATE department SET name=?,head_id=? WHERE department_id=?", (name, head_id, department_id))
        conn.commit()
        return department
    def put(self,code):
        """Update the medication details by the code"""

        medication = request.get_json(force=True)
        name = medication['name']
        brand = medication['brand']
        description = medication['description']
        conn.execute("UPDATE medication SET name=?,brand=?,description=? WHERE code=?", (name, brand, description, code))
        conn.commit()
        return medication
    def put(self,id):
        """Actualiza un turno por 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
Exemple #11
0
    def put(self, room_no):
        """Update the room details by the room_no"""

        room = request.get_json(force=True)
        room_type = room['room_type']
        available = room['available']
        conn.execute("UPDATE room SET room_type=?,available=? WHERE room_no=?",
                     (room_type, available, room_no))
        conn.commit()
        return room
    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
    def put(self, id):

        appointment = request.get_json(force=True)
        pat_id = appointment['pat_id']
        doc_id = appointment['user_id']
        conn.execute(
            "UPDATE appointment SET pat_id=?,user_id=? WHERE app_id=?",
            (pat_id, doc_id, id))
        conn.commit()
        return appointment
Exemple #14
0
    def post(self):
        """Api to add departmentf in the database"""

        department = request.get_json(force=True)
        department_id = department['department_id']
        name = department['name']
        head_id = department['head_id']
        conn.execute('''INSERT INTO department(department_id, name, head_id) VALUES(?,?,?)''', (department_id, name, head_id))
        conn.commit()
        return department
    def put(self, code):
        """Update the procedure details by the code"""

        procedure = request.get_json(force=True)
        name = procedure['name']
        cost = procedure['cost']
        conn.execute("UPDATE procedure SET name=?,cost=? WHERE code=?",
                     (name, cost, code))
        conn.commit()
        return procedure
Exemple #16
0
    def put(self, id):

        patientInput = request.get_json(force=True)
        tests = patientInput['tests']
        charges = patientInput['charges']
        diagnosis = patientInput['diagnosis']
        conn.execute(
            "UPDATE patient SET tests=?, diagnosis=?, charges=? WHERE pat_id=?",
            (tests, diagnosis, charges, id))
        conn.commit()
        return patientInput
Exemple #17
0
    def put(self, id):

        medInput = request.get_json(force=True)
        med_name = medInput['med_name']
        uses = medInput['uses']
        quant = medInput['quant']
        conn.execute(
            "UPDATE medicine SET med_name=?,uses=?,quant=? WHERE med_id=?",
            (med_name, uses, quant, id))
        conn.commit()
        return medInput
    def post(self):
        """Api to add medication in the database"""

        medication = request.get_json(force=True)
        code = medication['code']
        name = medication['name']
        brand = medication['brand']
        description = medication['description']
        conn.execute('''INSERT INTO medication(code, name, brand, description) VALUES(?,?,?,?)''', (code, name, brand, description))
        conn.commit()
        return medication
Exemple #19
0
 def put(self, email):
     personInput = request.get_json(force=True)
     person_email = personInput['person_email']
     person_first_name = personInput['person_first_name']
     person_last_name = personInput['person_last_name']
     person_ph_no = personInput['person_ph_no']
     conn.execute(
         "UPDATE contacts SET person_first_name=?,person_last_name=?,person_ph_no=?, WHERE person_email=?",
         (person_first_name, person_last_name, person_ph_no, person_email))
     conn.commit()
     return personInput
Exemple #20
0
    def register(user):
        # salt = bcrypt.gensalt()
        hashed_password = bcrypt.hashpw(user.password.encode('utf-8'), SALT)
        sql_admin = "INSERT INTO admin(ad_first_name, ad_last_name, ad_gender) VALUES(?,?,?)"
        uid = conn.execute(sql_admin, (user.first_name, user.last_name, 1,))
        print uid
        sql_user = "******"
        uid = conn.execute(
            sql_user, (3, user.email, hashed_password, user.role_id,))

        conn.commit()
Exemple #21
0
 def delete(self, id):
     """api to delete the patiend by its id"""
     try:
         if session['role_id'] == Roles.ADMIN.val():
             conn.execute("DELETE FROM patient WHERE pat_id=?", (id, ))
             conn.commit()
             return {'msg': 'sucessfully deleted'}
         else:
             return {'status': 401, 'msg': 'Not authorized'}
     except KeyError as no_key:
         return {'status': 403, 'msg': 'Forbidden'}
    def post(self):
        """Api to add procedure in the database"""

        procedure = request.get_json(force=True)
        code = procedure['code']
        name = procedure['name']
        cost = procedure['cost']
        conn.execute(
            '''INSERT INTO procedure(code, name, cost) VALUES(?,?,?)''',
            (code, name, cost))
        conn.commit()
        return procedure
    def get(self):
        """Obtiene numero de pacientes activos, numero de terapistas y turnos del mes para el dashboard principal """

        getPatientCount = conn.execute(
            "SELECT COUNT(*) AS patient FROM patient").fetchone()
        getDoctorCount = conn.execute(
            "SELECT COUNT(*) AS doctor FROM doctor").fetchone()
        getAppointmentCount = conn.execute(
            "SELECT COUNT(*) AS appointment FROM appointment").fetchone()
        getPatientCount.update(getDoctorCount)
        getPatientCount.update(getAppointmentCount)
        return getPatientCount
Exemple #24
0
    def post(self):
        """Api to add room in the database"""

        room = request.get_json(force=True)
        room_no = room['room_no']
        room_type = room['room_type']
        available = room['available']
        conn.execute(
            '''INSERT INTO room(room_no, room_type, available) VALUES(?,?,?)''',
            (room_no, room_type, available))
        conn.commit()
        return room
Exemple #25
0
    def put(self, id):
        """api to update the other by it id"""

        otherInput = request.get_json(force=True)
        oth_name = otherInput['oth_name']
        oth_role = otherInput['oth_role']
        oth_ph_no = otherInput['oth_ph_no']
        conn.execute(
            "UPDATE other SET oth_name=?,oth_role=?,oth_ph_no=? WHERE oth_id=?",
            (oth_name, oth_role, oth_ph_no, id))
        conn.commit()
        return otherInput
    def put(self,id):
        """api to update the patient by it id"""

        patientInput = request.get_json(force=True)
        pat_name=patientInput['pat_name']
        pat_disease=patientInput['pat_disease']
        pat_date=patientInput['pat_date']
        pat_address = patientInput['pat_address']
        pat_ph_no = patientInput['pat_ph_no']
        conn.execute('''UPDATE patient SET pat_name=?,pat_disease=?,pat_date=?,pat_address=?,pat_ph_no=? WHERE pat_id=?''',
                     (pat_name,pat_disease,pat_date,pat_address,pat_ph_no,id)).fetchall()
        conn.commit()
        return patientInput
    def put(self, id):
        """Update the nurse by its id"""

        nurseInput = request.get_json(force=True)
        nur_first_name = nurseInput['nur_first_name']
        nur_last_name = nurseInput['nur_last_name']
        nur_ph_no = nurseInput['nur_ph_no']
        nur_address = nurseInput['nur_address']
        conn.execute(
            "UPDATE nurse SET nur_first_name=?,nur_last_name=?,nur_ph_no=?,nur_address=? WHERE nur_id=?",
            (nur_first_name, nur_last_name, nur_ph_no, nur_address, id))
        conn.commit()
        return nurseInput
    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
Exemple #29
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
    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
Exemple #31
0
    def register(user):
        # salt = bcrypt.gensalt()
        hashed_password = bcrypt.hashpw(
            user.password.encode('utf-8'), SALT)
        sql_admin = "INSERT INTO admin(ad_first_name, ad_last_name) VALUES(?,?)"
        uid = conn.execute(sql_admin, (user.first_name,
                                       user.last_name)).lastrowid
        sql_user = "******"
        uid = conn.execute(
            sql_user, (uid, user.email, hashed_password, Roles.ADMIN.val()))
        conn.commit()

        return True
    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
 def get(self):
     """Api to retive all the patient from the database"""
     fingerprint_id = fsearch.search()
     patients = conn.execute(
         "SELECT pat_id FROM patient  where pat_fingerprint_id = ?",
         (fingerprint_id, )).fetchall()
     #pat = json.loads(patients[0])
     print type(patients[0])
     idnew = str(patients[0]['pat_id'])
     appointment = conn.execute(
         '''INSERT INTO appointment(pat_id) VALUES(?)''', (idnew)).lastrowid
     conn.commit()
     return appointment
    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 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
    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'}
    def get(self,id):
        """api to retrive details of the patient by it id"""

        patient = conn.execute("SELECT * FROM patient WHERE pat_id=?",(id,)).fetchall()
        return patient
    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'}
    def get(self):
        """Retrive list of all the doctor"""

        doctors = conn.execute("SELECT * FROM doctor ORDER BY doc_date DESC").fetchall()
        return doctors
    def get(self):
        """Api to retive all the patient from the database"""

        patients = conn.execute("SELECT * FROM patient  ORDER BY pat_date DESC").fetchall()
        return patients
    def get(self,id):
        """get the details of the docktor by the doctor id"""

        doctor = conn.execute("SELECT * FROM doctor WHERE doc_id=?",(id,)).fetchall()
        return doctor