Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: openmrs/openmrs-core
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 7897f5eb317d
Choose a base ref
...
head repository: openmrs/openmrs-core
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 3283fb7c2278
Choose a head ref
  • 2 commits
  • 15 files changed
  • 2 contributors

Commits on Mar 28, 2014

  1. TRUNK 4281: translate hard coded messages for cohorts

    citigodev1 committed Mar 28, 2014
    Copy the full SHA
    e957106 View commit details
  2. Merge pull request #828 from ehsdev/master

    TRUNK 4281: translate hard coded messages for cohorts
    dkayiwa committed Mar 28, 2014
    Copy the full SHA
    3283fb7 View commit details
50 changes: 30 additions & 20 deletions api/src/main/java/org/openmrs/reporting/DrugOrderFilter.java
Original file line number Diff line number Diff line change
@@ -20,8 +20,8 @@
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Set;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.openmrs.Cohort;
@@ -30,6 +30,7 @@
import org.openmrs.api.PatientSetService;
import org.openmrs.api.PatientSetService.GroupMethod;
import org.openmrs.api.context.Context;
import org.openmrs.messagesource.MessageSourceService;
import org.openmrs.report.EvaluationContext;
import org.openmrs.util.OpenmrsUtil;

@@ -86,31 +87,36 @@ public String getCacheKey() {
}

public String getDescription() {
MessageSourceService mss = Context.getMessageSourceService();
Locale locale = Context.getLocale();
DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, Context.getLocale());
StringBuffer ret = new StringBuffer();
StringBuilder ret = new StringBuilder();
boolean currentlyCase = getWithinLastDays() != null && getWithinLastDays() == 0
&& (getWithinLastMonths() == null || getWithinLastMonths() == 0);
if (currentlyCase) {
ret.append("Patients currently ");
ret.append(mss.getMessage("reporting.patientCurrently")).append(" ");
} else {
ret.append("Patients ");
ret.append(mss.getMessage("reporting.patients")).append(" ");
}
if (getDrugListToUse() == null || getDrugListToUse().size() == 0) {
if (getDrugListToUse() == null || getDrugListToUse().isEmpty()) {
if (getAnyOrAll() == GroupMethod.NONE) {
ret.append(currentlyCase ? "taking no drugs" : "who never took any drugs");
ret.append(currentlyCase ? mss.getMessage("reporting.takingNoDrugs") : mss
.getMessage("reporting.whoNeverTakeDrug"));
} else {
ret.append(currentlyCase ? "taking any drugs" : "ever taking any drugs");
ret.append(currentlyCase ? mss.getMessage("reporting.takingAnyDrugs") : mss
.getMessage("reporting.everTakingAnyDrugs"));
}
} else {
if (getDrugListToUse().size() == 1) {
if (getAnyOrAll() == GroupMethod.NONE) {
ret.append("not taking ");
ret.append(mss.getMessage("reporting.notTaking")).append(" ");
} else {
ret.append("taking ");
ret.append(mss.getMessage("reporting.taking").toLowerCase()).append(" ");
}
ret.append(getDrugListToUse().get(0).getName());
} else {
ret.append("taking " + getAnyOrAll() + " of [");
ret.append(mss.getMessage("reporting.taking").toLowerCase()).append(" ").append(getAnyOrAll()).append(
mss.getMessage("reporting.of")).append(" [");
for (Iterator<Drug> i = getDrugListToUse().iterator(); i.hasNext();) {
ret.append(i.next().getName());
if (i.hasNext()) {
@@ -120,22 +126,26 @@ public String getDescription() {
ret.append("]");
}
}
Integer within_last_days = getWithinLastDays();
Integer within_last_months = getWithinLastMonths();

if (!currentlyCase) {
if (getWithinLastDays() != null || getWithinLastMonths() != null) {
ret.append(" withing the last");
if (getWithinLastMonths() != null) {
ret.append(" " + getWithinLastMonths() + " months");
}
if (getWithinLastDays() != null) {
ret.append(" " + getWithinLastDays() + " days");
}
if (within_last_days != null || within_last_months != null) {
if (within_last_months != null)
ret.append(" ").append(
mss.getMessage("reporting.WithinTheLastMonths", new Object[] { within_last_months }, locale));

if (within_last_days != null)
ret.append(" ").append(
mss.getMessage("reporting.WithinTheLastDays", new Object[] { within_last_days }, locale));

}
}
if (getSinceDate() != null) {
ret.append(" since " + df.format(getSinceDate()));
ret.append(" ").append(mss.getMessage("reporting.since", new Object[] { df.format(getSinceDate()) }, locale));
}
if (getUntilDate() != null) {
ret.append(" until " + df.format(getUntilDate()));
ret.append(" ").append(mss.getMessage("reporting.until", new Object[] { df.format(getUntilDate()) }, locale));
}
return ret.toString();
}
Original file line number Diff line number Diff line change
@@ -16,10 +16,10 @@
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.openmrs.Cohort;
@@ -28,6 +28,7 @@
import org.openmrs.api.PatientSetService;
import org.openmrs.api.PatientSetService.GroupMethod;
import org.openmrs.api.context.Context;
import org.openmrs.messagesource.MessageSourceService;
import org.openmrs.report.EvaluationContext;
import org.openmrs.util.OpenmrsUtil;

@@ -126,30 +127,32 @@ public Cohort filter(Cohort input, EvaluationContext context) {

public String getDescription() {
// TODO: internationalize this
MessageSourceService mss = Context.getMessageSourceService();
Locale locale = Context.getLocale();
StringBuilder sb = new StringBuilder();
if (groupMethod != null && groupMethod == GroupMethod.NONE) {
sb.append("No drug orders");
sb.append(mss.getMessage("reporting.noDrugOrders"));
} else if (drugId != null || drugConcept != null) {
sb.append("Taking ");
sb.append(mss.getMessage("reporting.taking")).append(" ");
SortedSet<String> names = new TreeSet<String>();
if (drugId != null) {
Drug drug = Context.getConceptService().getDrug(drugId);
if (drug == null) {
log.error("Can't find drug with id " + drugId);
names.add("MISSING DRUG " + drugId);
names.add(mss.getMessage("reporting.missingDrug") + " " + drugId);
} else {
names.add(drug.getName());
}
}
if (drugConcept != null) {
names.add(drugConcept.getName(Context.getLocale(), false).getName());
}
sb.append(OpenmrsUtil.join(names, " or "));
sb.append(OpenmrsUtil.join(names, " " + mss.getMessage("reporting.or") + " "));
} else {
sb.append("Any Drug Order");
sb.append(mss.getMessage("reporting.anyDrugOrder"));
}
if (getOnDate() != null) {
sb.append(" on " + getOnDate());
sb.append(" ").append(mss.getMessage("reporting.on", new Object[] { getOnDate() }, locale));
}
return sb.toString();
}
39 changes: 22 additions & 17 deletions api/src/main/java/org/openmrs/reporting/DrugOrderStopFilter.java
Original file line number Diff line number Diff line change
@@ -16,12 +16,13 @@
import java.util.Date;
import java.util.Iterator;
import java.util.List;

import java.util.Locale;
import org.openmrs.Cohort;
import org.openmrs.Concept;
import org.openmrs.ConceptName;
import org.openmrs.Drug;
import org.openmrs.api.context.Context;
import org.openmrs.messagesource.MessageSourceService;
import org.openmrs.report.EvaluationContext;
import org.openmrs.util.OpenmrsUtil;

@@ -89,17 +90,19 @@ public String getCacheKey() {
}

public String getDescription() {
MessageSourceService msa = Context.getMessageSourceService();
Locale locale = Context.getLocale();
StringBuilder sb = new StringBuilder();
sb.append("Patients who stopped or changed ");
sb.append(msa.getMessage("reporting.patientsWhoStopOrChanged")).append(" ");
if ((getDrugList() != null && getDrugList().size() > 0)
|| (getGenericDrugList() != null && getGenericDrugList().size() > 0)) {
if (getDrugList() != null && getDrugList().size() > 0) {
if (getDrugList().size() == 1) {
sb.append(getDrugList().get(0).getName());
} else {
sb.append("any of [");
sb.append(msa.getMessage("reporting.anyOf")).append(" [");
for (Iterator<Drug> i = getDrugList().iterator(); i.hasNext();) {
sb.append(" " + i.next().getName() + " ");
sb.append(" ").append(i.next().getName()).append(" ");
if (i.hasNext()) {
sb.append(",");
}
@@ -109,11 +112,12 @@ public String getDescription() {
}
if (getGenericDrugList() != null && getGenericDrugList().size() > 0) {
if (getGenericDrugList().size() == 1) {
sb.append("any form of " + getGenericDrugList().get(0).getName().getName());
sb.append(msa.getMessage("reporting.anyFormOf")).append(" ").append(
getGenericDrugList().get(0).getName().getName());
} else {
sb.append("any form of [");
sb.append(msa.getMessage("reporting.anyFormOf")).append(" [");
for (Iterator<Concept> i = getGenericDrugList().iterator(); i.hasNext();) {
sb.append(" " + i.next().getName().getName() + " ");
sb.append(" ").append(i.next().getName().getName()).append(" ");
if (i.hasNext()) {
sb.append(",");
}
@@ -122,20 +126,20 @@ public String getDescription() {
}
}
} else {
sb.append("any drug");
sb.append(msa.getMessage("reporting.anyDrug"));
}
if (getDiscontinuedReasonList() != null && getDiscontinuedReasonList().size() > 0) {
if (getDiscontinuedReasonList().size() == 1) {
String reason = "[name not defined]";
String reason = "[" + msa.getMessage("reporting.nameNotDefined") + "]";
ConceptName cn = getDiscontinuedReasonList().get(0).getName();
if (cn != null) {
reason = cn.getName();
}
sb.append(" because of " + reason);
sb.append(" ").append(msa.getMessage("reporting.becauseOf", new Object[] { reason }, locale));
} else {
sb.append(" because of any of [");
sb.append(" ").append(msa.getMessage("reporting.becauseOfAnyOf")).append(" [");
for (Iterator<Concept> i = getDiscontinuedReasonList().iterator(); i.hasNext();) {
sb.append(" " + i.next().getName().getName() + " ");
sb.append(" ").append(i.next().getName().getName()).append(" ");
if (i.hasNext()) {
sb.append(",");
}
@@ -144,20 +148,21 @@ public String getDescription() {
}
}
if (withinLastMonths != null || withinLastDays != null) {
sb.append(" within the last ");
if (withinLastMonths != null) {
sb.append(withinLastMonths + " month(s) ");
sb.append(" ").append(
msa.getMessage("reporting.withinTheLastMonths", new Object[] { withinLastMonths }, locale));
}
if (withinLastDays != null) {
sb.append(withinLastDays + " day(s) ");
sb.append(" ")
.append(msa.getMessage("reporting.withinTheLastDays", new Object[] { withinLastDays }, locale));
}
}
// TODO untilDaysAgo untilMonthsAgo
if (sinceDate != null) {
sb.append(" on or after " + sinceDate + " ");
sb.append(" ").append(msa.getMessage("reporting.onOrAfter", new Object[] { sinceDate }, locale));
}
if (untilDate != null) {
sb.append(" on or before " + untilDate + " ");
sb.append(" ").append(msa.getMessage("reporting.onOrBefore", new Object[] { untilDate }, locale));
}
return sb.toString();
}
34 changes: 19 additions & 15 deletions api/src/main/java/org/openmrs/reporting/EncounterPatientFilter.java
Original file line number Diff line number Diff line change
@@ -17,13 +17,14 @@
import java.util.Date;
import java.util.Iterator;
import java.util.List;

import java.util.Locale;
import org.openmrs.Cohort;
import org.openmrs.EncounterType;
import org.openmrs.Form;
import org.openmrs.Location;
import org.openmrs.api.PatientSetService;
import org.openmrs.api.context.Context;
import org.openmrs.messagesource.MessageSourceService;
import org.openmrs.report.EvaluationContext;
import org.openmrs.util.OpenmrsUtil;

@@ -85,50 +86,53 @@ public String getCacheKey() {
}

public String getDescription() {
StringBuffer ret = new StringBuffer();
ret.append("Patients with ");
MessageSourceService msa = Context.getMessageSourceService();
Locale locale = Context.getLocale();
StringBuilder ret = new StringBuilder();
ret.append(msa.getMessage("reporting.patientsWith")).append(" ");
if (atLeastCount != null || atMostCount != null) {
if (atLeastCount != null) {
ret.append("at least " + atLeastCount + " ");
ret.append(msa.getMessage("reporting.atLeast", new Object[] { atLeastCount }, locale)).append(" ");
}
if (atMostCount != null) {
ret.append("at most " + atMostCount + " ");
ret.append(msa.getMessage("reporting.atMost", new Object[] { atMostCount }, locale)).append(" ");
}
} else {
ret.append("any ");
ret.append(msa.getMessage("reporting.any")).append(" ");
}
if (encounterTypeList != null) {
ret.append("[");
for (Iterator<EncounterType> i = encounterTypeList.iterator(); i.hasNext();) {
ret.append(" " + i.next().getName());
ret.append(" ").append(i.next().getName());
if (i.hasNext()) {
ret.append(" ,");
}
}
ret.append(" ] ");
}
ret.append("encounters ");
ret.append(msa.getMessage("reporting.encounters")).append(" ");
if (location != null) {
ret.append("at " + location.getName() + " ");
ret.append(msa.getMessage("reporting.at", new Object[] { location.getName() }, locale)).append(" ");
}
if (withinLastMonths != null || withinLastDays != null) {
ret.append("within the last ");
if (withinLastMonths != null) {
ret.append(withinLastMonths + " month(s) ");
ret.append(" ").append(
msa.getMessage("reporting.withinTheLastMonths", new Object[] { withinLastMonths }, locale));
}
if (withinLastDays != null) {
ret.append(withinLastDays + " day(s) ");
ret.append(" ").append(
msa.getMessage("reporting.withinTheLastDays", new Object[] { withinLastDays }, locale));
}
}
// TODO untilDaysAgo untilMonthsAgo
if (sinceDate != null) {
ret.append("on or after " + sinceDate + " ");
ret.append(msa.getMessage("reporting.onOrAfter", new Object[] { sinceDate }, locale));
}
if (untilDate != null) {
ret.append("on or before " + untilDate + " ");
ret.append(msa.getMessage("reporting.onOrBefore", new Object[] { untilDate }, locale));
}
if (form != null) {
ret.append("from the " + form.getName() + " form ");
ret.append(msa.getMessage("reporting.fromThe", new Object[] { form.getName() }, locale));
}
return ret.toString();
}
Original file line number Diff line number Diff line change
@@ -15,8 +15,9 @@

import java.util.ArrayList;
import java.util.List;

import org.openmrs.Cohort;
import org.openmrs.api.context.Context;
import org.openmrs.messagesource.MessageSourceService;
import org.openmrs.report.EvaluationContext;
import org.openmrs.report.Parameter;
import org.openmrs.report.Parameterizable;
@@ -77,7 +78,9 @@ public boolean isReadyToRun() {
}

public String getDescription() {
return "NOT " + (baseFilter == null ? "?" : baseFilter.getDescription());
MessageSourceService msa = Context.getMessageSourceService();
return msa.getMessage("reporting.not").toUpperCase() + " "
+ (baseFilter == null ? "?" : baseFilter.getDescription());
}

/**
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@
import org.openmrs.Location;
import org.openmrs.api.PatientSetService.PatientLocationMethod;
import org.openmrs.api.context.Context;
import org.openmrs.messagesource.MessageSourceService;
import org.openmrs.report.EvaluationContext;

/**
@@ -45,10 +46,11 @@ public String getCacheKey() {
}

public String getDescription() {
MessageSourceService msa = Context.getMessageSourceService();
StringBuilder sb = new StringBuilder();
sb.append("Patients who belong to ");
sb.append(getLocation() == null ? "NULL" : getLocation().getName());
sb.append(" (by method " + getCalculationMethod() + ")");
sb.append(msa.getMessage("reporting.patientsWhoBelongTo")).append(" ");
sb.append(getLocation() == null ? msa.getMessage("reporting.null") : getLocation().getName());
sb.append(" (").append(msa.getMessage("reporting.byMethod")).append(" ").append(getCalculationMethod()).append(")");
return sb.toString();
}

Loading