Advertisement
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>
- enum boolean {false, true};
- enum sex {male, female};
- int login(); //This function is pretty self explanatory. It will check the credentials of the user
- void verifyPatient(char); //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
- char patientNameSearchedFor;
- 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
- typedef struct searchDatabase{
- char name[15];
- int idOne;
- int idTwo;
- int idThree;
- int idFour;
- int idFive;
- int idSix;
- int idSeven;
- int idEight;
- } med;
- union patientIdentification {
- char first[15];
- char last[15];
- int year;
- int month;
- int day;
- int sex;
- int IdOne;
- int IdTwo;
- int IdThree;
- char allergies[15];
- };
- void main() {
- login();
- printf("Enter First and/or Last name of patient);
- scanf("%s", &patientNameSearchedFor);
- verifyPatient(patientNameSearchedFor);
- 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() {
- int success = false;
- int compare;
- while(1 == 1) {
- char input[30] = {"0"};
- char userlist[30] = {"0"};
- char password[30] = {"0"};
- char passwordlist[30] = {"0"};
- int numberOfUsers;
- printf("Username:\n\n");
- scanf("%s", &input);
- printf("\nPassword:\n\n");
- scanf("%s", &password);
- FILE *fptr;
- fptr = fopen("users.txt", "r");
- for(i = 0; i<numberOfUsers; i++) {
- //input code from the login lab to compare. I don't know enough about how to parse files yet so I will add that when I get there
- compare
- }
- fclose(fptr);
- if(compare = true && erapmoc = true) {
- return 1;
- }
- switch(loginResult)
- case 0: {
- printf("Failed to login due to error in username or password")
- getchar();
- exit(0);
- break;
- }
- default: {
- break;
- } //literally done to fulfill the assignment minimums.
- }
- return 0;
- }
- void verifyPatient(patient) {
- FILE *fp;
- fp = fopen("patient.txt", "r");
- /*----------------------------------------------
- * Like I said, I don't know how to parse files
- * but will do a search and return the results and
- * put them into the structure at the top
- -----------------------------------------------*/
- fclose(fp);
- }
- void searchDrug(drug) {
- File *fptr;
- fptr = fopen("medicine.txt", "r");
- /*----------------------------------------------
- * Like I said, I don't know how to parse files
- * but will do a search and return the results and
- * put them into the structure at the top
- -----------------------------------------------*/
- 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");
- gets(verify);
- exiting = strcmp(verify, exitCode);
- if (exiting = 0) {
- return;
- }
- starting = strcmp(verify, start);
- if (starting = 0) {
- break;
- }
- }//this is the starting sequence
- int timestamp;
- 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);
- wait(500); //I don't know how to do the time yet
- timestamp + 30; //I also don't know how to do a clock yet either
- 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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement