Skip to content

Commit

Permalink
update minimum date report filter
Browse files Browse the repository at this point in the history
  • Loading branch information
bennsimon committed Nov 25, 2020
1 parent 63b9eb3 commit 25c7d2c
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 12 deletions.
6 changes: 3 additions & 3 deletions opensrp-giz-malawi/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ android {
applicationId "org.smartregister.giz"
minSdkVersion androidMinSdkVersion
targetSdkVersion androidTargetSdkVersion
versionCode 34
versionName "0.2.44"
versionCode 35
versionName "0.2.45"
multiDexEnabled true
buildConfigField "long", "MAX_SERVER_TIME_DIFFERENCE", "1800000l"
buildConfigField "boolean", "TIME_CHECK", "false"
Expand Down Expand Up @@ -341,7 +341,7 @@ dependencies {
exclude group: 'com.android.support', module: 'appcompat-v7'
}

implementation('org.smartregister:opensrp-client-reporting:0.0.20-SNAPSHOT@aar') {
implementation('org.smartregister:opensrp-client-reporting:0.0.22-v4-SNAPSHOT@aar') {
transitive = true
exclude group: 'id.zelory', module: 'compressor'
exclude group: 'org.smartregister', module: 'opensrp-client-core'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,21 @@
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.google.android.material.snackbar.Snackbar;
import com.google.android.material.tabs.TabLayout;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentPagerAdapter;
import androidx.fragment.app.FragmentStatePagerAdapter;
import androidx.viewpager.widget.PagerAdapter;
import androidx.viewpager.widget.ViewPager;
import androidx.appcompat.app.AppCompatActivity;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.google.android.material.snackbar.Snackbar;
import com.google.android.material.tabs.TabLayout;
import com.vijay.jsonwizard.constants.JsonFormConstants;

import org.greenrobot.eventbus.EventBus;
Expand Down Expand Up @@ -77,7 +78,7 @@
public class HIA2ReportsActivity extends AppCompatActivity {

public static final int REQUEST_CODE_GET_JSON = 3432;
public static final int MONTH_SUGGESTION_LIMIT = 3;
public static final int MONTH_SUGGESTION_LIMIT = 10;
public static final String FORM_KEY_CONFIRM = "confirm";
public static final DateFormat yyyyMMdd = new SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.crashlytics.android.core.CrashlyticsCore;
import com.evernote.android.job.JobManager;

import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;
import org.smartregister.Context;
import org.smartregister.CoreLibrary;
Expand All @@ -39,6 +40,7 @@
import org.smartregister.giz.activity.GizOpdProfileActivity;
import org.smartregister.giz.activity.GizPncFormActivity;
import org.smartregister.giz.activity.GizPncProfileActivity;
import org.smartregister.giz.activity.HIA2ReportsActivity;
import org.smartregister.giz.activity.LoginActivity;
import org.smartregister.giz.activity.OpdFormActivity;
import org.smartregister.giz.configuration.GizAncMaternityTransferProcessor;
Expand Down Expand Up @@ -103,6 +105,8 @@
import org.smartregister.pnc.utils.PncDbConstants;
import org.smartregister.receiver.SyncStatusBroadcastReceiver;
import org.smartregister.reporting.ReportingLibrary;
import org.smartregister.reporting.util.Constants;
import org.smartregister.repository.AllSharedPreferences;
import org.smartregister.repository.EventClientRepository;
import org.smartregister.repository.Hia2ReportRepository;
import org.smartregister.repository.Repository;
Expand All @@ -112,7 +116,9 @@
import org.smartregister.view.activity.DrishtiApplication;
import org.smartregister.view.receiver.TimeChangedBroadcastReceiver;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
Expand Down Expand Up @@ -314,6 +320,7 @@ public void onCreate() {
activityConfiguration.setHomeRegisterActivityClass(AncRegisterActivity.class);
activityConfiguration.setLandingPageActivityClass(AllClientsRegisterActivity.class);
activityConfiguration.setProfileActivityClass(GizAncProfileActivity.class);

AncMetadata ancMetadata = new AncMetadata();
ancMetadata.setLocationLevels(GizUtils.getLocationLevels());
ancMetadata.setHealthFacilityLevels(GizUtils.getHealthFacilityLevels());
Expand All @@ -338,6 +345,22 @@ public void onCreate() {
JobManager.create(this).addJobCreator(new GizMalawiJobCreator());
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);

initMinimumDateForReportGeneration();
}

private void initMinimumDateForReportGeneration() {
AllSharedPreferences allSharedPreferences = context().allSharedPreferences();
if (StringUtils.isBlank(allSharedPreferences.getPreference(Constants.ReportingConfig.MIN_REPORT_DATE))) {
Calendar startDate = Calendar.getInstance();
startDate.set(Calendar.DAY_OF_MONTH, 1);
startDate.set(Calendar.HOUR_OF_DAY, 0);
startDate.set(Calendar.MINUTE, 0);
startDate.set(Calendar.SECOND, 0);
startDate.set(Calendar.MILLISECOND, 0);
startDate.add(Calendar.MONTH, -1 * HIA2ReportsActivity.MONTH_SUGGESTION_LIMIT);
String dateFormatted = new SimpleDateFormat(GizConstants.DateTimeFormat.YYYY_MM_dd_HH_mm_ss).format(startDate.getTime());
allSharedPreferences.savePreference(Constants.ReportingConfig.MIN_REPORT_DATE, dateFormatted);
}
}

private void setupMaternityLibrary() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void populateClientRow(@NonNull Cursor cursor, @NonNull CommonPersonObjec
if (strVisitEndDate != null) {
Date visitEndDate = OpdUtils.convertStringToDate(OpdConstants.DateFormat.YYYY_MM_DD_HH_MM_SS, strVisitEndDate);
if (visitEndDate != null && OpdLibrary.getInstance().isPatientInTreatedState(visitEndDate)) {
String treatedTime = OpdUtils.convertDate(visitEndDate, GizConstants.DateFormat.HH_MM_AMPM);
String treatedTime = OpdUtils.convertDate(visitEndDate, GizConstants.DateTimeFormat.HH_MM_AMPM);

Context context = dueButton.getContext();
dueButton.setText(String.format(context.getResources().getString(R.string.treated_at_time), treatedTime));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,9 @@ public static class IntentKeyUtil {
public static final String IS_REMOTE_LOGIN = "is_remote_login";
}

public interface DateFormat {
public interface DateTimeFormat {
String HH_MM_AMPM = "h:mm a";
String YYYY_MM_dd_HH_mm_ss = "yyyy-MM-dd HH:mm:ss";
}

public interface RegisterType {
Expand Down

0 comments on commit 25c7d2c

Please sign in to comment.