def post(self):

        if connection is None:
            return {'message': 'No Connection'}, HTTPStatus.SERVICE_UNAVAILABLE

        data = request.get_json()
        if data is None: return {'message': 'No Data'}, HTTPStatus.BAD_REQUEST
        # doctor = Doctor(
        #     data['first_name'],
        #     data['last_name'],
        #     data['mobile_number'],
        #     data['email_address'],
        #     data['specialization'],
        #     data['qualification'],
        #     data['resid_address'],
        #     data['username']
        #     )

        sql_query = """
            BEGIN
                INSERT INTO doctor (first_name, last_name, mobile_number, email_address, specialization, qualification, resid_address, username) 
                VALUES 
                ( :first_name, :last_name, :mobile_number, :email_address, :specialization, :qualification, :resid_address, :username)
                RETURNING doctor_id INTO :doctor_id;
                COMMIT;
            END;
            """

        with connection.cursor() as cur:
            data['doctor_id'] = cur.var(cx_Oracle.NUMBER)
            cur.execute(sql_query, data)
            data['doctor_id'] = int(data['doctor_id'].getvalue())

        return {'data': data}, HTTPStatus.OK
Beispiel #2
0
    def post(self):

        if connection is None:
            return {'message': 'No Connection'}, HTTPStatus.SERVICE_UNAVAILABLE

        data = request.get_json()
        # receptionist = Receptionist(
        #     data['first_name'],
        #     data['last_name'],
        #     data['mobile_number'],
        #     data['email_address'],
        #     data['username']
        #     )

        sql_query = """
            BEGIN
                INSERT INTO receptionist (first_name, last_name, mobile_number, email_address, username) 
                VALUES 
                ( :first_name, :last_name, :mobile_number, :email_address, :username)
                RETURNING receptionist_id INTO :receptionist_id;
                COMMIT;
            END;
            """

        with connection.cursor() as cur:
            data['receptionist_id'] = cur.var(cx_Oracle.NUMBER)
            cur.execute(sql_query, data)
            data['receptionist_id'] = int(data['receptionist_id'].getvalue())

        connection.close()

        return {'data': data}, HTTPStatus.OK
    def post(self):

        if connection is None:  return {'message':'No Connection'}, HTTPStatus.SERVICE_UNAVAILABLE

        data = request.get_json()
        patient = User_account_details(
            data['username'],
            data['digest_password'],
            datetime.today().strftime('%Y/%m/%d'),
            None
            )

        sql_query = """
            BEGIN
                INSERT INTO user_account_details (username, digest_password, account_created, account_last_login) 
                VALUES 
                ( :username, :digest_password, TO_DATE(:account_created), :account_last_login)
                RETURNING username INTO :username;
                COMMIT;
            END;
            """
        response_data = {'username': None}
        with connection.cursor() as cur:
            response_data['username'] = cur.var(cx_Oracle.VARCHAR2)
            cur.execute(sql_query, data )
            response_data['username'] = str(response_data['username'].getvalue())
            
        connection.close()
        
        return {'data': response_data }, HTTPStatus.OK
Beispiel #4
0
    def post(self):

        if connection is None:
            return {'message': 'No Connection'}, HTTPStatus.SERVICE_UNAVAILABLE

        data = request.get_json()
        # patient = Patient(
        #     data['patient_id'],
        #     data['first_name'],
        #     data['last_name'],
        #     data['age'],
        #     data['mobile_number'],
        #     data['email_address'],
        #     data['guardian_name'],
        #     data['guardian_mobile']
        #     )

        sql_query = """
            BEGIN
                INSERT INTO medication_record (prescription, date_prescribed, medication_issued, doctor_id, patient_id, pharmacist_id) 
                VALUES 
                ( :prescription, TO_DATE(:date_prescribed), TO_DATE(:medication_issued), :doctor_id, :patient_id, :pharmacist_id)
                RETURNING med_record_id INTO :med_record_id;
                COMMIT;
            END;
            """

        with connection.cursor() as cur:
            data['med_record_id'] = cur.var(cx_Oracle.NUMBER)
            cur.execute(sql_query, data)
            data['med_record_id'] = int(data['med_record_id'].getvalue())

        connection.close()

        return {'data': data}, HTTPStatus.OK
    def post(self):
        user = None
        if connection is None:  return {'message':'No Connection'}, HTTPStatus.SERVICE_UNAVAILABLE

        data = request.get_json()
        patient = User_account_details(
            data['username'],
            data['digest_password'],
            None,
            None
            )

        sql_query = """
            BEGIN
                SELECT *  FROM user_account_details WHERE
                username = :username AND digest_password = :digest_password;
            END;
        """
        response_data = {'username': None}
        with connection.cursor() as cur:
            cur.execute(sql_query, data )
            record  = cur.fetchone()

            if record is None:
                connection.close()
                return { 'message': "Unauthorized" }, HTTPStatus.UNAUTHORIZED
            else:
                user = User_account_details(*record)
                user.digest_password = None
        connection.close()
        
        return {'data': user.data }, HTTPStatus.OK
    def post(self):

        if connection is None:
            return {'message': 'No Connection'}, HTTPStatus.SERVICE_UNAVAILABLE

        data = request.get_json()

        sql_query = """
            BEGIN
                INSERT INTO consultant_datetime (consult_id, consult_date, consult_time, status, receptionist_id, doctor_id) 
                VALUES 
                ( TO_DATE(:consult_date, 'yyyy/mm/dd'), TO_DATE(:consult_time,'hh:mm'), :status, :receptionist_id, :doctor_id)
                RETURNING consult_id INTO :consult_id;
                COMMIT;
            END;
            """

        with connection.cursor() as cur:
            data['consult_id'] = cur.var(cx_Oracle.NUMBER)
            cur.execute(sql_query, data)
            data['consult_id'] = int(data['consult_id'].getvalue())

        connection.close()

        return {'data': data}, HTTPStatus.OK
    def delete(self, mobile_number):
        if connection is None: return {'message':'No Connection'}, HTTPStatus.SERVICE_UNAVAILABLE
        
        
        with connection.cursor() as cur:
            if cur.execute('DELETE FROM patient WHERE mobile_number = :mob',{'mob':mobile_number}):
                return {}, HTTPStatus.NO_CONTENT

            else:
                return {'message': 'Operation error' }, HTTPStatus.BAD_REQUEST
                    
        connection.close()
    def delete(self, username):
        if connection is None: return {'message':'No Connection'}, HTTPStatus.SERVICE_UNAVAILABLE
        
        
        with connection.cursor() as cur:
            if cur.execute('DELETE FROM username WHERE username = :uname',{'username':patient_id}):
                return {}, HTTPStatus.NO_CONTENT

            else:
                return {'message': 'Operation error' }, HTTPStatus.BAD_REQUEST
                    
        connection.close()
    def delete(self, doctor_id):

        if connection is None:
            return {'message': 'No Connection'}, HTTPStatus.SERVICE_UNAVAILABLE

        with connection.cursor() as cur:
            if cur.execute('DELETE FROM doctor WHERE doctor_id = :id',
                           {'id': doctor_id}):
                return {}, HTTPStatus.NO_CONTENT

            else:
                return {'message': 'Operation error'}, HTTPStatus.BAD_REQUEST
    def delete(self, patient_id):
        if connection is None:
            return {'message': 'No Connection'}, HTTPStatus.SERVICE_UNAVAILABLE

        with connection.cursor() as cur:
            if cur.execute(
                    'DELETE FROM patient_medical_records WHERE patient_id = :id',
                {'id': patient_id}):
                return {}, HTTPStatus.NO_CONTENT

            else:
                return {'message': 'Operation error'}, HTTPStatus.BAD_REQUEST

        connection.close()
    def delete(self, consult_id):
        if connection is None:
            return {'message': 'No Connection'}, HTTPStatus.SERVICE_UNAVAILABLE

        with connection.cursor() as cur:
            if cur.execute(
                    'DELETE FROM consultant_datetime WHERE consult_id = :id',
                {'id': consult_id}):
                return {}, HTTPStatus.NO_CONTENT

            else:
                return {'message': 'Operation error'}, HTTPStatus.BAD_REQUEST

        connection.close()
    def get(self, mobile_number):
        
        patient = None
        if connection is None: return {'message':'No Connection'}, HTTPStatus.SERVICE_UNAVAILABLE
        
        with connection.cursor() as cur:
            cur.execute('select * from patient where mobile_number = :mob',{'mob':mobile_number})
            record = cur.fetchone()

            if record is None:
                connection.close()
                return {'message':"Not Found"}, HTTPStatus.NOT_FOUND
            else:
                patient = Patient(*record)
                    
        connection.close()
        return {'data': patient.data }, HTTPStatus.OK
    def get(self, pharmacist_id):
        
        doctor = None
        if connection is None: return {'message':'No Connection'}, HTTPStatus.SERVICE_UNAVAILABLE
        
        data =[]
        
        with connection.cursor() as cur:
            cur.execute('select * from pharmacist where pharmacist_id = :id',{'id':pharmacist_id})
            record = cur.fetchone()

            if record is None:
                connection.close()
                return {'message':"Not Found"}, HTTPStatus.NOT_FOUND
            else:
                pharmacist = Pharmacist(*record)
                    
        connection.close()
        return {'data': pharmacist.data }, HTTPStatus.OK
    def get(self):
        
        if connection is None: return {'message':'No Connection'}, HTTPStatus.SERVICE_UNAVAILABLE
        
        data =[]
        
        with connection.cursor() as cur:
            cur.execute('select * from pharmacist')
            records = cur.fetchall()

            if len(records) == 0:   return {'message':"Not Found"}, HTTPStatus.NOT_FOUND
            
            for row in records:
                pharmacist = Pharmacist(*list(row))
                pharmacist.append(pharmacist.data)

        connection.close()
        
        return {'data': data }, HTTPStatus.OK
Beispiel #15
0
    def get(self, appointment_id):

        appointment = None
        if connection is None:
            return {'message': 'No Connection'}, HTTPStatus.SERVICE_UNAVAILABLE

        with connection.cursor() as cur:
            cur.execute('select * from appointment where appointment_id = :id',
                        {'id': appointment_id})
            record = cur.fetchone()

            if record is None:
                connection.close()
                return {'message': "Not Found"}, HTTPStatus.NOT_FOUND
            else:
                appointment = Appointment(*record)

        connection.close()
        return {'data': appointment.data}, HTTPStatus.OK
    def get(self, status):

        if connection is None:
            return {'message': 'No Connection'}, HTTPStatus.SERVICE_UNAVAILABLE

        data = []

        with connection.cursor() as cur:
            cur.execute(
                'select * from consultant_datetime where status = :status',
                {'status': status})
            record = cur.fetchone()

            if record is None:
                connection.close()
                return {'message': "Not Found"}, HTTPStatus.NOT_FOUND
            else:
                consultDateTime = Consultant_datetime(*record)

        connection.close()
        return {'data': data}, HTTPStatus.OK


# class ConsultDoctorResource( Resource ):

#     def get(self, status):

#         if connection is None: return {'message':'No Connection'}, HTTPStatus.SERVICE_UNAVAILABLE

#         data =[]

#         with connection.cursor() as cur:
#             cur.execute('select * from consultant_datetime where status = :status',{'status':status})
#             record = cur.fetchone()

#             if record is None:
#                 connection.close()
#                 return {'message':"Not Found"}, HTTPStatus.NOT_FOUND
#             else:
#                 consultDateTime = Consultant_datetime(*record)

#         connection.close()
#         return {'data': data }, HTTPStatus.OK
Beispiel #17
0
    def get(self, med_record_id):

        medicationRecord = None
        if connection is None:
            return {'message': 'No Connection'}, HTTPStatus.SERVICE_UNAVAILABLE

        with connection.cursor() as cur:
            cur.execute(
                'SELECT * FROM medication_record where med_record_id = :id',
                {'id': med_record_id})
            record = cur.fetchone()

            if record is None:
                connection.close()
                return {'message': "Not Found"}, HTTPStatus.NOT_FOUND
            else:
                medicationRecord = Medication_record(*record)

        connection.close()
        return {'data': medicationRecord.data}, HTTPStatus.OK
Beispiel #18
0
    def get(self, doctor_id):
        appointment = None
        if connection is None:
            return {'message': 'No Connection'}, HTTPStatus.SERVICE_UNAVAILABLE

        data = []
        with connection.cursor() as cur:
            cur.execute('select * from appointment where doctor_id = :id',
                        {'id': doctor_id})
            record = cur.fetchall()

            if len(record) == 0:
                connection.close()
                return {'message': "Not Found"}, HTTPStatus.NOT_FOUND
            else:
                for row in record:
                    appointment = Appointment(*row)
                    data.append(appointment)
        connection.close()
        return {'data': data}, HTTPStatus.OK
Beispiel #19
0
    def get(self):

        if connection is None:
            return {'message': 'No Connection'}, HTTPStatus.SERVICE_UNAVAILABLE

        data = []

        with connection.cursor() as cur:
            cur.execute('SELECT DISTINCT symptom FROM symptons_record')
            records = cur.fetchall()

            if len(records) == 0:
                return {'message': "Not Found"}, HTTPStatus.NOT_FOUND

            for row in records:
                data.append(str(row[0]))

        connection.close()

        return {'data': data}, HTTPStatus.OK
    def get(self):

        if connection is None:
            return {'message': 'No Connection'}, HTTPStatus.SERVICE_UNAVAILABLE

        data = []

        with connection.cursor() as cur:
            cur.execute('select * from doctor')
            records = cur.fetchall()

            if len(records) == 0:

                return {'message': "Not Found"}, HTTPStatus.NOT_FOUND

            for row in records:
                doctor = Doctor(*list(row))
                data.append(doctor.data)

        return {'data': data}, HTTPStatus.OK
    def get(self):

        if connection is None:
            return {'message': 'No Connection'}, HTTPStatus.SERVICE_UNAVAILABLE

        data = []

        with connection.cursor() as cur:
            cur.execute('select * from consultant_datetime')
            records = cur.fetchall()

            if len(records) == 0:
                return {'message': "Not Found"}, HTTPStatus.NOT_FOUND

            for row in records:
                consultantDateTime = Consultant_datetime(*list(row))
                data.append(consultantDateTime.data)

        connection.close()

        return {'data': data}, HTTPStatus.OK
Beispiel #22
0
    def get(self):

        if connection is None:
            return {'message': 'No Connection'}, HTTPStatus.SERVICE_UNAVAILABLE

        data = []

        with connection.cursor() as cur:
            cur.execute('SELECT * from medication_record')
            records = cur.fetchall()

            if len(records) == 0:
                return {'message': "Not Found"}, HTTPStatus.NOT_FOUND

            for row in records:
                medicationRecord = Medication_record(*list(row))
                data.append(medicationRecord.data)

        connection.close()

        return {'data': data}, HTTPStatus.OK
Beispiel #23
0
    def get(self, medical_record_id):

        Medical_records = None
        if connection is None:
            return {'message': 'No Connection'}, HTTPStatus.SERVICE_UNAVAILABLE

        data = []

        with connection.cursor() as cur:
            cur.execute(
                'select * from medical_records where medical_record_id = :id',
                {'id': medical_record_id})
            record = cur.fetchone()

            if record is None:
                connection.close()
                return {'message': "Not Found"}, HTTPStatus.NOT_FOUND
            else:
                medicalRecord = Medical_records(*record)

        connection.close()
        return {'data': medicalRecord.data}, HTTPStatus.OK
    def get(self, consult_id):

        Consultant_datetime = None
        if connection is None:
            return {'message': 'No Connection'}, HTTPStatus.SERVICE_UNAVAILABLE

        data = []

        with connection.cursor() as cur:
            cur.execute(
                'select * from consultant_datetime where consult_id = :id',
                {'id': consult_id})
            record = cur.fetchone()

            if record is None:
                connection.close()
                return {'message': "Not Found"}, HTTPStatus.NOT_FOUND
            else:
                consultantDateTime = Consultant_datetime(*record)

        connection.close()
        return {'data': consultantDateTime.data}, HTTPStatus.OK
    def get(self, specialization):

        data = []
        if connection is None:
            return {'message': 'No Connection'}, HTTPStatus.SERVICE_UNAVAILABLE

        data = []

        with connection.cursor() as cur:
            cur.callproc("doctor_pkg.read_doctor_specialization", [
                specialization,
            ])
            records = get_listformat(cur)

            if records is None:
                return {'message': "Not Found"}, HTTPStatus.NOT_FOUND

            for row in records:
                doctor = Doctor(*list(row))
                data.append(doctor.data)

        return {'data': data}, HTTPStatus.OK
Beispiel #26
0
    def get(self, doctor_id):

        if connection is None:
            return {'message': 'No Connection'}, HTTPStatus.SERVICE_UNAVAILABLE

        data = []

        with connection.cursor() as cur:
            cur.execute(
                'SELECT * FROM doctor_consult_details WHERE doctor_id = :id',
                {'id': doctor_id})
            records = cur.fetchall()

            if len(records) == 0:
                return {'message': "Not Found"}, HTTPStatus.NOT_FOUND

            for row in records:
                doctorConsultDetail = Doctor_consult_details(*list(row))
                data.append(doctorConsultDetail.data)

        connection.close()

        return {'data': data}, HTTPStatus.OK
Beispiel #27
0
    def get(self, medical_record_id):

        if connection is None:
            return {'message': 'No Connection'}, HTTPStatus.SERVICE_UNAVAILABLE

        data = []

        with connection.cursor() as cur:
            cur.execute(
                'SELECT * FROM symptons_record WHERE medical_record_id = :id',
                {'id': medical_record_id})
            records = cur.fetchall()

            if len(records) == 0:
                return {'message': "Not Found"}, HTTPStatus.NOT_FOUND

            for row in records:
                symptomsRecord = Symptoms_record(*list(row))
                data.append(symptomsRecord.data)

        connection.close()

        return {'data': data}, HTTPStatus.OK
    def get(self, patient_id):

        if connection is None:
            return {'message': 'No Connection'}, HTTPStatus.SERVICE_UNAVAILABLE

        data = []

        with connection.cursor() as cur:
            cur.execute(
                'SELECT * FROM patient_medical_records WHERE patient_id = :id',
                {'id': patient_id})
            records = cur.fetchall()

            if len(records) == 0:
                return {'message': "Not Found"}, HTTPStatus.NOT_FOUND

            for row in records:
                patientMedicalRecords = Patient_medical_records(*list(row))
                data.append(patientMedicalRecords.data)

        connection.close()

        return {'data': data}, HTTPStatus.OK
    def get(self, doctor_id):

        doctor = None
        if connection is None:
            return {'message': 'No Connection'}, HTTPStatus.SERVICE_UNAVAILABLE

        data = []

        with connection.cursor() as cur:
            # cur.execute('select * from doctor where doctor_id = :id',{'id':doctor_id})
            cur.callproc("doctor_pkg.read_doctor_id", [
                doctor_id,
            ])

            record = get_listformat(cur)

            if record is None:
                return {'message': "Not Found"}, HTTPStatus.NOT_FOUND
            else:
                [record] = record
                doctor = Doctor(*record)

        return {'data': doctor.data}, HTTPStatus.OK