Advertisement
yony258

Untitled

Dec 6th, 2012
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. In JSP File:
  2.  
  3. <script src="<openmrs:contextPath/>/dwr/interface/DWRAppointmentService.js"></script>
  4. <script type="text/javascript">
  5. function updatePatient(formFieldId, patientObj, isPageLoad) {
  6. if(!isPageLoad){
  7. DWRAppointmentService.getPatientDescription(patientObj.patientId, function(details){
  8. if(details==null){
  9. document.getElementById('labelPhone').value = "";
  10. document.getElementById('labelMissed').value = "";
  11. }
  12. else{
  13. if(details[0]!=null)
  14. document.getElementById('labelPhone').value = details[0];
  15. if(details[1]!=null)
  16. document.getElementById('labelMissed').value = details[1];
  17. }
  18. });
  19. }
  20. }
  21. </script>
  22.  
  23. In DWRAppointmentService Class
  24.  
  25. public class DWRAppointmentService {
  26.  
  27. public PatientDescription getPatientDescription(Integer patientId) {
  28. Patient patient = Context.getPatientService().getPatient(patientId);
  29. if (patient == null)
  30. return null;
  31.  
  32. PatientDescription patientDescription = new PatientDescription("test","test");
  33. /*patientDescription
  34. .setPhoneNumber(patient.getAttribute(
  35. Context.getAdministrationService().getGlobalProperty("appointment.phoneNumberPersonAttributeTypeId"))
  36. .getValue());
  37. Date missedLastAppointment = Context.getService(AppointmentService.class).getMissedLastAppointment(patient);
  38. if (missedLastAppointment != null)
  39. patientDescription.setDateMissed(Context.getDateFormat().format(missedLastAppointment));
  40. */
  41. return patientDescription;
  42. }
  43. }
  44.  
  45. In config.xml
  46.  
  47. <dwr>
  48. <allow>
  49. <create creator="yony258" javascript="DWRAppointmentService">
  50. <param name="class" value="@MODULE_PACKAGE@.web.DWRAppointmentService" />
  51. <include method="getPatientDescription" />
  52. </create>
  53. </allow>
  54.  
  55. <signatures>
  56. <![CDATA[
  57. import @MODULE_PACKAGE@.web.DWRAppointmentService;
  58. DWRAppointmentService.getPatientDescription(Integer patientId);
  59. ]]>
  60. </signatures>
  61. </dwr>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement