use of org.openmrs.ui.framework.SimpleObject in project openmrs-module-pihcore by PIH.
the class VitalsListPageController method get.
public String get(PageModel model, UiUtils ui, @SpringBean("encounterService") EncounterService encounterService, @SpringBean("personService") PersonService personService) {
// TODO restrict by location at some point if necessary
Map<Patient, Encounter> patientsWithCheckInEncounter = new LinkedHashMap<Patient, Encounter>();
// all patients that have a check-in encounter today, but no vitals encounter
List<Encounter> checkInEncounters = encounterService.getEncounters(null, null, new DateMidnight().toDate(), null, null, Collections.singletonList(encounterService.getEncounterTypeByUuid(EncounterTypes.CHECK_IN.uuid())), null, null, null, false);
List<Encounter> vitalsEncounters = encounterService.getEncounters(null, null, new DateMidnight().toDate(), null, null, Collections.singletonList(encounterService.getEncounterTypeByUuid(EncounterTypes.VITALS.uuid())), null, null, null, false);
for (Encounter encounter : checkInEncounters) {
// sanity check on visit
if (encounter.getVisit() != null) {
// we check that the patient isn't already in the list instead of just inserting again because we want to keep the earliest date
if (!patientsWithCheckInEncounter.containsKey(encounter.getPatient())) {
patientsWithCheckInEncounter.put(encounter.getPatient(), encounter);
}
}
}
for (Encounter encounter : vitalsEncounters) {
if (patientsWithCheckInEncounter.containsKey(encounter.getPatient())) {
patientsWithCheckInEncounter.remove(encounter.getPatient());
}
}
SimpleObject vitalsListBreadcrumb = SimpleObject.create("label", ui.message("pihcore.vitalsList.title"), "link", ui.pageLink("pihcore", "vitals/vitalsList"));
// used to determine whether or not we display a link to the patient in the results list
model.addAttribute("patientWithCheckInEncounter", patientsWithCheckInEncounter);
model.addAttribute("mothersFirstName", personService.getPersonAttributeTypeByUuid(HaitiPersonAttributeTypes.MOTHERS_FIRST_NAME.uuid()));
model.addAttribute("dossierIdentifierName", PihHaitiPatientIdentifierTypes.DOSSIER_NUMBER.name());
model.addAttribute("breadcrumbOverride", ui.toJson(Arrays.asList(vitalsListBreadcrumb)));
return null;
}
use of org.openmrs.ui.framework.SimpleObject in project openmrs-module-pihcore by PIH.
the class MonthSinceMirebalaisOpeningFragmentController method controller.
public void controller(FragmentModel model) {
List<SimpleObject> months = new ArrayList<SimpleObject>();
YearMonth earliest = new YearMonth(2013, 2);
YearMonth month = new YearMonth().minusMonths(1);
while (month.isAfter(earliest)) {
months.add(SimpleObject.create("label", month.toString("MMM yyyy", Context.getLocale()), "value", month.toString("yyyy-MM-01")));
month = month.minusMonths(1);
}
model.addAttribute("months", months);
}
use of org.openmrs.ui.framework.SimpleObject in project openmrs-module-pihcore by PIH.
the class RegistrationsByAgeReportFragmentController method evaluate.
public SimpleObject evaluate(@SpringBean DataSetDefinitionService dataSetDefinitionService, @SpringBean RegistrationDataSetManager registrationDataSetManager, @RequestParam(value = "startDate", required = false) Date startDate, @RequestParam(value = "endDate", required = false) Date endDate, PageModel model, UiUtils ui) throws Exception {
Map<String, AgeResult> registrationsByAge = new LinkedHashMap<String, AgeResult>();
EvaluationContext context = new EvaluationContext();
context.addParameterValue(ReportingConstants.START_DATE_PARAMETER.getName(), startDate);
context.addParameterValue(ReportingConstants.END_DATE_PARAMETER.getName(), endDate);
DataSetDefinition dsd = registrationDataSetManager.constructDataSet();
SimpleDataSet dataSet = (SimpleDataSet) dataSetDefinitionService.evaluate(dsd, context);
List<String> columns = new ArrayList<String>();
columns.add("EMR_ID");
columns.add("GIVEN_NAME");
columns.add("FAMILY_NAME");
columns.add("AGE_AT_REGISTRATION");
columns.add("BIRTHDATE");
columns.add("GENDER");
columns.add("REGISTRATION_DATE");
List<String> ageCategories = new ArrayList<String>();
ageCategories.add(getAgeCategory(0.0));
for (Integer bound : ageBoundaries) {
ageCategories.add(getAgeCategory(bound.doubleValue()));
}
String totalCategory = ui.message("pihcore.total");
ageCategories.add(totalCategory);
for (DataSetRow row : dataSet) {
Double patientAge = (Double) row.getColumnValue("AGE_AT_REGISTRATION");
String ageCategory = getAgeCategory(patientAge);
Map<String, Object> m = new HashMap<String, Object>();
for (String column : columns) {
m.put(column, ui.format(row.getColumnValue(column)));
}
getAgeResult(registrationsByAge, ageCategory).addRow(m);
getAgeResult(registrationsByAge, totalCategory).addRow(m);
}
List<String> columnLabels = new ArrayList<String>();
for (String column : columns) {
columnLabels.add(ui.message("pihcore." + column.toLowerCase()));
}
SimpleObject result = new SimpleObject();
result.put("startDate", startDate);
result.put("endDate", endDate);
result.put("ageCategories", ageCategories);
result.put("columns", columns);
result.put("columnLabels", columnLabels);
result.put("registrationsByAge", registrationsByAge);
return result;
}
use of org.openmrs.ui.framework.SimpleObject in project openmrs-module-pihcore by PIH.
the class CheckinPageController method controller.
public Object controller(@RequestParam("patientId") Patient patient, @RequestParam(value = "closeVisit", required = false) Boolean closeVisit, UiUtils ui, UiSessionContext uiSessionContext, PageModel model, EmrApiProperties emrApiProperties, @SpringBean AdtService adtService, @InjectBeans PatientDomainWrapper patientDomainWrapper) {
patientDomainWrapper.setPatient(patient);
VisitDomainWrapper activeVisit = patientDomainWrapper.getActiveVisit(uiSessionContext.getSessionLocation());
if (closeVisit != null && closeVisit && activeVisit != null) {
adtService.closeAndSaveVisit(activeVisit.getVisit());
activeVisit = null;
}
// if there is no active visit, redirect directly to the form
if (activeVisit == null) {
return new Redirect("/registrationapp/registrationSummary.page?patientId=" + patient.getId() + "&appId=registrationapp.registerPatient" + "&breadcrumbOverrideProvider=coreapps&breadcrumbOverridePage=findpatient%2FfindPatient&breadcrumbOverrideApp=mirebalais.liveCheckin&breadcrumbOverrideLabel=mirebalais.app.patientRegistration.checkin.label");
} else // prompt the user to see if they want close the existing visit
{
List<Encounter> existingEncounters = new ArrayList<Encounter>();
if (activeVisit != null) {
for (Encounter encounter : activeVisit.getVisit().getEncounters()) {
if (!encounter.isVoided() && emrApiProperties.getCheckInEncounterType().equals(encounter.getEncounterType())) {
existingEncounters.add(encounter);
}
}
}
SimpleObject appHomepageBreadcrumb = SimpleObject.create("label", ui.escapeJs(ui.message("mirebalais.checkin.title")));
SimpleObject patientPageBreadcrumb = SimpleObject.create("label", ui.escapeJs(patient.getFamilyName()) + ", " + ui.escapeJs(patient.getGivenName()), "link", ui.thisUrlWithContextPath());
model.addAttribute("breadcrumbOverride", ui.toJson(Arrays.asList(appHomepageBreadcrumb, patientPageBreadcrumb)));
model.addAttribute("activeVisit", activeVisit);
model.addAttribute("existingEncounters", existingEncounters);
model.addAttribute("patient", patientDomainWrapper);
model.addAttribute("appName", "mirebalais.liveCheckin");
return null;
}
}
use of org.openmrs.ui.framework.SimpleObject in project openmrs-module-pihcore by PIH.
the class CheckInsByAgeReportFragmentController method evaluate.
public SimpleObject evaluate(@SpringBean DataSetDefinitionService dataSetDefinitionService, @SpringBean CheckInDataSetManager checkInDataSetManager, @RequestParam(value = "startDate", required = false) Date startDate, @RequestParam(value = "endDate", required = false) Date endDate, PageModel model, UiUtils ui) throws Exception {
Map<String, AgeResult> checkInsByAge = new LinkedHashMap<String, AgeResult>();
EvaluationContext context = new EvaluationContext();
context.addParameterValue(ReportingConstants.START_DATE_PARAMETER.getName(), startDate);
context.addParameterValue(ReportingConstants.END_DATE_PARAMETER.getName(), endDate);
DataSetDefinition dsd = checkInDataSetManager.constructDataSet();
SimpleDataSet dataSet = (SimpleDataSet) dataSetDefinitionService.evaluate(dsd, context);
List<String> columns = new ArrayList<String>();
columns.add("CHECK_IN_DATE");
columns.add("EMR_ID");
columns.add("GIVEN_NAME");
columns.add("FAMILY_NAME");
columns.add("AGE_AT_CHECK_IN");
columns.add("BIRTHDATE");
columns.add("GENDER");
columns.add("TYPE_OF_VISIT");
List<String> ageCategories = new ArrayList<String>();
ageCategories.add(getAgeCategory(0.0));
for (Integer bound : ageBoundaries) {
ageCategories.add(getAgeCategory(bound.doubleValue()));
}
String totalCategory = ui.message("pihcore.total");
ageCategories.add(totalCategory);
for (DataSetRow row : dataSet) {
Double patientAge = (Double) row.getColumnValue("AGE_AT_CHECK_IN");
String ageCategory = getAgeCategory(patientAge);
Map<String, Object> m = new HashMap<String, Object>();
for (String column : columns) {
m.put(column, ui.format(row.getColumnValue(column)));
}
getAgeResult(checkInsByAge, ageCategory).addRow(m);
getAgeResult(checkInsByAge, totalCategory).addRow(m);
}
List<String> columnLabels = new ArrayList<String>();
for (String column : columns) {
columnLabels.add(ui.message("pihcore." + column.toLowerCase()));
}
SimpleObject result = new SimpleObject();
result.put("startDate", startDate);
result.put("endDate", endDate);
result.put("ageCategories", ageCategories);
result.put("columns", columns);
result.put("columnLabels", columnLabels);
result.put("checkInsByAge", checkInsByAge);
return result;
}
Aggregations