Advertisement
Guest User

Untitled

a guest
Nov 15th, 2016
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.27 KB | None | 0 0
  1. /*------------------------------------------
  2. * I do not know if you want the full function
  3. * or just a basic outline so I just did as
  4. * much of the program as I could so far
  5. -------------------------------------------*/
  6. #include<stdio.h>
  7. #include<string.h>
  8. enum boolean {false, true};
  9. enum sex {male, female};
  10. int login(); //This function is pretty self explanatory. It will check the credentials of the user
  11. 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.
  12. void searchDrug(char);
  13. /*-----------------------------------
  14. * this will do a similar thing to the
  15. * function above and ask to see if the
  16. * drug is the right one and then will
  17. * ask again for another search if the
  18. * response is no. I made the char below
  19. * to use in other functions but as I am
  20. * writing this I am realizing I need to
  21. * change it
  22. --------------------------------------*/
  23. char drugSearchedFor[15];
  24. int verifyNoAllergies(char,char);
  25. //this function will have no feedback given to the user unless an allergy is found with the drug
  26. //in which case it will notify the user of the issue
  27. char patientNameSearchedFor;
  28. int allClear;
  29. void administerDrug(char,char);
  30. //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
  31. typedef struct searchDatabase{
  32. char name[15];
  33. int idOne;
  34. int idTwo;
  35. int idThree;
  36. int idFour;
  37. int idFive;
  38. int idSix;
  39. int idSeven;
  40. int idEight;
  41. } med;
  42. union patientIdentification {
  43. char first[15];
  44. char last[15];
  45. int year;
  46. int month;
  47. int day;
  48. int sex;
  49. int IdOne;
  50. int IdTwo;
  51. int IdThree;
  52. char allergies[15];
  53. };
  54. void main() {
  55. login();
  56. printf("Enter First and/or Last name of patient);
  57. scanf("%s", &patientNameSearchedFor);
  58. verifyPatient(patientNameSearchedFor);
  59. printf("What drug is being administered?\n");
  60. scanf("%s", &drugSearchedFor);
  61. searchDrug(drugSearchedFor);
  62. allClear = verifyNoAllergies(drugSearchedFor, patientNameSearchedFor);
  63. if(allClear = false) {
  64. 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");
  65. getchar();
  66. exit(0);
  67. }
  68. /*Personally I would rather have the Nurse or doctor double-check
  69. * all of their information and try again and set this exit as
  70. * somewhat of a punishment to make an incentive to not make a
  71. * mistake. It wouldn't take to long to start again anyways.
  72. * and something is likely going to mess up somewhere else.
  73. *but that's just me */
  74. administerDrug(drugSearchedFor, patientNameSearchedFor);
  75. }
  76. int login() {
  77. int success = false;
  78. int compare;
  79. while(1 == 1) {
  80. char input[30] = {"0"};
  81. char userlist[30] = {"0"};
  82. char password[30] = {"0"};
  83. char passwordlist[30] = {"0"};
  84. int numberOfUsers;
  85. printf("Username:\n\n");
  86. scanf("%s", &input);
  87. printf("\nPassword:\n\n");
  88. scanf("%s", &password);
  89. FILE *fptr;
  90. fptr = fopen("users.txt", "r");
  91. for(i = 0; i<numberOfUsers; i++) {
  92. //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
  93. compare
  94. }
  95. fclose(fptr);
  96. if(compare = true && erapmoc = true) {
  97. return 1;
  98. }
  99. switch(loginResult)
  100. case 0: {
  101. printf("Failed to login due to error in username or password")
  102. getchar();
  103. exit(0);
  104. break;
  105. }
  106. default: {
  107. break;
  108. } //literally done to fulfill the assignment minimums.
  109. }
  110. return 0;
  111. }
  112. void verifyPatient(patient) {
  113. FILE *fp;
  114. fp = fopen("patient.txt", "r");
  115. /*----------------------------------------------
  116. * Like I said, I don't know how to parse files
  117. * but will do a search and return the results and
  118. * put them into the structure at the top
  119. -----------------------------------------------*/
  120. fclose(fp);
  121. }
  122. void searchDrug(drug) {
  123. File *fptr;
  124. fptr = fopen("medicine.txt", "r");
  125. /*----------------------------------------------
  126. * Like I said, I don't know how to parse files
  127. * but will do a search and return the results and
  128. * put them into the structure at the top
  129. -----------------------------------------------*/
  130. fclose(fp);
  131. }
  132. void administerDrug(drug[15], patient[15]) {
  133. char start[6] = {"s", "t", "a", "r", "t"};
  134. char verify[6];
  135. char exitCode[6] = {"e", "x", "i", "t"};
  136. int exiting = 1;
  137. int starting = 1;
  138. while (1 == 1) {
  139. printf("type 'start' to start administering the drug\n or type 'exit' to exit");
  140. gets(verify);
  141. exiting = strcmp(verify, exitCode);
  142. if (exiting = 0) {
  143. return;
  144. }
  145. starting = strcmp(verify, start);
  146. if (starting = 0) {
  147. break;
  148. }
  149. }//this is the starting sequence
  150. int timestamp;
  151. int totalNumberOfDoses;
  152. char drug[15];
  153. char patient[15];
  154. for(int doseNumber = 1; doseNumber <= totalNumberofDoses; doseNumber++) {
  155. printf(ā€œ%d- Dispensing %d/%d of %s to %sā€, timestamp, doseNumber, totalNumberOfDoses, drug, patient);
  156. wait(500); //I don't know how to do the time yet
  157. timestamp + 30; //I also don't know how to do a clock yet either
  158. printf("\ncontinue with the next dose?\n\n type 1 to stop or press any other button to continue");
  159. int stop;
  160. scanf("%d", &stop);
  161. if (stop = 1) {
  162. return;
  163. }
  164. }//and the patient is better
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement