Advertisement
Guest User

Untitled

a guest
Dec 31st, 2012
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.06 KB | None | 0 0
  1. <%@ include file="/WEB-INF/template/include.jsp"%>
  2.  
  3. <%@ include file="/WEB-INF/template/header.jsp"%>
  4. <openmrs:htmlInclude file="/scripts/timepicker/timepicker.js" />
  5. <openmrs:htmlInclude
  6. file="/moduleResources/appointment/Scripts/jquery.dataTables.js" />
  7. <openmrs:htmlInclude
  8. file="/moduleResources/appointment/Scripts/jquery.maxlength.js" />
  9. <openmrs:htmlInclude
  10. file="/moduleResources/appointment/Scripts/queryParameters.js" />
  11. <openmrs:htmlInclude
  12. file="/moduleResources/appointment/Styles/createAppointmentStyle.css" />
  13. <openmrs:htmlInclude
  14. file="/moduleResources/appointment/Styles/appointment_jQueryDatatable.css" />
  15. <openmrs:htmlInclude
  16. file="/moduleResources/appointment/Styles/jQuerySmoothness/jquery-ui-1.9.2.custom.css" />
  17.  
  18. <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
  19.  
  20. <script type="text/javascript">
  21. function forceMaxLength(object, maxLength) {
  22. if (object.value.length >= maxLength) {
  23. object.value = object.value.substring(0, maxLength);
  24. }
  25. }
  26. </script>
  27. <script type="text/javascript"
  28. src='${pageContext.request.contextPath}/dwr/engine.js'></script>
  29. <script type="text/javascript"
  30. src='${pageContext.request.contextPath}/dwr/util.js'></script>
  31. <script type="text/javascript"
  32. src='${pageContext.request.contextPath}/dwr/interface/DWRAppointmentService.js'></script>
  33. <script type="text/javascript">
  34. $j(document)
  35. .ready(
  36. function() {
  37. //Focus "search patient"
  38. $j('#patient_id_selection').focus();
  39.  
  40. //Init max notes length
  41. $j('[name="reason"]').maxlength({
  42. 'feedback' : '.charsLeft',
  43. 'useInput' : true
  44. });
  45.  
  46. //Datatables.net
  47. $j('#availableTimesTable').dataTable(
  48. {
  49. "aoColumns" : [ {
  50. "bSortable" : true
  51. }, {
  52. "bSortable" : true
  53. }, {
  54. "bSortable" : true
  55. }, {
  56. "iDataSort" : 6
  57. }, {
  58. "bSortable" : true
  59. }, {
  60. "bSortable" : true
  61. }, {
  62. "bVisible" : false
  63. } ],
  64. "oLanguage": {
  65. "sZeroRecords": "<spring:message code='appointment.Appointment.create.table.empty' />"
  66. },
  67. "aLengthMenu" : [ [ 5, 10, 25, 50, -1 ],
  68. [ 5, 10, 25, 50, "All" ] ],
  69. "iDisplayLength" : 5,
  70. "bLengthChange" : true,
  71. "bFilter" : false,
  72. "bInfo" : true,
  73. "bPaginate" : true,
  74. "bJQueryUI" : true
  75. });
  76.  
  77. //If the user is using "Simple" version
  78.  
  79. if ($j('#locationId').length > 0) {
  80. var selectLocation = $j('#locationId');
  81. //Set the Null option text (Default is empty string)
  82. if (selectLocation[0][0].innerHTML == '')
  83. selectLocation[0][0].innerHTML = "<spring:message code='appointment.Appointment.create.label.locationNotSpecified'/>";
  84.  
  85. }
  86.  
  87. //Toggle Checked Row
  88. $j('.dataTables_wrapper tbody tr').live(
  89. 'click',
  90. function() {
  91. var table = $j('#availableTimesTable')
  92. .dataTable();
  93. var nNodes = table.fnGetNodes();
  94. for ( var i = 0; i < nNodes.length; i++) {
  95. $j('input:radio', nNodes[i]).attr(
  96. 'checked', false);
  97. $j(nNodes[i])
  98. .removeClass('selectedRow');
  99. $j(nNodes[i])
  100. .addClass('notSelectedRow');
  101. }
  102. $j('input:radio', this).attr('checked',
  103. true);
  104. $j(this).addClass('selectedRow');
  105. $j(this).removeClass('notSelectedRow');
  106. });
  107. });
  108.  
  109. function updatePatient(formFieldId, patientObj, isPageLoad) {
  110. if (patientObj != null) {
  111. if(queryParameters['patientId']!=patientObj.patientId){
  112. queryParameters['patientId']=patientObj.patientId;
  113. location.search = $j.param(queryParameters);
  114. }
  115. addPatientLink(patientObj);
  116. DWRAppointmentService
  117. .getPatientDescription(
  118. patientObj.patientId,
  119. function(details) {
  120. if (!details) {
  121. document.getElementById('patientDataCell').innerHTML = "";
  122. return;
  123. }
  124. var phone = "<spring:message code='appointment.Appointment.create.patientNoPhoneNumber'/>";
  125. var dateMissedLastAppointment = "<spring:message code='appointment.Appointment.create.patientNotMissedLastAppointment'/>";
  126. if (details.phoneNumber)
  127. phone = details.phoneNumber;
  128. if (details.dateMissedLastAppointment)
  129. dateMissedLastAppointment = details.dateMissedLastAppointment;
  130. var detailsText = "<b><spring:message code='appointment.Appointment.create.patientPhoneNumber'/></b>"
  131. + phone
  132. + "<br/><b><spring:message code='appointment.Appointment.create.patientMissedMeeting'/></b>"
  133. + dateMissedLastAppointment
  134. + "<br/><br/>";
  135. for ( var i = 0; i < details.identifiers.length; i++) {
  136. var array = details.identifiers[i]
  137. .split(":");
  138. detailsText += "<b>" + array[0] + "</b>: "
  139. + array[1] + "<br/>";
  140. }
  141.  
  142. document.getElementById('patientDataCell').innerHTML = detailsText;
  143. });
  144. }
  145. }
  146. function addPatientLink(patientObj) {
  147. document.getElementById('patientLinkDiv').innerHTML = "";
  148. if (patientObj != null) {
  149. var genderImg = "<img src='${pageContext.request.contextPath}/images/male.gif' alt='<spring:message code='Person.gender.male'/>'/>";
  150. if (patientObj.gender != 'M')
  151. genderImg = "<img src='${pageContext.request.contextPath}/images/female.gif' alt='<spring:message code='Person.gender.female'/>'/>";
  152. var age = "";
  153. if (patientObj.age == 0)
  154. age += "1";
  155. else
  156. age += patientObj.age.toString();
  157. age += " <spring:message code='Person.age.year' />";
  158. var detailsText = "<table><tr><td>";
  159. detailsText += genderImg + " (" + age + ")<br/></td><td>";
  160. var message = "<img src='${pageContext.request.contextPath}/moduleResources/appointment/Images/view.png' class='formIcon' alt=''/><spring:message code='appointment.Appointment.create.link.viewPatient'/>";
  161. var link = "<a href='${pageContext.request.contextPath}/patientDashboard.form?patientId="
  162. + patientObj.patientId + "'>";
  163. detailsText += link + message + "</a><br/>";
  164. message = "<img src='${pageContext.request.contextPath}/moduleResources/appointment/Images/edit.png' class='formIcon' alt=''/><spring:message code='appointment.Appointment.create.link.editPatient'/>";
  165. link = "<a href='${pageContext.request.contextPath}/admin/patients/shortPatientForm.form?patientId="
  166. + patientObj.patientId + "'>";
  167. detailsText += link + message + "</a>";
  168. document.getElementById('patientLinkDiv').innerHTML += detailsText
  169. + "</td></tr></table>";
  170. }
  171. }
  172.  
  173. function updateToDate(object) {
  174. if (object.value == '') {
  175. var fromDate = document.getElementById('fromDate').value;
  176. if (fromDate != '')
  177. object.value = fromDate;
  178. }
  179. showDateTimePicker(object);
  180. }
  181. </script>
  182.  
  183. <h2 id="headline">
  184. <spring:message code="appointment.Appointment.create.title" />
  185. </h2>
  186. <spring:hasBindErrors name="appointment">
  187. <spring:message code="fix.error" />
  188. <br />
  189. </spring:hasBindErrors>
  190. <form:form modelAttribute="appointment" method="post">
  191. <fieldset>
  192. <table id="createAppointmentTable">
  193. <tr class="boxHeader steps">
  194. <td colspan="3"><spring:message
  195. code="appointment.Appointment.steps.selectPatient" /></td>
  196. </tr>
  197. <tr>
  198. <td class="formLabel"><spring:message
  199. code="appointment.Appointment.create.label.findPatient" /></td>
  200.  
  201. <td><spring:bind path="appointment.patient">
  202. <openmrs_tag:patientField formFieldName="patient"
  203. callback="updatePatient" initialValue="${status.value}"/>
  204. <c:if test="${status.errorMessage != ''}">
  205. <span class="error">${status.errorMessage}</span>
  206. </c:if>
  207. </spring:bind><div id="patientLinkDiv"></div></td>
  208. <td></td>
  209. </tr>
  210. <tr>
  211. <td></td>
  212. <td colspan="3" id="patientDataCell" style="font-style: italic;">
  213. </td>
  214. </tr>
  215. <tr class="boxHeader steps">
  216. <td colspan="3"><spring:message
  217. code="appointment.Appointment.steps.defineAppointmentProperties" /></td>
  218. </tr>
  219. <tr>
  220. <td class="formLabel"><spring:message
  221. code="appointment.Appointment.create.label.appointmentType" /></td>
  222. <td><spring:bind path="appointment.appointmentType">
  223. <select name="${status.expression}" id="appointmentTypeSelect">
  224. <c:forEach var="appointmentType" items="${appointmentTypeList}">
  225. <option value="${appointmentType.appointmentTypeId}"
  226. ${appointment.appointmentType.appointmentTypeId==appointmentType.appointmentTypeId ? 'selected' : ''}>${appointmentType.name}</option>
  227. </c:forEach>
  228. </select>
  229. <c:if test="${status.errorMessage != ''}">
  230. <span class="error">${status.errorMessage}</span>
  231. </c:if>
  232. </spring:bind></td>
  233. </tr>
  234. <tr>
  235. <td class="formLabel"><spring:message
  236. code="appointment.Appointment.create.label.location" /></td>
  237. <td><openmrs_tag:locationField formFieldName="locationId"
  238. initialValue="${selectedLocation}" optionHeader="[blank]" /></td>
  239. </tr>
  240. <tr>
  241. <td class="formLabel"><spring:message
  242. code="appointment.Appointment.create.label.clinician" /></td>
  243. <td><select name="providerSelect" id="providerSelect">
  244. <option value="" ${null==param.providerSelect ? 'selected' : ''}>
  245. <spring:message
  246. code="appointment.Appointment.create.label.clinicianNotSpecified" />
  247. </option>
  248. <c:forEach var="provider" items="${providerList}">
  249. <option value="${provider.providerId}"
  250. ${provider.providerId==param.providerSelect ? 'selected' : ''}>${provider.name}</option>
  251. </c:forEach>
  252. </select></td>
  253. </tr>
  254. <tr>
  255. <td class="formLabel"><spring:message
  256. code="appointment.Appointment.create.label.betweenDates" /></td>
  257. <td><input type="text" name="fromDate" id="fromDate" size="16"
  258. value="${param.fromDate}" onfocus="showDateTimePicker(this)" /> <img
  259. src="${pageContext.request.contextPath}/moduleResources/appointment/Images/calendarIcon.png"
  260. class="calendarIcon" alt=""
  261. onClick="document.getElementById('fromDate').focus();" /> and <input
  262. type="text" name="toDate" id="toDate" size="16"
  263. value="${param.toDate}" onfocus="updateToDate(this)" /> <img
  264. src="${pageContext.request.contextPath}/moduleResources/appointment/Images/calendarIcon.png"
  265. class="calendarIcon" alt=""
  266. onClick="document.getElementById('toDate').focus();" /></td>
  267. </tr>
  268. <tr class="boxHeader steps">
  269. <td colspan="3"><spring:message
  270. code="appointment.Appointment.steps.selectTime" /></td>
  271. </tr>
  272. <tr>
  273. <td />
  274. <td><input type="submit" name="findAvailableTime"
  275. class="appointmentButton"
  276. value="<spring:message code="appointment.Appointment.create.findTime"/>"></td>
  277. <td><spring:bind path="appointment.timeSlot">
  278. <c:if test="${status.errorMessage != ''}">
  279. <span class="error">${status.errorMessage}</span>
  280. </c:if>
  281. </spring:bind></td>
  282. </tr>
  283. <tr>
  284. <td colspan="3">
  285. <table id="availableTimesTable" cellspacing="0">
  286. <thead>
  287. <tr>
  288. <th><spring:message
  289. code="appointment.Appointment.create.header.selectedOption" /></th>
  290. <th><spring:message
  291. code="appointment.Appointment.create.header.clinician" /></th>
  292. <th><spring:message
  293. code="appointment.Appointment.create.header.appointmentType" /></th>
  294. <th><spring:message
  295. code="appointment.Appointment.create.header.date" /></th>
  296. <th><spring:message
  297. code="appointment.Appointment.create.header.timeSlot" /></th>
  298. <th><spring:message
  299. code="appointment.Appointment.create.header.location" /></th>
  300. </tr>
  301. </thead>
  302. <tbody>
  303. <c:forEach var="slot" items="${availableTimes}">
  304. <tr
  305. ${slot.timeSlotId==appointment.timeSlot.timeSlotId ? 'class="selectedRow"' : 'class="notSelectedRow"'} />
  306. <td><spring:bind path="appointment.timeSlot">
  307. <input type="radio" name="${status.expression}"
  308. value="${slot.timeSlotId}"
  309. ${slot.timeSlotId==appointment.timeSlot.timeSlotId ? 'checked' : ''} />
  310. </spring:bind></td>
  311.  
  312. <td>${slot.appointmentBlock.provider.name}</td>
  313. <td><c:forEach var="appointmentType"
  314. items="${slot.appointmentBlock.types}" varStatus="status">
  315. ${appointmentType.name}<c:if
  316. test="${status.index != fn:length(slot.appointmentBlock.types)-1}">, </c:if>
  317. </c:forEach></td>
  318. <td><fmt:formatDate type="date" value="${slot.startDate}" /></td>
  319. <td><fmt:formatDate type="time" pattern="HH:mm"
  320. value="${slot.startDate}" /> - <fmt:formatDate type="time"
  321. pattern="HH:mm" value="${slot.endDate}" /></td>
  322. <td>${slot.appointmentBlock.location.name}</td>
  323. <td><fmt:formatDate type="date" value="${slot.startDate}"
  324. pattern="yyyyMMddHHmm" /></td>
  325. </tr>
  326. </c:forEach>
  327. </tbody>
  328. </table>
  329. </td>
  330. </tr>
  331. <tr class="boxHeader steps">
  332. <td colspan="3"><spring:message
  333. code="appointment.Appointment.steps.enterNotes" /></td>
  334. </tr>
  335. <tr>
  336. <td class="formLabel"><spring:message
  337. code="appointment.Appointment.create.label.reason" /></td>
  338. <spring:bind path="appointment.reason">
  339. <td><textarea name="reason" rows="3" cols="50"
  340. style="resize: none"
  341. onkeypress="return forceMaxLength(this, 1024);">${status.value}</textarea></td>
  342. </spring:bind>
  343. <input type="hidden" name="maxlength" value="1024" />
  344. </tr>
  345. <tr><td></td><td style="font-size:12px;">
  346. (<spring:message code="appointment.Appointment.create.label.charactersLeft" /><span class="charsLeft">1024</span>)
  347. </td></tr>
  348. <tr>
  349. <td></td>
  350. <td><input type="submit" class="saveButton"
  351. value="<spring:message code="appointment.Appointment.create.save"/>"
  352. name="save"></td>
  353. </tr>
  354. </table>
  355. </fieldset>
  356. </form:form>
  357. <%@ include file="/WEB-INF/template/footer.jsp"%>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement