Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*------------------------------------------
- * I do not know if you want the full function
- * or just a basic outline so I just did as
- * much of the program as I could so far
- -------------------------------------------*/
- #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.
- void searchDrug(char);
- /*-----------------------------------
- * this will do a similar thing to the
- * function above and ask to see if the
- * drug is the right one and then will
- * ask again for another search if the
- * response is no. I made the char below
- * to use in other functions but as I am
- * writing this I am realizing I need to
- * change it
- --------------------------------------*/
- char drugSearchedFor[15];
- int verifyNoAllergies(char,char);
- //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();
- verifyPatient();
- printf("What drug is being administered?\n");
- scanf("%s", &drugSearchedFor);
- searchDrug(drugSearchedFor);
- allClear = verifyNoAllergies(drugSearchedFor, patientNameSearchedFor);
- 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);
- }
- /*Personally I would rather have the Nurse or doctor double-check
- * all of their information and try again and set this exit as
- * somewhat of a punishment to make an incentive to not make a
- * mistake. It wouldn't take to long to start again anyways.
- * and something is likely going to mess up somewhere else.
- *but that's just me */
- 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();
- 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);
- int compareName;
- int IDNumber;
- 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);
- 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;
- }
- void searchDrug(drug) {
- MedicineInfo();
- File *fp;
- fptr = fopen("medicine.txt", "r");
- fclose(fp);
- }
- void administerDrug(drug[15], patient[15]) {
- 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")
- }//this is the starting sequence
- int timestamp = 1200;
- int totalNumberOfDoses;
- char drug[15];
- char patient[15];
- for(int doseNumber = 1; doseNumber <= totalNumberofDoses; doseNumber++) {
- printf(ā%d- Dispensing %d/%d of %s to %sā, timestamp, doseNumber, totalNumberOfDoses, drug, patient);
- sleep(2000);
- timestamp + 30;
- 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