Skip to content

Commit

Permalink
no primary key for sql table, updating patient by serial num combined…
Browse files Browse the repository at this point in the history
… with full name
  • Loading branch information
MohammadKhGh99 committed Dec 28, 2024
1 parent b14e6e4 commit 1817ba1
Show file tree
Hide file tree
Showing 2 changed files with 106 additions and 5 deletions.
26 changes: 21 additions & 5 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,14 @@ def save_patient_func(form, update=False):
f" وصف_الحالة = '{description}', "
f"التشخيص = '{diagnosis}',"
f" العلاج = '{therapy}' "
f"where الرقم_التسلسلي = '{serial_num}'")
f"where الرقم_التسلسلي = '{serial_num}' and الإسم_الثلاثي ='{fullname}'")
connection.commit()
flash('تم الحفظ بنجاح!', 'success')
except Exception as e:
connection.rollback()
flash('حدث خطأ أثناء الحفظ! \n' + str(e), 'error')
print(e)
return False
raise e
# condition of adding a new patient
else:
try:
Expand All @@ -90,7 +90,7 @@ def save_patient_func(form, update=False):
connection.rollback()
flash('حدث خطأ أثناء الحفظ! \n' + str(e), 'error')
print(e)
return False
raise e
if update:
return True, (fullname, id_number, serial_year_num, serial_num, status, age, gender, children, prayer, city, phone, work, health, companion, description, diagnosis, therapy)
return True
Expand All @@ -107,7 +107,12 @@ def add_patient():

@app.route('/update-patient', methods=['POST'])
def update_patient():
boolean, results = save_patient_func(request.form, True) # type: ignore - special case don't worry
result = save_patient_func(request.form, True)
if type(result) is tuple:
boolean, results = result
else:
boolean = result
results = []
return render_template('show-search-results.html', fullname=results[0], id=results[1], serialYearNum=results[2],
serialNum=results[3], status=results[4], age=results[5], gender=results[6], children=results[7],
prayer=results[8], city=results[9], phone=results[10], work=results[11], health=results[12], companion=results[13],
Expand Down Expand Up @@ -261,7 +266,7 @@ def create_table():
arabic_sql_create_table = """
create table if not exists Patient(
سنة_الرقم_التسلسلي nvarchar(4),
الرقم_التسلسلي nvarchar(20) primary key,
الرقم_التسلسلي nvarchar(20),
الإسم_الثلاثي nvarchar(45),
الإسم_الشخصي nvarchar(15),
إسم_الأب nvarchar(15),
Expand Down Expand Up @@ -295,6 +300,17 @@ def create_table():


if __name__ == "__main__":
# with sqlite3.connect("Patient.db") as data_connection:
# data_cursor = data_connection.cursor()
# data_cursor.execute("select * from Patient")
# all_data = data_cursor.fetchall()
# data_connection.commit()
# with sqlite3.connect("علاج.db") as empty_connection:
# empty_cursor = empty_connection.cursor()
# for data in all_data:
# empty_cursor.execute("insert into Patient values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
# data)

if not os.path.exists("علاج.db"):
create_table()
webbrowser.open("http://127.0.0.1:5000")
Expand Down
85 changes: 85 additions & 0 deletions conversion-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
{
"version": "auto-py-to-exe-configuration_v1",
"pyinstallerOptions": [
{
"optionDest": "noconfirm",
"value": true
},
{
"optionDest": "filenames",
"value": "C:/Users/m7mdg/D/PersonalCodingProjects/PatientsData-FlaskVersion/app.py"
},
{
"optionDest": "onefile",
"value": false
},
{
"optionDest": "console",
"value": true
},
{
"optionDest": "clean_build",
"value": false
},
{
"optionDest": "strip",
"value": false
},
{
"optionDest": "noupx",
"value": false
},
{
"optionDest": "disable_windowed_traceback",
"value": false
},
{
"optionDest": "uac_admin",
"value": false
},
{
"optionDest": "uac_uiaccess",
"value": false
},
{
"optionDest": "argv_emulation",
"value": false
},
{
"optionDest": "bootloader_ignore_signals",
"value": false
},
{
"optionDest": "datas",
"value": "C:/Users/m7mdg/D/PersonalCodingProjects/PatientsData-FlaskVersion/static;static/"
},
{
"optionDest": "datas",
"value": "C:/Users/m7mdg/D/PersonalCodingProjects/PatientsData-FlaskVersion/templates;templates/"
},
{
"optionDest": "datas",
"value": "C:/Users/m7mdg/D/PersonalCodingProjects/PatientsData-FlaskVersion/client_secrets.json;."
},
{
"optionDest": "datas",
"value": "C:/Users/m7mdg/D/PersonalCodingProjects/PatientsData-FlaskVersion/Constants.py;."
},
{
"optionDest": "datas",
"value": "C:/Users/m7mdg/D/PersonalCodingProjects/PatientsData-FlaskVersion/GDriveConnect.py;."
},
{
"optionDest": "datas",
"value": "C:/Users/m7mdg/D/PersonalCodingProjects/PatientsData-FlaskVersion/\u0639\u0644\u0627\u062c.db;."
},
{
"optionDest": "datas",
"value": "C:/Users/m7mdg/D/PersonalCodingProjects/PatientsData-FlaskVersion/\u0646\u0633\u062e_\u0625\u062d\u062a\u064a\u0627\u0637\u064a.csv;."
}
],
"nonPyinstallerOptions": {
"increaseRecursionLimit": true,
"manualArguments": ""
}
}

0 comments on commit 1817ba1

Please sign in to comment.