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 6.11 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<string.h>
  3. #include<windows.h>
  4. #include"file_1.h"
  5. #include"file_2.h"
  6. enum boolean {false, true};
  7. int login(); //This function is pretty self explanatory. It will check the credentials of the user
  8. 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.
  9. char searchDrug();
  10. int drugID;
  11. int PatientID;
  12. int verifyNoAllergies(int,intd);
  13. //this function will have no feedback given to the user unless an allergy is found with the drug
  14. //in which case it will notify the user of the issue
  15. int allClear;
  16. void administerDrug(char,char);
  17. //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
  18. void main() {
  19. login();
  20. PatientID = verifyPatient();
  21. drugID = searchDrug();
  22. allClear = verifyNoAllergies(drug, PatientID);
  23. if(allClear = false) {
  24. 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");
  25. getchar();
  26. exit(0);
  27. }
  28. administerDrug(drugSearchedFor, patientNameSearchedFor);
  29. }
  30. int login() {
  31. AddUserInfo();
  32. int success = false;
  33. int loginResult;
  34. int compare;
  35. while(1 == 1) {
  36. char input[30] = {"0"};
  37. char userlist[30] = {"0"};
  38. char password[30] = {"0"};
  39. char passwordlist[30] = {"0"};
  40. printf("Username:\n\n");
  41. scanf("%s", &input);
  42. printf("\nPassword:\n\n");
  43. scanf("%s", &password);
  44. FILE *fptr;
  45. fptr = fopen("availableUsers.txt", "r");
  46. for(i = 0; i<5; i++) {
  47. loginResult = strcmp(input, available[i].username);
  48. if(loginResult == 0){
  49. break;
  50. }
  51. }
  52. for(i = 0; i<5; i++) {
  53. compare = strcmp(password, available[i].password);
  54. if(compare == 0) {
  55. break;
  56. }
  57. }
  58. if(loginResult == 0) {
  59. loginResult = loginResult + compare;
  60. }
  61. switch(loginResult)
  62. case 0: {
  63. break;
  64. }
  65. default: {
  66. printf("Failed to login due to error in username or password")
  67. getchar();
  68. exit(0);
  69. break;
  70. }
  71. }
  72. return 0;
  73. }
  74. int verifyPatient(patient) {
  75. uploadPatients();
  76. int IDNumber;
  77. while(compareName /= 0) {
  78. char patientSearch[30];
  79. FILE *fp;
  80. fp = fopen("patients.txt", "r");
  81. printf("Enter the first or last name of the patient");
  82. scanf("%s", &patientSearch);
  83. getchar();
  84. int compareName = 1;
  85. for(int i = 0; i < 16; i++) {
  86. compareName = strcmp(patientSearch, ident[i].firstName);
  87. if(compareName = 0) {
  88. IDNumber = i;
  89. break;
  90. }
  91. compareName = strcmp(patientSearch, ident[i].lastName);
  92. if(compareName = 0) {
  93. IDNumber = i;
  94. break;
  95. }
  96. }
  97.  
  98. switch(compareName)
  99. case 0: {
  100. int yesNo;
  101. 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);
  102. scanf("%d", &yesNo);
  103. getchar();
  104. if(yesNo == 2) {
  105. printf("please search again");
  106. compareName = 1;
  107. }
  108. break;
  109. }
  110. default: {
  111. printf("I don't have a patient with that name. Try again\n");
  112. break;
  113. }
  114. fclose(fp);
  115. }
  116. return IDNumber;
  117. }
  118.  
  119. int searchDrug() {
  120. int IDNumber;
  121. MedicineInfo();
  122. File *fp;
  123. fptr = fopen("Medication.txt", "r");
  124. int compareDrug = 1;
  125. while(compareDrug /= 0) {
  126. printf("\nWhat drug are you looking for?);
  127. char search[30];
  128. scanf("%s", &search);
  129. getchar();
  130. for(int i = 0; i < 16; i++) {
  131. compareDrug = strcmp(search, info[i].name);
  132. if(compareDrug = 0) {
  133. IDNumber = i;
  134. break;
  135. }
  136. }
  137. switch(compareDrug)
  138. case 0: {
  139. int yesNo;
  140. printf("Is %s the drug you are looking for?\ntype 1 for yes or 2 for no\n", info[IDNumber].name);
  141. scanf("%d", yesNo);
  142. getchar();
  143. if(yesNo == 2) {
  144. printf("please search again");
  145. compareDrug = 1;
  146. }
  147. break;
  148. }
  149. default: {
  150. printf("I have no drug with that name. please search again\n");
  151. break
  152. }
  153. }
  154. fclose(fp);
  155. return IDNumber;
  156. }
  157.  
  158. void administerDrug(drug, patient) {
  159. char start[6] = {"s", "t", "a", "r", "t"};
  160. char verify[6];
  161. char exitCode[6] = {"e", "x", "i", "t"};
  162. int exiting = 1;
  163. int starting = 1;
  164. while (1 == 1) {
  165. printf("type 'start' to start administering the drug\n or type 'exit' to exit\n");
  166. gets(verify);
  167. exiting = strcmp(verify, exitCode);
  168. if (exiting = 0) {
  169. return;
  170. }
  171. starting = strcmp(verify, start);
  172. else if (starting = 0) {
  173. break;
  174. }
  175. else {
  176. printf("\nthat is not a valid option\n")
  177. }
  178. int timestamp = 1200;
  179. int totalNumberOfDoses;
  180. int age;
  181. int weight;
  182. char nameOfPatientA[30];
  183. char nameOfPatientB[30];
  184. FILE *fptr;
  185. fptr = fopen("patients.txt", "r");
  186. fscanf(fptr, ident[patient].age, &age);
  187. fscanf(fptr, ident[patient].valueA, &weight);
  188. fscanf(fptr, ident[patient].firstName, &nameOfPatientA);
  189. fscanf(fptr, ident[patient].firstName, &nameOfPatientB);
  190. fclose(fptr);
  191. FILE *fp;
  192. fp = fopen("Medication.txt", "r");
  193. int dose;
  194. int amount;
  195. int frequency;
  196. if(age => 18) {
  197. if(weight => 150) {
  198. fscanf(fptr, info[drug].valueA, &dose);
  199. }
  200. else {
  201. fscanf(fptr, info[drug].valueB, &dose);
  202. }
  203.  
  204. fscanf(fptr, info[drug].valueE, &amount);
  205. fscanf(fptr, info[drug].valueG, &frequency);
  206. }
  207. else {
  208. if(weight => 120) {
  209. fscanf(fptr, info[drug].valueC, &dose);
  210. }
  211. else {
  212. fscanf(fptr, info[drug].valueD, &dose);
  213. }
  214.  
  215. fscanf(fptr, info[drug].valueE, &amount);
  216. fscanf(fptr, info[drug].valueG, &frequency);
  217. }
  218. char drugName[30];
  219. fscanf(fptr, info[drug].name, drugName);
  220. int simFrequency;
  221. simFrequency = 30 * frequency;
  222. frequency = 2000 * frequency;
  223. for(int doseNumber = 1; doseNumber <= dose; doseNumber++) {
  224. printf(ā€œ%d- Dispensing %d/%d of %s to %s %sā€, timestamp, doseNumber, dose, drugName, nameOfPatientA, nameOfPatientB);
  225. sleep(frequency);
  226. timestamp + simFrequency;
  227. printf("\ncontinue with the next dose?\n\n type 1 to stop or press any other button to continue");
  228. int stop;
  229. scanf("%d", &stop);
  230. if (stop = 1) {
  231. return;
  232. }
  233. }//and the patient is better
Add Comment
Please, Sign In to add comment