def test_serializer_pass(self): expected = [ { "patient_id": 1, "requester_id": 1, "requester_type": "DR", "doc_type": "PR" }, { "patient_id": 1, "requester_id": 2, "requester_type": "DR", "doc_type": "PR" }, { "patient_id": 1, "requester_id": 1, "requester_type": "PH", "doc_type": "PR" }, ] data = [[1, 1, u'DR', u'PR'], [1, 2, u'DR', u'PR'], [1, 1, u'PH', u'PR']] actual = serializer(data=data, table_schema=schema["permission_requests"]) self.assertEqual(actual, expected)
def get_prescription(self, prescription_id): query = "select * from prescriptions where " \ "id = " + str(prescription_id) +\ ";" cur = self.conn.cursor() cur.execute(query) rows = cur.fetchone() details = serializer(data=rows, table_schema=schema["prescriptions"]) logging.info("retrived prescriptions from id") return details
def get_doctors(self, doctor_id): query = "select * from doctors where " \ "id = " + str(doctor_id) + \ ";" cur = self.conn.cursor() cur.execute(query) list = cur.fetchall() data = serializer(data=list, table_schema=schema["doctors"]) logging.info("served doctor by its id") return data
def get_all_requests(self, patient_id): query = "select * from permission_requests where " \ "patient_id = " + str(patient_id) + \ ";" cur = self.conn.cursor() cur.execute(query) list = cur.fetchall() data = serializer(data=list, table_schema=schema["medical_records"]) logging.info(" served all requests for patient") return data
def get_pharmacists(self, pharmacist_id): query = "select * from pharmacists where " \ "id = " + str(pharmacist_id) + \ ";" cur = self.conn.cursor() cur.execute(query) list = cur.fetchall() data = serializer(data=list, table_schema=schema["pharmacists"]) logging.info("served pharmacist by its id") return data
def prescriptions_by_patient_id(self, patient_id): query = "select * from medical_records where " \ "patient_id = " + str(patient_id) + \ ";" cur = self.conn.cursor() cur.execute(query) list = cur.fetchall() data = serializer(data=list, table_schema=schema["medical_records"]) logging.info("served all medical_records of given patient") return data
def get_prescriptions(self, requester_id, patient_id, requester_type): query = "select * from permissions where " \ "requester_id = " + str(requester_id) + \ " and patient_id = " + str(patient_id) + \ " and requester_type = '" + str(requester_type) + \ "';" cur = self.conn.cursor() cur.execute(query) list = cur.fetchall() data = serializer(data=list, table_schema=schema["permissions"]) logging.info(" served prescription to doctors about patients") return data