Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/Testing_Tuesday' into Testing_Tu…
Browse files Browse the repository at this point in the history
…esday
  • Loading branch information
Mstjamush committed Dec 4, 2020
2 parents 2e6a9ed + 6513b3d commit 3b20891
Show file tree
Hide file tree
Showing 19 changed files with 285 additions and 62 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION_NAME=2.0.3-SNAPSHOT
VERSION_NAME=2.0.6-SNAPSHOT
VERSION_CODE=1
GROUP=org.smartregister
POM_SETTING_DESCRIPTION=OpenSRP Client Chw Core Library
Expand Down
16 changes: 7 additions & 9 deletions opensrp-chw-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -149,15 +149,15 @@ 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
exclude group: 'org.smartregister', module: 'opensrp-client-core'
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'
Expand Down Expand Up @@ -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'
Expand All @@ -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'
Expand Down Expand Up @@ -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'
Expand All @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
*/
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ public abstract class DefaultChildMedicalHistoryActivityFlv implements CoreChild
protected List<Visit> visits;
protected Map<String, List<Visit>> visitMap = new LinkedHashMap<>();
protected Map<String, List<Vaccine>> vaccineMap = new LinkedHashMap<>();
private Context context;
protected Context context;
private LinearLayout parentView;
private 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) {
Expand Down Expand Up @@ -271,7 +271,7 @@ private VisitDetailsFormatter getDewormingFormatter() {
};
}

private VisitDetailsFormatter getDieataryFormatter() {
protected VisitDetailsFormatter getDieataryFormatter() {
return (title, details, visitDate) -> {
String diet_diversity = NCUtils.getText(details);
String value = "";
Expand Down Expand Up @@ -423,7 +423,7 @@ private void medicalHistory(List<MedicalHistory> medicalHistories, String type,
}
}

private interface VisitDetailsFormatter {
protected interface VisitDetailsFormatter {
String format(String title, List<VisitDetail> details, Date visitDate);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<Task> getToBeCompletedReferralTasks(){
public static List<Task> 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" +
Expand All @@ -34,13 +36,17 @@ private static AbstractDao.DataMap<Task> 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"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> 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;
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);

Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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<>();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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})
Expand Down
Loading

0 comments on commit 3b20891

Please sign in to comment.