Skip to content

Commit

Permalink
Merge pull request #60 from OpenSRP/malaria_profile_with_more_than_on…
Browse files Browse the repository at this point in the history
…e_visit

Malaria profile with more than one visit
  • Loading branch information
whoisladleo authored Oct 11, 2019
2 parents 58542ea + ff4c5fb commit e42d588
Show file tree
Hide file tree
Showing 12 changed files with 166 additions and 108 deletions.
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

0 comments on commit e42d588

Please sign in to comment.