Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions servicesB/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,6 @@ def add_rendezvous():
duree = int(duree)
except ValueError as e:
return jsonify({"error": f"Invalid input: {str(e)}"}), 400


response, error = patientServices.add_rendez_vous(config, medecinId, patientId, date, heure, description, duree)

Expand All @@ -547,7 +546,27 @@ def add_rendezvous():
return jsonify(response), 201

except Exception as e:
return jsonify({"error": str(e)}), 500
return jsonify({"error": str(e)}), 500####################################
###################################
@app.route('/delete_rendez_vous', methods=['DELETE'])
def delete_rendez_vous_route():
try:
data = request.json
medecinId = data.get('medecinId')
patientId = data.get('patientId')
date = data.get('date')
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ajoute heure aussi

il peut y avoir plusieurs rdv du meme patient dans la journée


if not medecinId or not patientId or not date:
return jsonify({"error": "Missing required parameters"}), 400

patient, error = patientServices.delete_rendez_vous(app.config, medecinId, patientId, date)

if error:
return jsonify({"error": error}), 404

return jsonify({"message": "Rendez-vous deleted successfully", "patient": patient}), 200

except Exception as e:
return jsonify({"error": str(e)}), 500
if __name__ == '__main__':
app.run(debug=True)
49 changes: 44 additions & 5 deletions servicesB/dal.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ def logIn( config ,username, password):
return None, str(e)
finally:
con.close()

@staticmethod
def get_rendez_vous(config, medecinId, date, startHour, endHour):
print("get RDV")
Expand Down Expand Up @@ -82,8 +81,8 @@ def add_rendez_vous(config, medecinId, patientId, date, heure, description, dure

query = """
INSERT INTO rendez_vous (medecinId, patientId, date, heure, duree, description)
VALUES (%s, %s, %s, %s, %s, %s);
"""
VALUES (%s, %s, %s, %s, %s, %s);
"""
cur.execute(query, (medecinId, patientId, date, heure, duree, description))
_ = cur.fetchone()

Expand All @@ -93,8 +92,48 @@ def add_rendez_vous(config, medecinId, patientId, date, heure, description, dure

finally:
if con:
con.close()
@staticmethod
con.close()

@staticmethod
def delete_rendez_vous(config, medecinId, patientId, date):
print("Deleting RDV")

# Connexion à la base de données
con, error = connect_db(config)
if con is None:
return None, "Connection to database failed: %s" % (error)

try:
# Exécution de la requête SQL avec un curseur contextuel
with con.cursor(dictionary=True) as cur:
query = """
DELETE FROM rendez_vous
WHERE medecinId = %s
AND patientId = %s
AND date = %s;
"""
cur.execute(query, (medecinId, patientId, date))

# Confirmation des modifications
con.commit()

# Vérification du nombre de lignes affectées
if cur.rowcount == 0:
return None, "Aucun enregistrement trouvé pour suppression"

return "Suppression réussie", None

except Exception as e:
# En cas d'exception, retour en arrière de la transaction
con.rollback()
print(f"Exception: {e}")
return None, str(e)

finally:
# Fermeture de la connexion à la base de données
if con:
con.close()
@staticmethod
def fetch_patient_info_by_Id(config, patient_id):
con, error = connect_db(config)
if con is None:
Expand Down
18 changes: 17 additions & 1 deletion servicesB/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,23 @@ def add_rendez_vous(config, medecinId, patientId, date, heure, description, dure
return None, "Rendez-vous déjà pris"
except Exception as e:
return None, e

###########################################################
@staticmethod
def delete_rendez_vous(config, medecinId, patientId, date):
try:
print(f"Tentative de suppression pour rendez-vous du patient {patientId} avec le médecin {medecinId} à la date {date}:")
patient, error = DAOpatients.delete_rendez_vous(config, medecinId, patientId, date)

if error:
print(f"Erreur lors de la suppression : {error}")
return None, "Suppression non trouvée"

print(f"Rendez-vous supprimé avec succès pour le patient {patientId}")
return patient, None
except Exception as e:
print(f"Exception: {e}")
return None, str(e)

###########################################################
def FicheMedicale(config,patient_id):#
try:
Expand Down