Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<string.h>
- #include<windows.h>
- #include"file_1.h"
- #include"file_2.h"
- enum boolean {false, true};
- int login(); //This function is pretty self explanatory. It will check the credentials of the user
- int verifyPatient(); //This will identify the patient based on the file information after a search is done and then bring up verifications on their information.
- char searchDrug();
- int drugID;
- int PatientID;
- int verifyNoAllergies(int,intd);
- //this function will have no feedback given to the user unless an allergy is found with the drug
- //in which case it will notify the user of the issue
- int allClear;
- void administerDrug(char,char);
- //this will do a for loop for the printf and allow the user to exit before starting and continue to ask if it can continue
- void main() {
- login();
- PatientID = verifyPatient();
- drugID = searchDrug();
- allClear = verifyNoAllergies(drug, PatientID);
- if(allClear = false) {
- printf("\nThis patient has allergies to this specific drug.\n\nPlease double-check your charts and try again\n\npress any key and enter to exit");
- getchar();
- exit(0);
- }
- administerDrug(drugSearchedFor, patientNameSearchedFor);
- }
- int login() {
- AddUserInfo();
- int success = false;
- int loginResult;
- int compare;
- while(1 == 1) {
- char input[30] = {"0"};
- char userlist[30] = {"0"};
- char password[30] = {"0"};
- char passwordlist[30] = {"0"};
- printf("Username:\n\n");
- scanf("%s", &input);
- printf("\nPassword:\n\n");
- scanf("%s", &password);
- FILE *fptr;
- fptr = fopen("availableUsers.txt", "r");
- for(i = 0; i<5; i++) {
- loginResult = strcmp(input, available[i].username);
- if(loginResult == 0){
- break;
- }
- }
- for(i = 0; i<5; i++) {
- compare = strcmp(password, available[i].password);
- if(compare == 0) {
- break;
- }
- }
- if(loginResult == 0) {
- loginResult = loginResult + compare;
- }
- switch(loginResult)
- case 0: {
- break;
- }
- default: {
- printf("Failed to login due to error in username or password")
- getchar();
- exit(0);
- break;
- }
- }
- return 0;
- }
- int verifyPatient(patient) {
- uploadPatients();
- int IDNumber;
- while(compareName /= 0) {
- char patientSearch[30];
- FILE *fp;
- fp = fopen("patients.txt", "r");
- printf("Enter the first or last name of the patient");
- scanf("%s", &patientSearch);
- getchar();
- int compareName = 1;
- for(int i = 0; i < 16; i++) {
- compareName = strcmp(patientSearch, ident[i].firstName);
- if(compareName = 0) {
- IDNumber = i;
- break;
- }
- compareName = strcmp(patientSearch, ident[i].lastName);
- if(compareName = 0) {
- IDNumber = i;
- break;
- }
- }
- switch(compareName)
- case 0: {
- int yesNo;
- printf("is %s %s, born on %d %d %d with an allergy to %s the person you are looking for?\n type 1 for yes or 2 for no", ident[IDNumber].firstName, ident[IDNumber].lastName, ident[IDNumber].year, ident[IDNumber].month, ident[IDNumber].day, ident[IDNumber].allergies);
- scanf("%d", &yesNo);
- getchar();
- if(yesNo == 2) {
- printf("please search again");
- compareName = 1;
- }
- break;
- }
- default: {
- printf("I don't have a patient with that name. Try again\n");
- break;
- }
- fclose(fp);
- }
- return IDNumber;
- }
- int searchDrug() {
- int IDNumber;
- MedicineInfo();
- File *fp;
- fptr = fopen("Medication.txt", "r");
- int compareDrug = 1;
- while(compareDrug /= 0) {
- printf("\nWhat drug are you looking for?);
- char search[30];
- scanf("%s", &search);
- getchar();
- for(int i = 0; i < 16; i++) {
- compareDrug = strcmp(search, info[i].name);
- if(compareDrug = 0) {
- IDNumber = i;
- break;
- }
- }
- switch(compareDrug)
- case 0: {
- int yesNo;
- printf("Is %s the drug you are looking for?\ntype 1 for yes or 2 for no\n", info[IDNumber].name);
- scanf("%d", yesNo);
- getchar();
- if(yesNo == 2) {
- printf("please search again");
- compareDrug = 1;
- }
- break;
- }
- default: {
- printf("I have no drug with that name. please search again\n");
- break
- }
- }
- fclose(fp);
- return IDNumber;
- }
- void administerDrug(drug, patient) {
- char start[6] = {"s", "t", "a", "r", "t"};
- char verify[6];
- char exitCode[6] = {"e", "x", "i", "t"};
- int exiting = 1;
- int starting = 1;
- while (1 == 1) {
- printf("type 'start' to start administering the drug\n or type 'exit' to exit\n");
- gets(verify);
- exiting = strcmp(verify, exitCode);
- if (exiting = 0) {
- return;
- }
- starting = strcmp(verify, start);
- else if (starting = 0) {
- break;
- }
- else {
- printf("\nthat is not a valid option\n")
- }
- int timestamp = 1200;
- int totalNumberOfDoses;
- int age;
- int weight;
- char nameOfPatientA[30];
- char nameOfPatientB[30];
- FILE *fptr;
- fptr = fopen("patients.txt", "r");
- fscanf(fptr, ident[patient].age, &age);
- fscanf(fptr, ident[patient].valueA, &weight);
- fscanf(fptr, ident[patient].firstName, &nameOfPatientA);
- fscanf(fptr, ident[patient].firstName, &nameOfPatientB);
- fclose(fptr);
- FILE *fp;
- fp = fopen("Medication.txt", "r");
- int dose;
- int amount;
- int frequency;
- if(age => 18) {
- if(weight => 150) {
- fscanf(fptr, info[drug].valueA, &dose);
- }
- else {
- fscanf(fptr, info[drug].valueB, &dose);
- }
- fscanf(fptr, info[drug].valueE, &amount);
- fscanf(fptr, info[drug].valueG, &frequency);
- }
- else {
- if(weight => 120) {
- fscanf(fptr, info[drug].valueC, &dose);
- }
- else {
- fscanf(fptr, info[drug].valueD, &dose);
- }
- fscanf(fptr, info[drug].valueE, &amount);
- fscanf(fptr, info[drug].valueG, &frequency);
- }
- char drugName[30];
- fscanf(fptr, info[drug].name, drugName);
- int simFrequency;
- simFrequency = 30 * frequency;
- frequency = 2000 * frequency;
- for(int doseNumber = 1; doseNumber <= dose; doseNumber++) {
- printf(ā%d- Dispensing %d/%d of %s to %s %sā, timestamp, doseNumber, dose, drugName, nameOfPatientA, nameOfPatientB);
- sleep(frequency);
- timestamp + simFrequency;
- printf("\ncontinue with the next dose?\n\n type 1 to stop or press any other button to continue");
- int stop;
- scanf("%d", &stop);
- if (stop = 1) {
- return;
- }
- }//and the patient is better
Add Comment
Please, Sign In to add comment