diff --git a/opensrp-chw/build.gradle b/opensrp-chw/build.gradle index d3794ec1a6..afc046ecc2 100644 --- a/opensrp-chw/build.gradle +++ b/opensrp-chw/build.gradle @@ -149,9 +149,6 @@ android { minifyEnabled false zipAlignEnabled true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - buildConfigField "int", "OPENMRS_UNIQUE_ID_INITIAL_BATCH_SIZE", '500' - buildConfigField "int", "OPENMRS_UNIQUE_ID_BATCH_SIZE", '500' - buildConfigField "int", "OPENMRS_UNIQUE_ID_SOURCE", '2' buildConfigField "boolean", "TIME_CHECK", "true" buildConfigField "int", "DATA_SYNC_DURATION_MINUTES", '15' buildConfigField "int", "VACCINE_SYNC_PROCESSING_MINUTES", '30' @@ -168,9 +165,6 @@ android { } debug { - buildConfigField "int", "OPENMRS_UNIQUE_ID_INITIAL_BATCH_SIZE", '30' - buildConfigField "int", "OPENMRS_UNIQUE_ID_BATCH_SIZE", '15' - buildConfigField "int", "OPENMRS_UNIQUE_ID_SOURCE", '2' buildConfigField "boolean", "TIME_CHECK", "false" buildConfigField "int", "DATA_SYNC_DURATION_MINUTES", '15' buildConfigField "int", "VACCINE_SYNC_PROCESSING_MINUTES", '30' @@ -238,6 +232,9 @@ android { applicationIdSuffix ".ba" versionCode 8 versionName "1.0.8" + buildConfigField "int", "OPENMRS_UNIQUE_ID_INITIAL_BATCH_SIZE", '10000' + buildConfigField "int", "OPENMRS_UNIQUE_ID_BATCH_SIZE", '10000' + buildConfigField "int", "OPENMRS_UNIQUE_ID_SOURCE", '2' buildConfigField "String", 'opensrp_url', '"https://boresha-afya.smartregister.org/opensrp/"' buildConfigField "String", 'guidebooks_url', '"https://opensrp.s3.amazonaws.com/media/ba/"' buildConfigField "String", 'opensrp_url_debug', '"https://boresha-afya-stage.smartregister.org/opensrp/"' @@ -254,6 +251,9 @@ android { applicationIdSuffix ".chad" versionCode 3 versionName "1.0.3" + buildConfigField "int", "OPENMRS_UNIQUE_ID_INITIAL_BATCH_SIZE", '10000' + buildConfigField "int", "OPENMRS_UNIQUE_ID_BATCH_SIZE", '10000' + buildConfigField "int", "OPENMRS_UNIQUE_ID_SOURCE", '2' buildConfigField "String", 'opensrp_url', '"https://wcaro-td.smartregister.org/opensrp/"' buildConfigField "String", 'guidebooks_url', '"https://opensrp.s3.amazonaws.com/media/chad/"' buildConfigField "String", 'opensrp_url_debug', '"https://wcaro-stage.smartregister.org/opensrp/"' @@ -272,6 +272,9 @@ android { applicationIdSuffix ".drc" versionCode 11 versionName "1.0.16" + buildConfigField "int", "OPENMRS_UNIQUE_ID_INITIAL_BATCH_SIZE", '10000' + buildConfigField "int", "OPENMRS_UNIQUE_ID_BATCH_SIZE", '10000' + buildConfigField "int", "OPENMRS_UNIQUE_ID_SOURCE", '2' buildConfigField "String", 'opensrp_url', '"https://wcaro-cd.smartregister.org/opensrp/"' buildConfigField "String", 'guidebooks_url', '"https://opensrp.s3.amazonaws.com/media/drc/"' buildConfigField "String", 'opensrp_url_preview', '"https://wcaro-cd-preview.smartregister.org/opensrp/"' @@ -290,6 +293,7 @@ android { applicationIdSuffix ".guinea" versionCode 4 versionName "1.0.3" + buildConfigField "int", "OPENMRS_UNIQUE_ID_SOURCE", '2' buildConfigField "int", "OPENMRS_UNIQUE_ID_INITIAL_BATCH_SIZE", '1000' buildConfigField "int", "OPENMRS_UNIQUE_ID_BATCH_SIZE", '500' buildConfigField "String", 'opensrp_url', '"https://wcaro-guinea.smartregister.org/opensrp/"' @@ -310,6 +314,7 @@ android { applicationIdSuffix ".togo" versionCode 26 versionName "1.2.7" + buildConfigField "int", "OPENMRS_UNIQUE_ID_SOURCE", '2' buildConfigField "int", "OPENMRS_UNIQUE_ID_INITIAL_BATCH_SIZE", '1000' buildConfigField "int", "OPENMRS_UNIQUE_ID_BATCH_SIZE", '500' buildConfigField "String", 'opensrp_url', '"https://wcaro-tg.smartregister.org/opensrp/"' @@ -328,6 +333,9 @@ android { dimension = 'baseDimension' versionCode 8 versionName "1.0.1" + buildConfigField "int", "OPENMRS_UNIQUE_ID_INITIAL_BATCH_SIZE", '10000' + buildConfigField "int", "OPENMRS_UNIQUE_ID_BATCH_SIZE", '10000' + buildConfigField "int", "OPENMRS_UNIQUE_ID_SOURCE", '2' buildConfigField "String", 'opensrp_url', '"https://wcaro-lr.smartregister.org/opensrp/"' buildConfigField "String", 'guidebooks_url', '"https://opensrp.s3.amazonaws.com/media/liberia/"' buildConfigField "String", 'opensrp_url_debug', '"https://wcaro-stage.smartregister.org/opensrp/"' @@ -344,10 +352,11 @@ android { dimension = 'baseDimension' applicationIdSuffix ".lmh" versionCode 2 - versionName "1.1.2" - buildConfigField "int", "OPENMRS_UNIQUE_ID_INITIAL_BATCH_SIZE", '100000' - buildConfigField "int", "OPENMRS_UNIQUE_ID_BATCH_SIZE", '50000' - buildConfigField "String", 'opensrp_url', '"https://lmh-liberia.smartregister.org/opensrp/"' + versionName "2.0.1-rc5" + buildConfigField "int", "OPENMRS_UNIQUE_ID_INITIAL_BATCH_SIZE", '10000' + buildConfigField "int", "OPENMRS_UNIQUE_ID_BATCH_SIZE", '10000' + buildConfigField "int", "OPENMRS_UNIQUE_ID_SOURCE", '1' + buildConfigField "String", 'opensrp_url', '"https://liberiavts.smartregister.org/opensrp/"' buildConfigField "String", 'guidebooks_url', '"https://opensrp.s3.amazonaws.com/media/lmh/"' buildConfigField "String", 'opensrp_url_debug', '"https://lmh-liberia-preview.smartregister.org/opensrp/"' buildConfigField "String[]", "LOCATION_HIERACHY", '{"Country" , "County" , "District", "Clinics", "CHSS", "Village","Commune"}' diff --git a/opensrp-chw/src/lmh/java/org/smartregister/chw/application/ChwApplicationFlv.java b/opensrp-chw/src/lmh/java/org/smartregister/chw/application/ChwApplicationFlv.java index 0713a68b63..052bb0020f 100644 --- a/opensrp-chw/src/lmh/java/org/smartregister/chw/application/ChwApplicationFlv.java +++ b/opensrp-chw/src/lmh/java/org/smartregister/chw/application/ChwApplicationFlv.java @@ -9,7 +9,7 @@ public boolean hasANC() { @Override public boolean syncUsingPost() { - return false; + return true; } @Override diff --git a/opensrp-chw/src/main/java/org/smartregister/chw/application/ChwSyncConfiguration.java b/opensrp-chw/src/main/java/org/smartregister/chw/application/ChwSyncConfiguration.java index 690c4ab97a..96dd4564b5 100644 --- a/opensrp-chw/src/main/java/org/smartregister/chw/application/ChwSyncConfiguration.java +++ b/opensrp-chw/src/main/java/org/smartregister/chw/application/ChwSyncConfiguration.java @@ -11,7 +11,9 @@ import org.smartregister.repository.AllSharedPreferences; import org.smartregister.view.activity.BaseLoginActivity; +import java.util.HashSet; import java.util.List; +import java.util.Set; import static org.smartregister.util.Utils.isEmptyCollection; @@ -36,9 +38,10 @@ public String getSyncFilterValue() { if(StringUtils.isBlank(locationId)) locationId = allSharedPreferences().fetchUserLocalityId(providerId); List locationIds = LocationHelper.getInstance().locationsFromHierarchy(true, null); + if (!isEmptyCollection(locationIds) && locationIds.contains(locationId)) { int index = locationIds.indexOf(locationId); - List subLocationIds = locationIds.subList(index, locationIds.size()); + Set subLocationIds = new HashSet<>(locationIds.subList(index, locationIds.size())); return StringUtils.join(subLocationIds, ","); } return locationId; @@ -115,12 +118,12 @@ public String getOauthClientSecret() { @Override public int getConnectTimeout() { - return BuildConfig.MAX_CONNECTION_TIMEOUT * 60000; + return BuildConfig.MAX_CONNECTION_TIMEOUT * 300000; } @Override public int getReadTimeout() { - return BuildConfig.MAX_READ_TIMEOUT * 60000; + return BuildConfig.MAX_READ_TIMEOUT * 300000; } @Override diff --git a/opensrp-chw/src/main/java/org/smartregister/chw/interactor/ChildUpcomingServiceInteractor.java b/opensrp-chw/src/main/java/org/smartregister/chw/interactor/ChildUpcomingServiceInteractor.java new file mode 100644 index 0000000000..0bf11f6916 --- /dev/null +++ b/opensrp-chw/src/main/java/org/smartregister/chw/interactor/ChildUpcomingServiceInteractor.java @@ -0,0 +1,17 @@ +package org.smartregister.chw.interactor; + +import android.content.Context; + +import org.smartregister.chw.anc.domain.MemberObject; +import org.smartregister.chw.anc.model.BaseUpcomingService; +import org.smartregister.chw.core.interactor.CoreChildUpcomingServiceInteractor; + +import java.util.List; + +public class ChildUpcomingServiceInteractor extends CoreChildUpcomingServiceInteractor { + + public final List getUpcomingServices(final MemberObject memberObject, final Context ctx){ + return getMemberServices(ctx, memberObject); + } + +} diff --git a/opensrp-chw/src/main/java/org/smartregister/chw/presenter/FamilyProfileDuePresenter.java b/opensrp-chw/src/main/java/org/smartregister/chw/presenter/FamilyProfileDuePresenter.java index 5ebf52b7e9..f30c8f3693 100644 --- a/opensrp-chw/src/main/java/org/smartregister/chw/presenter/FamilyProfileDuePresenter.java +++ b/opensrp-chw/src/main/java/org/smartregister/chw/presenter/FamilyProfileDuePresenter.java @@ -3,41 +3,22 @@ import android.content.Context; import android.util.Pair; -import org.joda.time.DateTime; -import org.joda.time.LocalDate; -import org.joda.time.Months; import org.smartregister.chw.anc.domain.MemberObject; import org.smartregister.chw.application.ChwApplication; -import org.smartregister.chw.core.application.CoreChwApplication; import org.smartregister.chw.core.dao.VisitDao; import org.smartregister.chw.core.utils.CoreConstants; -import org.smartregister.chw.core.utils.VaccineScheduleUtil; -import org.smartregister.chw.core.utils.VisitVaccineUtil; import org.smartregister.chw.dao.ChwChildDao; import org.smartregister.chw.model.FamilyKitModel; import org.smartregister.chw.model.WashCheckModel; -import org.smartregister.chw.util.Constants; +import org.smartregister.chw.util.UpcomingServicesUtil; import org.smartregister.dao.AbstractDao; -import org.smartregister.domain.Alert; import org.smartregister.family.contract.FamilyProfileDueContract; import org.smartregister.family.presenter.BaseFamilyProfileDuePresenter; -import org.smartregister.immunization.db.VaccineRepo; -import org.smartregister.immunization.domain.jsonmapping.Vaccine; -import org.smartregister.immunization.domain.jsonmapping.VaccineGroup; -import org.smartregister.immunization.util.VaccinatorUtils; -import java.text.ParseException; -import java.text.SimpleDateFormat; import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; import java.util.List; -import java.util.Locale; -import java.util.Map; import java.util.function.Supplier; -import timber.log.Timber; - public class FamilyProfileDuePresenter extends BaseFamilyProfileDuePresenter { private WashCheckModel washCheckModel; private FamilyKitModel familyKitModel; @@ -97,8 +78,6 @@ private String getSelectCondition(){ String validMembers(){ List> familyMembers = FamilyMemberDao.getFamilyMembers(this.familyBaseEntityId); - List childVaccineGroups = VaccineScheduleUtil.getVaccineGroups(ChwApplication.getInstance().getApplicationContext(), CoreConstants.SERVICE_GROUPS.CHILD); - List specialVaccines = VaccinatorUtils.getSpecialVaccines(contextSupplier.get()); StringBuilder joiner = new StringBuilder(); for (Pair familyMemberRepr : familyMembers) { @@ -109,7 +88,7 @@ String validMembers(){ boolean vaccineCardReceived = VisitDao.memberHasVaccineCard(member.getBaseEntityId()); - if (!vaccineCardReceived || pendingImmunization(member, childVaccineGroups, specialVaccines)) { + if (!vaccineCardReceived || UpcomingServicesUtil.hasUpcomingDueServices(member, contextSupplier.get())) { joiner.append(String.format("'%s'", member.getBaseEntityId())); joiner.append(","); } @@ -121,55 +100,6 @@ String validMembers(){ return joiner.toString(); } - int immunizationCeiling(MemberObject memberObject) { - String gender = ChwChildDao.getChildGender(memberObject.getBaseEntityId()); - - if (gender != null && gender.equalsIgnoreCase("Female")) { - if (memberObject.getAge() >= 9 && memberObject.getAge() <= 11) { - return 132; - } else { - return 60; - } - } - - return 60; - } - - boolean pendingImmunization(MemberObject memberObject, List vaccineGroups, List specialVaccines){ - Date dob = null; - try { - dob = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()).parse(memberObject.getDob()); - } catch (ParseException e) { - Timber.e(e); - } - - int ageInMonths = Months.monthsBetween(new LocalDate(dob), new LocalDate()).getMonths(); - if (ageInMonths >= immunizationCeiling(memberObject)) return false; - - List vaccines = CoreChwApplication.getInstance().vaccineRepository() - .findByEntityId(memberObject.getBaseEntityId()); - - String vaccineCategory = memberObject.getAge() > 5 ? Constants.CHILD_OVER_5 : CoreConstants.SERVICE_GROUPS.CHILD; - List allVacs = VaccineRepo.getVaccines(vaccineCategory); - - Map vaccinesRepo = new HashMap<>(); - for (VaccineRepo.Vaccine vaccine : allVacs) { - vaccinesRepo.put(vaccine.display().toLowerCase().replace(" ", ""), vaccine); - } - - Map>> pendingVaccines = VisitVaccineUtil.generateVisitVaccines( - memberObject.getBaseEntityId(), - vaccinesRepo, - new DateTime(dob), - vaccineGroups, - specialVaccines, - vaccines, - null - ); - - return !pendingVaccines.isEmpty(); - } - public boolean saveData(String jsonObject) { return washCheckModel.saveWashCheckEvent(jsonObject); } diff --git a/opensrp-chw/src/main/java/org/smartregister/chw/util/UpcomingServicesUtil.java b/opensrp-chw/src/main/java/org/smartregister/chw/util/UpcomingServicesUtil.java index 0ea2d90d0c..242dd0efff 100644 --- a/opensrp-chw/src/main/java/org/smartregister/chw/util/UpcomingServicesUtil.java +++ b/opensrp-chw/src/main/java/org/smartregister/chw/util/UpcomingServicesUtil.java @@ -11,9 +11,9 @@ import org.smartregister.chw.anc.domain.MemberObject; import org.smartregister.chw.anc.model.BaseUpcomingService; import org.smartregister.chw.application.ChwApplication; -import org.smartregister.chw.core.interactor.CoreChildUpcomingServiceInteractor; import org.smartregister.chw.core.utils.CoreConstants; import org.smartregister.chw.dao.ChwChildDao; +import org.smartregister.chw.interactor.ChildUpcomingServiceInteractor; import java.util.ArrayList; import java.util.HashMap; @@ -71,6 +71,18 @@ static String getDueServicesState(List serviceList) { return hasDue ? CoreConstants.VISIT_STATE.DUE : null; } + public static boolean hasUpcomingDueServices(MemberObject memberObject, Context ctx){ + String childGender = ChwChildDao.getChildGender(memberObject.getBaseEntityId()); + int childAge = memberObject.getAge(); + if (!ChwApplication.getApplicationFlavor().showChildrenAboveTwoDueStatus() + && childAge >= 2 + && !(childGender.equalsIgnoreCase("Female") && childAge >= 9 && childAge <= 11)){ + return false; + } + List upcomingServices = new ChildUpcomingServiceInteractor().getUpcomingServices(memberObject, ctx); + return getDueServicesState(upcomingServices) != null; + } + public static void fetchUpcomingDueServicesState(MemberObject memberObject, Context ctx, Consumer onDueStatusFetched) { String childGender = ChwChildDao.getChildGender(memberObject.getBaseEntityId()); int childAge = memberObject.getAge(); @@ -82,7 +94,7 @@ public static void fetchUpcomingDueServicesState(MemberObject memberObject, Cont return; } - new CoreChildUpcomingServiceInteractor().getUpComingServices(memberObject, ctx, new BaseAncUpcomingServicesContract.InteractorCallBack() { + new ChildUpcomingServiceInteractor().getUpComingServices(memberObject, ctx, new BaseAncUpcomingServicesContract.InteractorCallBack() { @Override public void onDataFetched(List serviceList) { onDueStatusFetched.accept(getDueServicesState(serviceList));