Beispiel #1
0
def add_medicine_by_name_manufacturer_brand_spec_amount_default_price(
        med_name, med_manufacturer, brand, spec, amount, price):
    sql_helper.exec_sql(
        'INSERT INTO Medicines values (%(med_name)s, %(med_manufacturer)s,%(brand)s, %(spec)s, '
        '%(amount)s, %(price)s)', {
            'med_name': med_name,
            'med_manufacturer': med_manufacturer,
            'brand': brand,
            'spec': spec,
            'amount': amount,
            'price': price
        })

    return sql_helper.fetchall_to_dict(
        "SELECT * FROM Medicines "
        "WHERE med_name = %(med_name)s, med_manufacturer = %(med_manufacturer)s, "
        "brand = %(brand)s, spec = %(spec)s", {
            'med_name': med_name,
            'med_manufacturer': med_manufacturer,
            'brand': brand,
            'spec': spec
        })
Beispiel #2
0
def get_bp_records_by_patient_id(patient_id):
    return sql_helper.fetchall_to_dict(
        "SELECT * FROM BP_Records WHERE patient_id = %(patient_id)s ORDER BY create_time DESC",
        {'patient_id': patient_id})
Beispiel #3
0
def get_medicine_by_med_name(med_name):
    return sql_helper.fetchall_to_dict(
        "SELECT * FROM Medicines"
        " where med_name LIKE %(med_name)s",
        {'med_name': '%' + med_name + '%'})
Beispiel #4
0
def get_patients_by_patient_id(patient_id):
    return sql_helper.fetchall_to_dict(
        "SELECT * FROM Patients WHERE patient_id = %(patient_id)s",
        {'patient_id': patient_id})
Beispiel #5
0
def search_patients(keyword):
    return sql_helper.fetchall_to_dict(
        "SELECT * FROM Patients p WHERE p.name LIKE %(keyword)s",
        {"keyword": '%' + keyword + '%'})
Beispiel #6
0
def get_patients_by_name(name):
    return sql_helper.fetchall_to_dict(
        "SELECT * FROM Patients p WHERE p.name = %(name)s", {'name': name})
Beispiel #7
0
def get_prescriptions_with_medicine_by_patient_name(patient_name):
    return sql_helper.fetchall_to_dict(
        "SELECT uname, patient_id, create_time, prescription_id, med_name, med_manufacturer, brand, spec, name, phone_number"
        " FROM ((Patients NATURAL JOIN Prescriptions) NATURAL JOIN Has_Medicine) p WHERE p.name = %(name)s"
        " ORDER BY patient_id DESC",
        {'name': patient_name})
Beispiel #8
0
def get_all_patients():
    return sql_helper.fetchall_to_dict("SELECT * FROM Patients")
Beispiel #9
0
def get_prescriptions_with_medicine_by_patient_id(patient_id):
    return sql_helper.fetchall_to_dict(
        "SELECT * FROM Prescriptions NATURAL JOIN Has_Medicine WHERE patient_id = %(patient_id)s ORDER BY create_time",
        {'patient_id': patient_id})
Beispiel #10
0
def get_all_paid_unpaid_bills_by_doc_uname(uname, paid):
    return sql_helper.fetchall_to_dict(
        "SELECT * FROM Bills WHERE paid = %(paid), uname = %(uname)s ORDER BY create_time",
        {'uname': uname, 'paid': paid})
Beispiel #11
0
def set_bill_paid_by_bill_id_and_status(bill_id, paid, paid_time):
    return sql_helper.fetchall_to_dict("UPDATE Bills SET paid = %(paid)s"
                                       " WHERE bill_id = %(bill_id)s, paid_time = %(paid_time)s",
                                       {'bill_id': bill_id, 'paid': paid, 'paid_time': paid_time})
Beispiel #12
0
def get_all_bills_by_doc_uname(uname):
    return sql_helper.fetchall_to_dict(
        "SELECT * FROM Bills WHERE uname = %(uname)s ORDER BY create_time",
        {'uname': uname})
Beispiel #13
0
def get_doctors_by_uname(uname):
    return sql_helper.fetchall_to_dict("SELECT u.name, u.email FROM Users u NATURAL JOIN Doctors WHERE uname = %(uname)s",
                                       {'uname': uname})