Advertisement
Guest User

Untitled

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