Skip to content

Commit

Permalink
Merge branch 'master' into geo-wiget
Browse files Browse the repository at this point in the history
  • Loading branch information
ellykits committed Oct 8, 2020
2 parents bf72046 + 7f89d44 commit 320ee72
Show file tree
Hide file tree
Showing 31 changed files with 529 additions and 138 deletions.
24 changes: 17 additions & 7 deletions opensrp-chw/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@ buildscript {
}
}

allprojects {
repositories {
maven { url 'https://maven.google.com' }
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
maven { url "http://dl.bintray.com/ona/kujaku" }
maven { url 'https://maven.fabric.io/public' }
mavenLocal()
}
}

apply plugin: 'com.android.application'
apply plugin: 'jacoco'
apply plugin: 'com.github.kt3k.coveralls'
Expand Down Expand Up @@ -266,7 +276,7 @@ android {
dimension = 'baseDimension'
applicationIdSuffix ".lmh"
versionCode 1
versionName "0.0.3"
versionName "0.0.5-rc1"
buildConfigField "String", 'opensrp_url', '"https://lmh-liberia.smartregister.org/opensrp/"'
buildConfigField "String", 'guidebooks_url', '"https://opensrp.s3.amazonaws.com/media/lmh/"'
buildConfigField "String", 'opensrp_url_debug', '"https://lmh-stage.smartregister.org/opensrp/"'
Expand All @@ -275,7 +285,7 @@ android {
buildConfigField "String[]", "ALLOWED_LOCATION_LEVELS_DEBUG", '{"Clinic" , "CHSS" , "CHA"}'
buildConfigField "String", 'DEFAULT_LOCATION', '"Village"'
buildConfigField "String", 'DEFAULT_LOCATION_DEBUG', '"CHA"'
buildConfigField "int", "DATABASE_VERSION", '4'
buildConfigField "int", "DATABASE_VERSION", '5'
}
}

Expand All @@ -285,7 +295,7 @@ android {
}

dependencies {
implementation('org.smartregister:opensrp-client-chw-core:1.5.2-SNAPSHOT@aar') {
implementation('org.smartregister:opensrp-client-chw-core:1.5.7-SNAPSHOT@aar') {
transitive = true
exclude group: 'com.android.support', module: 'appcompat-v7'
exclude group: 'androidx.legacy', module: 'legacy-support-v4'
Expand All @@ -296,12 +306,12 @@ dependencies {
}

//Do not upgrade to 1.1.0 due to compatibility issues
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
//Do not upgrade to 1.1.0 due to compatibility issues
implementation 'androidx.recyclerview:recyclerview:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
implementation 'com.android.support:multidex:1.0.3'
//Do not upgrade to 24.jre-1 due to compatibility issues
implementation 'com.google.guava:guava:20.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,8 @@ public Intent getStockReportIntent(Activity activity) {
public Intent getServiceReportIntent(Activity activity) {
return new Intent(activity, HIA2ReportsActivity.class);
}

@Override
public String childNavigationMenuCountString() {return null;
}
}
11 changes: 8 additions & 3 deletions opensrp-chw/src/lmh/assets/rule/home-visit-rules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,16 @@ condition: "homeAlertRule.isVisitWithinThisMonth()"
actions:
- "homeAlertRule.buttonStatus = 'VISIT_THIS_MONTH'"
---
name: overdue
description: previous month not visited
priority: 2
condition: "homeAlertRule.evaluateIfOverdueWithinMonth(1)"
actions:
- "homeAlertRule.buttonStatus = 'OVERDUE'"
---
name: due
description: due first day of month and same month
priority: 3
condition: "homeAlertRule.isLmhChildDueWithinMonth()"
condition: "homeAlertRule.isDueWithinMonth()"
actions:
- "homeAlertRule.buttonStatus = 'DUE'"


Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,9 @@ public boolean dueVaccinesFilterInChildRegister() {
public boolean showAllChildServicesDueIncludingCurrentChild(){
return false;
}

@Override
public boolean saveOnSubmission() {
return true;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,31 @@
package org.smartregister.chw.custom_view;

public class NavigationMenuFlv extends DefaultNavigationMenuFlv {
@Override
public boolean hasCommunityResponders() {
return false;
}

@Override
public String childNavigationMenuCountString() {
return "Select count(*)\n" +
" FROM ec_child\n" +
" LEFT JOIN ec_family ON ec_child.relational_id = ec_family.id COLLATE NOCASE \n" +
" LEFT JOIN ec_family_member ON ec_family_member.base_entity_id = ec_family.primary_caregiver COLLATE NOCASE \n" +
" LEFT JOIN (select base_entity_id , max(visit_date) visit_date from visits GROUP by base_entity_id) VISIT_SUMMARY ON VISIT_SUMMARY.base_entity_id = ec_child.base_entity_id \n" +
" WHERE ec_child.date_removed is null\n" +
" AND (( ifnull(ec_child.entry_point,'') <> 'PNC' ) or (ifnull(ec_child.entry_point,'') = 'PNC' and ( date(ec_child.dob, '+28 days') <= date() \n" +
" and ((SELECT is_closed FROM ec_family_member WHERE base_entity_id = ec_child.mother_entity_id ) = 0))) \n" +
" or (ifnull(ec_child.entry_point,'') = 'PNC' \n" +
" and (SELECT is_closed FROM ec_family_member WHERE base_entity_id = ec_child.mother_entity_id ) = 1)) \n" +
" and CASE WHEN ec_child.gender = 'Male' \n" +
" THEN (\n" +
" (( julianday('now') - julianday(ec_child.dob))/365.25) < 2\n" +
" )\n" +
" WHEN ec_child.gender = 'Female' \n" +
" THEN (\n" +
" ((( julianday('now') - julianday(ec_child.dob))/365.25) < 2) OR (((julianday('now') - julianday(ec_child.dob))/365.25) BETWEEN 9 AND 11)\n" +
" ) END";
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import net.sqlcipher.database.SQLiteDatabase;

import org.smartregister.chw.anc.repository.VisitRepository;
import org.smartregister.chw.util.RepositoryUtils;
import org.smartregister.domain.db.Column;
import org.smartregister.immunization.repository.RecurringServiceRecordRepository;
Expand Down Expand Up @@ -36,6 +37,9 @@ public static void onUpgrade(Context context, SQLiteDatabase db, int oldVersion,
case 4:
upgradeToVersion4(db);
break;
case 5:
upgradeToVersion5(db);
break;
default:
break;
}
Expand Down Expand Up @@ -106,7 +110,15 @@ private static void upgradeToVersion4(SQLiteDatabase db) {
EventClientRepository.createTable(db, EventClientRepository.Table.foreignEvent, EventClientRepository.event_column.values());
EventClientRepository.createTable(db, EventClientRepository.Table.foreignClient, EventClientRepository.client_column.values());
} catch (Exception e) {
Timber.e(e, "upgradeToVersion3");
Timber.e(e, "upgradeToVersion4");
}
}

private static void upgradeToVersion5(SQLiteDatabase db) {
try {
db.execSQL(VisitRepository.ADD_VISIT_GROUP_COLUMN);
} catch (Exception e) {
Timber.e(e, "upgradeToVersion5");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import org.smartregister.chw.core.utils.CoreConstants;
import org.smartregister.chw.dao.ChildDao;
import org.smartregister.chw.dao.PersonDao;
import org.smartregister.chw.rules.LmhHomeAlertRule;
import org.smartregister.chw.util.ChildUtils;
import org.smartregister.chw.util.Constants;

Expand All @@ -24,7 +23,7 @@ public List<ScheduleTask> generateTasks(String baseEntityID, String eventName, D
ChildHomeVisit childHomeVisit = ChildUtils.getLastHomeVisit(Constants.TABLE_NAME.CHILD, baseEntityID);
String yearOfBirth = PersonDao.getDob(baseEntityID);

LmhHomeAlertRule alertRule = new LmhHomeAlertRule(
HomeAlertRule alertRule = new HomeAlertRule(
ChwApplication.getInstance().getApplicationContext(), yearOfBirth, childHomeVisit.getLastHomeVisitDate(), childHomeVisit.getVisitNotDoneDate(), childHomeVisit.getDateCreated());
CoreChwApplication.getInstance().getRulesEngineHelper().getButtonAlertStatus(alertRule, CoreConstants.RULE_FILE.HOME_VISIT);

Expand Down
2 changes: 2 additions & 0 deletions opensrp-chw/src/lmh/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@
<string name="ipv">Polio (IPV)</string>
<string name="mcv_1">Measles (MCV 1)</string>
<string name="mcv_2">Measles (MCV 2)</string>
<string name="hpv_1">HPV 1</string>
<string name="hpv_2">HPV 2</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ protected void onCreation() {
}
notificationAndReferralRecyclerView.setAdapter(notificationListAdapter);
notificationListAdapter.setOnClickListener(this);
// setVaccineHistoryView(lastVisitDay);
// setVaccineHistoryView(lastVisitDay);
}

@Override
public void setUpToolbar() {
updateToolbarTitle(this, org.smartregister.chw.core.R.id.toolbar_title, memberObject.getFirstName());
updateToolbarTitle(this, R.id.toolbar_title, memberObject.getFirstName());

}

Expand All @@ -90,13 +90,14 @@ public void onClick(View view) {
int i = view.getId();
if (i == R.id.last_visit_row) {
openMedicalHistoryScreen();
}
else if(i== R.id.vaccine_history){
} else if (i == R.id.vaccine_history) {
openMedicalHistoryScreen();
}
else if (i == R.id.most_due_overdue_row) {
} else if (i == R.id.most_due_overdue_row) {
openUpcomingServicePage();
} else if(i == R.id.view_due_today){
openUpcomingServicePage();
} else if (i == R.id.textview_record_visit || i == R.id.record_visit_done_bar) {
}
else if (i == R.id.textview_record_visit || i == R.id.record_visit_done_bar) {
openVisitHomeScreen(false);
} else if (i == R.id.family_has_row) {
openFamilyDueTab();
Expand All @@ -122,7 +123,6 @@ protected void initializePresenter() {

presenter = new ChildProfilePresenter(this, new CoreChildProfileModel(familyName), childBaseEntityId);
}

@Override
protected void setupViews() {
super.setupViews();
Expand Down Expand Up @@ -264,8 +264,8 @@ public void setServiceNameUpcoming(String serviceName, String dueDate) {
@Override
public void setLastVisitRowView(String days) {
lastVisitDay = days;
flavor.setLastVisitRowView(lastVisitDay,layoutLastVisitRow, viewLastVisitRow, textViewLastVisit, this);
flavor.setVaccineHistoryView(lastVisitDay,layoutVaccineHistoryRow, viewVaccineHistoryRow, this);
flavor.setLastVisitRowView(lastVisitDay, layoutLastVisitRow, viewLastVisitRow, textViewLastVisit, this);
flavor.setVaccineHistoryView(lastVisitDay, layoutVaccineHistoryRow, viewVaccineHistoryRow, this);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
import android.content.Intent;
import android.view.View;

import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;

import org.apache.commons.lang3.time.DateUtils;
import org.joda.time.LocalDate;
import org.smartregister.chw.R;
import org.smartregister.chw.anc.adapter.BaseUpcomingServiceAdapter;
import org.smartregister.chw.anc.domain.MemberObject;
Expand All @@ -17,13 +18,14 @@
import org.smartregister.view.customcontrols.CustomFontTextView;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class UpcomingServicesActivity extends CoreUpcomingServicesActivity {

private RecyclerView dueTodayRV;
private CustomFontTextView todayServicesTV;
private RecyclerView upcomingServicesRV;
private CustomFontTextView upcomingServiceTv;

public static void startMe(Activity activity, MemberObject memberObject) {
Intent intent = new Intent(activity, UpcomingServicesActivity.class);
Expand All @@ -34,45 +36,74 @@ public static void startMe(Activity activity, MemberObject memberObject) {
@Override
public void setUpView() {
super.setUpView();

dueTodayRV = findViewById(R.id.today_services_recyclerView);
todayServicesTV = findViewById(R.id.today_services);
upcomingServicesRV = findViewById(R.id.recyclerView);
upcomingServiceTv = findViewById(R.id.upcoming_services);
}

@Override
public void refreshServices(List<BaseUpcomingService> serviceList) {
if (ChwApplication.getApplicationFlavor().splitUpcomingServicesView()) {
filterAndPopulateDueTodayServices(serviceList);
} else {
setUpcomingServiceViews();
super.refreshServices(serviceList);
}

super.refreshServices(serviceList);
}

protected void filterAndPopulateDueTodayServices(List<BaseUpcomingService> serviceList) {
List<BaseUpcomingService> dueNowServiceList = filterDueTodayServices(serviceList);
private List<BaseUpcomingService> deepCopy(@Nullable List<BaseUpcomingService> serviceList) {
if (serviceList == null) return null;

if (!dueNowServiceList.isEmpty()) {
updateUi();
serviceList.removeAll(dueNowServiceList);
RecyclerView.Adapter dueTodayAdapter = new BaseUpcomingServiceAdapter(this, dueNowServiceList);
dueTodayRV.setAdapter(dueTodayAdapter);
List<BaseUpcomingService> result = new ArrayList<>();

for (BaseUpcomingService service : serviceList) {
BaseUpcomingService copy = new BaseUpcomingService();
copy.setServiceName(service.getServiceName());
copy.setServiceDate(service.getOverDueDate());
copy.setExpiryDate(service.getExpiryDate());
copy.setOverDueDate(service.getOverDueDate());

copy.setUpcomingServiceList(deepCopy(service.getUpcomingServiceList()));
result.add(copy);
}
}

private void updateUi() {
todayServicesTV.setVisibility(View.VISIBLE);
dueTodayRV.setVisibility(View.VISIBLE);
return result;
}

protected List<BaseUpcomingService> filterDueTodayServices(List<BaseUpcomingService> serviceList) {
Date date = new Date();
private void filterAndPopulateDueTodayServices(List<BaseUpcomingService> serviceList) {
List<BaseUpcomingService> eligibleServiceList = new ArrayList<>();
for (BaseUpcomingService filterService : deepCopy(serviceList)) {
List<BaseUpcomingService> eligibleVaccines = new ArrayList<>();
for (BaseUpcomingService vaccine : filterService.getUpcomingServiceList()) {
if (vaccine.getExpiryDate() == null || new LocalDate(vaccine.getExpiryDate()).isAfter(new LocalDate())) {
eligibleVaccines.add(vaccine);
}
}

filterService.setUpcomingServiceList(eligibleVaccines);
if (filterService.getUpcomingServiceList().size() > 0)
eligibleServiceList.add(filterService);
}

List<BaseUpcomingService> dueNowServiceList = new ArrayList<>();
for (BaseUpcomingService service : serviceList) {
if (service.getServiceDate() != null && DateUtils.isSameDay(date, service.getServiceDate())) {
for (BaseUpcomingService service : eligibleServiceList) {
if (service.getServiceDate() != null)
dueNowServiceList.add(service);
}
}
return dueNowServiceList;


if (!dueNowServiceList.isEmpty()) {
todayServicesTV.setVisibility(View.VISIBLE);
dueTodayRV.setVisibility(View.VISIBLE);
RecyclerView.Adapter<?> dueTodayAdapter = new BaseUpcomingServiceAdapter(this, dueNowServiceList);
dueTodayRV.setAdapter(dueTodayAdapter);
}
}

protected void setUpcomingServiceViews() {
upcomingServicesRV.setVisibility(View.VISIBLE);
upcomingServiceTv.setVisibility(View.VISIBLE);
}

}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.smartregister.chw.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand All @@ -15,15 +16,16 @@
import java.util.List;

public class EligibleChildrenAdapter extends ListableAdapter<EligibleChild, ListableViewHolder<EligibleChild>> {

public EligibleChildrenAdapter(List<EligibleChild> items, ListContract.View<EligibleChild> view) {
private Context context;
public EligibleChildrenAdapter(List<EligibleChild> items, ListContract.View<EligibleChild> view, Context context) {
super(items, view);
this.context = context;
}

@NonNull
@Override
public ListableViewHolder<EligibleChild> onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.eligible_children_report_item, parent, false);
return new EligibleChildrenViewHolder(view);
return new EligibleChildrenViewHolder(view, context);
}
}
Loading

0 comments on commit 320ee72

Please sign in to comment.