Skip to content

Commit

Permalink
Cumulative Report
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 Jan 22, 2018
1 parent f914dec commit a2fe2d1
Show file tree
Hide file tree
Showing 18 changed files with 1,303 additions and 242 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1157,7 +1157,7 @@ private void saveVaccine(VaccineWrapper tag) {
tag.setDbKey(vaccine.getId());

// Update coverage reports
CoverageDropoutIntentService.updateIndicators(ChildDetailTabbedActivity.this, childDetails.entityId(), Utils.dobToDateTime(childDetails).toDate(), tag.getName(), String.valueOf(tag.getUpdatedVaccineDate().toDate().getTime()));
CoverageDropoutIntentService.updateIndicators(ChildDetailTabbedActivity.this, childDetails.entityId(), Utils.dobToDateTime(childDetails).toDate(), tag.getName(), tag.getUpdatedVaccineDate().toDate());

if (tag.getName().equalsIgnoreCase(VaccineRepo.Vaccine.bcg2.display())) {
invalidateOptionsMenu();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import org.smartregister.path.domain.CohortIndicator;
import org.smartregister.path.helper.SpinnerHelper;
import org.smartregister.path.receiver.CoverageDropoutBroadcastReceiver;
import org.smartregister.path.repository.ChildReportRepository;
import org.smartregister.path.repository.CohortPatientRepository;
import org.smartregister.path.repository.CohortIndicatorRepository;
import org.smartregister.path.repository.CohortRepository;
import org.smartregister.path.toolbar.LocationSwitcherToolbar;
Expand Down Expand Up @@ -350,12 +350,12 @@ public int compare(Cohort lhs, Cohort rhs) {
});


ChildReportRepository childReportRepository = VaccinatorApplication.getInstance().childReportRepository();
CohortPatientRepository cohortPatientRepository = VaccinatorApplication.getInstance().cohortPatientRepository();

// Populate the default cohort
Cohort cohort = cohorts.get(0);

long cohortSize = childReportRepository.countCohort(cohort.getId());
long cohortSize = cohortPatientRepository.countCohort(cohort.getId());
CohortHolder cohortHolder = new CohortHolder(cohort.getId(), cohort.getMonthAsDate(), cohortSize);


Expand Down Expand Up @@ -483,8 +483,8 @@ protected Pair<List<CohortIndicator>, Long> doInBackground(Long... params) {
CohortIndicatorRepository cohortIndicatorRepository = VaccinatorApplication.getInstance().cohortIndicatorRepository();
List<CohortIndicator> indicators = cohortIndicatorRepository.findByCohort(cohortId);

ChildReportRepository childReportRepository = VaccinatorApplication.getInstance().childReportRepository();
long cohortSize = childReportRepository.countCohort(cohortId);
CohortPatientRepository cohortPatientRepository = VaccinatorApplication.getInstance().cohortPatientRepository();
long cohortSize = cohortPatientRepository.countCohort(cohortId);

return Pair.create(indicators, cohortSize);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,12 @@
import org.smartregister.path.receiver.PathSyncBroadcastReceiver;
import org.smartregister.path.receiver.SyncStatusBroadcastReceiver;
import org.smartregister.path.receiver.VaccinatorAlarmReceiver;
import org.smartregister.path.repository.ChildReportRepository;
import org.smartregister.path.repository.CohortPatientRepository;
import org.smartregister.path.repository.CohortIndicatorRepository;
import org.smartregister.path.repository.CohortRepository;
import org.smartregister.path.repository.CumulativeIndicatorRepository;
import org.smartregister.path.repository.CumulativePatientRepository;
import org.smartregister.path.repository.CumulativeRepository;
import org.smartregister.path.repository.DailyTalliesRepository;
import org.smartregister.path.repository.HIA2IndicatorsRepository;
import org.smartregister.path.repository.MonthlyTalliesRepository;
Expand Down Expand Up @@ -79,7 +82,10 @@ public class VaccinatorApplication extends DrishtiApplication
private StockRepository stockRepository;
private CohortRepository cohortRepository;
private CohortIndicatorRepository cohortIndicatorRepository;
private ChildReportRepository childReportRepository;
private CohortPatientRepository cohortPatientRepository;
private CumulativeRepository cumulativeRepository;
private CumulativeIndicatorRepository cumulativeIndicatorRepository;
private CumulativePatientRepository cumulativePatientRepository;
private boolean lastModified;

@Override
Expand Down Expand Up @@ -352,11 +358,32 @@ public CohortIndicatorRepository cohortIndicatorRepository() {
return cohortIndicatorRepository;
}

public ChildReportRepository childReportRepository() {
if (childReportRepository == null) {
childReportRepository = new ChildReportRepository((PathRepository) getRepository());
public CohortPatientRepository cohortPatientRepository() {
if (cohortPatientRepository == null) {
cohortPatientRepository = new CohortPatientRepository((PathRepository) getRepository());
}
return childReportRepository;
return cohortPatientRepository;
}

public CumulativeRepository cumulativeRepository() {
if (cumulativeRepository == null) {
cumulativeRepository = new CumulativeRepository((PathRepository) getRepository());
}
return cumulativeRepository;
}

public CumulativeIndicatorRepository cumulativeIndicatorRepository() {
if (cumulativeIndicatorRepository == null) {
cumulativeIndicatorRepository = new CumulativeIndicatorRepository((PathRepository) getRepository());
}
return cumulativeIndicatorRepository;
}

public CumulativePatientRepository cumulativePatientRepository() {
if (cumulativeIndicatorRepository == null) {
cumulativePatientRepository = new CumulativePatientRepository((PathRepository) getRepository());
}
return cumulativePatientRepository;
}

public boolean isLastModified() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/**
* Created by keyman on 11/01/18.
*/
public class ChildReport implements Serializable {
public class CohortPatient implements Serializable {
private Long id;
private String baseEntityId;
private Long cohortId;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
package org.smartregister.path.domain;

import android.util.Log;

import org.smartregister.path.repository.CumulativeRepository;

import java.io.Serializable;
import java.text.ParseException;
import java.util.Date;

/**
* Created by keyman on 22/01/18.
*/
public class Cumulative implements Serializable {
private Long id;
private Integer year;
private Long csoNumber;
private Long zeirNumber;
private Date createdAt;
private Date updatedAt;

public Long getId() {
return id;
}

public void setId(Long id) {
this.id = id;
}

public Integer getYear() {
return year;
}

public void setYear(Integer year) {
this.year = year;
}

public Date getYearAsDate() {
if (year == null) {
return null;
}
try {
return CumulativeRepository.DF_YYYY.parse(year.toString());
} catch (ParseException e) {
Log.e(Cohort.class.getName(), e.getMessage(), e);
return null;
}
}

public void setYear(Date date) {
if (date != null) {
try {
this.year = Integer.valueOf(CumulativeRepository.DF_YYYY.format(date));
} catch (Exception e) {
Log.e(Cohort.class.getName(), e.getMessage(), e);
}
}
}

public Long getCsoNumber() {
return csoNumber;
}

public void setCsoNumber(Long csoNumber) {
this.csoNumber = csoNumber;
}

public Long getZeirNumber() {
return zeirNumber;
}

public void setZeirNumber(Long zeirNumber) {
this.zeirNumber = zeirNumber;
}

public Date getCreatedAt() {
return createdAt;
}

public void setCreatedAt(Date createdAt) {
this.createdAt = createdAt;
}

public Date getUpdatedAt() {
return updatedAt;
}

public void setUpdatedAt(Date updatedAt) {
this.updatedAt = updatedAt;
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
package org.smartregister.path.domain;

import android.util.Log;

import org.apache.commons.lang3.StringUtils;
import org.smartregister.path.repository.CumulativeIndicatorRepository;

import java.io.Serializable;
import java.text.ParseException;
import java.util.Date;

/**
* Created by keyman on 11/01/18.
*/
public class CumulativeIndicator implements Serializable {
private Long id;
private Long cumulativeId;
private String month;
private String vaccine;
private Long value;
private Date createdAt;
private Date updatedAt;

public Long getId() {
return id;
}

public void setId(Long id) {
this.id = id;
}

public Long getCumulativeId() {
return cumulativeId;
}

public void setCumulativeId(Long cumulativeId) {
this.cumulativeId = cumulativeId;
}

public String getMonth() {
return month;
}

public void setMonth(String month) {
this.month = month;
}

public Date getMonthAsDate() {
if (StringUtils.isBlank(month)) {
return null;
}
try {
return CumulativeIndicatorRepository.DF_YYYYMM.parse(month);
} catch (ParseException e) {
Log.e(Cohort.class.getName(), e.getMessage(), e);
return null;
}
}

public void setMonth(Date date) {
if (date != null) {
try {
this.month = CumulativeIndicatorRepository.DF_YYYYMM.format(date);
} catch (Exception e) {
Log.e(Cohort.class.getName(), e.getMessage(), e);
}
}
}

public String getVaccine() {
return vaccine;
}

public void setVaccine(String vaccine) {
this.vaccine = vaccine;
}


public Long getValue() {
return value;
}

public void setValue(Long value) {
this.value = value;
}

public Date getCreatedAt() {
return createdAt;
}

public void setCreatedAt(Date createdAt) {
this.createdAt = createdAt;
}

public Date getUpdatedAt() {
return updatedAt;
}

public void setUpdatedAt(Date updatedAt) {
this.updatedAt = updatedAt;
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package org.smartregister.path.domain;

import java.io.Serializable;
import java.util.Date;

/**
* Created by keyman on 22/01/18.
*/
public class CumulativePatient implements Serializable {
private Long id;
private String baseEntityId;
private String validVaccines;
private Date createdAt;
private Date updatedAt;

public Long getId() {
return id;
}

public void setId(Long id) {
this.id = id;
}

public String getBaseEntityId() {
return baseEntityId;
}

public void setBaseEntityId(String baseEntityId) {
this.baseEntityId = baseEntityId;
}

public String getValidVaccines() {
return validVaccines;
}

public void setValidVaccines(String validVaccines) {
this.validVaccines = validVaccines;
}

public Date getCreatedAt() {
return createdAt;
}

public void setCreatedAt(Date createdAt) {
this.createdAt = createdAt;
}

public Date getUpdatedAt() {
return updatedAt;
}

public void setUpdatedAt(Date updatedAt) {
this.updatedAt = updatedAt;
}
}

0 comments on commit a2fe2d1

Please sign in to comment.