Advertisement
Guest User

Untitled

a guest
Nov 15th, 2016
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.48 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 .
  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);//this function will have no feedback given to the user unless an allergy is found with the drug
  25. //in which case it will notify the user of the issue
  26. char patientNameSearchedFor;
  27. int allClear;
  28. void administerDrug(char,char);
  29. typedef struct searchDatabase{
  30. char name[15];
  31. int idOne;
  32. int idTwo;
  33. int idThree;
  34. int idFour;
  35. int idFive;
  36. int idSix;
  37. int idSeven;
  38. int idEight;
  39. } med;
  40. union patientIdentification {
  41. char first[15];
  42. char last[15];
  43. int year;
  44. int month;
  45. int day;
  46. int sex;
  47. int IdOne;
  48. int IdTwo;
  49. int IdThree;
  50. char allergies[15];
  51. };
  52. void main() {
  53. login();
  54. printf("Enter First and/or Last name of patient);
  55. scanf("%s", &patientNameSearchedFor);
  56. verifyPatient(patientNameSearchedFor);
  57. printf("What drug is being administered?\n");
  58. scanf("%s", &drugSearchedFor);
  59. searchDrug(drugSearchedFor);
  60. allClear = verifyNoAllergies(drugSearchedFor, patientNameSearchedFor);
  61. if(allClear = false) {
  62. 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");
  63. getchar();
  64. end(0);
  65. }
  66. /*Personally I would rather have the Nurse or doctor double-check
  67. * all of their information and try again and set this exit as
  68. * somewhat of a punishment to make an incentive to not make a
  69. * mistake. It wouldn't take to long to start again anyways.*/
  70. administerDrug(drugSearchedFor, patientNameSearchedFor);
  71. }
  72. int login() {
  73. int success = false;
  74. int compare;
  75. while(1 == 1) {
  76. char input[30] = {"0"};
  77. char userlist[30] = {"0"};
  78. char password[30] = {"0"};
  79. char passwordlist[30] = {"0"};
  80. int numberOfUsers;
  81. printf("Username:\n\n");
  82. scanf("%s", &input);
  83. printf("\nPassword:\n\n");
  84. scanf("%s", &password);
  85. FILE *fptr;
  86. fptr = fopen("users.txt", "r");
  87. for(i = 0; i<numberOfUsers; i++) {
  88. //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
  89. compare
  90. }
  91. fclose(fptr);
  92. if(compare = true && erapmoc = true) {
  93. return 1;
  94. }
  95. switch(loginResult)
  96. case 0: {
  97. printf("Failed to login due to error in username or password")
  98. getchar();
  99. exit(0);
  100. break;
  101. }
  102. default: {
  103. break;
  104. } //literally done to fulfill the assignment minimums.
  105. }
  106. return 0;
  107. }
  108. void verifyPatient(patient) {
  109. FILE *fp;
  110. fp = fopen("patient.txt", "r");
  111. fclose(fp);
  112. }
  113. void searchDrug(drug) {
  114. File *fptr;
  115. fptr = fopen("medicine.txt", "r");
  116. fclose(fp);
  117. }
  118. void administerDrug(drug[15], patient[15]) {
  119. char start[6] = {"s", "t", "a", "r", "t"};
  120. char verify[6];
  121. char exitCode[6] = {"e", "x", "i", "t"};
  122. int exiting = 1;
  123. int starting = 1;
  124. while (1 == 1) {
  125. printf("type 'start' to start administering the drug\n or type 'exit' to exit");
  126. gets(verify);
  127. exiting = strcmp(verify, exitCode);
  128. if (exiting = 0) {
  129. return;
  130. }
  131. starting = strcmp(verify, start);
  132. if (starting = 0) {
  133. break;
  134. }
  135. }//this is the starting sequence
  136. int timestamp;
  137. int totalNumberOfDoses;
  138. char drug[15];
  139. char patient[15];
  140. for(int doseNumber = 1; doseNumber <= totalNumberofDoses; doseNumber++) {
  141. printf(ā€œ%d- Dispensing %d/%d of %s to %sā€, timestamp, doseNumber, totalNumberOfDoses, drug, patient);
  142. wait(500); //I don't know how to do the time yet
  143. timestamp + 30; //I also don't know how to do a clock yet either
  144. printf("\ncontinue with the next dose?\n\n type 1 to stop or press any other button to continue");
  145. int stop;
  146. scanf("%d", &stop);
  147. if (stop = 1) {
  148. return;
  149. }
  150. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement