Advertisement
ssmusoke

Patient Summary Fragment Controller

Jan 26th, 2016
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.38 KB | None | 0 0
  1. package org.openmrs.module.aijar.fragment.controller;
  2.  
  3. import org.apache.commons.logging.Log;
  4. import org.apache.commons.logging.LogFactory;
  5. import org.openmrs.Obs;
  6. import org.openmrs.Patient;
  7. import org.openmrs.Person;
  8. import org.openmrs.api.ConceptService;
  9. import org.openmrs.api.ObsService;
  10. import org.openmrs.api.PersonService;
  11. import org.openmrs.ui.framework.annotation.SpringBean;
  12. import org.openmrs.ui.framework.fragment.FragmentConfiguration;
  13. import org.openmrs.ui.framework.fragment.FragmentModel;
  14. import org.springframework.web.bind.annotation.RequestParam;
  15.  
  16. import java.util.List;
  17.  
  18. /**
  19. * Created by ssmusoke on 26/01/2016.
  20. */
  21. public class PatientSummaryFragmentController {
  22.  
  23. private static final Log log = LogFactory.getLog(PatientSummaryFragmentController.class);
  24.  
  25. public void controller(FragmentConfiguration config,
  26. FragmentModel model,
  27. @SpringBean("obsService") ObsService obsService,
  28. @SpringBean("conceptService") ConceptService conceptService,
  29. @SpringBean("personService") PersonService personService,
  30. @RequestParam("patientId") Patient patient) {
  31. Person person = personService.getPerson(patient.getPersonId());
  32. model.addAttribute("personid", patient.getPersonId());
  33. log.info("The person id is " + patient.getPersonId() + " and the patient id is " + patient.getPatientId() + " and the uuid is " + patient.getUuid());
  34. List<Obs> cd4Counts = obsService.getLastNObservations(1, person, conceptService.getConcept("5497"), false);
  35. log.info("There are " + cd4Counts.size() + " Cd4 counts");
  36. if (cd4Counts.size() > 0) {
  37. model.addAttribute("lastcd4", cd4Counts.get(0).getValueAsString());
  38. } else {
  39. model.addAttribute("lastcd4", "None Available");
  40. }
  41.  
  42. List<Obs> currentRegimens = obsService.getLastNObservations(1, person, conceptService.getConcept("90315"), false);
  43. log.info("There are " + currentRegimens.size() + " regimens");
  44. if (currentRegimens.size() > 0) {
  45. model.addAttribute("currentregimen", currentRegimens.get(0).getValueAsString());
  46. } else {
  47. model.addAttribute("currentregimen", "None Available");
  48. }
  49. model.addAttribute("testattr", "This should display");
  50. }
  51.  
  52.  
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement