From 382b771528faa4e49a5012c8e58765e182e6555e Mon Sep 17 00:00:00 2001 From: rkodev <43806892+rkodev@users.noreply.github.com> Date: Wed, 7 Oct 2020 21:57:05 +0300 Subject: [PATCH] Allow save on submit --- opensrp-chw/build.gradle | 6 +++--- .../chw/application/ChwApplicationFlv.java | 5 +++++ .../chw/repository/ChwRepositoryFlv.java | 14 +++++++++++++- .../chw/application/ChwApplication.java | 6 ++++++ .../chw/application/DefaultChwApplicationFlv.java | 5 +++++ 5 files changed, 32 insertions(+), 4 deletions(-) diff --git a/opensrp-chw/build.gradle b/opensrp-chw/build.gradle index 48528fd918..77a39a1b91 100644 --- a/opensrp-chw/build.gradle +++ b/opensrp-chw/build.gradle @@ -257,7 +257,7 @@ android { dimension = 'baseDimension' applicationIdSuffix ".lmh" versionCode 1 - versionName "0.0.4" + versionName "0.0.5-rc1" buildConfigField "String", 'opensrp_url', '"https://lmh-liberia.smartregister.org/opensrp/"' buildConfigField "String", 'guidebooks_url', '"https://opensrp.s3.amazonaws.com/media/lmh/"' buildConfigField "String", 'opensrp_url_debug', '"https://lmh-stage.smartregister.org/opensrp/"' @@ -266,7 +266,7 @@ android { buildConfigField "String[]", "ALLOWED_LOCATION_LEVELS_DEBUG", '{"Clinic" , "CHSS" , "CHA"}' buildConfigField "String", 'DEFAULT_LOCATION', '"Village"' buildConfigField "String", 'DEFAULT_LOCATION_DEBUG', '"CHA"' - buildConfigField "int", "DATABASE_VERSION", '4' + buildConfigField "int", "DATABASE_VERSION", '5' } } @@ -276,7 +276,7 @@ android { } dependencies { - implementation('org.smartregister:opensrp-client-chw-core:1.5.5-SNAPSHOT@aar') { + implementation('org.smartregister:opensrp-client-chw-core:1.5.6-SNAPSHOT@aar') { transitive = true exclude group: 'com.android.support', module: 'appcompat-v7' exclude group: 'androidx.legacy', module: 'legacy-support-v4' 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 0736ea3f03..6a8f70fbd1 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 @@ -119,4 +119,9 @@ public boolean dueVaccinesFilterInChildRegister() { public boolean showAllChildServicesDueIncludingCurrentChild(){ return false; } + + @Override + public boolean saveOnSubmission() { + return true; + } } diff --git a/opensrp-chw/src/lmh/java/org/smartregister/chw/repository/ChwRepositoryFlv.java b/opensrp-chw/src/lmh/java/org/smartregister/chw/repository/ChwRepositoryFlv.java index e85a0212da..35b1ca1cea 100644 --- a/opensrp-chw/src/lmh/java/org/smartregister/chw/repository/ChwRepositoryFlv.java +++ b/opensrp-chw/src/lmh/java/org/smartregister/chw/repository/ChwRepositoryFlv.java @@ -4,6 +4,7 @@ import net.sqlcipher.database.SQLiteDatabase; +import org.smartregister.chw.anc.repository.VisitRepository; import org.smartregister.chw.util.RepositoryUtils; import org.smartregister.domain.db.Column; import org.smartregister.immunization.repository.RecurringServiceRecordRepository; @@ -36,6 +37,9 @@ public static void onUpgrade(Context context, SQLiteDatabase db, int oldVersion, case 4: upgradeToVersion4(db); break; + case 5: + upgradeToVersion5(db); + break; default: break; } @@ -106,7 +110,15 @@ private static void upgradeToVersion4(SQLiteDatabase db) { EventClientRepository.createTable(db, EventClientRepository.Table.foreignEvent, EventClientRepository.event_column.values()); EventClientRepository.createTable(db, EventClientRepository.Table.foreignClient, EventClientRepository.client_column.values()); } catch (Exception e) { - Timber.e(e, "upgradeToVersion3"); + Timber.e(e, "upgradeToVersion4"); + } + } + + private static void upgradeToVersion5(SQLiteDatabase db) { + try { + db.execSQL(VisitRepository.ADD_VISIT_GROUP_COLUMN); + } catch (Exception e) { + Timber.e(e, "upgradeToVersion5"); } } } \ No newline at end of file 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 a044ca092c..0acbca08ab 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 @@ -187,9 +187,13 @@ private void initializeLibraries() { // init libraries ImmunizationLibrary.init(context, getRepository(), null, BuildConfig.VERSION_CODE, BuildConfig.DATABASE_VERSION); + ImmunizationLibrary.getInstance().setAllowSyncImmediately(flavor.saveOnSubmission()); + ConfigurableViewsLibrary.init(context); FamilyLibrary.init(context, getMetadata(), BuildConfig.VERSION_CODE, BuildConfig.DATABASE_VERSION); AncLibrary.init(context, getRepository(), BuildConfig.VERSION_CODE, BuildConfig.DATABASE_VERSION); + AncLibrary.getInstance().setSubmitOnSave(flavor.saveOnSubmission()); + PncLibrary.init(context, getRepository(), BuildConfig.VERSION_CODE, BuildConfig.DATABASE_VERSION); MalariaLibrary.init(context, getRepository(), BuildConfig.VERSION_CODE, BuildConfig.DATABASE_VERSION); FpLibrary.init(context, getRepository(), BuildConfig.VERSION_CODE, BuildConfig.DATABASE_VERSION); @@ -407,6 +411,8 @@ public interface Flavor { boolean dueVaccinesFilterInChildRegister(); boolean showAllChildServicesDueIncludingCurrentChild(); + + boolean saveOnSubmission(); } } diff --git a/opensrp-chw/src/main/java/org/smartregister/chw/application/DefaultChwApplicationFlv.java b/opensrp-chw/src/main/java/org/smartregister/chw/application/DefaultChwApplicationFlv.java index eaf17c6d61..4d66badf88 100644 --- a/opensrp-chw/src/main/java/org/smartregister/chw/application/DefaultChwApplicationFlv.java +++ b/opensrp-chw/src/main/java/org/smartregister/chw/application/DefaultChwApplicationFlv.java @@ -177,4 +177,9 @@ public boolean dueVaccinesFilterInChildRegister() { public boolean showAllChildServicesDueIncludingCurrentChild(){ return true; } + + @Override + public boolean saveOnSubmission() { + return false; + } }