Guest User

Untitled

a guest
Dec 9th, 2016
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.42 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. #include<windows.h>
  9. #include"file_1.h"
  10. #include"file_2.h"
  11. enum boolean {false, true};
  12. int login(); //This function is pretty self explanatory. It will check the credentials of the user
  13. 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.
  14. void searchDrug(char);
  15. /*-----------------------------------
  16. * this will do a similar thing to the
  17. * function above and ask to see if the
  18. * drug is the right one and then will
  19. * ask again for another search if the
  20. * response is no. I made the char below
  21. * to use in other functions but as I am
  22. * writing this I am realizing I need to
  23. * change it
  24. --------------------------------------*/
  25. char drugSearchedFor[15];
  26. int verifyNoAllergies(char,char);
  27. //this function will have no feedback given to the user unless an allergy is found with the drug
  28. //in which case it will notify the user of the issue
  29. int allClear;
  30. void administerDrug(char,char);
  31. //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
  32. void main() {
  33. login();
  34. verifyPatient();
  35. printf("What drug is being administered?\n");
  36. scanf("%s", &drugSearchedFor);
  37. searchDrug(drugSearchedFor);
  38. allClear = verifyNoAllergies(drugSearchedFor, patientNameSearchedFor);
  39. if(allClear = false) {
  40. 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");
  41. getchar();
  42. exit(0);
  43. }
  44. /*Personally I would rather have the Nurse or doctor double-check
  45. * all of their information and try again and set this exit as
  46. * somewhat of a punishment to make an incentive to not make a
  47. * mistake. It wouldn't take to long to start again anyways.
  48. * and something is likely going to mess up somewhere else.
  49. *but that's just me */
  50. administerDrug(drugSearchedFor, patientNameSearchedFor);
  51. }
  52. int login() {
  53. AddUserInfo();
  54. int success = false;
  55. int loginResult;
  56. int compare;
  57. while(1 == 1) {
  58. char input[30] = {"0"};
  59. char userlist[30] = {"0"};
  60. char password[30] = {"0"};
  61. char passwordlist[30] = {"0"};
  62. printf("Username:\n\n");
  63. scanf("%s", &input);
  64. printf("\nPassword:\n\n");
  65. scanf("%s", &password);
  66. FILE *fptr;
  67. fptr = fopen("availableUsers.txt", "r");
  68. for(i = 0; i<5; i++) {
  69. loginResult = strcmp(input, available[i].username);
  70. if(loginResult == 0){
  71. break;
  72. }
  73. }
  74. for(i = 0; i<5; i++) {
  75. compare = strcmp(password, available[i].password);
  76. if(compare == 0) {
  77. break;
  78. }
  79. }
  80. if(loginResult == 0) {
  81. loginResult = loginResult + compare;
  82. }
  83. switch(loginResult)
  84. case 0: {
  85. break;
  86. }
  87. default: {
  88. printf("Failed to login due to error in username or password")
  89. getchar();
  90. exit(0);
  91. break;
  92. }
  93. }
  94. return 0;
  95. }
  96. int verifyPatient(patient) {
  97. uploadPatients();
  98. while(compareName /= 0) {
  99. char patientSearch[30];
  100. FILE *fp;
  101. fp = fopen("patients.txt", "r");
  102. printf("Enter the first or last name of the patient");
  103. scanf("%s", &patientSearch);
  104. int compareName;
  105. int IDNumber;
  106. for(int i = 0; i < 16; i++) {
  107. compareName = strcmp(patientSearch, ident[i].firstName);
  108. if(compareName = 0) {
  109. IDNumber = i;
  110. break;
  111. }
  112. compareName = strcmp(patientSearch, ident[i].lastName);
  113. if(compareName = 0) {
  114. IDNumber = i;
  115. break;
  116. }
  117. }
  118.  
  119. switch(compareName)
  120. case 0: {
  121. int yesNo;
  122. 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);
  123. scanf("%d", &yesNo);
  124. if(yesNo == 2) {
  125. printf("please search again");
  126. compareName = 1;
  127. }
  128. break;
  129. }
  130. default: {
  131. printf("I don't have a patient with that name. Try again\n");
  132. break;
  133. }
  134. fclose(fp);
  135. }
  136. return IDNumber;
  137. }
  138.  
  139. void searchDrug(drug) {
  140. MedicineInfo();
  141. File *fp;
  142. fptr = fopen("medicine.txt", "r");
  143.  
  144. fclose(fp);
  145. }
  146. void administerDrug(drug[15], patient[15]) {
  147. char start[6] = {"s", "t", "a", "r", "t"};
  148. char verify[6];
  149. char exitCode[6] = {"e", "x", "i", "t"};
  150. int exiting = 1;
  151. int starting = 1;
  152. while (1 == 1) {
  153. printf("type 'start' to start administering the drug\n or type 'exit' to exit\n");
  154. gets(verify);
  155. exiting = strcmp(verify, exitCode);
  156. if (exiting = 0) {
  157. return;
  158. }
  159. starting = strcmp(verify, start);
  160. else if (starting = 0) {
  161. break;
  162. }
  163. else {
  164. printf("\nthat is not a valid option\n")
  165. }//this is the starting sequence
  166. int timestamp = 1200;
  167. int totalNumberOfDoses;
  168. char drug[15];
  169. char patient[15];
  170. for(int doseNumber = 1; doseNumber <= totalNumberofDoses; doseNumber++) {
  171. printf(ā€œ%d- Dispensing %d/%d of %s to %sā€, timestamp, doseNumber, totalNumberOfDoses, drug, patient);
  172. sleep(2000);
  173. timestamp + 30;
  174. printf("\ncontinue with the next dose?\n\n type 1 to stop or press any other button to continue");
  175. int stop;
  176. scanf("%d", &stop);
  177. if (stop = 1) {
  178. return;
  179. }
  180. }//and the patient is better
Add Comment
Please, Sign In to add comment