Bonsoir j'ai besion de votre aide pour coriger ce code

eya - Modifié le 19 déc. 2023 à 18:43
mamiemando Messages postés 33081 Date d'inscription jeudi 12 mai 2005 Statut Modérateur Dernière intervention 27 avril 2024 - 19 déc. 2023 à 19:26

Bonjour,

J'ai ce code qui contient des erreurs 

Corrigez les fautes s'il vous plaît

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// Structure pour stocker les informations d'un patient
struct Patient {
    int matricule;
    char nom[50];
    char date_naissance[20];
    char genre[10];
    char descriptionMaladies[100];
    char tonService[50];
    char tonRendezvous[100];
    char tonOrdonnance[90];
    char tonMedecin[50];
    char tonCertificats[30];
};

// Structure pour stocker les informations du patient
struct Patientt {
    char username[50];
    char password[50];
    char maladies[200];
    char ordonnances[200];
    char certificats[200];
    char rendezvous[200];
    char datesRendezvous[200];  // Ajout de la date du rendez-vous
};

// Structure pour stocker les informations d'un médecin
struct Medecin {
    int matricule;
    char nom[50];
    char date_naissance[20];
    char genre[10];
    char signature[30];
    char tonService[50];
    char specialite[15];
    char listePatients[100];
    char listOrdonnances[100];
    char listCertificats[100];
};

// Structure pour stocker les informations d'un service
struct Service {
    int identifiant;
    char nom[50];
    char listPatient[100];
    char listMedecin[100];
};
// Structure pour stocker les informations d'une ordonnance
struct Ordonnance {
    int matriculeMedecin;
    char nomMedecin[50];
    int identifiantPatient;
    char nomPatient[50];
    char signatureMedecin[30];
    char listeMedicaments[100];
};
struct Admin {
    char username[50];
    char password[50];
};

// Structure pour stocker les informations d'un certificat
struct Certificat {
    int identifiant;
    char dateCreation[20];
    char cause[50];
    int identifiantPatient;
    char nomPatient[50];
    int identifiantMedecin;
    char nomMedecin[50];
    char signatureMedecin[30];
};

// Structure pour stocker les informations d'un rendez-vous
struct RendezVous {
    char date[20];
    char autresDetails[100];
};

// Fonction pour sauvegarder la liste des patients dans un fichier
void sauvegarderPatients(struct Patient *patients, int nbPatients) {
    FILE *fichierPatients = fopen("patients.txt", "w");
    if (fichierPatients == NULL) {
        perror("Erreur lors de l'ouverture du fichier patients.txt");
        return;
    }

    for (int i = 0; i < nbPatients; i++) {
        fprintf(fichierPatients, "%d %s %s %s %s %s %s %s %s %s\n",
                patients[i].matricule, patients[i].nom, patients[i].date_naissance, patients[i].genre,
                patients[i].descriptionMaladies, patients[i].tonService, patients[i].tonRendezvous,
                patients[i].tonOrdonnance, patients[i].tonMedecin, patients[i].tonCertificats);
    }

    fclose(fichierPatients);
}

// Fonction pour charger la liste des patients depuis un fichier
void chargerPatients(struct Patient *patients, int *nbPatients) {
    FILE *fichierPatients = fopen("patients.txt", "r");
    if (fichierPatients == NULL) {
        perror("Erreur lors de l'ouverture du fichier patients.txt");
        return;
    }

    while (fscanf(fichierPatients, "%d %s %s %s %s %s %s %s %s %s",
                  &patients[*nbPatients].matricule, patients[*nbPatients].nom,
                  patients[*nbPatients].date_naissance, patients[*nbPatients].genre,
                  patients[*nbPatients].descriptionMaladies, patients[*nbPatients].tonService,
                  patients[*nbPatients].tonRendezvous, patients[*nbPatients].tonOrdonnance,
                  patients[*nbPatients].tonMedecin, patients[*nbPatients].tonCertificats) == 10) {
        (*nbPatients)++;
        if (*nbPatients >= 100) {
            printf("Attention : La capacité maximale des patients a été atteinte.\n");
            break;
        }
    }

    fclose(fichierPatients);
}

// Fonction pour sauvegarder la liste des médecins dans un fichier
void sauvegarderMedecins(struct Medecin *medecins, int nbMedecins) {
    FILE *fichierMedecins = fopen("medecins.txt", "w");
    if (fichierMedecins == NULL) {
        perror("Erreur lors de l'ouverture du fichier medecins.txt");
        return;
    }

    for (int i = 0; i < nbMedecins; i++) {
        fprintf(fichierMedecins, "%d %s %s %s %s %s %s %s %s %s\n",
                medecins[i].matricule, medecins[i].nom, medecins[i].date_naissance, medecins[i].genre,
                medecins[i].signature, medecins[i].tonService, medecins[i].specialite,
                medecins[i].listePatients, medecins[i].listOrdonnances, medecins[i].listCertificats);
    }

    fclose(fichierMedecins);
}

// Fonction pour charger la liste des médecins depuis un fichier
void chargerMedecins(struct Medecin *medecins, int *nbMedecins) {
    FILE *fichierMedecins = fopen("medecins.txt", "r");
    if (fichierMedecins == NULL) {
        perror("Erreur lors de l'ouverture du fichier medecins.txt");
        return;
    }

    while (fscanf(fichierMedecins, "%d %s %s %s %s %s %s %s %s %s",
                  &medecins[*nbMedecins].matricule, medecins[*nbMedecins].nom,
                  medecins[*nbMedecins].date_naissance, medecins[*nbMedecins].genre,
                  medecins[*nbMedecins].signature, medecins[*nbMedecins].tonService,
                  medecins[*nbMedecins].specialite, medecins[*nbMedecins].listePatients,
                  medecins[*nbMedecins].listOrdonnances, medecins[*nbMedecins].listCertificats) == 10) {
        (*nbMedecins)++;
        if (*nbMedecins >= 100) {
            printf("Attention : La capacité maximale des medecins a été atteinte.\n");
            break;
        }
    }

    fclose(fichierMedecins);
}

// Fonction pour sauvegarder la liste des services dans un fichier
void sauvegarderServices(struct Service *services, int nombreServices) {
    FILE *fichierServices = fopen("services.txt", "w");
    if (fichierServices == NULL) {
        perror("Erreur lors de l'ouverture du fichier services.txt");
        return;
    }

    for (int i = 0; i < nombreServices; i++) {
        fprintf(fichierServices, "%d %s %s %s\n",
                services[i].identifiant, services[i].nom, services[i].listPatient, services[i].listMedecin);
    }

    fclose(fichierServices);
}

// Fonction pour charger la liste des services depuis un fichier
void chargerServices(struct Service *services, int *nombreServices) {
    FILE *fichierServices = fopen("services.txt", "r");
    if (fichierServices == NULL) {
        perror("Erreur lors de l'ouverture du fichier services.txt");
        return;
    }

    while (fscanf(fichierServices, "%d %s %s %s",
                  &services[*nombreServices].identifiant, services[*nombreServices].nom,
                  services[*nombreServices].listPatient, services[*nombreServices].listMedecin) == 4) {
        (*nombreServices)++;
        if (*nombreServices >= 100) {
            printf("Attention : La capacité maximale des services a été atteinte.\n");
            break;
        }
    }

    fclose(fichierServices);
}

// Fonction pour sauvegarder la liste des rendez-vous dans un fichier
void sauvegarderRendezVous(struct RendezVous *rendezVous, int nbRendezVous) {
    FILE *fichierRendezVous = fopen("rendezvous.txt", "w");
    if (fichierRendezVous == NULL) {
        perror("Erreur lors de l'ouverture du fichier rendezvous.txt");
        return;
    }

    for (int i = 0; i < nbRendezVous; i++) {
        fprintf(fichierRendezVous, "%s %s\n",
                rendezVous[i].date, rendezVous[i].autresDetails);
    }

    fclose(fichierRendezVous);
}

// Fonction pour charger la liste des rendez-vous depuis un fichier
void chargerRendezVous(struct RendezVous *rendezVous, int *nbRendezVous) {
    FILE *fichierRendezVous = fopen("rendezvous.txt", "r");
    if (fichierRendezVous == NULL) {
        perror("Erreur lors de l'ouverture du fichier rendezvous.txt");
        return;
    }

    while (fscanf(fichierRendezVous, "%s %s",
                  rendezVous[*nbRendezVous].date, rendezVous[*nbRendezVous].autresDetails) == 2) {
        (*nbRendezVous)++;
        if (*nbRendezVous >= 100) {
            printf("Attention : La capacité maximale des rendezvous a été atteinte.\n");
            break;
        }
    }

    fclose(fichierRendezVous);
}

// Fonction pour ajouter un nouveau patient
void ajouterPatient(struct Patient *patients, int *nbPatients) {
if (*nbPatients < 100) {
        printf("Entrez le matricule du patient : ");
        scanf("%d", &patients[*nbPatients].matricule);
        printf("Entrez le nom du patient : ");
        scanf("%s", patients[*nbPatients].nom);
        printf("Entrez la date de naissance du patient : ");
        scanf("%s", patients[*nbPatients].date_naissance);
        printf("Entrez le genre du patient : ");
        scanf("%s", patients[*nbPatients].genre);
        printf("Entrez les services auxquels il est attribué : ");
        scanf("%s", patients[*nbPatients].tonService);
        printf("Décrire la maladie du patient : ");
        scanf("%s", patients[*nbPatients].descriptionMaladies);
        printf("Entrez ses rendez-vous : ");
        scanf("%s", patients[*nbPatients].tonRendezvous);
        printf("Entrez ses ordonnances : ");
        scanf("%s", patients[*nbPatients].tonOrdonnance);
        printf("Entrez ses médecins : ");
        scanf("%s", patients[*nbPatients].tonMedecin);
        printf("Entrez ses certificats : ");
        scanf("%s", patients[*nbPatients].tonCertificats);

        (*nbPatients)++;
    } else {
        printf("Le tableau des patients est plein. Impossible d'ajouter plus de patients.\n");
    }
}

// Fonction pour afficher la liste des patients
void afficherPatients(struct Patient *patients, int nbPatients) {
   printf("Liste des patients :\n");
    for (int i = 0; i < nbPatients; i++) {
        printf("Matricule : %d\n", patients[i].matricule);
        printf("Nom : %s\n", patients[i].nom);
        printf("Date de naissance : %s\n", patients[i].date_naissance);
        printf("Genre : %s\n", patients[i].genre);
        printf("\n");
    }
}

// Fonction pour modifier un patient
void modifierPatient(struct Patient *patients, int nbPatients) {
     int matriculeRecherche;
    printf("Matricule du patient à modifier : ");
    scanf("%d", &matriculeRecherche);
    for (int i = 0; i < nbPatients; i++) {
        if (patients[i].matricule == matriculeRecherche) {
            printf("Nouveau nom : ");
            scanf("%s", patients[i].nom);
            printf("Nouvelle date : ");
            scanf("%s", patients[i].date_naissance);
            printf("Nouveau genre : ");
            scanf("%s", patients[i].genre);

            printf("Patient modifié avec succès\n");
            return;
        }
    }
    printf("Patient non trouvé\n");
}

// Fonction pour supprimer un patient
void supprimerPatient(struct Patient *patients, int *nbPatients) {
   int matriculeRecherche;
    printf("Matricule du patient à supprimer : ");
    scanf("%d", &matriculeRecherche);
    for (int i = 0; i < *nbPatients; i++) {
        if (patients[i].matricule == matriculeRecherche) {
            // Décaler les éléments du tableau pour "supprimer" le patient
            for (int j = i; j < *nbPatients - 1; j++) {
                patients[j] = patients[j + 1];
            }
            (*nbPatients)--;
            printf("Patient supprimé avec succès\n");
            return;
        }
    }
    printf("Patient non trouvé\n");
}

// Fonction pour ajouter un nouveau médecin
void ajouterMedecin(struct Medecin *medecin, int *nbMedecins) {
   if (*nbMedecins < 100) {
        printf("Entrez le matricule du medecin : ");
        scanf("%d", &medecin[*nbMedecins].matricule);
        printf("Entrez le nom du medecin : ");
        scanf("%s", medecin[*nbMedecins].nom);
        printf("Entrez la date de naissance du medecin : ");
        scanf("%s", medecin[*nbMedecins].date_naissance);
        printf("Entrez le genre du medecin : ");
        scanf("%s", medecin[*nbMedecins].genre);
        printf("Entrez sa signature : ");
        scanf("%s", medecin[*nbMedecins].signature);
        printf("Entrez le service qui lui appartient : ");
        scanf("%s", medecin[*nbMedecins].tonService);
        printf("Entrez sa spécialité : ");
        scanf("%s", medecin[*nbMedecins].specialite);
        printf("Entrez la liste des patients qui lui sont attribués : ");
        scanf("%s", medecin[*nbMedecins].listePatients);
        printf("Entrez la liste des ordonnances prescrites : ");
        scanf("%s", medecin[*nbMedecins].listOrdonnances);
        printf("Entrez la liste de ses certificats émis : ");
        scanf("%s", medecin[*nbMedecins].listCertificats);

        (*nbMedecins)++;
    } else {
        printf("Le tableau des medecins est plein. Impossible d'ajouter plus de medecins.\n");
    }
}

// Fonction pour modifier un médecin
void modifierMedecin(struct Medecin *medecin, int nbMedecins) {
    int matriculeRecherche;
    printf("Matricule du medecin à modifier : ");
    scanf("%d", &matriculeRecherche);
    for (int i = 0; i < nbMedecins; i++) {
        if (medecin[i].matricule == matriculeRecherche) {
            printf("Nouveau nom : ");
            scanf("%s", medecin[i].nom);
            printf("Nouvelle date : ");
            scanf("%s", medecin[i].date_naissance);
            printf("Nouveau genre : ");
            scanf("%s", medecin[i].genre);
            printf("Nouvelle signature : ");
            scanf("%s", medecin[i].signature);
            printf("Nouveau service qui lui appartient : ");
            scanf("%s", medecin[i].tonService);
            printf("Nouvelle spécialité : ");
            scanf("%s", medecin[i].specialite);
            printf("Entrez la liste des patients qui lui sont attribués : ");
            scanf("%s", medecin[i].listePatients);
            printf("Entrez la liste des ordonnances prescrites : ");
            scanf("%s", medecin[i].listOrdonnances);
            printf("Entrez la liste de ses certificats émis : ");
            scanf("%s", medecin[i].listCertificats);

            printf("Medecin modifié avec succès\n");
            return;
        }
    }
    printf("Medecin non trouvé\n");
}

// Fonction pour supprimer un médecin
void supprimerMedecin(struct Medecin *medecin, int *nbMedecins) {
    int matriculeRecherche;
    printf("Matricule du medecin à supprimer : ");
    scanf("%d", &matriculeRecherche);
    for (int i = 0; i < *nbMedecins; i++) {
        if (medecin[i].matricule == matriculeRecherche) {
            for (int j = i; j < *nbMedecins - 1; j++) {
                medecin[j] = medecin[j + 1];
            }
            (*nbMedecins)--;
            printf("Medecin supprimé avec succès\n");
            return;
        }
    }
    printf("Medecin non trouvé\n");
}

// Fonction pour ajouter un nouveau service
void ajouterService(struct Service services[], int *nombreServices) {
    printf("Nouveau service :\n");
    printf("Identifiant : ");
    scanf("%d", &services[*nombreServices].identifiant);
    printf("Nom : ");
    scanf("%s", services[*nombreServices].nom);
    printf("La liste des médecins : ");
    scanf("%s", services[*nombreServices].listMedecin);
    printf("La liste des patients : ");
    scanf("%s", services[*nombreServices].listPatient);
    (*nombreServices)++;
}

// Fonction pour modifier un service
void modifierService(struct Service services[], int nombreServices) {
   int identifiantRecherche;
    printf("Identifiant du service à modifier : ");
    scanf("%d", &identifiantRecherche);
    for (int i = 0; i < nombreServices; i++) {
        if (services[i].identifiant == identifiantRecherche) {
            printf("Nouveau nom du service : ");
            scanf("%s", services[i].nom);
            printf("Nouveau list des medecins : ");
            scanf("%s", services[i].listMedecin);
            printf("Nouveau list des patients : ");
            scanf("%s", services[i].listPatient);
            printf("Service modifié avec succès\n");
            return;
        }
    }
    printf("Service non trouvé\n");
}

// Fonction pour supprimer un service
void supprimerService(struct Service services[], int *nombreServices) {
    int identifiantRecherche;
    printf("Identifiant du service à supprimer : ");
    scanf("%d", &identifiantRecherche);
    for (int i = 0; i < *nombreServices; i++) {
        if (services[i].identifiant == identifiantRecherche) {
            for (int j = i; j < *nombreServices - 1; j++) {
                services[j] = services[j + 1];
            }
            (*nombreServices)--;
            printf("Service supprimé avec succès\n");
            return;
        }
    }
    printf("Service non trouvé\n");
}
struct JourFerie {
    int jour;
    int mois;
};

// Ajouter la liste des jours fériés
struct JourFerie joursFeries[] = {{1, 1}, {1, 5}, {14, 7}, {1, 11}, {25, 12}};
int nbJoursFeries = sizeof(joursFeries) / sizeof(joursFeries[0]);

// Fonction pour vérifier la validité d'un rendez-vous
int estRendezVousValide(struct Medecin medecin, char dateRendezVous[20], struct RendezVous rendezVous[], int nbRendezVous) {
    // Vérifier si la date correspond à un jour férié
    int jour, mois;
    scanf(dateRendezVous, "%d/%d", &jour, &mois);
    for (int i = 0; i < nbJoursFeries; i++) {
        if (joursFeries[i].jour == jour && joursFeries[i].mois == mois) {
            printf("Le rendez-vous est un jour férié. Choisissez une autre date.\n");
            return 1;
        }
}
}

// Fonction pour ajouter un rendez-vous
void ajouterRendezVous(struct Patient *patient, struct Medecin *medecin, struct RendezVous rendezVous[], int *nbPatients, int *nbRendezVous) {
    printf("Entrez la date du rendez-vous (format JJ/MM) : ");
    scanf("%s", patient[*nbPatients].tonRendezvous);

    // Vérifier si le rendez-vous est valide
    if (estRendezVousValide(*medecin, patient[*nbPatients].tonRendezvous, rendezVous, *nbRendezVous)) {
        printf("Autres détails du rendez-vous : ");
        scanf("%s", rendezVous[*nbRendezVous].autresDetails);

        // Enregistrez la date du rendez-vous pour le suivi
        strcpy(rendezVous[*nbRendezVous].date, patient[*nbPatients].tonRendezvous);

        (*nbPatients)++;
        (*nbRendezVous)++;
        printf("Rendez-vous ajouté avec succès.\n");
    } else {
        printf("Rendez-vous non valide. Veuillez réessayer.\n");
    }
}

int trouverPatientParIdentifiant(struct Patient *patients, int nbPatients, int idPatient) {
    for (int i = 0; i < nbPatients; i++) {
        if (patients[i].matricule == idPatient) {
            return i;
        }
    }
    return -1;
}
 // Recherche du patient par identifiant
int indexPatient = trouverPatientParIdentifiant(patients, nbPatients, idPatient);
    if (indexPatient == -1) {
        printf("Patient non trouvé.\n");
        return ;
    }

void lireLigne(char *chaine, int taille) {
    fgets(chaine, taille, stdin);
    // Supprimer le retour à la ligne
    size_t len = strlen(chaine);
    if (len > 0 && chaine[len - 1] == '\n') {
        chaine[len - 1] = '\0';
    }
    
// Fonction pour rédiger une ordonnance
void redigerOrdonnance(struct Medecin *medecin, struct Patient *patients, struct Ordonnance *ordonnances, int *nbOrdonnances) {
    int idPatient,nbPatients;
    printf("Entrez l'identifiant du patient : ");
    scanf("%d", &idPatient);
    

    // Création d'une nouvelle ordonnance
    struct Ordonnance nouvelleOrdonnance;
    nouvelleOrdonnance.matriculeMedecin = medecin->matricule;
    strcpy(nouvelleOrdonnance.nomMedecin, medecin->nom);
    nouvelleOrdonnance.identifiantPatient = patients[indexPatient].matricule;
    strcpy(nouvelleOrdonnance.nomPatient, patients[indexPatient].nom);
    printf("Entrez la liste des médicaments : ");
    lireLigne(nouvelleOrdonnance.listeMedicaments, sizeof(nouvelleOrdonnance.listeMedicaments));

    // Ajout de la nouvelle ordonnance à la liste
    ordonnances[*nbOrdonnances] = nouvelleOrdonnance;
    (*nbOrdonnances)++;

    printf("Ordonnance rédigée avec succès.\n");
}
int trouverPatientParIdentifiant(struct Patient *patients, int nbPatients, int idPatient);
// Fonction pour rédiger un certificat
void redigerCertificat(struct Medecin *medecin, struct Patient *patients, struct Certificat *certificats, int *nbCertificats, int nbPatients) {
    int idPatient;
    printf("Entrez l'identifiant du patient : ");
    scanf("%d", &idPatient);

    // Recherche du patient par identifiant
    int indexPatient = trouverPatientParIdentifiant(patients, nbPatients, idPatient);
    if (indexPatient == -1) {
        printf("Patient non trouvé.\n");
        return;
    }

    // Création d'un nouveau certificat
    struct Certificat nouveauCertificat;
    nouveauCertificat.identifiant = (*nbCertificats) + 1; // Identifiant unique
    time_t now;
    time(&now);
    struct tm *local = localtime(&now);
    strftime(nouveauCertificat.dateCreation, sizeof(nouveauCertificat.dateCreation), "%Y-%m-%d", local);
    printf("Entrez la cause du certificat : ");
    lireLigne(nouveauCertificat.cause, sizeof(nouveauCertificat.cause));
    nouveauCertificat.identifiantPatient = patients[indexPatient].matricule;
    strcpy(nouveauCertificat.nomPatient, patients[indexPatient].nom);
    nouveauCertificat.identifiantMedecin = medecin->matricule;
    strcpy(nouveauCertificat.nomMedecin, medecin->nom);
    strcpy(nouveauCertificat.signatureMedecin, medecin->signature);

    // Ajout du nouveau certificat à la liste
    certificats[*nbCertificats] = nouveauCertificat;
    (*nbCertificats)++;

    printf("Certificat rédigé avec succès.\n");
}

// Fonction pour consulter la liste des certificats d'un patient
void consulterCertificats(struct Patient *patients, struct Certificat *certificats, int nbCertificats, int nbPatients) {
    int idPatient;
    printf("Entrez l'identifiant du patient : ");
    scanf("%d", &idPatient);

    // Recherche du patient par identifiant
    int indexPatient = trouverPatientParIdentifiant(patients, int nbPatients, idPatient);
    if (indexPatient == -1) {
        printf("Patient non trouvé.\n");
        return;
    }

    printf("Certificats pour le patient %s :\n", patients[indexPatient].nom);

    for (int i = 0; i < nbCertificats; i++) {
        if (certificats[i].identifiantPatient == idPatient) {
            printf("Identifiant : %d\n", certificats[i].identifiant);
            printf("Date de création : %s\n", certificats[i].dateCreation);
            printf("Cause : %s\n", certificats[i].cause);
            printf("Nom du médecin : %s\n", certificats[i].nomMedecin);
            printf("Signature du médecin : %s\n", certificats[i].signatureMedecin);
            printf("\n");
        }
    }
}

void adminLogin(struct Admin *admins, int nbAdmins) {
    char username[50];
    char password[50];
    void lireLigne(char *chaine, int taille);

    printf("Nom d'utilisateur : ");
    lireLigne(username, sizeof(username));

    printf("Mot de passe : ");
    lireLigne(password, sizeof(password));

    // Recherche de l'administrateur par nom d'utilisateur et mot de passe
    int i;
for (i = 0; i < nbAdmins; i++) {
    if (strcmp(admins[i].username, username) == 0 && strcmp(admins[i].password, password) == 0) {
        printf("Bienvenue, %s!\n", username);
        break;
    }
}
    }

    if (i == nbAdmins) {
        printf("Identifiant ou mot de passe incorrect.\n");
    }
}


// Fonction pour l'authentification
int authentifier(struct Patientt *patients, int nbPatients, char *username, char *password) {
    for (int i = 0; i < nbPatients; ++i) {
        if (strcmp(username, patients[i].username) == 0 && strcmp(password, patients[i].password) == 0) {
            return i;  // Retourne l'indice du patient authentifié
        }
    }
    return -1;  // Retourne -1 si l'authentification échoue
}

// Fonction pour demander un certificat
void demanderCertificat(struct Patientt *patient) {
    printf("Demande de certificat pour le patient %s.\n", patient->username);
    // Ajouter la logique pour générer le certificat (exemple: saisie manuelle)
    char certificat[50];
    char date[20];
    printf("Entrez la date de votre certificat: ");
    scanf(" %[^\n]s", date);
    printf("Entrez les détails du certificat: ");
    scanf(" %[^\n]s", certificat);
    strcat(patient->certificats, certificat);
    strcat(patient->certificats, "\n");
    printf("Certificat généré avec succès.\n");
}

// Fonction pour demander un rendez-vous
void demanderRendezVous(struct Patientt *patient) {
    printf("Demande de rendez-vous pour le patient %s.\n", patient->username);
    // Ajouter la logique pour planifier le rendez-vous (exemple: saisie manuelle)
    char rendezvous[100];
    char ser[20];
    char dat[20];
    printf("Choisissez le service où vous souhaitez passer la visite médicale  ");
    scanf(" %[^\n]s", ser);
    printf("entrer la date adaptable à votre disponibilité :");
    scanf(" %[^\n]s", dat);
    strcat(patient->rendezvous, rendezvous);
    strcat(patient->rendezvous, "\n");
    strcat(patient->datesRendezvous, dat);  // Ajout de la date du rendez-vous
    strcat(patient->datesRendezvous, "\n");
    printf("Rendez-vous planifié avec succès.\n");
}

// Fonction pour rappeler les rendez-vous
void rappelerRendezVous(struct Patientt *patient) {
    printf("ce patient a un rendezvous le jour suivant %s:\n", patient->username);
    // Afficher les rendez-vous avec les dates correspondantes
    char *tokenRendezvous = strtok(patient->rendezvous, "\n");
    char *tokenDates = strtok(patient->datesRendezvous, "\n");

    while (tokenRendezvous != NULL && tokenDates != NULL) {
        printf("Date: %s, Rendez-vous: %s\n", tokenDates, tokenRendezvous);
        tokenRendezvous = strtok(NULL, "\n");
        tokenDates = strtok(NULL, "\n");
    }
}

// Fonction pour consulter le dossier médical
void consulterDossierMedical(struct Patientt *patient) {
    printf("Dossier médical du patient %s:\n", patient->username);
    printf("Maladies: %s\n", patient->maladies);
    printf("Ordonnances: %s\n", patient->ordonnances);
    printf("Certificats: %s\n", patient->certificats);
    rappelerRendezVous(patient);  // Utiliser la fonction rappelerRendezVous pour afficher les rendez-vous
}


void lireLigne(char *chaine, int taille);
int trouverPatientParIdentifiant(struct Patient *patients, int nbPatients, int idPatient);
void redigerCertificat(struct Medecin *medecin, struct Patient *patients, struct Certificat *certificats, int *nbCertificats, int nbPatients);
void consulterCertificats(struct Patient *patients, struct Certificat *certificats, int *nbCertificats);
void redigerDossierMalade(struct Patient **patients, int nbPatients, int indexMedecin);
int main() {
    int choix;
    struct Patient patients[100];
    int nbPatients = 0;

    struct Medecin medecins[100];
    int nbMedecins = 0;

    struct Service services[100];
    int nombreServices = 0;

    struct RendezVous rendezVous[100];
    int nbRendezVous = 0;

    struct Ordonnance ordonnances[100];
    int nbOrdonnances = 0;

    struct Certificat certificats[100];
    int nbCertificats = 0;

    struct Admin admin = {"admin", "admin"};
    int nbCertificat =0;
    // Charger les données depuis les fichiers
    chargerPatients(patients, &nbPatients);
    chargerMedecins(medecins, &nbMedecins);
    chargerServices(services, &nombreServices);
    chargerRendezVous(rendezVous, &nbRendezVous);
    chargerOrdonnances(ordonnances, &nbOrdonnances);
    chargerCertificats(certificats, &nbCertificats);
     
     
     
     // Exemple avec deux patients
    struct Patientt patients[2];
    strcpy(patients[0].username, "patient1");
    strcpy(patients[0].password, "pass1");
    patients[0].maladies[0] = '\0';
    patients[0].ordonnances[0] = '\0';
    patients[0].certificats[0] = '\0';
    patients[0].rendezvous[0] = '\0';
    patients[0].datesRendezvous[0] = '\0';

    strcpy(patients[1].username, "patient2");
    strcpy(patients[1].password, "pass2");
    patients[1].maladies[0] = '\0';
    patients[1].ordonnances[0] = '\0';
    patients[1].certificats[0] = '\0';
    patients[1].rendezvous[0] = '\0';
    patients[1].datesRendezvous[0] = '\0';

   
    char username[50];
    char password[50];
    int indexPatient;
    
    
    printf("Veuillez vous authentifier:\n");
    printf("Nom d'utilisateur: ");
    scanf("%s", username);
    printf("Mot de passe: ");
    scanf("%s", password);

    indexPatient = authentifier(patients, 2, username, password);

    if (indexPatient != -1) {
        printf("Authentification réussie.\n");
    
while (1) {
    printf("Bienvenue\n");
    printf("1. Bloc de l'administrateur\n");
    printf("2. Bloc pour les médecins\n");
    printf("3. Bloc pour les patients\n");
    printf("Entrez votre bloc : ");
    scanf("%d", &choix);

    switch (choix) {
        case 1:
             if (strcmp(inputUsername, admin.username) == 0 && strcmp(inputPassword, admin.password) == 0) {
            do {
                printf("Menu administrateur :\n");
                printf("1. Ajouter un nouveau service\n");
                printf("2. Modifier un service\n");
                printf("3. Supprimer un service\n");
                printf("4. Ajouter un nouveau médecin\n");
                printf("5. Modifier un médecin\n");
                printf("6. Supprimer médecin\n");
                printf("7. Ajouter un patient\n");
                printf("8. Modifier un patient\n");
                printf("9. Supprimer un patient\n");
                printf("10. Afficher la liste des patients\n");
                printf("11. Planifier les rendez-vous\n");
                printf("12. Quitter\n");
                printf("Entrez votre choix : ");
                scanf("%d", &tonchoix);

                switch (tonchoix) {
                    case 1:
                        ajouterService(services, &nombreServices);
                        break;
                    case 2:
                        modifierService(services, nombreServices);
                        break;
                    case 3:
                        supprimerService(services, &nombreServices);
                        break;
                    case 4:
                        ajouterMedecin(medecins, &nbMedecins);
                        break;
                    case 5:
                        modifierMedecin(medecins, nbMedecins);
                        break;
                    case 6:
                        supprimerMedecin(medecins, &nbMedecins);
                        break;
                    case 7:
                        ajouterPatient(patients, &nbPatients);
                        break;
                    case 8:
                        modifierPatient(patients, nbPatients);
                        break;
                    case 9:
                        supprimerPatient(patients, &nbPatients);
                        break;
                    case 10:
                        afficherPatients(patients, nbPatients);
                        break;
                    case 11:
                        ajouterRendezVous(patients, medecins, rendezVous, &nbPatients, &nbRendezVous);
                        break;
                    case 12:
                        printf("Au revoir !\n");
                        break;
                    default:
                        printf("Choix invalide. Veuillez réessayer.\n");
                }
            } while (tonchoix != 11);}
            break;
            else {
                printf("Vérifiez vos données s'il vous plaît");
            }           
            
        case 2:
             do {
                printf("Menu médecin :\n");
                printf("1. Rédiger le dossier du malade\n");
                printf("2. Rédiger des ordonnances\n");
                printf("3. Rédiger des certificats\n");
                printf("4. Consulter la liste des certificats d'un patient\n");
                printf("5. Quitter\n");
                printf("Entrez votre choix : ");
                scanf("%d", &tonchoix);

                switch (tonchoix) {
                     case 1:
                        redigerDossierMalade(&patients, nbPatients, indexMedecin);
                        break;
                    case 2:
                        redigerOrdonnance(&medecins[indexMedecin], patients, ordonnances, nbOrdonnances);
                        break;
                    case 3:
                        redigerCertificat(&medecins[indexMedecin], patients, certificats, nbCertificats, nbPatients);
                        break;
                    case 4:
                        consulterCertificats(certificats, nbCertificats);
                        break;
                    case 5:
                        printf("Déconnexion.\n");
                        break;
                    default:
                            printf("Choix invalide. Veuillez réessayer.\n");
                    }
            } while (tonchoix != 5);
            break;
        case 3:
            do {
            printf("\nMenu principal:\n");
            printf("1. Demander un certificat\n");
            printf("2. Demander un rendez-vous\n");
            printf("3. Rappeler les rendez-vous\n");
            printf("4. Consulter le dossier médical\n");
            printf("0. Quitter\n");
            printf("Choix: ");
            scanf("%d", &tonchoix);

            switch (tonchoix) {
                case 1:
                    demanderCertificat(&patients[indexPatient]);
                    break;
                case 2:
                    demanderRendezVous(&patients[indexPatient]);
                    break;
                case 3:
                    rappelerRendezVous(&patients[indexPatient]);
                    break;
                case 4:
                    consulterDossierMedical(&patients[indexPatient]);
                    break;
                case 0:
                    printf("Au revoir!\n");
                    break;
                default:
                    printf("Choix invalide. Veuillez réessayer.\n");
            }
        } while (tonchoix != 0);
     else {
        printf("Echec de l'authentification. Veuillez vérifier vos informations.\n");
    }


    return 0;
}

Modération : merci d'utiliser les balises de code, comme expliqué ici.
Windows / Chrome 119.0.0.0

3 réponses

mamiemando Messages postés 33081 Date d'inscription jeudi 12 mai 2005 Statut Modérateur Dernière intervention 27 avril 2024 7 749
19 déc. 2023 à 19:26

Bonjour,

Tout d'abord, il n'est pas très stratégique de poser une question sous cette forme dans un forum. Ça donne un peu l'impression de déléguer ton travail. Généralement, on attend un problème précis sur un extrait de code minimal. Ici on a plus de 900 lignes de codes et pleins de problèmes. C'est donc une discussion, qui une fois résolue, sera complètement inexploitable.

Ensuite, vu ton code, je pense que tu as un problème de méthodologie.

  • Vues certaines erreurs, je doute que tu utilises un environnement de développement (IDE) adapté pour faire du C/C++.
    • On a vite fait d'oublier de fermer une accolade (ou d'en fermer une de trop), il faut donc être TRÈS rigoureux à ce niveau. Et le meilleur moyen d'y arriver c'est de bien indenter son code. Et heureusement, tout IDE digne de ce nom permet d'indenter tout un fichier (éventuellement mal indenté).
    • En l'occurrence, dans ton code, certaines accolades ne sont pas fermées (ou pas au bon endroit) -- voir plus loin.
  • Ton code donne l'impression d'avoir été écrit d'une traite.
    • Je te conseille plutôt de développer chaque fonction petit à petit, et à chaque fois que tu fais un ajout, de vérifier si le code compile toujours et fait toujours ce qu'il est supposé faire. Cela évite d'avoir des dizaines d'erreurs qui s'amoncellent.
      • Si tu te disciplines à procéder ainsi, tu auras peu d'erreur entre deux compilations, et tu seras quelles lignes sont concernées (celles que tu viens d'ajouter).
    • Pour reprendre ton travail suivant cette méthodologie, commente par exemple tout ton code, sauf la fonction main. Dans la fonction main, décommente le code jusqu'au premier appel d'une autre fonction, et commente toute la fin, puis compile et vérifie si ça marche. Et ainsi de suite en décommentant progressivement chaque fonction.

Voici quelques une des erreurs les plus flagrantes :

1)

// Recherche du patient par identifiant
int indexPatient = trouverPatientParIdentifiant(patients, nbPatients, idPatient);
if (indexPatient == -1) {
printf("Patient non trouvé.\n");
return ;
}

Ce bout de code n'est dans aucune fonction. Or ce n'est pas autorisé en C/C++.  De plus l'appel mixe une déclaration et un appel (car l'un des arguments est précédé d'un type). Je pense que ce bloc a été déplacé par erreur en dehors de redigerOrdonnance. Peut-être que le type est un tentative de cast ratée.

2)

void redigerOrdonnance(struct Medecin *medecin, struct Patient *patients, struct Ordonnance *ordonnances, int *nbOrdonnances) {

... est défini dans une autre fonction (void lireLigne(char *chaine, int taille)) et ça n'est pas possible non plus. Probablement parce que tu as oublié l'accolade fermante de lireLigne ?

3)

void adminLogin(struct Admin *admins, int nbAdmins) {
    char username[50];
    char password[50];
    void lireLigne(char *chaine, int taille);

    printf("Nom d'utilisateur : ");
    lireLigne(username, sizeof(username));

    printf("Mot de passe : ");
    lireLigne(password, sizeof(password));

    // Recherche de l'administrateur par nom d'utilisateur et mot de passe
    int i;
    for (i = 0; i < nbAdmins; i++) {
        if (strcmp(admins[i].username, username) == 0 && strcmp(admins[i].password, password) == 0) {
            printf("Bienvenue, %s!\n", username);
            break;
        }
    }
}

if (i == nbAdmins) {
    printf("Identifiant ou mot de passe incorrect.\n");
}
}

Ici le dernier bloc if est en dehors de la fonction, ce qui laisse penser que tu as fermé une accolade de trop juste avant.

4)

                    } while (tonchoix != 0);
                    else {
                        printf("Echec de l'authentification. Veuillez vérifier vos informations.\n");
                    }

Ici on a un else qui n'est pas précédé d'un if... En réalité, c'est parce qu'il manque pas moins de 3 accolades fermantes devant else !

5) Malheureusement, il y a encore beaucoup d'autres erreurs.

  • Certaines variables ne sont pas déclarées (par exemple inputUsername) ni même initialisée. Probablement tu voulais écrire username ? Idem avec inputPassword, tonchoix...
  • Certains appels de fonction ne sont pas cohérent avec leur signature, la fonction chargerOrdonnance, chargerCertificats, redigerDossierMalade
    ne sont pas définies.
  • La fonction consulterPatients est déclarée deux fois (la 2e, juste avant le main, et elle est non seulement inutile mais en plus pas conforme à la première déclaration.
  • Dans main, la variable patients est déclarée deux fois (je pense que la deuxième fois il serait sage de la nommer patientts vu son type), ce qui n'est pas autorisé. La variable indexMedecin n'est jamais définie.

Voici donc un code qui compile (et fait probablement n'importe quoi) en commentent ce qui n'a pas de sens et en bougeant les bouts de code qui ne me paraissaient pas à leur place et en corrigeant les accolades. Maintenant à toi de jouer :-)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// Structure pour stocker les informations d'un patient
struct Patient {
    int matricule;
    char nom[50];
    char date_naissance[20];
    char genre[10];
    char descriptionMaladies[100];
    char tonService[50];
    char tonRendezvous[100];
    char tonOrdonnance[90];
    char tonMedecin[50];
    char tonCertificats[30];
};

// Structure pour stocker les informations du patient
struct Patientt {
    char username[50];
    char password[50];
    char maladies[200];
    char ordonnances[200];
    char certificats[200];
    char rendezvous[200];
    char datesRendezvous[200];  // Ajout de la date du rendez-vous
};

// Structure pour stocker les informations d'un médecin
struct Medecin {
    int matricule;
    char nom[50];
    char date_naissance[20];
    char genre[10];
    char signature[30];
    char tonService[50];
    char specialite[15];
    char listePatients[100];
    char listOrdonnances[100];
    char listCertificats[100];
};

// Structure pour stocker les informations d'un service
struct Service {
    int identifiant;
    char nom[50];
    char listPatient[100];
    char listMedecin[100];
};
// Structure pour stocker les informations d'une ordonnance
struct Ordonnance {
    int matriculeMedecin;
    char nomMedecin[50];
    int identifiantPatient;
    char nomPatient[50];
    char signatureMedecin[30];
    char listeMedicaments[100];
};
struct Admin {
    char username[50];
    char password[50];
};

// Structure pour stocker les informations d'un certificat
struct Certificat {
    int identifiant;
    char dateCreation[20];
    char cause[50];
    int identifiantPatient;
    char nomPatient[50];
    int identifiantMedecin;
    char nomMedecin[50];
    char signatureMedecin[30];
};

// Structure pour stocker les informations d'un rendez-vous
struct RendezVous {
    char date[20];
    char autresDetails[100];
};

// Fonction pour sauvegarder la liste des patients dans un fichier
void sauvegarderPatients(struct Patient *patients, int nbPatients) {
    FILE *fichierPatients = fopen("patients.txt", "w");
    if (fichierPatients == NULL) {
        perror("Erreur lors de l'ouverture du fichier patients.txt");
        return;
    }

    for (int i = 0; i < nbPatients; i++) {
        fprintf(fichierPatients, "%d %s %s %s %s %s %s %s %s %s\n",
                patients[i].matricule, patients[i].nom, patients[i].date_naissance, patients[i].genre,
                patients[i].descriptionMaladies, patients[i].tonService, patients[i].tonRendezvous,
                patients[i].tonOrdonnance, patients[i].tonMedecin, patients[i].tonCertificats);
    }

    fclose(fichierPatients);
}

// Fonction pour charger la liste des patients depuis un fichier
void chargerPatients(struct Patient *patients, int *nbPatients) {
    FILE *fichierPatients = fopen("patients.txt", "r");
    if (fichierPatients == NULL) {
        perror("Erreur lors de l'ouverture du fichier patients.txt");
        return;
    }

    while (fscanf(fichierPatients, "%d %s %s %s %s %s %s %s %s %s",
                &patients[*nbPatients].matricule, patients[*nbPatients].nom,
                patients[*nbPatients].date_naissance, patients[*nbPatients].genre,
                patients[*nbPatients].descriptionMaladies, patients[*nbPatients].tonService,
                patients[*nbPatients].tonRendezvous, patients[*nbPatients].tonOrdonnance,
                patients[*nbPatients].tonMedecin, patients[*nbPatients].tonCertificats) == 10) {
        (*nbPatients)++;
        if (*nbPatients >= 100) {
            printf("Attention : La capacité maximale des patients a été atteinte.\n");
            break;
        }
    }

    fclose(fichierPatients);
}

// Fonction pour sauvegarder la liste des médecins dans un fichier
void sauvegarderMedecins(struct Medecin *medecins, int nbMedecins) {
    FILE *fichierMedecins = fopen("medecins.txt", "w");
    if (fichierMedecins == NULL) {
        perror("Erreur lors de l'ouverture du fichier medecins.txt");
        return;
    }

    for (int i = 0; i < nbMedecins; i++) {
        fprintf(fichierMedecins, "%d %s %s %s %s %s %s %s %s %s\n",
                medecins[i].matricule, medecins[i].nom, medecins[i].date_naissance, medecins[i].genre,
                medecins[i].signature, medecins[i].tonService, medecins[i].specialite,
                medecins[i].listePatients, medecins[i].listOrdonnances, medecins[i].listCertificats);
    }

    fclose(fichierMedecins);
}

// Fonction pour charger la liste des médecins depuis un fichier
void chargerMedecins(struct Medecin *medecins, int *nbMedecins) {
    FILE *fichierMedecins = fopen("medecins.txt", "r");
    if (fichierMedecins == NULL) {
        perror("Erreur lors de l'ouverture du fichier medecins.txt");
        return;
    }

    while (fscanf(fichierMedecins, "%d %s %s %s %s %s %s %s %s %s",
                &medecins[*nbMedecins].matricule, medecins[*nbMedecins].nom,
                medecins[*nbMedecins].date_naissance, medecins[*nbMedecins].genre,
                medecins[*nbMedecins].signature, medecins[*nbMedecins].tonService,
                medecins[*nbMedecins].specialite, medecins[*nbMedecins].listePatients,
                medecins[*nbMedecins].listOrdonnances, medecins[*nbMedecins].listCertificats) == 10) {
        (*nbMedecins)++;
        if (*nbMedecins >= 100) {
            printf("Attention : La capacité maximale des medecins a été atteinte.\n");
            break;
        }
    }

    fclose(fichierMedecins);
}

// Fonction pour sauvegarder la liste des services dans un fichier
void sauvegarderServices(struct Service *services, int nombreServices) {
    FILE *fichierServices = fopen("services.txt", "w");
    if (fichierServices == NULL) {
        perror("Erreur lors de l'ouverture du fichier services.txt");
        return;
    }

    for (int i = 0; i < nombreServices; i++) {
        fprintf(fichierServices, "%d %s %s %s\n",
                services[i].identifiant, services[i].nom, services[i].listPatient, services[i].listMedecin);
    }

    fclose(fichierServices);
}

// Fonction pour charger la liste des services depuis un fichier
void chargerServices(struct Service *services, int *nombreServices) {
    FILE *fichierServices = fopen("services.txt", "r");
    if (fichierServices == NULL) {
        perror("Erreur lors de l'ouverture du fichier services.txt");
        return;
    }

    while (fscanf(fichierServices, "%d %s %s %s",
                &services[*nombreServices].identifiant, services[*nombreServices].nom,
                services[*nombreServices].listPatient, services[*nombreServices].listMedecin) == 4) {
        (*nombreServices)++;
        if (*nombreServices >= 100) {
            printf("Attention : La capacité maximale des services a été atteinte.\n");
            break;
        }
    }

    fclose(fichierServices);
}

// Fonction pour sauvegarder la liste des rendez-vous dans un fichier
void sauvegarderRendezVous(struct RendezVous *rendezVous, int nbRendezVous) {
    FILE *fichierRendezVous = fopen("rendezvous.txt", "w");
    if (fichierRendezVous == NULL) {
        perror("Erreur lors de l'ouverture du fichier rendezvous.txt");
        return;
    }

    for (int i = 0; i < nbRendezVous; i++) {
        fprintf(fichierRendezVous, "%s %s\n",
                rendezVous[i].date, rendezVous[i].autresDetails);
    }

    fclose(fichierRendezVous);
}

// Fonction pour charger la liste des rendez-vous depuis un fichier
void chargerRendezVous(struct RendezVous *rendezVous, int *nbRendezVous) {
    FILE *fichierRendezVous = fopen("rendezvous.txt", "r");
    if (fichierRendezVous == NULL) {
        perror("Erreur lors de l'ouverture du fichier rendezvous.txt");
        return;
    }

    while (fscanf(fichierRendezVous, "%s %s",
                rendezVous[*nbRendezVous].date, rendezVous[*nbRendezVous].autresDetails) == 2) {
        (*nbRendezVous)++;
        if (*nbRendezVous >= 100) {
            printf("Attention : La capacité maximale des rendezvous a été atteinte.\n");
            break;
        }
    }

    fclose(fichierRendezVous);
}

// Fonction pour ajouter un nouveau patient
void ajouterPatient(struct Patient *patients, int *nbPatients) {
    if (*nbPatients < 100) {
        printf("Entrez le matricule du patient : ");
        scanf("%d", &patients[*nbPatients].matricule);
        printf("Entrez le nom du patient : ");
        scanf("%s", patients[*nbPatients].nom);
        printf("Entrez la date de naissance du patient : ");
        scanf("%s", patients[*nbPatients].date_naissance);
        printf("Entrez le genre du patient : ");
        scanf("%s", patients[*nbPatients].genre);
        printf("Entrez les services auxquels il est attribué : ");
        scanf("%s", patients[*nbPatients].tonService);
        printf("Décrire la maladie du patient : ");
        scanf("%s", patients[*nbPatients].descriptionMaladies);
        printf("Entrez ses rendez-vous : ");
        scanf("%s", patients[*nbPatients].tonRendezvous);
        printf("Entrez ses ordonnances : ");
        scanf("%s", patients[*nbPatients].tonOrdonnance);
        printf("Entrez ses médecins : ");
        scanf("%s", patients[*nbPatients].tonMedecin);
        printf("Entrez ses certificats : ");
        scanf("%s", patients[*nbPatients].tonCertificats);

        (*nbPatients)++;
    } else {
        printf("Le tableau des patients est plein. Impossible d'ajouter plus de patients.\n");
    }
}

// Fonction pour afficher la liste des patients
void afficherPatients(struct Patient *patients, int nbPatients) {
    printf("Liste des patients :\n");
    for (int i = 0; i < nbPatients; i++) {
        printf("Matricule : %d\n", patients[i].matricule);
        printf("Nom : %s\n", patients[i].nom);
        printf("Date de naissance : %s\n", patients[i].date_naissance);
        printf("Genre : %s\n", patients[i].genre);
        printf("\n");
    }
}

// Fonction pour modifier un patient
void modifierPatient(struct Patient *patients, int nbPatients) {
    int matriculeRecherche;
    printf("Matricule du patient à modifier : ");
    scanf("%d", &matriculeRecherche);
    for (int i = 0; i < nbPatients; i++) {
        if (patients[i].matricule == matriculeRecherche) {
            printf("Nouveau nom : ");
            scanf("%s", patients[i].nom);
            printf("Nouvelle date : ");
            scanf("%s", patients[i].date_naissance);
            printf("Nouveau genre : ");
            scanf("%s", patients[i].genre);

            printf("Patient modifié avec succès\n");
            return;
        }
    }
    printf("Patient non trouvé\n");
}

// Fonction pour supprimer un patient
void supprimerPatient(struct Patient *patients, int *nbPatients) {
    int matriculeRecherche;
    printf("Matricule du patient à supprimer : ");
    scanf("%d", &matriculeRecherche);
    for (int i = 0; i < *nbPatients; i++) {
        if (patients[i].matricule == matriculeRecherche) {
            // Décaler les éléments du tableau pour "supprimer" le patient
            for (int j = i; j < *nbPatients - 1; j++) {
                patients[j] = patients[j + 1];
            }
            (*nbPatients)--;
            printf("Patient supprimé avec succès\n");
            return;
        }
    }
    printf("Patient non trouvé\n");
}

// Fonction pour ajouter un nouveau médecin
void ajouterMedecin(struct Medecin *medecin, int *nbMedecins) {
    if (*nbMedecins < 100) {
        printf("Entrez le matricule du medecin : ");
        scanf("%d", &medecin[*nbMedecins].matricule);
        printf("Entrez le nom du medecin : ");
        scanf("%s", medecin[*nbMedecins].nom);
        printf("Entrez la date de naissance du medecin : ");
        scanf("%s", medecin[*nbMedecins].date_naissance);
        printf("Entrez le genre du medecin : ");
        scanf("%s", medecin[*nbMedecins].genre);
        printf("Entrez sa signature : ");
        scanf("%s", medecin[*nbMedecins].signature);
        printf("Entrez le service qui lui appartient : ");
        scanf("%s", medecin[*nbMedecins].tonService);
        printf("Entrez sa spécialité : ");
        scanf("%s", medecin[*nbMedecins].specialite);
        printf("Entrez la liste des patients qui lui sont attribués : ");
        scanf("%s", medecin[*nbMedecins].listePatients);
        printf("Entrez la liste des ordonnances prescrites : ");
        scanf("%s", medecin[*nbMedecins].listOrdonnances);
        printf("Entrez la liste de ses certificats émis : ");
        scanf("%s", medecin[*nbMedecins].listCertificats);

        (*nbMedecins)++;
    } else {
        printf("Le tableau des medecins est plein. Impossible d'ajouter plus de medecins.\n");
    }
}

// Fonction pour modifier un médecin
void modifierMedecin(struct Medecin *medecin, int nbMedecins) {
    int matriculeRecherche;
    printf("Matricule du medecin à modifier : ");
    scanf("%d", &matriculeRecherche);
    for (int i = 0; i < nbMedecins; i++) {
        if (medecin[i].matricule == matriculeRecherche) {
            printf("Nouveau nom : ");
            scanf("%s", medecin[i].nom);
            printf("Nouvelle date : ");
            scanf("%s", medecin[i].date_naissance);
            printf("Nouveau genre : ");
            scanf("%s", medecin[i].genre);
            printf("Nouvelle signature : ");
            scanf("%s", medecin[i].signature);
            printf("Nouveau service qui lui appartient : ");
            scanf("%s", medecin[i].tonService);
            printf("Nouvelle spécialité : ");
            scanf("%s", medecin[i].specialite);
            printf("Entrez la liste des patients qui lui sont attribués : ");
            scanf("%s", medecin[i].listePatients);
            printf("Entrez la liste des ordonnances prescrites : ");
            scanf("%s", medecin[i].listOrdonnances);
            printf("Entrez la liste de ses certificats émis : ");
            scanf("%s", medecin[i].listCertificats);

            printf("Medecin modifié avec succès\n");
            return;
        }
    }
    printf("Medecin non trouvé\n");
}

// Fonction pour supprimer un médecin
void supprimerMedecin(struct Medecin *medecin, int *nbMedecins) {
    int matriculeRecherche;
    printf("Matricule du medecin à supprimer : ");
    scanf("%d", &matriculeRecherche);
    for (int i = 0; i < *nbMedecins; i++) {
        if (medecin[i].matricule == matriculeRecherche) {
            for (int j = i; j < *nbMedecins - 1; j++) {
                medecin[j] = medecin[j + 1];
            }
            (*nbMedecins)--;
            printf("Medecin supprimé avec succès\n");
            return;
        }
    }
    printf("Medecin non trouvé\n");
}

// Fonction pour ajouter un nouveau service
void ajouterService(struct Service services[], int *nombreServices) {
    printf("Nouveau service :\n");
    printf("Identifiant : ");
    scanf("%d", &services[*nombreServices].identifiant);
    printf("Nom : ");
    scanf("%s", services[*nombreServices].nom);
    printf("La liste des médecins : ");
    scanf("%s", services[*nombreServices].listMedecin);
    printf("La liste des patients : ");
    scanf("%s", services[*nombreServices].listPatient);
    (*nombreServices)++;
}

// Fonction pour modifier un service
void modifierService(struct Service services[], int nombreServices) {
    int identifiantRecherche;
    printf("Identifiant du service à modifier : ");
    scanf("%d", &identifiantRecherche);
    for (int i = 0; i < nombreServices; i++) {
        if (services[i].identifiant == identifiantRecherche) {
            printf("Nouveau nom du service : ");
            scanf("%s", services[i].nom);
            printf("Nouveau list des medecins : ");
            scanf("%s", services[i].listMedecin);
            printf("Nouveau list des patients : ");
            scanf("%s", services[i].listPatient);
            printf("Service modifié avec succès\n");
            return;
        }
    }
    printf("Service non trouvé\n");
}

// Fonction pour supprimer un service
void supprimerService(struct Service services[], int *nombreServices) {
    int identifiantRecherche;
    printf("Identifiant du service à supprimer : ");
    scanf("%d", &identifiantRecherche);
    for (int i = 0; i < *nombreServices; i++) {
        if (services[i].identifiant == identifiantRecherche) {
            for (int j = i; j < *nombreServices - 1; j++) {
                services[j] = services[j + 1];
            }
            (*nombreServices)--;
            printf("Service supprimé avec succès\n");
            return;
        }
    }
    printf("Service non trouvé\n");
}
struct JourFerie {
    int jour;
    int mois;
};

// Ajouter la liste des jours fériés
struct JourFerie joursFeries[] = {{1, 1}, {1, 5}, {14, 7}, {1, 11}, {25, 12}};
int nbJoursFeries = sizeof(joursFeries) / sizeof(joursFeries[0]);

// Fonction pour vérifier la validité d'un rendez-vous
int estRendezVousValide(struct Medecin medecin, char dateRendezVous[20], struct RendezVous rendezVous[], int nbRendezVous) {
    // Vérifier si la date correspond à un jour férié
    int jour, mois;
    scanf(dateRendezVous, "%d/%d", &jour, &mois);
    for (int i = 0; i < nbJoursFeries; i++) {
        if (joursFeries[i].jour == jour && joursFeries[i].mois == mois) {
            printf("Le rendez-vous est un jour férié. Choisissez une autre date.\n");
            return 1;
        }
    }
}

// Fonction pour ajouter un rendez-vous
void ajouterRendezVous(struct Patient *patient, struct Medecin *medecin, struct RendezVous rendezVous[], int *nbPatients, int *nbRendezVous) {
    printf("Entrez la date du rendez-vous (format JJ/MM) : ");
    scanf("%s", patient[*nbPatients].tonRendezvous);

    // Vérifier si le rendez-vous est valide
    if (estRendezVousValide(*medecin, patient[*nbPatients].tonRendezvous, rendezVous, *nbRendezVous)) {
        printf("Autres détails du rendez-vous : ");
        scanf("%s", rendezVous[*nbRendezVous].autresDetails);

        // Enregistrez la date du rendez-vous pour le suivi
        strcpy(rendezVous[*nbRendezVous].date, patient[*nbPatients].tonRendezvous);

        (*nbPatients)++;
        (*nbRendezVous)++;
        printf("Rendez-vous ajouté avec succès.\n");
    } else {
        printf("Rendez-vous non valide. Veuillez réessayer.\n");
    }
}

int trouverPatientParIdentifiant(struct Patient *patients, int nbPatients, int idPatient) {
    for (int i = 0; i < nbPatients; i++) {
        if (patients[i].matricule == idPatient) {
            return i;
        }
    }
    return -1;
}

void lireLigne(char *chaine, int taille) {
    fgets(chaine, taille, stdin);
    // Supprimer le retour à la ligne
    size_t len = strlen(chaine);
    if (len > 0 && chaine[len - 1] == '\n') {
        chaine[len - 1] = '\0';
    }
}

// Fonction pour rédiger une ordonnance
void redigerOrdonnance(struct Medecin *medecin, struct Patient *patients, struct Ordonnance *ordonnances, int *nbOrdonnances) {
    int idPatient,nbPatients;
    printf("Entrez l'identifiant du patient : ");
    scanf("%d", &idPatient);


    // Recherche du patient par identifiant
    int indexPatient = trouverPatientParIdentifiant(patients, nbPatients, idPatient);
    if (indexPatient == -1) {
        printf("Patient non trouvé.\n");
        return ;
    }


    // Création d'une nouvelle ordonnance
    struct Ordonnance nouvelleOrdonnance;
    nouvelleOrdonnance.matriculeMedecin = medecin->matricule;
    strcpy(nouvelleOrdonnance.nomMedecin, medecin->nom);
    nouvelleOrdonnance.identifiantPatient = patients[indexPatient].matricule;
    strcpy(nouvelleOrdonnance.nomPatient, patients[indexPatient].nom);
    printf("Entrez la liste des médicaments : ");
    lireLigne(nouvelleOrdonnance.listeMedicaments, sizeof(nouvelleOrdonnance.listeMedicaments));

    // Ajout de la nouvelle ordonnance à la liste
    ordonnances[*nbOrdonnances] = nouvelleOrdonnance;
    (*nbOrdonnances)++;

    printf("Ordonnance rédigée avec succès.\n");
}

int trouverPatientParIdentifiant(struct Patient *patients, int nbPatients, int idPatient);

// Fonction pour rédiger un certificat
void redigerCertificat(struct Medecin *medecin, struct Patient *patients, struct Certificat *certificats, int *nbCertificats, int nbPatients) {
    int idPatient;
    printf("Entrez l'identifiant du patient : ");
    scanf("%d", &idPatient);

    // Recherche du patient par identifiant
    int indexPatient = trouverPatientParIdentifiant(patients, nbPatients, idPatient);
    if (indexPatient == -1) {
        printf("Patient non trouvé.\n");
        return;
    }

    // Création d'un nouveau certificat
    struct Certificat nouveauCertificat;
    nouveauCertificat.identifiant = (*nbCertificats) + 1; // Identifiant unique
    time_t now;
    time(&now);
    struct tm *local = localtime(&now);
    strftime(nouveauCertificat.dateCreation, sizeof(nouveauCertificat.dateCreation), "%Y-%m-%d", local);
    printf("Entrez la cause du certificat : ");
    lireLigne(nouveauCertificat.cause, sizeof(nouveauCertificat.cause));
    nouveauCertificat.identifiantPatient = patients[indexPatient].matricule;
    strcpy(nouveauCertificat.nomPatient, patients[indexPatient].nom);
    nouveauCertificat.identifiantMedecin = medecin->matricule;
    strcpy(nouveauCertificat.nomMedecin, medecin->nom);
    strcpy(nouveauCertificat.signatureMedecin, medecin->signature);

    // Ajout du nouveau certificat à la liste
    certificats[*nbCertificats] = nouveauCertificat;
    (*nbCertificats)++;

    printf("Certificat rédigé avec succès.\n");
}

// Fonction pour consulter la liste des certificats d'un patient
void consulterCertificats(struct Patient *patients, struct Certificat *certificats, int nbCertificats, int nbPatients) {
    int idPatient;
    int indexPatient;
    printf("Entrez l'identifiant du patient : ");
    scanf("%d", &idPatient);

    // Recherche du patient par identifiant
    indexPatient = trouverPatientParIdentifiant(patients, nbPatients, idPatient);
    if (indexPatient == -1) {
        printf("Patient non trouvé.\n");
        return;
    }

    printf("Certificats pour le patient %s :\n", patients[indexPatient].nom);

    for (int i = 0; i < nbCertificats; i++) {
        if (certificats[i].identifiantPatient == idPatient) {
            printf("Identifiant : %d\n", certificats[i].identifiant);
            printf("Date de création : %s\n", certificats[i].dateCreation);
            printf("Cause : %s\n", certificats[i].cause);
            printf("Nom du médecin : %s\n", certificats[i].nomMedecin);
            printf("Signature du médecin : %s\n", certificats[i].signatureMedecin);
            printf("\n");
        }
    }
}

void adminLogin(struct Admin *admins, int nbAdmins) {
    char username[50];
    char password[50];
    void lireLigne(char *chaine, int taille);

    printf("Nom d'utilisateur : ");
    lireLigne(username, sizeof(username));

    printf("Mot de passe : ");
    lireLigne(password, sizeof(password));

    // Recherche de l'administrateur par nom d'utilisateur et mot de passe
    int i;
    for (i = 0; i < nbAdmins; i++) {
        if (strcmp(admins[i].username, username) == 0 && strcmp(admins[i].password, password) == 0) {
            printf("Bienvenue, %s!\n", username);
            break;
        }
    }

    if (i == nbAdmins) {
        printf("Identifiant ou mot de passe incorrect.\n");
    }
}


// Fonction pour l'authentification
int authentifier(struct Patientt *patients, int nbPatients, char *username, char *password) {
    for (int i = 0; i < nbPatients; ++i) {
        if (strcmp(username, patients[i].username) == 0 && strcmp(password, patients[i].password) == 0) {
            return i;  // Retourne l'indice du patient authentifié
        }
    }
    return -1;  // Retourne -1 si l'authentification échoue
}

// Fonction pour demander un certificat
void demanderCertificat(struct Patientt *patient) {
    printf("Demande de certificat pour le patient %s.\n", patient->username);
    // Ajouter la logique pour générer le certificat (exemple: saisie manuelle)
    char certificat[50];
    char date[20];
    printf("Entrez la date de votre certificat: ");
    scanf(" %[^\n]s", date);
    printf("Entrez les détails du certificat: ");
    scanf(" %[^\n]s", certificat);
    strcat(patient->certificats, certificat);
    strcat(patient->certificats, "\n");
    printf("Certificat généré avec succès.\n");
}

// Fonction pour demander un rendez-vous
void demanderRendezVous(struct Patientt *patient) {
    printf("Demande de rendez-vous pour le patient %s.\n", patient->username);
    // Ajouter la logique pour planifier le rendez-vous (exemple: saisie manuelle)
    char rendezvous[100];
    char ser[20];
    char dat[20];
    printf("Choisissez le service où vous souhaitez passer la visite médicale  ");
    scanf(" %[^\n]s", ser);
    printf("entrer la date adaptable à votre disponibilité :");
    scanf(" %[^\n]s", dat);
    strcat(patient->rendezvous, rendezvous);
    strcat(patient->rendezvous, "\n");
    strcat(patient->datesRendezvous, dat);  // Ajout de la date du rendez-vous
    strcat(patient->datesRendezvous, "\n");
    printf("Rendez-vous planifié avec succès.\n");
}

// Fonction pour rappeler les rendez-vous
void rappelerRendezVous(struct Patientt *patient) {
    printf("ce patient a un rendezvous le jour suivant %s:\n", patient->username);
    // Afficher les rendez-vous avec les dates correspondantes
    char *tokenRendezvous = strtok(patient->rendezvous, "\n");
    char *tokenDates = strtok(patient->datesRendezvous, "\n");

    while (tokenRendezvous != NULL && tokenDates != NULL) {
        printf("Date: %s, Rendez-vous: %s\n", tokenDates, tokenRendezvous);
        tokenRendezvous = strtok(NULL, "\n");
        tokenDates = strtok(NULL, "\n");
    }
}

// Fonction pour consulter le dossier médical
void consulterDossierMedical(struct Patientt *patient) {
    printf("Dossier médical du patient %s:\n", patient->username);
    printf("Maladies: %s\n", patient->maladies);
    printf("Ordonnances: %s\n", patient->ordonnances);
    printf("Certificats: %s\n", patient->certificats);
    rappelerRendezVous(patient);  // Utiliser la fonction rappelerRendezVous pour afficher les rendez-vous
}


/*
void lireLigne(char *chaine, int taille);
int trouverPatientParIdentifiant(struct Patient *patients, int nbPatients, int idPatient);
void redigerCertificat(struct Medecin *medecin, struct Patient *patients, struct Certificat *certificats, int *nbCertificats, int nbPatients);
void consulterCertificats(struct Patient *patients, struct Certificat *certificats, int *nbCertificats);
void redigerDossierMalade(struct Patient **patients, int nbPatients, int indexMedecin);
*/

int main() {
    int choix, tonchoix;
    struct Patient patients[100];
    int nbPatients = 0;

    struct Medecin medecins[100];
    int nbMedecins = 0;

    struct Service services[100];
    int nombreServices = 0;

    struct RendezVous rendezVous[100];
    int nbRendezVous = 0;

    struct Ordonnance ordonnances[100];
    int nbOrdonnances = 0;

    struct Certificat certificats[100];
    int nbCertificats = 0;

    struct Admin admin = {"admin", "admin"};
    int nbCertificat =0;
    // Charger les données depuis les fichiers
    //chargerPatients(patients, &nbPatients);
    chargerMedecins(medecins, &nbMedecins);
    chargerServices(services, &nombreServices);
    chargerRendezVous(rendezVous, &nbRendezVous);
    //chargerOrdonnances(ordonnances, &nbOrdonnances);
    //chargerCertificats(certificats, &nbCertificats);



    // Exemple avec deux patients
    struct Patientt patientts[2];
    strcpy(patientts[0].username, "patient1");
    strcpy(patientts[0].password, "pass1");
    patientts[0].maladies[0] = '\0';
    patientts[0].ordonnances[0] = '\0';
    patientts[0].certificats[0] = '\0';
    patientts[0].rendezvous[0] = '\0';
    patientts[0].datesRendezvous[0] = '\0';

    strcpy(patientts[1].username, "patient2");
    strcpy(patientts[1].password, "pass2");
    patientts[1].maladies[0] = '\0';
    patientts[1].ordonnances[0] = '\0';
    patientts[1].certificats[0] = '\0';
    patientts[1].rendezvous[0] = '\0';
    patientts[1].datesRendezvous[0] = '\0';


    char username[50];
    char password[50];
    int indexPatient;


    printf("Veuillez vous authentifier:\n");
    printf("Nom d'utilisateur: ");
    scanf("%s", username);
    printf("Mot de passe: ");
    scanf("%s", password);

    indexPatient = authentifier(patientts, 2, username, password);

    if (indexPatient != -1) {
        printf("Authentification réussie.\n");

        while (1) {
            printf("Bienvenue\n");
            printf("1. Bloc de l'administrateur\n");
            printf("2. Bloc pour les médecins\n");
            printf("3. Bloc pour les patients\n");
            printf("Entrez votre bloc : ");
            scanf("%d", &choix);

            switch (choix) {
                case 1:
                    if (strcmp(username, admin.username) == 0 && strcmp(password, admin.password) == 0) {
                        do {
                            printf("Menu administrateur :\n");
                            printf("1. Ajouter un nouveau service\n");
                            printf("2. Modifier un service\n");
                            printf("3. Supprimer un service\n");
                            printf("4. Ajouter un nouveau médecin\n");
                            printf("5. Modifier un médecin\n");
                            printf("6. Supprimer médecin\n");
                            printf("7. Ajouter un patient\n");
                            printf("8. Modifier un patient\n");
                            printf("9. Supprimer un patient\n");
                            printf("10. Afficher la liste des patients\n");
                            printf("11. Planifier les rendez-vous\n");
                            printf("12. Quitter\n");
                            printf("Entrez votre choix : ");
                            scanf("%d", &tonchoix);

                            switch (tonchoix) {
                                case 1:
                                    ajouterService(services, &nombreServices);
                                    break;
                                case 2:
                                    modifierService(services, nombreServices);
                                    break;
                                case 3:
                                    supprimerService(services, &nombreServices);
                                    break;
                                case 4:
                                    ajouterMedecin(medecins, &nbMedecins);
                                    break;
                                case 5:
                                    modifierMedecin(medecins, nbMedecins);
                                    break;
                                case 6:
                                    supprimerMedecin(medecins, &nbMedecins);
                                    break;
                                case 7:
                                    ajouterPatient(patients, &nbPatients);
                                    break;
                                case 8:
                                    modifierPatient(patients, nbPatients);
                                    break;
                                case 9:
                                    supprimerPatient(patients, &nbPatients);
                                    break;
                                case 10:
                                    afficherPatients(patients, nbPatients);
                                    break;
                                case 11:
                                    ajouterRendezVous(patients, medecins, rendezVous, &nbPatients, &nbRendezVous);
                                    break;
                                case 12:
                                    printf("Au revoir !\n");
                                    break;
                                default:
                                    printf("Choix invalide. Veuillez réessayer.\n");
                            }
                        } while (tonchoix != 11);
                    } else {
                        printf("Vérifiez vos données s'il vous plaît");
                    }
                    break;

                case 2:
                    do {
                        printf("Menu médecin :\n");
                        printf("1. Rédiger le dossier du malade\n");
                        printf("2. Rédiger des ordonnances\n");
                        printf("3. Rédiger des certificats\n");
                        printf("4. Consulter la liste des certificats d'un patient\n");
                        printf("5. Quitter\n");
                        printf("Entrez votre choix : ");
                        scanf("%d", &tonchoix);

                        switch (tonchoix) {
                            case 1:
                                //redigerDossierMalade(&patients, nbPatients, indexMedecin);
                                break;
                            case 2:
                                //redigerOrdonnance(&medecins[indexMedecin], patients, ordonnances, nbOrdonnances);
                                break;
                            case 3:
                                //redigerCertificat(&medecins[indexMedecin], patients, certificats, nbCertificats, nbPatients);
                                break;
                            case 4:
                                consulterCertificats(patients, certificats, nbCertificats, nbPatients);
                                break;
                            case 5:
                                printf("Déconnexion.\n");
                                break;
                            default:
                                printf("Choix invalide. Veuillez réessayer.\n");
                        }
                    } while (tonchoix != 5);
                    break;
                case 3:
                    do {
                        printf("\nMenu principal:\n");
                        printf("1. Demander un certificat\n");
                        printf("2. Demander un rendez-vous\n");
                        printf("3. Rappeler les rendez-vous\n");
                        printf("4. Consulter le dossier médical\n");
                        printf("0. Quitter\n");
                        printf("Choix: ");
                        scanf("%d", &tonchoix);

                        switch (tonchoix) {
                            case 1:
                                demanderCertificat(&patientts[indexPatient]);
                                break;
                            case 2:
                                demanderRendezVous(&patientts[indexPatient]);
                                break;
                            case 3:
                                rappelerRendezVous(&patientts[indexPatient]);
                                break;
                            case 4:
                                consulterDossierMedical(&patientts[indexPatient]);
                                break;
                            case 0:
                                printf("Au revoir!\n");
                                break;
                            default:
                                printf("Choix invalide. Veuillez réessayer.\n");
                        }
                    } while (tonchoix != 0);
            }
        }
    } else {
        printf("Echec de l'authentification. Veuillez vérifier vos informations.\n");
    }
    return 0;
}

Bonne chance

1

ok

0
jordane45 Messages postés 38145 Date d'inscription mercredi 22 octobre 2003 Statut Modérateur Dernière intervention 25 avril 2024 4 650
10 déc. 2023 à 02:48

Bonjour

Ok.... De ?

Ps: à l'avenir, merci d'utiliser les balises de code pour poster ton code sur le forum.

0
[Dal] Messages postés 6174 Date d'inscription mercredi 15 septembre 2004 Statut Contributeur Dernière intervention 2 février 2024 1 083
Modifié le 11 déc. 2023 à 02:15

Bonjour eya,

Ce code est entièrement écrit en C. Ce n'est pas du C++.

Voilà ce que donne ce code compilé avec gcc et avec les warnings.

$ gcc -Wall -Wextra 37960864.c
37960864.c: In function ‘estRendezVousValide’:
37960864.c:465:40: warning: unused parameter ‘medecin’ [-Wunused-parameter]
 int estRendezVousValide(struct Medecin medecin, char dateRendezVous[20], struct RendezVous rendezVous[], int nbRendezVous) {
                         ~~~~~~~~~~~~~~~^~~~~~~
37960864.c:465:92: warning: unused parameter ‘rendezVous’ [-Wunused-parameter]
 int estRendezVousValide(struct Medecin medecin, char dateRendezVous[20], struct RendezVous rendezVous[], int nbRendezVous) {
                                                                          ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
37960864.c:465:110: warning: unused parameter ‘nbRendezVous’ [-Wunused-parameter]
 int estRendezVousValide(struct Medecin medecin, char dateRendezVous[20], struct RendezVous rendezVous[], int nbRendezVous) {
                                                                                                          ~~~~^~~~~~~~~~~~
37960864.c: At top level:
37960864.c:507:49: error: ‘patients’ undeclared here (not in a function); did you mean ‘Patientt’?
 int indexPatient = trouverPatientParIdentifiant(patients, nbPatients, idPatient);
                                                 ^~~~~~~~
                                                 Patientt
37960864.c:507:59: error: ‘nbPatients’ undeclared here (not in a function); did you mean ‘Patientt’?
 int indexPatient = trouverPatientParIdentifiant(patients, nbPatients, idPatient);
                                                           ^~~~~~~~~~
                                                           Patientt
37960864.c:507:71: error: ‘idPatient’ undeclared here (not in a function); did you mean ‘Patient’?
 int indexPatient = trouverPatientParIdentifiant(patients, nbPatients, idPatient);
                                                                       ^~~~~~~~~
                                                                       Patient
37960864.c:508:5: error: expected identifier or ‘(’ before ‘if’
     if (indexPatient == -1) {
     ^~
37960864.c: In function ‘redigerOrdonnance’:
37960864.c:523:19: warning: unused variable ‘nbPatients’ [-Wunused-variable]
     int idPatient,nbPatients;
                   ^~~~~~~~~~
37960864.c: In function ‘consulterCertificats’:
37960864.c:586:63: error: expected expression before ‘int’
     int indexPatient = trouverPatientParIdentifiant(patients, int nbPatients, idPatient);
                                                               ^~~
37960864.c:586:24: error: too few arguments to function ‘trouverPatientParIdentifiant’
     int indexPatient = trouverPatientParIdentifiant(patients, int nbPatients, idPatient);
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
37960864.c:498:5: note: declared here
 int trouverPatientParIdentifiant(struct Patient *patients, int nbPatients, int idPatient) {
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
37960864.c:580:108: warning: unused parameter ‘nbPatients’ [-Wunused-parameter]
 void consulterCertificats(struct Patient *patients, struct Certificat *certificats, int nbCertificats, int nbPatients) {
                                                                                                        ~~~~^~~~~~~~~~
37960864.c: In function ‘lireLigne’:
37960864.c:627:9: error: ‘i’ undeclared (first use in this function)
     if (i == nbAdmins) {
         ^
37960864.c:627:9: note: each undeclared identifier is reported only once for each function it appears in
37960864.c:627:14: error: ‘nbAdmins’ undeclared (first use in this function); did you mean ‘Admin’?
     if (i == nbAdmins) {
              ^~~~~~~~
              Admin
37960864.c: In function ‘main’:
37960864.c:732:5: warning: implicit declaration of function ‘chargerOrdonnances’; did you mean ‘chargerServices’? [-Wimplicit-function-declaration]
     chargerOrdonnances(ordonnances, &nbOrdonnances);
     ^~~~~~~~~~~~~~~~~~
     chargerServices
37960864.c:733:5: warning: implicit declaration of function ‘chargerCertificats’; did you mean ‘redigerCertificat’? [-Wimplicit-function-declaration]
     chargerCertificats(certificats, &nbCertificats);
     ^~~~~~~~~~~~~~~~~~
     redigerCertificat
37960864.c:738:21: error: conflicting types for ‘patients’
     struct Patientt patients[2];
                     ^~~~~~~~
37960864.c:707:20: note: previous declaration of ‘patients’ was here
     struct Patient patients[100];
                    ^~~~~~~~
37960864.c:782:25: error: ‘inputUsername’ undeclared (first use in this function); did you mean ‘username’?
              if (strcmp(inputUsername, admin.username) == 0 && strcmp(inputPassword, admin.password) == 0) {
                         ^~~~~~~~~~~~~
                         username
37960864.c:782:71: error: ‘inputPassword’ undeclared (first use in this function); did you mean ‘password’?
              if (strcmp(inputUsername, admin.username) == 0 && strcmp(inputPassword, admin.password) == 0) {
                                                                       ^~~~~~~~~~~~~
                                                                       password
37960864.c:798:30: error: ‘tonchoix’ undeclared (first use in this function); did you mean ‘choix’?
                 scanf("%d", &tonchoix);
                              ^~~~~~~~
                              choix
37960864.c:820:40: warning: passing argument 1 of ‘ajouterPatient’ from incompatible pointer type [-Wincompatible-pointer-types]
                         ajouterPatient(patients, &nbPatients);
                                        ^~~~~~~~
37960864.c:242:37: note: expected ‘struct Patient *’ but argument is of type ‘struct Patientt *’
 void ajouterPatient(struct Patient *patients, int *nbPatients) {
                     ~~~~~~~~~~~~~~~~^~~~~~~~
37960864.c:823:41: warning: passing argument 1 of ‘modifierPatient’ from incompatible pointer type [-Wincompatible-pointer-types]
                         modifierPatient(patients, nbPatients);
                                         ^~~~~~~~
37960864.c:284:38: note: expected ‘struct Patient *’ but argument is of type ‘struct Patientt *’
 void modifierPatient(struct Patient *patients, int nbPatients) {
                      ~~~~~~~~~~~~~~~~^~~~~~~~
37960864.c:826:42: warning: passing argument 1 of ‘supprimerPatient’ from incompatible pointer type [-Wincompatible-pointer-types]
                         supprimerPatient(patients, &nbPatients);
                                          ^~~~~~~~
37960864.c:305:39: note: expected ‘struct Patient *’ but argument is of type ‘struct Patientt *’
 void supprimerPatient(struct Patient *patients, int *nbPatients) {
                       ~~~~~~~~~~~~~~~~^~~~~~~~
37960864.c:829:42: warning: passing argument 1 of ‘afficherPatients’ from incompatible pointer type [-Wincompatible-pointer-types]
                         afficherPatients(patients, nbPatients);
                                          ^~~~~~~~
37960864.c:272:39: note: expected ‘struct Patient *’ but argument is of type ‘struct Patientt *’
 void afficherPatients(struct Patient *patients, int nbPatients) {
                       ~~~~~~~~~~~~~~~~^~~~~~~~
37960864.c:832:43: warning: passing argument 1 of ‘ajouterRendezVous’ from incompatible pointer type [-Wincompatible-pointer-types]
                         ajouterRendezVous(patients, medecins, rendezVous, &nbPatients, &nbRendezVous);
                                           ^~~~~~~~
37960864.c:478:40: note: expected ‘struct Patient *’ but argument is of type ‘struct Patientt *’
 void ajouterRendezVous(struct Patient *patient, struct Medecin *medecin, struct RendezVous rendezVous[], int *nbPatients, int *nbRendezVous) {
                        ~~~~~~~~~~~~~~~~^~~~~~~
37960864.c:842:13: error: ‘else’ without a previous ‘if’
             else {
             ^~~~
37960864.c:859:69: error: ‘indexMedecin’ undeclared (first use in this function); did you mean ‘nbMedecins’?
                         redigerDossierMalade(&patients, nbPatients, indexMedecin);
                                                                     ^~~~~~~~~~~~
                                                                     nbMedecins
37960864.c:859:46: warning: passing argument 1 of ‘redigerDossierMalade’ from incompatible pointer type [-Wincompatible-pointer-types]
                         redigerDossierMalade(&patients, nbPatients, indexMedecin);
                                              ^~~~~~~~~
37960864.c:704:44: note: expected ‘struct Patient **’ but argument is of type ‘struct Patientt (*)[2]’
 void redigerDossierMalade(struct Patient **patients, int nbPatients, int indexMedecin);
                           ~~~~~~~~~~~~~~~~~^~~~~~~~
37960864.c:862:25: warning: implicit declaration of function ‘redigerOrdonnance’ [-Wimplicit-function-declaration]
                         redigerOrdonnance(&medecins[indexMedecin], patients, ordonnances, nbOrdonnances);
                         ^~~~~~~~~~~~~~~~~
37960864.c:865:68: warning: passing argument 2 of ‘redigerCertificat’ from incompatible pointer type [-Wincompatible-pointer-types]
                         redigerCertificat(&medecins[indexMedecin], patients, certificats, nbCertificats, nbPatients);
                                                                    ^~~~~~~~
37960864.c:702:65: note: expected ‘struct Patient *’ but argument is of type ‘struct Patientt *’
 void redigerCertificat(struct Medecin *medecin, struct Patient *patients, struct Certificat *certificats, int *nbCertificats, int nbPatients);
                                                 ~~~~~~~~~~~~~~~~^~~~~~~~
37960864.c:865:91: warning: passing argument 4 of ‘redigerCertificat’ makes pointer from integer without a cast [-Wint-conversion]
                         redigerCertificat(&medecins[indexMedecin], patients, certificats, nbCertificats, nbPatients);
                                                                                           ^~~~~~~~~~~~~
37960864.c:702:112: note: expected ‘int *’ but argument is of type ‘int’
 void redigerCertificat(struct Medecin *medecin, struct Patient *patients, struct Certificat *certificats, int *nbCertificats, int nbPatients);
                                                                                                           ~~~~~^~~~~~~~~~~~~
37960864.c:868:46: warning: passing argument 1 of ‘consulterCertificats’ from incompatible pointer type [-Wincompatible-pointer-types]
                         consulterCertificats(certificats, nbCertificats);
                                              ^~~~~~~~~~~
37960864.c:703:43: note: expected ‘struct Patient *’ but argument is of type ‘struct Certificat *’
 void consulterCertificats(struct Patient *patients, struct Certificat *certificats, int *nbCertificats);
                           ~~~~~~~~~~~~~~~~^~~~~~~~
37960864.c:868:59: warning: passing argument 2 of ‘consulterCertificats’ makes pointer from integer without a cast [-Wint-conversion]
                         consulterCertificats(certificats, nbCertificats);
                                                           ^~~~~~~~~~~~~
37960864.c:703:72: note: expected ‘struct Certificat *’ but argument is of type ‘int’
 void consulterCertificats(struct Patient *patients, struct Certificat *certificats, int *nbCertificats);
                                                     ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
37960864.c:868:25: error: too few arguments to function ‘consulterCertificats’
                         consulterCertificats(certificats, nbCertificats);
                         ^~~~~~~~~~~~~~~~~~~~
37960864.c:703:6: note: declared here
 void consulterCertificats(struct Patient *patients, struct Certificat *certificats, int *nbCertificats);
      ^~~~~~~~~~~~~~~~~~~~
37960864.c:909:6: error: ‘else’ without a previous ‘if’
      else {
      ^~~~
37960864.c:915:1: error: expected declaration or statement at end of input
 }
 ^
37960864.c:915:1: error: expected declaration or statement at end of input
37960864.c:915:1: error: expected declaration or statement at end of input
37960864.c:726:9: warning: unused variable ‘nbCertificat’ [-Wunused-variable]
     int nbCertificat =0;
         ^~~~~~~~~~~~
37960864.c: In function ‘estRendezVousValide’:
37960864.c:475:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
37960864.c: In function ‘main’:
37960864.c:843:17: warning: this statement may fall through [-Wimplicit-fallthrough=]
                 printf("Vérifiez vos données s'il vous plaît");
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
37960864.c:846:9: note: here
         case 2:
         ^~~~
At top level:
37960864.c:606:6: warning: ‘adminLogin’ defined but not used [-Wunused-function]
 void adminLogin(struct Admin *admins, int nbAdmins) {
      ^~~~~~~~~~
37960864.c:580:6: warning: ‘consulterCertificats’ defined but not used [-Wunused-function]
 void consulterCertificats(struct Patient *patients, struct Certificat *certificats, int nbCertificats, int nbPatients) {
      ^~~~~~~~~~~~~~~~~~~~
37960864.c:545:6: warning: ‘redigerCertificat’ defined but not used [-Wunused-function]
 void redigerCertificat(struct Medecin *medecin, struct Patient *patients, struct Certificat *certificats, int *nbCertificats, int nbPatients) {
      ^~~~~~~~~~~~~~~~~
37960864.c:522:6: warning: ‘redigerOrdonnance’ defined but not used [-Wunused-function]
 void redigerOrdonnance(struct Medecin *medecin, struct Patient *patients, struct Ordonnance *ordonnances, int *nbOrdonnances) {
      ^~~~~~~~~~~~~~~~~


Si ce code n'est pas le tiens, tu devrais songer à en utiliser un autre ou écrire ton propre code.

Si ce code est le tiens, tu as écris 915 lignes de code sans compiler et tester ton code et tu te retrouves donc avec un fatras à déboguer.

SI tu tiens à déboguer ce code, voilà une méthode :

  1. compile avec les warnings
  2. corrige le code de sorte à traiter le premier warning ou la première erreur
  3.  repasse à l'étape 1. jusqu'à ce que le code compile proprement
  4. ensuite exécute et teste chacune des fonctionnalités du code pour t'assurer que celui-ci fonctionne bien comme il le devrait

Normalement, ce n'est pas comme cela qu'on procède, car ce n'est pas comme cela qu'on développe un programme. Tu dois procéder par itérations courtes : tu écris quelques lignes de code, tu compiles avec les warnings,  tu résous toutes erreurs et avertissements et tu t'assures que le code compile proprement, et tu testes immédiatement que les quelques lignes que tu as écrites donnent le résultat attendu en exécutant le programme (mieux, tu écris les tests avant et exécute les tests à chaque itération de développement). Tu continues ensuite en écrivant quelques lignes de plus que tu puisses tester, etc.

0