diff --git a/build.gradle b/build.gradle index 33a2c066ed..7187516bb0 100644 --- a/build.gradle +++ b/build.gradle @@ -54,7 +54,13 @@ allprojects { maven { url 'https://maven.fabric.io/public' } maven { url "https://s3.amazonaws.com/repo.commonsware.com" } maven { url 'https://nexus.pentaho.org/content/groups/omni/' } - maven { url 'https://dl.bintray.com/ibm-watson-health/ibm-fhir-server-releases' } + maven { + url 'https://dl.bintray.com/ibm-watson-health/ibm-fhir-server-releases' + content { + // Does only include this group + includeGroup "com.ibm.fhir" + } + } } } diff --git a/opensrp-chw/build.gradle b/opensrp-chw/build.gradle index 2c1704d343..d3794ec1a6 100644 --- a/opensrp-chw/build.gradle +++ b/opensrp-chw/build.gradle @@ -39,6 +39,7 @@ allprojects { } } + apply plugin: 'com.android.application' apply plugin: 'jacoco' apply plugin: 'com.github.kt3k.coveralls' @@ -61,8 +62,14 @@ android { checkReleaseBuilds false abortOnError false } + defaultConfig { + // Required when setting minSdkVersion to 20 or lower + multiDexEnabled true + } compileOptions { + coreLibraryDesugaringEnabled true + sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } @@ -157,6 +164,7 @@ android { buildConfigField "int", "STOCK_USAGE_REPORT_MINUTES", '1440' buildConfigField "boolean", "USE_UNIFIED_REFERRAL_APPROACH", "true" buildConfigField "boolean", "BUILD_FOR_BORESHA_AFYA_SOUTH", "false" + buildConfigField "boolean", "LOG_CRASHLYTICS", "true" } debug { @@ -175,8 +183,14 @@ android { buildConfigField "int", "STOCK_USAGE_REPORT_MINUTES", '1440' buildConfigField "boolean", "USE_UNIFIED_REFERRAL_APPROACH", "true" buildConfigField "boolean", "BUILD_FOR_BORESHA_AFYA_SOUTH", "false" + buildConfigField "boolean", "LOG_CRASHLYTICS", "false" testCoverageEnabled true } + + preview { + initWith debug + buildConfigField "boolean", "LOG_CRASHLYTICS", "true" + } } packagingOptions { @@ -203,6 +217,7 @@ android { returnDefaultValues = true includeAndroidResources = true } + unitTests.all { systemProperty 'robolectric.enabledSdks', '28' jvmArgs '-noverify' @@ -329,16 +344,18 @@ android { dimension = 'baseDimension' applicationIdSuffix ".lmh" versionCode 2 - versionName "0.1.7" + versionName "1.1.2" + buildConfigField "int", "OPENMRS_UNIQUE_ID_INITIAL_BATCH_SIZE", '100000' + buildConfigField "int", "OPENMRS_UNIQUE_ID_BATCH_SIZE", '50000' buildConfigField "String", 'opensrp_url', '"https://lmh-liberia.smartregister.org/opensrp/"' buildConfigField "String", 'guidebooks_url', '"https://opensrp.s3.amazonaws.com/media/lmh/"' - buildConfigField "String", 'opensrp_url_debug', '"https://lmh-stage.smartregister.org/opensrp/"' + buildConfigField "String", 'opensrp_url_debug', '"https://lmh-liberia-preview.smartregister.org/opensrp/"' buildConfigField "String[]", "LOCATION_HIERACHY", '{"Country" , "County" , "District", "Clinics", "CHSS", "Village","Commune"}' buildConfigField "String[]", "ALLOWED_LOCATION_LEVELS", '{"Country" , "County" , "District", "Clinics", "CHSS", "Village","Commune"}' - buildConfigField "String[]", "ALLOWED_LOCATION_LEVELS_DEBUG", '{"Clinic" , "CHSS" , "CHA"}' + buildConfigField "String[]", "ALLOWED_LOCATION_LEVELS_DEBUG", '{"Country" , "County" , "District", "Clinics", "CHSS", "Village","Commune"}' buildConfigField "String", 'DEFAULT_LOCATION', '"Commune"' - buildConfigField "String", 'DEFAULT_LOCATION_DEBUG', '"CHA"' - buildConfigField "int", "DATABASE_VERSION", '6' + buildConfigField "String", 'DEFAULT_LOCATION_DEBUG', '"Commune"' + buildConfigField "int", "DATABASE_VERSION", '7' } } @@ -348,7 +365,11 @@ android { } dependencies { - implementation('org.smartregister:opensrp-client-chw-core:2.1.3-SNAPSHOT@aar') { + coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5' + + implementation('com.google.android.gms:play-services-vision:17.0.2') + + implementation('org.smartregister:opensrp-client-chw-core:2.1.4-LMH-Beta-04-SNAPSHOT@aar') { transitive = true exclude group: 'com.android.support', module: 'appcompat-v7' exclude group: 'androidx.legacy', module: 'legacy-support-v4' @@ -379,6 +400,7 @@ dependencies { androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' androidTestImplementation 'org.mockito:mockito-android:3.0.0' + //implementation 'com.github.lecho:hellocharts-android:1.5.8@aar' //For viewing PDFs in the app implementation 'com.github.barteksc:android-pdf-viewer:3.2.0-beta.1' @@ -391,6 +413,15 @@ dependencies { testImplementation 'org.robolectric:shadows-multidex:4.3.1' testImplementation 'org.robolectric:shadows-support-v4:3.4-rc2' testImplementation 'androidx.test:core:1.3.0' + // testImplementation 'com.ibm.fhir:fhir-model:4.7.0' + // testImplementation 'com.ibm.fhir:fhir-path:4.7.0' + + // unit test + def powerMockVersion = '2.0.7' + testImplementation "org.powermock:powermock-module-junit4:$powerMockVersion" + testImplementation "org.powermock:powermock-module-junit4-rule:$powerMockVersion" + testImplementation "org.powermock:powermock-api-mockito2:$powerMockVersion" + testImplementation "org.powermock:powermock-classloading-xstream:$powerMockVersion" } def flavors = android.productFlavors.collect { flavor -> flavor.name } @@ -430,6 +461,11 @@ task jacocoTestReport(type: JacocoReport, dependsOn: [ tasks.withType(Test) { jacoco.includeNoLocationClasses = true maxHeapSize = "3g" + + testLogging { + events "failed" + exceptionFormat "full" + } } tasks.coveralls { @@ -439,4 +475,4 @@ tasks.coveralls { coveralls { jacocoReportPath = "${buildDir}/reports/jacoco/jacocoRootReport/merged.xml" sourceDirs = ["$project.projectDir/src/main/java"] -} +} \ No newline at end of file diff --git a/opensrp-chw/src/ba/java/org/smartregister/chw/custom_view/FamilyFloatingMenuFlv.java b/opensrp-chw/src/ba/java/org/smartregister/chw/custom_view/FamilyFloatingMenuFlv.java new file mode 100644 index 0000000000..7c6952b48e --- /dev/null +++ b/opensrp-chw/src/ba/java/org/smartregister/chw/custom_view/FamilyFloatingMenuFlv.java @@ -0,0 +1,4 @@ +package org.smartregister.chw.custom_view; + +public class FamilyFloatingMenuFlv extends DefaultFamilyFloatingMenuFlv { +} diff --git a/opensrp-chw/src/ba/java/org/smartregister/chw/custom_view/NavigationMenuFlv.java b/opensrp-chw/src/ba/java/org/smartregister/chw/custom_view/NavigationMenuFlv.java index c0a5df02d6..9417c8737b 100644 --- a/opensrp-chw/src/ba/java/org/smartregister/chw/custom_view/NavigationMenuFlv.java +++ b/opensrp-chw/src/ba/java/org/smartregister/chw/custom_view/NavigationMenuFlv.java @@ -6,7 +6,6 @@ import org.apache.commons.lang3.tuple.Pair; import org.smartregister.chw.core.activity.CoreStockInventoryReportActivity; import org.smartregister.chw.core.activity.HIA2ReportsActivity; -import org.smartregister.chw.core.custom_views.NavigationMenu; import org.smartregister.chw.core.utils.CoreConstants; import org.smartregister.chw.referral.util.Constants; @@ -15,7 +14,7 @@ import java.util.List; import java.util.Locale; -public class NavigationMenuFlv implements NavigationMenu.Flavour { +public class NavigationMenuFlv extends DefaultNavigationMenuFlv { @Override public List> getSupportedLanguages() { diff --git a/opensrp-chw/src/ba/java/org/smartregister/chw/interactor/PncHomeVisitInteractorFlv.java b/opensrp-chw/src/ba/java/org/smartregister/chw/interactor/PncHomeVisitInteractorFlv.java index b54a8cd499..8fdb6d85fb 100644 --- a/opensrp-chw/src/ba/java/org/smartregister/chw/interactor/PncHomeVisitInteractorFlv.java +++ b/opensrp-chw/src/ba/java/org/smartregister/chw/interactor/PncHomeVisitInteractorFlv.java @@ -759,7 +759,7 @@ protected void evaluateImmunization(Person baby) throws Exception { .withBaseEntityID(baby.getBaseEntityID()) .withProcessingMode(BaseAncHomeVisitAction.ProcessingMode.SEPARATE) .withDestinationFragment(BaseHomeVisitImmunizationFragment.getInstance(view, baby.getBaseEntityID(), details, displays)) - .withHelper(new ImmunizationActionHelper(context, wrappers)) + .withHelper(new ImmunizationActionHelper(context, () -> wrappers)) .build(); actionList.put(MessageFormat.format(context.getString(R.string.pnc_immunization_at_birth), baby.getFullName()), action); diff --git a/opensrp-chw/src/chad/java/org/smartregister/chw/custom_view/FamilyFloatingMenuFlv.java b/opensrp-chw/src/chad/java/org/smartregister/chw/custom_view/FamilyFloatingMenuFlv.java new file mode 100644 index 0000000000..7c6952b48e --- /dev/null +++ b/opensrp-chw/src/chad/java/org/smartregister/chw/custom_view/FamilyFloatingMenuFlv.java @@ -0,0 +1,4 @@ +package org.smartregister.chw.custom_view; + +public class FamilyFloatingMenuFlv extends DefaultFamilyFloatingMenuFlv { +} diff --git a/opensrp-chw/src/drc/java/org/smartregister/chw/custom_view/FamilyFloatingMenuFlv.java b/opensrp-chw/src/drc/java/org/smartregister/chw/custom_view/FamilyFloatingMenuFlv.java new file mode 100644 index 0000000000..7c6952b48e --- /dev/null +++ b/opensrp-chw/src/drc/java/org/smartregister/chw/custom_view/FamilyFloatingMenuFlv.java @@ -0,0 +1,4 @@ +package org.smartregister.chw.custom_view; + +public class FamilyFloatingMenuFlv extends DefaultFamilyFloatingMenuFlv { +} diff --git a/opensrp-chw/src/guinea/java/org/smartregister/chw/custom_view/FamilyFloatingMenuFlv.java b/opensrp-chw/src/guinea/java/org/smartregister/chw/custom_view/FamilyFloatingMenuFlv.java new file mode 100644 index 0000000000..7c6952b48e --- /dev/null +++ b/opensrp-chw/src/guinea/java/org/smartregister/chw/custom_view/FamilyFloatingMenuFlv.java @@ -0,0 +1,4 @@ +package org.smartregister.chw.custom_view; + +public class FamilyFloatingMenuFlv extends DefaultFamilyFloatingMenuFlv { +} diff --git a/opensrp-chw/src/liberia/java/org/smartregister/chw/custom_view/FamilyFloatingMenuFlv.java b/opensrp-chw/src/liberia/java/org/smartregister/chw/custom_view/FamilyFloatingMenuFlv.java new file mode 100644 index 0000000000..7c6952b48e --- /dev/null +++ b/opensrp-chw/src/liberia/java/org/smartregister/chw/custom_view/FamilyFloatingMenuFlv.java @@ -0,0 +1,4 @@ +package org.smartregister.chw.custom_view; + +public class FamilyFloatingMenuFlv extends DefaultFamilyFloatingMenuFlv { +} diff --git a/opensrp-chw/src/lmh/assets/json.form/child_enrollment.json b/opensrp-chw/src/lmh/assets/json.form/child_enrollment.json index 989bd16862..3a446ec5d8 100644 --- a/opensrp-chw/src/lmh/assets/json.form/child_enrollment.json +++ b/opensrp-chw/src/lmh/assets/json.form/child_enrollment.json @@ -87,6 +87,7 @@ "openmrs_entity_id": "first_name", "openmrs_data_type": "text", "type": "edit_text", + "edit_type": "name", "hint": "{{child_enrollment.step1.first_name.hint}}", "expanded": false, "v_required": { @@ -105,6 +106,7 @@ "openmrs_entity_id": "middle_name", "openmrs_data_type": "text", "type": "edit_text", + "edit_type": "name", "hint": "{{child_enrollment.step1.middle_name.hint}}", "expanded": false, "v_regex": { @@ -206,11 +208,18 @@ "openmrs_entity_parent": "", "openmrs_entity": "person", "openmrs_entity_id": "gender", - "type": "spinner", + "type": "native_radio", "hint": "{{child_enrollment.step1.gender.hint}}", - "values": [ - "{{child_enrollment.step1.gender.values[0]}}", - "{{child_enrollment.step1.gender.values[1]}}" + "label": "{{child_enrollment.step1.gender.hint}}", + "options": [ + { + "key": "{{child_enrollment.step1.gender.values[0]}}", + "text": "{{child_enrollment.step1.gender.values[0]}}" + }, + { + "key": "{{child_enrollment.step1.gender.values[1]}}", + "text": "{{child_enrollment.step1.gender.values[1]}}" + } ], "v_required": { "value": "true", diff --git a/opensrp-chw/src/lmh/assets/json.form/family_member_register.json b/opensrp-chw/src/lmh/assets/json.form/family_member_register.json index 2b4d74aa4e..be47fda079 100644 --- a/opensrp-chw/src/lmh/assets/json.form/family_member_register.json +++ b/opensrp-chw/src/lmh/assets/json.form/family_member_register.json @@ -206,11 +206,18 @@ "openmrs_entity_parent": "", "openmrs_entity": "person", "openmrs_entity_id": "gender", - "type": "spinner", + "type": "native_radio", + "label": "{{family_member_register.step1.sex.hint}}", "hint": "{{family_member_register.step1.sex.hint}}", - "values": [ - "{{family_member_register.step1.sex.values[0]}}", - "{{family_member_register.step1.sex.values[1]}}" + "options": [ + { + "key": "{{family_member_register.step1.sex.values[0]}}", + "text": "{{family_member_register.step1.sex.values[0]}}" + }, + { + "key": "{{family_member_register.step1.sex.values[1]}}", + "text":"{{family_member_register.step1.sex.values[1]}}" + } ], "v_required": { "value": "true", diff --git a/opensrp-chw/src/lmh/assets/json.form/family_register.json b/opensrp-chw/src/lmh/assets/json.form/family_register.json index 11112a5124..ba94cdf416 100644 --- a/opensrp-chw/src/lmh/assets/json.form/family_register.json +++ b/opensrp-chw/src/lmh/assets/json.form/family_register.json @@ -1,5 +1,5 @@ { - "validate_on_submit": true, + "validate_on_submit": false, "show_errors_on_submit": false, "count": "2", "encounter_type": "Family Registration", @@ -80,7 +80,8 @@ "openmrs_entity": "person_identifier", "openmrs_entity_id": "opensrp_id", "hidden": "true", - "type": "barcode", + "type": "edit_text", + "value": "0", "barcode_type": "qrcode", "hint": "{{family_register.step1.unique_id.hint}}", "scanButtonText": "{{family_register.step1.unique_id.scanButtonText}}", @@ -95,6 +96,7 @@ "openmrs_entity": "person_address", "openmrs_entity_id": "cityVillage", "type": "edit_text", + "edit_type": "name", "hint": "{{family_register.step1.village_town.hint}}", "v_required": { "value": "true", @@ -257,11 +259,18 @@ "openmrs_entity_parent": "", "openmrs_entity": "person", "openmrs_entity_id": "gender", - "type": "spinner", + "type": "native_radio", + "label": "{{family_register.step2.sex.hint}}", "hint": "{{family_register.step2.sex.hint}}", - "values": [ - "{{family_register.step2.sex.values[0]}}", - "{{family_register.step2.sex.values[1]}}" + "options": [ + { + "key": "{{family_register.step2.sex.values[0]}}", + "text": "{{family_register.step2.sex.values[0]}}" + }, + { + "key": "{{family_register.step2.sex.values[1]}}", + "text": "{{family_register.step2.sex.values[1]}}" + } ], "v_required": { "value": "true", diff --git a/opensrp-chw/src/lmh/assets/vaccines.json b/opensrp-chw/src/lmh/assets/vaccines.json index db3e82e5bf..f17a41da95 100644 --- a/opensrp-chw/src/lmh/assets/vaccines.json +++ b/opensrp-chw/src/lmh/assets/vaccines.json @@ -53,13 +53,13 @@ { "reference": "dob", "offset": "+0d", - "window": "+5y" + "window": "+1y" } ], "expiry": [ { "reference": "dob", - "offset": "+5y" + "offset": "+1y" } ] } @@ -1020,6 +1020,36 @@ } ] } + }, + { + "name": "Typhoid", + "type": "Typhoid", + "openmrs_date": { + "parent_entity": "86022AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", + "entity": "concept", + "entity_id": "1410AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + }, + "openmrs_calculate": { + "parent_entity": "86022AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", + "entity": "concept", + "entity_id": "1418AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", + "calculation": 1 + }, + "schedule": { + "due": [ + { + "reference": "dob", + "offset": "+9m", + "window": "+2y" + } + ], + "expiry": [ + { + "reference": "dob", + "offset": "+2y" + } + ] + } } ] }, diff --git a/opensrp-chw/src/lmh/java/org/smartregister/chw/activity/ChildProfileActivityFlv.java b/opensrp-chw/src/lmh/java/org/smartregister/chw/activity/ChildProfileActivityFlv.java index 6c7e72629d..5c43c7ef4b 100644 --- a/opensrp-chw/src/lmh/java/org/smartregister/chw/activity/ChildProfileActivityFlv.java +++ b/opensrp-chw/src/lmh/java/org/smartregister/chw/activity/ChildProfileActivityFlv.java @@ -53,4 +53,9 @@ public void setVaccineHistoryView(String days, RelativeLayout layoutVaccineHisto public String getToolbarTitleName(MemberObject memberObject) { return memberObject.getFamilyName(); } + + @Override + public boolean usesEligibleChildText(){ + return true; + } } diff --git a/opensrp-chw/src/lmh/java/org/smartregister/chw/activity/DefaultChildMedicalHistoryActivityFlv.java b/opensrp-chw/src/lmh/java/org/smartregister/chw/activity/DefaultChildMedicalHistoryActivityFlv.java index 4a85d115f4..48232756c7 100644 --- a/opensrp-chw/src/lmh/java/org/smartregister/chw/activity/DefaultChildMedicalHistoryActivityFlv.java +++ b/opensrp-chw/src/lmh/java/org/smartregister/chw/activity/DefaultChildMedicalHistoryActivityFlv.java @@ -26,6 +26,7 @@ import org.smartregister.immunization.domain.ServiceRecord; import org.smartregister.immunization.domain.Vaccine; +import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Arrays; @@ -44,6 +45,7 @@ public abstract class DefaultChildMedicalHistoryActivityFlv implements CoreChild protected Map> vaccineMap = new LinkedHashMap<>(); private Context context; private LinearLayout parentView; + private final SimpleDateFormat dateFormat = new SimpleDateFormat(Constants.DATE_FORMATS.DOB, Locale.getDefault()); private SimpleDateFormat sdf = new SimpleDateFormat("dd MMM yyyy", Locale.getDefault()); @Override @@ -105,6 +107,23 @@ protected void evaluateLastVisitDate() { protected void evaluateImmunizations() { if (vaccineMap != null && vaccineMap.size() > 0) { + List validVaccines = new ArrayList<>(); + for (Visit visit: visits){ + for (Map.Entry> entry: visit.getVisitDetails().entrySet()){ + List validDetails = new ArrayList<>(entry.getValue().size()); + for (VisitDetail visitDetail: entry.getValue()) { + String date = NCUtils.getText(visitDetail); + // Using try to valid has a valid date, and may be not 'Vaccine not given' + try{ + dateFormat.parse(date); + validDetails.add(visitDetail); + } catch (ParseException e) { + e.printStackTrace(); + } + } + if (!validDetails.isEmpty()) validVaccines.add(entry.getKey()); + } + } List vaccineGiven = new ArrayList<>(); // generate data @@ -115,6 +134,8 @@ protected void evaluateImmunizations() { List content = new ArrayList<>(); for (Vaccine vaccine : entry.getValue()) { String val = toLowerCase(vaccine.getName()).replace(" ", "_"); + if (!validVaccines.contains(val)) continue; + vaccineGiven.add(val.replace("_", "")); String translated = Utils.getStringResourceByName(val, context); content.add(String.format("%s - %s %s", translated, context.getString(org.smartregister.chw.core.R.string.done), sdf.format(vaccine.getDate()))); diff --git a/opensrp-chw/src/lmh/java/org/smartregister/chw/application/ChwApplicationFlv.java b/opensrp-chw/src/lmh/java/org/smartregister/chw/application/ChwApplicationFlv.java index e7ae90d3db..0713a68b63 100644 --- a/opensrp-chw/src/lmh/java/org/smartregister/chw/application/ChwApplicationFlv.java +++ b/opensrp-chw/src/lmh/java/org/smartregister/chw/application/ChwApplicationFlv.java @@ -49,7 +49,7 @@ public boolean hasJobAids() { @Override public boolean hasDefaultDueFilterForChildClient() { - return true; + return false; } @Override @@ -94,16 +94,15 @@ public boolean showChildrenUnder5() { @Override public boolean launchChildClientsAtLogin() { - return true; + return false; } @Override public boolean useThinkMd() { - return true; + return false; } @Override - public boolean splitUpcomingServicesView() { return true; } @@ -149,21 +148,103 @@ public boolean showLastNameOnChildProfile() { } @Override - public boolean showChildrenAboveTwoDueStatus(){ + public boolean showChildrenAboveTwoDueStatus() { + return false; + } + + @Override + public boolean showFamilyServicesScheduleWithChildrenAboveTwo() { + return false; + } + + @Override + public boolean hasForeignData() { + return true; + } + + @Override + public boolean showIconsForChildrenUnderTwoAndGirlsAgeNineToEleven() { + return true; + } + + @Override + public boolean useAllChildrenTitle() { + return true; + } + + @Override + public boolean showBottomNavigation() { + return false; + } + + @Override + public boolean disableTitleClickGoBack() { + return true; + } + + @Override + public boolean showReportsDescription() { + return true; + } + + @Override + public boolean showDueFilterToggle() { return false; } @Override - public boolean showFamilyServicesScheduleWithChildrenAboveTwo() {return false;} + public boolean showReportsDivider() { + return true; + } + + @Override + public boolean hideChildRegisterPreviousNextIcons() { + return true; + } + + @Override + public boolean hideFamilyRegisterPreviousNextIcons() { + return true; + } + + @Override + public boolean showFamilyRegisterNextInToolbar() { + return true; + } + + @Override + public boolean onFamilySaveGoToProfile() { + return true; + } @Override - public boolean hasForeignData(){return true;} + public boolean onChildProfileHomeGoToChildRegister() { + return false; + } + + @Override + public boolean greyOutFormActionsIfInvalid() { + return true; + } @Override - public boolean showIconsForChildrenUnderTwoAndGirlsAgeNineToEleven(){ + public boolean checkExtraForDueInFamily() { + return true; + } + @Override + public boolean hideCaregiverAndFamilyHeadWhenOnlyOneAdult(){ return true; } @Override public boolean showsPhysicallyDisabledView() { return false; } + + @Override + public boolean vaccinesDefaultChecked() { return false; } + + @Override + public boolean checkDueStatusFromUpcomingServices() { + return true; + } } + diff --git a/opensrp-chw/src/lmh/java/org/smartregister/chw/custom_view/FamilyFloatingMenuFlv.java b/opensrp-chw/src/lmh/java/org/smartregister/chw/custom_view/FamilyFloatingMenuFlv.java new file mode 100644 index 0000000000..f4748195b4 --- /dev/null +++ b/opensrp-chw/src/lmh/java/org/smartregister/chw/custom_view/FamilyFloatingMenuFlv.java @@ -0,0 +1,11 @@ +package org.smartregister.chw.custom_view; + +import android.view.View; + +public class FamilyFloatingMenuFlv extends DefaultFamilyFloatingMenuFlv { + @Override + public void setCallLayoutVisibility(View view) { + view.setVisibility(View.GONE); + } + +} diff --git a/opensrp-chw/src/lmh/java/org/smartregister/chw/custom_view/NavigationMenuFlv.java b/opensrp-chw/src/lmh/java/org/smartregister/chw/custom_view/NavigationMenuFlv.java index 2615013bb8..b02357e8fa 100644 --- a/opensrp-chw/src/lmh/java/org/smartregister/chw/custom_view/NavigationMenuFlv.java +++ b/opensrp-chw/src/lmh/java/org/smartregister/chw/custom_view/NavigationMenuFlv.java @@ -1,6 +1,30 @@ package org.smartregister.chw.custom_view; +import android.app.Activity; +import android.graphics.Color; +import android.widget.Button; + +import androidx.appcompat.app.AlertDialog; + +import org.apache.commons.lang3.tuple.Pair; +import org.smartregister.chw.pinlogin.PinLoginUtil; + +import java.util.Arrays; +import java.util.List; +import java.util.Locale; + public class NavigationMenuFlv extends DefaultNavigationMenuFlv { + + @Override + public List> getSupportedLanguages() { + return Arrays.asList(Pair.of("English", Locale.ENGLISH)); + } + + @Override + public boolean hasMultipleLanguages() { + return false; + } + @Override public boolean hasCommunityResponders() { return false; @@ -20,4 +44,28 @@ public String childNavigationMenuCountString() { " and (SELECT is_closed FROM ec_family_member WHERE base_entity_id = ec_child.mother_entity_id ) = 1)) \n" + " and (((julianday('now') - julianday(ec_child.dob))/365.25) < 2 or (ec_child.gender = 'Female' and (((julianday('now') - julianday(ec_child.dob))/365.25) BETWEEN 9 AND 11)))\n"; } + + @Override + public AlertDialog doLogOutDialog(Activity activity) { + AlertDialog dialog = new AlertDialog.Builder(activity) + .setTitle("Log Out?") + .setMessage("You will be returned to the " + (PinLoginUtil.getPinLogger().enabledPin() ? "PIN entry screen." : "Log in screen.")) + .create(); + dialog.setOnShowListener(dialog1 -> { + Button positiveButton = ((AlertDialog) dialog1) + .getButton(AlertDialog.BUTTON_POSITIVE); + positiveButton.setTextColor(Color.RED); + + Button negativeButton = ((AlertDialog) dialog1) + .getButton(AlertDialog.BUTTON_NEGATIVE); + negativeButton.setTextColor(Color.GRAY); + }); + + return dialog; + } + + @Override + public boolean hasSyncStatusProgressBar() { + return false; + } } diff --git a/opensrp-chw/src/lmh/java/org/smartregister/chw/fragment/BaseHomeVisitImmunizationFragmentFlv.java b/opensrp-chw/src/lmh/java/org/smartregister/chw/fragment/BaseHomeVisitImmunizationFragmentFlv.java index f1a505d05d..b17431a979 100644 --- a/opensrp-chw/src/lmh/java/org/smartregister/chw/fragment/BaseHomeVisitImmunizationFragmentFlv.java +++ b/opensrp-chw/src/lmh/java/org/smartregister/chw/fragment/BaseHomeVisitImmunizationFragmentFlv.java @@ -2,9 +2,11 @@ import android.os.Bundle; import android.view.View; +import android.widget.DatePicker; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.annotation.VisibleForTesting; import org.smartregister.chw.anc.contract.BaseAncHomeVisitContract; import org.smartregister.chw.anc.domain.VaccineDisplay; @@ -13,6 +15,7 @@ import org.smartregister.chw.anc.util.NCUtils; import org.smartregister.util.DatePickerUtils; +import java.text.ParseException; import java.util.List; import java.util.Map; @@ -29,6 +32,16 @@ public static BaseHomeVisitImmunizationFragmentFlv getInstance(final BaseAncHome fragment.details = details; fragment.vaccinesDefaultChecked = defaultChecked; for (VaccineDisplay vaccineDisplay : vaccineDisplays) { + String name = NCUtils.removeSpaces(vaccineDisplay.getVaccineWrapper().getName()); + if (details != null && details.containsKey(name)) { + String value = NCUtils.getText(details.get(name)); + + try { + vaccineDisplay.setDateGiven(dateFormat.parse(value)); + } catch (ParseException e) { + e.printStackTrace(); + } + } fragment.vaccineDisplays.put(vaccineDisplay.getVaccineWrapper().getName(), vaccineDisplay); } @@ -42,7 +55,17 @@ public static BaseHomeVisitImmunizationFragmentFlv getInstance(final BaseAncHome @Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { - DatePickerUtils.themeDatePicker(singleDatePicker, new char[]{'d', 'm', 'y'}); + callDatePickerUtilsThemeDatePicker(singleDatePicker, new char[]{'d', 'm', 'y'}); super.onViewCreated(view, savedInstanceState); } + + @VisibleForTesting + void callDatePickerUtilsThemeDatePicker(DatePicker datePicker, char[] ymdOrder) { + DatePickerUtils.themeDatePicker(datePicker, ymdOrder); + } + + @Override + protected void setDatePickerTheme(DatePicker picker) { + callDatePickerUtilsThemeDatePicker(picker, new char[]{'d', 'm', 'y'}); + } } diff --git a/opensrp-chw/src/lmh/java/org/smartregister/chw/interactor/ChildHomeVisitInteractorFlv.java b/opensrp-chw/src/lmh/java/org/smartregister/chw/interactor/ChildHomeVisitInteractorFlv.java index 2d9a84ea4d..e713824ed9 100644 --- a/opensrp-chw/src/lmh/java/org/smartregister/chw/interactor/ChildHomeVisitInteractorFlv.java +++ b/opensrp-chw/src/lmh/java/org/smartregister/chw/interactor/ChildHomeVisitInteractorFlv.java @@ -15,11 +15,10 @@ public class ChildHomeVisitInteractorFlv extends DefaultChildHomeVisitInteractor protected int immunizationCeiling() { String gender = ChwChildDao.getChildGender(memberObject.getBaseEntityId()); - if(gender != null && gender.equalsIgnoreCase("Female")){ - if(memberObject.getAge() >= 9 && memberObject.getAge() <= 11) { + if (gender != null && gender.equalsIgnoreCase("Female")) { + if (memberObject.getAge() >= 9 && memberObject.getAge() <= 11) { return 132; - } - else { + } else { return 60; } } @@ -39,4 +38,8 @@ protected void bindEvents(Map serviceWrapperMap) throws } } + protected int vaccineCardCeiling() { + return 60; + } + } \ No newline at end of file diff --git a/opensrp-chw/src/lmh/java/org/smartregister/chw/model/NavigationModelFlv.java b/opensrp-chw/src/lmh/java/org/smartregister/chw/model/NavigationModelFlv.java index 13618faf6d..2502ff9aa2 100644 --- a/opensrp-chw/src/lmh/java/org/smartregister/chw/model/NavigationModelFlv.java +++ b/opensrp-chw/src/lmh/java/org/smartregister/chw/model/NavigationModelFlv.java @@ -9,14 +9,16 @@ public class NavigationModelFlv extends DefaultNavigationModelFlv { - private List navigationOptions = new ArrayList<>(); + private final List navigationOptions = new ArrayList<>(); @Override public List getNavigationItems() { if (navigationOptions.size() == 0) { - navigationOptions.add(new NavigationOption(R.mipmap.sidemenu_families, R.mipmap.sidemenu_families_active, R.string.menu_all_families, Constants.DrawerMenu.ALL_FAMILIES, 0)); - navigationOptions.add(new NavigationOption(R.mipmap.sidemenu_children, R.mipmap.sidemenu_children_active, R.string.menu_child_clients, Constants.DrawerMenu.CHILD_CLIENTS, 0)); + navigationOptions.add(new NavigationOption(R.mipmap.sidemenu_families, R.mipmap.sidemenu_families, R.string.menu_all_families, Constants.DrawerMenu.ALL_FAMILIES, 0)); + navigationOptions.add(new NavigationOption(R.drawable.ic_add_new_family_white, R.drawable.ic_add_new_family_white, R.string.menu_add_new_family, Constants.DrawerMenu.ADD_NEW_FAMILY, -1)); + navigationOptions.add(new NavigationOption(R.mipmap.sidemenu_children, R.mipmap.sidemenu_children, R.string.menu_child_clients, Constants.DrawerMenu.CHILD_CLIENTS, 0)); + navigationOptions.add(new NavigationOption(R.drawable.ic_reports, R.drawable.ic_reports, R.string.reports_dashboard, Constants.DrawerMenu.REPORTS, -1)); } return navigationOptions; diff --git a/opensrp-chw/src/lmh/java/org/smartregister/chw/repository/ChwRepositoryFlv.java b/opensrp-chw/src/lmh/java/org/smartregister/chw/repository/ChwRepositoryFlv.java index 210cd5ccf0..23a4e227ab 100644 --- a/opensrp-chw/src/lmh/java/org/smartregister/chw/repository/ChwRepositoryFlv.java +++ b/opensrp-chw/src/lmh/java/org/smartregister/chw/repository/ChwRepositoryFlv.java @@ -44,6 +44,9 @@ public static void onUpgrade(Context context, SQLiteDatabase db, int oldVersion, case 6: upgradeToVersion6(db); break; + case 7: + upgradeToVersion7(db); + break; default: break; } @@ -134,4 +137,13 @@ private static void upgradeToVersion6(SQLiteDatabase db) { Timber.e(e, "upgradeToVersion6"); } } + + private static void upgradeToVersion7(SQLiteDatabase db) { + try { + db.execSQL(VaccineRepository.UPDATE_TABLE_ADD_IS_VOIDED_COL); + db.execSQL(VaccineRepository.UPDATE_TABLE_ADD_IS_VOIDED_COL_INDEX); + } catch (Exception e) { + Timber.e(e, "upgradeToVersion7"); + } + } } \ No newline at end of file diff --git a/opensrp-chw/src/lmh/java/org/smartregister/chw/task/ChildHomeVisitSchedulerFlv.java b/opensrp-chw/src/lmh/java/org/smartregister/chw/task/ChildHomeVisitSchedulerFlv.java index ee2db9ffdc..7ec2f015f9 100644 --- a/opensrp-chw/src/lmh/java/org/smartregister/chw/task/ChildHomeVisitSchedulerFlv.java +++ b/opensrp-chw/src/lmh/java/org/smartregister/chw/task/ChildHomeVisitSchedulerFlv.java @@ -1,5 +1,7 @@ package org.smartregister.chw.task; +import androidx.annotation.VisibleForTesting; + import org.smartregister.chw.application.ChwApplication; import org.smartregister.chw.core.application.CoreChwApplication; import org.smartregister.chw.core.contract.ScheduleTask; @@ -17,9 +19,9 @@ import java.util.List; public class ChildHomeVisitSchedulerFlv extends DefaultChildHomeVisitSchedulerFlv { - @Override - public List generateTasks(String baseEntityID, String eventName, Date eventDate, BaseScheduleTask baseScheduleTask) { - // recompute the home visit task for this child + + @VisibleForTesting() + HomeAlertRule getAlertRule(final String baseEntityID){ ChildHomeVisit childHomeVisit = ChildUtils.getLastHomeVisit(Constants.TABLE_NAME.CHILD, baseEntityID); String yearOfBirth = PersonDao.getDob(baseEntityID); @@ -27,6 +29,14 @@ public List generateTasks(String baseEntityID, String eventName, D ChwApplication.getInstance().getApplicationContext(), yearOfBirth, childHomeVisit.getLastHomeVisitDate(), childHomeVisit.getVisitNotDoneDate(), childHomeVisit.getDateCreated()); CoreChwApplication.getInstance().getRulesEngineHelper().getButtonAlertStatus(alertRule, CoreConstants.RULE_FILE.HOME_VISIT); + return alertRule; + } + + @Override + public List generateTasks(String baseEntityID, String eventName, Date eventDate, BaseScheduleTask baseScheduleTask) { + // recompute the home visit task for this child + HomeAlertRule alertRule = getAlertRule(baseEntityID); + // Check If any task are due for that child if (ChwChildDao.hasDueVaccines(baseEntityID)) { baseScheduleTask.setScheduleDueDate(alertRule.getDueDate()); diff --git a/opensrp-chw/src/lmh/res/drawable/ic_add_new_family_white.xml b/opensrp-chw/src/lmh/res/drawable/ic_add_new_family_white.xml new file mode 100644 index 0000000000..962847b009 --- /dev/null +++ b/opensrp-chw/src/lmh/res/drawable/ic_add_new_family_white.xml @@ -0,0 +1,9 @@ + + + diff --git a/opensrp-chw/src/lmh/res/drawable/ic_navigate_next_grey_24dp.xml b/opensrp-chw/src/lmh/res/drawable/ic_navigate_next_grey_24dp.xml new file mode 100644 index 0000000000..c809dbee8f --- /dev/null +++ b/opensrp-chw/src/lmh/res/drawable/ic_navigate_next_grey_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/opensrp-chw/src/lmh/res/drawable/ic_reports.xml b/opensrp-chw/src/lmh/res/drawable/ic_reports.xml new file mode 100644 index 0000000000..762af7233b --- /dev/null +++ b/opensrp-chw/src/lmh/res/drawable/ic_reports.xml @@ -0,0 +1,14 @@ + + + + diff --git a/opensrp-chw/src/lmh/res/drawable/ic_transfer_data_receive.xml b/opensrp-chw/src/lmh/res/drawable/ic_transfer_data_receive.xml new file mode 100644 index 0000000000..e1a5381c8c --- /dev/null +++ b/opensrp-chw/src/lmh/res/drawable/ic_transfer_data_receive.xml @@ -0,0 +1,10 @@ + + + diff --git a/opensrp-chw/src/lmh/res/drawable/ic_transfer_data_send.xml b/opensrp-chw/src/lmh/res/drawable/ic_transfer_data_send.xml new file mode 100644 index 0000000000..558afc034d --- /dev/null +++ b/opensrp-chw/src/lmh/res/drawable/ic_transfer_data_send.xml @@ -0,0 +1,10 @@ + + + diff --git a/opensrp-chw/src/lmh/res/drawable/p2p_card_text_color_selector.xml b/opensrp-chw/src/lmh/res/drawable/p2p_card_text_color_selector.xml new file mode 100644 index 0000000000..c58a8cb97e --- /dev/null +++ b/opensrp-chw/src/lmh/res/drawable/p2p_card_text_color_selector.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/opensrp-chw/src/lmh/res/layout-w900dp/navigation_view.xml b/opensrp-chw/src/lmh/res/layout-w900dp/navigation_view.xml new file mode 100644 index 0000000000..5249e0b3c8 --- /dev/null +++ b/opensrp-chw/src/lmh/res/layout-w900dp/navigation_view.xml @@ -0,0 +1,397 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/opensrp-chw/src/lmh/res/layout/fragment_base_anc_home_visit.xml b/opensrp-chw/src/lmh/res/layout/fragment_base_anc_home_visit.xml new file mode 100644 index 0000000000..795be4aed7 --- /dev/null +++ b/opensrp-chw/src/lmh/res/layout/fragment_base_anc_home_visit.xml @@ -0,0 +1,215 @@ + + + + + + + + + + + + + + +