From 1abdecc8dc3b842d49c1b1316a4c1c6f905b1e0c Mon Sep 17 00:00:00 2001 From: rkodev <43806892+rkodev@users.noreply.github.com> Date: Mon, 14 Sep 2020 13:50:05 +0300 Subject: [PATCH 01/78] Upgrade core to v2.* --- opensrp-chw-core/build.gradle | 2 +- .../chw/core/activity/CoreAllClientsRegisterActivity.java | 7 +++++++ .../chw/core/activity/CoreChildRegisterActivity.java | 8 +++++++- .../chw/core/application/CoreChwApplication.java | 7 ++++--- .../chw/core/fragment/AddMemberFragment.java | 2 +- .../chw/core/fragment/CoreChildRegisterFragment.java | 2 +- .../chw/core/repository/CoreChwRepository.java | 4 ++++ 7 files changed, 25 insertions(+), 7 deletions(-) diff --git a/opensrp-chw-core/build.gradle b/opensrp-chw-core/build.gradle index 8a232daf56..dbe3b9bedd 100644 --- a/opensrp-chw-core/build.gradle +++ b/opensrp-chw-core/build.gradle @@ -127,7 +127,7 @@ dependencies { compileOnly 'com.ibm.fhir:fhir-model:4.2.3' - api('org.smartregister:opensrp-client-core:1.15.4-SNAPSHOT@aar') { + api('org.smartregister:opensrp-client-core:2.0.6-SNAPSHOT@aar') { transitive = true exclude group: 'com.github.bmelnychuk', module: 'atv' exclude group: 'com.google.guava', module: 'guava' diff --git a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/CoreAllClientsRegisterActivity.java b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/CoreAllClientsRegisterActivity.java index b1a13dd333..22cadbd66b 100644 --- a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/CoreAllClientsRegisterActivity.java +++ b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/CoreAllClientsRegisterActivity.java @@ -15,6 +15,8 @@ import org.smartregister.opd.presenter.BaseOpdRegisterActivityPresenter; import org.smartregister.view.fragment.BaseRegisterFragment; +import java.util.Map; + public class CoreAllClientsRegisterActivity extends BaseOpdRegisterActivity { @Override @@ -53,6 +55,11 @@ protected void onResumption() { } } + @Override + public void startFormActivity(String s, String s1, Map map) { + // to do + } + @Override public void switchToBaseFragment() { Intent intent = new Intent(this, CoreFamilyRegisterActivity.class); diff --git a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/CoreChildRegisterActivity.java b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/CoreChildRegisterActivity.java index c9ec7fe2d0..508211d10a 100644 --- a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/CoreChildRegisterActivity.java +++ b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/CoreChildRegisterActivity.java @@ -28,6 +28,7 @@ import java.util.Arrays; import java.util.List; +import java.util.Map; import timber.log.Timber; @@ -86,6 +87,11 @@ protected void onResumption() { } } + @Override + public void startFormActivity(String s, String s1, Map map) { + // code + } + @Override public void startFormActivity(String formName, String entityId, String metaData) { try { @@ -158,6 +164,6 @@ public void openFamilyListView() { @Override public void startRegistration() { - startFormActivity(Utils.metadata().familyRegister.formName, null, null); + startFormActivity(Utils.metadata().familyRegister.formName, null, ""); } } 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 a0e56ea981..3cfcb968e7 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 @@ -38,8 +38,8 @@ import org.smartregister.repository.UniqueIdRepository; import org.smartregister.sync.ClientProcessorForJava; import org.smartregister.sync.helper.ECSyncHelper; +import org.smartregister.view.activity.BaseLoginActivity; import org.smartregister.view.activity.DrishtiApplication; -import org.smartregister.view.activity.LoginActivity; import java.util.ArrayList; import java.util.List; @@ -62,7 +62,6 @@ public abstract class CoreChwApplication extends DrishtiApplication implements C protected ClientProcessorForJava clientProcessorForJava; private LocationRepository locationRepository; private ECSyncHelper ecSyncHelper; - private String password; private UniqueIdRepository uniqueIdRepository; private HIA2IndicatorsRepository hIA2IndicatorsRepository; private DailyTalliesRepository dailyTalliesRepository; @@ -153,7 +152,7 @@ public void onCreate() { @Override public void logoutCurrentUser() { - Intent intent = new Intent(getApplicationContext(), LoginActivity.class); + Intent intent = new Intent(getApplicationContext(), BaseLoginActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.addCategory(Intent.CATEGORY_HOME); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); @@ -162,6 +161,7 @@ public void logoutCurrentUser() { context.userService().logoutSession(); } + /* @Override public String getPassword() { if (password == null) { @@ -170,6 +170,7 @@ public String getPassword() { } return password; } + */ @Override public ClientProcessorForJava getClientProcessor() { diff --git a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/fragment/AddMemberFragment.java b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/fragment/AddMemberFragment.java index 259de25e7c..3fb5e7d779 100644 --- a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/fragment/AddMemberFragment.java +++ b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/fragment/AddMemberFragment.java @@ -83,7 +83,7 @@ public void onClick(View v) { ((CoreFamilyProfileActivity) context).startChildForm(CoreConstants.JSON_FORM.getChildRegister(), "", "", ""); dismiss(); } else if (i == R.id.layout_add_other_family_member) { - ((CoreFamilyProfileActivity) context).startFormActivity(CoreConstants.JSON_FORM.getFamilyMemberRegister(), null, null); + ((CoreFamilyProfileActivity) context).startFormActivity(CoreConstants.JSON_FORM.getFamilyMemberRegister(), null, ""); dismiss(); } } catch (Exception e) { diff --git a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/fragment/CoreChildRegisterFragment.java b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/fragment/CoreChildRegisterFragment.java index 714e6afab3..3e8e4ba40c 100644 --- a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/fragment/CoreChildRegisterFragment.java +++ b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/fragment/CoreChildRegisterFragment.java @@ -87,7 +87,7 @@ protected String getDefaultSortQuery() { @Override protected void startRegistration() { - ((CoreChildRegisterActivity) getActivity()).startFormActivity(CoreConstants.JSON_FORM.getChildRegister(), null, null); + ((CoreChildRegisterActivity) getActivity()).startFormActivity(CoreConstants.JSON_FORM.getChildRegister(), null, ""); //getActivity().startFormActivity(Utils.metadata().familyRegister.formName, null, null); } diff --git a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/repository/CoreChwRepository.java b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/repository/CoreChwRepository.java index fd39a547d8..a83b5b771a 100644 --- a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/repository/CoreChwRepository.java +++ b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/repository/CoreChwRepository.java @@ -109,6 +109,7 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { super.onUpgrade(db, oldVersion, newVersion); } + /** @Override public SQLiteDatabase getReadableDatabase() { String pass = CoreChwApplication.getInstance().getPassword(); @@ -118,7 +119,9 @@ public SQLiteDatabase getReadableDatabase() { throw new IllegalStateException("Password is blank"); } } + **/ + /** @Override public SQLiteDatabase getWritableDatabase() { String pass = CoreChwApplication.getInstance().getPassword(); @@ -128,6 +131,7 @@ public SQLiteDatabase getWritableDatabase() { throw new IllegalStateException("Password is blank"); } } + **/ @Override public synchronized SQLiteDatabase getWritableDatabase(String password) { From 089de1903756575369d674eb32338cff8075d741 Mon Sep 17 00:00:00 2001 From: rkodev <43806892+rkodev@users.noreply.github.com> Date: Mon, 14 Sep 2020 17:01:05 +0300 Subject: [PATCH 02/78] Update gradle version to aplha build --- gradle.properties | 2 +- opensrp-chw-core/build.gradle | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle.properties b/gradle.properties index ac76185fdf..e05136ea83 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -VERSION_NAME=1.4.9-SNAPSHOT +VERSION_NAME=1.4.9-alpha-SNAPSHOT VERSION_CODE=1 GROUP=org.smartregister POM_SETTING_DESCRIPTION=OpenSRP Client Chw Core Library diff --git a/opensrp-chw-core/build.gradle b/opensrp-chw-core/build.gradle index fd1c1ccc9e..7aec3e3a36 100644 --- a/opensrp-chw-core/build.gradle +++ b/opensrp-chw-core/build.gradle @@ -144,7 +144,7 @@ dependencies { exclude group: 'com.android.support', module: 'appcompat-v7' } - api('org.smartregister:opensrp-client-family:1.3.0-SNAPSHOT@aar') { + api('org.smartregister:opensrp-client-family:1.3.0-aplha-SNAPSHOT@aar') { transitive = true exclude group: 'org.smartregister', module: 'opensrp-client-core' exclude group: 'org.smartregister', module: 'opensrp-client-native-form' From f6487d1220c78a2e01ab4199549e67e1bae5faf9 Mon Sep 17 00:00:00 2001 From: rkodev <43806892+rkodev@users.noreply.github.com> Date: Mon, 14 Sep 2020 23:05:58 +0300 Subject: [PATCH 03/78] Fix months translation https://github.com/OpenSRP/opensrp-client-chw/issues/1336 --- gradle.properties | 2 +- .../java/org/smartregister/chw/core/utils/VisitVaccineUtil.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle.properties b/gradle.properties index e05136ea83..13de3d6574 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -VERSION_NAME=1.4.9-alpha-SNAPSHOT +VERSION_NAME=1.4.9-alpha1-SNAPSHOT VERSION_CODE=1 GROUP=org.smartregister POM_SETTING_DESCRIPTION=OpenSRP Client Chw Core Library diff --git a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/utils/VisitVaccineUtil.java b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/utils/VisitVaccineUtil.java index a0be052fde..b59b14ee16 100644 --- a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/utils/VisitVaccineUtil.java +++ b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/utils/VisitVaccineUtil.java @@ -422,7 +422,7 @@ public static String getVaccineTitle(String name, Context context) { return context.getString(R.string.at_birth); } - return name.replace("Weeks", context.getString(R.string.date_weeks)).toLowerCase() + return name.replace("Weeks", context.getString(R.string.date_weeks)) .replace("Months", context.getString(R.string.date_months)).toLowerCase(); } } From 895b0fe2ddfe9d4de02899b17304448605181150 Mon Sep 17 00:00:00 2001 From: Allan O Date: Tue, 15 Sep 2020 21:31:21 +0300 Subject: [PATCH 04/78] :arrow_up: Update native form dependency --- opensrp-chw-core/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opensrp-chw-core/build.gradle b/opensrp-chw-core/build.gradle index 7aec3e3a36..210157c75b 100644 --- a/opensrp-chw-core/build.gradle +++ b/opensrp-chw-core/build.gradle @@ -114,7 +114,7 @@ dependencies { exclude group: 'com.rengwuxian.materialedittext', module: 'library' } - api('org.smartregister:opensrp-client-native-form:1.14.1-SNAPSHOT@aar') { + api('org.smartregister:opensrp-client-native-form:1.14.3.1-SNAPSHOT@aar') { transitive = true exclude group: 'com.android.support', module: 'appcompat-v7' exclude group: 'com.android.support', module: 'cardview-v7' From f70710775a561276bd6bd0a54d2d73445ac8df6f Mon Sep 17 00:00:00 2001 From: Allan O Date: Wed, 16 Sep 2020 10:40:54 +0300 Subject: [PATCH 05/78] :recycle: Set status to expiry if on same date of expiry --- .../org/smartregister/chw/core/utils/ChwServiceSchedule.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/utils/ChwServiceSchedule.java b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/utils/ChwServiceSchedule.java index 257e5679e8..f839d7e32a 100644 --- a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/utils/ChwServiceSchedule.java +++ b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/utils/ChwServiceSchedule.java @@ -164,7 +164,7 @@ private static AlertStatus calculateAlertStatus(DateTime dueDateTime, DateTime e Calendar today = Calendar.getInstance(); standardiseCalendarDate(today); - if (expiredCal.getTimeInMillis() < today.getTimeInMillis()) {// expired + if (expiredCal.getTimeInMillis() <= today.getTimeInMillis()) {// expired return AlertStatus.expired; } else if (dueCal.getTimeInMillis() <= today.getTimeInMillis()) {// Due return AlertStatus.normal; From 759a3d400c51a5c15972cf691bed81625b8775cd Mon Sep 17 00:00:00 2001 From: Allan O Date: Thu, 17 Sep 2020 18:59:48 +0300 Subject: [PATCH 06/78] :arrow_up: Update Immunisation dependency --- gradle.properties | 2 +- opensrp-chw-core/build.gradle | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle.properties b/gradle.properties index 13de3d6574..5ffc826572 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -VERSION_NAME=1.4.9-alpha1-SNAPSHOT +VERSION_NAME=1.4.10-alpha1-SNAPSHOT VERSION_CODE=1 GROUP=org.smartregister POM_SETTING_DESCRIPTION=OpenSRP Client Chw Core Library diff --git a/opensrp-chw-core/build.gradle b/opensrp-chw-core/build.gradle index 210157c75b..47f2802a24 100644 --- a/opensrp-chw-core/build.gradle +++ b/opensrp-chw-core/build.gradle @@ -152,7 +152,7 @@ dependencies { exclude group: 'com.android.support', module: 'appcompat-v7' } - api('org.smartregister:opensrp-client-immunization:1.4.48-SNAPSHOT@aar') { + api('org.smartregister:opensrp-client-immunization:2.0.0-SNAPSHOT@aar') { transitive = true exclude group: 'org.smartregister', module: 'opensrp-client-core' exclude group: 'org.smartregister', module: 'opensrp-client-native-form' From ffa2f733540a2fa3c4d3f84086750f91d8be4aef Mon Sep 17 00:00:00 2001 From: Elly Kitoto Date: Wed, 23 Sep 2020 15:15:21 +0300 Subject: [PATCH 07/78] Setup Transifex Client Signed-off-by: Elly Kitoto --- .tx/config | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 .tx/config diff --git a/.tx/config b/.tx/config new file mode 100644 index 0000000000..dd4c05afe4 --- /dev/null +++ b/.tx/config @@ -0,0 +1,9 @@ +[main] +host = https://www.transifex.com + +[opensrp-client-chw-core.opensrp-chw-core-src-main-res-values-strings-xml--master] +file_filter = opensrp-chw-core/src/main/res/values-/strings.xml +source_file = opensrp-chw-core/src/main/res/values/strings.xml +source_lang = en +type = ANDROID + From d927ffd0399dc2d0c5e379139827e69d23553de3 Mon Sep 17 00:00:00 2001 From: Elly Kitoto Date: Wed, 23 Sep 2020 15:24:25 +0300 Subject: [PATCH 08/78] Pull recent translations Signed-off-by: Elly Kitoto --- .../src/main/res/values-fr/strings.xml | 37 ++++++++++++++++--- 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/opensrp-chw-core/src/main/res/values-fr/strings.xml b/opensrp-chw-core/src/main/res/values-fr/strings.xml index c2840b4163..ba6436d92a 100644 --- a/opensrp-chw-core/src/main/res/values-fr/strings.xml +++ b/opensrp-chw-core/src/main/res/values-fr/strings.xml @@ -123,13 +123,15 @@ Secondaire Université Enlever cette personne + Enlever la mère Information d\'enregistrement Enregistrement CPN Confirmation pour paludisme Visite de suivi du paludisme Diagnostic du paludisme Suivi de l\'enfant malade - Corriger enfant %1$s\'s détails + Corriger les détails de bébé %1$s + Enlever bébé %1$s Visite de %1$s faite Référer au centre de santé Mise à jour en cours... @@ -206,6 +208,7 @@ Sélectionner un nouveau chef de ménage %s adultes et %s enfants de moins de 5 ans + Fièvre Jaune Retour à profil de %1$s Depuis %1$s @@ -283,7 +286,7 @@ VISITE CPN A LA FORMATION SANITAIRE Carnet CPN - Td + VAT SP dose Analyse urinaire Dépistage VIH @@ -298,7 +301,7 @@ FAF reçu: {0} Examens effectués: {0} Carnet CPN reçu - Td{0} - fait {1} + VAT{0} - fait {1} SP dose{0}- fait {1} un deux @@ -375,7 +378,9 @@ ÂG ANNULER Références%s - + G: %s + Enfant: %s + Enfants: %s Aucun numéro de téléphone fourni Signes de danger de la CPN; Symptômes:%s %s, %s @@ -424,9 +429,23 @@ %s dose + {0} (MÈRE) + {0} (BÉBÉ) + Visites CPoN au Centre de Santé + Visites CPoN + Planification Familiale + Carte de vaccination enfant + Immunisations (à la naissance) + Allaitement maternel exclusif + Visite {0}: {} + Carte de vaccination enfant reçu: {0} + Date: {0} + VPO 0: {0} + BCG: {0} + - Vaccinations (%s) \n%s \n%s - Vaccinations (%s) \n%s + Immunisations (%s) (%s) \n%s \n%s + Immunisations (%s) (%s) \n%s Jours @@ -434,6 +453,12 @@ Mois Dernière visite il y a %1$s jours + G: %1$s + Signes de danger: %1$s + Action prise: %1$s + Village: %1$s + Évaluation de la santé ThinkMD + Plan de soins ThinkMD (%1$s) Revenir à tous les clients From 47d676d4ed88f6290f6ff7979c5c535c7ce32b7e Mon Sep 17 00:00:00 2001 From: rkodev <43806892+rkodev@users.noreply.github.com> Date: Wed, 23 Sep 2020 15:36:00 +0300 Subject: [PATCH 09/78] Fix sample app. Add ouath --- .../chw/hf/activity/FamilyRegisterActivity.java | 7 +++++++ .../hf/activity/ReferralRegisterActivity.java | 7 +++++++ .../chw/hf/activity/UpdatesRegisterActivity.java | 6 ++++++ .../chw/hf/sync/HfSyncConfiguration.java | 16 ++++++++++++++++ 4 files changed, 36 insertions(+) diff --git a/sample/src/main/java/org/smartregister/chw/hf/activity/FamilyRegisterActivity.java b/sample/src/main/java/org/smartregister/chw/hf/activity/FamilyRegisterActivity.java index 80889f8b5c..4492577f93 100644 --- a/sample/src/main/java/org/smartregister/chw/hf/activity/FamilyRegisterActivity.java +++ b/sample/src/main/java/org/smartregister/chw/hf/activity/FamilyRegisterActivity.java @@ -18,6 +18,8 @@ import org.smartregister.helper.BottomNavigationHelper; import org.smartregister.view.fragment.BaseRegisterFragment; +import java.util.Map; + public class FamilyRegisterActivity extends CoreFamilyRegisterActivity { public static void registerBottomNavigation(BottomNavigationHelper bottomNavigationHelper, @@ -68,4 +70,9 @@ protected void onCreate(Bundle savedInstanceState) { protected BaseRegisterFragment getRegisterFragment() { return new FamilyRegisterFragment(); } + + @Override + public void startFormActivity(String s, String s1, Map map) { + + } } diff --git a/sample/src/main/java/org/smartregister/chw/hf/activity/ReferralRegisterActivity.java b/sample/src/main/java/org/smartregister/chw/hf/activity/ReferralRegisterActivity.java index ded102b2fc..e46792c894 100644 --- a/sample/src/main/java/org/smartregister/chw/hf/activity/ReferralRegisterActivity.java +++ b/sample/src/main/java/org/smartregister/chw/hf/activity/ReferralRegisterActivity.java @@ -6,6 +6,8 @@ import org.smartregister.helper.BottomNavigationHelper; import org.smartregister.view.fragment.BaseRegisterFragment; +import java.util.Map; + public class ReferralRegisterActivity extends BaseReferralRegister { @Override @@ -23,6 +25,11 @@ protected BaseRegisterFragment getRegisterFragment() { return new ReferralRegisterFragment(); } + @Override + public void startFormActivity(String s, String s1, Map map) { + + } + @Override protected void registerBottomNavigation() { bottomNavigationHelper = new BottomNavigationHelper(); diff --git a/sample/src/main/java/org/smartregister/chw/hf/activity/UpdatesRegisterActivity.java b/sample/src/main/java/org/smartregister/chw/hf/activity/UpdatesRegisterActivity.java index 42decd757e..6f9a1d427a 100644 --- a/sample/src/main/java/org/smartregister/chw/hf/activity/UpdatesRegisterActivity.java +++ b/sample/src/main/java/org/smartregister/chw/hf/activity/UpdatesRegisterActivity.java @@ -12,6 +12,7 @@ import org.smartregister.view.fragment.BaseRegisterFragment; import java.util.List; +import java.util.Map; public class UpdatesRegisterActivity extends BaseChwNotificationRegister { @@ -35,6 +36,11 @@ protected Fragment[] getOtherFragments() { return new Fragment[0]; } + @Override + public void startFormActivity(String s, String s1, Map map) { + + } + @Override public void startFormActivity(String formName, String entityId, String metaData) { //Overridden not needed diff --git a/sample/src/main/java/org/smartregister/chw/hf/sync/HfSyncConfiguration.java b/sample/src/main/java/org/smartregister/chw/hf/sync/HfSyncConfiguration.java index 871ebba529..df6db12616 100644 --- a/sample/src/main/java/org/smartregister/chw/hf/sync/HfSyncConfiguration.java +++ b/sample/src/main/java/org/smartregister/chw/hf/sync/HfSyncConfiguration.java @@ -5,6 +5,7 @@ import org.smartregister.SyncFilter; import org.smartregister.chw.core.utils.Utils; import org.smartregister.chw.hf.BuildConfig; +import org.smartregister.view.activity.BaseLoginActivity; import java.util.Collections; import java.util.List; @@ -67,4 +68,19 @@ public List getSynchronizedLocationTags() { public String getTopAllowedLocationLevel() { return ""; } + + @Override + public String getOauthClientId() { + return null; + } + + @Override + public String getOauthClientSecret() { + return null; + } + + @Override + public Class getAuthenticationActivity() { + return null; + } } From 28bae8e27017c680b8789d23468b30f124543aeb Mon Sep 17 00:00:00 2001 From: rkodev <43806892+rkodev@users.noreply.github.com> Date: Wed, 23 Sep 2020 16:38:47 +0300 Subject: [PATCH 10/78] Move icon dimensions to xml --- gradle.properties | 2 +- opensrp-chw-core/build.gradle | 2 +- .../chw/core/provider/CoreRegisterProvider.java | 9 +++++---- opensrp-chw-core/src/main/res/values/dimens.xml | 5 ++++- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/gradle.properties b/gradle.properties index 5ffc826572..66de952844 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -VERSION_NAME=1.4.10-alpha1-SNAPSHOT +VERSION_NAME=1.4.10-alpha7-SNAPSHOT VERSION_CODE=1 GROUP=org.smartregister POM_SETTING_DESCRIPTION=OpenSRP Client Chw Core Library diff --git a/opensrp-chw-core/build.gradle b/opensrp-chw-core/build.gradle index 47f2802a24..1b11cf0e42 100644 --- a/opensrp-chw-core/build.gradle +++ b/opensrp-chw-core/build.gradle @@ -114,7 +114,7 @@ dependencies { exclude group: 'com.rengwuxian.materialedittext', module: 'library' } - api('org.smartregister:opensrp-client-native-form:1.14.3.1-SNAPSHOT@aar') { + api('org.smartregister:opensrp-client-native-form:1.14.5.0-beta1-SNAPSHOT@aar') { transitive = true exclude group: 'com.android.support', module: 'appcompat-v7' exclude group: 'com.android.support', module: 'cardview-v7' diff --git a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/provider/CoreRegisterProvider.java b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/provider/CoreRegisterProvider.java index a52ec8f977..3cdc2a0b30 100644 --- a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/provider/CoreRegisterProvider.java +++ b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/provider/CoreRegisterProvider.java @@ -86,16 +86,17 @@ public void getView(Cursor cursor, SmartRegisterClient client, RegisterViewHolde private void addImageView(RegisterViewHolder viewHolder, int res_id) { //Limit size of icons added to 3 - if (viewHolder.memberIcon instanceof LinearLayout) { + if (viewHolder.memberIcon instanceof LinearLayout) { LinearLayout iconsLayout = (LinearLayout) viewHolder.memberIcon; - if (iconsLayout.getChildCount() > 3) { + if (iconsLayout.getChildCount() > 3) { TextView counterTextView = (TextView) iconsLayout.getChildAt(iconsLayout.getChildCount() - 1); counterTextView.setText(context.getString(R.string.icons_counter, Integer.parseInt(counterTextView.getText().toString().substring(1)) + 1)); + counterTextView.setTextSize(context.getResources().getDimension(R.dimen.family_register_text_size)); } else if (iconsLayout.getChildCount() == 3) { addCounterTextView(iconsLayout); } else { ImageView imageView = new ImageView(context); - int size = convertDpToPixel(22, context); + int size = (int) context.getResources().getDimension(R.dimen.family_register_image_size);//convertDpToPixel(22, context); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); layoutParams.gravity = Gravity.CENTER; imageView.setLayoutParams(layoutParams); @@ -112,7 +113,7 @@ private void addCounterTextView(LinearLayout iconsLayout) { counterTextView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); counterTextView.setBackground(ContextCompat.getDrawable(context, R.drawable.counter_drawable)); counterTextView.setText(context.getString(R.string.icons_counter, 1)); - int size = convertDpToPixel(34, context); + int size = (int) context.getResources().getDimension(R.dimen.family_register_count_size);//convertDpToPixel(34, context); counterTextView.getLayoutParams().height = size; counterTextView.getLayoutParams().width = size; counterTextView.setGravity(Gravity.CENTER); diff --git a/opensrp-chw-core/src/main/res/values/dimens.xml b/opensrp-chw-core/src/main/res/values/dimens.xml index dc47d39350..4052b3bda1 100644 --- a/opensrp-chw-core/src/main/res/values/dimens.xml +++ b/opensrp-chw-core/src/main/res/values/dimens.xml @@ -69,4 +69,7 @@ 8dp 8dp - \ No newline at end of file + 5sp + 22dp + 34dp + \ No newline at end of file From 5b375544e49302e664d746e6d7e5f733a8e7bb15 Mon Sep 17 00:00:00 2001 From: rkodev <43806892+rkodev@users.noreply.github.com> Date: Wed, 23 Sep 2020 17:25:40 +0300 Subject: [PATCH 11/78] Remove static context objects from navigation drawer --- .../chw/core/adapter/NavigationAdapter.java | 15 +++++++-------- .../core/adapter/NavigationAdapterHost.java | 7 +++++++ .../chw/core/custom_views/NavigationMenu.java | 19 ++++++++++++++----- 3 files changed, 28 insertions(+), 13 deletions(-) create mode 100644 opensrp-chw-core/src/main/java/org/smartregister/chw/core/adapter/NavigationAdapterHost.java diff --git a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/adapter/NavigationAdapter.java b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/adapter/NavigationAdapter.java index 4b8a4cc028..75a5cff0c0 100644 --- a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/adapter/NavigationAdapter.java +++ b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/adapter/NavigationAdapter.java @@ -11,6 +11,7 @@ import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; +import org.apache.commons.lang3.StringUtils; import org.smartregister.chw.core.R; import org.smartregister.chw.core.listener.NavigationListener; import org.smartregister.chw.core.model.NavigationOption; @@ -23,27 +24,25 @@ public class NavigationAdapter extends RecyclerView.Adapter { private List navigationOptionList; - private String selectedView = CoreConstants.DrawerMenu.ALL_FAMILIES; private View.OnClickListener onClickListener; private Context context; private Map registeredActivities; + private NavigationAdapterHost host; - public NavigationAdapter(List navigationOptions, Activity context, Map registeredActivities) { + public NavigationAdapter(List navigationOptions, Activity context, Map registeredActivities, NavigationAdapterHost host) { this.navigationOptionList = navigationOptions; this.context = context; this.onClickListener = new NavigationListener(context, this); this.registeredActivities = registeredActivities; + this.host = host; } public String getSelectedView() { - if (selectedView == null || selectedView.equals("")) - setSelectedView(CoreConstants.DrawerMenu.ALL_FAMILIES); - - return selectedView; + return StringUtils.isBlank(host.getSelectedView()) ? CoreConstants.DrawerMenu.ALL_FAMILIES : host.getSelectedView(); } public void setSelectedView(String selectedView) { - this.selectedView = selectedView; + host.setSelectedView(selectedView); this.notifyDataSetChanged(); } @@ -65,7 +64,7 @@ public void onBindViewHolder(@NonNull MyViewHolder holder, int position) { holder.getView().setTag(model.getMenuTitle()); - if (selectedView != null && selectedView.equals(model.getMenuTitle())) { + if (host.getSelectedView().equals(model.getMenuTitle())) { holder.tvCount.setTextColor(context.getResources().getColor(R.color.navigation_item_selected)); holder.tvName.setTextColor(context.getResources().getColor(R.color.navigation_item_selected)); holder.ivIcon.setImageResource(model.getResourceActiveID()); diff --git a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/adapter/NavigationAdapterHost.java b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/adapter/NavigationAdapterHost.java new file mode 100644 index 0000000000..891c011f8e --- /dev/null +++ b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/adapter/NavigationAdapterHost.java @@ -0,0 +1,7 @@ +package org.smartregister.chw.core.adapter; + +public interface NavigationAdapterHost { + String getSelectedView(); + + void setSelectedView(String selectedView); +} diff --git a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/custom_views/NavigationMenu.java b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/custom_views/NavigationMenu.java index 2b4a52d14a..e9ec955fb2 100644 --- a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/custom_views/NavigationMenu.java +++ b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/custom_views/NavigationMenu.java @@ -30,6 +30,7 @@ import org.smartregister.chw.core.R; import org.smartregister.chw.core.activity.ChwP2pModeSelectActivity; import org.smartregister.chw.core.adapter.NavigationAdapter; +import org.smartregister.chw.core.adapter.NavigationAdapterHost; import org.smartregister.chw.core.application.CoreChwApplication; import org.smartregister.chw.core.contract.NavigationContract; import org.smartregister.chw.core.model.NavigationModel; @@ -54,7 +55,7 @@ import timber.log.Timber; -public class NavigationMenu implements NavigationContract.View, SyncStatusBroadcastReceiver.SyncStatusListener, DrawerLayout.DrawerListener { +public class NavigationMenu implements NavigationContract.View, SyncStatusBroadcastReceiver.SyncStatusListener, DrawerLayout.DrawerListener , NavigationAdapterHost { private static NavigationMenu instance; private static WeakReference activityWeakReference; private static CoreChwApplication application; @@ -73,6 +74,7 @@ public class NavigationMenu implements NavigationContract.View, SyncStatusBroadc private NavigationContract.Presenter mPresenter; private View parentView; private Timer timer; + private static String selectedView = CoreConstants.DrawerMenu.ALL_FAMILIES; public static void setupNavigationMenu(CoreChwApplication application, NavigationMenu.Flavour menuFlavor, NavigationModel.Flavor modelFlavor, Map registeredActivities, boolean showDeviceToDeviceSync) { @@ -275,10 +277,7 @@ private void registerNavigation(Activity parentActivity) { if (recyclerView != null) { List navigationOptions = mPresenter.getOptions(); - if (navigationAdapter == null) { - navigationAdapter = new NavigationAdapter(navigationOptions, parentActivity, registeredActivities); - } - + navigationAdapter = new NavigationAdapter(navigationOptions, parentActivity, registeredActivities, this); RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(parentActivity); recyclerView.setLayoutManager(mLayoutManager); recyclerView.setItemAnimator(new DefaultItemAnimator()); @@ -468,6 +467,16 @@ public DrawerLayout getDrawer() { return drawer; } + @Override + public String getSelectedView() { + return NavigationMenu.selectedView; + } + + @Override + public void setSelectedView(String selectedView) { + NavigationMenu.selectedView = selectedView; + } + public interface Flavour { List> getSupportedLanguages(); From a135d8077837051b84660e178c5c90f4b1a3090a Mon Sep 17 00:00:00 2001 From: rkodev <43806892+rkodev@users.noreply.github.com> Date: Wed, 23 Sep 2020 22:03:04 +0300 Subject: [PATCH 12/78] Add optional check for team id in authorization --- gradle.properties | 2 +- opensrp-chw-core/build.gradle | 2 +- .../chw/core/service/CoreAuthorizationService.java | 12 +++++++++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/gradle.properties b/gradle.properties index 66de952844..b020d2f6ec 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -VERSION_NAME=1.4.10-alpha7-SNAPSHOT +VERSION_NAME=1.4.10-alpha11-SNAPSHOT VERSION_CODE=1 GROUP=org.smartregister POM_SETTING_DESCRIPTION=OpenSRP Client Chw Core Library diff --git a/opensrp-chw-core/build.gradle b/opensrp-chw-core/build.gradle index 1b11cf0e42..111387d13b 100644 --- a/opensrp-chw-core/build.gradle +++ b/opensrp-chw-core/build.gradle @@ -127,7 +127,7 @@ dependencies { compileOnly 'com.ibm.fhir:fhir-model:4.2.3' - api('org.smartregister:opensrp-client-core:2.0.6-SNAPSHOT@aar') { + api('org.smartregister:opensrp-client-core:2.1.4-SNAPSHOT@aar') { transitive = true exclude group: 'com.github.bmelnychuk', module: 'atv' exclude group: 'com.google.guava', module: 'guava' diff --git a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/service/CoreAuthorizationService.java b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/service/CoreAuthorizationService.java index 6b488a935d..78c736284c 100644 --- a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/service/CoreAuthorizationService.java +++ b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/service/CoreAuthorizationService.java @@ -26,11 +26,21 @@ public class CoreAuthorizationService implements P2PAuthorizationService { private Map authorizationDetails = new HashMap<>(); + private boolean checkTeamId; + + public CoreAuthorizationService(boolean checkTeamId) { + this.checkTeamId = checkTeamId; + } + + public CoreAuthorizationService() { + this.checkTeamId = true; + } + @Override public void authorizeConnection(@NonNull final Map peerDeviceMap, @NonNull final AuthorizationCallback authorizationCallback) { getAuthorizationDetails(map -> { Object peerDeviceTeamId = peerDeviceMap.get(AllConstants.PeerToPeer.KEY_TEAM_ID); - if (peerDeviceTeamId instanceof String + if (!checkTeamId || peerDeviceTeamId instanceof String && peerDeviceTeamId.equals(map.get(AllConstants.PeerToPeer.KEY_TEAM_ID))) { Object peerDeviceLocationId = peerDeviceMap.get(CoreConstants.PEER_TO_PEER.LOCATION_ID); Object myLocationId = authorizationDetails.get(CoreConstants.PEER_TO_PEER.LOCATION_ID); From 24fa8e49b5a5b532be837886e1960e083a97cf45 Mon Sep 17 00:00:00 2001 From: Mstjamush Date: Tue, 27 Oct 2020 16:44:41 +0300 Subject: [PATCH 13/78] Testing Tuesday --- .../custom_views/FamilyFloatingMenuTest.java | 84 +++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 opensrp-chw-core/src/test/java/org/smartregister/chw/core/custom_views/FamilyFloatingMenuTest.java diff --git a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/custom_views/FamilyFloatingMenuTest.java b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/custom_views/FamilyFloatingMenuTest.java new file mode 100644 index 0000000000..dff8982fcc --- /dev/null +++ b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/custom_views/FamilyFloatingMenuTest.java @@ -0,0 +1,84 @@ +package org.smartregister.chw.core.custom_views; + +import android.view.View; + +import androidx.appcompat.app.AppCompatActivity; +import androidx.fragment.app.FragmentActivity; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.mockito.ArgumentCaptor; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.MockitoAnnotations; +import org.robolectric.Robolectric; +import org.smartregister.Context; +import org.smartregister.CoreLibrary; +import org.smartregister.chw.core.BaseUnitTest; +import org.smartregister.chw.core.listener.OnClickFloatingMenu; +import org.smartregister.commonregistry.CommonRepository; +import org.smartregister.receiver.SyncStatusBroadcastReceiver; + +import java.util.ArrayList; + +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.Mockito.when; + +public class FamilyFloatingMenuTest extends BaseUnitTest { + @Mock + private CommonRepository commonRepository; + + @Mock + private Context context; + + private FamilyFloatingMenu familyFloatingMenu; + + @Mock + private View view; + + @Mock + private OnClickFloatingMenu onClickFloatingMenu; + + @Before + public void setUp() { + MockitoAnnotations.initMocks(this); + familyFloatingMenu = Mockito.mock(FamilyFloatingMenu.class, Mockito.CALLS_REAL_METHODS); + + CoreLibrary.init(context); + when(context.commonrepository(anyString())).thenReturn(commonRepository); + FragmentActivity activity = Robolectric.buildActivity(AppCompatActivity.class).create().resume().get(); + Context.bindtypes = new ArrayList<>(); + SyncStatusBroadcastReceiver.init(activity); + + } + + @Test + public void whenSetupViewsAnswered() { + familyFloatingMenu.setClickListener(onClickFloatingMenu); + + ArgumentCaptor captor = ArgumentCaptor.forClass(OnClickFloatingMenu.class); + Mockito.verify(familyFloatingMenu, Mockito.times(1)).setClickListener(captor.capture()); + Assert.assertEquals(captor.getValue(), onClickFloatingMenu); + } + @Test + public void whenOnClickAnswered() { + Mockito.doNothing().when(familyFloatingMenu).onClick(view); + familyFloatingMenu.onClick(view); + + ArgumentCaptor captor = ArgumentCaptor.forClass(View.class); + Mockito.verify(familyFloatingMenu, Mockito.times(1)).onClick(captor.capture()); + Assert.assertEquals(captor.getValue(), view); + } + + @Test + public void whenRedrawAnswered() { + Mockito.doNothing().when(familyFloatingMenu).reDraw(true); + familyFloatingMenu.reDraw(true); + + ArgumentCaptor captor = ArgumentCaptor.forClass(Boolean.class); + Mockito.verify(familyFloatingMenu, Mockito.times(1)).reDraw(captor.capture()); + Assert.assertEquals(captor.getValue(), true); + } + +} From 13589e6060ebb32b52c681d4917616f882109347 Mon Sep 17 00:00:00 2001 From: rkodev <43806892+rkodev@users.noreply.github.com> Date: Fri, 30 Oct 2020 15:26:53 +0300 Subject: [PATCH 14/78] Upgrade native forms and family module --- gradle.properties | 2 +- opensrp-chw-core/build.gradle | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gradle.properties b/gradle.properties index 642ce766ac..b76ca00bb1 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -VERSION_NAME=1.5.14-SNAPSHOT +VERSION_NAME=1.5.14.0-apha2-SNAPSHOT VERSION_CODE=1 GROUP=org.smartregister POM_SETTING_DESCRIPTION=OpenSRP Client Chw Core Library diff --git a/opensrp-chw-core/build.gradle b/opensrp-chw-core/build.gradle index f306928719..63ef932af8 100644 --- a/opensrp-chw-core/build.gradle +++ b/opensrp-chw-core/build.gradle @@ -126,7 +126,7 @@ dependencies { exclude group: 'xpp3', module: 'xpp3' } - api('org.smartregister:opensrp-client-native-form:1.14.5.4-SNAPSHOT@aar') { + api('org.smartregister:opensrp-client-native-form:1.14.5.4-apha1-SNAPSHOT@aar') { transitive = true exclude group: 'com.android.support', module: 'appcompat-v7' exclude group: 'com.android.support', module: 'cardview-v7' @@ -158,7 +158,7 @@ dependencies { exclude group: 'com.android.support', module: 'appcompat-v7' } - api('org.smartregister:opensrp-client-family:1.3.1-SNAPSHOT@aar') { + api('org.smartregister:opensrp-client-family:1.3.1-alpha1-SNAPSHOT@aar') { transitive = true exclude group: 'org.smartregister', module: 'opensrp-client-core' exclude group: 'org.smartregister', module: 'opensrp-client-native-form' From b5955b68e7251bdfa66ddca6eed759d3e47db1d6 Mon Sep 17 00:00:00 2001 From: Allan O Date: Tue, 3 Nov 2020 12:58:25 +0300 Subject: [PATCH 15/78] :white_check_mark: Add CoreFamilyRemoveMemberPresenter tests --- .../CoreFamilyRemoveMemberPresenterTest.java | 84 +++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 opensrp-chw-core/src/test/java/org/smartregister/chw/core/presenter/CoreFamilyRemoveMemberPresenterTest.java diff --git a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/presenter/CoreFamilyRemoveMemberPresenterTest.java b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/presenter/CoreFamilyRemoveMemberPresenterTest.java new file mode 100644 index 0000000000..a3d62cc5a2 --- /dev/null +++ b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/presenter/CoreFamilyRemoveMemberPresenterTest.java @@ -0,0 +1,84 @@ +package org.smartregister.chw.core.presenter; + +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.mockito.ArgumentMatchers; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.MockitoAnnotations; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.rule.PowerMockRule; +import org.robolectric.util.ReflectionHelpers; +import org.smartregister.chw.core.contract.FamilyRemoveMemberContract; +import org.smartregister.commonregistry.CommonPersonObjectClient; +import org.smartregister.family.util.DBConstants; +import org.smartregister.opd.utils.OpdDbConstants; + +import java.lang.ref.WeakReference; +import java.util.HashMap; + + +@PrepareForTest(CoreFamilyRemoveMemberPresenter.class) +public class CoreFamilyRemoveMemberPresenterTest { + + @Rule + public PowerMockRule rule = new PowerMockRule(); + + @Mock + private FamilyRemoveMemberContract.View view; + + @Mock + FamilyRemoveMemberContract.Interactor interactor; + + @Mock + FamilyRemoveMemberContract.Model model; + + private CoreFamilyRemoveMemberPresenter removeMemberPresenter; + + private CommonPersonObjectClient commonPersonClient; + + private HashMap columnMaps; + + @Before + public void setUp() { + MockitoAnnotations.initMocks(this); + removeMemberPresenter = Mockito.mock(CoreFamilyRemoveMemberPresenter.class, Mockito.CALLS_REAL_METHODS); + ReflectionHelpers.setField(removeMemberPresenter, "viewReference", new WeakReference<>(view)); + ReflectionHelpers.setField(removeMemberPresenter, "interactor", interactor); + ReflectionHelpers.setField(removeMemberPresenter, "model", model); + ReflectionHelpers.setField(removeMemberPresenter, "familyHead", "family-head"); + ReflectionHelpers.setField(removeMemberPresenter, "primaryCaregiver", "primary-care-giver"); + ReflectionHelpers.setField(removeMemberPresenter, "familyBaseEntityId", "family-entity-id"); + + commonPersonClient = new CommonPersonObjectClient("test-case-id", new HashMap<>(), "test"); + columnMaps = new HashMap<>(); + + commonPersonClient.setColumnmaps(columnMaps); + } + + @Test + public void removeMemberStartsRemoveMemberForm() throws Exception { + columnMaps.put(DBConstants.KEY.BASE_ENTITY_ID, ""); + columnMaps.put(OpdDbConstants.KEY.REGISTER_TYPE, ""); + CoreFamilyRemoveMemberPresenter presenterSpy = PowerMockito.spy(removeMemberPresenter); + PowerMockito.doNothing().when(presenterSpy, "startRemoveMemberForm", ArgumentMatchers.any(CommonPersonObjectClient.class)); + presenterSpy.removeMember(commonPersonClient); + PowerMockito.verifyPrivate(presenterSpy).invoke("startRemoveMemberForm", ArgumentMatchers.any(CommonPersonObjectClient.class)); + } + + + @Test + public void removeFamilyHeadInvokesProcessFamilyMember() { + columnMaps.put(DBConstants.KEY.BASE_ENTITY_ID, "family-head"); + columnMaps.put(OpdDbConstants.KEY.REGISTER_TYPE, ""); + + removeMemberPresenter.removeMember(commonPersonClient); + Mockito.verify(interactor, Mockito.times(1)).processFamilyMember( + ArgumentMatchers.anyString(), + ArgumentMatchers.any(CommonPersonObjectClient.class), + ArgumentMatchers.any(CoreFamilyRemoveMemberPresenter.class)); + } + +} From e243c4963b311a518ed5cda98a0e464662ca92ff Mon Sep 17 00:00:00 2001 From: Allan O Date: Tue, 10 Nov 2020 10:51:05 +0300 Subject: [PATCH 16/78] :white_check_mark: Add tests --- .../CoreFamilyRemoveMemberPresenterTest.java | 45 ++++++++++++++++++- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/presenter/CoreFamilyRemoveMemberPresenterTest.java b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/presenter/CoreFamilyRemoveMemberPresenterTest.java index a3d62cc5a2..2b16efde92 100644 --- a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/presenter/CoreFamilyRemoveMemberPresenterTest.java +++ b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/presenter/CoreFamilyRemoveMemberPresenterTest.java @@ -1,5 +1,7 @@ package org.smartregister.chw.core.presenter; +import org.json.JSONObject; +import org.junit.Assert; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -30,10 +32,10 @@ public class CoreFamilyRemoveMemberPresenterTest { private FamilyRemoveMemberContract.View view; @Mock - FamilyRemoveMemberContract.Interactor interactor; + private FamilyRemoveMemberContract.Interactor interactor; @Mock - FamilyRemoveMemberContract.Model model; + private FamilyRemoveMemberContract.Model model; private CoreFamilyRemoveMemberPresenter removeMemberPresenter; @@ -81,4 +83,43 @@ public void removeFamilyHeadInvokesProcessFamilyMember() { ArgumentMatchers.any(CoreFamilyRemoveMemberPresenter.class)); } + @Test + public void removeEveryoneStartsRemovalForm() { + JSONObject form = Mockito.mock(JSONObject.class); + Mockito.when(model.prepareFamilyRemovalForm( + ArgumentMatchers.anyString(), + ArgumentMatchers.anyString(), + ArgumentMatchers.anyString())).thenReturn(form); + removeMemberPresenter.removeEveryone(ArgumentMatchers.anyString(), ArgumentMatchers.anyString()); + Mockito.verify(view, Mockito.times(1)).startJsonActivity(form); + } + + @Test + public void familyRemovedExecutesViewEveryoneRemoved(){ + removeMemberPresenter.onFamilyRemoved(false); + Mockito.verify(view, Mockito.times(0)).onEveryoneRemoved(); + removeMemberPresenter.onFamilyRemoved(true); + Mockito.verify(view, Mockito.times(1)).onEveryoneRemoved(); + } + + @Test + public void memberRemovedExecutesViewOnMemberRemoved(){ + removeMemberPresenter.memberRemoved("test-removal"); + Mockito.verify(view, Mockito.times(1)).onMemberRemoved("test-removal"); + } + + @Test + public void getMainConditionReturnsCorrectString() { + String mainCondition = String.format(" %s = '%s' and %s is null and %s is null ", + DBConstants.KEY.OBJECT_RELATIONAL_ID, "family-entity-id", + DBConstants.KEY.DATE_REMOVED, + DBConstants.KEY.DOD); + Assert.assertEquals(mainCondition, removeMemberPresenter.getMainCondition()); + } + + @Test + public void getDefaultSortQueryReturnsCorrectString() { + String defaultSortQuery = String.format(" %s ASC ", DBConstants.KEY.DOB); + Assert.assertEquals(defaultSortQuery, removeMemberPresenter.getDefaultSortQuery()); + } } From 3e8a15304c6e17fac379f1ab6ac9c9e210d55930 Mon Sep 17 00:00:00 2001 From: Allan O Date: Tue, 10 Nov 2020 10:58:31 +0300 Subject: [PATCH 17/78] :green_heart: Fix Codacy reported issue --- .../chw/core/presenter/CoreFamilyRemoveMemberPresenterTest.java | 1 + 1 file changed, 1 insertion(+) diff --git a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/presenter/CoreFamilyRemoveMemberPresenterTest.java b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/presenter/CoreFamilyRemoveMemberPresenterTest.java index 2b16efde92..62e64d6ae3 100644 --- a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/presenter/CoreFamilyRemoveMemberPresenterTest.java +++ b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/presenter/CoreFamilyRemoveMemberPresenterTest.java @@ -66,6 +66,7 @@ public void removeMemberStartsRemoveMemberForm() throws Exception { columnMaps.put(OpdDbConstants.KEY.REGISTER_TYPE, ""); CoreFamilyRemoveMemberPresenter presenterSpy = PowerMockito.spy(removeMemberPresenter); PowerMockito.doNothing().when(presenterSpy, "startRemoveMemberForm", ArgumentMatchers.any(CommonPersonObjectClient.class)); + Assert.assertNotNull(commonPersonClient); presenterSpy.removeMember(commonPersonClient); PowerMockito.verifyPrivate(presenterSpy).invoke("startRemoveMemberForm", ArgumentMatchers.any(CommonPersonObjectClient.class)); } From e6883b596767d16958a0797ee7c934821d409ceb Mon Sep 17 00:00:00 2001 From: rkodev <43806892+rkodev@users.noreply.github.com> Date: Tue, 10 Nov 2020 21:00:15 +0300 Subject: [PATCH 18/78] Remove deleted vaccines from history page --- gradle.properties | 2 +- .../org/smartregister/chw/core/dao/EventDao.java | 12 ++++++++++++ .../chw/core/sync/CoreClientProcessor.java | 15 +++++++++------ 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/gradle.properties b/gradle.properties index 03b6b5a328..0b383bc6c9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -VERSION_NAME=1.5.21-SNAPSHOT +VERSION_NAME=1.5.21-test3-SNAPSHOT VERSION_CODE=1 GROUP=org.smartregister POM_SETTING_DESCRIPTION=OpenSRP Client Chw Core Library diff --git a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/dao/EventDao.java b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/dao/EventDao.java index 89468b9fd3..b30bc017e4 100644 --- a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/dao/EventDao.java +++ b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/dao/EventDao.java @@ -1,5 +1,6 @@ package org.smartregister.chw.core.dao; +import org.apache.commons.lang3.StringUtils; import org.jetbrains.annotations.Nullable; import org.json.JSONException; import org.json.JSONObject; @@ -8,7 +9,9 @@ import org.smartregister.dao.AbstractDao; import org.smartregister.sync.helper.ECSyncHelper; +import java.util.HashMap; import java.util.List; +import java.util.Map; import timber.log.Timber; @@ -78,6 +81,15 @@ private static ECSyncHelper getEcSyncHelper() { } public static void deleteVaccineByFormSubmissionId(String submissionId) { + String sql0 = "delete from visit_details where visit_details_id in ( " + + " select vd.visit_details_id " + + " from visit_details vd " + + " inner join visits v on v.visit_id = vd.visit_id " + + " inner join vaccines va on va.name = visit_key and va.base_entity_id = v.base_entity_id " + + " where va.formSubmissionId = '" + submissionId + "' " + + ")"; + updateDB(sql0); + String sql = "delete from vaccines where formSubmissionId = '" + submissionId + "'"; updateDB(sql); } diff --git a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/sync/CoreClientProcessor.java b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/sync/CoreClientProcessor.java index 3896d18f32..984d95d018 100644 --- a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/sync/CoreClientProcessor.java +++ b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/sync/CoreClientProcessor.java @@ -82,7 +82,7 @@ public static void addVaccine(VaccineRepository vaccineRepository, Vaccine vacci } // if its an updated vaccine, delete the previous object - vaccineRepository.deleteVaccine(vaccine.getBaseEntityId(), vaccine.getName()); + //vaccineRepository.deleteVaccine(vaccine.getBaseEntityId(), vaccine.getName()); // Add the vaccine vaccineRepository.add(vaccine); @@ -327,12 +327,15 @@ protected void processEvents(ClientClassification clientClassification, Table va public void processDeleteEvent(Event event) { try { + String formSubmissionId = event.getDetails() == null ? "" : event.getDetails().get("deleted_form_submission_id"); // delete from vaccine table - EventDao.deleteVaccineByFormSubmissionId(event.getFormSubmissionId()); - // delete from visit table - EventDao.deleteVisitByFormSubmissionId(event.getFormSubmissionId()); - // delete from recurring service table - EventDao.deleteServiceByFormSubmissionId(event.getFormSubmissionId()); + if (StringUtils.isNotBlank(formSubmissionId)) { + EventDao.deleteVaccineByFormSubmissionId(formSubmissionId); + // delete from visit table + EventDao.deleteVisitByFormSubmissionId(formSubmissionId); + // delete from recurring service table + EventDao.deleteServiceByFormSubmissionId(formSubmissionId); + } Timber.d("Ending processDeleteEvent: %s", event.getEventId()); } catch (Exception e) { From 0c68970de16cbaea593a3044aedbccf071c0990b Mon Sep 17 00:00:00 2001 From: rkodev <43806892+rkodev@users.noreply.github.com> Date: Tue, 10 Nov 2020 21:00:51 +0300 Subject: [PATCH 19/78] Bump up version --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 0b383bc6c9..eb3cf14196 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -VERSION_NAME=1.5.21-test3-SNAPSHOT +VERSION_NAME=1.5.22-SNAPSHOT VERSION_CODE=1 GROUP=org.smartregister POM_SETTING_DESCRIPTION=OpenSRP Client Chw Core Library From 8f597282ebb4f01676e731981064bdcd534c7c4d Mon Sep 17 00:00:00 2001 From: rkodev <43806892+rkodev@users.noreply.github.com> Date: Tue, 10 Nov 2020 21:29:36 +0300 Subject: [PATCH 20/78] Add core client processor test --- .../smartregister/chw/core/dao/EventDao.java | 3 -- .../core/sync/CoreClientProcessorTest.java | 31 +++++++++++++++++++ 2 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 opensrp-chw-core/src/test/java/org/smartregister/chw/core/sync/CoreClientProcessorTest.java diff --git a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/dao/EventDao.java b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/dao/EventDao.java index b30bc017e4..e24c1dc139 100644 --- a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/dao/EventDao.java +++ b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/dao/EventDao.java @@ -1,6 +1,5 @@ package org.smartregister.chw.core.dao; -import org.apache.commons.lang3.StringUtils; import org.jetbrains.annotations.Nullable; import org.json.JSONException; import org.json.JSONObject; @@ -9,9 +8,7 @@ import org.smartregister.dao.AbstractDao; import org.smartregister.sync.helper.ECSyncHelper; -import java.util.HashMap; import java.util.List; -import java.util.Map; import timber.log.Timber; diff --git a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/sync/CoreClientProcessorTest.java b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/sync/CoreClientProcessorTest.java new file mode 100644 index 0000000000..a471203a28 --- /dev/null +++ b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/sync/CoreClientProcessorTest.java @@ -0,0 +1,31 @@ +package org.smartregister.chw.core.sync; + +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.MockitoAnnotations; +import org.smartregister.chw.core.BaseUnitTest; +import org.smartregister.immunization.domain.Vaccine; +import org.smartregister.immunization.repository.VaccineRepository; + +public class CoreClientProcessorTest extends BaseUnitTest { + + @Mock + private VaccineRepository vaccineRepository; + + @Before + public void setUp() { + MockitoAnnotations.initMocks(this); + } + + @Test + public void testAddVaccine() { + Vaccine vaccine = new Vaccine(); + vaccine.setName("MEASLES 1"); + + CoreClientProcessor.addVaccine(vaccineRepository, vaccine); + Mockito.verify(vaccineRepository).add(vaccine); + Mockito.verify(vaccineRepository).updateFtsSearch(Mockito.any()); + } +} From 0e5720c71b81381e6715b1ea88e2316739f0b4f8 Mon Sep 17 00:00:00 2001 From: rkodev <43806892+rkodev@users.noreply.github.com> Date: Tue, 10 Nov 2020 21:54:25 +0300 Subject: [PATCH 21/78] Prevent NPE when generating schedules --- .../org/smartregister/chw/core/utils/VisitVaccineUtil.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/utils/VisitVaccineUtil.java b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/utils/VisitVaccineUtil.java index bc219fe7b8..fc845e9bc0 100644 --- a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/utils/VisitVaccineUtil.java +++ b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/utils/VisitVaccineUtil.java @@ -53,10 +53,10 @@ public static Map getAllVaccines() { List allVacs = new ArrayList<>(); - List woman = ImmunizationLibrary.getVaccineCacheMap().get("woman").vaccineRepo; + List woman = ImmunizationLibrary.getVaccineCacheMap().get("woman").vaccineRepo; allVacs.addAll(woman); - List child = ImmunizationLibrary.getVaccineCacheMap().get("child").vaccineRepo; + List child = ImmunizationLibrary.getVaccineCacheMap().get("child").vaccineRepo; allVacs.addAll(child); for (VaccineRepo.Vaccine vaccine : allVacs) { @@ -281,6 +281,7 @@ public static List getInMemoryAlerts( try { if (vaccineSchedules != null && vaccineSchedules.containsKey(vaccineCategory)) { for (VaccineSchedule curSchedule : vaccineSchedules.get(vaccineCategory).values()) { + if (curSchedule == null) continue; Alert curAlert = curSchedule.getOfflineAlert(baseEntityId, dob.toDate(), issuedVaccines); if (curAlert != null && curAlert.startDate() != null) { generatedAlerts.add(curAlert); From 1cce2f6e2b97645f997db7c43a1cb4bb2522b70d Mon Sep 17 00:00:00 2001 From: rkodev <43806892+rkodev@users.noreply.github.com> Date: Wed, 11 Nov 2020 14:05:22 +0300 Subject: [PATCH 22/78] Update CoreMalariaProfileContract to interface instead of class --- .../chw/core/contract/CoreMalariaProfileContract.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/contract/CoreMalariaProfileContract.java b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/contract/CoreMalariaProfileContract.java index bb647bcd81..de2915aaa3 100644 --- a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/contract/CoreMalariaProfileContract.java +++ b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/contract/CoreMalariaProfileContract.java @@ -4,18 +4,18 @@ import org.smartregister.chw.malaria.contract.MalariaProfileContract; import org.smartregister.repository.AllSharedPreferences; -public class CoreMalariaProfileContract { - public interface View extends MalariaProfileContract.View { +public interface CoreMalariaProfileContract { + interface View extends MalariaProfileContract.View { void startFormActivity(JSONObject formJson); } - public interface Presenter extends MalariaProfileContract.Presenter { + interface Presenter extends MalariaProfileContract.Presenter { void startHfMalariaFollowupForm(); void createHfMalariaFollowupEvent(AllSharedPreferences allSharedPreferences, String jsonString, String entityID) throws Exception; } - public interface Interactor extends MalariaProfileContract.Interactor { + interface Interactor extends MalariaProfileContract.Interactor { void createHfMalariaFollowupEvent(AllSharedPreferences allSharedPreferences, String jsonString, String entityIDd) throws Exception; } } From 87833cf229a77cc8aa665b5b8ef1e1d7f6d8683f Mon Sep 17 00:00:00 2001 From: rkodev <43806892+rkodev@users.noreply.github.com> Date: Wed, 11 Nov 2020 15:13:05 +0300 Subject: [PATCH 23/78] Fix sample app --- sample/build.gradle | 19 +++++++++++++++++++ .../chw/hf/custom_view/HfNavigationMenu.java | 10 ++++++++++ 2 files changed, 29 insertions(+) diff --git a/sample/build.gradle b/sample/build.gradle index efa3539057..fc1f311ea2 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -97,6 +97,25 @@ android { } } + // avoid errors with message 'Duplicate files copied in APK ...' + packagingOptions { + exclude 'META-INF/DEPENDENCIES.txt' + exclude 'META-INF/LICENSE.txt' + exclude 'META-INF/NOTICE.txt' + exclude 'META-INF/NOTICE' + exclude 'META-INF/NOTICE.md' + exclude 'META-INF/LICENSE' + exclude 'META-INF/LICENSE.md' + exclude 'META-INF/DEPENDENCIES' + exclude 'META-INF/notice.txt' + exclude 'META-INF/license.txt' + exclude 'META-INF/dependencies.txt' + exclude 'META-INF/LGPL2.1' + exclude 'LICENSE.txt' + exclude 'META-INF/LICENSE.md' + exclude 'META-INF/NOTICE.md' + } + lintOptions { checkReleaseBuilds false abortOnError false diff --git a/sample/src/main/java/org/smartregister/chw/hf/custom_view/HfNavigationMenu.java b/sample/src/main/java/org/smartregister/chw/hf/custom_view/HfNavigationMenu.java index f04abb0fcd..eea0bd358c 100644 --- a/sample/src/main/java/org/smartregister/chw/hf/custom_view/HfNavigationMenu.java +++ b/sample/src/main/java/org/smartregister/chw/hf/custom_view/HfNavigationMenu.java @@ -47,6 +47,16 @@ public Intent getServiceReportIntent(Activity activity) { return new Intent(activity, HIA2ReportsActivity.class); } + @Override + public String childNavigationMenuCountString() { + return null; + } + + @Override + public Intent getHIA2ReportActivityIntent(Activity activity) { + return null; + } + @Override public boolean hasCommunityResponders() { return false; From 24b886e3478c9a49ec3dfab664e944fbdcc81b6e Mon Sep 17 00:00:00 2001 From: rkodev <43806892+rkodev@users.noreply.github.com> Date: Wed, 11 Nov 2020 20:31:18 +0300 Subject: [PATCH 24/78] Upclient processor --- .../chw/core/sync/CoreClientProcessor.java | 86 +++++++++++++++---- 1 file changed, 68 insertions(+), 18 deletions(-) diff --git a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/sync/CoreClientProcessor.java b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/sync/CoreClientProcessor.java index 984d95d018..fa5b6b01e5 100644 --- a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/sync/CoreClientProcessor.java +++ b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/sync/CoreClientProcessor.java @@ -3,6 +3,8 @@ import android.content.ContentValues; import android.content.Context; +import net.sqlcipher.database.SQLiteDatabase; + import org.apache.commons.lang3.StringUtils; import org.smartregister.chw.anc.util.DBConstants; import org.smartregister.chw.anc.util.NCUtils; @@ -52,6 +54,7 @@ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; +import java.util.HashMap; import java.util.List; import java.util.Locale; import java.util.Map; @@ -237,7 +240,7 @@ protected void processEvents(ClientClassification clientClassification, Table va if (eventClient.getClient() == null) { return; } - processRemoveMember(eventClient.getClient().getBaseEntityId(), event.getEventDate().toDate()); + processRemoveMember(eventClient.getClient().getBaseEntityId(), event); break; case FamilyPlanningConstants.EventType.FAMILY_PLANNING_CHANGE_METHOD: clientProcessByObs(eventClient, clientClassification, event, "reason_stop_fp_chw", "decided_to_change_method"); @@ -278,7 +281,7 @@ protected void processEvents(ClientClassification clientClassification, Table va if (eventClient.getClient() == null) { return; } - processRemoveChild(eventClient.getClient().getBaseEntityId(), event.getEventDate().toDate()); + processRemoveChild(eventClient.getClient().getBaseEntityId(), event); break; case CoreConstants.EventType.CHILD_VACCINE_CARD_RECEIVED: if (eventClient.getClient() == null) { @@ -628,9 +631,33 @@ private void processRemoveFamily(String familyID, Date eventDate) { } } - private void processRemoveMember(String baseEntityId, Date eventDate) { + private SQLiteDatabase getWritableDatabase() { + return CoreChwApplication.getInstance().getRepository().getWritableDatabase(); + } - Date myEventDate = eventDate; + private Map readObs(Event event) { + Map obsMap = new HashMap<>(); + if (event.getObs() != null) { + for (Obs obs : event.getObs()) { + if (obs.getValues().size() > 0) + obsMap.put(obs.getFormSubmissionField(), obs.getValues().get(0).toString()); + } + } + return obsMap; + } + + private Date getDate(Map obsMap, String key) throws ParseException { + String strDod = obsMap.get(key); + if (StringUtils.isBlank(strDod)) return null; + + SimpleDateFormat defaultDf = new SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH); + SimpleDateFormat nfDf = new SimpleDateFormat("dd-MM-yyyy", Locale.ENGLISH); + return nfDf.parse(strDod); + } + + private void processRemoveMember(String baseEntityId, Event event) { + + Date myEventDate = event.getEventDate().toDate(); if (myEventDate == null) { myEventDate = new Date(); } @@ -639,28 +666,40 @@ private void processRemoveMember(String baseEntityId, Date eventDate) { return; } + SimpleDateFormat defaultDf = new SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH); + Map obsMap = readObs(event); + AllCommonsRepository commonsRepository = CoreChwApplication.getInstance().getAllCommonsRepository(CoreConstants.TABLE_NAME.FAMILY_MEMBER); if (commonsRepository != null) { ContentValues values = new ContentValues(); - values.put(DBConstants.KEY.DATE_REMOVED, new SimpleDateFormat("yyyy-MM-dd").format(myEventDate)); + values.put(DBConstants.KEY.DATE_REMOVED, defaultDf.format(myEventDate)); values.put("is_closed", 1); - CoreChwApplication.getInstance().getRepository().getWritableDatabase().update(CoreConstants.TABLE_NAME.FAMILY_MEMBER, values, - DBConstants.KEY.BASE_ENTITY_ID + " = ? ", new String[]{baseEntityId}); - // clean fts table - CoreChwApplication.getInstance().getRepository().getWritableDatabase().update(CommonFtsObject.searchTableName(CoreConstants.TABLE_NAME.FAMILY_MEMBER), values, + getWritableDatabase().update(CommonFtsObject.searchTableName(CoreConstants.TABLE_NAME.FAMILY_MEMBER), values, " object_id = ? ", new String[]{baseEntityId}); + + try { + Date dod = getDate(obsMap, "date_died"); + if (dod != null) + values.put(DBConstants.KEY.DOD, defaultDf.format(dod)); + } catch (ParseException e) { + Timber.e(e); + } + + getWritableDatabase().update(CoreConstants.TABLE_NAME.FAMILY_MEMBER, values, + DBConstants.KEY.BASE_ENTITY_ID + " = ? ", new String[]{baseEntityId}); + // Utils.context().commonrepository(CoreConstants.TABLE_NAME.FAMILY_MEMBER).populateSearchValues(baseEntityId, DBConstants.KEY.DATE_REMOVED, new SimpleDateFormat("yyyy-MM-dd").format(eventDate), null); - CoreChwApplication.getInstance().getContext().alertService().deleteOfflineAlerts(baseEntityId); + //CoreChwApplication.getInstance().getContext().alertService().deleteOfflineAlerts(baseEntityId); } } - private void processRemoveChild(String baseEntityId, Date eventDate) { + private void processRemoveChild(String baseEntityId, Event event) { - Date myEventDate = eventDate; + Date myEventDate = event.getEventDate().toDate(); if (myEventDate == null) { myEventDate = new Date(); } @@ -669,22 +708,33 @@ private void processRemoveChild(String baseEntityId, Date eventDate) { return; } + Map obsMap = readObs(event); + SimpleDateFormat defaultDf = new SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH); + AllCommonsRepository commonsRepository = CoreChwApplication.getInstance().getAllCommonsRepository(CoreConstants.TABLE_NAME.CHILD); if (commonsRepository != null) { ContentValues values = new ContentValues(); - values.put(DBConstants.KEY.DATE_REMOVED, new SimpleDateFormat("yyyy-MM-dd").format(myEventDate)); + values.put(DBConstants.KEY.DATE_REMOVED, defaultDf.format(myEventDate)); values.put("is_closed", 1); - CoreChwApplication.getInstance().getRepository().getWritableDatabase().update(CoreConstants.TABLE_NAME.CHILD, values, - DBConstants.KEY.BASE_ENTITY_ID + " = ? ", new String[]{baseEntityId}); - // clean fts table - CoreChwApplication.getInstance().getRepository().getWritableDatabase().update(CommonFtsObject.searchTableName(CoreConstants.TABLE_NAME.CHILD), values, + getWritableDatabase().update(CommonFtsObject.searchTableName(CoreConstants.TABLE_NAME.CHILD), values, CommonFtsObject.idColumn + " = ? ", new String[]{baseEntityId}); + try { + Date dod = getDate(obsMap, "date_died"); + if (dod != null) + values.put(DBConstants.KEY.DOD, defaultDf.format(dod)); + } catch (ParseException e) { + Timber.e(e); + } + + getWritableDatabase().update(CoreConstants.TABLE_NAME.CHILD, values, + DBConstants.KEY.BASE_ENTITY_ID + " = ? ", new String[]{baseEntityId}); + // Utils.context().commonrepository(CoreConstants.TABLE_NAME.CHILD).populateSearchValues(baseEntityId, DBConstants.KEY.DATE_REMOVED, new SimpleDateFormat("yyyy-MM-dd").format(eventDate), null); - CoreChwApplication.getInstance().getContext().alertService().deleteOfflineAlerts(baseEntityId); + //CoreChwApplication.getInstance().getContext().alertService().deleteOfflineAlerts(baseEntityId); } } From 76fcdc2126f6fb065aefd5c88c67d221cd59a1f2 Mon Sep 17 00:00:00 2001 From: rkodev <43806892+rkodev@users.noreply.github.com> Date: Wed, 11 Nov 2020 20:31:45 +0300 Subject: [PATCH 25/78] Update gradle properties --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index eb3cf14196..cc0b27942a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -VERSION_NAME=1.5.22-SNAPSHOT +VERSION_NAME=1.5.23-SNAPSHOT VERSION_CODE=1 GROUP=org.smartregister POM_SETTING_DESCRIPTION=OpenSRP Client Chw Core Library From 1f10699187565089ec42a3f6188dfa76e3fa3c51 Mon Sep 17 00:00:00 2001 From: rkodev <43806892+rkodev@users.noreply.github.com> Date: Wed, 11 Nov 2020 20:35:32 +0300 Subject: [PATCH 26/78] Codacy cleanup --- .../org/smartregister/chw/core/sync/CoreClientProcessor.java | 1 - 1 file changed, 1 deletion(-) diff --git a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/sync/CoreClientProcessor.java b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/sync/CoreClientProcessor.java index fa5b6b01e5..19b03391d3 100644 --- a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/sync/CoreClientProcessor.java +++ b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/sync/CoreClientProcessor.java @@ -650,7 +650,6 @@ private Date getDate(Map obsMap, String key) throws ParseExcepti String strDod = obsMap.get(key); if (StringUtils.isBlank(strDod)) return null; - SimpleDateFormat defaultDf = new SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH); SimpleDateFormat nfDf = new SimpleDateFormat("dd-MM-yyyy", Locale.ENGLISH); return nfDf.parse(strDod); } From 4e606f94834b77ae92a2dffbc944f6f430c2cd04 Mon Sep 17 00:00:00 2001 From: rkodev <43806892+rkodev@users.noreply.github.com> Date: Thu, 12 Nov 2020 19:19:14 +0300 Subject: [PATCH 27/78] Service model --- .../chw/core/model/ServiceTaskModel.java | 26 ------------------- 1 file changed, 26 deletions(-) delete mode 100644 opensrp-chw-core/src/main/java/org/smartregister/chw/core/model/ServiceTaskModel.java diff --git a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/model/ServiceTaskModel.java b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/model/ServiceTaskModel.java deleted file mode 100644 index 754ee59b3a..0000000000 --- a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/model/ServiceTaskModel.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.smartregister.chw.core.model; - -import org.smartregister.immunization.domain.ServiceWrapper; - -import java.util.Map; - -public class ServiceTaskModel { - private Map givenServiceMap; - private Map notGivenServiceMap; - - public Map getGivenServiceMap() { - return givenServiceMap; - } - - public void setGivenServiceMap(Map givenServiceMap) { - this.givenServiceMap = givenServiceMap; - } - - public Map getNotGivenServiceMap() { - return notGivenServiceMap; - } - - public void setNotGivenServiceMap(Map notGivenServiceMap) { - this.notGivenServiceMap = notGivenServiceMap; - } -} From f222de022cc705f48e4376e8c76647f2c2382dc9 Mon Sep 17 00:00:00 2001 From: rkodev <43806892+rkodev@users.noreply.github.com> Date: Thu, 12 Nov 2020 21:05:27 +0300 Subject: [PATCH 28/78] Add tests --- .../chw/core/sync/CoreClientProcessor.java | 2 +- .../core/sync/CoreClientProcessorTest.java | 38 +++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/sync/CoreClientProcessor.java b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/sync/CoreClientProcessor.java index 19b03391d3..b5bc6e65c4 100644 --- a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/sync/CoreClientProcessor.java +++ b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/sync/CoreClientProcessor.java @@ -170,7 +170,7 @@ private Table getServiceTable() { return serviceTable; } - protected void processEvents(ClientClassification clientClassification, Table vaccineTable, Table serviceTable, EventClient eventClient, Event event, String eventType) throws Exception { + public void processEvents(ClientClassification clientClassification, Table vaccineTable, Table serviceTable, EventClient eventClient, Event event, String eventType) throws Exception { switch (eventType) { case VaccineIntentService.EVENT_TYPE: case VaccineIntentService.EVENT_TYPE_OUT_OF_CATCHMENT: diff --git a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/sync/CoreClientProcessorTest.java b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/sync/CoreClientProcessorTest.java index a471203a28..121a8ad191 100644 --- a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/sync/CoreClientProcessorTest.java +++ b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/sync/CoreClientProcessorTest.java @@ -1,16 +1,38 @@ package org.smartregister.chw.core.sync; +import android.content.Context; + import org.junit.Before; import org.junit.Test; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.MockitoAnnotations; import org.smartregister.chw.core.BaseUnitTest; +import org.smartregister.domain.Client; +import org.smartregister.domain.Event; +import org.smartregister.domain.db.EventClient; +import org.smartregister.domain.jsonmapping.ClientClassification; +import org.smartregister.domain.jsonmapping.Table; import org.smartregister.immunization.domain.Vaccine; import org.smartregister.immunization.repository.VaccineRepository; +import java.util.ArrayList; +import java.util.List; + public class CoreClientProcessorTest extends BaseUnitTest { + @Mock + private ClientClassification classification; + + @Mock + private Table vaccineTable; + + @Mock + private Table serviceTable; + + @Mock + private Context context; + @Mock private VaccineRepository vaccineRepository; @@ -28,4 +50,20 @@ public void testAddVaccine() { Mockito.verify(vaccineRepository).add(vaccine); Mockito.verify(vaccineRepository).updateFtsSearch(Mockito.any()); } + + @Test + public void testProcessClient() throws Exception { + CoreClientProcessor processor = Mockito.spy(new CoreClientProcessor(context)); + Mockito.doNothing().when(processor).processEvents(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any()); + + List eventClients = new ArrayList<>(); + Event event = new Event(); + event.setEventType("Remove Family"); + EventClient eventClient = new EventClient(event, Mockito.mock(Client.class)); + eventClients.add(eventClient); + eventClients.add(eventClient); + + processor.processClient(eventClients); + Mockito.verify(processor, Mockito.times(2)).processEvents(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any()); + } } From 473697cc896c2a3f97256f8558830af8cc807030 Mon Sep 17 00:00:00 2001 From: rkodev <43806892+rkodev@users.noreply.github.com> Date: Thu, 12 Nov 2020 21:10:26 +0300 Subject: [PATCH 29/78] Add tests --- .../chw/core/sync/CoreClientProcessorTest.java | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/sync/CoreClientProcessorTest.java b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/sync/CoreClientProcessorTest.java index 121a8ad191..fe6c3094e8 100644 --- a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/sync/CoreClientProcessorTest.java +++ b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/sync/CoreClientProcessorTest.java @@ -11,8 +11,6 @@ import org.smartregister.domain.Client; import org.smartregister.domain.Event; import org.smartregister.domain.db.EventClient; -import org.smartregister.domain.jsonmapping.ClientClassification; -import org.smartregister.domain.jsonmapping.Table; import org.smartregister.immunization.domain.Vaccine; import org.smartregister.immunization.repository.VaccineRepository; @@ -21,15 +19,6 @@ public class CoreClientProcessorTest extends BaseUnitTest { - @Mock - private ClientClassification classification; - - @Mock - private Table vaccineTable; - - @Mock - private Table serviceTable; - @Mock private Context context; From eabd23b281b635c7ceb4474e61bec41e0d5f6c2f Mon Sep 17 00:00:00 2001 From: rkodev <43806892+rkodev@users.noreply.github.com> Date: Fri, 13 Nov 2020 11:19:21 +0300 Subject: [PATCH 30/78] Trigger Build From 39bad3c0e49fecae6c0a6a6e53362ceaca3136c4 Mon Sep 17 00:00:00 2001 From: rkodev <43806892+rkodev@users.noreply.github.com> Date: Fri, 13 Nov 2020 11:26:12 +0300 Subject: [PATCH 31/78] Trigger Build From 88c992df14d08f0c0e40c325fbec98284e315a97 Mon Sep 17 00:00:00 2001 From: rkodev <43806892+rkodev@users.noreply.github.com> Date: Fri, 13 Nov 2020 17:55:07 +0300 Subject: [PATCH 32/78] Fix edit vaccine history --- gradle.properties | 2 +- .../java/org/smartregister/chw/core/dao/EventDao.java | 9 --------- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/gradle.properties b/gradle.properties index cc0b27942a..68c8b2bf5d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -VERSION_NAME=1.5.23-SNAPSHOT +VERSION_NAME=1.5.24-SNAPSHOT VERSION_CODE=1 GROUP=org.smartregister POM_SETTING_DESCRIPTION=OpenSRP Client Chw Core Library diff --git a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/dao/EventDao.java b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/dao/EventDao.java index e24c1dc139..89468b9fd3 100644 --- a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/dao/EventDao.java +++ b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/dao/EventDao.java @@ -78,15 +78,6 @@ private static ECSyncHelper getEcSyncHelper() { } public static void deleteVaccineByFormSubmissionId(String submissionId) { - String sql0 = "delete from visit_details where visit_details_id in ( " + - " select vd.visit_details_id " + - " from visit_details vd " + - " inner join visits v on v.visit_id = vd.visit_id " + - " inner join vaccines va on va.name = visit_key and va.base_entity_id = v.base_entity_id " + - " where va.formSubmissionId = '" + submissionId + "' " + - ")"; - updateDB(sql0); - String sql = "delete from vaccines where formSubmissionId = '" + submissionId + "'"; updateDB(sql); } From e30e79d820ee73358fdaaf075a942f4a614accda Mon Sep 17 00:00:00 2001 From: rkodev <43806892+rkodev@users.noreply.github.com> Date: Sat, 14 Nov 2020 15:25:23 +0300 Subject: [PATCH 33/78] Update core version --- gradle.properties | 2 +- opensrp-chw-core/build.gradle | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle.properties b/gradle.properties index 68c8b2bf5d..178c7cd93d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -VERSION_NAME=1.5.24-SNAPSHOT +VERSION_NAME=1.5.25-SNAPSHOT VERSION_CODE=1 GROUP=org.smartregister POM_SETTING_DESCRIPTION=OpenSRP Client Chw Core Library diff --git a/opensrp-chw-core/build.gradle b/opensrp-chw-core/build.gradle index b15c47fe6c..4bd9613234 100644 --- a/opensrp-chw-core/build.gradle +++ b/opensrp-chw-core/build.gradle @@ -138,7 +138,7 @@ dependencies { compileOnly 'com.ibm.fhir:fhir-model:4.2.3' - api('org.smartregister:opensrp-client-core:1.15.4-SNAPSHOT@aar') { + api('org.smartregister:opensrp-client-core:1.15.4-beta1-SNAPSHOT@aar') { transitive = true exclude group: 'com.github.bmelnychuk', module: 'atv' exclude group: 'com.google.guava', module: 'guava' From d765df442e23bc22fc22d0db3014687689f015c0 Mon Sep 17 00:00:00 2001 From: Allan O Date: Tue, 17 Nov 2020 11:00:20 +0300 Subject: [PATCH 34/78] :white_check_mark: Update CoreFamilyRemoveMemberPresenterTest --- .../CoreFamilyRemoveMemberPresenterTest.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/presenter/CoreFamilyRemoveMemberPresenterTest.java b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/presenter/CoreFamilyRemoveMemberPresenterTest.java index 62e64d6ae3..cdbc3e86ba 100644 --- a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/presenter/CoreFamilyRemoveMemberPresenterTest.java +++ b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/presenter/CoreFamilyRemoveMemberPresenterTest.java @@ -50,7 +50,7 @@ public void setUp() { ReflectionHelpers.setField(removeMemberPresenter, "viewReference", new WeakReference<>(view)); ReflectionHelpers.setField(removeMemberPresenter, "interactor", interactor); ReflectionHelpers.setField(removeMemberPresenter, "model", model); - ReflectionHelpers.setField(removeMemberPresenter, "familyHead", "family-head"); + ReflectionHelpers.setField(removeMemberPresenter, "familyHead", "family-head-entity-id"); ReflectionHelpers.setField(removeMemberPresenter, "primaryCaregiver", "primary-care-giver"); ReflectionHelpers.setField(removeMemberPresenter, "familyBaseEntityId", "family-entity-id"); @@ -74,12 +74,12 @@ public void removeMemberStartsRemoveMemberForm() throws Exception { @Test public void removeFamilyHeadInvokesProcessFamilyMember() { - columnMaps.put(DBConstants.KEY.BASE_ENTITY_ID, "family-head"); + columnMaps.put(DBConstants.KEY.BASE_ENTITY_ID, "family-head-entity-id"); columnMaps.put(OpdDbConstants.KEY.REGISTER_TYPE, ""); removeMemberPresenter.removeMember(commonPersonClient); Mockito.verify(interactor, Mockito.times(1)).processFamilyMember( - ArgumentMatchers.anyString(), + ArgumentMatchers.eq("family-entity-id"), ArgumentMatchers.any(CommonPersonObjectClient.class), ArgumentMatchers.any(CoreFamilyRemoveMemberPresenter.class)); } @@ -88,10 +88,10 @@ public void removeFamilyHeadInvokesProcessFamilyMember() { public void removeEveryoneStartsRemovalForm() { JSONObject form = Mockito.mock(JSONObject.class); Mockito.when(model.prepareFamilyRemovalForm( - ArgumentMatchers.anyString(), - ArgumentMatchers.anyString(), - ArgumentMatchers.anyString())).thenReturn(form); - removeMemberPresenter.removeEveryone(ArgumentMatchers.anyString(), ArgumentMatchers.anyString()); + ArgumentMatchers.eq("family-entity-id"), + ArgumentMatchers.eq("family-name"), + ArgumentMatchers.eq("family-details"))).thenReturn(form); + removeMemberPresenter.removeEveryone("family-name", "family-details"); Mockito.verify(view, Mockito.times(1)).startJsonActivity(form); } From 782f4d1cc6a237ad0ffb2fc478c15960ce8c0fb5 Mon Sep 17 00:00:00 2001 From: Allan O Date: Tue, 17 Nov 2020 12:05:06 +0300 Subject: [PATCH 35/78] :white_check_mark: Add FpAlertRuleTest class --- .../chw/core/rule/FpAlertRuleTest.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 opensrp-chw-core/src/test/java/org/smartregister/chw/core/rule/FpAlertRuleTest.java diff --git a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/rule/FpAlertRuleTest.java b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/rule/FpAlertRuleTest.java new file mode 100644 index 0000000000..cba65e8021 --- /dev/null +++ b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/rule/FpAlertRuleTest.java @@ -0,0 +1,25 @@ +package org.smartregister.chw.core.rule; + +import org.junit.Before; +import org.smartregister.chw.core.BaseRobolectricTest; +import org.smartregister.chw.fp.util.FamilyPlanningConstants; + +import java.text.SimpleDateFormat; +import java.util.Date; + +public class FpAlertRuleTest extends BaseRobolectricTest { + + private FpAlertRule fpAlertRule; + + @Before + public void setUp() throws Exception { + Date fpDate = new SimpleDateFormat("dd-MM-yyyy").parse("17-11-2020"); + Date lastVisitDate = new SimpleDateFormat("dd-MM-yyyy").parse("17-10-2020"); + fpAlertRule = new FpAlertRule(fpDate, lastVisitDate, 10, FamilyPlanningConstants.DBConstants.FP_COC); + } + + + + + +} From a2711cef9b61b9757b99849745ae1eb45433a328 Mon Sep 17 00:00:00 2001 From: Allan O Date: Tue, 17 Nov 2020 12:37:40 +0300 Subject: [PATCH 36/78] :white_check_mark: Add get visitID, check sterilization valid tests --- .../smartregister/chw/core/rule/FpAlertRule.java | 3 +++ .../chw/core/rule/FpAlertRuleTest.java | 14 ++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/rule/FpAlertRule.java b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/rule/FpAlertRule.java index 95543a54cc..38697a442a 100644 --- a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/rule/FpAlertRule.java +++ b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/rule/FpAlertRule.java @@ -38,6 +38,7 @@ public void setVisitID(String visitID) { this.visitID = visitID; } + // TODO -> This always returns TRUE? public boolean isCocPopValid(int dueDay, int overdueDate) { if (lastVisitDate != null) { this.dueDate = (new DateTime(this.lastVisitDate)).plusDays(this.pillCycles * 28).minusDays(dueDay); @@ -49,6 +50,7 @@ public boolean isCocPopValid(int dueDay, int overdueDate) { return true; } + // TODO -> This always returns TRUE? public boolean isCondomValid(int dueDay, int overdueDate) { if (lastVisitDate != null) { int monthOfYear = new DateTime(lastVisitDate).getMonthOfYear(); @@ -72,6 +74,7 @@ public boolean isCondomValid(int dueDay, int overdueDate) { return true; } + // TODO -> This always returns TRUE? public boolean isInjectionValid(int dueDay, int overdueDate) { if (lastVisitDate != null) { this.dueDate = new DateTime(lastVisitDate).plusDays(dueDay); diff --git a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/rule/FpAlertRuleTest.java b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/rule/FpAlertRuleTest.java index cba65e8021..6cb9ae0936 100644 --- a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/rule/FpAlertRuleTest.java +++ b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/rule/FpAlertRuleTest.java @@ -1,6 +1,9 @@ package org.smartregister.chw.core.rule; +import org.junit.Assert; import org.junit.Before; +import org.junit.Test; +import org.robolectric.util.ReflectionHelpers; import org.smartregister.chw.core.BaseRobolectricTest; import org.smartregister.chw.fp.util.FamilyPlanningConstants; @@ -16,10 +19,21 @@ public void setUp() throws Exception { Date fpDate = new SimpleDateFormat("dd-MM-yyyy").parse("17-11-2020"); Date lastVisitDate = new SimpleDateFormat("dd-MM-yyyy").parse("17-10-2020"); fpAlertRule = new FpAlertRule(fpDate, lastVisitDate, 10, FamilyPlanningConstants.DBConstants.FP_COC); + ReflectionHelpers.setField(fpAlertRule, "visitID", "test-visit-id"); } + @Test + public void canGetVisitId() { + Assert.assertEquals("test-visit-id", fpAlertRule.getVisitID()); + } + @Test + public void canGetIfFemaleSterilizationFollowUpOneValid() { + ReflectionHelpers.setField(fpAlertRule, "fpDifference", 5); + Assert.assertFalse(fpAlertRule.isFemaleSterilizationFollowUpOneValid(10, 15, 20)); + Assert.assertTrue(fpAlertRule.isFemaleSterilizationFollowUpOneValid(2, 6, 10)); + } } From 09650577dbee0d4028a2763fd1f4991ca889238b Mon Sep 17 00:00:00 2001 From: rkodev <43806892+rkodev@users.noreply.github.com> Date: Wed, 18 Nov 2020 08:28:35 +0300 Subject: [PATCH 37/78] Fix failing tests --- .../chw/core/activity/CoreChildProfileActivityTest.java | 6 +++--- .../activity/CoreFamilyOtherMemberProfileActivityTest.java | 4 ++-- .../chw/core/activity/CoreFamilyProfileActivityTest.java | 6 +++--- .../chw/core/activity/CoreFamilyRegisterActivityTest.java | 6 +++--- .../chw/core/activity/CorePncMemberProfileActivityTest.java | 6 +++--- .../CoreStockInventoryItemDetailsReportActivityTest.java | 6 +++--- .../core/activity/CoreStockInventoryReportActivityTest.java | 4 ++-- .../activity/impl/CoreFamilyRegisterActivityTestImpl.java | 6 ++++++ .../core/activity/mock/BaseChwNotificationRegisterMock.java | 6 ++++++ 9 files changed, 31 insertions(+), 19 deletions(-) diff --git a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/CoreChildProfileActivityTest.java b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/CoreChildProfileActivityTest.java index 1f91d01ba7..79b0c723b8 100644 --- a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/CoreChildProfileActivityTest.java +++ b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/CoreChildProfileActivityTest.java @@ -62,10 +62,10 @@ public void setUp() { CoreLibrary.init(context); //Auto login by default - String password = "pwd"; + //String password = "pwd"; context.session().start(context.session().lengthInMilliseconds()); - context.configuration().getDrishtiApplication().setPassword(password); - context.session().setPassword(password); + //context.configuration().getDrishtiApplication().setPassword(password); + //context.session().setPassword(password); controller = Robolectric.buildActivity(CoreChildProfileActivity.class).create().start(); activity = controller.get(); diff --git a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/CoreFamilyOtherMemberProfileActivityTest.java b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/CoreFamilyOtherMemberProfileActivityTest.java index 8e17350eae..28fc4e4847 100644 --- a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/CoreFamilyOtherMemberProfileActivityTest.java +++ b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/CoreFamilyOtherMemberProfileActivityTest.java @@ -47,8 +47,8 @@ public void setUp() { //Auto login by default String password = "pwd"; context.session().start(context.session().lengthInMilliseconds()); - context.configuration().getDrishtiApplication().setPassword(password); - context.session().setPassword(password); + //context.configuration().getDrishtiApplication().setPassword(password); + //context.session().setPassword(password); Intent intent = new Intent(); intent.putExtra(CoreConstants.INTENT_KEY.CHILD_COMMON_PERSON, commonPersonObjectClient); diff --git a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/CoreFamilyProfileActivityTest.java b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/CoreFamilyProfileActivityTest.java index c158d46c17..ee9e144ebf 100644 --- a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/CoreFamilyProfileActivityTest.java +++ b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/CoreFamilyProfileActivityTest.java @@ -46,10 +46,10 @@ public void setUp() { CoreLibrary.init(context); //Auto login by default - String password = "pwd"; + //String password = "pwd"; context.session().start(context.session().lengthInMilliseconds()); - context.configuration().getDrishtiApplication().setPassword(password); - context.session().setPassword(password); + //context.configuration().getDrishtiApplication().setPassword(password); + //context.session().setPassword(password); controller = Robolectric.buildActivity(CoreFamilyProfileActivityTestImpl.class).create().start(); activity = controller.get(); diff --git a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/CoreFamilyRegisterActivityTest.java b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/CoreFamilyRegisterActivityTest.java index 0a5818dc6f..b59c7e889e 100644 --- a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/CoreFamilyRegisterActivityTest.java +++ b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/CoreFamilyRegisterActivityTest.java @@ -44,10 +44,10 @@ public void setUp() { CoreLibrary.init(context); //Auto login by default - String password = "pwd"; + //String password = "pwd"; context.session().start(context.session().lengthInMilliseconds()); - context.configuration().getDrishtiApplication().setPassword(password); - context.session().setPassword(password); + //context.configuration().getDrishtiApplication().setPassword(password); + //context.session().setPassword(password); controller = Robolectric.buildActivity(CoreFamilyRegisterActivityTestImpl.class, new Intent()).create().start(); activity = controller.get(); diff --git a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/CorePncMemberProfileActivityTest.java b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/CorePncMemberProfileActivityTest.java index 6ed39e8229..6fefcaef7e 100644 --- a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/CorePncMemberProfileActivityTest.java +++ b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/CorePncMemberProfileActivityTest.java @@ -47,10 +47,10 @@ public void setUp() { CoreLibrary.init(context); //Auto login by default - String password = "pwd"; + //String password = "pwd"; context.session().start(context.session().lengthInMilliseconds()); - context.configuration().getDrishtiApplication().setPassword(password); - context.session().setPassword(password); + //context.configuration().getDrishtiApplication().setPassword(password); + //context.session().setPassword(password); Intent intent = new Intent(); intent.putExtra("MemberObject", memberObject); diff --git a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/CoreStockInventoryItemDetailsReportActivityTest.java b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/CoreStockInventoryItemDetailsReportActivityTest.java index 69d0d94504..3ddfd39d4c 100644 --- a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/CoreStockInventoryItemDetailsReportActivityTest.java +++ b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/CoreStockInventoryItemDetailsReportActivityTest.java @@ -48,10 +48,10 @@ public void setUp() { CoreLibrary.init(context); //Auto login by default - String password = "pwd"; + //String password = "pwd"; context.session().start(context.session().lengthInMilliseconds()); - context.configuration().getDrishtiApplication().setPassword(password); - context.session().setPassword(password); + //context.configuration().getDrishtiApplication().setPassword(password); + //context.session().setPassword(password); String stockItemName = "Male Condoms"; String providerName = "All-CHWs"; diff --git a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/CoreStockInventoryReportActivityTest.java b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/CoreStockInventoryReportActivityTest.java index b6e4345cf7..b9542e619c 100644 --- a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/CoreStockInventoryReportActivityTest.java +++ b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/CoreStockInventoryReportActivityTest.java @@ -57,8 +57,8 @@ public void setUp() { //Auto login by default String password = "pwd"; context.session().start(context.session().lengthInMilliseconds()); - context.configuration().getDrishtiApplication().setPassword(password); - context.session().setPassword(password); + //context.configuration().getDrishtiApplication().setPassword(password); + //context.session().setPassword(password); controller = Robolectric.buildActivity(CoreStockInventoryReportActivity.class).create().start(); activity = controller.get(); diff --git a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/impl/CoreFamilyRegisterActivityTestImpl.java b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/impl/CoreFamilyRegisterActivityTestImpl.java index 15dd3bbebe..c47b012756 100644 --- a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/impl/CoreFamilyRegisterActivityTestImpl.java +++ b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/impl/CoreFamilyRegisterActivityTestImpl.java @@ -6,6 +6,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.Map; public class CoreFamilyRegisterActivityTestImpl extends CoreFamilyRegisterActivity { @Override @@ -13,6 +14,11 @@ protected BaseRegisterFragment getRegisterFragment() { return Mockito.mock(BaseRegisterFragment.class); } + @Override + public void startFormActivity(String s, String s1, Map map) { + + } + public List getViewIdentifiers() { List result = new ArrayList<>(); result.add("1234"); diff --git a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/mock/BaseChwNotificationRegisterMock.java b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/mock/BaseChwNotificationRegisterMock.java index 4d63f44b68..bc0ff99eff 100644 --- a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/mock/BaseChwNotificationRegisterMock.java +++ b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/mock/BaseChwNotificationRegisterMock.java @@ -14,6 +14,7 @@ import java.util.HashMap; import java.util.List; +import java.util.Map; import static org.mockito.Mockito.mock; @@ -40,6 +41,11 @@ protected Fragment[] getOtherFragments() { return new Fragment[0]; } + @Override + public void startFormActivity(String s, String s1, Map map) { + + } + @Override public void startFormActivity(String formName, String entityId, String metaData) { //mock do nothing From e5100d3c662ef027ea05bc25780492905feaf8ff Mon Sep 17 00:00:00 2001 From: rkodev <43806892+rkodev@users.noreply.github.com> Date: Wed, 18 Nov 2020 09:11:58 +0300 Subject: [PATCH 38/78] Fix failing tests --- .../CoreChildProfileActivityTest.java | 42 +++++++++++++++++-- ...eFamilyOtherMemberProfileActivityTest.java | 16 +++++-- .../CoreFamilyProfileActivityTest.java | 3 -- .../CoreStockInventoryReportActivityTest.java | 5 +-- 4 files changed, 54 insertions(+), 12 deletions(-) diff --git a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/CoreChildProfileActivityTest.java b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/CoreChildProfileActivityTest.java index 79b0c723b8..7a3b542b74 100644 --- a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/CoreChildProfileActivityTest.java +++ b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/CoreChildProfileActivityTest.java @@ -62,10 +62,7 @@ public void setUp() { CoreLibrary.init(context); //Auto login by default - //String password = "pwd"; context.session().start(context.session().lengthInMilliseconds()); - //context.configuration().getDrishtiApplication().setPassword(password); - //context.session().setPassword(password); controller = Robolectric.buildActivity(CoreChildProfileActivity.class).create().start(); activity = controller.get(); @@ -128,6 +125,9 @@ public void testInitializePresenter() { @Test public void testSetUpViews() { activity = Mockito.spy(activity); + activity.setTheme(org.smartregister.R.style.AppTheme); //we need this here + activity.setContentView(R.layout.activity_child_profile); + activity.memberObject = memberObject; CoreChildProfileContract.Presenter presenter = Mockito.mock(CoreChildProfileContract.Presenter.class); Mockito.doReturn(presenter).when(activity).presenter(); @@ -280,6 +280,9 @@ public void testSetAge() { @Test public void testSetVisitButtonDueStatusMutatesViewsDesign() { activity = Mockito.spy(activity); + activity.setTheme(org.smartregister.R.style.AppTheme); //we need this here + activity.setContentView(R.layout.activity_child_profile); + CoreChildProfileContract.Presenter presenter = Mockito.mock(CoreChildProfileContract.Presenter.class); Mockito.doReturn(presenter).when(activity).presenter(); activity.setupViews(); @@ -295,6 +298,9 @@ public void testSetVisitButtonDueStatusMutatesViewsDesign() { @Test public void testSetVisitButtonOverdueStatus() { activity = Mockito.spy(activity); + activity.setTheme(org.smartregister.R.style.AppTheme); //we need this here + activity.setContentView(R.layout.activity_child_profile); + CoreChildProfileContract.Presenter presenter = Mockito.mock(CoreChildProfileContract.Presenter.class); Mockito.doReturn(presenter).when(activity).presenter(); activity.setupViews(); @@ -310,6 +316,9 @@ public void testSetVisitButtonOverdueStatus() { @Test public void testSetVisitNotDoneThisMonth() { activity = Mockito.spy(activity); + activity.setTheme(org.smartregister.R.style.AppTheme); //we need this here + activity.setContentView(R.layout.activity_child_profile); + CoreChildProfileContract.Presenter presenter = Mockito.mock(CoreChildProfileContract.Presenter.class); Mockito.doReturn(presenter).when(activity).presenter(); activity.setupViews(); @@ -354,6 +363,9 @@ public void testSetLastVisitRowView() { @Test public void testSetServiceNameDue() { activity = Mockito.spy(activity); + activity.setTheme(org.smartregister.R.style.AppTheme); //we need this here + activity.setContentView(R.layout.activity_child_profile); + CoreChildProfileContract.Presenter presenter = Mockito.mock(CoreChildProfileContract.Presenter.class); Mockito.doReturn(presenter).when(activity).presenter(); activity.setupViews(); @@ -372,6 +384,9 @@ public void testSetServiceNameDue() { @Test public void testSetServiceNameOverDue() { activity = Mockito.spy(activity); + activity.setTheme(org.smartregister.R.style.AppTheme); //we need this here + activity.setContentView(R.layout.activity_child_profile); + CoreChildProfileContract.Presenter presenter = Mockito.mock(CoreChildProfileContract.Presenter.class); Mockito.doReturn(presenter).when(activity).presenter(); activity.setupViews(); @@ -384,6 +399,9 @@ public void testSetServiceNameOverDue() { @Test public void testSetServiceNameUpcoming() { activity = Mockito.spy(activity); + activity.setTheme(org.smartregister.R.style.AppTheme); //we need this here + activity.setContentView(R.layout.activity_child_profile); + CoreChildProfileContract.Presenter presenter = Mockito.mock(CoreChildProfileContract.Presenter.class); Mockito.doReturn(presenter).when(activity).presenter(); activity.setupViews(); @@ -396,6 +414,9 @@ public void testSetServiceNameUpcoming() { @Test public void testSetVisitLessTwentyFourView() { activity = Mockito.spy(activity); + activity.setTheme(org.smartregister.R.style.AppTheme); //we need this here + activity.setContentView(R.layout.activity_child_profile); + CoreChildProfileContract.Presenter presenter = Mockito.mock(CoreChildProfileContract.Presenter.class); Mockito.doReturn(presenter).when(activity).presenter(); activity.setupViews(); @@ -413,6 +434,9 @@ public void testSetVisitLessTwentyFourView() { @Test public void testSetVisitAboveTwentyFourView() { activity = Mockito.spy(activity); + activity.setTheme(org.smartregister.R.style.AppTheme); //we need this here + activity.setContentView(R.layout.activity_child_profile); + CoreChildProfileContract.Presenter presenter = Mockito.mock(CoreChildProfileContract.Presenter.class); Mockito.doReturn(presenter).when(activity).presenter(); activity.setupViews(); @@ -424,6 +448,9 @@ public void testSetVisitAboveTwentyFourView() { @Test public void testSetFamilyHasNothingDue() { activity = Mockito.spy(activity); + activity.setTheme(org.smartregister.R.style.AppTheme); //we need this here + activity.setContentView(R.layout.activity_child_profile); + CoreChildProfileContract.Presenter presenter = Mockito.mock(CoreChildProfileContract.Presenter.class); Mockito.doReturn(presenter).when(activity).presenter(); activity.setupViews(); @@ -436,6 +463,9 @@ public void testSetFamilyHasNothingDue() { @Test public void testSetFamilyHasServiceDueDue() { activity = Mockito.spy(activity); + activity.setTheme(org.smartregister.R.style.AppTheme); //we need this here + activity.setContentView(R.layout.activity_child_profile); + CoreChildProfileContract.Presenter presenter = Mockito.mock(CoreChildProfileContract.Presenter.class); Mockito.doReturn(presenter).when(activity).presenter(); activity.setupViews(); @@ -448,6 +478,9 @@ public void testSetFamilyHasServiceDueDue() { @Test public void testSetFamilyHasServiceOverdue() { activity = Mockito.spy(activity); + activity.setTheme(org.smartregister.R.style.AppTheme); //we need this here + activity.setContentView(R.layout.activity_child_profile); + CoreChildProfileContract.Presenter presenter = Mockito.mock(CoreChildProfileContract.Presenter.class); Mockito.doReturn(presenter).when(activity).presenter(); activity.setupViews(); @@ -524,6 +557,9 @@ public void testOnJsonProcessed() { @Test public void testonProfileTaskFetched() { activity = Mockito.spy(activity); + activity.setTheme(org.smartregister.R.style.AppTheme); //we need this here + activity.setContentView(R.layout.activity_child_profile); + CoreChildProfileContract.Presenter presenter = Mockito.mock(CoreChildProfileContract.Presenter.class); Mockito.doReturn(presenter).when(activity).presenter(); activity.setupViews(); diff --git a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/CoreFamilyOtherMemberProfileActivityTest.java b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/CoreFamilyOtherMemberProfileActivityTest.java index 28fc4e4847..e19bcfb160 100644 --- a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/CoreFamilyOtherMemberProfileActivityTest.java +++ b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/CoreFamilyOtherMemberProfileActivityTest.java @@ -23,6 +23,7 @@ import org.smartregister.chw.core.BaseUnitTest; import org.smartregister.chw.core.R; import org.smartregister.chw.core.activity.impl.CoreFamilyOtherMemberProfileActivityImpl; +import org.smartregister.chw.core.presenter.CoreFamilyOtherMemberActivityPresenter; import org.smartregister.chw.core.utils.CoreConstants; import org.smartregister.commonregistry.CommonPersonObjectClient; @@ -45,16 +46,14 @@ public void setUp() { CoreLibrary.init(context); //Auto login by default - String password = "pwd"; context.session().start(context.session().lengthInMilliseconds()); - //context.configuration().getDrishtiApplication().setPassword(password); - //context.session().setPassword(password); Intent intent = new Intent(); intent.putExtra(CoreConstants.INTENT_KEY.CHILD_COMMON_PERSON, commonPersonObjectClient); controller = Robolectric.buildActivity(CoreFamilyOtherMemberProfileActivityImpl.class, intent).create().start(); activity = controller.get(); + activity.setTheme(org.smartregister.R.style.AppTheme); //we need this here } @After @@ -69,7 +68,12 @@ public void tearDown() { @Test public void testSetupViewsInitializesViews() { + activity.setTheme(org.smartregister.R.style.AppTheme); //we need this here + activity.setContentView(R.layout.activity_family_other_member_profile_chw); + + ReflectionHelpers.setField(activity,"presenter", Mockito.mock(CoreFamilyOtherMemberActivityPresenter.class)); activity.setupViews(); + Assert.assertNotNull(ReflectionHelpers.getField(activity, "familyFloatingMenu")); Assert.assertNotNull(ReflectionHelpers.getField(activity, "textViewFamilyHas")); Assert.assertNotNull(ReflectionHelpers.getField(activity, "layoutFamilyHasRow")); @@ -91,6 +95,12 @@ public void testOnCreateOptionsMenuInflatesProfileMenu() { @Test public void settingGenderSetsTranslatedString() { String gender = "Female"; + activity.setTheme(org.smartregister.R.style.AppTheme); //we need this here + activity.setContentView(R.layout.activity_family_other_member_profile_chw); + + ReflectionHelpers.setField(activity,"presenter", Mockito.mock(CoreFamilyOtherMemberActivityPresenter.class)); + activity.setupViews(); + activity.setProfileDetailOne(gender); Assert.assertNotNull(ReflectionHelpers.getField(activity, "detailOneView")); } diff --git a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/CoreFamilyProfileActivityTest.java b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/CoreFamilyProfileActivityTest.java index ee9e144ebf..a6cb7aa769 100644 --- a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/CoreFamilyProfileActivityTest.java +++ b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/CoreFamilyProfileActivityTest.java @@ -46,10 +46,7 @@ public void setUp() { CoreLibrary.init(context); //Auto login by default - //String password = "pwd"; context.session().start(context.session().lengthInMilliseconds()); - //context.configuration().getDrishtiApplication().setPassword(password); - //context.session().setPassword(password); controller = Robolectric.buildActivity(CoreFamilyProfileActivityTestImpl.class).create().start(); activity = controller.get(); diff --git a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/CoreStockInventoryReportActivityTest.java b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/CoreStockInventoryReportActivityTest.java index b9542e619c..9dd03554bc 100644 --- a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/CoreStockInventoryReportActivityTest.java +++ b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/CoreStockInventoryReportActivityTest.java @@ -55,10 +55,7 @@ public void setUp() { year = "2019"; //Auto login by default - String password = "pwd"; context.session().start(context.session().lengthInMilliseconds()); - //context.configuration().getDrishtiApplication().setPassword(password); - //context.session().setPassword(password); controller = Robolectric.buildActivity(CoreStockInventoryReportActivity.class).create().start(); activity = controller.get(); @@ -101,6 +98,8 @@ public void testReloadRecycler() { getProvider(); List stockUsageItemReportList = activity.getStockUsageItemReportList(stockMonth, stockYear); CoreStockUsageItemAdapter coreStockUsageItemAdapter = new CoreStockUsageItemAdapter(stockUsageItemReportList, activity); + + activity.onCreation(); activity.recyclerView.setAdapter(coreStockUsageItemAdapter); activity.reloadRecycler(selected); From b545ef48811df7f4c023c69da43d6522ee4aed68 Mon Sep 17 00:00:00 2001 From: Qazi Abubakar Date: Wed, 18 Nov 2020 11:49:07 +0500 Subject: [PATCH 39/78] Implemented family kit task cleanup Incremented library version to 1.5.26-SNAPSHOT --- gradle.properties | 2 +- .../chw/core/repository/ScheduleRepository.java | 9 +++++++++ .../smartregister/chw/core/sync/CoreClientProcessor.java | 5 ++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/gradle.properties b/gradle.properties index 178c7cd93d..9e21e88762 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -VERSION_NAME=1.5.25-SNAPSHOT +VERSION_NAME=1.5.26-SNAPSHOT VERSION_CODE=1 GROUP=org.smartregister POM_SETTING_DESCRIPTION=OpenSRP Client Chw Core Library diff --git a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/repository/ScheduleRepository.java b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/repository/ScheduleRepository.java index e8c95192f5..1b1582f96a 100644 --- a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/repository/ScheduleRepository.java +++ b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/repository/ScheduleRepository.java @@ -163,6 +163,14 @@ public void deleteSchedulesByFamilyEntityID(String baseEntityID) { } } + public void deleteFamilyKitSchedule(String baseEntityID) { + try { + getWritableDatabase().execSQL("DELETE from schedule_service where schedule_name = 'FAMILY_KIT' and base_entity_id = '" + baseEntityID + "'"); + } catch (Exception e) { + Timber.e(e); + } + } + public void deleteScheduleByName(String name) { try { getWritableDatabase().delete(TABLE_NAME, SCHEDULE_NAME + "= ?", new String[]{name}); @@ -259,6 +267,7 @@ private String getDateForDB(Date date) { return sdf.format(date); } + private Date getCursorDate(Cursor c, String column_name) { String val = c.getType(c.getColumnIndex(column_name)) == Cursor.FIELD_TYPE_NULL ? null : c.getString(c.getColumnIndex(column_name)); if (val == null) diff --git a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/sync/CoreClientProcessor.java b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/sync/CoreClientProcessor.java index b5bc6e65c4..967346b17e 100644 --- a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/sync/CoreClientProcessor.java +++ b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/sync/CoreClientProcessor.java @@ -189,9 +189,12 @@ public void processEvents(ClientClassification clientClassification, Table vacci processVisitEvent(Utils.processOldEvents(eventClient), CoreConstants.EventType.CHILD_HOME_VISIT); processEvent(eventClient.getEvent(), eventClient.getClient(), clientClassification); break; + case CoreConstants.EventType.FAMILY_KIT: + processVisitEvent(Utils.processOldEvents(eventClient), CoreConstants.EventType.FAMILY_KIT); + processEvent(eventClient.getEvent(), eventClient.getClient(), clientClassification); + break; case CoreConstants.EventType.CHILD_VISIT_NOT_DONE: case CoreConstants.EventType.WASH_CHECK: - case CoreConstants.EventType.FAMILY_KIT: case CoreConstants.EventType.ROUTINE_HOUSEHOLD_VISIT: processVisitEvent(eventClient); processEvent(eventClient.getEvent(), eventClient.getClient(), clientClassification); From a3977bfb43a7041c2e669b54054266e4c75f9801 Mon Sep 17 00:00:00 2001 From: rkodev <43806892+rkodev@users.noreply.github.com> Date: Wed, 18 Nov 2020 10:18:19 +0300 Subject: [PATCH 40/78] Fix failing tests --- .../chw/core/activity/CoreFamilyProfileActivityTest.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/CoreFamilyProfileActivityTest.java b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/CoreFamilyProfileActivityTest.java index a6cb7aa769..9b3bee3a73 100644 --- a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/CoreFamilyProfileActivityTest.java +++ b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/CoreFamilyProfileActivityTest.java @@ -23,6 +23,7 @@ import org.smartregister.chw.core.R; import org.smartregister.chw.core.activity.impl.CoreFamilyProfileActivityTestImpl; import org.smartregister.chw.core.custom_views.FamilyFloatingMenu; +import org.smartregister.chw.core.presenter.CoreFamilyProfilePresenter; import org.smartregister.chw.core.utils.ChildDBConstants; import org.smartregister.chw.core.utils.CoreConstants; import org.smartregister.commonregistry.CommonPersonObjectClient; @@ -64,7 +65,11 @@ public void tearDown() { @Test public void testSetupViews() { + activity.setTheme(org.smartregister.R.style.AppTheme); //we need this here + activity.setContentView(R.layout.activity_family_profile); + ReflectionHelpers.setField(activity, "presenter", Mockito.mock(CoreFamilyProfilePresenter.class)); activity.setupViews(); + Assert.assertNotNull(ReflectionHelpers.getField(activity, "familyFloatingMenu")); } From 445578977ba48c722dac532b9f13dcc9c5a50d77 Mon Sep 17 00:00:00 2001 From: rkodev <43806892+rkodev@users.noreply.github.com> Date: Wed, 18 Nov 2020 10:53:50 +0300 Subject: [PATCH 41/78] Fix codacy issues --- .../activity/impl/CoreFamilyRegisterActivityTestImpl.java | 4 +++- .../core/activity/mock/BaseChwNotificationRegisterMock.java | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/impl/CoreFamilyRegisterActivityTestImpl.java b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/impl/CoreFamilyRegisterActivityTestImpl.java index c47b012756..485614abfc 100644 --- a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/impl/CoreFamilyRegisterActivityTestImpl.java +++ b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/impl/CoreFamilyRegisterActivityTestImpl.java @@ -8,6 +8,8 @@ import java.util.List; import java.util.Map; +import timber.log.Timber; + public class CoreFamilyRegisterActivityTestImpl extends CoreFamilyRegisterActivity { @Override protected BaseRegisterFragment getRegisterFragment() { @@ -16,7 +18,7 @@ protected BaseRegisterFragment getRegisterFragment() { @Override public void startFormActivity(String s, String s1, Map map) { - + Timber.v("startFormActivity stub"); } public List getViewIdentifiers() { diff --git a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/mock/BaseChwNotificationRegisterMock.java b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/mock/BaseChwNotificationRegisterMock.java index bc0ff99eff..9334d1d136 100644 --- a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/mock/BaseChwNotificationRegisterMock.java +++ b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/mock/BaseChwNotificationRegisterMock.java @@ -16,6 +16,8 @@ import java.util.List; import java.util.Map; +import timber.log.Timber; + import static org.mockito.Mockito.mock; public class BaseChwNotificationRegisterMock extends BaseChwNotificationRegister { @@ -43,7 +45,7 @@ protected Fragment[] getOtherFragments() { @Override public void startFormActivity(String s, String s1, Map map) { - + Timber.v("startFormActivity stub"); } @Override From 6f8b9272a766625d41b438443a79e48253163d26 Mon Sep 17 00:00:00 2001 From: rkodev <43806892+rkodev@users.noreply.github.com> Date: Wed, 18 Nov 2020 11:47:20 +0300 Subject: [PATCH 42/78] Add tests --- opensrp-chw-core/src/main/AndroidManifest.xml | 3 + .../CoreAncMemberProfileActivity.java | 5 +- .../CoreAncMemberProfileActivityTest.java | 70 +++++++++++++++++-- .../CoreAncMemberProfileActivityImpl.java | 25 +++++++ 4 files changed, 97 insertions(+), 6 deletions(-) create mode 100644 opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/impl/CoreAncMemberProfileActivityImpl.java diff --git a/opensrp-chw-core/src/main/AndroidManifest.xml b/opensrp-chw-core/src/main/AndroidManifest.xml index e5bd024b7c..6d2727ca4d 100644 --- a/opensrp-chw-core/src/main/AndroidManifest.xml +++ b/opensrp-chw-core/src/main/AndroidManifest.xml @@ -6,4 +6,7 @@ + + + \ No newline at end of file diff --git a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/CoreAncMemberProfileActivity.java b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/CoreAncMemberProfileActivity.java index 843c3bfe6f..a9e2e8ee3a 100644 --- a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/CoreAncMemberProfileActivity.java +++ b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/CoreAncMemberProfileActivity.java @@ -161,7 +161,7 @@ public void onClick(View view) { } private int getMonthsDifference(LocalDate date1, LocalDate date2) { - return Months.monthsBetween( date1.withDayOfMonth(1), date2.withDayOfMonth(1)).getMonths(); + return Months.monthsBetween(date1.withDayOfMonth(1), date2.withDayOfMonth(1)).getMonths(); } private boolean isVisitThisMonth(LocalDate lastVisitDate, LocalDate todayDate) { @@ -260,7 +260,8 @@ public void setupViews() { protected void initializeNotificationReferralRecyclerView() { notificationAndReferralLayout = findViewById(R.id.notification_and_referral_row); notificationAndReferralRecyclerView = findViewById(R.id.notification_and_referral_recycler_view); - notificationAndReferralRecyclerView.setLayoutManager(new LinearLayoutManager(this)); + if (notificationAndReferralRecyclerView != null) + notificationAndReferralRecyclerView.setLayoutManager(new LinearLayoutManager(this)); } @Override diff --git a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/CoreAncMemberProfileActivityTest.java b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/CoreAncMemberProfileActivityTest.java index 1da5f91786..cde2ebcaa9 100644 --- a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/CoreAncMemberProfileActivityTest.java +++ b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/CoreAncMemberProfileActivityTest.java @@ -1,5 +1,6 @@ package org.smartregister.chw.core.activity; +import android.view.MenuItem; import android.view.View; import org.junit.Assert; @@ -8,15 +9,25 @@ import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.MockitoAnnotations; +import org.robolectric.Robolectric; import org.robolectric.RuntimeEnvironment; +import org.robolectric.android.controller.ActivityController; import org.robolectric.util.ReflectionHelpers; +import org.smartregister.Context; +import org.smartregister.CoreLibrary; import org.smartregister.chw.anc.domain.MemberObject; +import org.smartregister.chw.core.BaseUnitTest; +import org.smartregister.chw.core.R; +import org.smartregister.chw.core.activity.impl.CoreAncMemberProfileActivityImpl; +import org.smartregister.chw.core.presenter.CoreAncMemberProfilePresenter; +import org.smartregister.chw.core.utils.CoreConstants; -public class CoreAncMemberProfileActivityTest { +public class CoreAncMemberProfileActivityTest extends BaseUnitTest { private CoreAncMemberProfileActivity activity; private View viewFamilyRow = new View(RuntimeEnvironment.systemContext); + private ActivityController controller; @Mock private MemberObject memberObject; @@ -24,9 +35,21 @@ public class CoreAncMemberProfileActivityTest { @Before public void setUp() { MockitoAnnotations.initMocks(this); - activity = Mockito.mock(CoreAncMemberProfileActivity.class, Mockito.CALLS_REAL_METHODS); - String baseEntityId = "base-entity-id"; - memberObject.setBaseEntityId(baseEntityId); + + MockitoAnnotations.initMocks(this); + + Context context = Context.getInstance(); + CoreLibrary.init(context); + + //Auto login by default + context.session().start(context.session().lengthInMilliseconds()); + + controller = Robolectric.buildActivity(CoreAncMemberProfileActivityImpl.class).create().start(); + activity = controller.get(); + memberObject = Mockito.mock(MemberObject.class); + memberObject.setBaseEntityId("some-base-entity-id"); + memberObject.setFamilyName("Some Family Name"); + ReflectionHelpers.setField(activity, "memberObject", memberObject); ReflectionHelpers.setField(activity, "view_family_row", viewFamilyRow); } @@ -37,8 +60,47 @@ public void registerPresenter() { Assert.assertNotNull(activity.ancMemberProfilePresenter()); } + @Test + public void testOnOptionsItemSelected() { + activity = Mockito.spy(activity); + + MenuItem menuItem = Mockito.mock(MenuItem.class); + CoreConstants.JSON_FORM.setLocaleAndAssetManager(activity.getApplicationContext().getResources().getConfiguration().locale, activity.getApplicationContext().getAssets()); + + // back pressed + Mockito.doReturn(android.R.id.home).when(menuItem).getItemId(); + Mockito.doNothing().when(activity).onBackPressed(); + + activity.onOptionsItemSelected(menuItem); + Mockito.verify(activity).onBackPressed(); + + // start form + Mockito.doReturn(R.id.action_anc_member_registration).when(menuItem).getItemId(); + Mockito.doNothing().when(activity).startFormForEdit(Mockito.any(), Mockito.any()); + + activity.onOptionsItemSelected(menuItem); + Mockito.verify(activity).startFormForEdit(Mockito.eq(R.string.edit_member_form_title), Mockito.any()); + + + // start form + Mockito.doReturn(R.id.action_anc_registration).when(menuItem).getItemId(); + Mockito.doNothing().when(activity).startFormForEdit(Mockito.any(), Mockito.any()); + + activity.onOptionsItemSelected(menuItem); + Mockito.verify(activity).startFormForEdit(Mockito.eq(R.string.edit_anc_registration_form_title), Mockito.any()); + + // start form + Mockito.doReturn(R.id.anc_danger_signs_outcome).when(menuItem).getItemId(); + CoreAncMemberProfilePresenter presenter = Mockito.mock(CoreAncMemberProfilePresenter.class); + ReflectionHelpers.setField(activity, "presenter", presenter); + + activity.onOptionsItemSelected(menuItem); + Mockito.verify(presenter).startAncDangerSignsOutcomeForm(memberObject); + } + @Test public void openFamilyLocationStartsAncMemberMapActivity() { + activity = Mockito.spy(activity); activity.openFamilyLocation(); Mockito.verify(activity).startActivity(Mockito.any()); } diff --git a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/impl/CoreAncMemberProfileActivityImpl.java b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/impl/CoreAncMemberProfileActivityImpl.java new file mode 100644 index 0000000000..ae73659d70 --- /dev/null +++ b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/impl/CoreAncMemberProfileActivityImpl.java @@ -0,0 +1,25 @@ +package org.smartregister.chw.core.activity.impl; + +import org.smartregister.chw.core.activity.CoreAncMemberProfileActivity; +import org.smartregister.domain.Task; + +import java.util.Set; + +import timber.log.Timber; + +public class CoreAncMemberProfileActivityImpl extends CoreAncMemberProfileActivity { + @Override + public void openUpcomingService() { + Timber.v("openUpcomingService"); + } + + @Override + public void openFamilyDueServices() { + Timber.v("openFamilyDueServices"); + } + + @Override + public void setClientTasks(Set taskList) { + Timber.v("setClientTasks"); + } +} From 723c278086f8490e5c44e723c3b5e4c2b5b1444e Mon Sep 17 00:00:00 2001 From: rkodev <43806892+rkodev@users.noreply.github.com> Date: Wed, 18 Nov 2020 12:58:57 +0300 Subject: [PATCH 43/78] Adds tests --- .../CoreAncMemberProfileActivityTest.java | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/CoreAncMemberProfileActivityTest.java b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/CoreAncMemberProfileActivityTest.java index cde2ebcaa9..37a04dac3d 100644 --- a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/CoreAncMemberProfileActivityTest.java +++ b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/CoreAncMemberProfileActivityTest.java @@ -2,7 +2,10 @@ import android.view.MenuItem; import android.view.View; +import android.widget.RelativeLayout; +import android.widget.TextView; +import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -21,12 +24,14 @@ import org.smartregister.chw.core.activity.impl.CoreAncMemberProfileActivityImpl; import org.smartregister.chw.core.presenter.CoreAncMemberProfilePresenter; import org.smartregister.chw.core.utils.CoreConstants; +import org.smartregister.domain.AlertStatus; + +import timber.log.Timber; public class CoreAncMemberProfileActivityTest extends BaseUnitTest { private CoreAncMemberProfileActivity activity; - private View viewFamilyRow = new View(RuntimeEnvironment.systemContext); private ActivityController controller; @Mock @@ -51,9 +56,20 @@ public void setUp() { memberObject.setFamilyName("Some Family Name"); ReflectionHelpers.setField(activity, "memberObject", memberObject); + View viewFamilyRow = new View(RuntimeEnvironment.systemContext); ReflectionHelpers.setField(activity, "view_family_row", viewFamilyRow); } + @After + public void tearDown() { + try { + activity.finish(); + controller.pause().stop().destroy(); //destroy controller if we can + } catch (Exception e) { + Timber.e(e); + } + } + @Test public void registerPresenter() { activity.registerPresenter(); @@ -98,6 +114,18 @@ public void testOnOptionsItemSelected() { Mockito.verify(presenter).startAncDangerSignsOutcomeForm(memberObject); } + @Test + public void testSetFamilyStatus() { + ReflectionHelpers.setField(activity, "rlFamilyServicesDue", Mockito.mock(RelativeLayout.class)); + ReflectionHelpers.setField(activity, "tvFamilyStatus", Mockito.mock(TextView.class)); + + activity.setFamilyStatus(AlertStatus.complete); + Assert.assertFalse(ReflectionHelpers.getField(activity, "hasDueServices")); + + activity.setFamilyStatus(AlertStatus.normal); + Assert.assertTrue(ReflectionHelpers.getField(activity, "hasDueServices")); + } + @Test public void openFamilyLocationStartsAncMemberMapActivity() { activity = Mockito.spy(activity); From e9e921d92976a7a204736afa32cb159661939a84 Mon Sep 17 00:00:00 2001 From: Qazi Abubakar Date: Wed, 18 Nov 2020 15:03:49 +0500 Subject: [PATCH 44/78] Added new test --- .../smartregister/chw/core/utils/CoreConstantsTest.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/utils/CoreConstantsTest.java b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/utils/CoreConstantsTest.java index e4faad3005..064d079864 100644 --- a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/utils/CoreConstantsTest.java +++ b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/utils/CoreConstantsTest.java @@ -33,6 +33,14 @@ public void getMenuType() { Assert.assertEquals(CoreConstants.MenuType.ChangePrimaryCare, "ChangePrimaryCare"); } + @Test + public void testBusinessStatus() { + Assert.assertEquals(CoreConstants.BUSINESS_STATUS.REFERRED, "Referred"); + Assert.assertEquals(CoreConstants.BUSINESS_STATUS.IN_PROGRESS, "In-Progress"); + Assert.assertEquals(CoreConstants.BUSINESS_STATUS.COMPLETE, "Complete"); + Assert.assertEquals(CoreConstants.BUSINESS_STATUS.EXPIRED, "Expired"); + } + @Test public void testGetStockUsageForm() { Assert.assertEquals("stock_usage_report", CoreConstants.JSON_FORM.getStockUsageForm()); From df5290631cec212015bc97e6deab1e674480ba37 Mon Sep 17 00:00:00 2001 From: Hamza Ahmed Khan Date: Wed, 18 Nov 2020 15:26:01 +0500 Subject: [PATCH 45/78] Monthly drafts report fix --- .../chw/core/activity/HIA2ReportsActivity.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/HIA2ReportsActivity.java b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/HIA2ReportsActivity.java index 616cb5970b..1a6741ebf2 100644 --- a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/HIA2ReportsActivity.java +++ b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/HIA2ReportsActivity.java @@ -150,8 +150,12 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) { for (int j = 0; j < fieldsArray.length(); j++) { JSONObject fieldJsonObject = fieldsArray.getJSONObject(j); String key = fieldJsonObject.getString(KEY); - String value = fieldJsonObject.getString(VALUE); - result.put(key, value); + if (!fieldJsonObject.has(VALUE)) { + result.put(key, ""); + } else { + String value = fieldJsonObject.getString(VALUE); + result.put(key, value); + } } boolean saveClicked; From 21e0540338aa09b3506aae6e9d15d68f0bfdd526 Mon Sep 17 00:00:00 2001 From: Qazi Abubakar Date: Wed, 18 Nov 2020 15:47:06 +0500 Subject: [PATCH 46/78] Added new tests --- .../chw/core/utils/CoreConstantsTest.java | 56 +++++++++++++++++-- 1 file changed, 51 insertions(+), 5 deletions(-) diff --git a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/utils/CoreConstantsTest.java b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/utils/CoreConstantsTest.java index 064d079864..8da6dd5bb1 100644 --- a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/utils/CoreConstantsTest.java +++ b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/utils/CoreConstantsTest.java @@ -1,18 +1,36 @@ package org.smartregister.chw.core.utils; +import android.content.res.AssetManager; import android.os.Build; import org.junit.Assert; +import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; import org.robolectric.RobolectricTestRunner; import org.robolectric.annotation.Config; +import org.robolectric.util.ReflectionHelpers; +import org.smartregister.chw.core.application.CoreChwApplication; import org.smartregister.chw.core.application.TestApplication; +import org.smartregister.chw.core.fragment.CoreFpRegisterFragment; + +import java.lang.ref.WeakReference; +import java.util.Locale; @RunWith(RobolectricTestRunner.class) @Config(application = TestApplication.class, sdk = Build.VERSION_CODES.P) public class CoreConstantsTest { + @Mock + private CoreConstants.JSON_FORM jsonForm; + + @Before + public void setUp() { + MockitoAnnotations.initMocks(this); + } + @Test public void getUnifiedReferralForms() { Assert.assertEquals(CoreConstants.JSON_FORM.getAncUnifiedReferralForm(), "referrals/anc_referral_form"); @@ -34,11 +52,39 @@ public void getMenuType() { } @Test - public void testBusinessStatus() { - Assert.assertEquals(CoreConstants.BUSINESS_STATUS.REFERRED, "Referred"); - Assert.assertEquals(CoreConstants.BUSINESS_STATUS.IN_PROGRESS, "In-Progress"); - Assert.assertEquals(CoreConstants.BUSINESS_STATUS.COMPLETE, "Complete"); - Assert.assertEquals(CoreConstants.BUSINESS_STATUS.EXPIRED, "Expired"); + public void testGetFamilyKit() { + Locale locale = CoreChwApplication.getInstance().getResources().getConfiguration().locale; + AssetManager assetManager = CoreChwApplication.getInstance().getAssets(); + ReflectionHelpers.setField(jsonForm, "assetManager", assetManager); + ReflectionHelpers.setField(jsonForm, "locale", locale); + Assert.assertEquals(Utils.getLocalForm("family_kit", locale, assetManager), CoreConstants.JSON_FORM.getFamilyKit()); + } + + @Test + public void testGetWashCheck() { + Locale locale = CoreChwApplication.getInstance().getResources().getConfiguration().locale; + AssetManager assetManager = CoreChwApplication.getInstance().getAssets(); + ReflectionHelpers.setField(jsonForm, "assetManager", assetManager); + ReflectionHelpers.setField(jsonForm, "locale", locale); + Assert.assertEquals(Utils.getLocalForm("wash_check", locale, assetManager), CoreConstants.JSON_FORM.getWashCheck()); + } + + @Test + public void testGetFamilyRegister() { + Locale locale = CoreChwApplication.getInstance().getResources().getConfiguration().locale; + AssetManager assetManager = CoreChwApplication.getInstance().getAssets(); + ReflectionHelpers.setField(jsonForm, "assetManager", assetManager); + ReflectionHelpers.setField(jsonForm, "locale", locale); + Assert.assertEquals(Utils.getLocalForm("family_register", locale, assetManager), CoreConstants.JSON_FORM.getFamilyRegister()); + } + + @Test + public void testGetFamilyMemberRegister() { + Locale locale = CoreChwApplication.getInstance().getResources().getConfiguration().locale; + AssetManager assetManager = CoreChwApplication.getInstance().getAssets(); + ReflectionHelpers.setField(jsonForm, "assetManager", assetManager); + ReflectionHelpers.setField(jsonForm, "locale", locale); + Assert.assertEquals(Utils.getLocalForm("family_member_register", locale, assetManager), CoreConstants.JSON_FORM.getFamilyMemberRegister()); } @Test From e5c2cdc0f2b5b4d7ac51966744b630172a841cd1 Mon Sep 17 00:00:00 2001 From: Qazi Abubakar Date: Wed, 18 Nov 2020 15:47:38 +0500 Subject: [PATCH 47/78] Added new tests --- .../org/smartregister/chw/core/utils/CoreConstantsTest.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/utils/CoreConstantsTest.java b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/utils/CoreConstantsTest.java index 8da6dd5bb1..9a622439a6 100644 --- a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/utils/CoreConstantsTest.java +++ b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/utils/CoreConstantsTest.java @@ -14,9 +14,7 @@ import org.robolectric.util.ReflectionHelpers; import org.smartregister.chw.core.application.CoreChwApplication; import org.smartregister.chw.core.application.TestApplication; -import org.smartregister.chw.core.fragment.CoreFpRegisterFragment; -import java.lang.ref.WeakReference; import java.util.Locale; @RunWith(RobolectricTestRunner.class) From 88f1695047ed8a515f09dae4ba630205a836ac74 Mon Sep 17 00:00:00 2001 From: rkodev <43806892+rkodev@users.noreply.github.com> Date: Wed, 18 Nov 2020 14:18:21 +0300 Subject: [PATCH 48/78] Add test and update gradle --- gradle.properties | 2 +- ...oreChildRegisterFragmentPresenterTest.java | 83 +++++++++++++++++++ 2 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 opensrp-chw-core/src/test/java/org/smartregister/chw/core/presenter/CoreChildRegisterFragmentPresenterTest.java diff --git a/gradle.properties b/gradle.properties index e173dc008c..80f9025e5c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -VERSION_NAME=2.0.0-0-SNAPSHOT +VERSION_NAME=2.0.0-SNAPSHOT VERSION_CODE=1 GROUP=org.smartregister POM_SETTING_DESCRIPTION=OpenSRP Client Chw Core Library diff --git a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/presenter/CoreChildRegisterFragmentPresenterTest.java b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/presenter/CoreChildRegisterFragmentPresenterTest.java new file mode 100644 index 0000000000..8d7edbb43c --- /dev/null +++ b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/presenter/CoreChildRegisterFragmentPresenterTest.java @@ -0,0 +1,83 @@ +package org.smartregister.chw.core.presenter; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.MockitoAnnotations; +import org.robolectric.util.ReflectionHelpers; +import org.smartregister.chw.core.contract.CoreChildRegisterFragmentContract; +import org.smartregister.configurableviews.model.Field; +import org.smartregister.configurableviews.model.RegisterConfiguration; +import org.smartregister.configurableviews.model.View; +import org.smartregister.configurableviews.model.ViewConfiguration; + +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public class CoreChildRegisterFragmentPresenterTest { + + @Mock + private CoreChildRegisterFragmentContract.View view; + + @Mock + private CoreChildRegisterFragmentContract.Model model; + + private CoreChildRegisterFragmentPresenter presenter; + + @Before + public void setUp() { + MockitoAnnotations.initMocks(this); + presenter = Mockito.mock(CoreChildRegisterFragmentPresenter.class, Mockito.CALLS_REAL_METHODS); + ReflectionHelpers.setField(presenter, "viewReference", new WeakReference<>(view)); + ReflectionHelpers.setField(presenter, "model", model); + ReflectionHelpers.setField(presenter, "viewConfigurationIdentifier", "12345"); + } + + @Test + public void testProcessViewConfigurations() { + ViewConfiguration viewConfiguration = Mockito.mock(ViewConfiguration.class); + Mockito.doReturn(viewConfiguration).when(model).getViewConfiguration("12345"); + + Set changes = new HashSet<>(); + Mockito.doReturn(changes).when(model).getRegisterActiveColumns("12345"); + Mockito.doReturn(Mockito.mock(RegisterConfiguration.class)).when(viewConfiguration).getMetadata(); + + presenter.processViewConfigurations(); + Assert.assertEquals(ReflectionHelpers.getField(presenter, "visibleColumns"), changes); + } + + @Test + public void testInitializeQueries() { + presenter.initializeQueries("sample"); + Mockito.verify(view).initializeQueryParams(Mockito.any(), Mockito.any(), Mockito.any()); + Mockito.verify(view).initializeAdapter(Mockito.any()); + Mockito.verify(view).countExecute(); + Mockito.verify(view).filterandSortInInitializeQueries(); + } + + @Test + public void testUpdateSortAndFilter() { + List filterList = new ArrayList<>(); + Field sortField = Mockito.mock(Field.class); + presenter.updateSortAndFilter(filterList, sortField); + Mockito.verify(view).updateFilterAndFilterStatus(Mockito.any(), Mockito.any()); + } + + @Test + public void testGetMainCondition() { + String condition = " ec_child.date_removed is null AND ((( julianday('now') - julianday(ec_child.dob))/365.25) <5) and (( ifnull(ec_child.entry_point,'') <> 'PNC' ) or (ifnull(ec_child.entry_point,'') = 'PNC' and ( date(ec_child.dob, '+28 days') <= date() and ((SELECT is_closed FROM ec_family_member WHERE base_entity_id = ec_child.mother_entity_id ) = 0))) or (ifnull(ec_child.entry_point,'') = 'PNC' and (SELECT is_closed FROM ec_family_member WHERE base_entity_id = ec_child.mother_entity_id ) = 1)) and ((( julianday('now') - julianday(ec_child.dob))/365.25) < 5) "; + Assert.assertEquals(condition, presenter.getMainCondition()); + } + + @Test + public void testGetMainConditionWithTable() { + String condition = " tableName.date_removed is null AND ((( julianday('now') - julianday(ec_child.tableName.dob))/365.25) <5) and (( ifnull(ec_child.tableName.entry_point,'') <> 'PNC' ) or (ifnull(ec_child.tableName.entry_point,'') = 'PNC' and ( date(ec_child.tableName.dob, '+28 days') <= date() and ((SELECT is_closed FROM ec_family_member WHERE base_entity_id = ec_child.tableName.mother_entity_id ) = 0))) or (ifnull(ec_child.entry_point,'') = 'PNC' and (SELECT is_closed FROM ec_family_member WHERE base_entity_id = ec_child.mother_entity_id ) = 1)) and ((( julianday('now') - julianday(ec_child.tableName.dob))/365.25) < 5) "; + String tableName = "tableName"; + Assert.assertEquals(condition, presenter.getMainCondition(tableName)); + } +} From fbb3e9a5f59f582e82b25d0c470b88449b11b5de Mon Sep 17 00:00:00 2001 From: rkodev <43806892+rkodev@users.noreply.github.com> Date: Wed, 18 Nov 2020 14:22:30 +0300 Subject: [PATCH 49/78] Codacy --- .../core/presenter/CoreChildRegisterFragmentPresenterTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/presenter/CoreChildRegisterFragmentPresenterTest.java b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/presenter/CoreChildRegisterFragmentPresenterTest.java index 8d7edbb43c..b0b2d2e410 100644 --- a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/presenter/CoreChildRegisterFragmentPresenterTest.java +++ b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/presenter/CoreChildRegisterFragmentPresenterTest.java @@ -62,7 +62,7 @@ public void testInitializeQueries() { @Test public void testUpdateSortAndFilter() { - List filterList = new ArrayList<>(); + List filterList = new ArrayList<>(); Field sortField = Mockito.mock(Field.class); presenter.updateSortAndFilter(filterList, sortField); Mockito.verify(view).updateFilterAndFilterStatus(Mockito.any(), Mockito.any()); From eb17d78e895e69a8966bb8b8a84eac81452db26e Mon Sep 17 00:00:00 2001 From: Qazi Abubakar Date: Wed, 18 Nov 2020 16:42:32 +0500 Subject: [PATCH 50/78] Added method to update local repo on child member removal --- .../chw/core/repository/ScheduleRepository.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/repository/ScheduleRepository.java b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/repository/ScheduleRepository.java index 1b1582f96a..8accc2c2a4 100644 --- a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/repository/ScheduleRepository.java +++ b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/repository/ScheduleRepository.java @@ -171,6 +171,14 @@ public void deleteFamilyKitSchedule(String baseEntityID) { } } + public void deleteChildMember(String baseEntityID) { + try { + getWritableDatabase().delete("ec_child", BASE_ENTITY_ID + "= ?", new String[]{baseEntityID}); + } catch (Exception e) { + Timber.e(e); + } + } + public void deleteScheduleByName(String name) { try { getWritableDatabase().delete(TABLE_NAME, SCHEDULE_NAME + "= ?", new String[]{name}); From 682bf90f158d5b1f4e80f686fbdd86c52765b697 Mon Sep 17 00:00:00 2001 From: Qazi Abubakar Date: Wed, 18 Nov 2020 17:39:08 +0500 Subject: [PATCH 51/78] Added new tests --- .../smartregister/chw/core/utils/CoreConstantsTest.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/utils/CoreConstantsTest.java b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/utils/CoreConstantsTest.java index 9a622439a6..f5da123102 100644 --- a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/utils/CoreConstantsTest.java +++ b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/utils/CoreConstantsTest.java @@ -85,6 +85,15 @@ public void testGetFamilyMemberRegister() { Assert.assertEquals(Utils.getLocalForm("family_member_register", locale, assetManager), CoreConstants.JSON_FORM.getFamilyMemberRegister()); } + @Test + public void testGetChildRegister() { + Locale locale = CoreChwApplication.getInstance().getResources().getConfiguration().locale; + AssetManager assetManager = CoreChwApplication.getInstance().getAssets(); + ReflectionHelpers.setField(jsonForm, "assetManager", assetManager); + ReflectionHelpers.setField(jsonForm, "locale", locale); + Assert.assertEquals(Utils.getLocalForm("child_enrollment", locale, assetManager), CoreConstants.JSON_FORM.getChildRegister()); + } + @Test public void testGetStockUsageForm() { Assert.assertEquals("stock_usage_report", CoreConstants.JSON_FORM.getStockUsageForm()); From 81dc5dd45a7d4c3cd48b4261a82b7a5934bf7606 Mon Sep 17 00:00:00 2001 From: Qazi Abubakar Date: Thu, 19 Nov 2020 14:54:29 +0500 Subject: [PATCH 52/78] soft deleted a child member using "is_closed" --- .../chw/core/repository/ScheduleRepository.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/repository/ScheduleRepository.java b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/repository/ScheduleRepository.java index 8accc2c2a4..1c599fcf97 100644 --- a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/repository/ScheduleRepository.java +++ b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/repository/ScheduleRepository.java @@ -5,8 +5,11 @@ import net.sqlcipher.database.SQLiteDatabase; +import org.smartregister.chw.anc.util.DBConstants; +import org.smartregister.chw.core.application.CoreChwApplication; import org.smartregister.chw.core.contract.ScheduleTask; import org.smartregister.chw.core.domain.BaseScheduleTask; +import org.smartregister.chw.core.utils.CoreConstants; import org.smartregister.repository.BaseRepository; import java.text.ParseException; @@ -171,12 +174,11 @@ public void deleteFamilyKitSchedule(String baseEntityID) { } } - public void deleteChildMember(String baseEntityID) { - try { - getWritableDatabase().delete("ec_child", BASE_ENTITY_ID + "= ?", new String[]{baseEntityID}); - } catch (Exception e) { - Timber.e(e); - } + public void closeChildMember(String baseEntityID) { + ContentValues values = new ContentValues(); + values.put("is_closed", 1); + CoreChwApplication.getInstance().getRepository().getWritableDatabase().update(CoreConstants.TABLE_NAME.CHILD, values, + DBConstants.KEY.BASE_ENTITY_ID + " = ? ", new String[]{baseEntityID}); } public void deleteScheduleByName(String name) { From 092eb9f9a55b3239fe238a1bf6ea661c71f8eb06 Mon Sep 17 00:00:00 2001 From: zzainulabidin Date: Fri, 20 Nov 2020 13:16:00 +0500 Subject: [PATCH 53/78] Add delivery kit to medical history pages --- .../DefaultAncMedicalHistoryActivityFlv.java | 20 +++++++++++ .../res/layout/medical_history_details.xml | 35 +++++++++++++++++++ .../src/main/res/values-fr/strings.xml | 1 + .../src/main/res/values-sw/strings.xml | 1 + .../src/main/res/values/strings.xml | 1 + 5 files changed, 58 insertions(+) diff --git a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/DefaultAncMedicalHistoryActivityFlv.java b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/DefaultAncMedicalHistoryActivityFlv.java index c354ff2e97..991a97288a 100644 --- a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/DefaultAncMedicalHistoryActivityFlv.java +++ b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/DefaultAncMedicalHistoryActivityFlv.java @@ -25,6 +25,7 @@ public abstract class DefaultAncMedicalHistoryActivityFlv implements CoreAncMedicalHistoryActivity.Flavor { protected LinearLayout linearLayoutAncCard; + protected LinearLayout linearLayoutDeliveryKit; protected LinearLayout linearLayoutHealthFacilityVisit; protected LinearLayout linearLayoutHealthFacilityVisitDetails; protected LayoutInflater inflater; @@ -33,6 +34,7 @@ public abstract class DefaultAncMedicalHistoryActivityFlv implements CoreAncMedi private LinearLayout linearLayoutIPTp, linearLayoutIPTpDetails; private TextView customFontTextViewLastVisit; private TextView customFontTextViewAncCard; + private TextView customFontTextViewDeliveryKit; @Override public View bindViews(Activity activity) { @@ -41,6 +43,7 @@ public View bindViews(Activity activity) { linearLayoutLastVisit = view.findViewById(R.id.linearLayoutLastVisit); linearLayoutAncCard = view.findViewById(R.id.linearLayoutAncCard); + linearLayoutDeliveryKit = view.findViewById(R.id.linearLayoutDeliveryKit); linearLayoutHealthFacilityVisit = view.findViewById(R.id.linearLayoutHealthFacilityVisit); linearLayoutHealthFacilityVisitDetails = view.findViewById(R.id.linearLayoutHealthFacilityVisitDetails); linearLayoutTTImmunization = view.findViewById(R.id.linearLayoutTTImmunization); @@ -49,6 +52,7 @@ public View bindViews(Activity activity) { linearLayoutIPTpDetails = view.findViewById(R.id.linearLayoutIPTpDetails); customFontTextViewLastVisit = view.findViewById(R.id.customFontTextViewLastVisit); customFontTextViewAncCard = view.findViewById(R.id.customFontTextViewAncCard); + customFontTextViewDeliveryKit = view.findViewById(R.id.customFontTextViewDeliveryKit); return view; } @@ -59,6 +63,7 @@ public void processViewData(List visits, Context context) { int days = 0; String has_card = "No"; + String has_delivery_kit = "No"; List> hf_visits = new ArrayList<>(); Map immunizations = new HashMap<>(); Map services = new HashMap<>(); @@ -80,6 +85,15 @@ public void processViewData(List visits, Context context) { } + // delivery kiy + if (has_delivery_kit.equalsIgnoreCase("No")) { + List details = visits.get(x).getVisitDetails().get("delivery_kit"); + if (details != null && StringUtils.isNotBlank(details.get(0).getHumanReadable())) { + has_delivery_kit = details.get(0).getHumanReadable(); + } + + } + String[] hf_params = {"anc_hf_visit_date", "weight", "sys_bp", "dia_bp", "hb_level", "ifa_received", "tests_done"}; extractHFVisit(visits, hf_params, hf_visits, x, context); @@ -91,6 +105,7 @@ public void processViewData(List visits, Context context) { processLastVisit(days, context); processAncCard(has_card, context); + processDeliveryKit(has_delivery_kit, context); processHealthFacilityVisit(hf_visits, context); processTTImmunization(immunizations, context); processIPTp(services, context); @@ -183,6 +198,11 @@ protected void processAncCard(String has_card, Context context) { customFontTextViewAncCard.setText(MessageFormat.format("{0}: {1}", context.getString(R.string.anc_home_visit_anc_card_received), getTranslatedText(context, has_card.toLowerCase()))); } + protected void processDeliveryKit(String has_delivery_kit, Context context) { + linearLayoutDeliveryKit.setVisibility(View.VISIBLE); + customFontTextViewDeliveryKit.setText(MessageFormat.format("{0}: {1}", context.getString(R.string.anc_home_visit_delivery_kit_received), getTranslatedText(context, has_delivery_kit.toLowerCase()))); + } + protected void processHealthFacilityVisit(List> hf_visits, Context context) { if (hf_visits != null && hf_visits.size() > 0) { linearLayoutHealthFacilityVisit.setVisibility(View.VISIBLE); diff --git a/opensrp-chw-core/src/main/res/layout/medical_history_details.xml b/opensrp-chw-core/src/main/res/layout/medical_history_details.xml index 2119685a99..0d4c23128e 100644 --- a/opensrp-chw-core/src/main/res/layout/medical_history_details.xml +++ b/opensrp-chw-core/src/main/res/layout/medical_history_details.xml @@ -85,6 +85,41 @@ + + + + + + + + + FAF reçu: {0} Examens effectués: {0} Carnet CPN reçu + Kit de livraison reçu VAT{0} - fait {1} SP dose{0}- fait {1} un diff --git a/opensrp-chw-core/src/main/res/values-sw/strings.xml b/opensrp-chw-core/src/main/res/values-sw/strings.xml index c7c4b68592..bb1d7eaac6 100644 --- a/opensrp-chw-core/src/main/res/values-sw/strings.xml +++ b/opensrp-chw-core/src/main/res/values-sw/strings.xml @@ -301,6 +301,7 @@ Amepewa IFA: {0} Vipimo vimefanyika: {0} Kadi ya mama mjamzito imepokelewa + Vifaa vya kujifungua vimepokelewa TT{0} - Imefanyika {1} Dozi ya IPTp-SP {0}- Imefanyika {1} 1 diff --git a/opensrp-chw-core/src/main/res/values/strings.xml b/opensrp-chw-core/src/main/res/values/strings.xml index 44a94503ae..519134d038 100644 --- a/opensrp-chw-core/src/main/res/values/strings.xml +++ b/opensrp-chw-core/src/main/res/values/strings.xml @@ -314,6 +314,7 @@ IFA received: {0} Tests done: {0} ANC card received + Delivery kit received TT{0} - done {1} IPTp-SP dose{0}- done {1} 1 From b9a1b2accc014fbd5ebafa249833b56747a29520 Mon Sep 17 00:00:00 2001 From: zzainulabidin Date: Fri, 20 Nov 2020 14:51:45 +0500 Subject: [PATCH 54/78] Change delivery kit title --- .../res/layout/medical_history_details.xml | 811 +++++++++--------- .../src/main/res/values-fr/strings.xml | 1 + .../src/main/res/values-sw/strings.xml | 1 + .../src/main/res/values/strings.xml | 2 + 4 files changed, 409 insertions(+), 406 deletions(-) diff --git a/opensrp-chw-core/src/main/res/layout/medical_history_details.xml b/opensrp-chw-core/src/main/res/layout/medical_history_details.xml index 0d4c23128e..97a3d00b2b 100644 --- a/opensrp-chw-core/src/main/res/layout/medical_history_details.xml +++ b/opensrp-chw-core/src/main/res/layout/medical_history_details.xml @@ -14,412 +14,411 @@ android:layout_height="match_parent" android:orientation="vertical"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/opensrp-chw-core/src/main/res/values-fr/strings.xml b/opensrp-chw-core/src/main/res/values-fr/strings.xml index ba474a6ac7..8230c0bda5 100644 --- a/opensrp-chw-core/src/main/res/values-fr/strings.xml +++ b/opensrp-chw-core/src/main/res/values-fr/strings.xml @@ -287,6 +287,7 @@ VISITE CPN A LA FORMATION SANITAIRE Carnet CPN VAT + Kit de livraison SP dose Analyse urinaire Dépistage VIH diff --git a/opensrp-chw-core/src/main/res/values-sw/strings.xml b/opensrp-chw-core/src/main/res/values-sw/strings.xml index bb1d7eaac6..97cb6d9fa7 100644 --- a/opensrp-chw-core/src/main/res/values-sw/strings.xml +++ b/opensrp-chw-core/src/main/res/values-sw/strings.xml @@ -286,6 +286,7 @@ MAHUDHURIO YA KLINIKI YA WAJAWAZITO KWENYE KITUO CHA KUTOLEA HUDUMA ZA AFYA. Kadi ya kliniki ya mjamzito + Kitanda cha Uwasilishaji CHANJO YA PEPOPUNDA DOZI YA IPTp-SP Kipimo kwenye njia ya mkojo diff --git a/opensrp-chw-core/src/main/res/values/strings.xml b/opensrp-chw-core/src/main/res/values/strings.xml index 519134d038..d3f1a036f3 100644 --- a/opensrp-chw-core/src/main/res/values/strings.xml +++ b/opensrp-chw-core/src/main/res/values/strings.xml @@ -299,6 +299,7 @@ · ANC HEALTH FACILITY VISITS ANC Card + Delivery Kit TT IMMUNIZATION IPTp-SP DOSE Urine analysis @@ -745,4 +746,5 @@ View vaccine history See vaccines due today + Delivery kit received From f7a867921d2afbce939a8d6e8803da341411fe7e Mon Sep 17 00:00:00 2001 From: zzainulabidin Date: Fri, 20 Nov 2020 15:01:40 +0500 Subject: [PATCH 55/78] Remove dublicate string from strings.xml --- opensrp-chw-core/src/main/res/values/strings.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/opensrp-chw-core/src/main/res/values/strings.xml b/opensrp-chw-core/src/main/res/values/strings.xml index d3f1a036f3..30406bd077 100644 --- a/opensrp-chw-core/src/main/res/values/strings.xml +++ b/opensrp-chw-core/src/main/res/values/strings.xml @@ -746,5 +746,4 @@ View vaccine history See vaccines due today - Delivery kit received From d6e5b8a681153feed9dd8b8ae1869becfebbc5e4 Mon Sep 17 00:00:00 2001 From: Allan O Date: Tue, 24 Nov 2020 13:07:22 +0300 Subject: [PATCH 56/78] :white_check_mark: Add button status tests --- .../chw/core/rule/FpAlertRuleTest.java | 71 ++++++++++++++++++- 1 file changed, 68 insertions(+), 3 deletions(-) diff --git a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/rule/FpAlertRuleTest.java b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/rule/FpAlertRuleTest.java index 6cb9ae0936..b087096eb6 100644 --- a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/rule/FpAlertRuleTest.java +++ b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/rule/FpAlertRuleTest.java @@ -1,24 +1,36 @@ package org.smartregister.chw.core.rule; +import org.joda.time.DateTime; +import org.joda.time.LocalDate; +import org.joda.time.LocalTime; +import org.joda.time.format.DateTimeFormat; +import org.joda.time.format.DateTimeFormatter; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.robolectric.util.ReflectionHelpers; import org.smartregister.chw.core.BaseRobolectricTest; +import org.smartregister.chw.core.utils.CoreConstants; import org.smartregister.chw.fp.util.FamilyPlanningConstants; +import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class FpAlertRuleTest extends BaseRobolectricTest { private FpAlertRule fpAlertRule; + private String dateTimeFormat = "dd-MM-yyyy HH:mm:ss"; + DateTime lastVisitDate; + DateTime dueDate; + DateTime expiryDate; + DateTime overDueDate; @Before - public void setUp() throws Exception { + public void setUp() throws ParseException { Date fpDate = new SimpleDateFormat("dd-MM-yyyy").parse("17-11-2020"); - Date lastVisitDate = new SimpleDateFormat("dd-MM-yyyy").parse("17-10-2020"); - fpAlertRule = new FpAlertRule(fpDate, lastVisitDate, 10, FamilyPlanningConstants.DBConstants.FP_COC); + Date lastVisit = new SimpleDateFormat("dd-MM-yyyy").parse("17-10-2020"); + fpAlertRule = new FpAlertRule(fpDate, lastVisit, 10, FamilyPlanningConstants.DBConstants.FP_COC); ReflectionHelpers.setField(fpAlertRule, "visitID", "test-visit-id"); } @@ -36,4 +48,57 @@ public void canGetIfFemaleSterilizationFollowUpOneValid() { Assert.assertTrue(fpAlertRule.isFemaleSterilizationFollowUpOneValid(2, 6, 10)); } + @Test + public void buttonStatusDoneIfVisitBeforeExpiry() { + lastVisitDate = LocalDate.now().toDateTime(LocalTime.MIDNIGHT); + dueDate = LocalDate.now().minusDays(5).toDateTime(LocalTime.MIDNIGHT); + expiryDate = LocalDate.now().plusDays(10).toDateTime(LocalTime.MIDNIGHT); + + ReflectionHelpers.setField(fpAlertRule, "dueDate", dueDate); + ReflectionHelpers.setField(fpAlertRule, "expiryDate", expiryDate); + ReflectionHelpers.setField(fpAlertRule, "lastVisitDate", lastVisitDate); + Assert.assertEquals(CoreConstants.VISIT_STATE.VISIT_DONE, fpAlertRule.getButtonStatus()); + } + + @Test + public void buttonStatusDueIfVisitBeforeOverdue() { + lastVisitDate = LocalDate.now().minusDays(10).toDateTime(LocalTime.MIDNIGHT); + dueDate = LocalDate.now().minusDays(5).toDateTime(LocalTime.MIDNIGHT); + overDueDate = LocalDate.now().plusDays(10).toDateTime(LocalTime.MIDNIGHT); + + ReflectionHelpers.setField(fpAlertRule, "dueDate", dueDate); + ReflectionHelpers.setField(fpAlertRule, "overDueDate", overDueDate); + ReflectionHelpers.setField(fpAlertRule, "lastVisitDate", lastVisitDate); + Assert.assertEquals(CoreConstants.VISIT_STATE.DUE, fpAlertRule.getButtonStatus()); + } + + + @Test + public void buttonStatusOverDueIfVisitAfterOverdue() { + lastVisitDate = LocalDate.now().minusDays(10).toDateTime(LocalTime.MIDNIGHT); + dueDate = LocalDate.now().minusDays(5).toDateTime(LocalTime.MIDNIGHT); + overDueDate = LocalDate.now().minusDays(1).toDateTime(LocalTime.MIDNIGHT); + expiryDate = LocalDate.now().plusDays(10).toDateTime(LocalTime.MIDNIGHT); + + ReflectionHelpers.setField(fpAlertRule, "dueDate", dueDate); + ReflectionHelpers.setField(fpAlertRule, "expiryDate", expiryDate); + ReflectionHelpers.setField(fpAlertRule, "overDueDate", overDueDate); + ReflectionHelpers.setField(fpAlertRule, "lastVisitDate", lastVisitDate); + Assert.assertEquals(CoreConstants.VISIT_STATE.OVERDUE, fpAlertRule.getButtonStatus()); + } + + + @Test + public void buttonStatusNotDueIfDateBeforeDueAndExpiry() { + lastVisitDate = LocalDate.now().toDateTime(LocalTime.MIDNIGHT); + dueDate = LocalDate.now().plusDays(10).toDateTime(LocalTime.MIDNIGHT); + expiryDate = LocalDate.now().plusDays(20).toDateTime(LocalTime.MIDNIGHT); + + ReflectionHelpers.setField(fpAlertRule, "dueDate", dueDate); + ReflectionHelpers.setField(fpAlertRule, "expiryDate", expiryDate); + ReflectionHelpers.setField(fpAlertRule, "lastVisitDate", lastVisitDate); + Assert.assertEquals(CoreConstants.VISIT_STATE.NOT_DUE_YET, fpAlertRule.getButtonStatus()); + } + + } From ef614b73e6295d6a190bb72cf1a21eace0b769f1 Mon Sep 17 00:00:00 2001 From: Allan O Date: Wed, 25 Nov 2020 22:11:28 +0300 Subject: [PATCH 57/78] :green_heart: Fix Codacy reported issues --- .../smartregister/chw/core/rule/FpAlertRuleTest.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/rule/FpAlertRuleTest.java b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/rule/FpAlertRuleTest.java index b087096eb6..e2d347e7ff 100644 --- a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/rule/FpAlertRuleTest.java +++ b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/rule/FpAlertRuleTest.java @@ -3,8 +3,6 @@ import org.joda.time.DateTime; import org.joda.time.LocalDate; import org.joda.time.LocalTime; -import org.joda.time.format.DateTimeFormat; -import org.joda.time.format.DateTimeFormatter; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -21,10 +19,10 @@ public class FpAlertRuleTest extends BaseRobolectricTest { private FpAlertRule fpAlertRule; private String dateTimeFormat = "dd-MM-yyyy HH:mm:ss"; - DateTime lastVisitDate; - DateTime dueDate; - DateTime expiryDate; - DateTime overDueDate; + private DateTime lastVisitDate; + private DateTime dueDate; + private DateTime expiryDate; + private DateTime overDueDate; @Before public void setUp() throws ParseException { From 1522e8b5b9272b994bbb6cba2e5773b9cfeaee8f Mon Sep 17 00:00:00 2001 From: Allan O Date: Wed, 25 Nov 2020 22:15:15 +0300 Subject: [PATCH 58/78] :white_check_mark: Remove unused field --- .../java/org/smartregister/chw/core/rule/FpAlertRuleTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/rule/FpAlertRuleTest.java b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/rule/FpAlertRuleTest.java index e2d347e7ff..55aca3adf0 100644 --- a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/rule/FpAlertRuleTest.java +++ b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/rule/FpAlertRuleTest.java @@ -18,7 +18,6 @@ public class FpAlertRuleTest extends BaseRobolectricTest { private FpAlertRule fpAlertRule; - private String dateTimeFormat = "dd-MM-yyyy HH:mm:ss"; private DateTime lastVisitDate; private DateTime dueDate; private DateTime expiryDate; From 04698f86efe69359bb631358153d99ce162e9a97 Mon Sep 17 00:00:00 2001 From: Qazi Abubakar Date: Fri, 27 Nov 2020 12:01:04 +0500 Subject: [PATCH 59/78] Fixed FamilyKit task schedule --- gradle.properties | 2 +- .../chw/core/rule/FamilyKitAlertRule.java | 16 ++++++++++++++++ .../chw/core/rule/MonthlyAlertRule.java | 8 ++++---- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/gradle.properties b/gradle.properties index 23cdc90a68..e206018289 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -VERSION_NAME=2.0.1-SNAPSHOT +VERSION_NAME=2.0.2-SNAPSHOT VERSION_CODE=1 GROUP=org.smartregister POM_SETTING_DESCRIPTION=OpenSRP Client Chw Core Library diff --git a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/rule/FamilyKitAlertRule.java b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/rule/FamilyKitAlertRule.java index 98f30eee20..a8c8df9f8f 100644 --- a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/rule/FamilyKitAlertRule.java +++ b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/rule/FamilyKitAlertRule.java @@ -2,6 +2,10 @@ import android.content.Context; +import org.joda.time.DateTime; + +import java.util.Date; + //All date formats ISO 8601 yyyy-mm-dd /** @@ -13,6 +17,18 @@ public FamilyKitAlertRule(Context context, long lastVisitDateLong, long dateCrea super(context, lastVisitDateLong, dateCreatedLong); } + public Date getDueDate() { + Date lastDueDate = getLastDueDate(); + if (lastDueDate.getTime() < getFirstDayOfMonth(new Date()).getTime()) { + if (getFirstDayOfMonth(lastVisitDate.toDate()).getTime() < getFirstDayOfMonth(new Date()).getTime()) { + return getFirstDayOfMonth(new DateTime(lastVisitDate.toDate()).plusMonths(1).toDate()); + } + return getFirstDayOfMonth(new Date()); + } else { + return lastDueDate; + } + } + @Override public String getRuleKey() { return "familyKitAlertRule"; diff --git a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/rule/MonthlyAlertRule.java b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/rule/MonthlyAlertRule.java index c42a6d51e2..ed5b1d2c1d 100644 --- a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/rule/MonthlyAlertRule.java +++ b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/rule/MonthlyAlertRule.java @@ -20,7 +20,7 @@ public abstract class MonthlyAlertRule implements ICommonRule { public String visitMonthName; private LocalDate dateCreated; private LocalDate todayDate; - private LocalDate lastVisitDate; + public LocalDate lastVisitDate; private Context context; public MonthlyAlertRule(Context context, long lastVisitDateLong, long dateCreatedLong) { @@ -94,11 +94,11 @@ public boolean isVisitWithinThisMonth() { return (lastVisitDate != null) && isVisitThisMonth(lastVisitDate, todayDate); } - private Date getFirstDayOfMonth(Date refDate) { + public Date getFirstDayOfMonth(Date refDate) { return new DateTime(refDate).withDayOfMonth(1).toDate(); } - protected Date getLastDayOfMonth(Date refDate) { + public Date getLastDayOfMonth(Date refDate) { DateTime first = new DateTime(refDate).withDayOfMonth(1); return first.plusMonths(1).minusDays(1).toDate(); } @@ -117,7 +117,7 @@ public Date getDueDate() { } } - private Date getLastDueDate() { + public Date getLastDueDate() { if (lastVisitDate != null && getFirstDayOfMonth(lastVisitDate.toDate()).getTime() < dateCreated.toDate().getTime()) { return getFirstDayOfMonth(lastVisitDate.toDate()); } else { From fe2e17f84d7d95c0d20f09dc4463b1968f20fee3 Mon Sep 17 00:00:00 2001 From: Qazi Abubakar Date: Fri, 27 Nov 2020 12:55:16 +0500 Subject: [PATCH 60/78] Added new test case --- .../chw/core/rule/MonthlyAlertRuleTest.java | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 opensrp-chw-core/src/test/java/org/smartregister/chw/core/rule/MonthlyAlertRuleTest.java diff --git a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/rule/MonthlyAlertRuleTest.java b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/rule/MonthlyAlertRuleTest.java new file mode 100644 index 0000000000..266e61a24f --- /dev/null +++ b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/rule/MonthlyAlertRuleTest.java @@ -0,0 +1,48 @@ +package org.smartregister.chw.core.rule; + +import android.content.Context; + +import org.joda.time.DateTime; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.mockito.MockitoAnnotations; +import org.robolectric.RuntimeEnvironment; + +import java.util.Date; + +/** + * Created by Qazi Abubakar + */ +public class MonthlyAlertRuleTest { + Context context = RuntimeEnvironment.application; + private final long lastVisitDate = new DateTime().minusDays(7).toDate().getTime(); + private final long dateCreated = new DateTime().minusDays(30).toDate().getTime(); + private final MonthlyAlertRule monthlyAlertRule = new MonthlyAlertRule(context, lastVisitDate, dateCreated) { + @Override + public String getRuleKey() { + return "familyKitAlertRule"; + } + }; + + @Before + public void setUp() { + MockitoAnnotations.initMocks(this); + } + + @Test + public void testGetLastDayOfMonth(){ + DateTime first = new DateTime(new Date()).withDayOfMonth(1); + Date lastDate = first.plusMonths(1).minusDays(1).toDate(); + Assert.assertNotEquals(first.toDate(), monthlyAlertRule.getLastDayOfMonth(new Date())); + Assert.assertEquals(lastDate.toString(), monthlyAlertRule.getLastDayOfMonth(new Date()).toString()); + } + + @Test + public void testGetFirstDayOfMonth(){ + DateTime first = new DateTime(new Date()).withDayOfMonth(1); + Date lastDate = first.plusMonths(1).minusDays(1).toDate(); + Assert.assertEquals(first.toDate(), monthlyAlertRule.getFirstDayOfMonth(new Date())); + Assert.assertNotEquals(lastDate, monthlyAlertRule.getFirstDayOfMonth(new Date())); + } +} From 44ea7d3af13fd862bf538be4f41d59db8153ed7e Mon Sep 17 00:00:00 2001 From: Qazi Abubakar Date: Fri, 27 Nov 2020 13:01:05 +0500 Subject: [PATCH 61/78] Fixed codacy issue --- .../org/smartregister/chw/core/rule/MonthlyAlertRuleTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/rule/MonthlyAlertRuleTest.java b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/rule/MonthlyAlertRuleTest.java index 266e61a24f..42a1aa106c 100644 --- a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/rule/MonthlyAlertRuleTest.java +++ b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/rule/MonthlyAlertRuleTest.java @@ -15,7 +15,7 @@ * Created by Qazi Abubakar */ public class MonthlyAlertRuleTest { - Context context = RuntimeEnvironment.application; + private final Context context = RuntimeEnvironment.application; private final long lastVisitDate = new DateTime().minusDays(7).toDate().getTime(); private final long dateCreated = new DateTime().minusDays(30).toDate().getTime(); private final MonthlyAlertRule monthlyAlertRule = new MonthlyAlertRule(context, lastVisitDate, dateCreated) { From c43ceaaa9adffc9d287f16745cd7be2e28c9a28d Mon Sep 17 00:00:00 2001 From: paulinembabu Date: Fri, 27 Nov 2020 14:32:37 +0300 Subject: [PATCH 62/78] Resolves issue when saving Monthly reports --- gradle.properties | 2 +- .../chw/core/activity/HIA2ReportsActivity.java | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/gradle.properties b/gradle.properties index e206018289..23cdc90a68 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -VERSION_NAME=2.0.2-SNAPSHOT +VERSION_NAME=2.0.1-SNAPSHOT VERSION_CODE=1 GROUP=org.smartregister POM_SETTING_DESCRIPTION=OpenSRP Client Chw Core Library diff --git a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/HIA2ReportsActivity.java b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/HIA2ReportsActivity.java index 1a6741ebf2..ad1846e8c2 100644 --- a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/HIA2ReportsActivity.java +++ b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/HIA2ReportsActivity.java @@ -150,12 +150,8 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) { for (int j = 0; j < fieldsArray.length(); j++) { JSONObject fieldJsonObject = fieldsArray.getJSONObject(j); String key = fieldJsonObject.getString(KEY); - if (!fieldJsonObject.has(VALUE)) { - result.put(key, ""); - } else { - String value = fieldJsonObject.getString(VALUE); - result.put(key, value); - } + String value = !fieldJsonObject.has(VALUE) ? "" : fieldJsonObject.getString(VALUE); + result.put(key, value); } boolean saveClicked; From 18c97bdd8ae4bff5579ef368425a5b776cf742e3 Mon Sep 17 00:00:00 2001 From: paulinembabu Date: Fri, 27 Nov 2020 14:39:12 +0300 Subject: [PATCH 63/78] Bumps up version --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 23cdc90a68..9d173a07f1 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -VERSION_NAME=2.0.1-SNAPSHOT +VERSION_NAME=2.0.3-SNAPSHOT VERSION_CODE=1 GROUP=org.smartregister POM_SETTING_DESCRIPTION=OpenSRP Client Chw Core Library From 820feb4a6528be2b5957e2d3b71f4bb32c9d85bc Mon Sep 17 00:00:00 2001 From: Qazi Abubakar Date: Mon, 30 Nov 2020 15:27:50 +0500 Subject: [PATCH 64/78] changed access modifier for getDieataryFormatter method to override it later upgraded library version to 2.0.3-SNAPSHOT --- gradle.properties | 2 +- .../activity/DefaultChildMedicalHistoryActivityFlv.java | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/gradle.properties b/gradle.properties index e206018289..9d173a07f1 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -VERSION_NAME=2.0.2-SNAPSHOT +VERSION_NAME=2.0.3-SNAPSHOT VERSION_CODE=1 GROUP=org.smartregister POM_SETTING_DESCRIPTION=OpenSRP Client Chw Core Library diff --git a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/DefaultChildMedicalHistoryActivityFlv.java b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/DefaultChildMedicalHistoryActivityFlv.java index c3da6bda3f..c43852f48e 100644 --- a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/DefaultChildMedicalHistoryActivityFlv.java +++ b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/DefaultChildMedicalHistoryActivityFlv.java @@ -42,9 +42,9 @@ public abstract class DefaultChildMedicalHistoryActivityFlv implements CoreChild protected List visits; protected Map> visitMap = new LinkedHashMap<>(); protected Map> vaccineMap = new LinkedHashMap<>(); - private Context context; + public Context context; private LinearLayout parentView; - private SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy", Locale.getDefault()); + public SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy", Locale.getDefault()); @Override public View bindViews(Activity activity) { @@ -271,7 +271,7 @@ private VisitDetailsFormatter getDewormingFormatter() { }; } - private VisitDetailsFormatter getDieataryFormatter() { + public VisitDetailsFormatter getDieataryFormatter() { return (title, details, visitDate) -> { String diet_diversity = NCUtils.getText(details); String value = ""; @@ -423,7 +423,7 @@ private void medicalHistory(List medicalHistories, String type, } } - private interface VisitDetailsFormatter { + public interface VisitDetailsFormatter { String format(String title, List details, Date visitDate); } } From 29c39db312d0aab6a7a24637f43f85408a368809 Mon Sep 17 00:00:00 2001 From: Qazi Abubakar Date: Mon, 30 Nov 2020 18:38:52 +0500 Subject: [PATCH 65/78] upgraded library version to 2.0.4-SNAPSHOT --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 9d173a07f1..248f3ad7e5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -VERSION_NAME=2.0.3-SNAPSHOT +VERSION_NAME=2.0.4-SNAPSHOT VERSION_CODE=1 GROUP=org.smartregister POM_SETTING_DESCRIPTION=OpenSRP Client Chw Core Library From 875e12b345f6db36be16dc7238a6686af1a47ce8 Mon Sep 17 00:00:00 2001 From: Allan O Date: Tue, 1 Dec 2020 10:47:51 +0300 Subject: [PATCH 66/78] :white_check_mark: Add FPAlertRuleTest --- .../chw/core/rule/FpAlertRuleTest.java | 101 ++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 opensrp-chw-core/src/test/java/org/smartregister/chw/core/rule/FpAlertRuleTest.java diff --git a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/rule/FpAlertRuleTest.java b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/rule/FpAlertRuleTest.java new file mode 100644 index 0000000000..1f3360005f --- /dev/null +++ b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/rule/FpAlertRuleTest.java @@ -0,0 +1,101 @@ +package org.smartregister.chw.core.rule; + +import org.joda.time.DateTime; +import org.joda.time.LocalDate; +import org.joda.time.LocalTime; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.robolectric.util.ReflectionHelpers; +import org.smartregister.chw.core.BaseRobolectricTest; +import org.smartregister.chw.core.utils.CoreConstants; +import org.smartregister.chw.fp.util.FamilyPlanningConstants; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; + +public class FpAlertRuleTest extends BaseRobolectricTest { + + private FpAlertRule fpAlertRule; + private DateTime lastVisitDate; + private DateTime dueDate; + private DateTime expiryDate; + private DateTime overDueDate; + + @Before + public void setUp() throws ParseException { + Date fpDate = new SimpleDateFormat("dd-MM-yyyy").parse("17-11-2020"); + Date lastVisit = new SimpleDateFormat("dd-MM-yyyy").parse("17-10-2020"); + fpAlertRule = new FpAlertRule(fpDate, lastVisit, 10, FamilyPlanningConstants.DBConstants.FP_COC); + ReflectionHelpers.setField(fpAlertRule, "visitID", "test-visit-id"); + } + + + @Test + public void canGetVisitId() { + Assert.assertEquals("test-visit-id", fpAlertRule.getVisitID()); + } + + + @Test + public void canGetIfFemaleSterilizationFollowUpOneValid() { + ReflectionHelpers.setField(fpAlertRule, "fpDifference", 5); + Assert.assertFalse(fpAlertRule.isFemaleSterilizationFollowUpOneValid(10, 15, 20)); + Assert.assertTrue(fpAlertRule.isFemaleSterilizationFollowUpOneValid(2, 6, 10)); + } + + @Test + public void buttonStatusDoneIfVisitBeforeExpiry() { + lastVisitDate = LocalDate.now().toDateTime(LocalTime.MIDNIGHT); + dueDate = LocalDate.now().minusDays(5).toDateTime(LocalTime.MIDNIGHT); + expiryDate = LocalDate.now().plusDays(10).toDateTime(LocalTime.MIDNIGHT); + + ReflectionHelpers.setField(fpAlertRule, "dueDate", dueDate); + ReflectionHelpers.setField(fpAlertRule, "expiryDate", expiryDate); + ReflectionHelpers.setField(fpAlertRule, "lastVisitDate", lastVisitDate); + Assert.assertEquals(CoreConstants.VISIT_STATE.VISIT_DONE, fpAlertRule.getButtonStatus()); + } + + @Test + public void buttonStatusDueIfVisitBeforeOverdue() { + lastVisitDate = LocalDate.now().minusDays(10).toDateTime(LocalTime.MIDNIGHT); + dueDate = LocalDate.now().minusDays(5).toDateTime(LocalTime.MIDNIGHT); + overDueDate = LocalDate.now().plusDays(10).toDateTime(LocalTime.MIDNIGHT); + + ReflectionHelpers.setField(fpAlertRule, "dueDate", dueDate); + ReflectionHelpers.setField(fpAlertRule, "overDueDate", overDueDate); + ReflectionHelpers.setField(fpAlertRule, "lastVisitDate", lastVisitDate); + Assert.assertEquals(CoreConstants.VISIT_STATE.DUE, fpAlertRule.getButtonStatus()); + } + + + @Test + public void buttonStatusOverDueIfVisitAfterOverdue() { + lastVisitDate = LocalDate.now().minusDays(10).toDateTime(LocalTime.MIDNIGHT); + dueDate = LocalDate.now().minusDays(5).toDateTime(LocalTime.MIDNIGHT); + overDueDate = LocalDate.now().minusDays(1).toDateTime(LocalTime.MIDNIGHT); + expiryDate = LocalDate.now().plusDays(10).toDateTime(LocalTime.MIDNIGHT); + + ReflectionHelpers.setField(fpAlertRule, "dueDate", dueDate); + ReflectionHelpers.setField(fpAlertRule, "expiryDate", expiryDate); + ReflectionHelpers.setField(fpAlertRule, "overDueDate", overDueDate); + ReflectionHelpers.setField(fpAlertRule, "lastVisitDate", lastVisitDate); + Assert.assertEquals(CoreConstants.VISIT_STATE.OVERDUE, fpAlertRule.getButtonStatus()); + } + + + @Test + public void buttonStatusNotDueIfDateBeforeDueAndExpiry() { + lastVisitDate = LocalDate.now().toDateTime(LocalTime.MIDNIGHT); + dueDate = LocalDate.now().plusDays(10).toDateTime(LocalTime.MIDNIGHT); + expiryDate = LocalDate.now().plusDays(20).toDateTime(LocalTime.MIDNIGHT); + + ReflectionHelpers.setField(fpAlertRule, "dueDate", dueDate); + ReflectionHelpers.setField(fpAlertRule, "expiryDate", expiryDate); + ReflectionHelpers.setField(fpAlertRule, "lastVisitDate", lastVisitDate); + Assert.assertEquals(CoreConstants.VISIT_STATE.NOT_DUE_YET, fpAlertRule.getButtonStatus()); + } + + +} \ No newline at end of file From a5d59ea2ec7edf7b66def26dc7840c4fc38fb83a Mon Sep 17 00:00:00 2001 From: rkodev <43806892+rkodev@users.noreply.github.com> Date: Tue, 1 Dec 2020 11:52:43 +0300 Subject: [PATCH 67/78] Adds tests --- .../smartregister/chw/core/utils/Utils.java | 27 +++++++- .../chw/core/utils/UtilsTest.java | 65 +++++++++++++++++++ 2 files changed, 91 insertions(+), 1 deletion(-) diff --git a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/utils/Utils.java b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/utils/Utils.java index 3ff6698bf6..f10653415b 100644 --- a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/utils/Utils.java +++ b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/utils/Utils.java @@ -101,14 +101,29 @@ public abstract class Utils extends org.smartregister.family.util.Utils { public static final SimpleDateFormat yyyy_mm_dd = new SimpleDateFormat("yyyy-mm-dd"); private static List assets; + /** + * Can be replaced with a final constant or direct reference + * @return + */ + @Deprecated public static int getAnCWomanImageResourceIdentifier() { return R.drawable.anc_woman; } + /** + * Can be replaced with a final constant or direct reference + * @return + */ + @Deprecated public static int getPnCWomanImageResourceIdentifier() { return R.drawable.pnc_woman; } + /** + * Can be replaced with a final constant or direct reference + * @return + */ + @Deprecated public static int getMemberImageResourceIdentifier() { return R.mipmap.ic_member; } @@ -154,7 +169,7 @@ public static String firstCharacterUppercase(String str) { } public static String convertToDateFormateString(String timeAsDDMMYYYY, SimpleDateFormat dateFormat) { - SimpleDateFormat sdf = new SimpleDateFormat("dd-mm-yyyy", Locale.getDefault());//12-08-2018 + SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy", Locale.getDefault());//12-08-2018 try { Date date = sdf.parse(timeAsDDMMYYYY); return dateFormat.format(date); @@ -229,10 +244,20 @@ public static Bitmap getBitmap(Drawable drawable) { return result; } + /** + * Can be replaced with a final constant or direct reference + * @return + */ + @Deprecated public static int getOverDueProfileImageResourceIDentifier() { return R.color.visit_status_over_due; } + /** + * Can be replaced with a final constant or direct reference + * @return + */ + @Deprecated public static int getDueProfileImageResourceIDentifier() { return R.color.due_profile_blue; } diff --git a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/utils/UtilsTest.java b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/utils/UtilsTest.java index 8c31ae1fb5..3193c58536 100644 --- a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/utils/UtilsTest.java +++ b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/utils/UtilsTest.java @@ -16,6 +16,7 @@ import org.robolectric.RobolectricTestRunner; import org.robolectric.RuntimeEnvironment; import org.robolectric.annotation.Config; +import org.smartregister.chw.core.R; import org.smartregister.chw.core.application.CoreChwApplication; import org.smartregister.chw.core.application.TestApplication; import org.smartregister.chw.referral.domain.MemberObject; @@ -50,6 +51,70 @@ public void setUp() { MockitoAnnotations.initMocks(this); } + @Test + public void testGetAnCWomanImageResourceIdentifier() { + Assert.assertEquals(R.drawable.anc_woman, Utils.getAnCWomanImageResourceIdentifier()); + } + + @Test + public void testGetPnCWomanImageResourceIdentifier() { + Assert.assertEquals(R.drawable.pnc_woman, Utils.getPnCWomanImageResourceIdentifier()); + } + + @Test + public void testGetMemberImageResourceIdentifier() { + Assert.assertEquals(R.mipmap.ic_member, Utils.getMemberImageResourceIdentifier()); + } + + @Test + public void testGetYesNoAsLanguageSpecific() { + Assert.assertEquals(context.getString(R.string.yes), Utils.getYesNoAsLanguageSpecific(context, "Yes")); + Assert.assertEquals(context.getString(R.string.yes), Utils.getYesNoAsLanguageSpecific(context, "YES")); + Assert.assertEquals("", Utils.getYesNoAsLanguageSpecific(context, "")); + Assert.assertEquals(context.getString(R.string.no), Utils.getYesNoAsLanguageSpecific(context, "No")); + Assert.assertEquals(context.getString(R.string.no), Utils.getYesNoAsLanguageSpecific(context, "NO")); + Assert.assertEquals("other", Utils.getYesNoAsLanguageSpecific(context, "other")); + } + + @Test + public void testFirstCharacterUppercase() { + Assert.assertEquals(Utils.firstCharacterUppercase(" "), " "); + Assert.assertEquals(Utils.firstCharacterUppercase(""), ""); + Assert.assertEquals(Utils.firstCharacterUppercase("mike"), "Mike"); + Assert.assertEquals(Utils.firstCharacterUppercase("s"), "S"); + Assert.assertEquals(Utils.firstCharacterUppercase("kevin hart"), "Kevin hart"); + } + + @Test + public void testConvertToDateFormateString() { + Assert.assertEquals("2018-08-12", Utils.convertToDateFormateString("12-08-2018", new SimpleDateFormat("yyyy-MM-dd"))); + Assert.assertEquals("", Utils.convertToDateFormateString("me", new SimpleDateFormat("yyyy-MM-dd"))); + } + + @Test + public void testGetOverDueProfileImageResourceIDentifier() { + Assert.assertEquals(R.color.visit_status_over_due, Utils.getOverDueProfileImageResourceIDentifier()); + } + + @Test + public void testGetDueProfileImageResourceIDentifier() { + Assert.assertEquals(R.color.due_profile_blue, Utils.getDueProfileImageResourceIDentifier()); + } + + /* + public void testProcessOldEvents(){ + Gson gson = new Gson(); + String oldIllnessInfo = "{\"identifiers\":{},\"baseEntityId\":\"d0da64ab-ab8c-4cd8-ab18-e2661009e436\",\"locationId\":\"402ecf03-af72-4c93-b099-e1ce327d815b\",\"eventDate\":\"2019-08-30T22:21:26.660Z\",\"eventType\":\"Child Home Visit\",\"formSubmissionId\":\"2735394b-b799-4cd0-9d2b-6d84d34448d9\",\"providerId\":\"chaone\",\"duration\":0,\"obs\":[{\"fieldType\":\"formsubmissionField\",\"fieldDataType\":\"text\",\"fieldCode\":\"home_visit_id\",\"parentCode\":\"\",\"values\":[\"6f28e369-0db3-44a1-a61f-5b907a98f13e\"],\"set\":[],\"formSubmissionField\":\"home_visit_id\",\"humanReadableValues\":[]},{\"fieldType\":\"formsubmissionField\",\"fieldDataType\":\"text\",\"fieldCode\":\"last_home_visit\",\"parentCode\":\"\",\"values\":[\"1567174886622\"],\"set\":[],\"formSubmissionField\":\"last_home_visit\",\"humanReadableValues\":[]},{\"fieldType\":\"formsubmissionField\",\"fieldDataType\":\"text\",\"fieldCode\":\"singleVaccine\",\"parentCode\":\"\",\"values\":[\"{\\\"singleVaccinesGiven\\\":[]}\"],\"set\":[],\"formSubmissionField\":\"singleVaccine\",\"humanReadableValues\":[]},{\"fieldType\":\"formsubmissionField\",\"fieldDataType\":\"text\",\"fieldCode\":\"groupVaccine\",\"parentCode\":\"\",\"values\":[\"{\\\"groupVaccinesGiven\\\":[]}\"],\"set\":[],\"formSubmissionField\":\"groupVaccine\",\"humanReadableValues\":[]},{\"fieldType\":\"formsubmissionField\",\"fieldDataType\":\"text\",\"fieldCode\":\"vaccineNotGiven\",\"parentCode\":\"\",\"values\":[\"{\\\"vaccineNotGiven\\\":[]}\"],\"set\":[],\"formSubmissionField\":\"vaccineNotGiven\",\"humanReadableValues\":[]},{\"fieldType\":\"formsubmissionField\",\"fieldDataType\":\"text\",\"fieldCode\":\"service\",\"parentCode\":\"\",\"values\":[\"{\\\"Vitamin A\\\":{\\\"alert\\\":{\\\"caseID\\\":\\\"d0da64ab-ab8c-4cd8-ab18-e2661009e436\\\",\\\"completionDate\\\":null,\\\"expiryDate\\\":\\\"2019-09-23\\\",\\\"offline\\\":true,\\\"scheduleName\\\":\\\"Vitamin A1\\\",\\\"startDate\\\":\\\"2015-03-23\\\",\\\"status\\\":\\\"normal\\\",\\\"visitCode\\\":\\\"vitamina1\\\"},\\\"color\\\":null,\\\"createdAt\\\":null,\\\"dbKey\\\":1,\\\"defaultName\\\":\\\"Vitamin A\\\",\\\"dob\\\":\\\"2014-09-23T08:00:00.000+08:00\\\",\\\"gender\\\":\\\"Male\\\",\\\"id\\\":\\\"d0da64ab-ab8c-4cd8-ab18-e2661009e436\\\",\\\"patientName\\\":\\\"Doudou Balde\\\",\\\"patientNumber\\\":\\\"\\\",\\\"photo\\\":{\\\"filePath\\\":null,\\\"resourceId\\\":2131230828},\\\"previousVaccineId\\\":null,\\\"serviceType\\\":{\\\"dateEntity\\\":\\\"encounter\\\",\\\"dateEntityId\\\":\\\"encounter_date\\\",\\\"expiryOffset\\\":\\\"+5y\\\",\\\"id\\\":13,\\\"milestoneOffset\\\":\\\"[+6m]\\\",\\\"name\\\":\\\"Vitamin A1\\\",\\\"preOffset\\\":\\\"+6m\\\",\\\"prerequisite\\\":\\\"dob\\\",\\\"serviceGroup\\\":\\\"child\\\",\\\"serviceLogic\\\":\\\"\\\",\\\"serviceNameEntity\\\":\\\"concept\\\",\\\"serviceNameEntityId\\\":\\\"86339AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\\\",\\\"type\\\":\\\"Vitamin A\\\",\\\"units\\\":null,\\\"updatedAt\\\":1566980540710},\\\"status\\\":\\\"due\\\",\\\"synced\\\":false,\\\"today\\\":false,\\\"updatedVaccineDate\\\":\\\"2019-08-30T22:20:42.718+08:00\\\",\\\"vaccineDate\\\":\\\"2015-03-23T00:00:00.000+08:00\\\",\\\"value\\\":null}}\"],\"set\":[],\"formSubmissionField\":\"service\",\"humanReadableValues\":[]},{\"fieldType\":\"formsubmissionField\",\"fieldDataType\":\"text\",\"fieldCode\":\"serviceNotGiven\",\"parentCode\":\"\",\"values\":[\"{\\\"Deworming\\\":{\\\"alert\\\":{\\\"caseID\\\":\\\"d0da64ab-ab8c-4cd8-ab18-e2661009e436\\\",\\\"completionDate\\\":null,\\\"expiryDate\\\":\\\"2019-09-23\\\",\\\"offline\\\":true,\\\"scheduleName\\\":\\\"Deworming 1\\\",\\\"startDate\\\":\\\"2015-09-23\\\",\\\"status\\\":\\\"normal\\\",\\\"visitCode\\\":\\\"deworming1\\\"},\\\"color\\\":null,\\\"createdAt\\\":null,\\\"dbKey\\\":null,\\\"defaultName\\\":\\\"Deworming\\\",\\\"dob\\\":\\\"2014-09-23T08:00:00.000+08:00\\\",\\\"gender\\\":\\\"Male\\\",\\\"id\\\":\\\"d0da64ab-ab8c-4cd8-ab18-e2661009e436\\\",\\\"patientName\\\":\\\"Doudou Balde\\\",\\\"patientNumber\\\":\\\"\\\",\\\"photo\\\":{\\\"filePath\\\":null,\\\"resourceId\\\":2131230828},\\\"previousVaccineId\\\":null,\\\"serviceType\\\":{\\\"dateEntity\\\":\\\"encounter\\\",\\\"dateEntityId\\\":\\\"encounter_date\\\",\\\"expiryOffset\\\":\\\"+5y\\\",\\\"id\\\":22,\\\"milestoneOffset\\\":\\\"[+1y]\\\",\\\"name\\\":\\\"Deworming 1\\\",\\\"preOffset\\\":\\\"+1y\\\",\\\"prerequisite\\\":\\\"dob\\\",\\\"serviceGroup\\\":\\\"child\\\",\\\"serviceLogic\\\":\\\"\\\",\\\"serviceNameEntity\\\":\\\"concept\\\",\\\"serviceNameEntityId\\\":\\\"159922AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\\\",\\\"type\\\":\\\"Deworming\\\",\\\"units\\\":null,\\\"updatedAt\\\":1566980540721},\\\"status\\\":\\\"due\\\",\\\"synced\\\":false,\\\"today\\\":false,\\\"updatedVaccineDate\\\":null,\\\"vaccineDate\\\":\\\"2015-09-23T00:00:00.000+08:00\\\",\\\"value\\\":null}}\"],\"set\":[],\"formSubmissionField\":\"serviceNotGiven\",\"humanReadableValues\":[]},{\"fieldType\":\"formsubmissionField\",\"fieldDataType\":\"text\",\"fieldCode\":\"birth_certificate\",\"parentCode\":\"\",\"values\":[\"{\\\"birtCert\\\":\\\"{\\\\\\\"count\\\\\\\":\\\\\\\"1\\\\\\\",\\\\\\\"encounter_type\\\\\\\":\\\\\\\"Birth Certification\\\\\\\",\\\\\\\"entity_id\\\\\\\":\\\\\\\"d0da64ab-ab8c-4cd8-ab18-e2661009e436\\\\\\\",\\\\\\\"metadata\\\\\\\":{\\\\\\\"start\\\\\\\":{\\\\\\\"openmrs_entity_parent\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"openmrs_entity\\\\\\\":\\\\\\\"concept\\\\\\\",\\\\\\\"openmrs_data_type\\\\\\\":\\\\\\\"start\\\\\\\",\\\\\\\"openmrs_entity_id\\\\\\\":\\\\\\\"163137AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\\\\\\\",\\\\\\\"value\\\\\\\":\\\\\\\"2019-08-30 22:20:17\\\\\\\"},\\\\\\\"end\\\\\\\":{\\\\\\\"openmrs_entity_parent\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"openmrs_entity\\\\\\\":\\\\\\\"concept\\\\\\\",\\\\\\\"openmrs_data_type\\\\\\\":\\\\\\\"end\\\\\\\",\\\\\\\"openmrs_entity_id\\\\\\\":\\\\\\\"163138AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\\\\\\\",\\\\\\\"value\\\\\\\":\\\\\\\"2019-08-30 22:20:38\\\\\\\"},\\\\\\\"today\\\\\\\":{\\\\\\\"openmrs_entity_parent\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"openmrs_entity\\\\\\\":\\\\\\\"encounter\\\\\\\",\\\\\\\"openmrs_entity_id\\\\\\\":\\\\\\\"encounter_date\\\\\\\",\\\\\\\"value\\\\\\\":\\\\\\\"30-08-2019\\\\\\\"},\\\\\\\"deviceid\\\\\\\":{\\\\\\\"openmrs_entity_parent\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"openmrs_entity\\\\\\\":\\\\\\\"concept\\\\\\\",\\\\\\\"openmrs_data_type\\\\\\\":\\\\\\\"deviceid\\\\\\\",\\\\\\\"openmrs_entity_id\\\\\\\":\\\\\\\"163149AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\\\\\\\",\\\\\\\"value\\\\\\\":\\\\\\\"865959046137007\\\\\\\"},\\\\\\\"subscriberid\\\\\\\":{\\\\\\\"openmrs_entity_parent\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"openmrs_entity\\\\\\\":\\\\\\\"concept\\\\\\\",\\\\\\\"openmrs_data_type\\\\\\\":\\\\\\\"subscriberid\\\\\\\",\\\\\\\"openmrs_entity_id\\\\\\\":\\\\\\\"163150AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\\\\\\\",\\\\\\\"value\\\\\\\":\\\\\\\"460031208673496\\\\\\\"},\\\\\\\"simserial\\\\\\\":{\\\\\\\"openmrs_entity_parent\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"openmrs_entity\\\\\\\":\\\\\\\"concept\\\\\\\",\\\\\\\"openmrs_data_type\\\\\\\":\\\\\\\"simserial\\\\\\\",\\\\\\\"openmrs_entity_id\\\\\\\":\\\\\\\"163151AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\\\\\\\",\\\\\\\"value\\\\\\\":\\\\\\\"89860314107971674978\\\\\\\"},\\\\\\\"phonenumber\\\\\\\":{\\\\\\\"openmrs_entity_parent\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"openmrs_entity\\\\\\\":\\\\\\\"concept\\\\\\\",\\\\\\\"openmrs_data_type\\\\\\\":\\\\\\\"phonenumber\\\\\\\",\\\\\\\"openmrs_entity_id\\\\\\\":\\\\\\\"163152AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\\\\\\\",\\\\\\\"value\\\\\\\":\\\\\\\"\\\\\\\"},\\\\\\\"encounter_location\\\\\\\":\\\\\\\"\\\\\\\"},\\\\\\\"step1\\\\\\\":{\\\\\\\"title\\\\\\\":\\\\\\\"Birth Certification\\\\\\\",\\\\\\\"fields\\\\\\\":[{\\\\\\\"key\\\\\\\":\\\\\\\"birth_cert\\\\\\\",\\\\\\\"openmrs_entity_parent\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"openmrs_entity\\\\\\\":\\\\\\\"concept\\\\\\\",\\\\\\\"openmrs_entity_id\\\\\\\":\\\\\\\"165406AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\\\\\\\",\\\\\\\"openmrs_data_type\\\\\\\":\\\\\\\"select one\\\\\\\",\\\\\\\"type\\\\\\\":\\\\\\\"spinner\\\\\\\",\\\\\\\"hint\\\\\\\":\\\\\\\"Does the child have a birth certificate?\\\\\\\",\\\\\\\"values\\\\\\\":[\\\\\\\"Yes\\\\\\\",\\\\\\\"No\\\\\\\"],\\\\\\\"openmrs_choice_ids\\\\\\\":{\\\\\\\"Yes\\\\\\\":\\\\\\\"1065AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\\\\\\\",\\\\\\\"No\\\\\\\":\\\\\\\"1066AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\\\\\\\"},\\\\\\\"v_required\\\\\\\":{\\\\\\\"value\\\\\\\":true,\\\\\\\"err\\\\\\\":\\\\\\\"Please select option\\\\\\\"},\\\\\\\"step\\\\\\\":\\\\\\\"step1\\\\\\\",\\\\\\\"is-rule-check\\\\\\\":true,\\\\\\\"value\\\\\\\":\\\\\\\"Yes\\\\\\\"},{\\\\\\\"key\\\\\\\":\\\\\\\"birth_cert_issue_date\\\\\\\",\\\\\\\"openmrs_entity_parent\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"openmrs_entity\\\\\\\":\\\\\\\"concept\\\\\\\",\\\\\\\"openmrs_entity_id\\\\\\\":\\\\\\\"164129AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\\\\\\\",\\\\\\\"type\\\\\\\":\\\\\\\"date_picker\\\\\\\",\\\\\\\"hint\\\\\\\":\\\\\\\"Birth certificate issuance date\\\\\\\",\\\\\\\"expanded\\\\\\\":false,\\\\\\\"max_date\\\\\\\":\\\\\\\"today\\\\\\\",\\\\\\\"min_date\\\\\\\":\\\\\\\"today-1802d\\\\\\\",\\\\\\\"v_required\\\\\\\":{\\\\\\\"value\\\\\\\":\\\\\\\"true\\\\\\\",\\\\\\\"err\\\\\\\":\\\\\\\"Please enter Birth certificate issuance date\\\\\\\"},\\\\\\\"relevance\\\\\\\":{\\\\\\\"rules-engine\\\\\\\":{\\\\\\\"ex-rules\\\\\\\":{\\\\\\\"rules-file\\\\\\\":\\\\\\\"birth_certification.yml\\\\\\\"}}},\\\\\\\"is_visible\\\\\\\":true,\\\\\\\"value\\\\\\\":\\\\\\\"30-08-2019\\\\\\\"},{\\\\\\\"key\\\\\\\":\\\\\\\"birth_cert_num\\\\\\\",\\\\\\\"openmrs_entity_parent\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"openmrs_entity\\\\\\\":\\\\\\\"concept\\\\\\\",\\\\\\\"openmrs_entity_id\\\\\\\":\\\\\\\"162052AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\\\\\\\",\\\\\\\"openmrs_data_type\\\\\\\":\\\\\\\"text\\\\\\\",\\\\\\\"type\\\\\\\":\\\\\\\"edit_text\\\\\\\",\\\\\\\"hint\\\\\\\":\\\\\\\"Birth certificate number\\\\\\\",\\\\\\\"v_required\\\\\\\":{\\\\\\\"value\\\\\\\":\\\\\\\"true\\\\\\\",\\\\\\\"err\\\\\\\":\\\\\\\"Please enter number\\\\\\\"},\\\\\\\"relevance\\\\\\\":{\\\\\\\"rules-engine\\\\\\\":{\\\\\\\"ex-rules\\\\\\\":{\\\\\\\"rules-file\\\\\\\":\\\\\\\"birth_certification.yml\\\\\\\"}}},\\\\\\\"is_visible\\\\\\\":true,\\\\\\\"value\\\\\\\":\\\\\\\"20150901\\\\\\\"},{\\\\\\\"key\\\\\\\":\\\\\\\"birth_notification\\\\\\\",\\\\\\\"openmrs_entity_parent\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"openmrs_entity\\\\\\\":\\\\\\\"concept\\\\\\\",\\\\\\\"openmrs_entity_id\\\\\\\":\\\\\\\"165405AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\\\\\\\",\\\\\\\"openmrs_data_type\\\\\\\":\\\\\\\"select one\\\\\\\",\\\\\\\"type\\\\\\\":\\\\\\\"spinner\\\\\\\",\\\\\\\"hint\\\\\\\":\\\\\\\"Was the birth notification done?\\\\\\\",\\\\\\\"values\\\\\\\":[\\\\\\\"Yes\\\\\\\",\\\\\\\"No\\\\\\\"],\\\\\\\"openmrs_choice_ids\\\\\\\":{\\\\\\\"Yes\\\\\\\":\\\\\\\"1065AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\\\\\\\",\\\\\\\"No\\\\\\\":\\\\\\\"1066AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\\\\\\\"},\\\\\\\"v_required\\\\\\\":{\\\\\\\"value\\\\\\\":false,\\\\\\\"err\\\\\\\":\\\\\\\"Please select option\\\\\\\"},\\\\\\\"relevance\\\\\\\":{\\\\\\\"rules-engine\\\\\\\":{\\\\\\\"ex-rules\\\\\\\":{\\\\\\\"rules-file\\\\\\\":\\\\\\\"birth_certification.yml\\\\\\\"}}},\\\\\\\"is_visible\\\\\\\":false,\\\\\\\"step\\\\\\\":\\\\\\\"step1\\\\\\\",\\\\\\\"is-rule-check\\\\\\\":true},{\\\\\\\"key\\\\\\\":\\\\\\\"birthinstroductions\\\\\\\",\\\\\\\"openmrs_entity_parent\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"openmrs_entity\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"openmrs_entity_id\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"type\\\\\\\":\\\\\\\"label\\\\\\\",\\\\\\\"text\\\\\\\":\\\\\\\"Ask to see the birth notification and instruct the caregiver to register the birth at County Health.\\\\\\\",\\\\\\\"relevance\\\\\\\":{\\\\\\\"rules-engine\\\\\\\":{\\\\\\\"ex-rules\\\\\\\":{\\\\\\\"rules-file\\\\\\\":\\\\\\\"birth_certification.yml\\\\\\\"}}},\\\\\\\"is_visible\\\\\\\":false},{\\\\\\\"key\\\\\\\":\\\\\\\"caregiverinstroductions\\\\\\\",\\\\\\\"openmrs_entity_parent\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"openmrs_entity\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"openmrs_entity_id\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"type\\\\\\\":\\\\\\\"label\\\\\\\",\\\\\\\"text\\\\\\\":\\\\\\\"Instruct the caregiver to have the birth registered at County Health.\\\\\\\",\\\\\\\"relevance\\\\\\\":{\\\\\\\"rules-engine\\\\\\\":{\\\\\\\"ex-rules\\\\\\\":{\\\\\\\"rules-file\\\\\\\":\\\\\\\"birth_certification.yml\\\\\\\"}}},\\\\\\\"is_visible\\\\\\\":false}]}}\\\"}\"],\"set\":[],\"formSubmissionField\":\"birth_certificate\",\"humanReadableValues\":[]},{\"fieldType\":\"formsubmissionField\",\"fieldDataType\":\"text\",\"fieldCode\":\"illness_information\",\"parentCode\":\"\",\"values\":[\"{}\"],\"set\":[],\"formSubmissionField\":\"illness_information\",\"humanReadableValues\":[]}],\"entityType\":\"ec_child\",\"version\":1567174886660,\"teamId\":\"d9eb010a-6d03-4bf8-b57a-b488dedd6f51\",\"team\":\"Clinic A Team\",\"dateCreated\":\"2019-08-30T14:21:50.258Z\",\"serverVersion\":1567174910258,\"clientApplicationVersion\":1,\"clientDatabaseVersion\":9,\"type\":\"Event\",\"id\":\"2e2601e9-e612-4eb5-9ca2-0ea19829fac2\",\"revision\":\"v1\"}"; + String oldServiceEvent = "{\"identifiers\":{},\"baseEntityId\":\"d0da64ab-ab8c-4cd8-ab18-e2661009e436\",\"locationId\":\"402ecf03-af72-4c93-b099-e1ce327d815b\",\"eventDate\":\"2019-08-30T22:21:26.660Z\",\"eventType\":\"Child Home Visit\",\"formSubmissionId\":\"2735394b-b799-4cd0-9d2b-6d84d34448d9\",\"providerId\":\"chaone\",\"duration\":0,\"obs\":[{\"fieldType\":\"formsubmissionField\",\"fieldDataType\":\"text\",\"fieldCode\":\"home_visit_id\",\"parentCode\":\"\",\"values\":[\"6f28e369-0db3-44a1-a61f-5b907a98f13e\"],\"set\":[],\"formSubmissionField\":\"home_visit_id\",\"humanReadableValues\":[]},{\"fieldType\":\"formsubmissionField\",\"fieldDataType\":\"text\",\"fieldCode\":\"last_home_visit\",\"parentCode\":\"\",\"values\":[\"1567174886622\"],\"set\":[],\"formSubmissionField\":\"last_home_visit\",\"humanReadableValues\":[]},{\"fieldType\":\"formsubmissionField\",\"fieldDataType\":\"text\",\"fieldCode\":\"singleVaccine\",\"parentCode\":\"\",\"values\":[\"{\\\"singleVaccinesGiven\\\":[]}\"],\"set\":[],\"formSubmissionField\":\"singleVaccine\",\"humanReadableValues\":[]},{\"fieldType\":\"formsubmissionField\",\"fieldDataType\":\"text\",\"fieldCode\":\"groupVaccine\",\"parentCode\":\"\",\"values\":[\"{\\\"groupVaccinesGiven\\\":[]}\"],\"set\":[],\"formSubmissionField\":\"groupVaccine\",\"humanReadableValues\":[]},{\"fieldType\":\"formsubmissionField\",\"fieldDataType\":\"text\",\"fieldCode\":\"vaccineNotGiven\",\"parentCode\":\"\",\"values\":[\"{\\\"vaccineNotGiven\\\":[]}\"],\"set\":[],\"formSubmissionField\":\"vaccineNotGiven\",\"humanReadableValues\":[]},{\"fieldType\":\"formsubmissionField\",\"fieldDataType\":\"text\",\"fieldCode\":\"service\",\"parentCode\":\"\",\"values\":[\"{\\\"Vitamin A\\\":{\\\"alert\\\":{\\\"caseID\\\":\\\"d0da64ab-ab8c-4cd8-ab18-e2661009e436\\\",\\\"completionDate\\\":null,\\\"expiryDate\\\":\\\"2019-09-23\\\",\\\"offline\\\":true,\\\"scheduleName\\\":\\\"Vitamin A1\\\",\\\"startDate\\\":\\\"2015-03-23\\\",\\\"status\\\":\\\"normal\\\",\\\"visitCode\\\":\\\"vitamina1\\\"},\\\"color\\\":null,\\\"createdAt\\\":null,\\\"dbKey\\\":1,\\\"defaultName\\\":\\\"Vitamin A\\\",\\\"dob\\\":\\\"2014-09-23T08:00:00.000+08:00\\\",\\\"gender\\\":\\\"Male\\\",\\\"id\\\":\\\"d0da64ab-ab8c-4cd8-ab18-e2661009e436\\\",\\\"patientName\\\":\\\"Doudou Balde\\\",\\\"patientNumber\\\":\\\"\\\",\\\"photo\\\":{\\\"filePath\\\":null,\\\"resourceId\\\":2131230828},\\\"previousVaccineId\\\":null,\\\"serviceType\\\":{\\\"dateEntity\\\":\\\"encounter\\\",\\\"dateEntityId\\\":\\\"encounter_date\\\",\\\"expiryOffset\\\":\\\"+5y\\\",\\\"id\\\":13,\\\"milestoneOffset\\\":\\\"[+6m]\\\",\\\"name\\\":\\\"Vitamin A1\\\",\\\"preOffset\\\":\\\"+6m\\\",\\\"prerequisite\\\":\\\"dob\\\",\\\"serviceGroup\\\":\\\"child\\\",\\\"serviceLogic\\\":\\\"\\\",\\\"serviceNameEntity\\\":\\\"concept\\\",\\\"serviceNameEntityId\\\":\\\"86339AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\\\",\\\"type\\\":\\\"Vitamin A\\\",\\\"units\\\":null,\\\"updatedAt\\\":1566980540710},\\\"status\\\":\\\"due\\\",\\\"synced\\\":false,\\\"today\\\":false,\\\"updatedVaccineDate\\\":\\\"2019-08-30T22:20:42.718+08:00\\\",\\\"vaccineDate\\\":\\\"2015-03-23T00:00:00.000+08:00\\\",\\\"value\\\":null}}\"],\"set\":[],\"formSubmissionField\":\"service\",\"humanReadableValues\":[]},{\"fieldType\":\"formsubmissionField\",\"fieldDataType\":\"text\",\"fieldCode\":\"serviceNotGiven\",\"parentCode\":\"\",\"values\":[\"{\\\"Deworming\\\":{\\\"alert\\\":{\\\"caseID\\\":\\\"d0da64ab-ab8c-4cd8-ab18-e2661009e436\\\",\\\"completionDate\\\":null,\\\"expiryDate\\\":\\\"2019-09-23\\\",\\\"offline\\\":true,\\\"scheduleName\\\":\\\"Deworming 1\\\",\\\"startDate\\\":\\\"2015-09-23\\\",\\\"status\\\":\\\"normal\\\",\\\"visitCode\\\":\\\"deworming1\\\"},\\\"color\\\":null,\\\"createdAt\\\":null,\\\"dbKey\\\":null,\\\"defaultName\\\":\\\"Deworming\\\",\\\"dob\\\":\\\"2014-09-23T08:00:00.000+08:00\\\",\\\"gender\\\":\\\"Male\\\",\\\"id\\\":\\\"d0da64ab-ab8c-4cd8-ab18-e2661009e436\\\",\\\"patientName\\\":\\\"Doudou Balde\\\",\\\"patientNumber\\\":\\\"\\\",\\\"photo\\\":{\\\"filePath\\\":null,\\\"resourceId\\\":2131230828},\\\"previousVaccineId\\\":null,\\\"serviceType\\\":{\\\"dateEntity\\\":\\\"encounter\\\",\\\"dateEntityId\\\":\\\"encounter_date\\\",\\\"expiryOffset\\\":\\\"+5y\\\",\\\"id\\\":22,\\\"milestoneOffset\\\":\\\"[+1y]\\\",\\\"name\\\":\\\"Deworming 1\\\",\\\"preOffset\\\":\\\"+1y\\\",\\\"prerequisite\\\":\\\"dob\\\",\\\"serviceGroup\\\":\\\"child\\\",\\\"serviceLogic\\\":\\\"\\\",\\\"serviceNameEntity\\\":\\\"concept\\\",\\\"serviceNameEntityId\\\":\\\"159922AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\\\",\\\"type\\\":\\\"Deworming\\\",\\\"units\\\":null,\\\"updatedAt\\\":1566980540721},\\\"status\\\":\\\"due\\\",\\\"synced\\\":false,\\\"today\\\":false,\\\"updatedVaccineDate\\\":null,\\\"vaccineDate\\\":\\\"2015-09-23T00:00:00.000+08:00\\\",\\\"value\\\":null}}\"],\"set\":[],\"formSubmissionField\":\"serviceNotGiven\",\"humanReadableValues\":[]},{\"fieldType\":\"formsubmissionField\",\"fieldDataType\":\"text\",\"fieldCode\":\"birth_certificate\",\"parentCode\":\"\",\"values\":[\"{\\\"birtCert\\\":\\\"{\\\\\\\"count\\\\\\\":\\\\\\\"1\\\\\\\",\\\\\\\"encounter_type\\\\\\\":\\\\\\\"Birth Certification\\\\\\\",\\\\\\\"entity_id\\\\\\\":\\\\\\\"d0da64ab-ab8c-4cd8-ab18-e2661009e436\\\\\\\",\\\\\\\"metadata\\\\\\\":{\\\\\\\"start\\\\\\\":{\\\\\\\"openmrs_entity_parent\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"openmrs_entity\\\\\\\":\\\\\\\"concept\\\\\\\",\\\\\\\"openmrs_data_type\\\\\\\":\\\\\\\"start\\\\\\\",\\\\\\\"openmrs_entity_id\\\\\\\":\\\\\\\"163137AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\\\\\\\",\\\\\\\"value\\\\\\\":\\\\\\\"2019-08-30 22:20:17\\\\\\\"},\\\\\\\"end\\\\\\\":{\\\\\\\"openmrs_entity_parent\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"openmrs_entity\\\\\\\":\\\\\\\"concept\\\\\\\",\\\\\\\"openmrs_data_type\\\\\\\":\\\\\\\"end\\\\\\\",\\\\\\\"openmrs_entity_id\\\\\\\":\\\\\\\"163138AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\\\\\\\",\\\\\\\"value\\\\\\\":\\\\\\\"2019-08-30 22:20:38\\\\\\\"},\\\\\\\"today\\\\\\\":{\\\\\\\"openmrs_entity_parent\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"openmrs_entity\\\\\\\":\\\\\\\"encounter\\\\\\\",\\\\\\\"openmrs_entity_id\\\\\\\":\\\\\\\"encounter_date\\\\\\\",\\\\\\\"value\\\\\\\":\\\\\\\"30-08-2019\\\\\\\"},\\\\\\\"deviceid\\\\\\\":{\\\\\\\"openmrs_entity_parent\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"openmrs_entity\\\\\\\":\\\\\\\"concept\\\\\\\",\\\\\\\"openmrs_data_type\\\\\\\":\\\\\\\"deviceid\\\\\\\",\\\\\\\"openmrs_entity_id\\\\\\\":\\\\\\\"163149AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\\\\\\\",\\\\\\\"value\\\\\\\":\\\\\\\"865959046137007\\\\\\\"},\\\\\\\"subscriberid\\\\\\\":{\\\\\\\"openmrs_entity_parent\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"openmrs_entity\\\\\\\":\\\\\\\"concept\\\\\\\",\\\\\\\"openmrs_data_type\\\\\\\":\\\\\\\"subscriberid\\\\\\\",\\\\\\\"openmrs_entity_id\\\\\\\":\\\\\\\"163150AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\\\\\\\",\\\\\\\"value\\\\\\\":\\\\\\\"460031208673496\\\\\\\"},\\\\\\\"simserial\\\\\\\":{\\\\\\\"openmrs_entity_parent\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"openmrs_entity\\\\\\\":\\\\\\\"concept\\\\\\\",\\\\\\\"openmrs_data_type\\\\\\\":\\\\\\\"simserial\\\\\\\",\\\\\\\"openmrs_entity_id\\\\\\\":\\\\\\\"163151AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\\\\\\\",\\\\\\\"value\\\\\\\":\\\\\\\"89860314107971674978\\\\\\\"},\\\\\\\"phonenumber\\\\\\\":{\\\\\\\"openmrs_entity_parent\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"openmrs_entity\\\\\\\":\\\\\\\"concept\\\\\\\",\\\\\\\"openmrs_data_type\\\\\\\":\\\\\\\"phonenumber\\\\\\\",\\\\\\\"openmrs_entity_id\\\\\\\":\\\\\\\"163152AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\\\\\\\",\\\\\\\"value\\\\\\\":\\\\\\\"\\\\\\\"},\\\\\\\"encounter_location\\\\\\\":\\\\\\\"\\\\\\\"},\\\\\\\"step1\\\\\\\":{\\\\\\\"title\\\\\\\":\\\\\\\"Birth Certification\\\\\\\",\\\\\\\"fields\\\\\\\":[{\\\\\\\"key\\\\\\\":\\\\\\\"birth_cert\\\\\\\",\\\\\\\"openmrs_entity_parent\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"openmrs_entity\\\\\\\":\\\\\\\"concept\\\\\\\",\\\\\\\"openmrs_entity_id\\\\\\\":\\\\\\\"165406AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\\\\\\\",\\\\\\\"openmrs_data_type\\\\\\\":\\\\\\\"select one\\\\\\\",\\\\\\\"type\\\\\\\":\\\\\\\"spinner\\\\\\\",\\\\\\\"hint\\\\\\\":\\\\\\\"Does the child have a birth certificate?\\\\\\\",\\\\\\\"values\\\\\\\":[\\\\\\\"Yes\\\\\\\",\\\\\\\"No\\\\\\\"],\\\\\\\"openmrs_choice_ids\\\\\\\":{\\\\\\\"Yes\\\\\\\":\\\\\\\"1065AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\\\\\\\",\\\\\\\"No\\\\\\\":\\\\\\\"1066AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\\\\\\\"},\\\\\\\"v_required\\\\\\\":{\\\\\\\"value\\\\\\\":true,\\\\\\\"err\\\\\\\":\\\\\\\"Please select option\\\\\\\"},\\\\\\\"step\\\\\\\":\\\\\\\"step1\\\\\\\",\\\\\\\"is-rule-check\\\\\\\":true,\\\\\\\"value\\\\\\\":\\\\\\\"Yes\\\\\\\"},{\\\\\\\"key\\\\\\\":\\\\\\\"birth_cert_issue_date\\\\\\\",\\\\\\\"openmrs_entity_parent\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"openmrs_entity\\\\\\\":\\\\\\\"concept\\\\\\\",\\\\\\\"openmrs_entity_id\\\\\\\":\\\\\\\"164129AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\\\\\\\",\\\\\\\"type\\\\\\\":\\\\\\\"date_picker\\\\\\\",\\\\\\\"hint\\\\\\\":\\\\\\\"Birth certificate issuance date\\\\\\\",\\\\\\\"expanded\\\\\\\":false,\\\\\\\"max_date\\\\\\\":\\\\\\\"today\\\\\\\",\\\\\\\"min_date\\\\\\\":\\\\\\\"today-1802d\\\\\\\",\\\\\\\"v_required\\\\\\\":{\\\\\\\"value\\\\\\\":\\\\\\\"true\\\\\\\",\\\\\\\"err\\\\\\\":\\\\\\\"Please enter Birth certificate issuance date\\\\\\\"},\\\\\\\"relevance\\\\\\\":{\\\\\\\"rules-engine\\\\\\\":{\\\\\\\"ex-rules\\\\\\\":{\\\\\\\"rules-file\\\\\\\":\\\\\\\"birth_certification.yml\\\\\\\"}}},\\\\\\\"is_visible\\\\\\\":true,\\\\\\\"value\\\\\\\":\\\\\\\"30-08-2019\\\\\\\"},{\\\\\\\"key\\\\\\\":\\\\\\\"birth_cert_num\\\\\\\",\\\\\\\"openmrs_entity_parent\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"openmrs_entity\\\\\\\":\\\\\\\"concept\\\\\\\",\\\\\\\"openmrs_entity_id\\\\\\\":\\\\\\\"162052AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\\\\\\\",\\\\\\\"openmrs_data_type\\\\\\\":\\\\\\\"text\\\\\\\",\\\\\\\"type\\\\\\\":\\\\\\\"edit_text\\\\\\\",\\\\\\\"hint\\\\\\\":\\\\\\\"Birth certificate number\\\\\\\",\\\\\\\"v_required\\\\\\\":{\\\\\\\"value\\\\\\\":\\\\\\\"true\\\\\\\",\\\\\\\"err\\\\\\\":\\\\\\\"Please enter number\\\\\\\"},\\\\\\\"relevance\\\\\\\":{\\\\\\\"rules-engine\\\\\\\":{\\\\\\\"ex-rules\\\\\\\":{\\\\\\\"rules-file\\\\\\\":\\\\\\\"birth_certification.yml\\\\\\\"}}},\\\\\\\"is_visible\\\\\\\":true,\\\\\\\"value\\\\\\\":\\\\\\\"20150901\\\\\\\"},{\\\\\\\"key\\\\\\\":\\\\\\\"birth_notification\\\\\\\",\\\\\\\"openmrs_entity_parent\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"openmrs_entity\\\\\\\":\\\\\\\"concept\\\\\\\",\\\\\\\"openmrs_entity_id\\\\\\\":\\\\\\\"165405AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\\\\\\\",\\\\\\\"openmrs_data_type\\\\\\\":\\\\\\\"select one\\\\\\\",\\\\\\\"type\\\\\\\":\\\\\\\"spinner\\\\\\\",\\\\\\\"hint\\\\\\\":\\\\\\\"Was the birth notification done?\\\\\\\",\\\\\\\"values\\\\\\\":[\\\\\\\"Yes\\\\\\\",\\\\\\\"No\\\\\\\"],\\\\\\\"openmrs_choice_ids\\\\\\\":{\\\\\\\"Yes\\\\\\\":\\\\\\\"1065AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\\\\\\\",\\\\\\\"No\\\\\\\":\\\\\\\"1066AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\\\\\\\"},\\\\\\\"v_required\\\\\\\":{\\\\\\\"value\\\\\\\":false,\\\\\\\"err\\\\\\\":\\\\\\\"Please select option\\\\\\\"},\\\\\\\"relevance\\\\\\\":{\\\\\\\"rules-engine\\\\\\\":{\\\\\\\"ex-rules\\\\\\\":{\\\\\\\"rules-file\\\\\\\":\\\\\\\"birth_certification.yml\\\\\\\"}}},\\\\\\\"is_visible\\\\\\\":false,\\\\\\\"step\\\\\\\":\\\\\\\"step1\\\\\\\",\\\\\\\"is-rule-check\\\\\\\":true},{\\\\\\\"key\\\\\\\":\\\\\\\"birthinstroductions\\\\\\\",\\\\\\\"openmrs_entity_parent\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"openmrs_entity\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"openmrs_entity_id\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"type\\\\\\\":\\\\\\\"label\\\\\\\",\\\\\\\"text\\\\\\\":\\\\\\\"Ask to see the birth notification and instruct the caregiver to register the birth at County Health.\\\\\\\",\\\\\\\"relevance\\\\\\\":{\\\\\\\"rules-engine\\\\\\\":{\\\\\\\"ex-rules\\\\\\\":{\\\\\\\"rules-file\\\\\\\":\\\\\\\"birth_certification.yml\\\\\\\"}}},\\\\\\\"is_visible\\\\\\\":false},{\\\\\\\"key\\\\\\\":\\\\\\\"caregiverinstroductions\\\\\\\",\\\\\\\"openmrs_entity_parent\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"openmrs_entity\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"openmrs_entity_id\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"type\\\\\\\":\\\\\\\"label\\\\\\\",\\\\\\\"text\\\\\\\":\\\\\\\"Instruct the caregiver to have the birth registered at County Health.\\\\\\\",\\\\\\\"relevance\\\\\\\":{\\\\\\\"rules-engine\\\\\\\":{\\\\\\\"ex-rules\\\\\\\":{\\\\\\\"rules-file\\\\\\\":\\\\\\\"birth_certification.yml\\\\\\\"}}},\\\\\\\"is_visible\\\\\\\":false}]}}\\\"}\"],\"set\":[],\"formSubmissionField\":\"birth_certificate\",\"humanReadableValues\":[]},{\"fieldType\":\"formsubmissionField\",\"fieldDataType\":\"text\",\"fieldCode\":\"illness_information\",\"parentCode\":\"\",\"values\":[\"{}\"],\"set\":[],\"formSubmissionField\":\"illness_information\",\"humanReadableValues\":[]}],\"entityType\":\"ec_child\",\"version\":1567174886660,\"teamId\":\"d9eb010a-6d03-4bf8-b57a-b488dedd6f51\",\"team\":\"Clinic A Team\",\"dateCreated\":\"2019-08-30T14:21:50.258Z\",\"serverVersion\":1567174910258,\"clientApplicationVersion\":1,\"clientDatabaseVersion\":9,\"type\":\"Event\",\"id\":\"2e2601e9-e612-4eb5-9ca2-0ea19829fac2\",\"revision\":\"v1\"}"; + String oldBirthCertEvent = "{\"identifiers\":{},\"baseEntityId\":\"d0da64ab-ab8c-4cd8-ab18-e2661009e436\",\"locationId\":\"402ecf03-af72-4c93-b099-e1ce327d815b\",\"eventDate\":\"2019-08-30T22:21:26.660Z\",\"eventType\":\"Child Home Visit\",\"formSubmissionId\":\"2735394b-b799-4cd0-9d2b-6d84d34448d9\",\"providerId\":\"chaone\",\"duration\":0,\"obs\":[{\"fieldType\":\"formsubmissionField\",\"fieldDataType\":\"text\",\"fieldCode\":\"home_visit_id\",\"parentCode\":\"\",\"values\":[\"6f28e369-0db3-44a1-a61f-5b907a98f13e\"],\"set\":[],\"formSubmissionField\":\"home_visit_id\",\"humanReadableValues\":[]},{\"fieldType\":\"formsubmissionField\",\"fieldDataType\":\"text\",\"fieldCode\":\"last_home_visit\",\"parentCode\":\"\",\"values\":[\"1567174886622\"],\"set\":[],\"formSubmissionField\":\"last_home_visit\",\"humanReadableValues\":[]},{\"fieldType\":\"formsubmissionField\",\"fieldDataType\":\"text\",\"fieldCode\":\"singleVaccine\",\"parentCode\":\"\",\"values\":[\"{\\\"singleVaccinesGiven\\\":[]}\"],\"set\":[],\"formSubmissionField\":\"singleVaccine\",\"humanReadableValues\":[]},{\"fieldType\":\"formsubmissionField\",\"fieldDataType\":\"text\",\"fieldCode\":\"groupVaccine\",\"parentCode\":\"\",\"values\":[\"{\\\"groupVaccinesGiven\\\":[]}\"],\"set\":[],\"formSubmissionField\":\"groupVaccine\",\"humanReadableValues\":[]},{\"fieldType\":\"formsubmissionField\",\"fieldDataType\":\"text\",\"fieldCode\":\"vaccineNotGiven\",\"parentCode\":\"\",\"values\":[\"{\\\"vaccineNotGiven\\\":[]}\"],\"set\":[],\"formSubmissionField\":\"vaccineNotGiven\",\"humanReadableValues\":[]},{\"fieldType\":\"formsubmissionField\",\"fieldDataType\":\"text\",\"fieldCode\":\"service\",\"parentCode\":\"\",\"values\":[\"{\\\"Vitamin A\\\":{\\\"alert\\\":{\\\"caseID\\\":\\\"d0da64ab-ab8c-4cd8-ab18-e2661009e436\\\",\\\"completionDate\\\":null,\\\"expiryDate\\\":\\\"2019-09-23\\\",\\\"offline\\\":true,\\\"scheduleName\\\":\\\"Vitamin A1\\\",\\\"startDate\\\":\\\"2015-03-23\\\",\\\"status\\\":\\\"normal\\\",\\\"visitCode\\\":\\\"vitamina1\\\"},\\\"color\\\":null,\\\"createdAt\\\":null,\\\"dbKey\\\":1,\\\"defaultName\\\":\\\"Vitamin A\\\",\\\"dob\\\":\\\"2014-09-23T08:00:00.000+08:00\\\",\\\"gender\\\":\\\"Male\\\",\\\"id\\\":\\\"d0da64ab-ab8c-4cd8-ab18-e2661009e436\\\",\\\"patientName\\\":\\\"Doudou Balde\\\",\\\"patientNumber\\\":\\\"\\\",\\\"photo\\\":{\\\"filePath\\\":null,\\\"resourceId\\\":2131230828},\\\"previousVaccineId\\\":null,\\\"serviceType\\\":{\\\"dateEntity\\\":\\\"encounter\\\",\\\"dateEntityId\\\":\\\"encounter_date\\\",\\\"expiryOffset\\\":\\\"+5y\\\",\\\"id\\\":13,\\\"milestoneOffset\\\":\\\"[+6m]\\\",\\\"name\\\":\\\"Vitamin A1\\\",\\\"preOffset\\\":\\\"+6m\\\",\\\"prerequisite\\\":\\\"dob\\\",\\\"serviceGroup\\\":\\\"child\\\",\\\"serviceLogic\\\":\\\"\\\",\\\"serviceNameEntity\\\":\\\"concept\\\",\\\"serviceNameEntityId\\\":\\\"86339AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\\\",\\\"type\\\":\\\"Vitamin A\\\",\\\"units\\\":null,\\\"updatedAt\\\":1566980540710},\\\"status\\\":\\\"due\\\",\\\"synced\\\":false,\\\"today\\\":false,\\\"updatedVaccineDate\\\":\\\"2019-08-30T22:20:42.718+08:00\\\",\\\"vaccineDate\\\":\\\"2015-03-23T00:00:00.000+08:00\\\",\\\"value\\\":null}}\"],\"set\":[],\"formSubmissionField\":\"service\",\"humanReadableValues\":[]},{\"fieldType\":\"formsubmissionField\",\"fieldDataType\":\"text\",\"fieldCode\":\"serviceNotGiven\",\"parentCode\":\"\",\"values\":[\"{\\\"Deworming\\\":{\\\"alert\\\":{\\\"caseID\\\":\\\"d0da64ab-ab8c-4cd8-ab18-e2661009e436\\\",\\\"completionDate\\\":null,\\\"expiryDate\\\":\\\"2019-09-23\\\",\\\"offline\\\":true,\\\"scheduleName\\\":\\\"Deworming 1\\\",\\\"startDate\\\":\\\"2015-09-23\\\",\\\"status\\\":\\\"normal\\\",\\\"visitCode\\\":\\\"deworming1\\\"},\\\"color\\\":null,\\\"createdAt\\\":null,\\\"dbKey\\\":null,\\\"defaultName\\\":\\\"Deworming\\\",\\\"dob\\\":\\\"2014-09-23T08:00:00.000+08:00\\\",\\\"gender\\\":\\\"Male\\\",\\\"id\\\":\\\"d0da64ab-ab8c-4cd8-ab18-e2661009e436\\\",\\\"patientName\\\":\\\"Doudou Balde\\\",\\\"patientNumber\\\":\\\"\\\",\\\"photo\\\":{\\\"filePath\\\":null,\\\"resourceId\\\":2131230828},\\\"previousVaccineId\\\":null,\\\"serviceType\\\":{\\\"dateEntity\\\":\\\"encounter\\\",\\\"dateEntityId\\\":\\\"encounter_date\\\",\\\"expiryOffset\\\":\\\"+5y\\\",\\\"id\\\":22,\\\"milestoneOffset\\\":\\\"[+1y]\\\",\\\"name\\\":\\\"Deworming 1\\\",\\\"preOffset\\\":\\\"+1y\\\",\\\"prerequisite\\\":\\\"dob\\\",\\\"serviceGroup\\\":\\\"child\\\",\\\"serviceLogic\\\":\\\"\\\",\\\"serviceNameEntity\\\":\\\"concept\\\",\\\"serviceNameEntityId\\\":\\\"159922AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\\\",\\\"type\\\":\\\"Deworming\\\",\\\"units\\\":null,\\\"updatedAt\\\":1566980540721},\\\"status\\\":\\\"due\\\",\\\"synced\\\":false,\\\"today\\\":false,\\\"updatedVaccineDate\\\":null,\\\"vaccineDate\\\":\\\"2015-09-23T00:00:00.000+08:00\\\",\\\"value\\\":null}}\"],\"set\":[],\"formSubmissionField\":\"serviceNotGiven\",\"humanReadableValues\":[]},{\"fieldType\":\"formsubmissionField\",\"fieldDataType\":\"text\",\"fieldCode\":\"birth_certificate\",\"parentCode\":\"\",\"values\":[\"{\\\"birtCert\\\":\\\"{\\\\\\\"count\\\\\\\":\\\\\\\"1\\\\\\\",\\\\\\\"encounter_type\\\\\\\":\\\\\\\"Birth Certification\\\\\\\",\\\\\\\"entity_id\\\\\\\":\\\\\\\"d0da64ab-ab8c-4cd8-ab18-e2661009e436\\\\\\\",\\\\\\\"metadata\\\\\\\":{\\\\\\\"start\\\\\\\":{\\\\\\\"openmrs_entity_parent\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"openmrs_entity\\\\\\\":\\\\\\\"concept\\\\\\\",\\\\\\\"openmrs_data_type\\\\\\\":\\\\\\\"start\\\\\\\",\\\\\\\"openmrs_entity_id\\\\\\\":\\\\\\\"163137AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\\\\\\\",\\\\\\\"value\\\\\\\":\\\\\\\"2019-08-30 22:20:17\\\\\\\"},\\\\\\\"end\\\\\\\":{\\\\\\\"openmrs_entity_parent\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"openmrs_entity\\\\\\\":\\\\\\\"concept\\\\\\\",\\\\\\\"openmrs_data_type\\\\\\\":\\\\\\\"end\\\\\\\",\\\\\\\"openmrs_entity_id\\\\\\\":\\\\\\\"163138AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\\\\\\\",\\\\\\\"value\\\\\\\":\\\\\\\"2019-08-30 22:20:38\\\\\\\"},\\\\\\\"today\\\\\\\":{\\\\\\\"openmrs_entity_parent\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"openmrs_entity\\\\\\\":\\\\\\\"encounter\\\\\\\",\\\\\\\"openmrs_entity_id\\\\\\\":\\\\\\\"encounter_date\\\\\\\",\\\\\\\"value\\\\\\\":\\\\\\\"30-08-2019\\\\\\\"},\\\\\\\"deviceid\\\\\\\":{\\\\\\\"openmrs_entity_parent\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"openmrs_entity\\\\\\\":\\\\\\\"concept\\\\\\\",\\\\\\\"openmrs_data_type\\\\\\\":\\\\\\\"deviceid\\\\\\\",\\\\\\\"openmrs_entity_id\\\\\\\":\\\\\\\"163149AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\\\\\\\",\\\\\\\"value\\\\\\\":\\\\\\\"865959046137007\\\\\\\"},\\\\\\\"subscriberid\\\\\\\":{\\\\\\\"openmrs_entity_parent\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"openmrs_entity\\\\\\\":\\\\\\\"concept\\\\\\\",\\\\\\\"openmrs_data_type\\\\\\\":\\\\\\\"subscriberid\\\\\\\",\\\\\\\"openmrs_entity_id\\\\\\\":\\\\\\\"163150AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\\\\\\\",\\\\\\\"value\\\\\\\":\\\\\\\"460031208673496\\\\\\\"},\\\\\\\"simserial\\\\\\\":{\\\\\\\"openmrs_entity_parent\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"openmrs_entity\\\\\\\":\\\\\\\"concept\\\\\\\",\\\\\\\"openmrs_data_type\\\\\\\":\\\\\\\"simserial\\\\\\\",\\\\\\\"openmrs_entity_id\\\\\\\":\\\\\\\"163151AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\\\\\\\",\\\\\\\"value\\\\\\\":\\\\\\\"89860314107971674978\\\\\\\"},\\\\\\\"phonenumber\\\\\\\":{\\\\\\\"openmrs_entity_parent\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"openmrs_entity\\\\\\\":\\\\\\\"concept\\\\\\\",\\\\\\\"openmrs_data_type\\\\\\\":\\\\\\\"phonenumber\\\\\\\",\\\\\\\"openmrs_entity_id\\\\\\\":\\\\\\\"163152AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\\\\\\\",\\\\\\\"value\\\\\\\":\\\\\\\"\\\\\\\"},\\\\\\\"encounter_location\\\\\\\":\\\\\\\"\\\\\\\"},\\\\\\\"step1\\\\\\\":{\\\\\\\"title\\\\\\\":\\\\\\\"Birth Certification\\\\\\\",\\\\\\\"fields\\\\\\\":[{\\\\\\\"key\\\\\\\":\\\\\\\"birth_cert\\\\\\\",\\\\\\\"openmrs_entity_parent\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"openmrs_entity\\\\\\\":\\\\\\\"concept\\\\\\\",\\\\\\\"openmrs_entity_id\\\\\\\":\\\\\\\"165406AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\\\\\\\",\\\\\\\"openmrs_data_type\\\\\\\":\\\\\\\"select one\\\\\\\",\\\\\\\"type\\\\\\\":\\\\\\\"spinner\\\\\\\",\\\\\\\"hint\\\\\\\":\\\\\\\"Does the child have a birth certificate?\\\\\\\",\\\\\\\"values\\\\\\\":[\\\\\\\"Yes\\\\\\\",\\\\\\\"No\\\\\\\"],\\\\\\\"openmrs_choice_ids\\\\\\\":{\\\\\\\"Yes\\\\\\\":\\\\\\\"1065AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\\\\\\\",\\\\\\\"No\\\\\\\":\\\\\\\"1066AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\\\\\\\"},\\\\\\\"v_required\\\\\\\":{\\\\\\\"value\\\\\\\":true,\\\\\\\"err\\\\\\\":\\\\\\\"Please select option\\\\\\\"},\\\\\\\"step\\\\\\\":\\\\\\\"step1\\\\\\\",\\\\\\\"is-rule-check\\\\\\\":true,\\\\\\\"value\\\\\\\":\\\\\\\"Yes\\\\\\\"},{\\\\\\\"key\\\\\\\":\\\\\\\"birth_cert_issue_date\\\\\\\",\\\\\\\"openmrs_entity_parent\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"openmrs_entity\\\\\\\":\\\\\\\"concept\\\\\\\",\\\\\\\"openmrs_entity_id\\\\\\\":\\\\\\\"164129AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\\\\\\\",\\\\\\\"type\\\\\\\":\\\\\\\"date_picker\\\\\\\",\\\\\\\"hint\\\\\\\":\\\\\\\"Birth certificate issuance date\\\\\\\",\\\\\\\"expanded\\\\\\\":false,\\\\\\\"max_date\\\\\\\":\\\\\\\"today\\\\\\\",\\\\\\\"min_date\\\\\\\":\\\\\\\"today-1802d\\\\\\\",\\\\\\\"v_required\\\\\\\":{\\\\\\\"value\\\\\\\":\\\\\\\"true\\\\\\\",\\\\\\\"err\\\\\\\":\\\\\\\"Please enter Birth certificate issuance date\\\\\\\"},\\\\\\\"relevance\\\\\\\":{\\\\\\\"rules-engine\\\\\\\":{\\\\\\\"ex-rules\\\\\\\":{\\\\\\\"rules-file\\\\\\\":\\\\\\\"birth_certification.yml\\\\\\\"}}},\\\\\\\"is_visible\\\\\\\":true,\\\\\\\"value\\\\\\\":\\\\\\\"30-08-2019\\\\\\\"},{\\\\\\\"key\\\\\\\":\\\\\\\"birth_cert_num\\\\\\\",\\\\\\\"openmrs_entity_parent\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"openmrs_entity\\\\\\\":\\\\\\\"concept\\\\\\\",\\\\\\\"openmrs_entity_id\\\\\\\":\\\\\\\"162052AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\\\\\\\",\\\\\\\"openmrs_data_type\\\\\\\":\\\\\\\"text\\\\\\\",\\\\\\\"type\\\\\\\":\\\\\\\"edit_text\\\\\\\",\\\\\\\"hint\\\\\\\":\\\\\\\"Birth certificate number\\\\\\\",\\\\\\\"v_required\\\\\\\":{\\\\\\\"value\\\\\\\":\\\\\\\"true\\\\\\\",\\\\\\\"err\\\\\\\":\\\\\\\"Please enter number\\\\\\\"},\\\\\\\"relevance\\\\\\\":{\\\\\\\"rules-engine\\\\\\\":{\\\\\\\"ex-rules\\\\\\\":{\\\\\\\"rules-file\\\\\\\":\\\\\\\"birth_certification.yml\\\\\\\"}}},\\\\\\\"is_visible\\\\\\\":true,\\\\\\\"value\\\\\\\":\\\\\\\"20150901\\\\\\\"},{\\\\\\\"key\\\\\\\":\\\\\\\"birth_notification\\\\\\\",\\\\\\\"openmrs_entity_parent\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"openmrs_entity\\\\\\\":\\\\\\\"concept\\\\\\\",\\\\\\\"openmrs_entity_id\\\\\\\":\\\\\\\"165405AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\\\\\\\",\\\\\\\"openmrs_data_type\\\\\\\":\\\\\\\"select one\\\\\\\",\\\\\\\"type\\\\\\\":\\\\\\\"spinner\\\\\\\",\\\\\\\"hint\\\\\\\":\\\\\\\"Was the birth notification done?\\\\\\\",\\\\\\\"values\\\\\\\":[\\\\\\\"Yes\\\\\\\",\\\\\\\"No\\\\\\\"],\\\\\\\"openmrs_choice_ids\\\\\\\":{\\\\\\\"Yes\\\\\\\":\\\\\\\"1065AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\\\\\\\",\\\\\\\"No\\\\\\\":\\\\\\\"1066AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\\\\\\\"},\\\\\\\"v_required\\\\\\\":{\\\\\\\"value\\\\\\\":false,\\\\\\\"err\\\\\\\":\\\\\\\"Please select option\\\\\\\"},\\\\\\\"relevance\\\\\\\":{\\\\\\\"rules-engine\\\\\\\":{\\\\\\\"ex-rules\\\\\\\":{\\\\\\\"rules-file\\\\\\\":\\\\\\\"birth_certification.yml\\\\\\\"}}},\\\\\\\"is_visible\\\\\\\":false,\\\\\\\"step\\\\\\\":\\\\\\\"step1\\\\\\\",\\\\\\\"is-rule-check\\\\\\\":true},{\\\\\\\"key\\\\\\\":\\\\\\\"birthinstroductions\\\\\\\",\\\\\\\"openmrs_entity_parent\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"openmrs_entity\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"openmrs_entity_id\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"type\\\\\\\":\\\\\\\"label\\\\\\\",\\\\\\\"text\\\\\\\":\\\\\\\"Ask to see the birth notification and instruct the caregiver to register the birth at County Health.\\\\\\\",\\\\\\\"relevance\\\\\\\":{\\\\\\\"rules-engine\\\\\\\":{\\\\\\\"ex-rules\\\\\\\":{\\\\\\\"rules-file\\\\\\\":\\\\\\\"birth_certification.yml\\\\\\\"}}},\\\\\\\"is_visible\\\\\\\":false},{\\\\\\\"key\\\\\\\":\\\\\\\"caregiverinstroductions\\\\\\\",\\\\\\\"openmrs_entity_parent\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"openmrs_entity\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"openmrs_entity_id\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"type\\\\\\\":\\\\\\\"label\\\\\\\",\\\\\\\"text\\\\\\\":\\\\\\\"Instruct the caregiver to have the birth registered at County Health.\\\\\\\",\\\\\\\"relevance\\\\\\\":{\\\\\\\"rules-engine\\\\\\\":{\\\\\\\"ex-rules\\\\\\\":{\\\\\\\"rules-file\\\\\\\":\\\\\\\"birth_certification.yml\\\\\\\"}}},\\\\\\\"is_visible\\\\\\\":false}]}}\\\"}\"],\"set\":[],\"formSubmissionField\":\"birth_certificate\",\"humanReadableValues\":[]},{\"fieldType\":\"formsubmissionField\",\"fieldDataType\":\"text\",\"fieldCode\":\"illness_information\",\"parentCode\":\"\",\"values\":[\"{}\"],\"set\":[],\"formSubmissionField\":\"illness_information\",\"humanReadableValues\":[]}],\"entityType\":\"ec_child\",\"version\":1567174886660,\"teamId\":\"d9eb010a-6d03-4bf8-b57a-b488dedd6f51\",\"team\":\"Clinic A Team\",\"dateCreated\":\"2019-08-30T14:21:50.258Z\",\"serverVersion\":1567174910258,\"clientApplicationVersion\":1,\"clientDatabaseVersion\":9,\"type\":\"Event\",\"id\":\"2e2601e9-e612-4eb5-9ca2-0ea19829fac2\",\"revision\":\"v1\"}"; + + Event event = gson.fromJson(oldIllnessInfo, Event.class); + EventClient eventClient = new EventClient(event,new Client("12345")); + List result = Utils.processOldEvents(eventClient); + Assert.assertEquals(result.size(),1); + } + */ + @Test public void canConvertReferralToANCMemberObject() { client = new CommonPersonObjectClient("case1", details, "test user"); From e64d7c60ba07344b8f20315477fc8c0b13f9e98d Mon Sep 17 00:00:00 2001 From: Allan O Date: Tue, 1 Dec 2020 13:21:48 +0300 Subject: [PATCH 68/78] :white_check_mark: Add FpAlertRuleTest methods --- .../chw/core/rule/FpAlertRuleTest.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/rule/FpAlertRuleTest.java b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/rule/FpAlertRuleTest.java index 1f3360005f..7db64cce5d 100644 --- a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/rule/FpAlertRuleTest.java +++ b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/rule/FpAlertRuleTest.java @@ -98,4 +98,26 @@ public void buttonStatusNotDueIfDateBeforeDueAndExpiry() { } + @Test + public void canGetDueDate() { + dueDate = LocalDate.now().plusDays(10).toDateTime(LocalTime.MIDNIGHT); + ReflectionHelpers.setField(fpAlertRule, "dueDate", dueDate); + Assert.assertEquals(dueDate.toDate(), fpAlertRule.getDueDate()); + } + + @Test + public void canGetOverdueDate() { + overDueDate = LocalDate.now().minusDays(1).toDateTime(LocalTime.MIDNIGHT); + ReflectionHelpers.setField(fpAlertRule, "overDueDate", overDueDate); + Assert.assertEquals(overDueDate.toDate(), fpAlertRule.getOverDueDate()); + } + + @Test + public void canGetExpiryDate() { + expiryDate = LocalDate.now().plusDays(10).toDateTime(LocalTime.MIDNIGHT); + ReflectionHelpers.setField(fpAlertRule, "expiryDate", expiryDate); + Assert.assertEquals(expiryDate.toDate(), fpAlertRule.getExpiryDate()); + } + + } \ No newline at end of file From 147f1710b50c7c576a159b8202e292243c100b97 Mon Sep 17 00:00:00 2001 From: Allan O Date: Tue, 1 Dec 2020 13:22:14 +0300 Subject: [PATCH 69/78] :white_check_mark: Add MonthlyAlertRuleTest class, methods --- .../implementation/MonthlyAlertRuleImpl.java | 17 +++++++ .../chw/core/rule/MonthlyAlertRuleTest.java | 44 +++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 opensrp-chw-core/src/test/java/org/smartregister/chw/core/implementation/MonthlyAlertRuleImpl.java create mode 100644 opensrp-chw-core/src/test/java/org/smartregister/chw/core/rule/MonthlyAlertRuleTest.java diff --git a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/implementation/MonthlyAlertRuleImpl.java b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/implementation/MonthlyAlertRuleImpl.java new file mode 100644 index 0000000000..d1f28454f3 --- /dev/null +++ b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/implementation/MonthlyAlertRuleImpl.java @@ -0,0 +1,17 @@ +package org.smartregister.chw.core.implementation; + +import android.content.Context; + +import org.smartregister.chw.core.rule.MonthlyAlertRule; + +public class MonthlyAlertRuleImpl extends MonthlyAlertRule { + + public MonthlyAlertRuleImpl(Context context, long lastVisitDateLong, long dateCreatedLong) { + super(context, lastVisitDateLong, dateCreatedLong); + } + + @Override + public String getRuleKey() { + return null; + } +} diff --git a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/rule/MonthlyAlertRuleTest.java b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/rule/MonthlyAlertRuleTest.java new file mode 100644 index 0000000000..926fd3c426 --- /dev/null +++ b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/rule/MonthlyAlertRuleTest.java @@ -0,0 +1,44 @@ +package org.smartregister.chw.core.rule; + +import android.content.Context; + +import org.joda.time.DateTime; +import org.joda.time.LocalDate; +import org.joda.time.LocalTime; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.powermock.reflect.Whitebox; +import org.robolectric.RuntimeEnvironment; +import org.robolectric.util.ReflectionHelpers; +import org.smartregister.chw.core.BaseRobolectricTest; +import org.smartregister.chw.core.implementation.MonthlyAlertRuleImpl; + +import java.util.Date; + +public class MonthlyAlertRuleTest extends BaseRobolectricTest { + + private LocalDate dateCreated; + private LocalDate todayDate; + private LocalDate lastVisitDate; + private Context context; + private MonthlyAlertRule monthlyAlertRule; + + @Before + public void setUp() { + context = RuntimeEnvironment.application; + monthlyAlertRule = new MonthlyAlertRuleImpl(context, new Date().getTime(), new Date().getTime()); + } + + @Test + public void lastDueDateIs1stIfLastVisitEarlierThanCreated() throws Exception { + Date firstDayOfThisMonth = LocalDate.now().withDayOfMonth(1).toDate(); + dateCreated = LocalDate.fromDateFields(firstDayOfThisMonth).plusWeeks(2); + lastVisitDate = LocalDate.fromDateFields(firstDayOfThisMonth).plusWeeks(1); + + ReflectionHelpers.setField(monthlyAlertRule, "dateCreated", dateCreated); + ReflectionHelpers.setField(monthlyAlertRule, "lastVisitDate", lastVisitDate); + + Assert.assertEquals(firstDayOfThisMonth, Whitebox.invokeMethod(monthlyAlertRule, "getLastDueDate")); + } +} From 62cf225938523ae3c1db28dee037ca583fdf7679 Mon Sep 17 00:00:00 2001 From: Allan O Date: Tue, 1 Dec 2020 13:25:53 +0300 Subject: [PATCH 70/78] :white_check_mark: Remove unused dependencies --- .../org/smartregister/chw/core/rule/MonthlyAlertRuleTest.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/rule/MonthlyAlertRuleTest.java b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/rule/MonthlyAlertRuleTest.java index 926fd3c426..d1e44b45e9 100644 --- a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/rule/MonthlyAlertRuleTest.java +++ b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/rule/MonthlyAlertRuleTest.java @@ -2,9 +2,7 @@ import android.content.Context; -import org.joda.time.DateTime; import org.joda.time.LocalDate; -import org.joda.time.LocalTime; import org.junit.Assert; import org.junit.Before; import org.junit.Test; From c4815c7c09e7db38327d244b545957cbd2dc9ea3 Mon Sep 17 00:00:00 2001 From: Allan O Date: Tue, 1 Dec 2020 13:29:26 +0300 Subject: [PATCH 71/78] :white_check_mark: Fix Codacy reported issues --- .../chw/core/rule/MonthlyAlertRuleTest.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/rule/MonthlyAlertRuleTest.java b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/rule/MonthlyAlertRuleTest.java index d1e44b45e9..09e4d845dc 100644 --- a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/rule/MonthlyAlertRuleTest.java +++ b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/rule/MonthlyAlertRuleTest.java @@ -16,23 +16,19 @@ public class MonthlyAlertRuleTest extends BaseRobolectricTest { - private LocalDate dateCreated; - private LocalDate todayDate; - private LocalDate lastVisitDate; - private Context context; private MonthlyAlertRule monthlyAlertRule; @Before public void setUp() { - context = RuntimeEnvironment.application; + Context context = RuntimeEnvironment.application; monthlyAlertRule = new MonthlyAlertRuleImpl(context, new Date().getTime(), new Date().getTime()); } @Test public void lastDueDateIs1stIfLastVisitEarlierThanCreated() throws Exception { Date firstDayOfThisMonth = LocalDate.now().withDayOfMonth(1).toDate(); - dateCreated = LocalDate.fromDateFields(firstDayOfThisMonth).plusWeeks(2); - lastVisitDate = LocalDate.fromDateFields(firstDayOfThisMonth).plusWeeks(1); + LocalDate dateCreated = LocalDate.fromDateFields(firstDayOfThisMonth).plusWeeks(2); + LocalDate lastVisitDate = LocalDate.fromDateFields(firstDayOfThisMonth).plusWeeks(1); ReflectionHelpers.setField(monthlyAlertRule, "dateCreated", dateCreated); ReflectionHelpers.setField(monthlyAlertRule, "lastVisitDate", lastVisitDate); From d5489794e54e05143e41e2a047162de516215f4f Mon Sep 17 00:00:00 2001 From: rkodev <43806892+rkodev@users.noreply.github.com> Date: Tue, 1 Dec 2020 15:57:51 +0300 Subject: [PATCH 72/78] Upgrade to firebasE --- gradle.properties | 2 +- opensrp-chw-core/build.gradle | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/gradle.properties b/gradle.properties index 9d173a07f1..248f3ad7e5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -VERSION_NAME=2.0.3-SNAPSHOT +VERSION_NAME=2.0.4-SNAPSHOT VERSION_CODE=1 GROUP=org.smartregister POM_SETTING_DESCRIPTION=OpenSRP Client Chw Core Library diff --git a/opensrp-chw-core/build.gradle b/opensrp-chw-core/build.gradle index f578e2b0f7..03fdcac62f 100644 --- a/opensrp-chw-core/build.gradle +++ b/opensrp-chw-core/build.gradle @@ -260,9 +260,7 @@ dependencies { exclude group: 'com.rengwuxian.materialedittext', module: 'library' } - api('com.crashlytics.sdk.android:crashlytics:2.10.1@aar') { - transitive = true - } + api 'com.google.firebase:firebase-crashlytics:17.3.0' androidTestImplementation 'org.mockito:mockito-android:3.0.0' androidTestImplementation 'androidx.test.ext:junit:1.1.2' From 5f2acee2c79055a56306315287000e40f46e1a5b Mon Sep 17 00:00:00 2001 From: Qazi Abubakar Date: Wed, 2 Dec 2020 16:33:45 +0500 Subject: [PATCH 73/78] changed access modifier from public to protected --- .../activity/DefaultChildMedicalHistoryActivityFlv.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/DefaultChildMedicalHistoryActivityFlv.java b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/DefaultChildMedicalHistoryActivityFlv.java index c43852f48e..5fe0323c5f 100644 --- a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/DefaultChildMedicalHistoryActivityFlv.java +++ b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/DefaultChildMedicalHistoryActivityFlv.java @@ -42,9 +42,9 @@ public abstract class DefaultChildMedicalHistoryActivityFlv implements CoreChild protected List visits; protected Map> visitMap = new LinkedHashMap<>(); protected Map> vaccineMap = new LinkedHashMap<>(); - public Context context; + protected Context context; private LinearLayout parentView; - public SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy", Locale.getDefault()); + protected SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy", Locale.getDefault()); @Override public View bindViews(Activity activity) { @@ -271,7 +271,7 @@ private VisitDetailsFormatter getDewormingFormatter() { }; } - public VisitDetailsFormatter getDieataryFormatter() { + protected VisitDetailsFormatter getDieataryFormatter() { return (title, details, visitDate) -> { String diet_diversity = NCUtils.getText(details); String value = ""; @@ -423,7 +423,7 @@ private void medicalHistory(List medicalHistories, String type, } } - public interface VisitDetailsFormatter { + protected interface VisitDetailsFormatter { String format(String title, List details, Date visitDate); } } From c29200fe56bb3d28c6d514fdec84bd988b6408b2 Mon Sep 17 00:00:00 2001 From: Qazi Abubakar Date: Wed, 2 Dec 2020 16:36:11 +0500 Subject: [PATCH 74/78] upgraded library version to 2.0.5-SNAPSHOT --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 248f3ad7e5..ebbcf9cd6e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -VERSION_NAME=2.0.4-SNAPSHOT +VERSION_NAME=2.0.5-SNAPSHOT VERSION_CODE=1 GROUP=org.smartregister POM_SETTING_DESCRIPTION=OpenSRP Client Chw Core Library From 4661d9cae5894418483f4c3022e344f29a9f8ca8 Mon Sep 17 00:00:00 2001 From: rkodev <43806892+rkodev@users.noreply.github.com> Date: Wed, 2 Dec 2020 16:16:40 +0300 Subject: [PATCH 75/78] Upgrade core to v4.0 --- opensrp-chw-core/build.gradle | 12 ++++++------ .../activity/BaseReferralTaskViewActivity.java | 2 +- .../activity/ChwP2pModeSelectActivity.java | 11 ++++++++--- .../activity/CoreChildHomeVisitActivity.java | 2 ++ .../chw/core/dao/ReferralTaskDao.java | 18 ++++++++++++------ .../CloseExpiredReferralsIntentService.java | 5 ++++- .../chw/core/utils/CoreReferralUtils.java | 9 +++++++-- 7 files changed, 40 insertions(+), 19 deletions(-) diff --git a/opensrp-chw-core/build.gradle b/opensrp-chw-core/build.gradle index 03fdcac62f..0959215821 100644 --- a/opensrp-chw-core/build.gradle +++ b/opensrp-chw-core/build.gradle @@ -138,7 +138,7 @@ dependencies { compileOnly 'com.ibm.fhir:fhir-model:4.2.3' - api('org.smartregister:opensrp-client-core:2.1.4-SNAPSHOT@aar') { + api('org.smartregister:opensrp-client-core:4.0.4-SNAPSHOT@aar') { transitive = true exclude group: 'com.github.bmelnychuk', module: 'atv' exclude group: 'com.google.guava', module: 'guava' @@ -149,7 +149,7 @@ dependencies { exclude group: 'com.ibm.fhir', module: 'fhir-model' } implementation 'androidx.appcompat:appcompat:1.2.0' - implementation 'androidx.constraintlayout:constraintlayout:2.0.0' + implementation 'androidx.constraintlayout:constraintlayout:2.0.4' api('org.smartregister:opensrp-client-configurable-views:1.1.5-SNAPSHOT@aar') { transitive = true @@ -157,7 +157,7 @@ dependencies { exclude group: 'com.android.support', module: 'appcompat-v7' } - api('org.smartregister:opensrp-client-family:1.3.1-alpha1-SNAPSHOT@aar') { + api('org.smartregister:opensrp-client-family:2.0.0-SNAPSHOT@aar') { transitive = true exclude group: 'org.smartregister', module: 'opensrp-client-core' exclude group: 'org.smartregister', module: 'opensrp-client-native-form' @@ -190,7 +190,7 @@ dependencies { exclude group: 'com.github.lecho', module: 'hellocharts-android' } - api('org.smartregister:opensrp-client-chw-anc:1.1.2-SNAPSHOT@aar') { + api('org.smartregister:opensrp-client-chw-anc:2.0.0-SNAPSHOT@aar') { transitive = true exclude group: 'org.smartregister', module: 'opensrp-client-core' exclude group: 'com.android.support', module: 'appcompat-v7' @@ -199,7 +199,7 @@ dependencies { exclude group: 'org.smartregister', module: 'opensrp-client-immunization' } - api('org.smartregister:opensrp-client-chw-pnc:1.0.3-SNAPSHOT@aar') { + api('org.smartregister:opensrp-client-chw-pnc:2.0.0-SNAPSHOT@aar') { transitive = true exclude group: 'org.smartregister', module: 'opensrp-client-chw-anc' exclude group: 'org.smartregister', module: 'opensrp-client-core' @@ -251,7 +251,7 @@ dependencies { api 'com.evernote:android-job:1.2.6' api 'org.greenrobot:eventbus:3.1.1' - api("org.smartregister:android-p2p-sync:0.3.8-apha1-SNAPSHOT") { + api("org.smartregister:android-p2p-sync:0.3.8-aplha3-SNAPSHOT") { transitive = true exclude group: 'org.smartregister', module: 'opensrp-client-core' exclude group: 'com.android.support', module: 'appcompat-v7' diff --git a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/BaseReferralTaskViewActivity.java b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/BaseReferralTaskViewActivity.java index 8361a992b8..2535a1f668 100644 --- a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/BaseReferralTaskViewActivity.java +++ b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/BaseReferralTaskViewActivity.java @@ -136,7 +136,7 @@ protected void getReferralDetails() { updateProblemDisplay(); String clientAge = (Utils.getTranslatedDate(Utils.getDuration(Utils.getValue(getPersonObjectClient().getColumnmaps(), DBConstants.KEY.DOB, false)), getBaseContext())); clientName.setText(getString(R.string.client_name_age_suffix, name, clientAge)); - referralDate.setText(org.smartregister.chw.core.utils.Utils.dd_MMM_yyyy.format(getTask().getExecutionStartDate().toDate())); + referralDate.setText(org.smartregister.chw.core.utils.Utils.dd_MMM_yyyy.format(getTask().getExecutionPeriod().getStart().toDate())); //For PNC get children belonging to the woman String childrenForPncWoman = getChildrenForPncWoman(getPersonObjectClient().entityId()); diff --git a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/ChwP2pModeSelectActivity.java b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/ChwP2pModeSelectActivity.java index babc1be213..db97375a18 100644 --- a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/ChwP2pModeSelectActivity.java +++ b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/ChwP2pModeSelectActivity.java @@ -1,6 +1,6 @@ package org.smartregister.chw.core.activity; -import android.content.Context; +import android.content.res.Configuration; import android.os.Bundle; import androidx.annotation.Nullable; @@ -17,9 +17,14 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { } @Override - protected void attachBaseContext(Context base) { + protected void attachBaseContext(android.content.Context base) { // get language from prefs String lang = LangUtils.getLanguage(base.getApplicationContext()); - super.attachBaseContext(LangUtils.setAppLocale(base, lang)); + Configuration newConfiguration = LangUtils.setAppLocale(base, lang); + + super.attachBaseContext(base); + + applyOverrideConfiguration(newConfiguration); } + } diff --git a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/CoreChildHomeVisitActivity.java b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/CoreChildHomeVisitActivity.java index 26827d4328..ebcfefde87 100644 --- a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/CoreChildHomeVisitActivity.java +++ b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/CoreChildHomeVisitActivity.java @@ -73,10 +73,12 @@ public void redrawHeader(MemberObject memberObject) { tvTitle.setText(MessageFormat.format("{0}, {1} {2}", memberObject.getFullName(), getDuration(memberObject.getDob()), getString(R.string.home_visit_suffix))); } + /* @Override protected void attachBaseContext(Context base) { // get language from prefs String lang = LangUtils.getLanguage(base.getApplicationContext()); super.attachBaseContext(LangUtils.setAppLocale(base, lang)); } + */ } diff --git a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/dao/ReferralTaskDao.java b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/dao/ReferralTaskDao.java index 6278bcd186..ac7678cc2b 100644 --- a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/dao/ReferralTaskDao.java +++ b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/dao/ReferralTaskDao.java @@ -2,19 +2,21 @@ import org.joda.time.DateTime; import org.smartregister.dao.AbstractDao; +import org.smartregister.domain.Period; import org.smartregister.domain.Task; import java.util.List; -public class ReferralTaskDao extends AbstractDao{ +public class ReferralTaskDao extends AbstractDao { /** * This method return a list of referral tasks that were marked as done on Facility and are now * supposed to be dismissed (Completed) by the chw; 3 days after the CHW marked them as done. + * * @return list of referral tasks to be completed */ - public static List getToBeCompletedReferralTasks(){ + public static List getToBeCompletedReferralTasks() { String queryStatement = - "SELECT task.*\n" + + "SELECT task.*\n" + "FROM task\n" + " INNER JOIN ec_referral_dismissal on task._id = ec_referral_dismissal.referral_task\n" + "WHERE (Cast((JulianDay(ec_referral_dismissal.notification_dismissal_date) -\n" + @@ -34,13 +36,17 @@ private static AbstractDao.DataMap mapColumnValuesToTask() { task.setGroupIdentifier(getCursorValue(row, "group_id")); task.setStatus(Task.TaskStatus.valueOf(getCursorValue(row, "status"))); task.setBusinessStatus(getCursorValue(row, "business_status")); - task.setPriority(getCursorIntValue(row, "priority")); + task.setPriority(Task.TaskPriority.valueOf(getCursorValue(row, "priority"))); task.setCode(getCursorValue(row, "code")); task.setDescription(getCursorValue(row, "description")); task.setFocus(getCursorValue(row, "focus")); task.setForEntity(getCursorValue(row, "for")); - task.setExecutionStartDate(new DateTime(getCursorValueAsDate(row, "start"))); - task.setExecutionEndDate(new DateTime(getCursorValueAsDate(row, "end"))); + + Period period = new Period(); + period.setStart(new DateTime(getCursorValueAsDate(row, "start"))); + period.setEnd(new DateTime(getCursorValueAsDate(row, "end"))); + task.setExecutionPeriod(period); + task.setAuthoredOn(new DateTime(getCursorValueAsDate(row, "authored_on"))); task.setLastModified(new DateTime(getCursorValueAsDate(row, "last_modified"))); task.setOwner(getCursorValue(row, "owner")); diff --git a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/sync/intent/CloseExpiredReferralsIntentService.java b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/sync/intent/CloseExpiredReferralsIntentService.java index 4e743b6ecc..acead92634 100644 --- a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/sync/intent/CloseExpiredReferralsIntentService.java +++ b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/sync/intent/CloseExpiredReferralsIntentService.java @@ -14,6 +14,7 @@ import org.smartregister.chw.referral.util.DBConstants; import org.smartregister.clientandeventmodel.Event; import org.smartregister.clientandeventmodel.Obs; +import org.smartregister.domain.Period; import org.smartregister.domain.Task; import org.smartregister.family.FamilyLibrary; import org.smartregister.repository.AllSharedPreferences; @@ -247,7 +248,9 @@ private void referralNotYetDoneTask(String taskId, String baseEntityId) { private Task updateCurrentTask(String taskId, String baseEntityId) { Task currentTask = taskRepository.getTaskByIdentifier(taskId); DateTime now = new DateTime(); - currentTask.setExecutionEndDate(now); + Period period = new Period(); + period.setEnd(now); + currentTask.setExecutionPeriod(period); currentTask.setLastModified(now); currentTask.setForEntity(baseEntityId); currentTask.setSyncStatus(BaseRepository.TYPE_Unsynced); 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 b6fdfb6560..8b7ad7701f 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 @@ -19,6 +19,7 @@ import org.smartregister.clientandeventmodel.Event; import org.smartregister.commonregistry.CommonRepository; import org.smartregister.cursoradapter.SmartRegisterQueryBuilder; +import org.smartregister.domain.Period; import org.smartregister.domain.Task; import org.smartregister.family.util.DBConstants; import org.smartregister.location.helper.LocationHelper; @@ -171,13 +172,17 @@ private static void createReferralTask(String baseEntityId, AllSharedPreferences 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); + task.setPriority(Task.TaskPriority.ROUTINE); task.setCode(CoreConstants.JsonAssets.REFERRAL_CODE); task.setDescription(referralProblems); task.setFocus(focus); task.setForEntity(baseEntityId); DateTime now = new DateTime(); - task.setExecutionStartDate(now); + + Period period = new Period(); + period.setStart(now); + task.setExecutionPeriod(period); + task.setAuthoredOn(now); task.setLastModified(now); task.setOwner(allSharedPreferences.fetchRegisteredANM()); From fa6e5e516cef42331e7213ae2514b9c6346aac2f Mon Sep 17 00:00:00 2001 From: rkodev <43806892+rkodev@users.noreply.github.com> Date: Wed, 2 Dec 2020 17:09:30 +0300 Subject: [PATCH 76/78] Fix broken tests after core v4.) --- .../chw/core/application/TestApplication.java | 3 +- .../CoreFamilyPlanningFloatingMenuTest.java | 20 ++--- .../chw/core/dao/FHIRBundleDaoTest.java | 3 - .../chw/core/dao/ReferralTaskDaoTest.java | 5 +- .../core/sync/SampleSyncConfiguration.java | 74 +++++++++++++++++++ 5 files changed, 84 insertions(+), 21 deletions(-) create mode 100644 opensrp-chw-core/src/test/java/org/smartregister/chw/core/sync/SampleSyncConfiguration.java diff --git a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/application/TestApplication.java b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/application/TestApplication.java index be4eb2204b..41dc3b9ef0 100644 --- a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/application/TestApplication.java +++ b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/application/TestApplication.java @@ -4,6 +4,7 @@ import org.robolectric.Robolectric; import org.smartregister.Context; import org.smartregister.CoreLibrary; +import org.smartregister.chw.core.sync.SampleSyncConfiguration; import org.smartregister.chw.pnc.PncLibrary; import org.smartregister.configurableviews.ConfigurableViewsLibrary; import org.smartregister.family.BuildConfig; @@ -27,7 +28,7 @@ public void onCreate() { mInstance = this; context = Context.getInstance(); context.updateApplicationContext(getApplicationContext()); - CoreLibrary.init(context); + CoreLibrary.init(context, new SampleSyncConfiguration()); ConfigurableViewsLibrary.init(context); diff --git a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/custom_views/CoreFamilyPlanningFloatingMenuTest.java b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/custom_views/CoreFamilyPlanningFloatingMenuTest.java index 86f8a4601e..62fd1dac67 100644 --- a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/custom_views/CoreFamilyPlanningFloatingMenuTest.java +++ b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/custom_views/CoreFamilyPlanningFloatingMenuTest.java @@ -1,30 +1,27 @@ package org.smartregister.chw.core.custom_views; +import android.os.Build; import android.view.View; import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.MockitoAnnotations; +import org.robolectric.RobolectricTestRunner; +import org.robolectric.annotation.Config; import org.smartregister.Context; -import org.smartregister.CoreLibrary; +import org.smartregister.chw.core.application.TestApplication; import org.smartregister.chw.core.listener.OnClickFloatingMenu; -import org.smartregister.commonregistry.CommonRepository; import java.util.ArrayList; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.Mockito.when; - +@RunWith(RobolectricTestRunner.class) +@Config(application = TestApplication.class, sdk = Build.VERSION_CODES.P) public class CoreFamilyPlanningFloatingMenuTest { - @Mock - private CommonRepository commonRepository; - - @Mock - private Context context; private CoreFamilyPlanningFloatingMenu coreFamilyPlanningFloatingMenu; @@ -38,9 +35,6 @@ public class CoreFamilyPlanningFloatingMenuTest { public void setUp() { MockitoAnnotations.initMocks(this); coreFamilyPlanningFloatingMenu = Mockito.mock(CoreFamilyPlanningFloatingMenu.class, Mockito.CALLS_REAL_METHODS); - - CoreLibrary.init(context); - when(context.commonrepository(anyString())).thenReturn(commonRepository); Context.bindtypes = new ArrayList<>(); } diff --git a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/dao/FHIRBundleDaoTest.java b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/dao/FHIRBundleDaoTest.java index 7bcc0774d2..e5ad9703f4 100644 --- a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/dao/FHIRBundleDaoTest.java +++ b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/dao/FHIRBundleDaoTest.java @@ -14,7 +14,6 @@ import org.powermock.api.mockito.PowerMockito; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; -import org.smartregister.CoreLibrary; import org.smartregister.chw.core.utils.Utils; import org.smartregister.thinkmd.model.FHIRBundleModel; @@ -31,8 +30,6 @@ public class FHIRBundleDaoTest { @Before public void setUp() { MockitoAnnotations.initMocks(this); - org.smartregister.Context context = org.smartregister.Context.getInstance(); - CoreLibrary.init(context); } @PrepareForTest({ChildDao.class, Utils.class}) diff --git a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/dao/ReferralTaskDaoTest.java b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/dao/ReferralTaskDaoTest.java index 928a0ecf0a..ad44236b00 100644 --- a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/dao/ReferralTaskDaoTest.java +++ b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/dao/ReferralTaskDaoTest.java @@ -6,11 +6,9 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.MockitoAnnotations; -import org.mockito.junit.MockitoJUnitRunner; import org.smartregister.domain.Task; import org.smartregister.repository.Repository; @@ -18,7 +16,6 @@ import static org.smartregister.domain.Task.TaskStatus.READY; -@RunWith(MockitoJUnitRunner.class) public class ReferralTaskDaoTest extends ReferralTaskDao { @Mock private Repository repository; @@ -38,7 +35,7 @@ public void testGetToBeCompletedReferralTasks() { MatrixCursor matrixCursor = new MatrixCursor(new String[]{"_id", "plan_id", "group_id", "status", "business_status", "priority", "code", "description", "focus", "for", "start", "end", "authored_on", "last_modified", "owner", "sync_status", "server_version", "structure_id", "reason_reference", "location", "requester"}); - matrixCursor.addRow(new Object[]{"1", "plan", "group", READY, "Complete", 3, "ANC", "referred", "ANC Visit", + matrixCursor.addRow(new Object[]{"1", "plan", "group", READY, "Complete", "ROUTINE", "ANC", "referred", "ANC Visit", "location.properties.uid:415-2342fc", "1589962159596", "1589962159596", "1589962159596", "1589962159596", "chwone", 1, "1566393632423", "structure._id.33efadf1-feda-4861-a979-ff4f7cec9ea7", "assigned to", "2c3a0ebd-f79d-4128-a6d3-5dfbffbd01c8", "chwone"}); diff --git a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/sync/SampleSyncConfiguration.java b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/sync/SampleSyncConfiguration.java new file mode 100644 index 0000000000..88330b0a51 --- /dev/null +++ b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/sync/SampleSyncConfiguration.java @@ -0,0 +1,74 @@ +package org.smartregister.chw.core.sync; + +import org.smartregister.SyncConfiguration; +import org.smartregister.SyncFilter; +import org.smartregister.view.activity.BaseLoginActivity; + +import java.util.List; + +public class SampleSyncConfiguration extends SyncConfiguration { + @Override + public int getSyncMaxRetries() { + return 0; + } + + @Override + public SyncFilter getSyncFilterParam() { + return SyncFilter.LOCATION_ID; + } + + @Override + public String getSyncFilterValue() { + return "12324"; + } + + @Override + public int getUniqueIdSource() { + return 0; + } + + @Override + public int getUniqueIdBatchSize() { + return 0; + } + + @Override + public int getUniqueIdInitialBatchSize() { + return 0; + } + + @Override + public SyncFilter getEncryptionParam() { + return SyncFilter.LOCATION_ID; + } + + @Override + public boolean updateClientDetailsTable() { + return false; + } + + @Override + public List getSynchronizedLocationTags() { + return null; + } + + @Override + public String getTopAllowedLocationLevel() { + return null; + } + + @Override + public String getOauthClientId() { + return null; + } + + @Override + public String getOauthClientSecret() { + return null; + } + + @Override + public Class getAuthenticationActivity() { + return null; + } +} From a46ab759dfeea29cff37b62d79f31a4b9ac38402 Mon Sep 17 00:00:00 2001 From: rkodev <43806892+rkodev@users.noreply.github.com> Date: Wed, 2 Dec 2020 17:12:46 +0300 Subject: [PATCH 77/78] Update vore to verion 2.0.6 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index ebbcf9cd6e..5eddd4a28d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -VERSION_NAME=2.0.5-SNAPSHOT +VERSION_NAME=2.0.6-SNAPSHOT VERSION_CODE=1 GROUP=org.smartregister POM_SETTING_DESCRIPTION=OpenSRP Client Chw Core Library From d6ef422786284e0334fbfa94768aa9fc6d118627 Mon Sep 17 00:00:00 2001 From: rkodev <43806892+rkodev@users.noreply.github.com> Date: Mon, 7 Dec 2020 15:23:04 +0300 Subject: [PATCH 78/78] Upgrade native forms, family and p2p library --- gradle.properties | 2 +- opensrp-chw-core/build.gradle | 6 ++++-- .../chw/core/activity/CoreFamilyRegisterActivity.java | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/gradle.properties b/gradle.properties index 5eddd4a28d..6787bf3f6f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -VERSION_NAME=2.0.6-SNAPSHOT +VERSION_NAME=2.0.7-SNAPSHOT VERSION_CODE=1 GROUP=org.smartregister POM_SETTING_DESCRIPTION=OpenSRP Client Chw Core Library diff --git a/opensrp-chw-core/build.gradle b/opensrp-chw-core/build.gradle index 0959215821..a124bed74f 100644 --- a/opensrp-chw-core/build.gradle +++ b/opensrp-chw-core/build.gradle @@ -157,7 +157,7 @@ dependencies { exclude group: 'com.android.support', module: 'appcompat-v7' } - api('org.smartregister:opensrp-client-family:2.0.0-SNAPSHOT@aar') { + api('org.smartregister:opensrp-client-family:2.0.1-SNAPSHOT@aar') { transitive = true exclude group: 'org.smartregister', module: 'opensrp-client-core' exclude group: 'org.smartregister', module: 'opensrp-client-native-form' @@ -197,6 +197,7 @@ dependencies { exclude group: 'org.smartregister', module: 'opensrp-client-native-form' exclude group: 'org.smartregister', module: 'opensrp-client-configurable-views' exclude group: 'org.smartregister', module: 'opensrp-client-immunization' + exclude group: 'org.smartregister', module: 'opensrp-client-family' } api('org.smartregister:opensrp-client-chw-pnc:2.0.0-SNAPSHOT@aar') { @@ -207,6 +208,7 @@ dependencies { exclude group: 'org.smartregister', module: 'opensrp-client-native-form' exclude group: 'org.smartregister', module: 'opensrp-client-configurable-views' exclude group: 'org.smartregister', module: 'opensrp-client-immunization' + exclude group: 'org.smartregister', module: 'opensrp-client-family' } api('org.smartregister:opensrp-client-chw-malaria:1.2.18-SNAPSHOT@aar') { @@ -251,7 +253,7 @@ dependencies { api 'com.evernote:android-job:1.2.6' api 'org.greenrobot:eventbus:3.1.1' - api("org.smartregister:android-p2p-sync:0.3.8-aplha3-SNAPSHOT") { + api("org.smartregister:android-p2p-sync:0.3.8-aplha4-SNAPSHOT") { transitive = true exclude group: 'org.smartregister', module: 'opensrp-client-core' exclude group: 'com.android.support', module: 'appcompat-v7' diff --git a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/CoreFamilyRegisterActivity.java b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/CoreFamilyRegisterActivity.java index c27ac79f7f..123a289d70 100644 --- a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/CoreFamilyRegisterActivity.java +++ b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/CoreFamilyRegisterActivity.java @@ -64,7 +64,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) { @Override public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { - if (requestCode == CoreConstants.RQ_CODE.STORAGE_PERMISIONS && grantResults[0] == PackageManager.PERMISSION_GRANTED) { + if (requestCode == CoreConstants.RQ_CODE.STORAGE_PERMISIONS && grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { NavigationMenu navigationMenu = NavigationMenu.getInstance(this, null, null); if (navigationMenu != null) { navigationMenu.startP2PActivity(this);