Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package org.openmrs.module.aijar.fragment.controller;
- import org.apache.commons.logging.Log;
- import org.apache.commons.logging.LogFactory;
- import org.openmrs.Obs;
- import org.openmrs.Patient;
- import org.openmrs.Person;
- import org.openmrs.api.ConceptService;
- import org.openmrs.api.ObsService;
- import org.openmrs.api.PersonService;
- import org.openmrs.ui.framework.annotation.SpringBean;
- import org.openmrs.ui.framework.fragment.FragmentConfiguration;
- import org.openmrs.ui.framework.fragment.FragmentModel;
- import org.springframework.web.bind.annotation.RequestParam;
- import java.util.List;
- /**
- * Created by ssmusoke on 26/01/2016.
- */
- public class PatientSummaryFragmentController {
- private static final Log log = LogFactory.getLog(PatientSummaryFragmentController.class);
- public void controller(FragmentConfiguration config,
- FragmentModel model,
- @SpringBean("obsService") ObsService obsService,
- @SpringBean("conceptService") ConceptService conceptService,
- @SpringBean("personService") PersonService personService,
- @RequestParam("patientId") Patient patient) {
- Person person = personService.getPerson(patient.getPersonId());
- model.addAttribute("personid", patient.getPersonId());
- log.info("The person id is " + patient.getPersonId() + " and the patient id is " + patient.getPatientId() + " and the uuid is " + patient.getUuid());
- List<Obs> cd4Counts = obsService.getLastNObservations(1, person, conceptService.getConcept("5497"), false);
- log.info("There are " + cd4Counts.size() + " Cd4 counts");
- if (cd4Counts.size() > 0) {
- model.addAttribute("lastcd4", cd4Counts.get(0).getValueAsString());
- } else {
- model.addAttribute("lastcd4", "None Available");
- }
- List<Obs> currentRegimens = obsService.getLastNObservations(1, person, conceptService.getConcept("90315"), false);
- log.info("There are " + currentRegimens.size() + " regimens");
- if (currentRegimens.size() > 0) {
- model.addAttribute("currentregimen", currentRegimens.get(0).getValueAsString());
- } else {
- model.addAttribute("currentregimen", "None Available");
- }
- model.addAttribute("testattr", "This should display");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement