Advertisement
Guest User

Untitled

a guest
Jun 13th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.98 KB | None | 0 0
  1. @using Resources
  2. @model PTS41.Models.Content.PatientAppointmentContent
  3. @{
  4. ViewBag.Title = Doctor.PATIENT_APPOINTMENT;
  5. ViewBag.PageTitle = Doctor.PATIENT_APPOINTMENT;
  6. }
  7.  
  8. <script>
  9. function createTxtBox(description) {
  10. var input = document.createElement("input");
  11. input.type = "hidden";
  12. input.id = "input" + globalIndex;
  13. input.name = "input" + globalIndex;
  14.  
  15. if (description == null) {
  16. input.value = "";
  17.  
  18. } else {
  19. input.value = description;
  20. }
  21. document.getElementById("prescriptionContainer").appendChild(input);
  22.  
  23. document.getElementById("PrescriptionDescription").value = "";
  24. globalIndex += 1;
  25. }
  26. </script>
  27.  
  28. <div class="container">
  29. <div class="row">
  30. <div class="col-12">
  31. <!-- Temporary-->
  32. <div class="card">
  33. <div class="card-body">
  34. <h4 class="card-title">@Doctor.PATIENT_APPOINTMENT</h4>
  35. <h6 class="card-subtitle"></h6>
  36. <div>
  37. <div class="form-group">
  38. <label for="usr">@Global.NAME:</label>
  39. <input type="text" class="form-control" id="name" value="@(Model.User.name + " " + Model.User.lastname)" disabled>
  40. </div>
  41. <div class="form-group">
  42. <label for="birthday">@Global.BIRTH_DATE:</label>
  43. <input type="text" class="form-control" id="birthday" value="@Model.User.birthdate.ToShortDateString()" disabled>
  44. </div>
  45. <br/>
  46. <div class="form-group">
  47. <label for="reason">@Doctor.VISIT_REASON:</label>
  48. <input type="text" class="form-control" id="reason" value="@Model.CurrentAppointment.reason" disabled>
  49. </div>
  50. <div class="form-group">
  51. <label for="description">@Doctor.DESCRIPTION:</label>
  52. <input type="text" class="form-control" id="description" value="@Model.CurrentAppointment.description" disabled>
  53. </div>
  54. @using (Html.BeginForm("SaveAppointment", "Doctor", FormMethod.Post))
  55. {
  56. <input type="hidden" value="@Model.CurrentAppointment.id" name="AppointmentId"/>
  57. <input type="hidden" value="@Model.CurrentAppointment.patient_id" name="PatientId"/>
  58. <div class="form-group">
  59. <!-- Button trigger modal -->
  60. <!-- Modal -->
  61. <div class="modal fade" id="drugModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  62. <div class="modal-dialog" style="width: 2250px;" role="document">
  63. <div class="modal-content">
  64. <div class="container">
  65. <div class="modal-header">
  66. <h5 class="modal-title" id="exampleModalLabel">@Doctor.MEDICINE</h5>
  67. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  68. <span aria-hidden="true">&times;</span>
  69. </button>
  70. </div>
  71. <!-- Alle medicijnen -->
  72. <label for="exampleFormControlSelect2">@Doctor.ALL_MEDICINE:</label>
  73. <select multiple class="form-control" id="lstBox1">
  74. @{
  75. foreach (var drug in Model.AllDrugs)
  76. {
  77. <option id="@drug.id" value="@drug.id">@(drug.name + " - " + drug.description)</option>
  78. }
  79. }
  80. </select>
  81. <br/>
  82. <div class="subject-info-arrows text-center">
  83. <input type="button" id="btnDown" onclick="btnDownClick()" value="▼" class="btn btn-default"/>
  84. &nbsp;&nbsp;&nbsp;
  85. <input type="button" id="btnUp" onclick="btnUpClick()" value="▲" class="btn btn-default"/>
  86. </div>
  87. <!--Huidig gebruikende medicijnen-->
  88. <label for="exampleFormControlSelect2">@Doctor.CURRENT_USING_MEDICINE:</label>
  89. <select multiple class="form-control" id="lstBox2" onchange="selectedIndexChanged()">
  90. @{
  91. foreach (var drug in Model.CurrentUsingDrugs)
  92. {
  93. <option value="@drug.id">@(drug.name + " - " + drug.description)</option>
  94. }
  95. }
  96. </select>
  97. <br/>
  98. Gebruiksbeschrijving<br/>
  99. <textarea class="form-control" id="PrescriptionDescription" rows="6" onkeyup="setPrescriptionVariable()"></textarea>
  100. </div>
  101. <div class="modal-footer" id="prescriptionContainer">
  102. <script type="text/javascript">
  103. var globalIndex = 0;
  104. </script>
  105.  
  106. @foreach (var drug in Model.PrescriptionAndDrug)
  107. {
  108. <script type="text/javascript">
  109. createTxtBox('@drug.Key.description');
  110. </script>
  111. }
  112. <input type="hidden" name="globalIndex" id="txtGlobalIndex"/>
  113. </div>
  114. </div>
  115. </div>
  116. </div>
  117. <!--End modal-->
  118. <input type="hidden" value="@Model.AllCurrentUsingDrugsString" name="AllCurrentUsingDrugsString" id="AllCurrentUsingDrugsString"/>
  119. <label for="exampleFormControlSelect2">@Doctor.CURRENT_USING_MEDICINE:</label>
  120. <select multiple class="form-control" id="lstBox3" name="testListItems">
  121. @{
  122. foreach (var drug in Model.CurrentUsingDrugs)
  123. {
  124. <option value="@drug.id">@(drug.name + " - " + drug.description)</option>
  125. }
  126. }
  127. </select>
  128. <button style="margin: 35px 0000" type="button" class="btn btn-info" data-toggle="modal" data-target="#drugModal">
  129. @Doctor.LINK_MEDICINE
  130. </button>
  131. <br/>
  132. </div>
  133. <div class="form-group">
  134. <label for="exampleFormControlTextarea1">@Doctor.APPOINTMENT_INFO:</label>
  135. <textarea class="form-control" id="conversationText" name="appointmentComments" rows="6">@Model.CurrentAppointment.comments</textarea>
  136. </div>
  137.  
  138. <div class="btn-group" data-toggle="buttons">
  139. <label class="btn btn-info"> <input type="radio" name="presence" value="present"/> Aanwezig</label>
  140. <label class="btn btn-info"> <input type="radio" name="presence" value="absent"/> Afwezig</label>
  141. </div>
  142. <input class="btn btn-primary" type="submit" value="@Global.SAVE">
  143. }
  144. </div>
  145. </div>
  146. </div>
  147. </div>
  148. </div>
  149. </div>
  150. <script>
  151. function selectedIndexChanged() {
  152. console.log("selected index changed");
  153.  
  154. const selectedIndex = document.getElementById("lstBox2").selectedIndex;
  155.  
  156. const myElem = document.getElementById(`input${selectedIndex}`);
  157.  
  158. if (myElem === null) {
  159. createTxtBox("");
  160. } else {
  161. document.getElementById("PrescriptionDescription").value =
  162. document.getElementById(`input${selectedIndex}`).value;
  163. }
  164.  
  165. document.getElementById("txtGlobalIndex").value = globalIndex;
  166. }
  167.  
  168. function setPrescriptionVariable() {
  169. const selectedIndex = document.getElementById("lstBox2").selectedIndex;
  170.  
  171. if (document.getElementById("PrescriptionDescription").value != null) {
  172. document.getElementById(`input${selectedIndex}`).value =
  173. document.getElementById("PrescriptionDescription").value;
  174. }
  175. }
  176.  
  177. function btnDownClick() {
  178. const selectedOpts = $('#lstBox1 option:selected');
  179.  
  180. $('#lstBox2').append($(selectedOpts).clone());
  181. $('#lstBox3').append($(selectedOpts).clone());
  182. $(selectedOpts).remove();
  183.  
  184. // Id's toevoegen aan txtbox.
  185. var ids = new Array();
  186. $('#lstBox2').children().each(function() {
  187. ids.push($(this).val());
  188. });
  189. document.getElementById("AllCurrentUsingDrugsString").value = ids;
  190. }
  191.  
  192. function btnUpClick() {
  193. const index = document.getElementById("lstBox2").selectedIndex;
  194. document.getElementById("lstBox3").remove(index);
  195.  
  196. const selectedOpts = $('#lstBox2 option:selected');
  197. if (selectedOpts.length == 0) {
  198. alert("Nothing to move.");
  199. }
  200. $('#lstBox1').append($(selectedOpts).clone());
  201. $(selectedOpts).remove();
  202.  
  203. // id's verwijderen uit textbox
  204. var ids = new Array();
  205. $('#lstBox2').children().each(function() {
  206. ids.push($(this).val());
  207. });
  208. document.getElementById("AllCurrentUsingDrugsString").value = ids;
  209.  
  210. // Alle textboxen boven de verwijderde index hernoemen.
  211. document.getElementById(`input${index}`).remove();
  212.  
  213. for (let i = index + 1; i < globalIndex; i++) {
  214. const input = document.getElementById(`input${i}`);
  215. console.log(`input id = ${input.id}`);
  216. console.log(`Index = ${index}`);
  217. input.id = `input${i - 1}`;
  218. console.log(`input id = ${input.id}`);
  219. }
  220. globalIndex -= 1;
  221.  
  222. document.getElementById("PrescriptionDescription").value = "";
  223. }
  224. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement