Ejemplo n.º 1
0
void editVisit(){
	if(isLoged == 0){
		printf("\n!!Musisz byc zalogowany by edytowac wizyty!!\n");
		return;
	}
	char choose;
	do{
		getVisitInfo();
		
		printf("\n#1. Odwolaj wizyte\n"); 
		printf("#2. Zmien termin wizyty\n"); 
		printf("#q. Cofnij\n"); 
		
		fgets(&choose,5,stdin);
		switch(choose){
			case '1' : {
				cancelVisit();
				break;
			}
			case '2' : {
				//chooseDoctor();
				break;
			}
		}
		
		
	}while(choose != 'q');
	
}
Ejemplo n.º 2
0
int main(int argc, char** argv){
	
	msgid = msgget(997,IPC_CREAT | 0666);
	if(msgid == -1) perror("Tworzenie kolejki komunikatow");
	
	patientCount = getPatientCount();
	loadPatient(); 
	loadDoctors();
	doctorCount = getDoctorCount();
	printDoctors();
	printPatients();
			printf("begin\n");

	while(1){
		if(msgrcv(msgid,&addPatientMessage,sizeof(addPatientMessage),1,IPC_NOWAIT) != -1){
			addPatientX();
		}
		else if(msgrcv(msgid,&loginMessage,sizeof(loginMessage),2,IPC_NOWAIT) != -1){
			loginUser();
		}
		else if(msgrcv(msgid,&informationMessage,sizeof(informationMessage),3,IPC_NOWAIT) != -1){
			sendDoctorsInDate();
		}
	
		else if(msgrcv(msgid,&informationMessage,sizeof(informationMessage),6,IPC_NOWAIT) != -1){
			sendVisitInfo();
		}
		else if(msgrcv(msgid,&informationMessage,sizeof(informationMessage),5,IPC_NOWAIT) != -1){
			cancelVisit();
		}
		else if(msgrcv(msgid,&informationMessage,sizeof(informationMessage),4,IPC_NOWAIT) != -1){
			addVisit();
		}
		else if(msgrcv(msgid,&informationMessage,sizeof(informationMessage),7,IPC_NOWAIT) != -1){
			showVisitDay();
		}
		
		else if(msgrcv(msgid,&doctorMessage,sizeof(doctorMessage),10,IPC_NOWAIT) != -1){
			giveVacation();
		}



		//printPatients();
		sleep(1);
	}
	return 0;
}
Ejemplo n.º 3
0
int main() {
    int msgid = createMessageQueue("PATIENT");
    clearCalendar(&day);
    struct msgbuf patient;
    patient.pid = getpid();
    quit = false;
    bool log_on = false;
    while (!quit) {
        if (!log_on) {
            printf("---------\n");
            printf("MAIN MENU\n");
            printf("---------\n");
            printf("\tIf you want to login, enter 'l'.\n");
            printf("\tIf you want to register, enter 'r'.\n");
            printf("\tIf you want to quit, enter 'q': ");
            char choice;
            scanf("%s", &choice);
            if (choice == 'q') {
                quit = true;
            }
            else if (choice == 'r') {
                patient = registerNewPatient(msgid);
                log_on = true;
            }
            else if (choice == 'l') {
                patient = login(msgid, P_LOGIN_REQUEST);
                if (patient.index < 1000) {
                    log_on = true;
                }
            }
        }
        else if (log_on) {
            printf("------------\n");
            printf("HELLO %s!\n", patient.name);
            printf("------------\n");
            displayInstruction();
            while (true) {
                char decision;
                scanf("%s", &decision);
                if (decision == 'q') {
                    log_on = false;
                    printf("\tYou've logout successfully\n");
                    break;
                }
                else if (decision == 'd') {
                    requestForDoctorsList(msgid, &patient);
                }
                else if (decision == 's') {
                    displayStatusOfVisit(msgid, patient);
                    displayInstruction();
                }
                else if (decision == 'c') {
                    cancelVisit(msgid, &patient);
                    displayInstruction();
                }
                else if (decision == 'v') {
                    changeDateOfVisit(msgid, &patient);
                    displayInstruction();
                }
            }
        }
    }
    return 0;
}