Example #1
0
def get_all_prescriptions(patient_id):
    try:
        logging.info("received request from patients for all prescriptions")
        return prescriptions.get(patient_id=patient_id)
    except BaseException as bex:
        logging.error(bex.message)
        return Response(status=status.HTTP_500_INTERNAL_SERVER_ERROR)
Example #2
0
def all_requests(patient_id):
    try:
        logging.info("received request from patients for all pending requests")
        return request_documents.get(patient_id=patient_id)
    except BaseException as bex:
        logging.error(bex.message)
        return Response(status=status.HTTP_500_INTERNAL_SERVER_ERROR)
Example #3
0
def get_prescription_details(prescription_id):
    try:
        requester_id = request.args.get("requester_id")
        logging.info("received request from doctor for details prescription")
        return prescriptions.get_detail(prescription_id=prescription_id,
                                        requester_id=requester_id)
    except BaseException as bex:
        logging.error(bex.message)
        return Response(status=status.HTTP_500_INTERNAL_SERVER_ERROR)
Example #4
0
def get_prescription_for_patient(requester_id):
    try:
        logging.info(
            "received request from doctor for prescriptions of patient")
        patient_id = request.args.get("patient_id")
        req_type = request.args.get("req_type")
        return documents.get(requester_id=requester_id,
                             patient_id=patient_id,
                             req_type=req_type)
    except BaseException as bex:
        logging.error(bex.message)
        return Response(status=status.HTTP_500_INTERNAL_SERVER_ERROR)
Example #5
0
def reject_permissions(patient_id):
    try:
        logging.info("grant permission to requestee by patient")
        requester_id = request.form["requester_id"]
        req_type = request.form["req_type"]
        doc_type = request.form["doc_type"]
        return grant_requests.delete(requester_id=requester_id,
                                     patient_id=patient_id,
                                     req_type=req_type,
                                     doc_type=doc_type)
    except BaseException as bex:
        logging.error(bex.message)
        return Response(status=status.HTTP_500_INTERNAL_SERVER_ERROR)
Example #6
0
def create_requests(requester_id):
    try:
        logging.info("received request for document permission")
        patient_id = request.form["patient_id"]
        req_type = request.form["req_type"]
        doc_type = request.form["doc_type"]
        return request_documents.post(requester_id=requester_id,
                                      patient_id=patient_id,
                                      req_type=req_type,
                                      doc_type=doc_type)
    except BaseException as bex:
        logging.error(bex.message)
        return Response(status=status.HTTP_500_INTERNAL_SERVER_ERROR)
 def remove_requests(self, requester_id, patient_id, req_type, doc_type):
     try:
         query = "delete from permission_requests where requester_id ='" + str(requester_id) + \
                 "'and patient_id ='" + str(patient_id) + \
                 "'and requester_type = '" + req_type + \
                 "'and doc_type = '" + doc_type + \
                 "';"
         cur = self.conn.cursor()
         cur.execute(query)
         logging.info(" remove permission request from DB")
         return True
     except BaseException as bex:
         logging.error(bex.message)
         return False
Example #8
0
def remove_grant_permissions(patient_id):
    try:
        logging.info("remove grant permission to requestee by patient")
        requester_id = request.form["requester_id"]
        prescription_id = request.form["prescription_id"]
        req_type = request.form["req_type"]
        return grant_requests.remove_permission(
            requester_id=requester_id,
            patient_id=patient_id,
            prescription_id=prescription_id,
            req_type=req_type)
    except BaseException as bex:
        logging.error(bex.message)
        return Response(status=status.HTTP_500_INTERNAL_SERVER_ERROR)
 def create_request(self, requester_id, patient_id, requester_type,
                    doc_type):
     try:
         query = "insert into permission_requests (requester_id, patient_id, requester_type, doc_type) " \
                 "values ('" + str(requester_id) + \
                 "','" + str(patient_id) + \
                 "','" + requester_type + \
                 "','" + doc_type + \
                 "');"
         cur = self.conn.cursor()
         cur.execute(query)
         logging.info(" Insert permission request into DB")
         return True
     except BaseException as bex:
         logging.error(bex.message)
         return False