Skip to content

Commit

Permalink
Added cumulative annual values for cso and zeir
Browse files Browse the repository at this point in the history
Signed-off-by: Ephraim Muhia <emuhia@ona.io>
  • Loading branch information
Ephraim Muhia committed Feb 1, 2018
1 parent a4b891b commit 550dc0f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 15 deletions.
Expand Up @@ -159,13 +159,9 @@ public void onServiceFinish(String actionType) {

@Override
protected <T> View generateView(final View view, final VaccineRepo.Vaccine vaccine, final List<T> indicators) {
long value = 0;

CumulativeIndicator cumulativeIndicator = retrieveCumulativeIndicator(indicators, vaccine);

if (cumulativeIndicator != null) {
value = cumulativeIndicator.getValue();
}
long value = retrieveCumulativeIndicatorValue(indicators, vaccine);

String display = vaccine.display();
if (vaccine.equals(VaccineRepo.Vaccine.measles1)) {
Expand Down
Expand Up @@ -135,13 +135,7 @@ public void onServiceFinish(String actionType) {

@Override
protected <T> View generateView(final View view, final VaccineRepo.Vaccine vaccine, final List<T> indicators) {
long value = 0;

CumulativeIndicator cumulativeIndicator = retrieveCumulativeIndicator(indicators, vaccine);

if (cumulativeIndicator != null) {
value = cumulativeIndicator.getValue();
}
long value = retrieveCumulativeIndicatorValue(indicators, vaccine);

String display = vaccine.display();
if (vaccine.equals(VaccineRepo.Vaccine.measles1)) {
Expand Down
Expand Up @@ -192,17 +192,18 @@ protected <T> View generateView(final View view, final VaccineRepo.Vaccine vacci
return view;
}

protected <T> CumulativeIndicator retrieveCumulativeIndicator(List<T> indicators, VaccineRepo.Vaccine vaccine) {
protected <T> Long retrieveCumulativeIndicatorValue(List<T> indicators, VaccineRepo.Vaccine vaccine) {
long value = 0L;
final String vaccineString = VaccineRepository.addHyphen(vaccine.display().toLowerCase());
for (T t : indicators) {
if (t instanceof CumulativeIndicator) {
CumulativeIndicator cumulativeIndicator = (CumulativeIndicator) t;
if (cumulativeIndicator.getVaccine().equals(vaccineString)) {
return cumulativeIndicator;
value += cumulativeIndicator.getValue();
}
}
}
return null;
return value;
}

protected <T> CohortIndicator retrieveCohortIndicator(List<T> indicators, VaccineRepo.Vaccine vaccine) {
Expand Down

0 comments on commit 550dc0f

Please sign in to comment.