Skip to content

Commit

Permalink
Merge pull request #2022 from opensrp/update_identifier_sources
Browse files Browse the repository at this point in the history
Update identifier sources
  • Loading branch information
LZRS authored Apr 6, 2022
2 parents 0f40f23 + 347ef26 commit e5f2b25
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 88 deletions.
29 changes: 19 additions & 10 deletions opensrp-chw/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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'
Expand Down Expand Up @@ -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/"'
Expand All @@ -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/"'
Expand All @@ -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/"'
Expand All @@ -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/"'
Expand All @@ -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/"'
Expand All @@ -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/"'
Expand All @@ -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"}'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public boolean hasANC() {

@Override
public boolean syncUsingPost() {
return false;
return true;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -36,9 +38,10 @@ public String getSyncFilterValue() {
if(StringUtils.isBlank(locationId)) locationId = allSharedPreferences().fetchUserLocalityId(providerId);

List<String> locationIds = LocationHelper.getInstance().locationsFromHierarchy(true, null);

if (!isEmptyCollection(locationIds) && locationIds.contains(locationId)) {
int index = locationIds.indexOf(locationId);
List<String> subLocationIds = locationIds.subList(index, locationIds.size());
Set<String> subLocationIds = new HashSet<>(locationIds.subList(index, locationIds.size()));
return StringUtils.join(subLocationIds, ",");
}
return locationId;
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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<BaseUpcomingService> getUpcomingServices(final MemberObject memberObject, final Context ctx){
return getMemberServices(ctx, memberObject);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -97,8 +78,6 @@ private String getSelectCondition(){

String validMembers(){
List<Pair<String, String>> familyMembers = FamilyMemberDao.getFamilyMembers(this.familyBaseEntityId);
List<VaccineGroup> childVaccineGroups = VaccineScheduleUtil.getVaccineGroups(ChwApplication.getInstance().getApplicationContext(), CoreConstants.SERVICE_GROUPS.CHILD);
List<Vaccine> specialVaccines = VaccinatorUtils.getSpecialVaccines(contextSupplier.get());

StringBuilder joiner = new StringBuilder();
for (Pair<String, String> familyMemberRepr : familyMembers) {
Expand All @@ -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(",");
}
Expand All @@ -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<VaccineGroup> vaccineGroups, List<Vaccine> 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<org.smartregister.immunization.domain.Vaccine> vaccines = CoreChwApplication.getInstance().vaccineRepository()
.findByEntityId(memberObject.getBaseEntityId());

String vaccineCategory = memberObject.getAge() > 5 ? Constants.CHILD_OVER_5 : CoreConstants.SERVICE_GROUPS.CHILD;
List<VaccineRepo.Vaccine> allVacs = VaccineRepo.getVaccines(vaccineCategory);

Map<String, VaccineRepo.Vaccine> vaccinesRepo = new HashMap<>();
for (VaccineRepo.Vaccine vaccine : allVacs) {
vaccinesRepo.put(vaccine.display().toLowerCase().replace(" ", ""), vaccine);
}

Map<VaccineGroup, List<Pair<VaccineRepo.Vaccine, Alert>>> 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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -71,6 +71,18 @@ static String getDueServicesState(List<BaseUpcomingService> 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<BaseUpcomingService> upcomingServices = new ChildUpcomingServiceInteractor().getUpcomingServices(memberObject, ctx);
return getDueServicesState(upcomingServices) != null;
}

public static void fetchUpcomingDueServicesState(MemberObject memberObject, Context ctx, Consumer<String> onDueStatusFetched) {
String childGender = ChwChildDao.getChildGender(memberObject.getBaseEntityId());
int childAge = memberObject.getAge();
Expand All @@ -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<BaseUpcomingService> serviceList) {
onDueStatusFetched.accept(getDueServicesState(serviceList));
Expand Down

0 comments on commit e5f2b25

Please sign in to comment.