diff --git a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/application/CoreChwApplication.java b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/application/CoreChwApplication.java index 9dfe55fabd..e4ac588eb7 100644 --- a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/application/CoreChwApplication.java +++ b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/application/CoreChwApplication.java @@ -36,12 +36,13 @@ import org.smartregister.view.activity.DrishtiApplication; import org.smartregister.view.activity.LoginActivity; +import java.util.ArrayList; import java.util.List; import java.util.Locale; import timber.log.Timber; -public class CoreChwApplication extends DrishtiApplication implements CoreApplication { +public abstract class CoreChwApplication extends DrishtiApplication implements CoreApplication { private static ClientProcessorForJava clientProcessor; @@ -263,4 +264,7 @@ public FamilyMetadata getMetadata() { metadata.updateFamilyOtherMemberRegister(CoreConstants.TABLE_NAME.FAMILY_MEMBER, Integer.MAX_VALUE, false); return metadata; } + + @Override + public abstract ArrayList getAllowedLocationLevels(); } diff --git a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/contract/CoreApplication.java b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/contract/CoreApplication.java index 0294d7ff14..0bb805eda3 100644 --- a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/contract/CoreApplication.java +++ b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/contract/CoreApplication.java @@ -5,6 +5,8 @@ import org.smartregister.family.domain.FamilyMetadata; import org.smartregister.sync.helper.ECSyncHelper; +import java.util.ArrayList; + public interface CoreApplication { void saveLanguage(String language); @@ -17,4 +19,6 @@ public interface CoreApplication { RulesEngineHelper getRulesEngineHelper(); FamilyMetadata getMetadata(); + + ArrayList getAllowedLocationLevels(); } diff --git a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/utils/CoreConstants.java b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/utils/CoreConstants.java index 6f4ed05632..60836cfba6 100644 --- a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/utils/CoreConstants.java +++ b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/utils/CoreConstants.java @@ -60,8 +60,6 @@ public static class CONFIGURATION { public static final String FAMILY_MEMBER_REGISTER = "family_member_register"; public static final String ANC_REGISTER = "anc_register"; public static final String MALARIA_REGISTER = "anc_malaria_confirmation"; - public static final String HEALTH_FACILITY_TAG = "MOH Jhpiego Facility Name"; - } public static final class EventType { diff --git a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/utils/CoreReferralUtils.java b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/utils/CoreReferralUtils.java index c8b8c8e105..b73a396439 100644 --- a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/utils/CoreReferralUtils.java +++ b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/utils/CoreReferralUtils.java @@ -165,9 +165,7 @@ private static void createReferralTask(String baseEntityId, AllSharedPreferences }*/ task.setPlanIdentifier(CoreConstants.REFERRAL_PLAN_ID); LocationHelper locationHelper = LocationHelper.getInstance(); - ArrayList allowedLevels = new ArrayList<>(); - allowedLevels.add(CoreConstants.CONFIGURATION.HEALTH_FACILITY_TAG); - task.setGroupIdentifier(locationHelper.getOpenMrsLocationId(locationHelper.generateDefaultLocationHierarchy(allowedLevels).get(0))); + task.setGroupIdentifier(locationHelper.getOpenMrsLocationId(locationHelper.generateDefaultLocationHierarchy(CoreChwApplication.getInstance().getAllowedLocationLevels()).get(0))); task.setStatus(Task.TaskStatus.READY); task.setBusinessStatus(CoreConstants.BUSINESS_STATUS.REFERRED); task.setPriority(3); diff --git a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/utils/VaccineScheduleUtil.java b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/utils/VaccineScheduleUtil.java index 4a51f8d364..6711b97a41 100644 --- a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/utils/VaccineScheduleUtil.java +++ b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/utils/VaccineScheduleUtil.java @@ -2,7 +2,6 @@ import android.content.Context; -import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Triple; import org.joda.time.DateTime; import org.joda.time.LocalDate; @@ -28,8 +27,6 @@ import java.util.List; import java.util.Map; -import timber.log.Timber; - public class VaccineScheduleUtil { private VaccineScheduleUtil() { diff --git a/opensrp-chw-hf/build.gradle b/opensrp-chw-hf/build.gradle index 5c7ff87c07..79a5e6ab54 100644 --- a/opensrp-chw-hf/build.gradle +++ b/opensrp-chw-hf/build.gradle @@ -36,8 +36,6 @@ android { multiDexEnabled true buildConfigField "String", 'opensrp_url', '"https://boresha-afya.smartregister.org/opensrp/"' buildConfigField "String", 'opensrp_url_debug', '"https://boresha-afya-stage.smartregister.org/opensrp/"' - buildConfigField "String[]", "ALLOWED_LOCATION_LEVELS", '{"MOH Jhpiego Facility Name" , "Village"}' - buildConfigField "String", 'DEFAULT_LOCATION', '"Village"' buildConfigField "boolean", 'SUPPORT_QR', 'true' buildConfigField "int", "DATABASE_VERSION", '5' buildConfigField "int", "DATA_SYNC_DURATION_MINUTES", '15' @@ -56,7 +54,7 @@ android { proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' buildConfigField "int", "OPENMRS_UNIQUE_ID_INITIAL_BATCH_SIZE", '250' buildConfigField "int", "OPENMRS_UNIQUE_ID_BATCH_SIZE", '100' - buildConfigField "int", "OPENMRS_UNIQUE_ID_SOURCE", '1' + 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' @@ -65,6 +63,8 @@ android { buildConfigField "int", "REPORT_INDICATOR_GENERATION_MINUTES", '15' buildConfigField "int", "HOME_VISIT_MINUTES", '60' buildConfigField "boolean", 'SUPPORT_REPORT', 'false' + buildConfigField "String[]", "ALLOWED_LOCATION_LEVELS", '{"Ward" , "Health Facility"}' + buildConfigField "String", 'DEFAULT_LOCATION', '"Health Facility"' } debug { @@ -79,6 +79,8 @@ android { buildConfigField "int", "REPORT_INDICATOR_GENERATION_MINUTES", '15' buildConfigField "int", "HOME_VISIT_MINUTES", '60' buildConfigField "boolean", 'SUPPORT_REPORT', 'false' + buildConfigField "String[]", "ALLOWED_LOCATION_LEVELS", '{"MOH Jhpiego Facility Name" , "Village"}' + buildConfigField "String", 'DEFAULT_LOCATION', '"Village"' testCoverageEnabled true } } diff --git a/opensrp-chw-hf/proguard-rules.pro b/opensrp-chw-hf/proguard-rules.pro index f1b424510d..84f5d54db3 100644 --- a/opensrp-chw-hf/proguard-rules.pro +++ b/opensrp-chw-hf/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in 'org.robolectric:robolectric:4.0.1'dle. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/opensrp-chw-hf/release/output.json b/opensrp-chw-hf/release/output.json deleted file mode 100644 index 51879813fe..0000000000 --- a/opensrp-chw-hf/release/output.json +++ /dev/null @@ -1 +0,0 @@ -[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":1,"versionName":"1.2.3","enabled":true,"outputFile":"opensrp-chw-hf-release.apk","fullName":"release","baseName":"release"},"path":"opensrp-chw-hf-release.apk","properties":{}}] \ No newline at end of file diff --git a/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/HealthFacilityApplication.java b/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/HealthFacilityApplication.java index d214415b41..4ac527c5b1 100644 --- a/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/HealthFacilityApplication.java +++ b/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/HealthFacilityApplication.java @@ -147,6 +147,11 @@ public FamilyMetadata getMetadata() { return metadata; } + @Override + public ArrayList getAllowedLocationLevels() { + return new ArrayList<>(Arrays.asList(BuildConfig.ALLOWED_LOCATION_LEVELS)); + } + public @NotNull Map getRegisteredActivities() { Map registeredActivities = new HashMap<>(); registeredActivities.put(CoreConstants.REGISTERED_ACTIVITIES.ANC_REGISTER_ACTIVITY, AncRegisterActivity.class); diff --git a/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/sync/helper/HfTaskServiceHelper.java b/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/sync/helper/HfTaskServiceHelper.java index 864ce114b8..1f313a13df 100644 --- a/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/sync/helper/HfTaskServiceHelper.java +++ b/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/sync/helper/HfTaskServiceHelper.java @@ -2,6 +2,7 @@ import org.smartregister.CoreLibrary; import org.smartregister.chw.core.utils.CoreConstants; +import org.smartregister.chw.hf.HealthFacilityApplication; import org.smartregister.location.helper.LocationHelper; import org.smartregister.repository.TaskRepository; import org.smartregister.sync.helper.TaskServiceHelper; @@ -28,8 +29,7 @@ public static HfTaskServiceHelper getInstance() { @Override protected List getLocationIds() { LocationHelper locationHelper = LocationHelper.getInstance(); - ArrayList allowedLevels = new ArrayList<>(); - allowedLevels.add(CoreConstants.CONFIGURATION.HEALTH_FACILITY_TAG); + ArrayList allowedLevels = HealthFacilityApplication.getInstance().getAllowedLocationLevels(); List locations = new ArrayList<>(); locations.add(locationHelper.getOpenMrsLocationId(locationHelper.generateDefaultLocationHierarchy(allowedLevels).get(0))); return locations; diff --git a/opensrp-chw/build.gradle b/opensrp-chw/build.gradle index 791a513a9c..b1e6344931 100644 --- a/opensrp-chw/build.gradle +++ b/opensrp-chw/build.gradle @@ -126,9 +126,9 @@ android { versionName "1.0.0" buildConfigField "String", 'opensrp_url', '"https://boresha-afya.smartregister.org/opensrp/"' buildConfigField "String", 'opensrp_url_debug', '"https://boresha-afya-stage.smartregister.org/opensrp/"' - buildConfigField "String[]", "ALLOWED_LOCATION_LEVELS", '{"MOH Jhpiego Facility Name" , "Village"}' + buildConfigField "String[]", "ALLOWED_LOCATION_LEVELS", '{"Ward" , "Health Facility"}' buildConfigField "String[]", "ALLOWED_LOCATION_LEVELS_DEBUG", '{"MOH Jhpiego Facility Name" , "Village"}' - buildConfigField "String", 'DEFAULT_LOCATION', '"Village"' + buildConfigField "String", 'DEFAULT_LOCATION', '"Health Facility"' buildConfigField "String", 'DEFAULT_LOCATION_DEBUG', '"Village"' buildConfigField "boolean", 'SUPPORT_QR', 'true' buildConfigField "boolean", 'SUPPORT_REPORT', 'false' diff --git a/opensrp-chw/src/main/java/org/smartregister/chw/activity/ChildMedicalHistoryActivity.java b/opensrp-chw/src/main/java/org/smartregister/chw/activity/ChildMedicalHistoryActivity.java index 4f974f9948..7edbefde18 100644 --- a/opensrp-chw/src/main/java/org/smartregister/chw/activity/ChildMedicalHistoryActivity.java +++ b/opensrp-chw/src/main/java/org/smartregister/chw/activity/ChildMedicalHistoryActivity.java @@ -1,6 +1,7 @@ package org.smartregister.chw.activity; import android.app.Activity; + import org.smartregister.chw.core.activity.CoreChildMedicalHistoryActivity; public class ChildMedicalHistoryActivity extends CoreChildMedicalHistoryActivity { diff --git a/opensrp-chw/src/main/java/org/smartregister/chw/application/ChwApplication.java b/opensrp-chw/src/main/java/org/smartregister/chw/application/ChwApplication.java index 6cc37f3ef0..c5ac3c8eab 100644 --- a/opensrp-chw/src/main/java/org/smartregister/chw/application/ChwApplication.java +++ b/opensrp-chw/src/main/java/org/smartregister/chw/application/ChwApplication.java @@ -104,7 +104,7 @@ public void onCreate() { SyncStatusBroadcastReceiver.init(this); - LocationHelper.init(new ArrayList<>(Arrays.asList(BuildConfig.DEBUG ? BuildConfig.ALLOWED_LOCATION_LEVELS_DEBUG : BuildConfig.ALLOWED_LOCATION_LEVELS)), BuildConfig.DEBUG ? BuildConfig.DEFAULT_LOCATION_DEBUG: BuildConfig.DEFAULT_LOCATION); + LocationHelper.init(new ArrayList<>(Arrays.asList(BuildConfig.DEBUG ? BuildConfig.ALLOWED_LOCATION_LEVELS_DEBUG : BuildConfig.ALLOWED_LOCATION_LEVELS)), BuildConfig.DEBUG ? BuildConfig.DEFAULT_LOCATION_DEBUG : BuildConfig.DEFAULT_LOCATION); // set up processor FamilyLibrary.getInstance().setClientProcessorForJava(ChwClientProcessor.getInstance(getApplicationContext())); @@ -158,6 +158,11 @@ public FamilyMetadata getMetadata() { return metadata; } + @Override + public ArrayList getAllowedLocationLevels() { + return new ArrayList<>(Arrays.asList(BuildConfig.ALLOWED_LOCATION_LEVELS)); + } + @NotNull public Map getRegisteredActivities() { Map registeredActivities = new HashMap<>();