Advertisement
yony258

Untitled

Dec 5th, 2012
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.35 KB | None | 0 0
  1. /**
  2. * The contents of this file are subject to the OpenMRS Public License
  3. * Version 1.0 (the "License"); you may not use this file except in
  4. * compliance with the License. You may obtain a copy of the License at
  5. * http://license.openmrs.org
  6. *
  7. * Software distributed under the License is distributed on an "AS IS"
  8. * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
  9. * License for the specific language governing rights and limitations
  10. * under the License.
  11. *
  12. * Copyright (C) OpenMRS, LLC. All Rights Reserved.
  13. */
  14. package org.openmrs.module.appointment.web.controller;
  15.  
  16. import java.util.HashSet;
  17. import java.util.LinkedList;
  18. import java.util.List;
  19. import java.util.Set;
  20.  
  21. import org.apache.commons.logging.Log;
  22. import org.apache.commons.logging.LogFactory;
  23. import org.openmrs.Provider;
  24. import org.openmrs.api.context.Context;
  25. import org.openmrs.module.appointment.Appointment;
  26. import org.openmrs.module.appointment.AppointmentType;
  27. import org.openmrs.module.appointment.api.AppointmentService;
  28. import org.springframework.stereotype.Controller;
  29. import org.springframework.ui.ModelMap;
  30. import org.springframework.web.bind.annotation.ModelAttribute;
  31. import org.springframework.web.bind.annotation.RequestMapping;
  32. import org.springframework.web.bind.annotation.RequestMethod;
  33. import org.springframework.web.bind.annotation.RequestParam;
  34.  
  35. /**
  36. * Controller for creating appointments.
  37. */
  38. @Controller
  39. public class CreateAppointmentFormController {
  40.  
  41. /** Logger for this class and subclasses */
  42. protected final Log log = LogFactory.getLog(getClass());
  43.  
  44. @RequestMapping(value = "/module/appointment/createAppointmentForm", method = RequestMethod.GET)
  45. public void showForm(ModelMap model) {
  46. //default empty Object
  47. Set<AppointmentType> appointmentTypeList = new HashSet<AppointmentType>();
  48. List<Provider> providerList = new LinkedList<Provider>();
  49.  
  50. //only fill the Object is the user has authenticated properly
  51. if (Context.isAuthenticated()) {
  52. AppointmentService appointmentService = Context.getService(AppointmentService.class);
  53. appointmentTypeList = appointmentService.getAllAppointmentTypes();
  54. providerList = Context.getProviderService().getAllProviders();
  55. }
  56.  
  57. model.addAttribute("appointmentTypeList", appointmentTypeList);
  58. model.addAttribute("providerList", providerList);
  59. }
  60.  
  61.  
  62.  
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement