Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Malaria profile with more than one visit #60

Merged
merged 25 commits into from
Oct 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
c811fda
add anc buttons
whoisladleo Sep 13, 2019
d5b1f19
version_name
whoisladleo Sep 13, 2019
16bbaee
Merge branch 'master' into malaria_profile_with_more_than_one_visit
whoisladleo Sep 13, 2019
3b58664
Merge branch 'master' into malaria_profile_with_more_than_one_visit
whoisladleo Sep 16, 2019
8b4b39a
add undo visit
whoisladleo Sep 20, 2019
a342dec
domain testing
whoisladleo Sep 20, 2019
f870a09
fix relationid error
whoisladleo Sep 20, 2019
c768f46
show profile image if exists
whoisladleo Sep 20, 2019
4614a20
Merge remote-tracking branch 'origin/malaria_profile_with_more_than_o…
whoisladleo Sep 23, 2019
c8059b8
test test date
whoisladleo Sep 23, 2019
ea0bd3d
trigger codacy
whoisladleo Oct 3, 2019
9f914c0
loose additional setters
whoisladleo Oct 9, 2019
37ead70
test malaria register fragment
whoisladleo Oct 9, 2019
8e750e1
clean ups
whoisladleo Oct 9, 2019
7681cd7
clean ups
whoisladleo Oct 9, 2019
f0327bb
Merge remote-tracking branch 'origin/malaria_profile_with_more_than_o…
whoisladleo Oct 9, 2019
66b88c8
test BaseMalariaRegisterFragmentPresenter
whoisladleo Oct 9, 2019
ee37882
test BaseMalariaRegisterPresenter
whoisladleo Oct 10, 2019
de067db
test BaseMalariaRegisterPresenter
whoisladleo Oct 10, 2019
50f427a
Merge remote-tracking branch 'origin/malaria_profile_with_more_than_o…
whoisladleo Oct 10, 2019
84fa909
fix build
whoisladleo Oct 10, 2019
0a8795e
Update BaseMalariaRegisterPresenterTest.java
whoisladleo Oct 10, 2019
6422877
more tests for BaseMalariaRegisterPresenter
whoisladleo Oct 10, 2019
3a5d5df
Merge remote-tracking branch 'origin/malaria_profile_with_more_than_o…
whoisladleo Oct 10, 2019
ff4c5fb
trigger coveralls
whoisladleo Oct 11, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
import org.smartregister.chw.malaria.presenter.BaseMalariaProfilePresenter;
import org.smartregister.chw.malaria.util.Constants;
import org.smartregister.chw.malaria.util.Util;
import org.smartregister.commonregistry.CommonPersonObjectClient;
import org.smartregister.domain.AlertStatus;
import org.smartregister.helper.ImageRenderHelper;
import org.smartregister.malaria.R;
import org.smartregister.view.activity.BaseProfileActivity;

Expand All @@ -37,10 +39,14 @@
import java.util.Date;
import java.util.Locale;

import de.hdodenhof.circleimageview.CircleImageView;


public class BaseMalariaProfileActivity extends BaseProfileActivity implements MalariaProfileContract.View, MalariaProfileContract.InteractorCallBack {
protected MemberObject MEMBER_OBJECT;
protected MalariaProfileContract.Presenter profilePresenter;
protected CommonPersonObjectClient client;
protected CircleImageView imageView;
protected TextView textViewName;
protected TextView textViewGender;
protected TextView textViewLocation;
Expand All @@ -54,6 +60,8 @@ public class BaseMalariaProfileActivity extends BaseProfileActivity implements M
protected RelativeLayout rlLastVisit;
protected RelativeLayout rlUpcomingServices;
protected RelativeLayout rlFamilyServicesDue;
protected RelativeLayout visitStatus;
protected TextView textViewUndo;
private TextView tvUpComingServices;
private TextView tvFamilyStatus;
private SimpleDateFormat dateFormat = new SimpleDateFormat("dd MMM", Locale.getDefault());
Expand Down Expand Up @@ -106,6 +114,8 @@ protected void onCreation() {

progressBar = findViewById(R.id.progress_bar);

visitStatus = findViewById(R.id.record_visit_status_bar);

findViewById(R.id.rlLastVisit).setOnClickListener(this);
findViewById(R.id.rlUpcomingServices).setOnClickListener(this);
findViewById(R.id.rlFamilyServicesDue).setOnClickListener(this);
Expand All @@ -119,7 +129,14 @@ protected void onCreation() {
textViewAncVisitNotDone = findViewById(R.id.textview_anc_visit_not_done);
textViewAncVisitNotDone.setOnClickListener(this);

textViewUndo = findViewById(R.id.textview_undo);
textViewUndo.setOnClickListener(this);

imageView = findViewById(R.id.imageview_profile);
imageRenderHelper = new ImageRenderHelper(this);

MEMBER_OBJECT = (MemberObject) getIntent().getSerializableExtra(Constants.MALARIA_MEMBER_OBJECT.MEMBER_OBJECT);
client = (CommonPersonObjectClient) getIntent().getSerializableExtra("CLIENT");

initializePresenter();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ public void fillProfileData(MemberObject memberObject) {

@Override
public void recordMalariaButton(int days_from_malaria_test_date) {
if (getView() == null)
if (getView() == null) {
return;
}

if (days_from_malaria_test_date < 7 || days_from_malaria_test_date > 14) {
getView().hideView();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class BaseMalariaRegisterPresenter implements MalariaRegisterContract.Pre
public static final String TAG = BaseMalariaRegisterPresenter.class.getName();

protected WeakReference<MalariaRegisterContract.View> viewReference;
protected MalariaRegisterContract.Interactor interactor;
private MalariaRegisterContract.Interactor interactor;
protected MalariaRegisterContract.Model model;

public BaseMalariaRegisterPresenter(MalariaRegisterContract.View view, MalariaRegisterContract.Model model, MalariaRegisterContract.Interactor interactor) {
Expand Down
8 changes: 8 additions & 0 deletions opensrp-chw-malaria/src/main/res/drawable/border.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="30dp" />
<stroke
android:width="1dp"
android:color="#CCCCCC" />
</shape>
96 changes: 71 additions & 25 deletions opensrp-chw-malaria/src/main/res/layout/view_record_malaria.xml
Original file line number Diff line number Diff line change
@@ -1,35 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:id="@+id/record_malaria"
android:orientation="horizontal"
android:paddingTop="10dp">
android:id="@+id/record_malaria"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:orientation="vertical"
android:paddingTop="10dp">

<LinearLayout
android:id="@+id/record_malaria_bar"
android:layout_width="match_parent"
android:id="@+id/record_malaria_bar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="10dp"
android:padding="10dp"
android:visibility="visible">

<org.smartregister.view.customcontrols.CustomFontTextView
android:id="@+id/textview_record_anc"
style="@style/CustomFontTextViewStyle.ListView.Normal.MultipleLines"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/record_btn_selector"
android:gravity="center_horizontal"
android:paddingLeft="30dp"
android:paddingTop="10dp"
android:paddingRight="30dp"
android:paddingBottom="10dp"
style="@style/CustomFontTextViewStyle.ListView.Normal.MultipleLines"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:layout_marginBottom="10dp"
android:background="@drawable/record_btn_selector"
android:gravity="center_horizontal"
android:paddingLeft="30dp"
android:paddingTop="10dp"
android:paddingRight="30dp"
android:paddingBottom="10dp"
android:text="@string/record_anc"
android:textColor="@color/white" />
android:textColor="@color/white" />

<org.smartregister.view.customcontrols.CustomFontTextView
android:id="@+id/textview_anc_visit_not_done"
Expand All @@ -40,12 +41,57 @@
android:layout_marginRight="30dp"
android:layout_marginBottom="10dp"
android:gravity="center_horizontal"
android:background="@drawable/border"
android:paddingLeft="30dp"
android:paddingTop="10dp"
android:paddingRight="30dp"
android:paddingBottom="10dp"
android:text="@string/record_anc_visit_not_done"
android:textColor="@color/grey" />
android:textColor="@color/grey"
android:visibility="visible" />


<RelativeLayout
android:id="@+id/record_visit_status_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:padding="10dp"
android:visibility="gone">

<ImageView
android:id="@+id/tick_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginEnd="10dp"
android:src="@drawable/childrow_upcoming" />


<org.smartregister.view.customcontrols.CustomFontTextView
android:id="@+id/textview_not_visit_this_month"
style="@style/CustomFontTextViewStyle.ListView.Normal.MultipleLines"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toStartOf="@+id/textview_undo"
android:layout_toEndOf="@+id/tick_image"
android:padding="10dp"
android:text="@string/not_visiting_this_month"
android:textColor="@color/black" />

<org.smartregister.view.customcontrols.CustomFontTextView
android:id="@+id/textview_undo"
style="@style/CustomFontTextViewStyle.ListView.Normal.Bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:padding="10dp"
android:text="@string/undo"
android:textColor="@color/primary" />

</RelativeLayout>


<org.smartregister.view.customcontrols.CustomFontTextView
android:id="@+id/textview_record_malaria"
Expand All @@ -67,9 +113,9 @@
</LinearLayout>

<View
android:id="@+id/view_record"
android:layout_width="match_parent"
android:layout_height="1px"
android:layout_marginTop="5dp"
android:background="@color/light_grey" />
android:id="@+id/view_record"
android:layout_width="match_parent"
android:layout_height="1px"
android:layout_marginTop="5dp"
android:background="@color/light_grey" />
</LinearLayout>
2 changes: 2 additions & 0 deletions opensrp-chw-malaria/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,7 @@
<string name="call">Call</string>
<string name="record_anc">Record ANC visit</string>
<string name="record_anc_visit_not_done">ANC visit not done</string>
<string name="not_visiting_this_month">Not visiting this month</string>
<string name="undo">UNDO</string>

</resources>
Original file line number Diff line number Diff line change
@@ -1,27 +1,16 @@
package org.smartregister.activity;

import android.graphics.Color;
import android.view.View;

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.mockito.Spy;
import org.smartregister.chw.malaria.activity.BaseMalariaProfileActivity;

public class BaseMalariaProfileActivityTest {
@Mock
protected BaseMalariaProfileActivity baseMalariaProfileActivity;

@Spy
protected BaseMalariaProfileActivity spy;

@Mock
protected View view;

@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package org.smartregister.model;

public class BaseMalariaRegisterFragmentModelTest {
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,10 @@ public void malariaTestDatePeriodGreaterThanTen() {
profilePresenter.recordMalariaButton(14);
verify(view).setOverDueColor();
}
}

@Test
public void refreshProfileBottom() {
profilePresenter.refreshProfileBottom();
verify(interactor).refreshProfileInfo(memberObject, profilePresenter.getView());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,17 @@
import org.mockito.MockitoAnnotations;
import org.smartregister.chw.malaria.contract.MalariaRegisterFragmentContract;
import org.smartregister.chw.malaria.presenter.BaseMalariaRegisterFragmentPresenter;
import org.smartregister.chw.malaria.util.Constants;
import org.smartregister.chw.malaria.util.DBConstants;

public class BaseMalariaRegisterFragmentPresenterTest {
@Mock
protected MalariaRegisterFragmentContract.View view;


@Mock
protected MalariaRegisterFragmentContract.Model model;

private BaseMalariaRegisterFragmentPresenter baseMalariaRegisterFragmentPresenter;

@Before
Expand All @@ -28,8 +33,25 @@ public void assertNotNull() {
}

@Test
public void testGetMainCondition() {
public void getMainCondition() {
Assert.assertEquals("", baseMalariaRegisterFragmentPresenter.getMainCondition());
}

@Test
public void getDueFilterCondition() {
Assert.assertEquals(" (cast( julianday(STRFTIME('%Y-%m-%d', datetime('now'))) - julianday(IFNULL(SUBSTR(malaria_test_date,7,4)|| '-' || SUBSTR(malaria_test_date,4,2) || '-' || SUBSTR(malaria_test_date,1,2),'')) as integer) between 7 and 14) ", baseMalariaRegisterFragmentPresenter.getDueFilterCondition());
}

@Test
public void getDefaultSortQuery() {
Assert.assertEquals(Constants.TABLES.MALARIA_CONFIRMATION + "." + DBConstants.KEY.LAST_INTERACTED_WITH + " DESC ", baseMalariaRegisterFragmentPresenter.getDefaultSortQuery());
}

@Test
public void getMainTable() {
Assert.assertEquals(Constants.TABLES.MALARIA_CONFIRMATION, baseMalariaRegisterFragmentPresenter.getMainTable());
}



}
Loading